javax.constraints
Interface VarSet

All Superinterfaces:
ConstrainedVariable
All Known Implementing Classes:
BasicVarSet

public interface VarSet
extends ConstrainedVariable

This interface represents a constrained set variable which, when bound, is equal to a set of elements. The domain of a constrained set variable is a set of Sets that consist of regular integers.

The domain of a constrained set variable defines two sets:

  1. The Required Set: the set of the elements that belong to all the possible values of the variable (the lower bound);
  2. The Possible Set: the set of the elements that belong to at least one of the possible values of the variable (the upper bound). The required set is always a subset of the possible set. You may only remove elements from the possible set - method "remove". You may only add element to the required set - method "require".

The cardinality of a set constrained variable is an integer constrained variable.

You may define set intersections and unions.

See also Problem#elementAt(Set[], Var)


Method Summary
 boolean contains(java.util.Set<java.lang.Integer> setOfValues)
           
 Var getCardinality()
           
 java.util.Set<java.lang.Integer> getPossibleSet()
           
 java.util.Set<java.lang.Integer> getRequiredSet()
           
 java.util.Set<java.lang.Integer> getValue()
           
 VarSet intersection(VarSet varSet)
          Creates a new set variable that is an intersection of this set variable with the "varSet" passed as a parameter.
 boolean isBound()
           
 boolean isPossible(int value)
           
 boolean isRequired(int value)
           
 void remove(int value)
          Removes the "value' from the possible set
 void require(int val)
          Adds the "value" to the required set
 void setEmpty(boolean flag)
          Sets the cardinality of this set variable to be equals 0 if the flag is true, and to be more or equal 1 if the flag is false.
 void setValue(java.util.Set<java.lang.Integer> set)
          Instantiates this set variable with the constant "set" of integers.
 VarSet union(VarSet varSet)
          Creates a new set variable that is an union of this set variable with the "varSet" passed as a parameter.
 
Methods inherited from interface javax.constraints.ConstrainedVariable
getImpl, getName, getObject, getProblem, setImpl, setName, setObject
 

Method Detail

contains

boolean contains(java.util.Set<java.lang.Integer> setOfValues)
Parameters:
setOfValues -
Returns:
true if the possible set contains "setOfValues"

getCardinality

Var getCardinality()
Returns:
an integer constraint variable that represents a number of elements in the domain of this variable when it is instantiated

getPossibleSet

java.util.Set<java.lang.Integer> getPossibleSet()
Returns:
the possible set

getRequiredSet

java.util.Set<java.lang.Integer> getRequiredSet()
Returns:
the required set

getValue

java.util.Set<java.lang.Integer> getValue()
                                          throws java.lang.Exception
Returns:
a Set of integers in the required set
Throws:
java.lang.Exception - if this set variable in not bound

intersection

VarSet intersection(VarSet varSet)
                    throws java.lang.Exception
Creates a new set variable that is an intersection of this set variable with the "varSet" passed as a parameter.

Parameters:
varSet -
Returns:
a set variable
Throws:
java.lang.Exception

isBound

boolean isBound()
Returns:
true when all elements in the domain are required

isPossible

boolean isPossible(int value)
Returns:
true if the "value" belongs to the possible set

isRequired

boolean isRequired(int value)
Returns:
true if the "value" belongs to the required set

remove

void remove(int value)
            throws java.lang.Exception
Removes the "value' from the possible set

Parameters:
value -
Throws:
java.lang.Exception

require

void require(int val)
             throws java.lang.Exception
Adds the "value" to the required set

Parameters:
val -
Throws:
java.lang.Exception - if the value is outside of the possible set

setEmpty

void setEmpty(boolean flag)
Sets the cardinality of this set variable to be equals 0 if the flag is true, and to be more or equal 1 if the flag is false.

Parameters:
flag -

setValue

void setValue(java.util.Set<java.lang.Integer> set)
              throws java.lang.Exception
Instantiates this set variable with the constant "set" of integers. All integers that do not belong to the "set" will be removed from the possible set.

Parameters:
set -
Throws:
java.lang.Exception - if some values in the "set' are not possible

union

VarSet union(VarSet varSet)
             throws java.lang.Exception
Creates a new set variable that is an union of this set variable with the "varSet" passed as a parameter.

Parameters:
varSet -
Returns:
a set variable
Throws:
java.lang.Exception