choco.kernel.solver.constraints
Class Formula

java.lang.Object
  extended by choco.kernel.solver.constraints.Formula
All Implemented Interfaces:
IExtensionnable, IPretty, SConstraint, Cloneable

public class Formula
extends Object
implements SConstraint

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
           
 Object[] parameters
          storing the parameters of the constraint
static int TIMES_XYZ
           
 Var[] variables
          storing the variables (IntVar, SetVar, ...) involved in the constraint
 
Fields inherited from interface choco.kernel.solver.constraints.SConstraint
LOGGER
 
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
 void addExtension(int extensionNumber)
          Adds a new extension.
 Object clone()
           
 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()
           
 SConstraintType getConstraintType()
          Return the type of constraint, ie the type of variable involved in the constraint
 Extension getExtension(int extensionNumber)
          Returns the queried extension
 int getFineDegree(int idx)
          Some global constraint might be able to provide some fine grained information about the "real" degree of a variables.
 int getNbVars()
          Network management: Get the number of variables involved in the constraint.
 Var getVar(int i)
          Network management: Accessing the ith variable of a constraint.
 Var getVarQuick(int i)
          Network management: Accessing the ith variable of a constraint.
 boolean isSatisfied()
          Semantic: Testing if the constraint is satisfied.
 AbstractSConstraint opposite(Solver solver)
          computes the constraint modelling the counter-opposite condition of this
 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 final int EQUAL_XC
possible static values for the constraintOperator field

See Also:
Constant Field Values

NOT_EQUAL_XC

public static final int NOT_EQUAL_XC
See Also:
Constant Field Values

GREATER_OR_EQUAL_XC

public static final int GREATER_OR_EQUAL_XC
See Also:
Constant Field Values

LESS_OR_EQUAL_XC

public static final int LESS_OR_EQUAL_XC
See Also:
Constant Field Values

EQUAL_XYC

public static final int EQUAL_XYC
See Also:
Constant Field Values

NOT_EQUAL_XYC

public static final int NOT_EQUAL_XYC
See Also:
Constant Field Values

GREATER_OR_EQUAL_XYC

public static final int GREATER_OR_EQUAL_XYC
See Also:
Constant Field Values

TIMES_XYZ

public static final int TIMES_XYZ
See Also:
Constant Field Values

INT_LIN_COMB

public static final int INT_LIN_COMB
See Also:
Constant Field Values

OCCURRENCE

public static final int OCCURRENCE
See Also:
Constant Field Values

ALL_DIFFERENT

public static final int ALL_DIFFERENT
See Also:
Constant Field Values

GLOBAL_CARDINALITY

public static final int GLOBAL_CARDINALITY
See Also:
Constant Field Values

NTH

public static final int NTH
See Also:
Constant Field Values

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 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: SConstraint
Network management: Get the number of variables involved in the constraint.

Specified by:
getNbVars in interface SConstraint
Returns:
number of variables involved in the constraint

getVar

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

Specified by:
getVar in interface SConstraint
Parameters:
i - index of the variable in the constraint
Returns:
the i^th variable involved in the constraint

getVarQuick

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

Specified by:
getVarQuick in interface SConstraint
Parameters:
i - index of the variable in the constraint
Returns:
the i^th variable involved in the constraint

setVar

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

Specified by:
setVar in interface SConstraint
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: SConstraint
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 SConstraint
Returns:
true if the constraint is satisfied

opposite

public AbstractSConstraint opposite(Solver solver)
Description copied from interface: SConstraint
computes the constraint modelling the counter-opposite condition of this

Specified by:
opposite in interface SConstraint
Parameters:
solver - the current solver
Returns:
a new constraint (modelling the opposite condition) @param solver

clone

public Object clone()
             throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException

getConstraintOperator

public int getConstraintOperator()

setConstraintIndex

public void setConstraintIndex(int i,
                               int idx)
Description copied from interface: SConstraint
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 SConstraint
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: SConstraint
Network management: Among all listeners linked to the idx-th variable of c, find the index of constraint c.

Specified by:
getConstraintIdx in interface SConstraint
Parameters:
idx - index of the variable in the constraint
Returns:
index of the constraint within the variable network

pretty

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

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

getConstraintType

public SConstraintType getConstraintType()
Return the type of constraint, ie the type of variable involved in the constraint

Specified by:
getConstraintType in interface SConstraint
Returns:

getExtension

public Extension getExtension(int extensionNumber)
Description copied from interface: IExtensionnable
Returns the queried extension

Specified by:
getExtension in interface IExtensionnable
Parameters:
extensionNumber - should use the number returned by getAbstractSConstraintExtensionNumber
Returns:
the queried extension

addExtension

public void addExtension(int extensionNumber)
Adds a new extension.

Specified by:
addExtension in interface IExtensionnable
Parameters:
extensionNumber - should use the number returned by getAbstractSConstraintExtensionNumber

getFineDegree

public int getFineDegree(int idx)
Description copied from interface: SConstraint
Some global constraint might be able to provide some fine grained information about the "real" degree of a variables. For example the global constraint on clauses can give the real number of clauses on each variable

Specified by:
getFineDegree in interface SConstraint
Parameters:
idx - index of the variable in the constraint
Returns:
a weight given to the variable by the constraint


Copyright © 2012. All Rights Reserved.