Google OR-Tools: operations_research::SolutionCollector Class Reference

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

#include <constraint_solver.h>

operations_research::SearchMonitor operations_research::BaseObject

Public Member Functions

 SolutionCollector (Solver *solver, const Assignment *assignment)
 SolutionCollector (Solver *solver)
 SolutionCollector (const SolutionCollector &)=delete
SolutionCollectoroperator= (const SolutionCollector &)=delete
 ~SolutionCollector () override
void Install () override
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
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 AtLocalOptimum ()
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
BaseObjectoperator= (const BaseObject &)=delete
virtual ~BaseObject ()=default

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)
operations_research::SolutionCollector::SolutionCollector ( Solver * solver,
const Assignment * assignment )

◆ SolutionCollector() [2/3]

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

◆ SolutionCollector() [3/3]

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

◆ ~SolutionCollector()

operations_research::SolutionCollector::~SolutionCollector ( )
override

◆ Add() [1/6]

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

◆ Add() [2/6]

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

◆ Add() [3/6]

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

◆ Add() [4/6]

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

◆ Add() [5/6]

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

◆ Add() [6/6]

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

◆ AddObjective()

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

◆ AddObjectives()

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

◆ 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 2539 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 2494 of file search.cc.

◆ BuildSolutionDataForCurrentState()

◆ check_index()

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

◆ DebugString()

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

◆ 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 2522 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 2526 of file search.cc.

◆ EnterSearch()

void operations_research::SolutionCollector::EnterSearch ( )
overridevirtual

◆ 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 2499 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 2534 of file search.cc.

◆ FreeSolution()

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

◆ has_solution()

bool operations_research::SolutionCollector::has_solution ( ) const

Returns whether any solutions were stored during the search.

Definition at line 2487 of file search.cc.

◆ Install()

void operations_research::SolutionCollector::Install ( )
overridevirtual

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 2375 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 2481 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 2504 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 2509 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 2530 of file search.cc.

◆ PopSolution()

void operations_research::SolutionCollector::PopSolution ( )
protected

Remove and delete the last popped solution.

Definition at line 2436 of file search.cc.

◆ Push()

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

◆ PushSolution()

void operations_research::SolutionCollector::PushSolution ( )
protected

Push the current state as a new solution.

Definition at line 2432 of file search.cc.

◆ solution()

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

Returns the nth solution.

Definition at line 2476 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 2485 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 2518 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 2544 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 2514 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 2489 of file search.cc.

◆ prototype_

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

protected

◆ recycle_solutions_

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

protected

◆ solution_data_

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

protected

◆ solution_pool_

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

protected

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