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.9
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) ConsistencyListener[]
(package private) InitializeListener[]
(package private) boolean
Fields inherited from class org.jacop.search.SimpleSolutionListener
alwaysUpdateToMostRecentSolution, childrenSolutionListeners, noSolutions, parentSolutionListener, parentSolutionNo, recordSolutions, solutionLimit, solutions, vars
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
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
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
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 Details
-
solutionFound
boolean solutionFound -
childrenConsistencyListeners
ConsistencyListener[] childrenConsistencyListeners -
childrenInitializeListeners
InitializeListener[] childrenInitializeListeners
-
-
Constructor Details
-
OneSolution
public OneSolution()
-
-
Method Details
-
executedAtInitialize
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
It sets the children listeners of this initialize listener.- Specified by:
setChildrenListeners
in interfaceInitializeListener
- Parameters:
children
- children listeners
-
setChildrenListeners
It sets one child listener for this initialize listener.- Specified by:
setChildrenListeners
in interfaceInitializeListener
- Parameters:
child
- the child of this initialize listener.
-
executeAfterSolution
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
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
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.
-