edu.mit.sketch.ddg
Class Constraint

java.lang.Object
  extended by edu.mit.sketch.ddg.Constraint
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
BinaryRelationshipConstraint, ConnectsConstraint, PropertyConstraint

public abstract class Constraint
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

This abstract class represents the constraints on primitives. It contains a data structure that stores all the pairs of primitives between which a constraint holds. It provides methods dealing with this data structure that apply to any kinds of constraints. Subclasses should implement the methods that apply to particular constraints.

If the constraint represents a property instead of a relationship, the primitive will have a self loop in the constraint graph - the constraint holds between the primitive and itself.

Constraint.java Created: Sat Nov 21 18:26:00 2001

Author:
Olya Veselova
See Also:
Serialized Form

Constructor Summary
Constraint()
          Constructs an empty constraint graph.
 
Method Summary
abstract  java.lang.Object clone()
          Clone the constraint.
 ConstraintGraph constraintGraph()
          Returns the constraint graph
 ConstraintGraphEdgeList labelledEdgeList()
          Return the list of edges in the current constraint labelled with the name of a constraint.
 void mergeIn(Constraint other)
          Put the constraints that are in other into this one, if they are not already in the graph
abstract  java.lang.String name()
          Return the name of the constraint.
abstract  boolean orientationInvariant()
          Returns true if the constraint is orinetation invariant
 void print(java.io.PrintStream out, boolean printDetails)
          Print the constraint: name, graph.
 void removeLowConfidence(double confidenceThreshold)
          Remove constraints that are below the confidence threshold.
 void removeLowRelevance(double relevanceThreshold)
          Remove constraints that are below the relevance threshold.
 void renamePrimitives(PrimitiveMapping mapping, PrimitiveList relabelled)
          Rename the primitives in the following constraint according to the given mapping.
 boolean sameAs(Constraint other, PrimitiveMapping mapping)
          Verifies whether this constraint is the same as the other one given the mapping between primitives.
 void setConstraintGraph(ConstraintGraph graph)
          Sets the constraint graph
 Constraint subgraph(PrimitiveList primitiveList)
          Return a new constraint that is a subgraph of this one only for the primitives in the given list.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Constraint

public Constraint()
Constructs an empty constraint graph.

Method Detail

name

public abstract java.lang.String name()
Return the name of the constraint. Subclasses should implement this method. The name should be a unique identifier of a constraint in the system.


orientationInvariant

public abstract boolean orientationInvariant()
Returns true if the constraint is orinetation invariant


constraintGraph

public ConstraintGraph constraintGraph()
Returns the constraint graph


setConstraintGraph

public void setConstraintGraph(ConstraintGraph graph)
Sets the constraint graph


labelledEdgeList

public ConstraintGraphEdgeList labelledEdgeList()
Return the list of edges in the current constraint labelled with the name of a constraint. Returns an empty list if there are no edges.


renamePrimitives

public void renamePrimitives(PrimitiveMapping mapping,
                             PrimitiveList relabelled)
Rename the primitives in the following constraint according to the given mapping. The keys of the mapping are renamed to the values in the mapping.


mergeIn

public void mergeIn(Constraint other)
Put the constraints that are in other into this one, if they are not already in the graph


print

public void print(java.io.PrintStream out,
                  boolean printDetails)
Print the constraint: name, graph. Print confidence and relevance if the printDetails is true.


removeLowConfidence

public void removeLowConfidence(double confidenceThreshold)
Remove constraints that are below the confidence threshold. Also removes primitives that have no outgoing edges after the operation.


removeLowRelevance

public void removeLowRelevance(double relevanceThreshold)
Remove constraints that are below the relevance threshold. Also removes primitives that have no outgoing edges after the operation.


subgraph

public Constraint subgraph(PrimitiveList primitiveList)
Return a new constraint that is a subgraph of this one only for the primitives in the given list. It is ok for the list to contain primitives that are not in the constraint graph. They will just be ignored.


clone

public abstract java.lang.Object clone()
Clone the constraint. Subclasses should implement this method.

Overrides:
clone in class java.lang.Object

sameAs

public boolean sameAs(Constraint other,
                      PrimitiveMapping mapping)
Verifies whether this constraint is the same as the other one given the mapping between primitives. The first primitive in the mapping pair is from the other object and the second is from this.