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

#include <bop_base.h>

Public Member Functions

 ProblemState (const sat::LinearBooleanProblem &problem)
 
 ProblemState (const ProblemState &)=delete
 This type is neither copyable nor movable.
 
ProblemStateoperator= (const ProblemState &)=delete
 
void SetParameters (const BopParameters &parameters)
 Sets parameters, used for instance to get the tolerance, the gap limit...
 
const BopParameters & GetParameters () const
 
void set_assignment_preference (const std::vector< bool > &a)
 
std::vector< bool > assignment_preference () const
 
bool MergeLearnedInfo (const LearnedInfo &learned_info, BopOptimizerBase::Status optimization_status)
 
LearnedInfo GetLearnedInfo () const
 
int64_t update_stamp () const
 
void MarkAsOptimal ()
 Marks the problem state as optimal.
 
void MarkAsInfeasible ()
 Marks the problem state as infeasible.
 
bool IsOptimal () const
 
bool IsInfeasible () const
 Returns true when the problem is proved to be infeasible.
 
bool IsVariableFixed (VariableIndex var) const
 
const util_intops::StrongVector< VariableIndex, bool > & is_fixed () const
 
bool GetVariableFixedValue (VariableIndex var) const
 
const util_intops::StrongVector< VariableIndex, bool > & fixed_values () const
 
const glop::DenseRowlp_values () const
 
const BopSolutionsolution () const
 
const sat::LinearBooleanProblem & original_problem () const
 
int64_t lower_bound () const
 
int64_t upper_bound () const
 
double GetScaledLowerBound () const
 Returns the scaled lower bound of the original problem.
 
const std::vector< sat::BinaryClause > & NewlyAddedBinaryClauses () const
 Returns the newly added binary clause since the last SynchronizationDone().
 
void SynchronizationDone ()
 

Static Public Attributes

static const int64_t kInitialStampValue
 

Detailed Description

This class represents the current state of the problem with all the information that the solver learned about it at a given time.

Definition at line 119 of file bop_base.h.

Constructor & Destructor Documentation

◆ ProblemState() [1/2]

operations_research::bop::ProblemState::ProblemState ( const sat::LinearBooleanProblem & problem)
explicit

◆ ProblemState() [2/2]

operations_research::bop::ProblemState::ProblemState ( const ProblemState & )
delete

This type is neither copyable nor movable.

Member Function Documentation

◆ assignment_preference()

std::vector< bool > operations_research::bop::ProblemState::assignment_preference ( ) const
inline

Definition at line 139 of file bop_base.h.

◆ fixed_values()

const util_intops::StrongVector< VariableIndex, bool > & operations_research::bop::ProblemState::fixed_values ( ) const
inline

Definition at line 194 of file bop_base.h.

◆ GetLearnedInfo()

LearnedInfo operations_research::bop::ProblemState::GetLearnedInfo ( ) const

Returns all the information learned so far.

Todo
(user): In the current implementation the learned information only contains binary clauses added since the last call to SynchronizationDone(). Add an iterator on the sat::BinaryClauseManager.

Definition at line 231 of file bop_base.cc.

◆ GetParameters()

const BopParameters & operations_research::bop::ProblemState::GetParameters ( ) const
inline

Definition at line 132 of file bop_base.h.

◆ GetScaledLowerBound()

double operations_research::bop::ProblemState::GetScaledLowerBound ( ) const
inline

Returns the scaled lower bound of the original problem.

Definition at line 222 of file bop_base.h.

◆ GetVariableFixedValue()

bool operations_research::bop::ProblemState::GetVariableFixedValue ( VariableIndex var) const
inline

Returns the value of the fixed variable var. Should be only called on fixed variables (CHECKed).

Definition at line 191 of file bop_base.h.

◆ is_fixed()

const util_intops::StrongVector< VariableIndex, bool > & operations_research::bop::ProblemState::is_fixed ( ) const
inline

Definition at line 185 of file bop_base.h.

◆ IsInfeasible()

bool operations_research::bop::ProblemState::IsInfeasible ( ) const
inline

Returns true when the problem is proved to be infeasible.

Definition at line 180 of file bop_base.h.

◆ IsOptimal()

bool operations_research::bop::ProblemState::IsOptimal ( ) const
inline

Returns true when the current state is proved to be optimal. In such a case solution() returns the optimal solution.

Definition at line 175 of file bop_base.h.

◆ IsVariableFixed()

bool operations_research::bop::ProblemState::IsVariableFixed ( VariableIndex var) const
inline

