Google OR-Tools v9.14
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::math_opt::PrimalSolution Struct Reference

Detailed Description

A solution to an optimization problem.

E.g. consider a simple linear program: min c * x s.t. A * x >= b x >= 0. A primal solution is assignment values to x. It is feasible if it satisfies A * x >= b and x >= 0 from above. In the class PrimalSolution, variable_values is x and objective_value is c * x.

For the general case of a MathOpt optimization model.

Definition at line 63 of file solution.h.

#include <solution.h>

Public Member Functions

PrimalSolutionProto Proto () const
 Returns the proto equivalent of this.
double get_objective_value (Objective objective) const

Static Public Member Functions

static absl::StatusOr< PrimalSolutionFromProto (ModelStorageCPtr model, const PrimalSolutionProto &primal_solution_proto)

Public Attributes

VariableMap< double > variable_values
double objective_value = 0.0
absl::flat_hash_map< Objective, double > auxiliary_objective_values
SolutionStatus feasibility_status = SolutionStatus::kUndetermined

Member Function Documentation

◆ FromProto()

absl::StatusOr< PrimalSolution > operations_research::math_opt::PrimalSolution::FromProto ( ModelStorageCPtr model,
const PrimalSolutionProto & primal_solution_proto )
static

Returns the PrimalSolution equivalent of primal_solution_proto.

Returns an error when:

  • VariableValuesFromProto(primal_solution_proto.variable_values) fails.
  • the feasibility_status is not specified.

Definition at line 59 of file solution.cc.

◆ get_objective_value()

double operations_research::math_opt::PrimalSolution::get_objective_value ( Objective objective) const

Returns the value for the given objective.

Will CHECK-fail if objective has been deleted, or if it is from the is from the wrong model (however, if the solution has no variables, this CHECK will not occur due to an implementation detail of the struct).

Here we assume all keys are in the same storage. As PrimalSolution is not properly encapsulated, we can't maintain a ModelStorage pointer and iterating on all keys would have a too high cost.

Definition at line 92 of file solution.cc.

◆ Proto()

PrimalSolutionProto operations_research::math_opt::PrimalSolution::Proto ( ) const

Returns the proto equivalent of this.

Definition at line 82 of file solution.cc.

Member Data Documentation

◆ auxiliary_objective_values

absl::flat_hash_map<Objective, double> operations_research::math_opt::PrimalSolution::auxiliary_objective_values

Definition at line 84 of file solution.h.

◆ feasibility_status

SolutionStatus operations_research::math_opt::PrimalSolution::feasibility_status = SolutionStatus::kUndetermined

Definition at line 86 of file solution.h.

◆ objective_value

double operations_research::math_opt::PrimalSolution::objective_value = 0.0

Definition at line 83 of file solution.h.

◆ variable_values

VariableMap<double> operations_research::math_opt::PrimalSolution::variable_values

Definition at line 82 of file solution.h.


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