choco.cp.solver.constraints.integer
Class IntLinComb

java.lang.Object
  extended by choco.kernel.solver.propagation.Propagator
      extended by choco.kernel.solver.constraints.AbstractSConstraint<IntDomainVar>
          extended by choco.kernel.solver.constraints.integer.AbstractIntSConstraint
              extended by choco.kernel.solver.constraints.integer.AbstractLargeIntSConstraint
                  extended by choco.cp.solver.constraints.integer.IntLinComb
All Implemented Interfaces:
IExtensionnable, IPretty, SConstraint<IntDomainVar>, IntPropagator, Cloneable, EventListener

public final class IntLinComb
extends AbstractLargeIntSConstraint

Implements a constraint Sigma (ai Xi) <=/>=/= C, with Xi variables, ai and C constants.


Field Summary
static int EQ
          Constant, to be assigned to op, representing linear equalities.
static int GEQ
          Constant, to be assigned to op, representing linear inequalities.
protected  IntLinCombOp intlincomb
          Filter based on the operator
static int LEQ
          Constant, to be assigned to op, representing linear inequalities.
protected  int nbPosVars
          Field representing the number of variables with positive coeffficients in the linear combination.
static int NEQ
          Constant, to be assigned to op, representing linear disequalities.
 
Fields inherited from class choco.kernel.solver.constraints.AbstractSConstraint
cIndices, constraintType, extensions, vars
 
Fields inherited from class choco.kernel.solver.propagation.Propagator
active, constAwakeEvent, priority, propagationEngine
 
Fields inherited from interface choco.kernel.solver.constraints.SConstraint
LOGGER
 
Constructor Summary
IntLinComb(IntDomainVar[] lvars, int[] lcoeffs, int nbPositive, int c, int linOperator)
          Constructs the constraint with the specified variables and constant.
 
Method Summary
 void awakeOnInf(int idx)
          Propagation whenever the lower bound of a variable is modified.
 void awakeOnInst(int idx)
          Propagation whenever a variable is instantiated.
 void awakeOnRem(int idx, int x)
          Propagation whenever a value is removed from the variable domain.
 void awakeOnRemovals(int idx, DisposableIntIterator deltaDomain)
          The default implementation of propagation when a variable has been modified consists in iterating all values that have been removed (the delta domain) and propagate them one after another, incrementally.
 void awakeOnSup(int idx)
          Propagation whenever the upper bound of a variable is modified.
 int getFilteredEventMask(int idx)
           
 boolean isSatisfied(int[] tuple)
          Checks if the constraint is satisfied when all variables are instantiated.
 AbstractSConstraint<IntDomainVar> opposite(Solver solver)
          Get the opposite constraint
 String pretty()
          pretty printing of the object.
 void propagate()
          Launchs the filtering algorithm.
 
Methods inherited from class choco.kernel.solver.constraints.integer.AbstractIntSConstraint
awakeOnBounds, getConstraintType, isConsistent, isSatisfied
 
Methods inherited from class choco.kernel.solver.constraints.AbstractSConstraint
addExtension, addListener, clone, getAbstractSConstraintExtensionNumber, getConstraintIdx, getExtension, getFineDegree, getNbVarNotInst, getNbVars, getVar, getVarQuick, isCompletelyInstantiated, isEntailed, setConstraintIndex, setExtension, setVar, toString
 
Methods inherited from class choco.kernel.solver.propagation.Propagator
activate, awake, constAwake, fail, getEvent, getPriority, isActive, setActive, setActiveSilently, setEntailed, setPassive, setPropagationEngine
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EQ

public static final int EQ
Constant, to be assigned to op, representing linear equalities.

See Also:
Constant Field Values

GEQ

public static final int GEQ
Constant, to be assigned to op, representing linear inequalities.

See Also:
Constant Field Values

NEQ

public static final int NEQ
Constant, to be assigned to op, representing linear disequalities.

See Also:
Constant Field Values

LEQ

public static final int LEQ
Constant, to be assigned to op, representing linear inequalities. Only used vby BoolIntLinComb

