Package org.jacop.search
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.7
-
-
Field Summary
Fields Modifier and Type Field Description (package private) ConsistencyListener[]
childrenConsistencyListeners
(package private) InitializeListener[]
childrenInitializeListeners
(package private) boolean
solutionFound
-
Fields inherited from class org.jacop.search.SimpleSolutionListener
alwaysUpdateToMostRecentSolution, childrenSolutionListeners, noSolutions, parentSolutionListener, parentSolutionNo, recordSolutions, solutionLimit, solutions, vars
-
-
Constructor Summary
Constructors Constructor Description OneSolution()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
executeAfterConsistency(boolean consistent)
It is executed right after consistency of the current search node.boolean
executeAfterSolution(Search<T> search, SelectChoicePoint<T> select)
It is executed by search after a solution is found.void
executedAtInitialize(Store store)
It is executed before the search starts labeling procedure.void
setChildrenListeners(ConsistencyListener child)
Setting one child listener.void
setChildrenListeners(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).void
setChildrenListeners(InitializeListener child)
It sets one child listener for this initialize listener.void
setChildrenListeners(InitializeListener[] children)
It sets the children listeners of this initialize listener.-
Methods inherited from class org.jacop.search.SimpleSolutionListener
assignSolution, assignSolution, findSolutionMatchingParent, getParentSolution, getSolution, getSolutions, getVariables, isRecordingSolutions, printAllSolutions, recordSolution, recordSolutions, returnSolution, returnSolution, searchAll, setChildrenListeners, setChildrenListeners, setParentSolutionListener, setSolutionLimit, setSolutionsNo, setVariables, solutionLimitReached, solutionsNo, toString
-
-
-
-
Field Detail
-
solutionFound
boolean solutionFound
-
childrenConsistencyListeners
ConsistencyListener[] childrenConsistencyListeners
-
childrenInitializeListeners
InitializeListener[] childrenInitializeListeners
-
-
Method Detail
-
executedAtInitialize
public void executedAtInitialize(Store store)
Description copied from interface:InitializeListener
It is executed before the search starts labeling procedure.- Specified by:
executedAtInitialize
in interfaceInitializeListener
- 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 interfaceInitializeListener
- Parameters:
children
- children listeners
-
setChildrenListeners
public void setChildrenListeners(InitializeListener child)
It sets one child listener for this initialize listener.- Specified by:
setChildrenListeners
in interfaceInitializeListener
- 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 interfaceSolutionListener<T extends Var>
- Overrides:
executeAfterSolution
in classSimpleSolutionListener<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 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.
-
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 interfaceConsistencyListener
- 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 interfaceConsistencyListener
- Parameters:
child
- the only child listener added to this consistency listener.
-
-