Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <constraint_solver.h>
Public Member Functions | |
ImprovementSearchLimit (Solver *solver, IntVar *objective_var, bool maximize, double objective_scaling_factor, double objective_offset, double improvement_rate_coefficient, int improvement_rate_solutions_distance) | |
--— Improvement Search Limit --— | |
ImprovementSearchLimit (Solver *solver, std::vector< IntVar * > objective_vars, std::vector< bool > maximize, std::vector< double > objective_scaling_factors, std::vector< double > objective_offsets, double improvement_rate_coefficient, int improvement_rate_solutions_distance) | |
~ImprovementSearchLimit () override | |
void | Copy (const SearchLimit *limit) override |
SearchLimit * | MakeClone () const override |
Allocates a clone of the limit. | |
bool | CheckWithOffset (absl::Duration offset) override |
bool | AtSolution () override |
void | Init () override |
This method is called when the search limit is initialized. | |
void | Install () override |
A search monitors adds itself on the active search. | |
Public Member Functions inherited from operations_research::SearchLimit | |
SearchLimit (Solver *const s) | |
SearchLimit (const SearchLimit &)=delete | |
This type is neither copyable nor movable. | |
SearchLimit & | operator= (const SearchLimit &)=delete |
~SearchLimit () override | |
-------— Search Limits -------— | |
bool | crossed () const |
Returns true if the limit has been crossed. | |
bool | Check () |
void | EnterSearch () override |
Internal methods. | |
void | BeginNextDecision (DecisionBuilder *b) override |
Before calling DecisionBuilder::Next. | |
void | PeriodicCheck () override |
Periodic call to check limits in long running methods. | |
void | RefuteDecision (Decision *d) override |
Before refuting the decision. | |
std::string | DebugString () const override |
void | Install () override |
A search monitors adds itself on the active search. | |
Public Member Functions inherited from operations_research::SearchMonitor | |
SearchMonitor (Solver *const s) | |
SearchMonitor (const SearchMonitor &)=delete | |
This type is neither copyable nor movable. | |
SearchMonitor & | operator= (const SearchMonitor &)=delete |
~SearchMonitor () override | |
virtual void | RestartSearch () |
Restart the search. | |
virtual void | ExitSearch () |
End of the search. | |
virtual void | EndNextDecision (DecisionBuilder *b, Decision *d) |
After calling DecisionBuilder::Next, along with the returned decision. | |
virtual void | ApplyDecision (Decision *d) |
Before applying the decision. | |
virtual void | AfterDecision (Decision *d, bool apply) |
virtual void | BeginFail () |
Just when the failure occurs. | |
virtual void | EndFail () |
After completing the backtrack. | |
virtual void | BeginInitialPropagation () |
Before the initial propagation. | |
virtual void | EndInitialPropagation () |
After the initial propagation. | |
virtual bool | AcceptSolution () |
virtual void | NoMoreSolutions () |
When the search tree is finished. | |
virtual bool | LocalOptimum () |
virtual bool | AcceptDelta (Assignment *delta, Assignment *deltadelta) |
virtual void | AcceptNeighbor () |
After accepting a neighbor during local search. | |
virtual void | AcceptUncheckedNeighbor () |
After accepting an unchecked neighbor during local search. | |
virtual bool | IsUncheckedSolutionLimitReached () |
virtual int | ProgressPercent () |
virtual void | Accept (ModelVisitor *visitor) const |
Accepts the given model visitor. | |
Solver * | solver () const |
Public Member Functions inherited from operations_research::BaseObject | |
BaseObject () | |
BaseObject (const BaseObject &)=delete | |
This type is neither copyable nor movable. | |
BaseObject & | operator= (const BaseObject &)=delete |
virtual | ~BaseObject () |
Additional Inherited Members | |
Static Public Attributes inherited from operations_research::SearchMonitor | |
static constexpr int | kNoProgress = -1 |
Protected Member Functions inherited from operations_research::SearchMonitor | |
void | ListenToEvent (Solver::MonitorEvent event) |
Limit based on the improvement rate of 'objective_var' or a lexicographic objective composed of 'objective_vars'. This limit proceeds in two stages: 1) During the phase of the search in which the objective is strictly improving, a threshold value is computed as the minimum improvement rate of the objective, based on the 'improvement_rate_coefficient' and 'improvement_rate_solutions_distance' parameters. 2) Then, if the search continues beyond this phase of strict improvement, the limit stops the search when the improvement rate of the objective gets below this threshold value.
Definition at line 4738 of file constraint_solver.h.
operations_research::ImprovementSearchLimit::ImprovementSearchLimit | ( | Solver * | solver, |
std::vector< IntVar * > | objective_vars, | ||
std::vector< bool > | maximize, | ||
std::vector< double > | objective_scaling_factors, | ||
std::vector< double > | objective_offsets, | ||
double | improvement_rate_coefficient, | ||
int | improvement_rate_solutions_distance ) |
|
override |
|
overridevirtual |
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.
To simplify, we'll consider minimization only in the rest of the code, which requires taking the opposite of the objective value if maximizing.
In case we haven't got enough solutions during the first stage, the limit never stops the search.
We need to have 'improvement_rate_solutions_distance_' + 1 element in the 'improvements_', so the distance between improvements is 'improvement_rate_solutions_distance_'.
Reimplemented from operations_research::SearchMonitor.
|
overridevirtual |
Same as Check() but adds the 'offset' value to the current time when time is considered in the limit.
Implements operations_research::SearchLimit.
|
overridevirtual |
Copy a limit. Warning: leads to a direct (no check) downcasting of 'limit' so one needs to be sure both SearchLimits are of the same type.
Implements operations_research::SearchLimit.
|
overridevirtual |
This method is called when the search limit is initialized.
Implements operations_research::SearchLimit.
|
overridevirtual |
A search monitors adds itself on the active search.
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 operations_research::SearchMonitor.
|
overridevirtual |
Allocates a clone of the limit.
Implements operations_research::SearchLimit.