Class SearchMonitor
- java.lang.Object
-
- com.google.ortools.constraintsolver.BaseObject
-
- com.google.ortools.constraintsolver.SearchMonitor
-
- Direct Known Subclasses:
LocalSearchMonitor,ObjectiveMonitor,PropagationMonitor,SearchLimit,SearchLog,SolutionCollector
public class SearchMonitor extends BaseObject
A search monitor is a simple set of callbacks to monitor all search events
-
-
Field Summary
Fields Modifier and Type Field Description static intkNoProgress-
Fields inherited from class com.google.ortools.constraintsolver.BaseObject
swigCMemOwn
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSearchMonitor(long cPtr, boolean cMemoryOwn)SearchMonitor(Solver s)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(ModelVisitor visitor)Accepts the given model visitor.booleanacceptDelta(Assignment delta, Assignment deltadelta)voidacceptNeighbor()After accepting a neighbor during local search.booleanacceptSolution()This method is called when a solution is found.voidAcceptUncheckedNeighbor()After accepting an unchecked neighbor during local search.voidafterDecision(Decision d, boolean apply)Just after refuting or applying the decision, apply is true after Apply.
This is called only if the Apply() or Refute() methods have not failed.voidapplyDecision(Decision d)Before applying the decision.booleanatSolution()This method is called when a valid solution is found.voidbeginFail()Just when the failure occurs.voidbeginInitialPropagation()Before the initial propagation.voidbeginNextDecision(DecisionBuilder b)Before calling DecisionBuilder::Next.voiddelete()voidendFail()After completing the backtrack.voidendInitialPropagation()After the initial propagation.voidendNextDecision(DecisionBuilder b, Decision d)After calling DecisionBuilder::Next, along with the returned decision.voidenterSearch()Beginning of the search.voidexitSearch()End of the search.protected voidfinalize()protected static longgetCPtr(SearchMonitor obj)voidinstall()Registers itself on the solver such that it gets notified of the search
and propagation events.booleanIsUncheckedSolutionLimitReached()Returns true if the limit of solutions has been reached including
unchecked solutions.voidkeepAliveDecisionBuilder(DecisionBuilder db)booleanlocalOptimum()When a local optimum is reached.voidnoMoreSolutions()When the search tree is finished.voidperiodicCheck()Periodic call to check limits in long running methods.intprogressPercent()Returns a percentage representing the propress of the search before
reaching limits.voidrefuteDecision(Decision d)Before refuting the decision.voidrestartSearch()Restart the search.Solversolver()protected voidswigDirectorDisconnect()protected static longswigRelease(SearchMonitor obj)voidswigReleaseOwnership()voidswigTakeOwnership()-
Methods inherited from class com.google.ortools.constraintsolver.BaseObject
getCPtr, swigRelease, toString
-
-
-
-
Constructor Detail
-
SearchMonitor
protected SearchMonitor(long cPtr, boolean cMemoryOwn)
-
SearchMonitor
public SearchMonitor(Solver s)
-
-
Method Detail
-
getCPtr
protected static long getCPtr(SearchMonitor obj)
-
swigRelease
protected static long swigRelease(SearchMonitor obj)
-
finalize
protected void finalize()
- Overrides:
finalizein classBaseObject
-
delete
public void delete()
- Overrides:
deletein classBaseObject
-
swigDirectorDisconnect
protected void swigDirectorDisconnect()
-
swigReleaseOwnership
public void swigReleaseOwnership()
-
swigTakeOwnership
public void swigTakeOwnership()
-
keepAliveDecisionBuilder
public void keepAliveDecisionBuilder(DecisionBuilder db)
-
enterSearch
public void enterSearch()
Beginning of the search.
-
restartSearch
public void restartSearch()
Restart the search.
-
exitSearch
public void exitSearch()
End of the search.
-
beginNextDecision
public void beginNextDecision(DecisionBuilder b)
Before calling DecisionBuilder::Next.
-
endNextDecision
public void endNextDecision(DecisionBuilder b, Decision d)
After calling DecisionBuilder::Next, along with the returned decision.
-
applyDecision
public void applyDecision(Decision d)
Before applying the decision.
-
refuteDecision
public void refuteDecision(Decision d)
Before refuting the decision.
-
afterDecision
public void afterDecision(Decision d, boolean apply)
Just after refuting or applying the decision, apply is true after Apply.
This is called only if the Apply() or Refute() methods have not failed.
-
beginFail
public void beginFail()
Just when the failure occurs.
-
endFail
public void endFail()
After completing the backtrack.
-
beginInitialPropagation
public void beginInitialPropagation()
Before the initial propagation.
-
endInitialPropagation
public void endInitialPropagation()
After the initial propagation.
-
acceptSolution
public boolean acceptSolution()
This method is called when a solution is found. It asserts whether the
solution is valid. A value of false indicates that the solution
should be discarded.
-
atSolution
public boolean atSolution()
This method is called when a valid solution is found. If the
return value is true, then search will resume after. If the result
is false, then search will stop there.
-
noMoreSolutions
public void noMoreSolutions()
When the search tree is finished.
-
localOptimum
public boolean localOptimum()
When a local optimum is reached. If 'true' is returned, the last solution
is discarded and the search proceeds with the next one.
-
acceptDelta
public boolean acceptDelta(Assignment delta, Assignment deltadelta)
-
acceptNeighbor
public void acceptNeighbor()
After accepting a neighbor during local search.
-
AcceptUncheckedNeighbor
public void AcceptUncheckedNeighbor()
After accepting an unchecked neighbor during local search.
-
IsUncheckedSolutionLimitReached
public boolean IsUncheckedSolutionLimitReached()
Returns true if the limit of solutions has been reached including
unchecked solutions.
-
periodicCheck
public void periodicCheck()
Periodic call to check limits in long running methods.
-
progressPercent
public int progressPercent()
Returns a percentage representing the propress of the search before
reaching limits.
-
accept
public void accept(ModelVisitor visitor)
Accepts the given model visitor.
-
install
public void install()
Registers itself on the solver such that it gets notified of the search
and propagation events. Override to incrementally install listeners for
specific events.
-
solver
public Solver solver()
-
-