See Also:
Constant Field Values

nbPosVars

protected final int nbPosVars
Field representing the number of variables with positive coeffficients in the linear combination.


intlincomb

protected final IntLinCombOp intlincomb
Filter based on the operator

Constructor Detail

IntLinComb

public IntLinComb(IntDomainVar[] lvars,
                  int[] lcoeffs,
                  int nbPositive,
                  int c,
                  int linOperator)
Constructs the constraint with the specified variables and constant. Use the Model.createIntLinComb API instead of this constructor. This constructor assumes that there are no null coefficient and that the positive coefficients come before the negative ones.

Parameters:
lvars - the variables of the constraint
lcoeffs - the constant coefficients
nbPositive - number of positive coefficients
c - the constant value of the constraint (the value the linear expression must equal)
linOperator - the operator to use (equality, inequality...)
Method Detail

getFilteredEventMask

public int getFilteredEventMask(int idx)
Overrides:
getFilteredEventMask in class Propagator

propagate

public void propagate()
               throws ContradictionException
Launchs the filtering algorithm.

Specified by:
propagate in class Propagator
Throws:
ContradictionException - if a domain empties or a contradiction is infered

awakeOnInf

public void awakeOnInf(int idx)
                throws ContradictionException
Propagation whenever the lower bound of a variable is modified.

Specified by:
awakeOnInf in interface IntPropagator
Overrides:
awakeOnInf in class AbstractIntSConstraint
Parameters:
idx - the index of the modified variable
Throws:
ContradictionException - if a domain empties or a contradiction is infered

awakeOnSup

public void awakeOnSup(int idx)
                throws ContradictionException
Propagation whenever the upper bound of a variable is modified.

Specified by:
awakeOnSup in interface IntPropagator
Overrides:
awakeOnSup in class AbstractIntSConstraint
Parameters:
idx - the index of the modified variable
Throws:
ContradictionException - if a domain empties or a contradiction is infered

awakeOnInst

public void awakeOnInst(int idx)
                 throws ContradictionException
Propagation whenever a variable is instantiated.

Specified by:
awakeOnInst in interface IntPropagator
Overrides:
awakeOnInst in class AbstractIntSConstraint
Parameters:
idx - the index of the modified variable
Throws:
ContradictionException - if a domain empties or a contradiction is infered

awakeOnRem

public void awakeOnRem(int idx,
                       int x)
                throws ContradictionException
Propagation whenever a value is removed from the variable domain.

Specified by:
awakeOnRem in interface IntPropagator
Overrides:
awakeOnRem in class AbstractIntSConstraint
Parameters:
idx - the index of the modified variable
x - the removed value
Throws:
ContradictionException - if a domain empties or a contradiction is infered

awakeOnRemovals

public void awakeOnRemovals(int idx,
                            DisposableIntIterator deltaDomain)
                     throws ContradictionException
Description copied from class: AbstractIntSConstraint
The default implementation of propagation when a variable has been modified consists in iterating all values that have been removed (the delta domain) and propagate them one after another, incrementally.

Specified by:
awakeOnRemovals in interface IntPropagator
Overrides:
awakeOnRemovals in class AbstractIntSConstraint
Throws:
ContradictionException

isSatisfied

public boolean isSatisfied(int[] tuple)
Checks if the constraint is satisfied when all variables are instantiated.

Specified by:
isSatisfied in interface IntPropagator
Overrides:
isSatisfied in class AbstractIntSConstraint
Returns:
true if the constraint is satisfied

opposite

public AbstractSConstraint<IntDomainVar> opposite(Solver solver)
Get the opposite constraint

Specified by:
opposite in interface SConstraint<IntDomainVar>
Overrides:
opposite in class AbstractSConstraint<IntDomainVar>
Parameters:
solver - the current solver
Returns:
the opposite constraint @param solver

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
Overrides:
pretty in class AbstractSConstraint<IntDomainVar>
Returns:
a readable string representation of the object


Copyright © 2012. All Rights Reserved.