net.sf.cpsolver.ifs.example.csp
Class CSPBinaryConstraint

java.lang.Object
  extended by net.sf.cpsolver.ifs.model.Constraint<V,T>
      extended by net.sf.cpsolver.ifs.model.BinaryConstraint<CSPVariable,CSPValue>
          extended by net.sf.cpsolver.ifs.example.csp.CSPBinaryConstraint
All Implemented Interfaces:
Comparable<Constraint<CSPVariable,CSPValue>>

public class CSPBinaryConstraint
extends BinaryConstraint<CSPVariable,CSPValue>

CSP binary constraint.

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

Version:
IFS 1.2 (Iterative Forward Search)
Copyright (C) 2006 - 2010 Tomas Muller
muller@unitime.org
http://muller.unitime.org

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not see http://www.gnu.org/licenses/.

Field Summary
 
Fields inherited from class net.sf.cpsolver.ifs.model.Constraint
iAssignedVariables, iConstraintListeners, iId
 
Constructor Summary
CSPBinaryConstraint(int id, int nrCompatiblePairs)
          Constructor
 
Method Summary
 void computeConflicts(CSPValue aValue, Set<CSPValue> 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(CSPValue value1, CSPValue value2)
          True if the pair of given values is compatible.
 
Methods inherited from class net.sf.cpsolver.ifs.model.BinaryConstraint
addVariable, another, first, isFirst, second
 
Methods inherited from class net.sf.cpsolver.ifs.model.Constraint
addConstraintListener, assigned, assignedVariables, compareTo, constraintListeners, countAssignedVariables, countVariables, equals, getDescription, getId, getModel, hashCode, inConflict, isHard, removeConstraintListener, removeVariable, setModel, unassigned, variables
 
Methods inherited from class java.lang.Object
clone, 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(CSPValue value1,
                            CSPValue value2)
True if the pair of given values is compatible.

Overrides:
isConsistent in class Constraint<CSPVariable,CSPValue>

computeConflicts

public void computeConflicts(CSPValue aValue,
                             Set<CSPValue> 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<CSPVariable,CSPValue>
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<CSPVariable,CSPValue>


Copyright © 2014 UniTime LLC. All Rights Reserved.