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

#include <constraint_solver.h>

Inheritance diagram for operations_research::SolutionCollector:
operations_research::SearchMonitor operations_research::BaseObject

Classes

struct  SolutionData
 

Public Member Functions

 SolutionCollector (Solver *solver, const Assignment *assignment)
 -------— Solution Collectors --------—
 
 SolutionCollector (Solver *solver)
 
 SolutionCollector (const SolutionCollector &)=delete
 This type is neither copyable nor movable.
 
SolutionCollectoroperator= (const SolutionCollector &)=delete
 
 ~SolutionCollector () override
 
void Install () override
 A search monitors adds itself on the active search.
 
std::string DebugString () const override
 
void Add (IntVar *var)
 Add API.
 
void Add (const std::vector< IntVar * > &vars)
 
void Add (IntervalVar *var)
 
void Add (const std::vector< IntervalVar * > &vars)
 
void Add (SequenceVar *var)
 
void Add (const std::vector< SequenceVar * > &vars)
 
void AddObjective (IntVar *objective)
 
void AddObjectives (const std::vector< IntVar * > &objectives)
 
void EnterSearch () override
 Beginning of the search.
 
int solution_count () const
 Returns how many solutions were stored during the search.
 
bool has_solution () const
 Returns whether any solutions were stored during the search.
 
Assignmentsolution (int n) const
 Returns the nth solution.
 
Assignmentlast_solution_or_null () const
 Returns the last solution if there are any, nullptr otherwise.
 
int64_t wall_time (int n) const
 Returns the wall time in ms for the nth solution.
 
int64_t branches (int n) const
 Returns the number of branches when the nth solution was found.
 
int64_t failures (int n) const
 
int64_t objective_value (int n) const
 Returns the objective value of the nth solution.
 
int64_t ObjectiveValueFromIndex (int n, int index) const
 Returns the value of the index-th objective of the nth solution.
 
int64_t Value (int n, IntVar *var) const
 This is a shortcut to get the Value of 'var' in the nth solution.
 
int64_t StartValue (int n, IntervalVar *var) const
 This is a shortcut to get the StartValue of 'var' in the nth solution.
 
int64_t EndValue (int n, IntervalVar *var) const
 This is a shortcut to get the EndValue of 'var' in the nth solution.
 
int64_t DurationValue (int n, IntervalVar *var) const
 This is a shortcut to get the DurationValue of 'var' in the nth solution.
 
int64_t PerformedValue (int n, IntervalVar *var) const
 This is a shortcut to get the PerformedValue of 'var' in the nth solution.
 
const std::vector< int > & ForwardSequence (int n, SequenceVar *var) const
 
const std::vector< int > & BackwardSequence (int n, SequenceVar *var) const
 
const std::vector< int > & Unperformed (int n, SequenceVar *var) const
 
- 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 bool AtSolution ()
 
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 void PeriodicCheck ()
 Periodic call to check limits in long running methods.
 
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 ()
 

Protected Member Functions

void PushSolution ()
 Push the current state as a new solution.
 
void Push (const SolutionData &data)
 
void PopSolution ()
 Remove and delete the last popped solution.
 
SolutionData BuildSolutionDataForCurrentState ()
 
void FreeSolution (Assignment *solution)
 
void check_index (int n) const
 
- Protected Member Functions inherited from operations_research::SearchMonitor
void ListenToEvent (Solver::MonitorEvent event)
 

Protected Attributes

std::unique_ptr< Assignmentprototype_
 
std::vector< SolutionDatasolution_data_
 
std::vector< Assignment * > recycle_solutions_
 
std::vector< std::unique_ptr< Assignment > > solution_pool_
 

Additional Inherited Members

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

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 4388 of file constraint_solver.h.

Constructor & Destructor Documentation

◆ SolutionCollector() [1/3]

operations_research::SolutionCollector::SolutionCollector ( Solver * solver,
const Assignment * assignment )

-------— Solution Collectors --------—

--— Base Class --—

Definition at line 2313 of file search.cc.

◆ SolutionCollector() [2/3]

operations_research::SolutionCollector::SolutionCollector ( Solver * solver)
explicit

Definition at line 2319 of file search.cc.

◆ SolutionCollector() [3/3]

operations_research::SolutionCollector::SolutionCollector ( const SolutionCollector & )
delete

This type is neither copyable nor movable.

◆ ~SolutionCollector()

operations_research::SolutionCollector::~SolutionCollector ( )
override

Definition at line 2322 of file search.cc.

Member Function Documentation

◆ Add() [1/6]

void operations_research::SolutionCollector::Add ( const std::vector< IntervalVar * > & vars)

Definition at line 2373 of file search.cc.

◆ Add() [2/6]

void operations_research::SolutionCollector::Add ( const std::vector< IntVar * > & vars)

Definition at line 2361 of file search.cc.

◆ Add() [3/6]

void operations_research::SolutionCollector::Add ( const std::vector< SequenceVar * > & vars)

Definition at line 2385 of file search.cc.

◆ Add() [4/6]

void operations_research::SolutionCollector::Add ( IntervalVar * var)

Definition at line 2367 of file search.cc.

◆ Add() [5/6]

void operations_research::SolutionCollector::Add ( IntVar * var)

Add API.

Definition at line 2355 of file search.cc.

◆ Add() [6/6]

void operations_research::SolutionCollector::Add ( SequenceVar * var)

Definition at line 2379 of file search.cc.

◆ AddObjective()

void operations_research::SolutionCollector::AddObjective ( IntVar * objective)

Definition at line 2391 of file search.cc.

◆ AddObjectives()

void operations_research::SolutionCollector::AddObjectives ( const std::vector< IntVar * > & objectives)

