- java.lang.Object
-
- org.chocosolver.solver.learn.Implications
-
- org.chocosolver.solver.learn.LazyImplications
-
public class LazyImplications extends Implications
This implication graph is lazily built. It maintains the list of events invoked during propagation on each variable, and maintains a copy of each domain.Data is stored in a stack, where each entry is a tuple:
< v, D, c, m, p, n>
where :- v is the variable modified,
- D is its current domain,
- c is the cause (most of the time, a propagator),
- m is the mask of event that triggers the modification,
- p is a pointer to the previous entry on v in the stack
- n is a pointer to the next entry on v in the stack (if any)
Note that, under some conditions, two entries can be merged into a single one. Project: choco-solver.
- Since:
- 25/01/2017.
- Author:
- Charles Prud'homme
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
collectNodesFromConflict(ContradictionException cft, ValueSortedMap<IntVar> front)
Fill set with indices of nodes that throws the conflictvoid
copyComplementSet(IntVar var, IntIterableRangeSet set, IntIterableRangeSet dest)
Copy in dest the complement of set wrt to root domain of varvoid
findPredecessor(ValueSortedMap<IntVar> front, IntVar vi, int p)
Find the direct predecessor of a node, declared on variable vi, starting from node at position p.ICause
getCauseAt(int idx)
Get theICause
declared in node idxint
getDecisionLevelAt(int idx)
Get the decision level declared in node idxIntIterableRangeSet
getDomainAt(int idx)
Get theIntIterableRangeSet
that represents domain declared in node idxint
getEventMaskAt(int idx)
Get the mask of event declared in node idx.IntVar
getIntVarAt(int idx)
Get theIntVar
declared in node idxint
getPredecessorOf(int idx)
Get the position of precedent entry of the one declared in node idxIntIterableRangeSet
getRootDomain(IntVar var)
Get theIntIterableRangeSet
that represents domain of this variables as declared in the modelint
getValueAt(int idx)
Get the value declared in node idxvoid
init(Model model)
Initialize this classvoid
predecessorsOf(int p, ValueSortedMap<IntVar> front)
Retrieve the nodes that are predecessors of node p in this and put them into set.void
pushEvent(IntVar var, ICause cause, IntEventType evt, int one, int two, int three)
Push an eventvoid
reset()
Reset the model, set at its creation state, before callingImplications.init(Model)
.int
size()
void
tagDecisionLevel()
void
undoLastEvent()
Undo the last event stored, use only when dealing with views.
-
-
-
Method Detail
-
init
public void init(Model model)
Description copied from class:Implications
Initialize this class- Specified by:
init
in classImplications
- Parameters:
model
- if needed, a reference to the model that uses this class
-
reset
public void reset()
Description copied from class:Implications
Reset the model, set at its creation state, before callingImplications.init(Model)
.- Specified by:
reset
in classImplications
-
tagDecisionLevel
public void tagDecisionLevel()
- Specified by:
tagDecisionLevel
in classImplications
-
undoLastEvent
public void undoLastEvent()
Description copied from class:Implications
Undo the last event stored, use only when dealing with views.- Specified by:
undoLastEvent
in classImplications
-
pushEvent
public void pushEvent(IntVar var, ICause cause, IntEventType evt, int one, int two, int three)
Description copied from class:Implications
Push an event- Specified by:
pushEvent
in classImplications
- Parameters:
var
- modified variablecause
- cause of the modificationevt
- modification maskone
- an inttwo
- an intthree
- an int
-
size
public int size()
- Specified by:
size
in classImplications
- Returns:
- the number of nodes in the implication graph.
-
collectNodesFromConflict
public void collectNodesFromConflict(ContradictionException cft, ValueSortedMap<IntVar> front)
Description copied from class:Implications
Fill set with indices of nodes that throws the conflict- Specified by:
collectNodesFromConflict
in classImplications
- Parameters:
cft
- the failure, in the form of aContradictionException
front
- (initially empty) map of (node, variable) in conflict
-
predecessorsOf
public void predecessorsOf(int p, ValueSortedMap<IntVar> front)
Description copied from class:Implications
Retrieve the nodes that are predecessors of node p in this and put them into set.- Specified by:
predecessorsOf
in classImplications
- Parameters:
p
- index of the node whom predecessors have to be foundfront
- map of (node, variable) in conflict
-
findPredecessor
public void findPredecessor(ValueSortedMap<IntVar> front, IntVar vi, int p)
Find the direct predecessor of a node, declared on variable vi, starting from node at position p. If a variable-based node already exists in front, then this node is used to look for the predecessor, assuming that it is below p (otherwise, this node the predecessor we are looking for). Otherwise, there is no node based on vi in front and the rightmost node above p, starting from the predecessor of its root node, is added.- Specified by:
findPredecessor
in classImplications
- Parameters:
front
- the set to updatevi
- the variable to look the predecessor forp
- the rightmost position of the node (below means outdated node).
-
getCauseAt
public ICause getCauseAt(int idx)
Description copied from class:Implications
Get theICause
declared in node idx- Specified by:
getCauseAt
in classImplications
- Parameters:
idx
- position of the node to query- Returns:
- the cause declared in node idx
-
getEventMaskAt
public int getEventMaskAt(int idx)
Description copied from class:Implications
Get the mask of event declared in node idx. The mask can be a bitwise operation over mask ofIntEventType
.- Specified by:
getEventMaskAt
in classImplications
- Parameters:
idx
- position of the node to query- Returns:
- the event declared in node idx
-
getIntVarAt
public IntVar getIntVarAt(int idx)
Description copied from class:Implications
Get theIntVar
declared in node idx- Specified by:
getIntVarAt
in classImplications
- Parameters:
idx
- position of the node to query- Returns:
- the intvar declared in node idx
-
getValueAt
public int getValueAt(int idx)
Description copied from class:Implications
Get the value declared in node idx- Specified by:
getValueAt
in classImplications
- Parameters:
idx
- position of the node to query- Returns:
- the value declared in node idx
-
getDecisionLevelAt
public int getDecisionLevelAt(int idx)
Description copied from class:Implications
Get the decision level declared in node idx- Specified by:
getDecisionLevelAt
in classImplications
- Parameters:
idx
- position of the node to query- Returns:
- the decision level declared in node idx
-
getDomainAt
public IntIterableRangeSet getDomainAt(int idx)
Description copied from class:Implications
Get theIntIterableRangeSet
that represents domain declared in node idx- Specified by:
getDomainAt
in classImplications
- Parameters:
idx
- position of the node to query- Returns:
- the domain declared in node idx
-
getPredecessorOf
public int getPredecessorOf(int idx)
Description copied from class:Implications
Get the position of precedent entry of the one declared in node idx- Specified by:
getPredecessorOf
in classImplications
- Parameters:
idx
- position of the node to query- Returns:
- its ancestor
-
getRootDomain
public IntIterableRangeSet getRootDomain(IntVar var)
Description copied from class:Implications
Get theIntIterableRangeSet
that represents domain of this variables as declared in the model- Specified by:
getRootDomain
in classImplications
- Parameters:
var
- variable to query- Returns:
- the domain declared in node idx
-
copyComplementSet
public void copyComplementSet(IntVar var, IntIterableRangeSet set, IntIterableRangeSet dest)
Description copied from class:Implications
Copy in dest the complement of set wrt to root domain of var- Specified by:
copyComplementSet
in classImplications
- Parameters:
var
- variable to query
-
-