Package org.jacop.search
Interface Search<T extends Var>
- Type Parameters:
T- type of variables used in this search.
- All Known Implementing Classes:
DepthFirstSearch,PrioritySearch,PrioritySearch.LinkingSearch
public interface Search<T extends Var>
All searches needs to implement this interface in order to be manipulable by
a large variety of search listeners. Of course, the search which implements
this interface will need to call appropriate functions of attached listeners
in the right place and act accordingly to the output of listeners.
- Version:
- 4.10
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddChildSearch(Search<? extends Var> child) It adds another child search to this one.booleanIt assigns the last solution.booleanassignSolution(int no) The first solution has index 0.intIt returns number of backtracks performed by the search.It returns the root of the Consistency Listener.intIt returns the value of the cost int variable for the best solution.doubleIt returns the value of the cost float variable for the best solution.It returns the cost variable.intIt returns number of decisions performed by the search.It returns the root of the ExitChildListener.It returns the root of the ExitListener.It returns the root of the InitializationListener.intIt returns the maximum depth reached by a search.intgetNodes()It returns number of search nodes explored by the search.Domain[]It returns the solution (an assignment of values to variables).Domain[]getSolution(int no) It returns the solution specified by the search.It returns the root Solution Listener.It returns the root of the TimeOutListener.T[]It returns the order of variables used by functions returning a solution in terms of the values.intIt returns number of wrong decisions performed by the search.id()It returns the string id of the search.booleanlabel(int firstVariable) This function is called recursively to assign variables one by one.booleanlabeling()It performs search, first by setting up the internal items/attributes of search, followed later by a call to labeling function with argument specifying the index of the first not grounded variable.booleanlabeling(Store store, SelectChoicePoint<T> select) It performs search using supplied choice point selection heuristic.booleanlabeling(Store store, SelectChoicePoint<T> select, Var costVar) It performs search using supplied choice point selection heuristic, as well as costVariable as aim at finding an optimal solution.voidIt prints all solutions.voidsetAssignSolution(boolean value) It decides if a solution is assigned to store after search exits.voidsetBacktracksOut(long out) It turns on the backtrack out.voidsetChildSearch(Search<? extends Var>[] child) It specifies the sub-searches for the current search.voidsetConsistencyListener(ConsistencyListener listener) It sets the root of the Consistency Listener.voidsetCostVar(Var cost) It sets the reference to the cost variable.voidsetDecisionsOut(long out) It turns on the decisions out.voidsetExitChildListener(ExitChildListener<T> listener) It sets the root of the ExitChild listener.voidsetExitListener(ExitListener listener) It sets the root of the Exit Listener.voidsetInitializeListener(InitializeListener listener) It sets the root of the InitializeListener.voidsetMasterSearch(Search<? extends Var> master) If the search is called by a master search then the search may need to obtain some information about the master search.voidsetNodesOut(long out) It turns on the nodes out.voidsetOptimize(boolean value) It sets the optimization flag.voidsetPrintInfo(boolean value) It decides if information about search is printed.voidsetSelectChoicePoint(SelectChoicePoint<T> select) It sets the select choice point object.voidsetSolutionListener(SolutionListener<T> listener) It returns the root of the SolutionListener.voidIt sets the reference to the store in the context of which the search operates.voidsetTimeOut(long out) It turns on the timeout.voidsetTimeOutListener(TimeOutListener listener) It sets the root of the TimeOutListener.voidsetTimeOutMilliseconds(long out) It turns on the timeout.voidsetWrongDecisionsOut(long out) It turns on the wrong decisions out.toString()
-
Method Details
-
setChildSearch
It specifies the sub-searches for the current search. In order for the current search to succeed at least one of those must succeed. If there are no sub-searches then the current search succeeds if all variables within select choice point object are assigned and all constraints attached to those variables are satisfied.- Parameters:
child- the array containing all children searches.
-
addChildSearch
It adds another child search to this one.- Parameters:
child- the search which is being added as child search.
-
getBacktracks
int getBacktracks()It returns number of backtracks performed by the search.- Returns:
- the number of backtracks.
-
getCostVariable
Var getCostVariable()It returns the cost variable.- Returns:
- cost variable.
-
getCostValue
int getCostValue()It returns the value of the cost int variable for the best solution.- Returns:
- the cost value.
-
getCostValueFloat
double getCostValueFloat()It returns the value of the cost float variable for the best solution.- Returns:
- the cost value.
-
setOptimize
void setOptimize(boolean value) It sets the optimization flag.- Parameters:
value- true if the search should optimize, false otherwise.
-
getDecisions
int getDecisions()It returns number of decisions performed by the search.- Returns:
- the number of decisions.
-
getMaximumDepth
int getMaximumDepth()It returns the maximum depth reached by a search.- Returns:
- the maximum depth.
-
getNodes
int getNodes()It returns number of search nodes explored by the search.- Returns:
- number of search nodes.
-
getWrongDecisions
int getWrongDecisions()It returns number of wrong decisions performed by the search.- Returns:
- number of wrong decisions.
-
getSolution
Domain[] getSolution()It returns the solution (an assignment of values to variables).- Returns:
- an array constituting the assignments.
-
getSolution
It returns the solution specified by the search. The first solution has an index 1.- Parameters:
no- the solution we are interested in.- Returns:
- an array constituting the assignments.
-
getVariables
T[] getVariables()It returns the order of variables used by functions returning a solution in terms of the values.- Returns:
- an array of variables as used by functions getSolution.
-
label
boolean label(int firstVariable) This function is called recursively to assign variables one by one.- Parameters:
firstVariable- the index to the first variable which has not been grounded yet.- Returns:
- true if the solution was found.
-
labeling
boolean labeling()It performs search, first by setting up the internal items/attributes of search, followed later by a call to labeling function with argument specifying the index of the first not grounded variable.- Returns:
- true if the solution was found.
-
labeling
It performs search using supplied choice point selection heuristic.- Parameters:
store- the store within which the search is conducted.select- the selection choice point heuristic.- Returns:
- true if the solution was found.
-
labeling
It performs search using supplied choice point selection heuristic, as well as costVariable as aim at finding an optimal solution.- Parameters:
store- constraint store which will be used by labeling.select- the selection choice point heuristic.costVar- variable to specify cost.- Returns:
- true if the solution was found.
-
setAssignSolution
void setAssignSolution(boolean value) It decides if a solution is assigned to store after search exits.- Parameters:
value- defines if solution is assigned.
-
setBacktracksOut
void setBacktracksOut(long out) It turns on the backtrack out.- Parameters:
out- defines how many backtracks are performed before the search exits.
-
setDecisionsOut
void setDecisionsOut(long out) It turns on the decisions out.- Parameters:
out- defines how many decisions are made before the search exits.
-
setNodesOut
void setNodesOut(long out) It turns on the nodes out.- Parameters:
out- defines how many nodes are visited before the search exits.
-
setPrintInfo
void setPrintInfo(boolean value) It decides if information about search is printed.- Parameters:
value- defines if info is printed to standard output.
-
setTimeOut
void setTimeOut(long out) It turns on the timeout.- Parameters:
out- defines how many seconds before the search exits.
-
setTimeOutMilliseconds
void setTimeOutMilliseconds(long out) It turns on the timeout.- Parameters:
out- defines how many miliseconds before the search exits.
-
setWrongDecisionsOut
void setWrongDecisionsOut(long out) It turns on the wrong decisions out.- Parameters:
out- defines how many wrong decisions are made before the search exits.
-
toString
String toString() -
getSolutionListener
SolutionListener<T> getSolutionListener()It returns the root Solution Listener.- Returns:
- the root Solution Listener.
-
getConsistencyListener
ConsistencyListener getConsistencyListener()It returns the root of the Consistency Listener.- Returns:
- the root Consistency Listener.
-
getExitChildListener
ExitChildListener<T> getExitChildListener()It returns the root of the ExitChildListener.- Returns:
- the root of ExitChildListener.
-
getExitListener
ExitListener getExitListener()It returns the root of the ExitListener.- Returns:
- the root of ExitListener.
-
getTimeOutListener
TimeOutListener getTimeOutListener()It returns the root of the TimeOutListener.- Returns:
- the root of the TimeOutListener.
-
getInitializeListener
InitializeListener getInitializeListener()It returns the root of the InitializationListener.- Returns:
- the root of the InitializeListener.
-
setSolutionListener
It returns the root of the SolutionListener.- Parameters:
listener- the root of the SolutionListener.
-
setConsistencyListener
It sets the root of the Consistency Listener.- Parameters:
listener- the new root.
-
setExitChildListener
It sets the root of the ExitChild listener.- Parameters:
listener- the new root.
-
setExitListener
It sets the root of the Exit Listener.- Parameters:
listener- the new root.
-
setTimeOutListener
It sets the root of the TimeOutListener.- Parameters:
listener- the new root.
-
setInitializeListener
It sets the root of the InitializeListener.- Parameters:
listener- the new root.
-
setSelectChoicePoint
It sets the select choice point object.- Parameters:
select- the choice point heuristic used by search.
-
setStore
It sets the reference to the store in the context of which the search operates.- Parameters:
store- the store in which context the search operates.
-
setCostVar
It sets the reference to the cost variable. It does not automatically mean that the search optimizes.- Parameters:
cost- variable used as a cost metric.
-
setMasterSearch
If the search is called by a master search then the search may need to obtain some information about the master search. For example, the textual description of the solution.- Parameters:
master- master search which will be/is calling that slave search.
-
id
String id()It returns the string id of the search.- Returns:
- the string id of the search.
-
assignSolution
boolean assignSolution(int no) The first solution has index 0.- Parameters:
no- the solution number which we want to enforce in the store.- Returns:
- true if the store is consistent after imposing the solution.
-
assignSolution
boolean assignSolution()It assigns the last solution.- Returns:
- true if the store is consistent after imposing the last solution.
-
printAllSolutions
void printAllSolutions()It prints all solutions.
-