Returns true when the variable var is fixed in the current problem state. The value of the fixed variable is returned by GetVariableFixedValue(var).

Definition at line 184 of file bop_base.h.

◆ lower_bound()

int64_t operations_research::bop::ProblemState::lower_bound ( ) const
inline

Returns the current lower (resp. upper) bound of the objective cost. For internal use only: this is the unscaled version of the lower (resp. upper) bound, and so should be compared only to the unscaled cost given by solution.GetCost().

Definition at line 218 of file bop_base.h.

◆ lp_values()

const glop::DenseRow & operations_research::bop::ProblemState::lp_values ( ) const
inline

Returns the values of the LP relaxation of the problem. Returns an empty vector when the LP has not been populated.

Definition at line 200 of file bop_base.h.

◆ MarkAsInfeasible()

void operations_research::bop::ProblemState::MarkAsInfeasible ( )

Marks the problem state as infeasible.

Mark as infeasible, i.e. set a lower_bound greater than the upper_bound.

Definition at line 253 of file bop_base.cc.

◆ MarkAsOptimal()

void operations_research::bop::ProblemState::MarkAsOptimal ( )

Marks the problem state as optimal.

Definition at line 247 of file bop_base.cc.

◆ MergeLearnedInfo()

bool operations_research::bop::ProblemState::MergeLearnedInfo ( const LearnedInfo & learned_info,
BopOptimizerBase::Status optimization_status )

Merges the learned information with the current problem state. For instance, if variables x, and y are fixed in the current state, and z is learned to be fixed, the result of the merge will be x, y, and z being fixed in the problem state.

Note
the LP values contained in the learned information (if any) will replace the LP values of the problem state, whatever the cost is. Returns true when the merge has changed the problem state.
Todo
(user): refactor this to not rely on the optimization status. All the information can be encoded in the learned_info bounds.

The lower bound might be greater that the cost of a feasible solution due to rounding errors in the problem scaling and Glop. As a feasible solution was found, the solution is proved optimal.

Merge fixed variables. Note that variables added during search, i.e. not in the original problem, are ignored.

Set the solution to the fixed variables.

Definition at line 108 of file bop_base.cc.

◆ NewlyAddedBinaryClauses()

const std::vector< sat::BinaryClause > & operations_research::bop::ProblemState::NewlyAddedBinaryClauses ( ) const

Returns the newly added binary clause since the last SynchronizationDone().

Definition at line 265 of file bop_base.cc.

◆ operator=()

ProblemState & operations_research::bop::ProblemState::operator= ( const ProblemState & )
delete

◆ original_problem()

const sat::LinearBooleanProblem & operations_research::bop::ProblemState::original_problem ( ) const
inline

Returns the original problem. Note that the current problem might be different, e.g. fixed variables, but equivalent, i.e. a solution to one should be a solution to the other too.

Definition at line 210 of file bop_base.h.

◆ set_assignment_preference()

void operations_research::bop::ProblemState::set_assignment_preference ( const std::vector< bool > & a)
inline

Sets an assignment preference for each variable. This is only used for warm start.

Definition at line 136 of file bop_base.h.

◆ SetParameters()

void operations_research::bop::ProblemState::SetParameters ( const BopParameters & parameters)
inline

Sets parameters, used for instance to get the tolerance, the gap limit...

Definition at line 128 of file bop_base.h.

◆ solution()

const BopSolution & operations_research::bop::ProblemState::solution ( ) const
inline

Returns the solution to the current state problem.

Note
the solution might not be feasible because until we find one, it will just be the all-false assignment.

Definition at line 205 of file bop_base.h.

◆ SynchronizationDone()

void operations_research::bop::ProblemState::SynchronizationDone ( )

Resets what is considered "new" information. This is meant to be called once all the optimize have been synchronized.

Definition at line 270 of file bop_base.cc.

◆ update_stamp()

int64_t operations_research::bop::ProblemState::update_stamp ( ) const
inline

Definition at line 165 of file bop_base.h.

◆ upper_bound()

int64_t operations_research::bop::ProblemState::upper_bound ( ) const
inline

Definition at line 219 of file bop_base.h.

Member Data Documentation

◆ kInitialStampValue

const int64_t operations_research::bop::ProblemState::kInitialStampValue
static

The stamp represents an upper bound on the number of times the problem state has been updated. If the stamp changed since last time one has checked the state, it's worth trying again as it might have changed (no guarantee).

ProblemState

Definition at line 164 of file bop_base.h.


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