java.lang.Object
org.maxicp.search.AbstractSearchMethod<SymbolicModel>
org.maxicp.search.AbstractConcurrentSearchMethod
- All Implemented Interfaces:
SearchMethod
- Direct Known Subclasses:
ConcurrentDFSearch
An abstract search method that can be used concurrently: it is stoppable and can be work-stealed.
An additional constraint w.r.t. AbstractSearchMethod is that an AbstractConcurrentSearchMethod
MUST NOT be running more than one solving process at a time.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.maxicp.search.AbstractSearchMethod
AbstractSearchMethod.IntRef -
Field Summary
FieldsFields inherited from class org.maxicp.search.AbstractSearchMethod
branching, failureListeners, sm, solutionListeners -
Constructor Summary
ConstructorsConstructorDescriptionAbstractConcurrentSearchMethod(StateManager sm, Supplier<SymbolicModel[]> branching) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract booleandone()protected abstract SymbolicModelRemove a model from the "list of open models" and returns it.protected abstract voidCalled when the current search is finishedprotected abstract voidCalled when a new search is startedprotected abstract voidprocess the next step of the search procedure.protected voidstartSolve(SearchStatistics statistics, Predicate<SearchStatistics> limit, Runnable onNodeVisit) Start the solving process.steal()Steal a (yet non-visited) model from this search method.stop()Stop a solving process (thread-safely)Methods inherited from class org.maxicp.search.AbstractSearchMethod
allFixed, notifyFailure, notifySolution, onFailure, onSolution, optimize, optimize, optimize, optimize, optimizeSubjectTo, optimizeSubjectTo, replay, replaySubjectTo, replaySubjectTo, replaySubjectTo, solve, solve, solve, solve, solveSubjectToMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.maxicp.search.SearchMethod
onFailure, onSolution
-
Field Details
-
statistics
-
onNodeVisit
-
-
Constructor Details
-
AbstractConcurrentSearchMethod
-
-
Method Details
-
done
protected abstract boolean done()- Returns:
- true if there are no more nodes to visit
-
initSolve
protected abstract void initSolve()Called when a new search is started -
processNextStep
protected abstract void processNextStep()process the next step of the search procedure. done() must be false to call this function. -
finishSolve
protected abstract void finishSolve()Called when the current search is finished -
extractModel
Remove a model from the "list of open models" and returns it. This function will be called on the same thread as startSolve if it's running, and is not needed to be thread-safe. The function is allowed to return null if and only if there is no Model left to visit. -
steal
Steal a (yet non-visited) model from this search method. Thread-safe. The function is allowed to return null if and only if there is no Model left to visit. -
stop
Stop a solving process (thread-safely)- Returns:
- a Fu
-
startSolve
protected void startSolve(SearchStatistics statistics, Predicate<SearchStatistics> limit, Runnable onNodeVisit) Description copied from class:AbstractSearchMethodStart the solving process.This method must be implemented by subclasses and do the heavy work. It must call notifySolution/notifyFailure when a solution is found or a failure occurs.
- Specified by:
startSolvein classAbstractSearchMethod<SymbolicModel>- Parameters:
statistics-limit-onNodeVisit- a closure to execute at each node visit
-