Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::ImprovementSearchLimit Class Reference

#include <constraint_solver.h>

Inheritance diagram for operations_research::ImprovementSearchLimit:
operations_research::SearchLimit operations_research::SearchMonitor operations_research::BaseObject

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
 
SearchLimitMakeClone () 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.
 
SearchLimitoperator= (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.
 
SearchMonitoroperator= (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.
 
Solversolver () const
 
- Public Member Functions inherited from operations_research::BaseObject
 BaseObject ()
 
 BaseObject (const BaseObject &)=delete
 This type is neither copyable nor movable.
 
BaseObjectoperator= (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)
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ImprovementSearchLimit() [1/2]

operations_research::ImprovementSearchLimit::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 --—

Definition at line 4564 of file search.cc.

◆ ImprovementSearchLimit() [2/2]

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 )

Definition at line 4576 of file search.cc.

◆ ~ImprovementSearchLimit()

operations_research::ImprovementSearchLimit::~ImprovementSearchLimit ( )
override

Definition at line 4595 of file search.cc.

Member Function Documentation

◆ AtSolution()

bool operations_research::ImprovementSearchLimit::AtSolution ( )
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.

Definition at line 4670 of file search.cc.

◆ CheckWithOffset()

bool operations_research::ImprovementSearchLimit::CheckWithOffset ( absl::Duration offset)
overridevirtual

Same as Check() but adds the 'offset' value to the current time when time is considered in the limit.

Implements operations_research::SearchLimit.

Definition at line 4636 of file search.cc.

◆ Copy()

void operations_research::ImprovementSearchLimit::Copy ( const SearchLimit * limit)
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.

Definition at line 4612 of file search.cc.

◆ Init()

void operations_research::ImprovementSearchLimit::Init ( )
overridevirtual

This method is called when the search limit is initialized.

Implements operations_research::SearchLimit.

Definition at line 4602 of file search.cc.

◆ Install()

void operations_research::ImprovementSearchLimit::Install ( )
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.

Definition at line 4597 of file search.cc.

◆ MakeClone()

SearchLimit * operations_research::ImprovementSearchLimit::MakeClone ( ) const
overridevirtual

Allocates a clone of the limit.

Implements operations_research::SearchLimit.

Definition at line 4629 of file search.cc.


The documentation for this class was generated from the following files: