ifs.example.csp
Class CSPBinaryConstraint

java.lang.Object
  extended by ifs.model.Constraint
      extended by ifs.model.BinaryConstraint
          extended by ifs.example.csp.CSPBinaryConstraint

public class CSPBinaryConstraint
extends BinaryConstraint

CSP binary constraint.

This class only implements the generation of a binary CSP constraint and the consistency check.

Version:
1.0
Author:
Tomáš Müller

Constructor Summary
CSPBinaryConstraint(int id, int nrCompatiblePairs)
          Constructor
 
Method Summary
 void computeConflicts(Value aValue, Set conflicts)
          Add the other variable to the set of conflicts, if it is not compatible with the given value.
 String getName()
          Constraint's name -- for printing purposes
 void init(Random rndNumGen)
          Initializes the constraint.
 boolean isConsistent(Value value1, Value value2)
          True if the pair of given values is compatible.
 
Methods inherited from class ifs.model.BinaryConstraint
addVariable, another, first, isFirst, second
 
Methods inherited from class ifs.model.Constraint
addConstraintListener, assigned, assignedVariables, countAssignedVariables, countVariables, getDescription, getId, getInfo, getModel, hashCode, inConflict, isHard, removeConstraintListener, removeVariable, setModel, unassigned, variables
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CSPBinaryConstraint

public CSPBinaryConstraint(int id,
                           int nrCompatiblePairs)
Constructor

Parameters:
nrCompatiblePairs - number of compatible pairs of values in the constraint
Method Detail

init

public void init(Random rndNumGen)
Initializes the constraint. Randomly generates the given number of compatible pairs of values.

Parameters:
rndNumGen - random number generator

isConsistent

public boolean isConsistent(Value value1,
                            Value value2)
True if the pair of given values is compatible.

Overrides:
isConsistent in class Constraint

computeConflicts

public void computeConflicts(Value aValue,
                             Set conflicts)
Add the other variable to the set of conflicts, if it is not compatible with the given value.

Specified by:
computeConflicts in class Constraint
Parameters:
aValue - value to be assigned to its varaible
conflicts - resultant set of conflicting values

getName

public String getName()
Description copied from class: Constraint
Constraint's name -- for printing purposes

Overrides:
getName in class Constraint


Copyright © 2005 Tomáš Müller