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>
public class LDS<T extends Var> extends java.lang.Object implements 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
Fields Modifier and Type Field Description (package private) ExitChildListener<T>[]
exitChildListeners
(package private) int
maxNoDiscrepancies
(package private) int
noDiscrepancies
(package private) boolean
recentExitingLeftChildGoingForDiscrepancy
(package private) boolean
recentExitingRightChild
(package private) boolean
timeOut
-
Constructor Summary
Constructors Constructor Description LDS(int maxDiscrepancies)
The search will not be allowed to deviate more than maxDiscrepancies times from the heuristic (e.g.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
leftChild(PrimitiveConstraint choice, boolean status)
It is executed after exiting the left child.boolean
leftChild(T var, int value, boolean status)
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 Detail
-
timeOut
boolean timeOut
-
noDiscrepancies
int noDiscrepancies
-
maxNoDiscrepancies
int maxNoDiscrepancies
-
recentExitingLeftChildGoingForDiscrepancy
boolean recentExitingLeftChildGoingForDiscrepancy
-
recentExitingRightChild
boolean recentExitingRightChild
-
exitChildListeners
ExitChildListener<T extends Var>[] exitChildListeners
-
-
Method Detail
-
leftChild
public boolean leftChild(T var, int value, boolean status)
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
public boolean leftChild(PrimitiveConstraint choice, boolean status)
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
public void rightChild(T var, int value, boolean status)
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
public void rightChild(PrimitiveConstraint choice, boolean status)
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
public void setChildrenListeners(ExitChildListener<T>[] children)
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
public void setChildrenListeners(ExitChildListener<T> child)
Description copied from interface:ExitChildListener
It adds one child listener.- Specified by:
setChildrenListeners
in interfaceExitChildListener<T extends Var>
- Parameters:
child
- added child listener.
-
-