choco
Class Formula

java.lang.Object
  extended by choco.Formula
All Implemented Interfaces:
Constraint, Entity, java.lang.Cloneable

public class Formula
extends java.lang.Object
implements Constraint

a class that is used to represent a syntatic formula involving unknowns. It is not a propagator (formulas have no behaviors, no semantic) By defaut, an AbstractModeler creates formulas instead of constraints


Field Summary
 int constraintOperator
          this slots characterizes the type of formula being stored (the predicate/relation/operator)
 java.lang.Object[] parameters
          storing the parameters of the constraint
 Var[] variables
          storing the variables (IntVar, SetVar, ...) involved in the constraint
 
Constructor Summary
Formula(Var v0, int c, int cop)
           
 
Method Summary
 java.lang.Object clone()
          returns a copy of the constraint.
 int getConstraintIdx(int idx)
          Network management: Among all listeners linked to the idx-th variable of c, find the index of constraint c.
 int getConstraintOperator()
           
 int getNbVars()
          Network management: Get the number of variables involved in the constraint.
 AbstractProblem getProblem()
          Retrieves the problem of the entity.
 Var getVar(int i)
          Network management: Accessing the ith variable of a constraint.
 int getVarIdxInOpposite(int i)
          computes the index of the i-th variable in the counter-opposite of the constraint
 boolean isEquivalentTo(Constraint compareTo)
          tests the equivalence (logical equality of the conditions) between two constraints.
 boolean isSatisfied()
          Semantic: Testing if the constraint is satisfied.
 AbstractConstraint opposite()
          computes the constraint modelling the counter-opposite condition of this
 java.lang.String pretty()
          pretty printing of the object.
 void setConstraintIndex(int i, int idx)
          Network management: Storing that among all listeners linked to the i-th variable of c, this (the current constraint) is found at index idx.
 void setVar(int i, Var v)
          Network management: Setting (or overwriting) the ith variable of a constraint.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

constraintOperator

public int constraintOperator
this slots characterizes the type of formula being stored (the predicate/relation/operator)


variables

public Var[] variables
storing the variables (IntVar, SetVar, ...) involved in the constraint


parameters

public java.lang.Object[] parameters
storing the parameters of the constraint

Constructor Detail

Formula

public Formula(Var v0,
               int c,
               int cop)
Method Detail

getNbVars

public int getNbVars()
Description copied from interface: Constraint
Network management: Get the number of variables involved in the constraint.

Specified by:
getNbVars in interface Constraint

getVar

public Var getVar(int i)
Description copied from interface: Constraint
Network management: Accessing the ith variable of a constraint.

Specified by:
getVar in interface Constraint
Parameters:
i - index of the variable in the constraint

setVar

public void setVar(int i,
                   Var v)
Description copied from interface: Constraint
Network management: Setting (or overwriting) the ith variable of a constraint.

Specified by:
setVar in interface Constraint
Parameters:
i - index of the variable in the constraint
v - the variable (may be an IntDomainVar, SetVar, RealVar, ...

isSatisfied

public boolean isSatisfied()
Description copied from interface: Constraint
Semantic: Testing if the constraint is satisfied. Note that all variables involved in the constraint must be instantiated when this method is called.

Specified by:
isSatisfied in interface Constraint

opposite

public AbstractConstraint opposite()
Description copied from interface: Constraint
computes the constraint modelling the counter-opposite condition of this

Specified by:
opposite in interface Constraint
Returns:
a new constraint (modelling the opposite condition)

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Description copied from interface: Constraint
returns a copy of the constraint. This copy is a new object, may be a recursive copy in case of composite constraints. The original and the copy share the same variables & plugins

Specified by:
clone in interface Constraint
Overrides:
clone in class java.lang.Object
Returns:
Throws:
java.lang.CloneNotSupportedException

getConstraintOperator

public int getConstraintOperator()

isEquivalentTo

public boolean isEquivalentTo(Constraint compareTo)
Description copied from interface: Constraint
tests the equivalence (logical equality of the conditions) between two constraints. In particular whenever c1.equals(c2), then c1.isEquivalent(c2).

Specified by:
isEquivalentTo in interface Constraint
Parameters:
compareTo - the constraint to be compared to
Returns:
true if and only if the constraints model the same logical condition.

getVarIdxInOpposite

public int getVarIdxInOpposite(int i)
Description copied from interface: Constraint
computes the index of the i-th variable in the counter-opposite of the constraint

Specified by:
getVarIdxInOpposite in interface Constraint
Parameters:
i - the index of the variable in the current constraint (this)
Returns:
the index of the variable in the opposite constraint (this.opposite())

setConstraintIndex

public void setConstraintIndex(int i,
                               int idx)
Description copied from interface: Constraint
Network management: Storing that among all listeners linked to the i-th variable of c, this (the current constraint) is found at index idx.

Specified by:
setConstraintIndex in interface Constraint
Parameters:
i - index of the variable in the constraint
idx - index of the constraint in the among all listeners linked to that variable

getConstraintIdx

public int getConstraintIdx(int idx)
Description copied from interface: Constraint
Network management: Among all listeners linked to the idx-th variable of c, find the index of constraint c.

Specified by:
getConstraintIdx in interface Constraint
Parameters:
idx - index of the variable in the constraint

getProblem

public AbstractProblem getProblem()
Description copied from interface: Entity
Retrieves the problem of the entity.

Specified by:
getProblem in interface Entity

pretty

public java.lang.String pretty()
Description copied from interface: Entity
pretty printing of the object. This String is not constant and may depend on the context.

Specified by:
pretty in interface Entity
Returns:
a readable string representation of the object