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

Base objective monitor class. All metaheuristics derive from this. More...

#include <constraint_solver.h>

Inheritance diagram for operations_research::ObjectiveMonitor:
operations_research::SearchMonitor operations_research::BaseObject operations_research::OptimizeVar

Public Member Functions

 ObjectiveMonitor (Solver *solver, const std::vector< bool > &maximize, std::vector< IntVar * > vars, std::vector< int64_t > steps)
 -------— Objective Management -------—
 
 ~ObjectiveMonitor () override
 
 ObjectiveMonitor (const ObjectiveMonitor &)=delete
 
ObjectiveMonitoroperator= (const ObjectiveMonitor &)=delete
 
IntVarObjectiveVar (int index) const
 
IntVarMinimizationVar (int index) const
 
int64_t Step (int index) const
 
bool Maximize (int index) const
 
int64_t BestValue (int index) const
 
int Size () const
 
void EnterSearch () override
 Beginning of the search.
 
bool AtSolution () override
 
bool AcceptDelta (Assignment *delta, Assignment *deltadelta) override
 
void Accept (ModelVisitor *visitor) const override
 Accepts the given model visitor.
 
- 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 BeginNextDecision (DecisionBuilder *b)
 Before calling DecisionBuilder::Next.
 
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 RefuteDecision (Decision *d)
 Before refuting 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 void AcceptNeighbor ()
 After accepting a neighbor during local search.
 
virtual void AcceptUncheckedNeighbor ()
 After accepting an unchecked neighbor during local search.
 
virtual bool IsUncheckedSolutionLimitReached ()
 
virtual void PeriodicCheck ()
 Periodic call to check limits in long running methods.
 
virtual int ProgressPercent ()
 
virtual void Install ()
 A search monitors adds itself on the active search.
 
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 ()
 
virtual std::string DebugString () const
 

Protected Member Functions

const std::vector< IntVar * > & objective_vars () const
 
const std::vector< IntVar * > & minimization_vars () const
 
int64_t BestInternalValue (int index) const
 
int64_t CurrentInternalValue (int index) const
 
void SetCurrentInternalValue (int index, int64_t value)
 
template<typename T >
void MakeMinimizationVarsLessOrEqualWithSteps (const T &upper_bounds)
 
template<typename T >
IntVarMakeMinimizationVarsLessOrEqualWithStepsStatus (const T &upper_bounds)
 
bool CurrentInternalValuesAreConstraining () const
 
- Protected Member Functions inherited from operations_research::SearchMonitor
void ListenToEvent (Solver::MonitorEvent event)
 

Protected Attributes

bool found_initial_solution_
 

Friends

class Solver
 

Additional Inherited Members

- Static Public Attributes inherited from operations_research::SearchMonitor
static constexpr int kNoProgress = -1
 

Detailed Description

Base objective monitor class. All metaheuristics derive from this.

Definition at line 4500 of file constraint_solver.h.

Constructor & Destructor Documentation

◆ ObjectiveMonitor() [1/2]

operations_research::ObjectiveMonitor::ObjectiveMonitor ( Solver * solver,
const std::vector< bool > & maximize,
std::vector< IntVar * > vars,
std::vector< int64_t > steps )

-------— Objective Management -------—

Necessary to enforce strict lexical less-than constraint.

Todo
(user): Remove optimization direction from solver or expose it for each OptimizeVar variable. Note that Solver::optimization_direction() is not used anywhere, only passed as information for the user. Direction set based on highest level as of 02/2023.

Definition at line 2948 of file search.cc.

◆ ~ObjectiveMonitor()

operations_research::ObjectiveMonitor::~ObjectiveMonitor ( )
inlineoverride

Definition at line 4504 of file constraint_solver.h.

◆ ObjectiveMonitor() [2/2]

operations_research::ObjectiveMonitor::ObjectiveMonitor ( const ObjectiveMonitor & )
delete

Member Function Documentation

◆ Accept()

void operations_research::ObjectiveMonitor::Accept ( ModelVisitor * visitor) const
overridevirtual

Accepts the given model visitor.

