choco.cp.solver.constraints.integer.bool
Class BoolIntLinComb

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.bool.BoolIntLinComb
All Implemented Interfaces:
IExtensionnable, IPretty, SConstraint<IntDomainVar>, IntPropagator, Cloneable, EventListener

public final class BoolIntLinComb
extends AbstractLargeIntSConstraint

A constraint to enforce Sigma_i coef[i]*x_i + k OP y_i where : - OP belongs to >=, <=, = - k is a constant - x_i are boolean variable - t_i is an enum variable It improves the general IntLinComb by storing lower and upper bound of the expression and sorting coefficient for filtering. User: Hadrien Date: 29 oct. 2006


Nested Class Summary
 class BoolIntLinComb.RightMemberBounds
           
 class BoolIntLinComb.SimpleRightMemberBounds
           
 
Field Summary
protected  int addcste
          coefficients of the integer variable
protected  IStateInt lb
          Lower bound of the expression
protected  IStateInt maxNegCoeff
          index of the maximum coefficient of negative sign
protected  IStateInt maxPosCoeff
          index of the maximum coefficient of positive sign
protected  int nbNegCoef
          number of negative coefficients
protected  int objCoef
          coefficients of the integer variable
protected  int op
          Field representing the type of linear constraint (equality, inequality, disequality).
protected  BoolIntLinComb.RightMemberBounds rmemb
           
protected  int[] sCoeffs
          coefs and vars are sorted in increasing value of the coef
protected  IStateInt ub
          upper bound of the expression
 
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
BoolIntLinComb(IEnvironment environment, IntDomainVar[] vs, int[] coefs, IntDomainVar c, int objcoef, int scste, int op)
          Constructs the constraint with the specified variables and constant.
 
Method Summary
 void awakeOnInf(int idx)
          Default propagation on improved lower bound: propagation on domain revision.
 void awakeOnInst(int idx)
          ********************************************************************
 void awakeOnSup(int idx)
          Default propagation on improved upper bound: propagation on domain revision.
protected  int computeLbFromScratch()
          Computes a lower bound estimate of a linear combination of variables.
protected  int computeUbFromScratch()
          Computes an upper bound estimate of a linear combination of variables.
 boolean filterNegCoeffLb()
          enforce variables that would otherwise make the upper bound unreachable
 boolean filterNegCoeffUb()
           
 boolean filterPosCoeffLb()
          ********************************************************************
 boolean filterPosCoeffUb()
           
 void fixPointOnEQ()
           
 int getFilteredEventMask(int idx)
           
protected  boolean hasConsistentLowerBound()
          Tests if the constraint is consistent with respect to the current state of domains.
protected  boolean hasConsistentUpperBound()
          Tests if the constraint is consistent with respect to the current state of domains.
 void initlb()
           
 void initUb()
           
 boolean isConsistent()
          Tests if the constraint is consistent with respect to the current state of domains.
 Boolean isEntailed()
          Checks if the constraint is entailed.
 boolean isSatisfied(int[] tuple)
          TEMPORARY: if not overriden by the constraint, throws an error to avoid bug using reified constraints in constraints that have not been changed to fulfill this api yet !
 void lookForNewMaxNegCoeff()
           
 void lookForNewMaxPosCoeff()
           
static IntDomainVar[] makeTableVar(IntDomainVar[] vs, IntDomainVar v)
           
 AbstractSConstraint<IntDomainVar> opposite(Solver solver)
          Computes the opposite of this constraint.
 String pretty()
          pretty printing of the object.
 void propagate()
          Propagation: Propagating the constraint until local consistency is reached.
 void propagateEQ()
           
 void propagateGEQ()
           
 void propagateLEQ()
           
 boolean updateForGEQ()
          ********************************************************************
 boolean updateForLEQ()
           
 void updateUbLbOnInst(int idx, int i)
          ********************************************************************
 
Methods inherited from class choco.kernel.solver.constraints.integer.AbstractIntSConstraint
awakeOnBounds, awakeOnRem, awakeOnRemovals, getConstraintType, isSatisfied
 
Methods inherited from class choco.kernel.solver.constraints.AbstractSConstraint
addExtension, addListener, clone, getAbstractSConstraintExtensionNumber, getConstraintIdx, getExtension, getFineDegree, getNbVarNotInst, getNbVars, getVar, getVarQuick, isCompletelyInstantiated, 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

op

protected int op
Field representing the type of linear constraint (equality, inequality, disequality).


lb

protected IStateInt lb
Lower bound of the expression


ub

protected IStateInt ub
upper bound of the expression


maxPosCoeff

protected IStateInt maxPosCoeff
index of the maximum coefficient of positive sign


maxNegCoeff

protected IStateInt maxNegCoeff
index of the maximum coefficient of negative sign


sCoeffs

protected final int[] sCoeffs
coefs and vars are sorted in increasing value of the coef


nbNegCoef

protected int nbNegCoef
number of negative coefficients


objCoef

protected final int objCoef
coefficients of the integer variable


addcste

