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

#include <bop_base.h>

Inheritance diagram for operations_research::bop::BopOptimizerBase:
operations_research::bop::BopAdaptiveLNSOptimizer operations_research::bop::BopCompleteLNSOptimizer operations_research::bop::BopRandomFirstSolutionGenerator operations_research::bop::GuidedSatFirstSolutionGenerator operations_research::bop::LinearRelaxation operations_research::bop::LocalSearchOptimizer operations_research::bop::PortfolioOptimizer operations_research::bop::SatCoreBasedOptimizer

Public Types

enum  Status {
  OPTIMAL_SOLUTION_FOUND , SOLUTION_FOUND , INFEASIBLE , LIMIT_REACHED ,
  INFORMATION_FOUND , CONTINUE , ABORT
}
 

Public Member Functions

 BopOptimizerBase (absl::string_view name)
 
virtual ~BopOptimizerBase ()
 
const std::string & name () const
 Returns the name given at construction.
 
virtual bool ShouldBeRun (const ProblemState &problem_state) const =0
 
virtual Status Optimize (const BopParameters &parameters, const ProblemState &problem_state, LearnedInfo *learned_info, TimeLimit *time_limit)=0
 

Static Public Member Functions

static std::string GetStatusString (Status status)
 Returns a string describing the status.
 

Protected Attributes

const std::string name_
 
StatsGroup stats_
 

Detailed Description

Base class used to optimize a ProblemState. Optimizers implementing this class are used in a sort of portfolio and are run sequentially or concurrently. See for instance BopRandomLNSOptimizer.

Definition at line 48 of file bop_base.h.

Member Enumeration Documentation

◆ Status

Return status of the Optimize() function below.

Todo
(user): To redesign, some are not needed anymore thanks to the problem state, e.g. IsOptimal().
Enumerator
OPTIMAL_SOLUTION_FOUND 
SOLUTION_FOUND 
INFEASIBLE 
LIMIT_REACHED 
INFORMATION_FOUND 

Some information was learned and the problem state will need to be updated. This will trigger a new optimization round.

Todo
(user): replace by learned_info->IsEmpty()? but we will need to clear the BopSolution there first.
CONTINUE 

This optimizer didn't learn any information yet but can be called again on the same problem state to resume its work.

ABORT 

There is no need to call this optimizer again on the same problem state.

Definition at line 69 of file bop_base.h.

Constructor & Destructor Documentation

◆ BopOptimizerBase()

operations_research::bop::BopOptimizerBase::BopOptimizerBase ( absl::string_view name)
explicit

Definition at line 44 of file bop_base.cc.

◆ ~BopOptimizerBase()

operations_research::bop::BopOptimizerBase::~BopOptimizerBase ( )
virtual

Definition at line 49 of file bop_base.cc.

Member Function Documentation

◆ GetStatusString()

std::string operations_research::bop::BopOptimizerBase::GetStatusString ( Status status)
static

Returns a string describing the status.

Fallback. We don't use "default:" so the compiler will return an error if we forgot one enum case above.

Definition at line 53 of file bop_base.cc.

◆ name()

const std::string & operations_research::bop::BopOptimizerBase::name ( ) const
inline

Returns the name given at construction.

Definition at line 54 of file bop_base.h.

◆ Optimize()

virtual Status operations_research::bop::BopOptimizerBase::Optimize ( const BopParameters & parameters,
const ProblemState & problem_state,
LearnedInfo * learned_info,
TimeLimit * time_limit )
pure virtual

Tries to infer more information about the problem state, i.e. reduces the gap by increasing the lower bound or finding a better solution. Returns SOLUTION_FOUND when a new solution with a better objective cost is found before a time limit. The learned information is cleared and the filled with any new information about the problem, e.g. a new lower bound.

Preconditions: ShouldBeRun() must returns true.

Implemented in operations_research::bop::BopRandomFirstSolutionGenerator, operations_research::bop::GuidedSatFirstSolutionGenerator, operations_research::bop::LinearRelaxation, operations_research::bop::PortfolioOptimizer, and operations_research::bop::SatCoreBasedOptimizer.

◆ ShouldBeRun()

virtual bool operations_research::bop::BopOptimizerBase::ShouldBeRun ( const ProblemState & problem_state) const
pure virtual

Returns true if this optimizer should be run on the given problem state. Some optimizer requires a feasible solution to run for instance.

Note
a similar effect can be achieved if Optimize() returns ABORT right away. However, doing the later will lower the chance of this optimizer to be called again since it will count as a failure to improve the current state.

Implemented in operations_research::bop::BopRandomFirstSolutionGenerator, operations_research::bop::GuidedSatFirstSolutionGenerator, operations_research::bop::LinearRelaxation, operations_research::bop::PortfolioOptimizer, and operations_research::bop::SatCoreBasedOptimizer.

Member Data Documentation

◆ name_

const std::string operations_research::bop::BopOptimizerBase::name_
protected

Definition at line 106 of file bop_base.h.

◆ stats_

StatsGroup operations_research::bop::BopOptimizerBase::stats_
mutableprotected

Definition at line 108 of file bop_base.h.


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