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
static int ALL_DIFFERENT
           
 int constraintOperator
          this slots characterizes the type of formula being stored (the predicate/relation/operator)
static int EQUAL_XC
          possible static values for the constraintOperator field
static int EQUAL_XYC
           
static int GLOBAL_CARDINALITY
           
static int GREATER_OR_EQUAL_XC
           
static int GREATER_OR_EQUAL_XYC
           
static int INT_LIN_COMB
           
static int LESS_OR_EQUAL_XC
           
static int NOT_EQUAL_XC
           
static int NOT_EQUAL_XYC
           
static int NTH
           
static int OCCURRENCE
           
 java.lang.Object[] parameters
          storing the parameters of the constraint
static int TIMES_XYZ
           
 Var[] variables
          storing the variables (IntVar, SetVar, ...) involved in the constraint
 
Constructor Summary
Formula(Var[] vars, int[] coeffs, int c1, int c2, int cop)
           
Formula(Var[] vars, int[] coeffs, int c1, int c2, int c3, int cop)
           
Formula(Var v0, int c, int cop)
           
Formula(Var v0, Var v1, int c, int cop)
           
Formula(Var v0, Var v1, Var v2, 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

EQUAL_XC

public static int EQUAL_XC
possible static values for the constraintOperator field


NOT_EQUAL_XC

public static int NOT_EQUAL_XC

GREATER_OR_EQUAL_XC

public static int GREATER_OR_EQUAL_XC

LESS_OR_EQUAL_XC

public static int LESS_OR_EQUAL_XC

EQUAL_XYC

public static int EQUAL_XYC

NOT_EQUAL_XYC

public static int NOT_EQUAL_XYC

GREATER_OR_EQUAL_XYC

public static int GREATER_OR_EQUAL_XYC

TIMES_XYZ

public static int TIMES_XYZ

INT_LIN_COMB

public static int INT_LIN_COMB

OCCURRENCE

public static int OCCURRENCE

ALL_DIFFERENT

public static int ALL_DIFFERENT

GLOBAL_CARDINALITY

public static int GLOBAL_CARDINALITY

NTH

public static int NTH

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)

Formula

public Formula(Var v0,
               Var v1,
               int c,
               int cop)

Formula

public Formula(Var v0,
               Var v1,
               Var v2,
               int cop)

Formula

public Formula(Var[] vars,
               int[] coeffs,
               int c1,
               int c2,
               int cop)

Formula

public Formula(Var[] vars,
               int[] coeffs,
               int c1,
               int c2,
               int c3,
               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