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 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.10
  • 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

      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 interface ExitChildListener<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 interface ExitChildListener<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 interface ExitChildListener<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 interface ExitChildListener<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 interface ExitChildListener<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 interface ExitChildListener<T extends Var>
      Parameters:
      child - added child listener.