Reimplemented from operations_research::SearchMonitor.

Definition at line 3045 of file search.cc.

◆ AcceptDelta()

bool operations_research::ObjectiveMonitor::AcceptDelta ( Assignment * delta,
Assignment * deltadelta )
overridevirtual

Reimplemented from operations_research::SearchMonitor.

Definition at line 3005 of file search.cc.

◆ AtSolution()

bool operations_research::ObjectiveMonitor::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.

Reimplemented from operations_research::SearchMonitor.

Reimplemented in operations_research::OptimizeVar.

Definition at line 2988 of file search.cc.

◆ BestInternalValue()

int64_t operations_research::ObjectiveMonitor::BestInternalValue ( int index) const
inlineprotected

Definition at line 4530 of file constraint_solver.h.

◆ BestValue()

int64_t operations_research::ObjectiveMonitor::BestValue ( int index) const
inline

Definition at line 4515 of file constraint_solver.h.

◆ CurrentInternalValue()

int64_t operations_research::ObjectiveMonitor::CurrentInternalValue ( int index) const
inlineprotected

Definition at line 4531 of file constraint_solver.h.

◆ CurrentInternalValuesAreConstraining()

bool operations_research::ObjectiveMonitor::CurrentInternalValuesAreConstraining ( ) const
protected

Definition at line 3055 of file search.cc.

◆ EnterSearch()

void operations_research::ObjectiveMonitor::EnterSearch ( )
overridevirtual

Beginning of the search.

-------— Search Monitor -------—

Reimplemented from operations_research::SearchMonitor.

Definition at line 2982 of file search.cc.

◆ MakeMinimizationVarsLessOrEqualWithSteps()

template<typename T >
void operations_research::ObjectiveMonitor::MakeMinimizationVarsLessOrEqualWithSteps ( const T & upper_bounds)
inlineprotected

Definition at line 4538 of file constraint_solver.h.

◆ MakeMinimizationVarsLessOrEqualWithStepsStatus()

template<typename T >
IntVar * operations_research::ObjectiveMonitor::MakeMinimizationVarsLessOrEqualWithStepsStatus ( const T & upper_bounds)
inlineprotected

Definition at line 4551 of file constraint_solver.h.

◆ Maximize()

bool operations_research::ObjectiveMonitor::Maximize ( int index) const
inline

Definition at line 4512 of file constraint_solver.h.

◆ minimization_vars()

const std::vector< IntVar * > & operations_research::ObjectiveMonitor::minimization_vars ( ) const
inlineprotected

Definition at line 4527 of file constraint_solver.h.

◆ MinimizationVar()

IntVar * operations_research::ObjectiveMonitor::MinimizationVar ( int index) const
inline

Definition at line 4510 of file constraint_solver.h.

◆ objective_vars()

const std::vector< IntVar * > & operations_research::ObjectiveMonitor::objective_vars ( ) const
inlineprotected

Definition at line 4526 of file constraint_solver.h.

◆ ObjectiveVar()

IntVar * operations_research::ObjectiveMonitor::ObjectiveVar ( int index) const
inline

Definition at line 4509 of file constraint_solver.h.

◆ operator=()

ObjectiveMonitor & operations_research::ObjectiveMonitor::operator= ( const ObjectiveMonitor & )
delete

◆ SetCurrentInternalValue()

void operations_research::ObjectiveMonitor::SetCurrentInternalValue ( int index,
int64_t value )
inlineprotected

Definition at line 4534 of file constraint_solver.h.

◆ Size()

int operations_research::ObjectiveMonitor::Size ( ) const
inline

Definition at line 4519 of file constraint_solver.h.

◆ Step()

int64_t operations_research::ObjectiveMonitor::Step ( int index) const
inline

Definition at line 4511 of file constraint_solver.h.

Friends And Related Symbol Documentation

◆ Solver

friend class Solver
friend

Definition at line 4572 of file constraint_solver.h.

Member Data Documentation

◆ found_initial_solution_

bool operations_research::ObjectiveMonitor::found_initial_solution_
protected

Definition at line 4569 of file constraint_solver.h.


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