jpaul.Constraints.SetConstraints
Class IntersectConstraint<T>

java.lang.Object
  extended by jpaul.Constraints.Constraint<SVar<T>,java.util.Set<T>>
      extended by jpaul.Constraints.SetConstraints.IntersectConstraint<T>

public class IntersectConstraint<T>
extends Constraint<SVar<T>,java.util.Set<T>>

IntersectConstraint models a set intersection constraint. Mathematically, such a constraint has the form:

vIn1 /\ vIn2 <= vDest
where /\ stands for set intersection, <= stands for set inclusion, and vIn1, vIn2, vDest are set-valued variables.

Version:
$Id: IntersectConstraint.java,v 1.6 2006/03/14 02:29:30 salcianu Exp $
Author:
Alexandru Salcianu - salcianu@alum.mit.edu

Field Summary
 
Fields inherited from class jpaul.Constraints.Constraint
AVG_COST, HIGH_COST, LOW_COST, VERY_LOW_COST
 
Constructor Summary
IntersectConstraint(SVar<T> vIn1, SVar<T> vIn2, SVar<T> vDest)
          Creates a IntersectConstraint with the meaning vIn1 /\ vIn2 <= vDest.
 
Method Summary
 void action(SolAccessor<SVar<T>,java.util.Set<T>> sa)
          Performs the action attached to this constraint.
 int cost()
          Returns HIGH_COST.
 boolean equals(java.lang.Object o)
           
 int hashCode()
           
 java.util.Collection<SVar<T>> in()
           
 java.util.Collection<SVar<T>> out()
           
 Constraint<SVar<T>,java.util.Set<T>> rewrite(UnionFind<SVar<T>> uf)
          We implemented rewrite(jpaul.DataStructs.UnionFind>), equals(java.lang.Object), and hashCode, such that constraints that are identical after variable unification are not duplicated needlessly.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IntersectConstraint

public IntersectConstraint(SVar<T> vIn1,
                           SVar<T> vIn2,
                           SVar<T> vDest)
Creates a IntersectConstraint with the meaning vIn1 /\ vIn2 <= vDest.

Method Detail

in

public java.util.Collection<SVar<T>> in()
Specified by:
in in class Constraint<SVar<T>,java.util.Set<T>>
Returns:
List of variables whose values may be read in order to construct the values of the outputs.

out

public java.util.Collection<SVar<T>> out()
Specified by:
out in class Constraint<SVar<T>,java.util.Set<T>>
Returns:
List of variables whose values may be affected by this constraint.

cost

public int cost()
Returns HIGH_COST.

Overrides:
cost in class Constraint<SVar<T>,java.util.Set<T>>

action

public void action(SolAccessor<SVar<T>,java.util.Set<T>> sa)
Description copied from class: Constraint
Performs the action attached to this constraint. The action should have the following form:
  1. Read the values of several in-variables using sa.get.
  2. Compute some values.
  3. Use sa.join to join the computed values to several out-variables.

Note1: It is a serious mistake to write an action method that reads/modifies variables that are not listed in the collections returned by in()/out(). If you ever suspect such an error, please set ConstraintSystem.CHECK_IN_OUT to true.

Note2: The solver initializes each variable to null (null is considered equivalent to the bottom element of the correspoding lattice). The body of action should be prepared to receive a null result from sa.get.

Specified by:
action in class Constraint<SVar<T>,java.util.Set<T>>
Parameters:
sa - Provides access to the values of the variables that are read/modified.

rewrite

public Constraint<SVar<T>,java.util.Set<T>> rewrite(UnionFind<SVar<T>> uf)
We implemented rewrite(jpaul.DataStructs.UnionFind>), equals(java.lang.Object), and hashCode, such that constraints that are identical after variable unification are not duplicated needlessly.

Overrides:
rewrite in class Constraint<SVar<T>,java.util.Set<T>>
Parameters:
uf - Union-find structure; for each variable v, uf.find(v) is the representative of its equivalence class.

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright 2005 Alexandru Salcianu - salcianu@alum.mit.edu