21#include "absl/log/check.h"
22#include "absl/status/status.h"
23#include "absl/status/statusor.h"
24#include "absl/strings/str_cat.h"
25#include "absl/strings/string_view.h"
26#include "absl/time/time.h"
27#include "absl/types/span.h"
42template <
typename EnumType>
43bool ParseEnumFlag(
const absl::string_view text, EnumType*
const value,
44 std::string*
const error) {
46 if (!enum_value.has_value()) {
47 *error =
"unknown value for enumeration";
55template <
typename EnumType>
56std::string UnparseEnumFlag(
const EnumType value) {
57 std::ostringstream oss;
94 static constexpr SolverType kSolverTypeValues[] = {
100 return absl::MakeConstSpan(kSolverTypeValues);
104 std::string*
const error) {
105 return ParseEnumFlag(text, value, error);
109 return UnparseEnumFlag(value);
116 return "primal_simplex";
118 return "dual_simplex";
122 return "first_order";
128 static constexpr LPAlgorithm kLPAlgorithmValues[] = {
134 return absl::MakeConstSpan(kLPAlgorithmValues);
138 std::string*
const error) {
139 return ParseEnumFlag(text, value, error);
143 return UnparseEnumFlag(value);
163 static constexpr Emphasis kEmphasisValues[] = {
167 return absl::MakeConstSpan(kEmphasisValues);
171 std::string*
const error) {
172 return ParseEnumFlag(text, value, error);
176 return UnparseEnumFlag(value);
278 _ <<
"invalid time_limit");
331 std::string* error) {
338 *error = absl::StrCat(
339 "SolveParametersProto was invalid and could not convert to "
341 params.status().ToString());
344 *solve_parameters = *std::move(params);
void set_compute_unbound_rays_if_possible(bool value)
bool compute_unbound_rays_if_possible() const
bool has_compute_unbound_rays_if_possible() const
optional bool compute_unbound_rays_if_possible = 1;
void set_name(Arg_ &&arg, Args_... args)
void set_value(Arg_ &&arg, Args_... args)
::operations_research::math_opt::GurobiParametersProto_Parameter *PROTOBUF_NONNULL add_parameters()
GurobiParametersProto_Parameter Parameter
nested types -------------------------------------------------—
const ::operations_research::math_opt::GurobiParametersProto_Parameter & parameters(int index) const
::operations_research::math_opt::GurobiParametersProto *PROTOBUF_NONNULL mutable_gurobi()
const ::operations_research::math_opt::HighsOptionsProto & highs() const
::operations_research::math_opt::EmphasisProto presolve() const
const ::operations_research::sat::SatParameters & cp_sat() const
bool has_cutoff_limit() const
optional double cutoff_limit = 20;
::int32_t threads() const
void set_solution_limit(::int32_t value)
const ::operations_research::math_opt::GlpkParametersProto & glpk() const
void set_presolve(::operations_research::math_opt::EmphasisProto value)
void set_lp_algorithm(::operations_research::math_opt::LPAlgorithmProto value)
bool has_objective_limit() const
optional double objective_limit = 21;
bool has_random_seed() const
optional int32 random_seed = 5;
void set_absolute_gap_tolerance(double value)
void set_relative_gap_tolerance(double value)
void set_node_limit(::int64_t value)
void set_solution_pool_size(::int32_t value)
bool has_solution_limit() const
optional int32 solution_limit = 23;
::operations_research::math_opt::HighsOptionsProto *PROTOBUF_NONNULL mutable_highs()
::operations_research::glop::GlopParameters *PROTOBUF_NONNULL mutable_glop()
void set_scaling(::operations_research::math_opt::EmphasisProto value)
::operations_research::pdlp::PrimalDualHybridGradientParams *PROTOBUF_NONNULL mutable_pdlp()
::operations_research::sat::SatParameters *PROTOBUF_NONNULL mutable_cp_sat()
const ::operations_research::glop::GlopParameters & glop() const
void set_objective_limit(double value)
void set_best_bound_limit(double value)
::operations_research::math_opt::EmphasisProto scaling() const
::int32_t random_seed() const
::operations_research::math_opt::EmphasisProto heuristics() const
void set_cuts(::operations_research::math_opt::EmphasisProto value)
::operations_research::GScipParameters *PROTOBUF_NONNULL mutable_gscip()
bool has_absolute_gap_tolerance() const
optional double absolute_gap_tolerance = 18;
void set_iteration_limit(::int64_t value)
void set_cutoff_limit(double value)
bool has_node_limit() const
optional int64 node_limit = 24;
double objective_limit() const
void set_threads(::int32_t value)
void set_enable_output(bool value)
::int32_t solution_pool_size() const
bool enable_output() const
double best_bound_limit() const
::operations_research::math_opt::LPAlgorithmProto lp_algorithm() const
const ::operations_research::GScipParameters & gscip() const
const ::operations_research::pdlp::PrimalDualHybridGradientParams & pdlp() const
double absolute_gap_tolerance() const
::int64_t iteration_limit() const
double relative_gap_tolerance() const
const ::operations_research::math_opt::GurobiParametersProto & gurobi() const
bool has_best_bound_limit() const
optional double best_bound_limit = 22;
::int32_t solution_limit() const
void set_heuristics(::operations_research::math_opt::EmphasisProto value)
bool has_relative_gap_tolerance() const
optional double relative_gap_tolerance = 17;
::int64_t node_limit() const
bool has_threads() const
optional int32 threads = 4;
const ::google::protobuf::Duration & time_limit() const
bool has_solution_pool_size() const
optional int32 solution_pool_size = 25;
bool has_time_limit() const
.google.protobuf.Duration time_limit = 1;
double cutoff_limit() const
bool has_iteration_limit() const
optional int64 iteration_limit = 2;
::google::protobuf::Duration *PROTOBUF_NONNULL mutable_time_limit()
void set_random_seed(::int32_t value)
::operations_research::math_opt::EmphasisProto cuts() const
::operations_research::math_opt::GlpkParametersProto *PROTOBUF_NONNULL mutable_glpk()
An object oriented wrapper for quadratic constraints in ModelStorage.
bool AbslParseFlag(const absl::string_view text, SolverType *const value, std::string *const error)
SolverType
The solvers supported by MathOpt.
Emphasis
never give an error, and will map onto their best match.
LPAlgorithm
Selects an algorithm for solving linear programs.
std::optional< typename EnumProto< P >::Cpp > EnumFromProto(P proto_value)
std::optional< E > EnumFromString(absl::string_view str)
Enum< E >::Proto EnumToProto(std::optional< E > value)
std::string AbslUnparseFlag(const SolverType value)
In SWIG mode, we don't want anything besides these top-level includes.
std::string ProtobufTextFormatPrintToStringForFlag(const google::protobuf::Message &proto)
bool ProtobufParseTextProtoForFlag(absl::string_view text, ProtoType *message_out, std::string *error_out)
inline ::absl::StatusOr< absl::Duration > DecodeGoogleApiProto(const google::protobuf::Duration &proto)
inline ::absl::StatusOr< google::protobuf::Duration > EncodeGoogleApiProto(absl::Duration d)
static absl::Span< const E > AllValues()
Returns all possible values of the enum.
static std::optional< absl::string_view > ToOptString(E value)
std::optional< bool > compute_unbound_rays_if_possible
static GlpkParameters FromProto(const GlpkParametersProto &proto)
GlpkParametersProto Proto() const
gtl::linked_hash_map< std::string, std::string > param_values
Parameter name-value pairs to set in insertion order.
GurobiParametersProto Proto() const
static GurobiParameters FromProto(const GurobiParametersProto &proto)
std::optional< LPAlgorithm > lp_algorithm
std::optional< int64_t > node_limit
std::optional< int32_t > random_seed
absl::Duration time_limit
pdlp::PrimalDualHybridGradientParams pdlp
std::optional< double > relative_gap_tolerance
static absl::StatusOr< SolveParameters > FromProto(const SolveParametersProto &proto)
std::optional< Emphasis > heuristics
std::optional< Emphasis > scaling
std::optional< double > absolute_gap_tolerance
std::optional< Emphasis > cuts
sat::SatParameters cp_sat
std::optional< int32_t > solution_limit
std::optional< int32_t > threads
If unset, use the solver default. If set, it must be >= 1.
std::optional< int64_t > iteration_limit
std::optional< int32_t > solution_pool_size
SolveParametersProto Proto() const
std::optional< double > objective_limit
std::optional< Emphasis > presolve
std::optional< double > cutoff_limit
glop::GlopParameters glop
std::optional< double > best_bound_limit
#define OR_ASSIGN_OR_RETURN3(lhs, rexpr, error_expression)