Module org.maxicp

Class AbstractConcurrentSearchMethod

java.lang.Object
org.maxicp.search.AbstractSearchMethod<SymbolicModel>
org.maxicp.search.AbstractConcurrentSearchMethod
All Implemented Interfaces:
SearchMethod
Direct Known Subclasses:
ConcurrentDFSearch

public abstract class AbstractConcurrentSearchMethod extends AbstractSearchMethod<SymbolicModel>
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.
  • Field Details

  • Constructor Details

  • 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

      protected abstract SymbolicModel 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

      public Future<SymbolicModel> 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

      public Future<NullType> 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: AbstractSearchMethod
      Start 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:
      startSolve in class AbstractSearchMethod<SymbolicModel>
      Parameters:
      statistics -
      limit -
      onNodeVisit - a closure to execute at each node visit