protected final int addcste
coefficients of the integer variable


rmemb

protected final BoolIntLinComb.RightMemberBounds rmemb
Constructor Detail

BoolIntLinComb

public BoolIntLinComb(IEnvironment environment,
                      IntDomainVar[] vs,
                      int[] coefs,
                      IntDomainVar c,
                      int objcoef,
                      int scste,
                      int op)
Constructs the constraint with the specified variables and constant. Use the Model.createIntLinComb API instead of this constructor. WARNING : This constructor assumes : - there are no null coefficient - coefficients "coefs" are sorted from the smallest to the biggest (negative coefs first). - objcoef is strictly POSITIVE - op belongs to EQ, GT, NEQ and LEQ

Method Detail

makeTableVar

public static IntDomainVar[] makeTableVar(IntDomainVar[] vs,
                                          IntDomainVar v)

getFilteredEventMask

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

updateUbLbOnInst

public final void updateUbLbOnInst(int idx,
                                   int i)
********************************************************************


lookForNewMaxPosCoeff

public final void lookForNewMaxPosCoeff()

lookForNewMaxNegCoeff

public final void lookForNewMaxNegCoeff()

updateForGEQ

public final boolean updateForGEQ()
                           throws ContradictionException
********************************************************************

Throws:
ContradictionException

updateForLEQ

public final boolean updateForLEQ()
                           throws ContradictionException
Throws:
ContradictionException

fixPointOnEQ

public final void fixPointOnEQ()
                        throws ContradictionException
Throws:
ContradictionException

filterNegCoeffUb

public boolean filterNegCoeffUb()
                         throws ContradictionException
Throws:
ContradictionException

filterPosCoeffUb

public boolean filterPosCoeffUb()
                         throws ContradictionException
Throws:
ContradictionException

filterPosCoeffLb

public final boolean filterPosCoeffLb()
                               throws ContradictionException
********************************************************************

Throws:
ContradictionException

filterNegCoeffLb

public final boolean filterNegCoeffLb()
                               throws ContradictionException
enforce variables that would otherwise make the upper bound unreachable

Throws:
ContradictionException

awakeOnInst

public void awakeOnInst(int idx)
                 throws ContradictionException
********************************************************************

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

awakeOnInf

public void awakeOnInf(int idx)
                throws ContradictionException
Description copied from class: AbstractIntSConstraint
Default propagation on improved lower bound: propagation on domain revision.

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

awakeOnSup

public void awakeOnSup(int idx)
                throws ContradictionException
Description copied from class: AbstractIntSConstraint
Default propagation on improved upper bound: propagation on domain revision.

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

propagate

public void propagate()
               throws ContradictionException
Description copied from class: Propagator
Propagation: Propagating the constraint until local consistency is reached.

Specified by:
propagate in class Propagator
Throws:
ContradictionException - contradiction exception

propagateEQ

public void propagateEQ()
                 throws ContradictionException
Throws:
ContradictionException

propagateGEQ

public void propagateGEQ()
                  throws ContradictionException
Throws:
ContradictionException

propagateLEQ

public void propagateLEQ()
                  throws ContradictionException
Throws:
ContradictionException

initUb

public final void initUb()

initlb

public final void initlb()

isConsistent

public boolean isConsistent()
Tests if the constraint is consistent with respect to the current state of domains.

Overrides:
isConsistent in class AbstractIntSConstraint
Returns:
true iff the constraint is bound consistent (weaker than arc consistent)

hasConsistentUpperBound

protected boolean hasConsistentUpperBound()
Tests if the constraint is consistent with respect to the current state of domains.

Returns:
true iff the constraint is bound consistent (weaker than arc consistent)

hasConsistentLowerBound

protected boolean hasConsistentLowerBound()
Tests if the constraint is consistent with respect to the current state of domains.

Returns:
true iff the constraint is bound consistent (weaker than arc consistent)

isEntailed

public Boolean isEntailed()
Checks if the constraint is entailed.

Overrides:
isEntailed in class AbstractSConstraint<IntDomainVar>
Returns:
Boolean.TRUE if the constraint is satisfied, Boolean.FALSE if it is violated, and null if the filtering algorithm cannot infer yet.

isSatisfied

public boolean isSatisfied(int[] tuple)
Description copied from class: AbstractIntSConstraint
TEMPORARY: if not overriden by the constraint, throws an error to avoid bug using reified constraints in constraints that have not been changed to fulfill this api yet !

Specified by:
isSatisfied in interface IntPropagator
Overrides:
isSatisfied in class AbstractIntSConstraint

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

opposite

public AbstractSConstraint<IntDomainVar> opposite(Solver solver)
Computes the opposite of this constraint.

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

computeUbFromScratch

protected final int computeUbFromScratch()
Computes an upper bound estimate of a linear combination of variables.

Returns:
the new upper bound value

computeLbFromScratch

protected final int computeLbFromScratch()
Computes a lower bound estimate of a linear combination of variables.

Returns:
the new lower bound value


Copyright © 2012. All Rights Reserved.