![]() |
OR-Tools
9.6
|
This class is the root class of all solution collectors.
It implements a basic query API to be used independently of the collector used.
Definition at line 4227 of file constraint_solver.h.
Classes | |
| struct | SolutionData |
Public Member Functions | |
| SolutionCollector (Solver *const solver, const Assignment *assignment) | |
| SolutionCollector (Solver *const solver) | |
| ~SolutionCollector () override | |
| void | Install () override |
| Registers itself on the solver such that it gets notified of the search and propagation events. More... | |
| std::string | DebugString () const override |
| void | Add (IntVar *const var) |
| Add API. More... | |
| void | Add (const std::vector< IntVar * > &vars) |
| void | Add (IntervalVar *const var) |
| void | Add (const std::vector< IntervalVar * > &vars) |
| void | Add (SequenceVar *const var) |
| void | Add (const std::vector< SequenceVar * > &vars) |
| void | AddObjective (IntVar *const objective) |
| void | EnterSearch () override |
| Beginning of the search. More... | |
| int | solution_count () const |
| Returns how many solutions were stored during the search. More... | |
| Assignment * | solution (int n) const |
| Returns the nth solution. More... | |
| int64_t | wall_time (int n) const |
| Returns the wall time in ms for the nth solution. More... | |
| int64_t | branches (int n) const |
| Returns the number of branches when the nth solution was found. More... | |
| int64_t | failures (int n) const |
| Returns the number of failures encountered at the time of the nth solution. More... | |
| int64_t | objective_value (int n) const |
| Returns the objective value of the nth solution. More... | |
| int64_t | Value (int n, IntVar *const var) const |
| This is a shortcut to get the Value of 'var' in the nth solution. More... | |
| int64_t | StartValue (int n, IntervalVar *const var) const |
| This is a shortcut to get the StartValue of 'var' in the nth solution. More... | |
| int64_t | EndValue (int n, IntervalVar *const var) const |
| This is a shortcut to get the EndValue of 'var' in the nth solution. More... | |
| int64_t | DurationValue (int n, IntervalVar *const var) const |
| This is a shortcut to get the DurationValue of 'var' in the nth solution. More... | |
| int64_t | PerformedValue (int n, IntervalVar *const var) const |
| This is a shortcut to get the PerformedValue of 'var' in the nth solution. More... | |
| const std::vector< int > & | ForwardSequence (int n, SequenceVar *const var) const |
| This is a shortcut to get the ForwardSequence of 'var' in the nth solution. More... | |
| const std::vector< int > & | BackwardSequence (int n, SequenceVar *const var) const |
| This is a shortcut to get the BackwardSequence of 'var' in the nth solution. More... | |
| const std::vector< int > & | Unperformed (int n, SequenceVar *const var) const |
| This is a shortcut to get the list of unperformed of 'var' in the nth solution. More... | |
| virtual void | RestartSearch () |
| Restart the search. More... | |
| virtual void | ExitSearch () |
| End of the search. More... | |
| virtual void | BeginNextDecision (DecisionBuilder *const b) |
| Before calling DecisionBuilder::Next. More... | |
| virtual void | EndNextDecision (DecisionBuilder *const b, Decision *const d) |
| After calling DecisionBuilder::Next, along with the returned decision. More... | |
| virtual void | ApplyDecision (Decision *const d) |
| Before applying the decision. More... | |
| virtual void | RefuteDecision (Decision *const d) |
| Before refuting the decision. More... | |
| virtual void | AfterDecision (Decision *const d, bool apply) |
| Just after refuting or applying the decision, apply is true after Apply. More... | |
| virtual void | BeginFail () |
| Just when the failure occurs. More... | |
| virtual void | EndFail () |
| After completing the backtrack. More... | |
| virtual void | BeginInitialPropagation () |
| Before the initial propagation. More... | |
| virtual void | EndInitialPropagation () |
| After the initial propagation. More... | |
| virtual bool | AcceptSolution () |
| This method is called when a solution is found. More... | |
| virtual bool | AtSolution () |
| This method is called when a valid solution is found. More... | |
| virtual void | NoMoreSolutions () |
| When the search tree is finished. More... | |
| virtual bool | LocalOptimum () |
| When a local optimum is reached. More... | |
| virtual bool | AcceptDelta (Assignment *delta, Assignment *deltadelta) |
| virtual void | AcceptNeighbor () |
| After accepting a neighbor during local search. More... | |
| virtual void | AcceptUncheckedNeighbor () |
| After accepting an unchecked neighbor during local search. More... | |
| virtual bool | IsUncheckedSolutionLimitReached () |
| Returns true if the limit of solutions has been reached including unchecked solutions. More... | |
| virtual void | PeriodicCheck () |
| Periodic call to check limits in long running methods. More... | |
| virtual int | ProgressPercent () |
| Returns a percentage representing the propress of the search before reaching limits. More... | |
| virtual void | Accept (ModelVisitor *const visitor) const |
| Accepts the given model visitor. More... | |
| Solver * | solver () const |
Static Public Attributes | |
| static constexpr int | kNoProgress = -1 |
Protected Member Functions | |
| void | PushSolution () |
| Push the current state as a new solution. More... | |
| void | Push (const SolutionData &data) |
| void | PopSolution () |
| Remove and delete the last popped solution. More... | |
| SolutionData | BuildSolutionDataForCurrentState () |
| void | FreeSolution (Assignment *solution) |
| void | check_index (int n) const |
| void | ListenToEvent (Solver::MonitorEvent event) |
Protected Attributes | |
| std::unique_ptr< Assignment > | prototype_ |
| std::vector< SolutionData > | solution_data_ |
| std::vector< Assignment * > | recycle_solutions_ |
| SolutionCollector | ( | Solver *const | solver, |
| const Assignment * | assignment | ||
| ) |
|
explicit |
|
override |
|
virtualinherited |
Accepts the given model visitor.
Reimplemented in RegularLimit, and OptimizeVar.
Definition at line 2929 of file constraint_solver.cc.
|
virtualinherited |
Reimplemented in OptimizeVar.
Definition at line 2923 of file constraint_solver.cc.
|
virtualinherited |
After accepting a neighbor during local search.
Definition at line 2926 of file constraint_solver.cc.
|
virtualinherited |
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.
Reimplemented in OptimizeVar.
Definition at line 2919 of file constraint_solver.cc.
|
virtualinherited |
After accepting an unchecked neighbor during local search.
Reimplemented in SearchLog.
Definition at line 2927 of file constraint_solver.cc.
| void Add | ( | const std::vector< IntervalVar * > & | vars | ) |
| void Add | ( | const std::vector< SequenceVar * > & | vars | ) |
| void Add | ( | IntervalVar *const | var | ) |
| void Add | ( | SequenceVar *const | var | ) |
|
virtualinherited |
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.
Definition at line 2914 of file constraint_solver.cc.
|
virtualinherited |
Before applying the decision.
Reimplemented in SearchLog.
Definition at line 2912 of file constraint_solver.cc.
|
virtualinherited |
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.
Reimplemented in SearchLog, ImprovementSearchLimit, and OptimizeVar.
Definition at line 2920 of file constraint_solver.cc.
| const std::vector< int > & BackwardSequence | ( | int | n, |
| SequenceVar *const | var | ||
| ) | const |
|
virtualinherited |
Just when the failure occurs.
Reimplemented in DemonProfiler, and SearchLog.
Definition at line 2915 of file constraint_solver.cc.
|
virtualinherited |
Before the initial propagation.
Reimplemented in SearchLog.
Definition at line 2917 of file constraint_solver.cc.
|
virtualinherited |
Before calling DecisionBuilder::Next.
Reimplemented in OptimizeVar, and SearchLimit.
Definition at line 2909 of file constraint_solver.cc.
| int64_t branches | ( | int | n | ) | const |
|
protected |
|
inlineoverridevirtual |
Reimplemented from BaseObject.
Definition at line 4233 of file constraint_solver.h.
| int64_t DurationValue | ( | int | n, |
| IntervalVar *const | var | ||
| ) | const |
|
virtualinherited |
After completing the backtrack.
Definition at line 2916 of file constraint_solver.cc.
|
virtualinherited |
After the initial propagation.
Reimplemented in SearchLog.
Definition at line 2918 of file constraint_solver.cc.
|
virtualinherited |
After calling DecisionBuilder::Next, along with the returned decision.
Reimplemented in SymmetryManager.
Definition at line 2910 of file constraint_solver.cc.
| int64_t EndValue | ( | int | n, |
| IntervalVar *const | var | ||
| ) | const |
|
overridevirtual |
Beginning of the search.
Reimplemented from SearchMonitor.
|
virtualinherited |
End of the search.
Reimplemented in LocalSearchProfiler, SearchLog, and RegularLimit.
Definition at line 2908 of file constraint_solver.cc.
| int64_t failures | ( | int | n | ) | const |
| const std::vector< int > & ForwardSequence | ( | int | n, |
| SequenceVar *const | var | ||
| ) | const |
|
protected |
|
overridevirtual |
Registers itself on the solver such that it gets notified of the search and propagation events.
Override to incrementally install listeners for specific events.
Reimplemented from SearchMonitor.
|
inlinevirtualinherited |
Returns true if the limit of solutions has been reached including unchecked solutions.
Reimplemented in RegularLimit.
Definition at line 3827 of file constraint_solver.h.
|
protectedinherited |
Definition at line 2938 of file constraint_solver.cc.
|
virtualinherited |
When a local optimum is reached.
If 'true' is returned, the last solution is discarded and the search proceeds with the next one.
Definition at line 2922 of file constraint_solver.cc.
|
virtualinherited |
When the search tree is finished.
Reimplemented in SearchLog.
Definition at line 2921 of file constraint_solver.cc.
| int64_t objective_value | ( | int | n | ) | const |
| int64_t PerformedValue | ( | int | n, |
| IntervalVar *const | var | ||
| ) | const |
|
virtualinherited |
Periodic call to check limits in long running methods.
Reimplemented in SearchLimit.
Definition at line 2928 of file constraint_solver.cc.
|
protected |
|
inlinevirtualinherited |
Returns a percentage representing the propress of the search before reaching limits.
Reimplemented in RegularLimit.
Definition at line 3834 of file constraint_solver.h.
|
inlineprotected |
Definition at line 4309 of file constraint_solver.h.
|
protected |
|
virtualinherited |
Before refuting the decision.
Reimplemented in SymmetryManager, SearchLog, SearchLimit, and OptimizeVar.
Definition at line 2913 of file constraint_solver.cc.
|
virtualinherited |
Restart the search.
Reimplemented in LocalSearchProfiler, and DemonProfiler.
Definition at line 2907 of file constraint_solver.cc.
| Assignment * solution | ( | int | n | ) | const |
| int solution_count | ( | ) | const |
|
inlineinherited |
Definition at line 3844 of file constraint_solver.h.
| int64_t StartValue | ( | int | n, |
| IntervalVar *const | var | ||
| ) | const |
| const std::vector< int > & Unperformed | ( | int | n, |
| SequenceVar *const | var | ||
| ) | const |
| int64_t Value | ( | int | n, |
| IntVar *const | var | ||
| ) | const |
| int64_t wall_time | ( | int | n | ) | const |
|
staticconstexprinherited |
Definition at line 3758 of file constraint_solver.h.
|
protected |
Definition at line 4316 of file constraint_solver.h.
|
protected |
Definition at line 4318 of file constraint_solver.h.
|
protected |
Definition at line 4317 of file constraint_solver.h.