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

#include <bop_solution.h>

Public Member Functions

 BopSolution (const sat::LinearBooleanProblem &problem, absl::string_view name)
 
void SetValue (VariableIndex var, bool value)
 
size_t Size () const
 
bool Value (VariableIndex var) const
 
const std::string & name () const
 
void set_name (absl::string_view name)
 
int64_t GetCost () const
 
double GetScaledCost () const
 
bool IsFeasible () const
 
util_intops::StrongVector< VariableIndex, bool >::const_iterator begin () const
 For range based iteration, i.e. for (const bool value : solution) {...}.
 
util_intops::StrongVector< VariableIndex, bool >::const_iterator end () const
 
bool operator< (const BopSolution &solution) const
 

Detailed Description

A Bop solution is a Boolean assignment for each variable of the problem. The cost value associated to the solution is the instantiation of the objective cost of the problem.

Note
a solution might not be a feasible solution, i.e. might violate some constraints of the problem. The IsFeasible() method can be used to test the feasibility.

Definition at line 39 of file bop_solution.h.

Constructor & Destructor Documentation

◆ BopSolution()

operations_research::bop::BopSolution::BopSolution ( const sat::LinearBooleanProblem & problem,
absl::string_view name )

BopSolution

Try the lucky assignment, i.e. the optimal one if feasible.

Definition at line 38 of file bop_solution.cc.

Member Function Documentation

◆ begin()

util_intops::StrongVector< VariableIndex, bool >::const_iterator operations_research::bop::BopSolution::begin ( ) const
inline

For range based iteration, i.e. for (const bool value : solution) {...}.

Definition at line 84 of file bop_solution.h.

◆ end()

util_intops::StrongVector< VariableIndex, bool >::const_iterator operations_research::bop::BopSolution::end ( ) const
inline

Definition at line 87 of file bop_solution.h.

◆ GetCost()

int64_t operations_research::bop::BopSolution::GetCost ( ) const
inline

Returns the objective cost of the solution.

Note
this code is lazy but not incremental and might run in the problem size. Use with care during search.

Definition at line 57 of file bop_solution.h.

◆ GetScaledCost()

double operations_research::bop::BopSolution::GetScaledCost ( ) const
inline

Returns the objective cost of the solution taking into account the problem cost scaling and offset. This is mainly useful for displaying the current problem cost, while internally, the algorithm works directly with the integer version of the cost returned by GetCost().

Definition at line 68 of file bop_solution.h.

◆ IsFeasible()

bool operations_research::bop::BopSolution::IsFeasible ( ) const
inline

Returns true iff the solution is feasible.

Note
this code is lazy but not incremental and might run in the problem size. Use with care during search.

Definition at line 76 of file bop_solution.h.

◆ name()

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

Definition at line 51 of file bop_solution.h.

◆ operator<()

bool operations_research::bop::BopSolution::operator< ( const BopSolution & solution) const
inline

Returns true when the cost of the argument solution is strictly greater than the cost of the object. This is used to sort solutions.

Definition at line 94 of file bop_solution.h.

◆ set_name()

void operations_research::bop::BopSolution::set_name ( absl::string_view name)
inline

Definition at line 52 of file bop_solution.h.

◆ SetValue()

void operations_research::bop::BopSolution::SetValue ( VariableIndex var,
bool value )
inline

Definition at line 43 of file bop_solution.h.

◆ Size()

size_t operations_research::bop::BopSolution::Size ( ) const
inline

Definition at line 49 of file bop_solution.h.

◆ Value()

bool operations_research::bop::BopSolution::Value ( VariableIndex var) const
inline

Definition at line 50 of file bop_solution.h.


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