Class Shaving<T extends IntVar>
- All Implemented Interfaces:
ConsistencyListener,ExitChildListener<T>
Shaving
Each search level stores the variable value pairs which were shaved at a given level.
Shaving speculation.
The right child is using all the shavable pairs from the subtree rooted at the sibling of the current search node. If shaving fails then it is recorded in non shavable.
Not-shavable speculation
Every time a variable value pair is being schedule for shavability check then it is checked if that pair was not already checked for shavability before with a negative results. If so, then check is not performed but also entry in not-shavable is removed.
If variable value pair proofs to be not shavable then this variable value pair is recorded into Not-shavable speculation.
Quick shave - upon exiting any subtree the variable value pair which was choosen at the root of that subtree is recorded as shavable variable value pair.
- Version:
- 4.10
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ConsistencyListener[]private intprivate ExitChildListener<T>[]intIt stores number of failed shaving attempts.(package private) booleanIt specifies if the search is in the left child.(package private) booleanprivate boolean(package private) Map<IntVar, LinkedHashSet<Integer>> booleanIt specifies if only the last failed constraint is allowed to suggest shaving values.booleanIt specifies if only variables in the scope of the last failed constraint are allowed to be used in shaving attempts.booleanIt specifies if the quickShave approach should be also used.(package private) Constraint(package private) boolean(package private) List<Map<IntVar, LinkedHashSet<Integer>>> (package private) List<Constraint> It contains list of constraints which suggest shaving explorations.(package private) StoreIt specifies current store, so shaving can obtained information about recent failed constraint.intIt stores number of successful shaving attempts.It stores the variables of the last failed constraints.(package private) boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidIt adds shaving constraint to the list of constraints guiding shaving.(package private) booleancheckIfShavable(IntVar var, Integer val) booleanexecuteAfterConsistency(boolean consistent) It is executed right after consistency of the current search node.booleanleftChild(PrimitiveConstraint choice, boolean status) It is executed after exiting the left child.booleanIt is executed after exiting the left child.voidrightChild(PrimitiveConstraint choice, boolean status) It is executed after exiting the right child.voidrightChild(IntVar var, int value, boolean status) It is executed after exiting the right child.voidSetting one child listener.voidsetChildrenListeners(ConsistencyListener[] children) Each of the child listeners will be called and the return code from them will be combined (taken into account) by a parent).voidsetChildrenListeners(ExitChildListener<T> child) It adds one child listener.voidsetChildrenListeners(ExitChildListener<T>[] children) It sets the children listeners for the current listener.voidIt specifies the constraint store in which context the shaving will take place.
-
Field Details
-
shavingConstraints
List<Constraint> shavingConstraintsIt contains list of constraints which suggest shaving explorations. -
leftChild
boolean leftChildIt specifies if the search is in the left child. -
store
Store storeIt specifies current store, so shaving can obtained information about recent failed constraint. -
recentlyFailedConstraint
Constraint recentlyFailedConstraint -
leftChildShaving
boolean leftChildShaving -
onlyFailedConstraint
public boolean onlyFailedConstraintIt specifies if only the last failed constraint is allowed to suggest shaving values. -
rightChild
boolean rightChild -
onlyIntVarsOfFailedConstraint
public boolean onlyIntVarsOfFailedConstraintIt specifies if only variables in the scope of the last failed constraint are allowed to be used in shaving attempts. -
varsOfFailedConstraint
It stores the variables of the last failed constraints. -
wrongDecisionEncountered
boolean wrongDecisionEncountered -
exitChildListeners
-
consistencyListeners
-
quickShave
public boolean quickShaveIt specifies if the quickShave approach should be also used. Quickshave uses variable-value pairs which lead to wrong decisions as shaving values higher in the search tree (until the first time shaving attempt for this value fails). -
leftChildWrongDecision
private boolean leftChildWrongDecision -
depth
private int depth -
shavable
List<Map<IntVar,LinkedHashSet<Integer>>> shavable -
notShavable
Map<IntVar,LinkedHashSet<Integer>> notShavable -
successes
public int successesIt stores number of successful shaving attempts. -
failures
public int failuresIt stores number of failed shaving attempts.
-
-
Constructor Details
-
Shaving
public Shaving()
-
-
Method Details
-
leftChild
Description copied from interface:ExitChildListenerIt is executed after exiting the left child.- Specified by:
leftChildin interfaceExitChildListener<T extends IntVar>- Parameters:
var- variable used in the choice point.value- value used in the choice point.status- true if the solution was found in the child subtree, false otherwise.- Returns:
- true if the search should continue undisturbed, false if it should exit the current node with false
-
leftChild
Description copied from interface:ExitChildListenerIt is executed after exiting the left child.- Specified by:
leftChildin interfaceExitChildListener<T extends IntVar>- Parameters:
choice- primitive constraint used as the base of the choice point.status- true if the solution was found in the child subtree, false otherwise.- Returns:
- true if the search should continue undisturbed to the right node, false if it should exit the current node with false
-
rightChild
Description copied from interface:ExitChildListenerIt is executed after exiting the right child.- Specified by:
rightChildin interfaceExitChildListener<T extends IntVar>- Parameters:
var- variable used in the choice point.value- value used in the choice point.status- true if the solution was found in the child subtree, false otherwise. exit the current node with false
-
rightChild
Description copied from interface:ExitChildListenerIt is executed after exiting the right child.- Specified by:
rightChildin interfaceExitChildListener<T extends IntVar>- Parameters:
choice- primitive constraint used as the base of the choice point.status- true if the solution was found in the child subtree, false otherwise. exit the current node with false
-
setChildrenListeners
Description copied from interface:ConsistencyListenerEach of the child listeners will be called and the return code from them will be combined (taken into account) by a parent).- Specified by:
setChildrenListenersin interfaceConsistencyListener- Parameters:
children- the children listeners attached to this listener.
-
setChildrenListeners
Description copied from interface:ExitChildListenerIt sets the children listeners for the current listener.- Specified by:
setChildrenListenersin interfaceExitChildListener<T extends IntVar>- Parameters:
children- array containing children listeners.
-
setChildrenListeners
Description copied from interface:ConsistencyListenerSetting one child listener.- Specified by:
setChildrenListenersin interfaceConsistencyListener- Parameters:
child- the only child listener added to this consistency listener.
-
setChildrenListeners
Description copied from interface:ExitChildListenerIt adds one child listener.- Specified by:
setChildrenListenersin interfaceExitChildListener<T extends IntVar>- Parameters:
child- added child listener.
-
executeAfterConsistency
public boolean executeAfterConsistency(boolean consistent) Description copied from interface:ConsistencyListenerIt is executed right after consistency of the current search node. Returning true when the parameter was false is not advised as things like invalid solutions can be found.- Specified by:
executeAfterConsistencyin interfaceConsistencyListener- Parameters:
consistent- specifies if the consistency call returned true or false.- Returns:
- true if the search should continue, false if the search should act as the consistency returned false.
-
checkIfShavable
-
addShavingConstraint
It adds shaving constraint to the list of constraints guiding shaving.- Parameters:
c- constraint which is added to the list of guiding constraints.
-
setStore
It specifies the constraint store in which context the shaving will take place.- Parameters:
store- constraint store.
-