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"
43template <
typename EnumType>
44bool ParseEnumFlag(
const absl::string_view text, EnumType*
const value,
45 std::string*
const error) {
47 if (!enum_value.has_value()) {
48 *error =
"unknown value for enumeration";
56template <
typename EnumType>
57std::string UnparseEnumFlag(
const EnumType value) {
58 std::ostringstream oss;
95 static constexpr SolverType kSolverTypeValues[] = {
101 return absl::MakeConstSpan(kSolverTypeValues);
105 std::string*
const error) {
106 return ParseEnumFlag(text, value, error);
110 return UnparseEnumFlag(value);
117 return "primal_simplex";
119 return "dual_simplex";
123 return "first_order";
129 static constexpr LPAlgorithm kLPAlgorithmValues[] = {
135 return absl::MakeConstSpan(kLPAlgorithmValues);
139 std::string*
const error) {
140 return ParseEnumFlag(text, value, error);
144 return UnparseEnumFlag(value);
164 static constexpr Emphasis kEmphasisValues[] = {
168 return absl::MakeConstSpan(kEmphasisValues);
172 std::string*
const error) {
173 return ParseEnumFlag(text, value, error);
177 return UnparseEnumFlag(value);
299 _ <<
"invalid time_limit");
353 std::string* error) {
360 *error = absl::StrCat(
361 "SolveParametersProto was invalid and could not convert to "
363 params.status().ToString());
366 *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
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
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
::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
bool has_random_seed() const
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
::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
void set_iteration_limit(::int64_t value)
void set_cutoff_limit(double value)
bool has_node_limit() const
const ::operations_research::math_opt::XpressParametersProto & xpress() const
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
::operations_research::math_opt::XpressParametersProto *PROTOBUF_NONNULL mutable_xpress()
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
::int32_t solution_limit() const
void set_heuristics(::operations_research::math_opt::EmphasisProto value)
bool has_relative_gap_tolerance() const
::int64_t node_limit() const
const ::google::protobuf::Duration & time_limit() const
bool has_solution_pool_size() const
bool has_time_limit() const
double cutoff_limit() const
bool has_iteration_limit() const
::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()
void set_name(Arg_ &&arg, Args_... args)
void set_value(Arg_ &&arg, Args_... args)
XpressParametersProto_Parameter Parameter
::operations_research::math_opt::XpressParametersProto_Parameter *PROTOBUF_NONNULL add_parameters()
const ::operations_research::math_opt::XpressParametersProto_Parameter & parameters(int index) const
bool AbslParseFlag(const absl::string_view text, SolverType *const value, std::string *const error)
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)
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()
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
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
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
XpressParametersProto Proto() const
static XpressParameters FromProto(const XpressParametersProto &proto)
gtl::linked_hash_map< std::string, std::string > param_values
#define OR_ASSIGN_OR_RETURN3(lhs, rexpr, error_expression)