Definition at line 2397 of file search.cc.

◆ BackwardSequence()

const std::vector< int > & operations_research::SolutionCollector::BackwardSequence ( int n,
SequenceVar * 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.

Definition at line 2515 of file search.cc.

◆ branches()

int64_t operations_research::SolutionCollector::branches ( int n) const

Returns the number of branches when the nth solution was found.

Definition at line 2470 of file search.cc.

◆ BuildSolutionDataForCurrentState()

SolutionCollector::SolutionData operations_research::SolutionCollector::BuildSolutionDataForCurrentState ( )
protected

Definition at line 2420 of file search.cc.

◆ check_index()

void operations_research::SolutionCollector::check_index ( int n) const
protected

Definition at line 2447 of file search.cc.

◆ DebugString()

std::string operations_research::SolutionCollector::DebugString ( ) const
inlineoverridevirtual

Reimplemented from operations_research::BaseObject.

Definition at line 4401 of file constraint_solver.h.

◆ DurationValue()

int64_t operations_research::SolutionCollector::DurationValue ( int n,
IntervalVar * var ) const

This is a shortcut to get the DurationValue of 'var' in the nth solution.

Definition at line 2498 of file search.cc.

◆ EndValue()

int64_t operations_research::SolutionCollector::EndValue ( int n,
IntervalVar * var ) const

This is a shortcut to get the EndValue of 'var' in the nth solution.

Definition at line 2502 of file search.cc.

◆ EnterSearch()

void operations_research::SolutionCollector::EnterSearch ( )
overridevirtual

Beginning of the search.

Reimplemented from operations_research::SearchMonitor.

Definition at line 2403 of file search.cc.

◆ failures()

int64_t operations_research::SolutionCollector::failures ( int n) const

Returns the number of failures encountered at the time of the nth solution.

Definition at line 2475 of file search.cc.

◆ ForwardSequence()

const std::vector< int > & operations_research::SolutionCollector::ForwardSequence ( int n,
SequenceVar * 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.

Definition at line 2510 of file search.cc.

◆ FreeSolution()

void operations_research::SolutionCollector::FreeSolution ( Assignment * solution)
protected

Definition at line 2441 of file search.cc.

◆ has_solution()

bool operations_research::SolutionCollector::has_solution ( ) const

Returns whether any solutions were stored during the search.

Definition at line 2463 of file search.cc.

◆ Install()

void operations_research::SolutionCollector::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 2351 of file search.cc.

◆ last_solution_or_null()

Assignment * operations_research::SolutionCollector::last_solution_or_null ( ) const

Returns the last solution if there are any, nullptr otherwise.

Definition at line 2457 of file search.cc.

◆ objective_value()

int64_t operations_research::SolutionCollector::objective_value ( int n) const

Returns the objective value of the nth solution.

Definition at line 2480 of file search.cc.

◆ ObjectiveValueFromIndex()

int64_t operations_research::SolutionCollector::ObjectiveValueFromIndex ( int n,
int index ) const

Returns the value of the index-th objective of the nth solution.

Definition at line 2485 of file search.cc.

◆ operator=()

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

◆ PerformedValue()

int64_t operations_research::SolutionCollector::PerformedValue ( int n,
IntervalVar * var ) const

This is a shortcut to get the PerformedValue of 'var' in the nth solution.

Definition at line 2506 of file search.cc.

◆ PopSolution()

void operations_research::SolutionCollector::PopSolution ( )
protected

Remove and delete the last popped solution.

Definition at line 2412 of file search.cc.

◆ Push()

void operations_research::SolutionCollector::Push ( const SolutionData & data)
inlineprotected

Definition at line 4484 of file constraint_solver.h.

◆ PushSolution()

void operations_research::SolutionCollector::PushSolution ( )
protected

Push the current state as a new solution.

Definition at line 2408 of file search.cc.

◆ solution()

Assignment * operations_research::SolutionCollector::solution ( int n) const

Returns the nth solution.

Definition at line 2452 of file search.cc.

◆ solution_count()

int operations_research::SolutionCollector::solution_count ( ) const

Returns how many solutions were stored during the search.

Definition at line 2461 of file search.cc.

◆ StartValue()

int64_t operations_research::SolutionCollector::StartValue ( int n,
IntervalVar * var ) const

This is a shortcut to get the StartValue of 'var' in the nth solution.

Definition at line 2494 of file search.cc.

◆ Unperformed()

const std::vector< int > & operations_research::SolutionCollector::Unperformed ( int n,
SequenceVar * var ) const

This is a shortcut to get the list of unperformed of 'var' in the nth solution.

Definition at line 2520 of file search.cc.

◆ Value()

int64_t operations_research::SolutionCollector::Value ( int n,
IntVar * var ) const

This is a shortcut to get the Value of 'var' in the nth solution.

Definition at line 2490 of file search.cc.

◆ wall_time()

int64_t operations_research::SolutionCollector::wall_time ( int n) const

Returns the wall time in ms for the nth solution.

Definition at line 2465 of file search.cc.

Member Data Documentation

◆ prototype_

std::unique_ptr<Assignment> operations_research::SolutionCollector::prototype_
protected

Definition at line 4491 of file constraint_solver.h.

◆ recycle_solutions_

std::vector<Assignment*> operations_research::SolutionCollector::recycle_solutions_
protected

Definition at line 4493 of file constraint_solver.h.

◆ solution_data_

std::vector<SolutionData> operations_research::SolutionCollector::solution_data_
protected

Definition at line 4492 of file constraint_solver.h.

◆ solution_pool_

std::vector<std::unique_ptr<Assignment> > operations_research::SolutionCollector::solution_pool_
protected

Definition at line 4495 of file constraint_solver.h.


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