Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#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< PrimalSolution > | FromProto (const ModelStorage *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 |
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.
|
static |
Returns the PrimalSolution equivalent of primal_solution_proto.
Returns an error when:
Definition at line 59 of file solution.cc.
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.
PrimalSolutionProto operations_research::math_opt::PrimalSolution::Proto | ( | ) | const |
Returns the proto equivalent of this.
Definition at line 82 of file solution.cc.
absl::flat_hash_map<Objective, double> operations_research::math_opt::PrimalSolution::auxiliary_objective_values |
Definition at line 85 of file solution.h.
SolutionStatus operations_research::math_opt::PrimalSolution::feasibility_status = SolutionStatus::kUndetermined |
Definition at line 87 of file solution.h.
double operations_research::math_opt::PrimalSolution::objective_value = 0.0 |
Definition at line 84 of file solution.h.
VariableMap<double> operations_research::math_opt::PrimalSolution::variable_values |
Definition at line 83 of file solution.h.