Package org.jacop.search
Class LDS<T extends Var>
java.lang.Object
org.jacop.search.LDS<T>
- Type Parameters:
T
- type of variable being used in the search.
- All Implemented Interfaces:
ExitChildListener<T>
Defines functionality of limited discrepancy search. Plugin in this object to
search to change your depth first search into limited discrepancy search.
- Version:
- 4.8
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) ExitChildListener<T>[]
(package private) int
(package private) int
(package private) boolean
(package private) boolean
(package private) boolean
-
Constructor Summary
ConstructorsConstructorDescriptionLDS
(int maxDiscrepancies) The search will not be allowed to deviate more than maxDiscrepancies times from the heuristic (e.g. -
Method Summary
Modifier and TypeMethodDescriptionboolean
leftChild
(PrimitiveConstraint choice, boolean status) It is executed after exiting the left child.boolean
It is executed after exiting the left child.void
rightChild
(PrimitiveConstraint choice, boolean status) It is executed after exiting the right child.void
rightChild
(T var, int value, boolean status) Exiting the right children requires reduction of the current number of discrepancies being used.void
setChildrenListeners
(ExitChildListener<T> child) It adds one child listener.void
setChildrenListeners
(ExitChildListener<T>[] children) It sets the children listeners for the current listener.
-
Field Details
-
timeOut
boolean timeOut -
noDiscrepancies
int noDiscrepancies -
maxNoDiscrepancies
int maxNoDiscrepancies -
recentExitingLeftChildGoingForDiscrepancy
boolean recentExitingLeftChildGoingForDiscrepancy -
recentExitingRightChild
boolean recentExitingRightChild -
exitChildListeners
ExitChildListener<T extends Var>[] exitChildListeners
-
-
Constructor Details
-
LDS
public LDS(int maxDiscrepancies) The search will not be allowed to deviate more than maxDiscrepancies times from the heuristic (e.g. variable and value ordering) in the search.- Parameters:
maxDiscrepancies
- maximal number of discrepancies allowed.
-
-
Method Details
-
leftChild
It is executed after exiting the left child. The parameters specify the variable and value used in the choice point. The parameter status specifies the return code from the child. The return parameter of this function specifies if the search should continue undisturbed or exit the current search node with value false.- Specified by:
leftChild
in interfaceExitChildListener<T extends Var>
- 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
It is executed after exiting the left child. The parameters specify the choice point. The parameter status specifies the return code from the child. The return parameter of this function specifies if the search should continue undisturbed or exit the current search node with false. If the continuing to the right child will exceed the number of allowed discrepancies then this function will return false so the right child will not be explored.- Specified by:
leftChild
in interfaceExitChildListener<T extends Var>
- 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
Exiting the right children requires reduction of the current number of discrepancies being used.- Specified by:
rightChild
in interfaceExitChildListener<T extends Var>
- 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:ExitChildListener
It is executed after exiting the right child.- Specified by:
rightChild
in interfaceExitChildListener<T extends Var>
- 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:ExitChildListener
It sets the children listeners for the current listener.- Specified by:
setChildrenListeners
in interfaceExitChildListener<T extends Var>
- Parameters:
children
- array containing children listeners.
-
setChildrenListeners
Description copied from interface:ExitChildListener
It adds one child listener.- Specified by:
setChildrenListeners
in interfaceExitChildListener<T extends Var>
- Parameters:
child
- added child listener.
-