C++ Reference
C++ Reference: Routing
Detailed Description
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 4053 of file constraint_solver.h.
Classes | |
| struct | SolutionData |
Public Member Functions | |
| SolutionCollector (Solver *const solver, const Assignment *assignment) | |
| SolutionCollector (Solver *const solver) | |
| ~SolutionCollector () override | |
| 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 | wall_time (int n) const |
| Returns the wall time in ms for the nth solution. More... | |
| int64 | branches (int n) const |
| Returns the number of branches when the nth solution was found. More... | |
| int64 | failures (int n) const |
| Returns the number of failures encountered at the time of the nth solution. More... | |
| int64 | objective_value (int n) const |
| Returns the objective value of the nth solution. More... | |
| int64 | Value (int n, IntVar *const var) const |
| This is a shortcut to get the Value of 'var' in the nth solution. More... | |
| int64 | StartValue (int n, IntervalVar *const var) const |
| This is a shortcut to get the StartValue of 'var' in the nth solution. More... | |
| int64 | EndValue (int n, IntervalVar *const var) const |
| This is a shortcut to get the EndValue of 'var' in the nth solution. More... | |
| int64 | DurationValue (int n, IntervalVar *const var) const |
| This is a shortcut to get the DurationValue of 'var' in the nth solution. More... | |
| int64 | 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... | |
| Solver * | solver () const |
| 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... | |
| virtual void | Install () |
| Registers itself on the solver such that it gets notified of the search and propagation events. More... | |
Static Public Attributes | |
| static const 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 |
Protected Attributes | |
| std::unique_ptr< Assignment > | prototype_ |
| std::vector< SolutionData > | solution_data_ |
| std::vector< Assignment * > | recycle_solutions_ |
Constructor & Destructor Documentation
◆ SolutionCollector() [1/2]
| SolutionCollector | ( | Solver *const | solver, |
| const Assignment * | assignment | ||
| ) |
◆ SolutionCollector() [2/2]
|
explicit |
◆ ~SolutionCollector()
|
override |
Member Function Documentation
◆ Accept()
|
virtualinherited |
Accepts the given model visitor.
Reimplemented in RegularLimit, and OptimizeVar.
◆ AcceptDelta()
|
virtualinherited |
Reimplemented in OptimizeVar.
◆ AcceptNeighbor()
|
virtualinherited |
After accepting a neighbor during local search.
◆ AcceptSolution()
|
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.
◆ AcceptUncheckedNeighbor()
|
virtualinherited |
After accepting an unchecked neighbor during local search.
Reimplemented in SearchLog.
◆ Add() [1/6]
| void Add | ( | const std::vector< IntervalVar * > & | vars | ) |
◆ Add() [2/6]
| void Add | ( | const std::vector< IntVar * > & | vars | ) |
◆ Add() [3/6]
| void Add | ( | const std::vector< SequenceVar * > & | vars | ) |
◆ Add() [4/6]
| void Add | ( | IntervalVar *const | var | ) |
◆ Add() [5/6]
| void Add | ( | IntVar *const | var | ) |
Add API.
◆ Add() [6/6]
| void Add | ( | SequenceVar *const | var | ) |
◆ AddObjective()
| void AddObjective | ( | IntVar *const | objective | ) |
◆ AfterDecision()
|
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.
◆ ApplyDecision()
|
virtualinherited |
Before applying the decision.
Reimplemented in SearchLog.
◆ AtSolution()
|
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 OptimizeVar, and SearchLog.
◆ BackwardSequence()
| 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.
The backward sequence is the list of ranked interval variables starting from the end of the sequence.
◆ BeginFail()
|
virtualinherited |
Just when the failure occurs.
Reimplemented in SearchLog.
◆ BeginInitialPropagation()
|
virtualinherited |
Before the initial propagation.
Reimplemented in SearchLog.
◆ BeginNextDecision()
|
virtualinherited |
Before calling DecisionBuilder::Next.
Reimplemented in OptimizeVar, and SearchLimit.
◆ branches()
| int64 branches | ( | int | n | ) | const |
Returns the number of branches when the nth solution was found.
◆ BuildSolutionDataForCurrentState()
|
protected |
◆ check_index()
|
protected |
◆ DebugString()
|
inlineoverridevirtual |
Reimplemented from BaseObject.
Definition at line 4058 of file constraint_solver.h.
◆ DurationValue()
| int64 DurationValue | ( | int | n, |
| IntervalVar *const | var | ||
| ) | const |
This is a shortcut to get the DurationValue of 'var' in the nth solution.
◆ EndFail()
|
virtualinherited |
After completing the backtrack.
◆ EndInitialPropagation()
|
virtualinherited |
After the initial propagation.
Reimplemented in SearchLog.
◆ EndNextDecision()
|
virtualinherited |
After calling DecisionBuilder::Next, along with the returned decision.
◆ EndValue()
| int64 EndValue | ( | int | n, |
| IntervalVar *const | var | ||
| ) | const |
This is a shortcut to get the EndValue of 'var' in the nth solution.
◆ EnterSearch()
|
overridevirtual |
Beginning of the search.
Reimplemented from SearchMonitor.
◆ ExitSearch()
|
virtualinherited |
End of the search.
Reimplemented in RegularLimit, and SearchLog.
◆ failures()
| int64 failures | ( | int | n | ) | const |
Returns the number of failures encountered at the time of the nth solution.
◆ ForwardSequence()
| 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.
The forward sequence is the list of ranked interval variables starting from the start of the sequence.
◆ FreeSolution()
|
protected |
◆ Install()
|
virtualinherited |
Registers itself on the solver such that it gets notified of the search and propagation events.
Reimplemented in LocalSearchMonitor, and PropagationMonitor.
◆ IsUncheckedSolutionLimitReached()
|
inlinevirtualinherited |
Returns true if the limit of solutions has been reached including unchecked solutions.
Reimplemented in RegularLimit.
Definition at line 3658 of file constraint_solver.h.
◆ LocalOptimum()
|
virtualinherited |
When a local optimum is reached.
If 'true' is returned, the last solution is discarded and the search proceeds with the next one.
◆ NoMoreSolutions()
|
virtualinherited |
When the search tree is finished.
Reimplemented in SearchLog.
◆ objective_value()
| int64 objective_value | ( | int | n | ) | const |
Returns the objective value of the nth solution.
◆ PerformedValue()
| int64 PerformedValue | ( | int | n, |
| IntervalVar *const | var | ||
| ) | const |
This is a shortcut to get the PerformedValue of 'var' in the nth solution.
◆ PeriodicCheck()
|
virtualinherited |
Periodic call to check limits in long running methods.
Reimplemented in SearchLimit.
◆ PopSolution()
|
protected |
Remove and delete the last popped solution.
◆ ProgressPercent()
|
inlinevirtualinherited |
Returns a percentage representing the propress of the search before reaching limits.
Reimplemented in RegularLimit.
Definition at line 3667 of file constraint_solver.h.
◆ Push()
|
inlineprotected |
Definition at line 4134 of file constraint_solver.h.
◆ PushSolution()
|
protected |
Push the current state as a new solution.
◆ RefuteDecision()
|
virtualinherited |
Before refuting the decision.
Reimplemented in SearchLog, SearchLimit, and OptimizeVar.
◆ RestartSearch()
|
virtualinherited |
Restart the search.
◆ solution()
| Assignment* solution | ( | int | n | ) | const |
Returns the nth solution.
◆ solution_count()
| int solution_count | ( | ) | const |
Returns how many solutions were stored during the search.
◆ solver()
|
inlineinherited |
Definition at line 3660 of file constraint_solver.h.
◆ StartValue()
| int64 StartValue | ( | int | n, |
| IntervalVar *const | var | ||
| ) | const |
This is a shortcut to get the StartValue of 'var' in the nth solution.
◆ Unperformed()
| 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.
◆ Value()
| int64 Value | ( | int | n, |
| IntVar *const | var | ||
| ) | const |
This is a shortcut to get the Value of 'var' in the nth solution.
◆ wall_time()
| int64 wall_time | ( | int | n | ) | const |
Returns the wall time in ms for the nth solution.
Member Data Documentation
◆ kNoProgress
|
staticinherited |
Definition at line 3589 of file constraint_solver.h.
◆ prototype_
|
protected |
Definition at line 4141 of file constraint_solver.h.
◆ recycle_solutions_
|
protected |
Definition at line 4143 of file constraint_solver.h.
◆ solution_data_
|
protected |
Definition at line 4142 of file constraint_solver.h.
The documentation for this class was generated from the following file: