Class OneSolution<T extends Var>

java.lang.Object
org.jacop.search.SimpleSolutionListener<T>
org.jacop.search.OneSolution<T>
All Implemented Interfaces:
ConsistencyListener, InitializeListener, SolutionListener<T>

public class OneSolution<T extends Var> extends SimpleSolutionListener<T> implements ConsistencyListener, InitializeListener
Defines functionality for OneSolution plug-in, that is the search with this plug-in will stop after funding first solution. Each call to this search will restore the functionality and the search will again search for a single solution.
Version:
4.10
  • Field Details

    • solutionFound

      boolean solutionFound
    • childrenConsistencyListeners

      ConsistencyListener[] childrenConsistencyListeners
    • childrenInitializeListeners

      InitializeListener[] childrenInitializeListeners
  • Constructor Details

    • OneSolution

      public OneSolution()
  • Method Details

    • executedAtInitialize

      public void executedAtInitialize(Store store)
      Description copied from interface: InitializeListener
      It is executed before the search starts labeling procedure.
      Specified by:
      executedAtInitialize in interface InitializeListener
      Parameters:
      store - store in which context the search is performed.
    • setChildrenListeners

      public void setChildrenListeners(InitializeListener[] children)
      It sets the children listeners of this initialize listener.
      Specified by:
      setChildrenListeners in interface InitializeListener
      Parameters:
      children - children listeners
    • setChildrenListeners

      public void setChildrenListeners(InitializeListener child)
      It sets one child listener for this initialize listener.
      Specified by:
      setChildrenListeners in interface InitializeListener
      Parameters:
      child - the child of this initialize listener.
    • executeAfterSolution

      public boolean executeAfterSolution(Search<T> search, SelectChoicePoint<T> select)
      Description copied from interface: SolutionListener
      It is executed by search after a solution is found.
      Specified by:
      executeAfterSolution in interface SolutionListener<T extends Var>
      Overrides:
      executeAfterSolution in class SimpleSolutionListener<T extends Var>
      Parameters:
      search - the search which have found a solution.
      select - the select choice point heuristic
      Returns:
      false forces the search to keep looking for a solution, true then the search will accept a solution.
    • executeAfterConsistency

      public boolean executeAfterConsistency(boolean consistent)
      Description copied from interface: ConsistencyListener
      It 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:
      executeAfterConsistency in interface ConsistencyListener
      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.
    • setChildrenListeners

      public void setChildrenListeners(ConsistencyListener[] children)
      Description copied from interface: ConsistencyListener
      Each of the child listeners will be called and the return code from them will be combined (taken into account) by a parent).
      Specified by:
      setChildrenListeners in interface ConsistencyListener
      Parameters:
      children - the children listeners attached to this listener.
    • setChildrenListeners

      public void setChildrenListeners(ConsistencyListener child)
      Description copied from interface: ConsistencyListener
      Setting one child listener.
      Specified by:
      setChildrenListeners in interface ConsistencyListener
      Parameters:
      child - the only child listener added to this consistency listener.