Class PropMultiCostRegular
- java.lang.Object
-
- org.chocosolver.solver.constraints.Propagator<IntVar>
-
- org.chocosolver.solver.constraints.nary.automata.PropMultiCostRegular
-
- All Implemented Interfaces:
Comparable<Propagator>,ICause,Identity
public final class PropMultiCostRegular extends Propagator<IntVar>
Created by IntelliJ IDEA. User: julien S Date: Jul 16, 2008 Time: 5:56:50 PM Multi-Cost-Regular is a propagator for the constraint ensuring that, given : an automaton Pi; a sequence of domain variables X; a set of bound variables Z; a assignment cost matrix for each bound variable C; The word formed by the sequence of assigned variables is accepted by Pi; for each z^k in Z, sum_i(C_i(x_k)k) = z^k AC is NP hard for such a constraint. The propagation is based on a Lagrangian Relaxation approach of the underlying Resource constrained shortest/longest path problems
-
-
Field Summary
Fields Modifier and Type Field Description double_MCR_DECIMAL_PRECgnu.trove.map.hash.TObjectIntHashMap<IntVar>mapMap to retrieve rapidly the index of a given variable.static intMAXBOUNDITERMaximum number of iteration during a bound computationstatic intMAXNONIMPROVEITERMaximum number of non improving iteration while computing a boundstatic doubleROLagrangian multiplier decreasing factorstatic doubleU0Constant coefficient of the lagrangian relaxation-
Fields inherited from class org.chocosolver.solver.constraints.Propagator
constraint, model, priority, reactToFineEvt, vars
-
-
Constructor Summary
Constructors Constructor Description PropMultiCostRegular(IntVar[] variables, IntVar[] costvariables, ICostAutomaton cauto, double precision)Constructs a multi-cost-regular propagator
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancheck()Necessary condition : checks whether the constraint is violted or notbooleancheck(int[] word)protected voidcheckWorld()voidcomputeSharpBounds()Iteratively compute upper and lower bound for the underlying RCSPPprotected voiddelayedGraphUpdate()Updates the graphs w.r.t. the caught event during event-based propagationprotected voidfilterDown(double realsp)Filters w.r.t. a given lower bound.protected voidfilterUp(double reallp)Filters w.r.t. a given upper bound.voidforcePathRecomputation()StoredDirectedMultiGraphgetGraph()double[]getInstantiatedLayerCosts(int layer)int[]getMinMaxPathCostForAssignment(int col, int val, int... resources)intgetMinPathCost(int... resources)intgetMinPathCostForAssignment(int col, int val, int... resources)intgetPropagationConditions(int vIdx)Returns the specific mask indicating the variable events on which thisPropagatorobject can react.
A mask is a bitwise OR operations overIEventTypethis can react on.intgetRegret(int layer, int value, int... resources)protected voidinitialize()Build internal structure of the propagator, if necessaryESatisEntailed()Check wetherthisis entailed according to the current state of its internal structure.booleanisGraphConsistent()booleanisSatisfied()booleanneedPropagation()protected booleanprefilter()Performs cost based filtering w.r.t. each cost dimension.voidpropagate(int evtmask)Call the main filtering algorithm to apply to theDomainof theVariableobjects.voidpropagate(int varIdx, int mask)Incremental filtering algorithm defined within thePropagator, called whenever the variable of index idxVarInProp has changed.voidrebuildCostRegInfo()protected voidupdateLowerBound()Performs a lagrangian relaxation to compute a new Lower bound of the underlying RCSPP problem Each built subproblem is a shortest path one can use to perform cost based filteringprotected voidupdateUpperBound()Performs a lagrangian relaxation to compute a new Upper bound of the underlying RCSPP problem Each built subproblem is a longest path one can use to perform cost based filtering-
Methods inherited from class org.chocosolver.solver.constraints.Propagator
addVariable, arity, compareTo, doFinePropagation, doFlush, doSchedule, doScheduleEvent, dynPriority, equals, fails, forcePropagate, forcePropagationOnBacktrack, getConstraint, getId, getModel, getNbVars, getPosition, getPriority, getVar, getVars, getVIndice, getVIndices, hashCode, isActive, isCompletelyInstantiated, isPassive, isReifiedAndSilent, isStateLess, linkVariables, reactToFineEvent, setActive, setPassive, setPosition, setReifiedSilent, setReifiedTrue, setVIndices, toString, unlinkVariables, unschedule, why
-
-
-
-
Field Detail
-
MAXBOUNDITER
public static final int MAXBOUNDITER
Maximum number of iteration during a bound computation- See Also:
- Constant Field Values
-
MAXNONIMPROVEITER
public static final int MAXNONIMPROVEITER
Maximum number of non improving iteration while computing a bound- See Also:
- Constant Field Values
-
U0
public static final double U0
Constant coefficient of the lagrangian relaxation- See Also:
- Constant Field Values
-
RO
public static final double RO
Lagrangian multiplier decreasing factor- See Also:
- Constant Field Values
-
map
public final gnu.trove.map.hash.TObjectIntHashMap<IntVar> map
Map to retrieve rapidly the index of a given variable.
-
_MCR_DECIMAL_PREC
public final double _MCR_DECIMAL_PREC
-
-
Constructor Detail
-
PropMultiCostRegular
public PropMultiCostRegular(IntVar[] variables, IntVar[] costvariables, ICostAutomaton cauto, double precision)
Constructs a multi-cost-regular propagator- Parameters:
variables- decision variablescostvariables- cost variablescauto- finite automaton with costs
-
-
Method Detail
-
getPropagationConditions
public int getPropagationConditions(int vIdx)
Description copied from class:PropagatorReturns the specific mask indicating the variable events on which thisPropagatorobject can react.
A mask is a bitwise OR operations overIEventTypethis can react on. For example, consider a propagator that can deduce filtering based on the lower bound of the integer variable X. Then, for this variable, the mask should be equal to :int mask = IntEventType.INCLOW.getMask() | IntEventType.INSTANTIATE.getMask();or, in a more convenient way:int mask = IntEvtType.combine(IntEventType.INCLOW,IntEventType.INSTANTIATE);That indicates the following behavior:- if X is instantiated, this propagator will be executed,
- if the lower bound of X is modified, this propagator will be executed,
- if the lower bound of X is removed, the event is promoted from REMOVE to INCLOW and this propagator will NOT be executed,
- otherwise, this propagator will NOT be executed
IntEventType.VOIDwhich states that this propagator should not be aware of modifications applied to the variable in position vIdx.- Overrides:
getPropagationConditionsin classPropagator<IntVar>- Parameters:
vIdx- index of the variable within the propagator- Returns:
- an int composed of
REMOVEand/orINSTANTIATEand/orDECUPPand/orINCLOW
-
initialize
protected void initialize() throws ContradictionExceptionBuild internal structure of the propagator, if necessary- Throws:
ContradictionException- if initialisation encounters a contradiction
-
propagate
public void propagate(int evtmask) throws ContradictionExceptionDescription copied from class:PropagatorCall the main filtering algorithm to apply to theDomainof theVariableobjects. It considers the current state of this objects to remove some values from domains and/or instantiate some variables. Calling this method is done from 2 (and only 2) steps:
- at the initial propagation step,
- when involved in a reified constraint.
It should initialized the internal data structure and apply filtering algorithm from scratch.- Specified by:
propagatein classPropagator<IntVar>- Parameters:
evtmask- type of propagation eventthismust consider.- Throws:
ContradictionException- when a contradiction occurs, like domain wipe out or other incoherencies.
-
propagate
public void propagate(int varIdx, int mask) throws ContradictionExceptionDescription copied from class:PropagatorIncremental filtering algorithm defined within thePropagator, called whenever the variable of index idxVarInProp has changed. This method calls a CUSTOM_PROPAGATION (coarse-grained) by default.This method should be overridden if the argument
reactToFineEvtis set totruein the constructor. Otherwise, it executespropagate(PropagatorEventType.CUSTOM_PROPAGATION.getStrengthenedMask());- Overrides:
propagatein classPropagator<IntVar>- Parameters:
varIdx- index of the variablevarinthismask- type of event- Throws:
ContradictionException- if a contradiction occurs
-
updateUpperBound
protected void updateUpperBound() throws ContradictionExceptionPerforms a lagrangian relaxation to compute a new Upper bound of the underlying RCSPP problem Each built subproblem is a longest path one can use to perform cost based filtering- Throws:
ContradictionException- if a domain becomes empty
-
updateLowerBound
protected void updateLowerBound() throws ContradictionExceptionPerforms a lagrangian relaxation to compute a new Lower bound of the underlying RCSPP problem Each built subproblem is a shortest path one can use to perform cost based filtering- Throws:
ContradictionException- if a domain becomes empty
-
prefilter
protected boolean prefilter() throws ContradictionExceptionPerforms cost based filtering w.r.t. each cost dimension.- Throws:
ContradictionException- if a domain is emptied
-
filterDown
protected void filterDown(double realsp) throws ContradictionExceptionFilters w.r.t. a given lower bound.- Parameters:
realsp- a given lower bound- Throws:
ContradictionException- if the cost variable domain is emptied
-
filterUp
protected void filterUp(double reallp) throws ContradictionExceptionFilters w.r.t. a given upper bound.- Parameters:
reallp- a given upper bound- Throws:
ContradictionException- if the cost variable domain is emptied
-
checkWorld
protected void checkWorld() throws ContradictionException- Throws:
ContradictionException
-
delayedGraphUpdate
protected void delayedGraphUpdate() throws ContradictionExceptionUpdates the graphs w.r.t. the caught event during event-based propagation- Throws:
ContradictionException- if removing an edge causes a domain to be emptied
-
computeSharpBounds
public void computeSharpBounds() throws ContradictionExceptionIteratively compute upper and lower bound for the underlying RCSPP- Throws:
ContradictionException- if a domain gets empty
-
rebuildCostRegInfo
public void rebuildCostRegInfo() throws ContradictionException- Throws:
ContradictionException
-
needPropagation
public final boolean needPropagation()
-
isGraphConsistent
public boolean isGraphConsistent()
-
getGraph
public final StoredDirectedMultiGraph getGraph()
-
getRegret
public final int getRegret(int layer, int value, int... resources)
-
isEntailed
public ESat isEntailed()
Description copied from class:PropagatorCheck wetherthisis entailed according to the current state of its internal structure. At least, should check the satisfaction ofthis(when all is instantiated).- Specified by:
isEntailedin classPropagator<IntVar>- Returns:
- ESat.TRUE if entailed, ESat.FALSE if not entailed, ESat.UNDEFINED if unknown
-
isSatisfied
public boolean isSatisfied()
-
check
public boolean check(int[] word)
-
check
public boolean check()
Necessary condition : checks whether the constraint is violted or not- Returns:
- true if the constraint is not violated
-
getMinPathCostForAssignment
public int getMinPathCostForAssignment(int col, int val, int... resources)
-
getMinMaxPathCostForAssignment
public int[] getMinMaxPathCostForAssignment(int col, int val, int... resources)
-
getMinPathCost
public int getMinPathCost(int... resources)
-
getInstantiatedLayerCosts
public double[] getInstantiatedLayerCosts(int layer)
-
forcePathRecomputation
public void forcePathRecomputation() throws ContradictionException- Throws:
ContradictionException
-
-