Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
An object oriented wrapper for quadratic constraints in ModelStorage. More...
Namespaces | |
namespace | internal |
Typedefs | |
using | Sos1ConstraintData = internal::SosConstraintData<Sos1ConstraintId> |
using | Sos2ConstraintData = internal::SosConstraintData<Sos2ConstraintId> |
using | SparseSubmatrixRowsView |
template<typename SparseVector > | |
using | sparse_value_type |
using | Callback = std::function<CallbackResult(const CallbackData&)> |
using | ProtoEnumIsValid = bool (*)(int) |
template<typename V > | |
using | LinearConstraintMap = absl::flat_hash_map<LinearConstraint, V> |
using | MockSolveFunction |
using | MessageCallback = std::function<void(const std::vector<std::string>&)> |
template<typename V > | |
using | ObjectiveMap = absl::flat_hash_map<Objective, V> |
using | SolveFunction |
using | Range = std::pair<double, double> |
A range of values, first is the minimum, second is the maximum. | |
template<typename V > | |
using | VariableMap = absl::flat_hash_map<Variable, V> |
using | QuadraticProductId = std::pair<VariableId, VariableId> |
Id type used for quadratic terms, i.e. products of two variables. | |
template<typename V > | |
using | QuadraticTermMap = absl::flat_hash_map<QuadraticTermKey, V> |
using | GRBenvUniquePtr = std::unique_ptr<GRBenv, GurobiFreeEnv> |
using | ObjectiveId = std::optional<AuxiliaryObjectiveId> |
nullopt denotes the primary objective. | |
Enumerations | |
enum class | SupportType { kNotSupported = 1 , kSupported = 2 , kNotImplemented = 3 } |
enum class | BasisStatus : int8_t { kFree = BASIS_STATUS_FREE , kAtLowerBound = BASIS_STATUS_AT_LOWER_BOUND , kAtUpperBound = BASIS_STATUS_AT_UPPER_BOUND , kFixedValue = BASIS_STATUS_FIXED_VALUE , kBasic = BASIS_STATUS_BASIC } |
Status of a variable/constraint in a LP basis. More... | |
enum class | CallbackEvent { kPresolve = CALLBACK_EVENT_PRESOLVE , kSimplex = CALLBACK_EVENT_SIMPLEX , kMip = CALLBACK_EVENT_MIP , kMipSolution = CALLBACK_EVENT_MIP_SOLUTION , kMipNode = CALLBACK_EVENT_MIP_NODE , kBarrier = CALLBACK_EVENT_BARRIER } |
The supported events during a solve for callbacks. More... | |
enum class | SolverType { kGscip = SOLVER_TYPE_GSCIP , kGurobi = SOLVER_TYPE_GUROBI , kGlop = SOLVER_TYPE_GLOP , kCpSat = SOLVER_TYPE_CP_SAT , kPdlp = SOLVER_TYPE_PDLP , kGlpk = SOLVER_TYPE_GLPK , kEcos = SOLVER_TYPE_ECOS , kScs = SOLVER_TYPE_SCS , kHighs = SOLVER_TYPE_HIGHS , kSantorini = SOLVER_TYPE_SANTORINI } |
The solvers supported by MathOpt. More... | |
enum class | LPAlgorithm { kPrimalSimplex = LP_ALGORITHM_PRIMAL_SIMPLEX , kDualSimplex = LP_ALGORITHM_DUAL_SIMPLEX , kBarrier = LP_ALGORITHM_BARRIER , kFirstOrder = LP_ALGORITHM_FIRST_ORDER } |
Selects an algorithm for solving linear programs. More... | |
enum class | Emphasis { kOff = EMPHASIS_OFF , kLow = EMPHASIS_LOW , kMedium = EMPHASIS_MEDIUM , kHigh = EMPHASIS_HIGH , kVeryHigh = EMPHASIS_VERY_HIGH } |
never give an error, and will map onto their best match. More... | |
enum class | SolutionStatus { kUndetermined = SOLUTION_STATUS_UNDETERMINED , kFeasible = SOLUTION_STATUS_FEASIBLE , kInfeasible = SOLUTION_STATUS_INFEASIBLE } |
Feasibility of a primal or dual solution as claimed by the solver. More... | |
enum class | FeasibilityStatus { kUndetermined = FEASIBILITY_STATUS_UNDETERMINED , kFeasible = FEASIBILITY_STATUS_FEASIBLE , kInfeasible = FEASIBILITY_STATUS_INFEASIBLE } |
enum class | TerminationReason { kOptimal = TERMINATION_REASON_OPTIMAL , kInfeasible = TERMINATION_REASON_INFEASIBLE , kUnbounded = TERMINATION_REASON_UNBOUNDED , kInfeasibleOrUnbounded = TERMINATION_REASON_INFEASIBLE_OR_UNBOUNDED , kImprecise = TERMINATION_REASON_IMPRECISE , kFeasible = TERMINATION_REASON_FEASIBLE , kNoSolutionFound = TERMINATION_REASON_NO_SOLUTION_FOUND , kNumericalError = TERMINATION_REASON_NUMERICAL_ERROR , kOtherError = TERMINATION_REASON_OTHER_ERROR } |
The reason a call to Solve() terminates. More... | |
enum class | Limit { kUndetermined = LIMIT_UNDETERMINED , kIteration = LIMIT_ITERATION , kTime = LIMIT_TIME , kNode = LIMIT_NODE , kSolution = LIMIT_SOLUTION , kMemory = LIMIT_MEMORY , kCutoff = LIMIT_CUTOFF , kObjective = LIMIT_OBJECTIVE , kNorm = LIMIT_NORM , kInterrupted = LIMIT_INTERRUPTED , kSlowProgress = LIMIT_SLOW_PROGRESS , kOther = LIMIT_OTHER } |
enum class | QpSupportType { kNoQpSupport , kDiagonalQpOnly , kConvexQp } |
enum | GlpkRayType { kPrimal , kDual } |
The type of the GlpkRay. More... | |
Functions | |
absl::StatusOr< GRBenv * > | NewPrimaryEnvFromISVKey (const GurobiIsvKey &isv_key) |
std::ostream & | operator<< (std::ostream &ostr, const IndicatorConstraint &constraint) |
bool | operator== (const IndicatorConstraint &lhs, const IndicatorConstraint &rhs) |
bool | operator!= (const IndicatorConstraint &lhs, const IndicatorConstraint &rhs) |
template<typename H > | |
H | AbslHashValue (H h, const IndicatorConstraint &constraint) |
absl::Status | ValidateConstraint (const IndicatorConstraintProto &constraint, const IdNameBiMap &variable_universe) |
std::ostream & | operator<< (std::ostream &ostr, const QuadraticConstraint &constraint) |
bool | operator== (const QuadraticConstraint &lhs, const QuadraticConstraint &rhs) |
bool | operator!= (const QuadraticConstraint &lhs, const QuadraticConstraint &rhs) |
template<typename H > | |
H | AbslHashValue (H h, const QuadraticConstraint &quadratic_constraint) |
absl::Status | ValidateConstraint (const QuadraticConstraintProto &constraint, const IdNameBiMap &variable_universe) |
std::ostream & | operator<< (std::ostream &ostr, const SecondOrderConeConstraint &constraint) |
bool | operator== (const SecondOrderConeConstraint &lhs, const SecondOrderConeConstraint &rhs) |
bool | operator!= (const SecondOrderConeConstraint &lhs, const SecondOrderConeConstraint &rhs) |
template<typename H > | |
H | AbslHashValue (H h, const SecondOrderConeConstraint &constraint) |
absl::Status | ValidateConstraint (const SecondOrderConeConstraintProto &constraint, const IdNameBiMap &variable_universe) |
std::ostream & | operator<< (std::ostream &ostr, const Sos1Constraint &constraint) |
bool | operator== (const Sos1Constraint &lhs, const Sos1Constraint &rhs) |
bool | operator!= (const Sos1Constraint &lhs, const Sos1Constraint &rhs) |
template<typename H > | |
H | AbslHashValue (H h, const Sos1Constraint &constraint) |
std::ostream & | operator<< (std::ostream &ostr, const Sos2Constraint &constraint) |
bool | operator== (const Sos2Constraint &lhs, const Sos2Constraint &rhs) |
bool | operator!= (const Sos2Constraint &lhs, const Sos2Constraint &rhs) |
template<typename H > | |
H | AbslHashValue (H h, const Sos2Constraint &constraint) |
absl::Status | ValidateConstraint (const SosConstraintProto &constraint, const IdNameBiMap &variable_universe) |
LinearExpression | ToLinearExpression (const ModelStorage &storage, const LinearExpressionData &expr_data) |
LinearExpressionData | FromLinearExpression (const LinearExpression &expression) |
Converts a LinearExpression to the associated "raw ID" format. | |
template<typename IdType > | |
std::vector< Variable > | AtomicConstraintNonzeroVariables (const ModelStorage &storage, const IdType id) |
template<typename ConstraintType > | |
std::vector< ConstraintType > | AtomicConstraints (const ModelStorage &storage) |
template<typename ConstraintType > | |
std::vector< ConstraintType > | SortedAtomicConstraints (const ModelStorage &storage) |
std::ostream & | operator<< (std::ostream &out, const BaseSolver::SolveArgs &args) |
std::ostream & | operator<< (std::ostream &out, const BaseSolver::ComputeInfeasibleSubsystemArgs &args) |
SolveResultProto | ResultForIntegerInfeasible (const bool is_maximize, const int64_t bad_variable_id, const double lb, const double ub) |
ObjectiveBoundsProto | GetObjectiveBounds (const SolveResultProto &solve_result) |
ProblemStatusProto | GetProblemStatus (const SolveResultProto &solve_result) |
void | RemoveSparseDoubleVectorZeros (SparseDoubleVectorProto &sparse_vector) |
SparseDoubleVectorProto | FilterSparseVector (const SparseDoubleVectorProto &input, const SparseVectorFilterProto &filter) |
void | ApplyAllFilters (const ModelSolveParametersProto &model_solve_params, SolutionProto &solution) |
absl::flat_hash_set< CallbackEventProto > | EventSet (const CallbackRegistrationProto &callback_registration) |
Returns the callback_registration.request_registration as a set of enums. | |
TerminationProto | TerminateForLimit (const LimitProto limit, const bool feasible, const absl::string_view detail) |
TerminationProto | FeasibleTermination (const LimitProto limit, const absl::string_view detail) |
TerminationProto | NoSolutionFoundTermination (const LimitProto limit, const absl::string_view detail) |
TerminationProto | TerminateForReason (const TerminationReasonProto reason, const absl::string_view detail) |
ObjectiveBoundsProto | MakeTrivialBounds (const bool is_maximize) |
TerminationProto | TerminateForReason (const bool is_maximize, const TerminationReasonProto reason, const absl::string_view detail) |
TerminationProto | OptimalTerminationProto (const double finite_primal_objective, const double dual_objective, const absl::string_view detail) |
TerminationProto | UnboundedTerminationProto (const bool is_maximize, const absl::string_view detail) |
TerminationProto | InfeasibleTerminationProto (bool is_maximize, const FeasibilityStatusProto dual_feasibility_status, const absl::string_view detail) |
TerminationProto | LimitTerminationProto (const bool is_maximize, const LimitProto limit, const std::optional< double > optional_finite_primal_objective, const std::optional< double > optional_dual_objective, const absl::string_view detail) |
TerminationProto | LimitTerminationProto (LimitProto limit, const double primal_objective, const double dual_objective, const bool claim_dual_feasible_solution_exists, const absl::string_view detail) |
TerminationProto | CutoffTerminationProto (bool is_maximize, absl::string_view detail={}) |
Calls NoSolutionFoundTerminationProto() with LIMIT_CUTOFF LIMIT. | |
TerminationProto | NoSolutionFoundTerminationProto (const bool is_maximize, const LimitProto limit, const std::optional< double > optional_dual_objective, const absl::string_view detail) |
TerminationProto | FeasibleTerminationProto (const bool is_maximize, const LimitProto limit, const double primal_objective, const std::optional< double > optional_dual_objective, const absl::string_view detail) |
TerminationProto | InfeasibleOrUnboundedTerminationProto (bool is_maximize, const FeasibilityStatusProto dual_feasibility_status, const absl::string_view detail) |
absl::Status | ModelIsSupported (const ModelProto &model, const SupportedProblemStructures &support_menu, const absl::string_view solver_name) |
bool | UpdateIsSupported (const ModelUpdateProto &update, const SupportedProblemStructures &support_menu) |
void | UpgradeSolveResultProtoForStatsMigration (SolveResultProto &solve_result_proto) |
int | NumVariables (const VariablesProto &variables) |
int | NumConstraints (const LinearConstraintsProto &linear_constraints) |
int | NumMatrixNonzeros (const SparseDoubleMatrixProto &matrix) |
std::optional< int64_t > | FirstVariableId (const VariablesProto &variables) |
std::optional< int64_t > | FirstLinearConstraintId (const LinearConstraintsProto &linear_constraints) |
ABSL_DEPRECATED ("Use TerminateForReason(bool, TerminationReasonProto, absl::string_view) " "instead") TerminationProto TerminateForReason(TerminationReasonProto reason | |
template<typename T > | |
std::vector< T > | SortedSetElements (const absl::flat_hash_set< T > &elements) |
template<typename K , typename V > | |
std::vector< K > | MapKeys (const absl::flat_hash_map< K, V > &in_map) |
template<typename K , typename V > | |
std::vector< K > | MapKeys (const google::protobuf::Map< K, V > &in_map) |
template<typename K , typename V > | |
std::vector< K > | SortedMapKeys (const absl::flat_hash_map< K, V > &in_map) |
template<typename K , typename V > | |
std::vector< K > | SortedMapKeys (const google::protobuf::Map< K, V > &in_map) |
SparseSubmatrixRowsView | SparseSubmatrixByRows (const SparseDoubleMatrixProto &matrix, const int64_t start_row_id, const std::optional< int64_t > end_row_id, const int64_t start_col_id, const std::optional< int64_t > end_col_id) |
std::vector< std::pair< int64_t, SparseVector< double > > > | TransposeSparseSubmatrix (const SparseSubmatrixRowsView &submatrix_by_rows) |
template<typename Collection , typename T = typename Collection::value_type> | |
SparseVectorView< T > | MakeView (absl::Span< const int64_t > ids, const Collection &values) |
template<typename T > | |
SparseVectorView< const T * > | MakeView (const google::protobuf::RepeatedField< int64_t > &ids, const google::protobuf::RepeatedPtrField< T > &values) |
template<typename SparseVectorProto , typename T = sparse_value_type<SparseVectorProto>> | |
SparseVectorView< T > | MakeView (const SparseVectorProto &sparse_vector) |
template<typename T > | |
SparseVectorView< T > | MakeView (const SparseVector< T > &sparse_vector) |
MATH_OPT_DEFINE_ENUM (BasisStatus, BASIS_STATUS_UNSPECIFIED) | |
MATH_OPT_DEFINE_ENUM (CallbackEvent, CALLBACK_EVENT_UNSPECIFIED) | |
std::ostream & | operator<< (std::ostream &out, const ModelSubset::Bounds &bounds) |
std::ostream & | operator<< (std::ostream &out, const ModelSubset &model_subset) |
std::ostream & | operator<< (std::ostream &out, const ComputeInfeasibleSubsystemResult &result) |
template<typename E > | |
Enum< E >::Proto | EnumToProto (std::optional< E > value) |
template<typename E > | |
Enum< E >::Proto | EnumToProto (E value) |
template<typename P > | |
std::optional< typename EnumProto< P >::Cpp > | EnumFromProto (P proto_value) |
template<typename E > | |
absl::string_view | EnumToString (E value) |
template<typename E > | |
std::optional< absl::string_view > | EnumToOptString (E value) |
template<typename E > | |
std::optional< E > | EnumFromString (absl::string_view str) |
template<typename E , typename = std::enable_if_t<Enum<E>::kIsImplemented>> | |
std::ostream & | operator<< (std::ostream &out, const E value) |
template<typename E , typename = std::enable_if_t<Enum<E>::kIsImplemented>> | |
std::ostream & | operator<< (std::ostream &out, const std::optional< E > opt_value) |
std::ostream & | operator<< (std::ostream &out, const LeadingCoefficientFormatter formatter) |
std::ostream & | operator<< (std::ostream &out, const ConstantFormatter formatter) |
template<typename Map , typename = std::enable_if_t<is_key_type_v<typename Map::key_type>>> | |
std::vector< typename Map::key_type > | SortedKeys (const Map &map) |
template<typename Set , typename = std::enable_if_t<is_key_type_v<typename Set::key_type>>> | |
std::vector< typename Set::key_type > | SortedElements (const Set &set) |
template<typename Map , typename Keys , typename = std::enable_if_t<is_key_type_v<typename Map::key_type>>> | |
std::vector< typename Map::mapped_type > | Values (const Map &map, const Keys &keys) |
std::ostream & | operator<< (std::ostream &ostr, const LinearConstraint &linear_constraint) |
bool | operator== (const LinearConstraint &lhs, const LinearConstraint &rhs) |
bool | operator!= (const LinearConstraint &lhs, const LinearConstraint &rhs) |
template<typename H > | |
H | AbslHashValue (H h, const LinearConstraint &linear_constraint) |
absl::StatusOr< MapFilter< Variable > > | VariableFilterFromProto (const Model &model, const SparseVectorFilterProto &proto) |
absl::StatusOr< MapFilter< LinearConstraint > > | LinearConstraintFilterFromProto (const Model &model, const SparseVectorFilterProto &proto) |
absl::StatusOr< MapFilter< QuadraticConstraint > > | QuadraticConstraintFilterFromProto (const Model &model, const SparseVectorFilterProto &proto) |
template<typename KeyType > | |
MapFilter< KeyType > | MakeSkipAllFilter () |
template<typename KeyType > | |
MapFilter< KeyType > | MakeSkipZerosFilter () |
template<typename Collection , typename ValueType = typename Collection::value_type> | |
MapFilter< ValueType > | MakeKeepKeysFilter (const Collection &keys) |
template<typename KeyType > | |
MapFilter< KeyType > | MakeKeepKeysFilter (std::initializer_list< KeyType > keys) |
void | PrintTo (const PrimalSolution &primal_solution, std::ostream *const os) |
void | PrintTo (const DualSolution &dual_solution, std::ostream *const os) |
void | PrintTo (const PrimalRay &primal_ray, std::ostream *const os) |
void | PrintTo (const DualRay &dual_ray, std::ostream *const os) |
void | PrintTo (const Basis &basis, std::ostream *const os) |
void | PrintTo (const Solution &solution, std::ostream *const os) |
void | PrintTo (const SolveResult &result, std::ostream *const os) |
Matcher< VariableMap< double > > | IsNearlySubsetOf (VariableMap< double > expected, double tolerance) |
Matcher< VariableMap< double > > | IsNear (VariableMap< double > expected, const double tolerance) |
Matcher< LinearConstraintMap< double > > | IsNearlySubsetOf (LinearConstraintMap< double > expected, double tolerance) |
Matcher< LinearConstraintMap< double > > | IsNear (LinearConstraintMap< double > expected, const double tolerance) |
Matcher< absl::flat_hash_map< QuadraticConstraint, double > > | IsNear (absl::flat_hash_map< QuadraticConstraint, double > expected, const double tolerance) |
Matcher< absl::flat_hash_map< QuadraticConstraint, double > > | IsNearlySubsetOf (absl::flat_hash_map< QuadraticConstraint, double > expected, double tolerance) |
template<typename K > | |
Matcher< absl::flat_hash_map< K, double > > | IsNear (absl::flat_hash_map< K, double > expected, const double tolerance) |
template<typename K > | |
Matcher< absl::flat_hash_map< K, double > > | IsNearlySubsetOf (absl::flat_hash_map< K, double > expected, const double tolerance) |
testing::Matcher< LinearExpression > | IsIdentical (LinearExpression expected) |
testing::Matcher< LinearExpression > | LinearExpressionIsNear (const LinearExpression expected, const double tolerance) |
testing::Matcher< BoundedLinearExpression > | IsNearlyEquivalent (const BoundedLinearExpression &expected, const double tolerance) |
testing::Matcher< QuadraticExpression > | IsIdentical (QuadraticExpression expected) |
Matcher< SolutionStatus > | SolutionStatusIs (const SolutionStatus expected, const bool allow_undetermined) |
Matcher< PrimalSolution > | IsNear (PrimalSolution expected, const double tolerance, const bool allow_undetermined) |
Matcher< DualSolution > | IsNear (DualSolution expected, const double tolerance, const bool allow_undetermined) |
Matcher< Basis > | BasisIs (const Basis &expected) |
Matcher< Solution > | IsNear (Solution expected, const SolutionMatcherOptions options) |
Matcher< PrimalRay > | IsNear (PrimalRay expected, const double tolerance) |
Matcher< PrimalRay > | PrimalRayIsNear (VariableMap< double > expected_var_values, const double tolerance) |
Matcher< DualRay > | IsNear (DualRay expected, const double tolerance) |
Matcher< ObjectiveBounds > | ObjectiveBoundsNear (const ObjectiveBounds &expected, const double tolerance) |
Matcher< SolveResult > | TerminatesWithOneOf (const std::vector< TerminationReason > &allowed) |
Checks that the result has one of the allowed termination reasons. | |
Matcher< SolveResult > | TerminatesWith (const TerminationReason expected) |
testing::Matcher< SolveResult > | TerminatesWithLimit (const Limit expected, const bool allow_limit_undetermined) |
testing::Matcher< SolveResult > | TerminatesWithReasonFeasible (const Limit expected, const bool allow_limit_undetermined) |
testing::Matcher< SolveResult > | TerminatesWithReasonNoSolutionFound (const Limit expected, const bool allow_limit_undetermined) |
template<typename MatcherType > | |
std::string | MatcherToStringImpl (const MatcherType &matcher, const bool negate) |
template<typename T > | |
std::string | MatcherToString (const Matcher< T > &matcher, bool negate) |
template<typename T > | |
std::string | MatcherToString (const ::testing::PolymorphicMatcher< T > &matcher, bool negate) |
MATCHER_P (FirstElementIs, first_element_matcher,(negation ? absl::StrCat("is empty or first element ", MatcherToString(first_element_matcher, true)) :absl::StrCat("has at least one element and first element ", MatcherToString(first_element_matcher, false)))) | |
Matcher< Termination > | LimitIs (math_opt::Limit limit, const Matcher< std::string > detail_matcher) |
Matcher< Termination > | ReasonIs (TerminationReason reason) |
Matcher< Termination > | ReasonIsOptimal () |
Matcher< ProblemStatus > | ProblemStatusIs (const ProblemStatus &expected) |
Matcher< Termination > | TerminationIsOptimal () |
Matcher< Termination > | TerminationIsOptimal (const double primal_objective_value, const std::optional< double > dual_objective_value, const double tolerance) |
Matcher< Termination > | TerminationIsIgnoreDetail (const Termination &expected) |
Matcher< SolveResult > | IsOptimal (const std::optional< double > expected_primal_objective, const double tolerance) |
Matcher< SolveResult > | IsOptimalWithSolution (const double expected_objective, const VariableMap< double > expected_variable_values, const double tolerance) |
Matcher< SolveResult > | IsOptimalWithDualSolution (const double expected_objective, const LinearConstraintMap< double > expected_dual_values, const VariableMap< double > expected_reduced_costs, const double tolerance) |
Matcher< SolveResult > | IsOptimalWithDualSolution (const double expected_objective, const LinearConstraintMap< double > expected_dual_values, const absl::flat_hash_map< QuadraticConstraint, double > expected_quadratic_dual_values, const VariableMap< double > expected_reduced_costs, const double tolerance) |
Matcher< SolveResult > | HasSolution (PrimalSolution expected, double tolerance=kMatcherDefaultTolerance) |
SolveResult has a primal solution matching expected within tolerance. | |
Matcher< SolveResult > | HasDualSolution (DualSolution expected, const double tolerance) |
Matcher< SolveResult > | HasPrimalRay (PrimalRay expected, const double tolerance) |
Matcher< SolveResult > | HasPrimalRay (VariableMap< double > expected_vars, const double tolerance) |
Matcher< SolveResult > | HasDualRay (DualRay expected, const double tolerance) |
Matcher< SolveResult > | IsConsistentWith (const SolveResult &expected, const SolveResultMatcherOptions &options) |
testing::Matcher< ComputeInfeasibleSubsystemResult > | IsFeasible () |
testing::Matcher< ComputeInfeasibleSubsystemResult > | IsUndetermined () |
testing::Matcher< ComputeInfeasibleSubsystemResult > | IsInfeasible (const std::optional< bool > expected_is_minimal, const std::optional< ModelSubset > expected_infeasible_subsystem) |
Matcher< UpdateResult > | DidUpdate () |
Actual UpdateResult.did_update is true. | |
testing::Matcher< Termination > | LimitIs (Limit limit, testing::Matcher< std::string > detail_matcher=testing::_) |
template<typename K , typename V , typename = std::enable_if_t<is_key_type_v<K>>> | |
void | PrintTo (const absl::flat_hash_map< K, V > &id_map, std::ostream *const os) |
MessageCallback | PrinterMessageCallback (std::ostream &output_stream, const absl::string_view prefix) |
MessageCallback | InfoLoggerMessageCallback (const absl::string_view prefix, const absl::SourceLocation loc) |
MessageCallback | VLoggerMessageCallback (int level, absl::string_view prefix, absl::SourceLocation loc) |
MessageCallback | VectorMessageCallback (std::vector< std::string > *sink) |
MessageCallback | RepeatedPtrFieldMessageCallback (google::protobuf::RepeatedPtrField< std::string > *sink) |
std::ostream & | operator<< (std::ostream &ostr, const Model &model) |
std::ostream & | operator<< (std::ostream &ostr, const Objective &objective) |
bool | operator== (const Objective &lhs, const Objective &rhs) |
bool | operator!= (const Objective &lhs, const Objective &rhs) |
template<typename H > | |
H | AbslHashValue (H h, const Objective &objective) |
bool | AbslParseFlag (const absl::string_view text, SolverType *const value, std::string *const error) |
std::string | AbslUnparseFlag (const SolverType value) |
bool | AbslParseFlag (absl::string_view text, LPAlgorithm *const value, std::string *const error) |
std::string | AbslUnparseFlag (const LPAlgorithm value) |
bool | AbslParseFlag (absl::string_view text, Emphasis *const value, std::string *const error) |
std::string | AbslUnparseFlag (const Emphasis value) |
bool | AbslParseFlag (absl::string_view text, SolveParameters *solve_parameters, std::string *error) |
std::string | AbslUnparseFlag (SolveParameters solve_parameters) |
MATH_OPT_DEFINE_ENUM (SolverType, SOLVER_TYPE_UNSPECIFIED) | |
MATH_OPT_DEFINE_ENUM (LPAlgorithm, LP_ALGORITHM_UNSPECIFIED) | |
MATH_OPT_DEFINE_ENUM (Emphasis, EMPHASIS_UNSPECIFIED) | |
MATH_OPT_DEFINE_ENUM (SolutionStatus, SOLUTION_STATUS_UNSPECIFIED) | |
absl::StatusOr< SolveResult > | Solve (const Model &model, const SolverType solver_type, const SolveArguments &solve_args, const SolverInitArguments &init_args) |
absl::StatusOr< ComputeInfeasibleSubsystemResult > | ComputeInfeasibleSubsystem (const Model &model, const SolverType solver_type, const ComputeInfeasibleSubsystemArguments &compute_args, const SolverInitArguments &init_args) |
absl::StatusOr< std::unique_ptr< IncrementalSolver > > | NewIncrementalSolver (Model *model, SolverType solver_type, SolverInitArguments arguments) |
std::ostream & | operator<< (std::ostream &ostr, const ObjectiveBounds &objective_bounds) |
std::ostream & | operator<< (std::ostream &ostr, const Termination &termination) |
std::ostream & | operator<< (std::ostream &ostr, const ProblemStatus &problem_status) |
std::ostream & | operator<< (std::ostream &ostr, const SolveStats &solve_stats) |
absl::Status | CheckSolverSpecificOutputEmpty (const SolveResultProto &result) |
std::ostream & | operator<< (std::ostream &out, const SolveResult &result) |
MATH_OPT_DEFINE_ENUM (FeasibilityStatus, FEASIBILITY_STATUS_UNSPECIFIED) | |
MATH_OPT_DEFINE_ENUM (TerminationReason, TERMINATION_REASON_UNSPECIFIED) | |
MATH_OPT_DEFINE_ENUM (Limit, LIMIT_UNSPECIFIED) | |
bool | AbslParseFlag (const absl::string_view text, SolverResources *const solver_resources, std::string *const error) |
std::string | AbslUnparseFlag (const SolverResources &solver_resources) |
absl::StatusOr< VariableMap< double > > | VariableValuesFromProto (const ModelStorage *const model, const SparseDoubleVectorProto &vars_proto) |
absl::StatusOr< VariableMap< int32_t > > | VariableValuesFromProto (const ModelStorage *model, const SparseInt32VectorProto &vars_proto) |
SparseDoubleVectorProto | VariableValuesToProto (const VariableMap< double > &variable_values) |
Returns the proto equivalent of variable_values. | |
absl::StatusOr< absl::flat_hash_map< Objective, double > > | AuxiliaryObjectiveValuesFromProto (const ModelStorage *const model, const google::protobuf::Map< int64_t, double > &aux_obj_proto) |
google::protobuf::Map< int64_t, double > | AuxiliaryObjectiveValuesToProto (const absl::flat_hash_map< Objective, double > &aux_obj_values) |
absl::StatusOr< LinearConstraintMap< double > > | LinearConstraintValuesFromProto (const ModelStorage *const model, const SparseDoubleVectorProto &lin_cons_proto) |
SparseDoubleVectorProto | LinearConstraintValuesToProto (const LinearConstraintMap< double > &linear_constraint_values) |
Returns the proto equivalent of linear_constraint_values. | |
absl::StatusOr< absl::flat_hash_map< QuadraticConstraint, double > > | QuadraticConstraintValuesFromProto (const ModelStorage *const model, const SparseDoubleVectorProto &quad_cons_proto) |
SparseDoubleVectorProto | QuadraticConstraintValuesToProto (const absl::flat_hash_map< QuadraticConstraint, double > &quadratic_constraint_values) |
Returns the proto equivalent of quadratic_constraint_values. | |
absl::StatusOr< VariableMap< BasisStatus > > | VariableBasisFromProto (const ModelStorage *const model, const SparseBasisStatusVector &basis_proto) |
SparseBasisStatusVector | VariableBasisToProto (const VariableMap< BasisStatus > &basis_values) |
Returns the proto equivalent of basis_values. | |
absl::StatusOr< LinearConstraintMap< BasisStatus > > | LinearConstraintBasisFromProto (const ModelStorage *const model, const SparseBasisStatusVector &basis_proto) |
SparseBasisStatusVector | LinearConstraintBasisToProto (const LinearConstraintMap< BasisStatus > &basis_values) |
Returns the proto equivalent of basis_values. | |
std::ostream & | operator<< (std::ostream &out, const ModelRanges &ranges) |
ModelRanges | ComputeModelRanges (const Model &model) |
Returns the ranges of the finite non-zero values in the given model. | |
std::ostream & | operator<< (std::ostream &ostr, const LinearExpression &expression) |
std::ostream & | operator<< (std::ostream &ostr, const BoundedLinearExpression &bounded_expression) |
std::ostream & | operator<< (std::ostream &ostr, const QuadraticExpression &expr) |
std::ostream & | operator<< (std::ostream &ostr, const BoundedQuadraticExpression &bounded_expression) |
internal::VariablesEquality | operator== (const Variable &lhs, const Variable &rhs) |
bool | operator!= (const Variable &lhs, const Variable &rhs) |
std::ostream & | operator<< (std::ostream &ostr, const Variable &variable) |
LinearTerm | operator* (double coefficient, LinearTerm term) |
LinearTerm | operator* (LinearTerm term, double coefficient) |
LinearTerm | operator* (double coefficient, Variable variable) |
LinearTerm | operator* (Variable variable, double coefficient) |
LinearTerm | operator/ (LinearTerm term, double coefficient) |
LinearTerm | operator/ (Variable variable, double coefficient) |
template<typename Iterable > | |
LinearExpression | Sum (const Iterable &items) |
RightIterable LinearExpression | InnerProduct (const LeftIterable &left, const RightIterable &right) |
LinearExpression | operator- (LinearExpression expr) |
LinearExpression | operator+ (Variable lhs, double rhs) |
LinearExpression | operator+ (double lhs, Variable rhs) |
LinearExpression | operator+ (Variable lhs, Variable rhs) |
LinearExpression | operator+ (const LinearTerm &lhs, double rhs) |
LinearExpression | operator+ (double lhs, const LinearTerm &rhs) |
LinearExpression | operator+ (const LinearTerm &lhs, Variable rhs) |
LinearExpression | operator+ (Variable lhs, const LinearTerm &rhs) |
LinearExpression | operator+ (const LinearTerm &lhs, const LinearTerm &rhs) |
LinearExpression | operator+ (LinearExpression lhs, double rhs) |
LinearExpression | operator+ (double lhs, LinearExpression rhs) |
LinearExpression | operator+ (LinearExpression lhs, Variable rhs) |
LinearExpression | operator+ (Variable lhs, LinearExpression rhs) |
LinearExpression | operator+ (LinearExpression lhs, const LinearTerm &rhs) |
LinearExpression | operator+ (LinearTerm lhs, LinearExpression rhs) |
LinearExpression | operator+ (LinearExpression lhs, const LinearExpression &rhs) |
LinearExpression | operator- (Variable lhs, double rhs) |
LinearExpression | operator- (double lhs, Variable rhs) |
LinearExpression | operator- (Variable lhs, Variable rhs) |
LinearExpression | operator- (const LinearTerm &lhs, double rhs) |
LinearExpression | operator- (double lhs, const LinearTerm &rhs) |
LinearExpression | operator- (const LinearTerm &lhs, Variable rhs) |
LinearExpression | operator- (Variable lhs, const LinearTerm &rhs) |
LinearExpression | operator- (const LinearTerm &lhs, const LinearTerm &rhs) |
LinearExpression | operator- (LinearExpression lhs, double rhs) |
LinearExpression | operator- (double lhs, LinearExpression rhs) |
LinearExpression | operator- (LinearExpression lhs, Variable rhs) |
LinearExpression | operator- (Variable lhs, LinearExpression rhs) |
LinearExpression | operator- (LinearExpression lhs, const LinearTerm &rhs) |
LinearExpression | operator- (LinearTerm lhs, LinearExpression rhs) |
LinearExpression | operator- (LinearExpression lhs, const LinearExpression &rhs) |
LinearExpression | operator* (LinearExpression lhs, double rhs) |
LinearExpression | operator* (double lhs, LinearExpression rhs) |
LinearExpression | operator/ (LinearExpression lhs, double rhs) |
LowerBoundedLinearExpression | operator>= (LinearExpression expression, double constant) |
LowerBoundedLinearExpression | operator<= (double constant, LinearExpression expression) |
LowerBoundedLinearExpression | operator>= (const LinearTerm &term, double constant) |
LowerBoundedLinearExpression | operator<= (double constant, const LinearTerm &term) |
LowerBoundedLinearExpression | operator>= (Variable variable, double constant) |
LowerBoundedLinearExpression | operator<= (double constant, Variable variable) |
UpperBoundedLinearExpression | operator<= (LinearExpression expression, double constant) |
UpperBoundedLinearExpression | operator>= (double constant, LinearExpression expression) |
UpperBoundedLinearExpression | operator<= (const LinearTerm &term, double constant) |
UpperBoundedLinearExpression | operator>= (double constant, const LinearTerm &term) |
UpperBoundedLinearExpression | operator<= (Variable variable, double constant) |
UpperBoundedLinearExpression | operator>= (double constant, Variable variable) |
BoundedLinearExpression | operator<= (LowerBoundedLinearExpression lhs, double rhs) |
BoundedLinearExpression | operator>= (double lhs, LowerBoundedLinearExpression rhs) |
BoundedLinearExpression | operator>= (UpperBoundedLinearExpression lhs, double rhs) |
BoundedLinearExpression | operator<= (double lhs, UpperBoundedLinearExpression rhs) |
BoundedLinearExpression | operator<= (LinearExpression lhs, const LinearExpression &rhs) |
BoundedLinearExpression | operator>= (LinearExpression lhs, const LinearExpression &rhs) |
BoundedLinearExpression | operator<= (LinearExpression lhs, const LinearTerm &rhs) |
BoundedLinearExpression | operator>= (LinearExpression lhs, const LinearTerm &rhs) |
BoundedLinearExpression | operator<= (const LinearTerm &lhs, LinearExpression rhs) |
BoundedLinearExpression | operator>= (const LinearTerm &lhs, LinearExpression rhs) |
BoundedLinearExpression | operator<= (LinearExpression lhs, Variable rhs) |
BoundedLinearExpression | operator>= (LinearExpression lhs, Variable rhs) |
BoundedLinearExpression | operator<= (Variable lhs, LinearExpression rhs) |
BoundedLinearExpression | operator>= (Variable lhs, LinearExpression rhs) |
BoundedLinearExpression | operator<= (const LinearTerm &lhs, const LinearTerm &rhs) |
BoundedLinearExpression | operator>= (const LinearTerm &lhs, const LinearTerm &rhs) |
BoundedLinearExpression | operator<= (const LinearTerm &lhs, Variable rhs) |
BoundedLinearExpression | operator>= (const LinearTerm &lhs, Variable rhs) |
BoundedLinearExpression | operator<= (Variable lhs, const LinearTerm &rhs) |
BoundedLinearExpression | operator>= (Variable lhs, const LinearTerm &rhs) |
BoundedLinearExpression | operator<= (Variable lhs, Variable rhs) |
BoundedLinearExpression | operator>= (Variable lhs, Variable rhs) |
BoundedLinearExpression | operator== (LinearExpression lhs, const LinearExpression &rhs) |
BoundedLinearExpression | operator== (LinearExpression lhs, const LinearTerm &rhs) |
BoundedLinearExpression | operator== (const LinearTerm &lhs, LinearExpression rhs) |
BoundedLinearExpression | operator== (LinearExpression lhs, Variable rhs) |
BoundedLinearExpression | operator== (Variable lhs, LinearExpression rhs) |
BoundedLinearExpression | operator== (LinearExpression lhs, double rhs) |
BoundedLinearExpression | operator== (double lhs, LinearExpression rhs) |
BoundedLinearExpression | operator== (const LinearTerm &lhs, const LinearTerm &rhs) |
BoundedLinearExpression | operator== (const LinearTerm &lhs, Variable rhs) |
BoundedLinearExpression | operator== (Variable lhs, const LinearTerm &rhs) |
BoundedLinearExpression | operator== (const LinearTerm &lhs, double rhs) |
BoundedLinearExpression | operator== (double lhs, const LinearTerm &rhs) |
BoundedLinearExpression | operator== (Variable lhs, double rhs) |
BoundedLinearExpression | operator== (double lhs, Variable rhs) |
std::ostream & | operator<< (std::ostream &ostr, const QuadraticTermKey &key) |
bool | operator== (QuadraticTermKey lhs, QuadraticTermKey rhs) |
bool | operator!= (QuadraticTermKey lhs, QuadraticTermKey rhs) |
QuadraticTerm | operator- (QuadraticTerm term) |
------------------------— Subtraction (-) ------------------------------— | |
QuadraticTerm | operator* (const double lhs, QuadraticTerm rhs) |
-------------------------— Multiplication (*) --------------------------— | |
QuadraticTerm | operator* (Variable lhs, Variable rhs) |
QuadraticTerm | operator* (Variable lhs, LinearTerm rhs) |
QuadraticTerm | operator* (LinearTerm lhs, Variable rhs) |
QuadraticTerm | operator* (LinearTerm lhs, LinearTerm rhs) |
QuadraticTerm | operator* (QuadraticTerm lhs, const double rhs) |
QuadraticTerm | operator/ (QuadraticTerm lhs, const double rhs) |
----------------------------— Division (/) -----------------------------— | |
QuadraticExpression | operator- (QuadraticExpression expr) |
QuadraticExpression | operator+ (const double lhs, const QuadraticTerm &rhs) |
--------------------------— Addition (+) -------------------------------— | |
QuadraticExpression | operator+ (double lhs, QuadraticExpression rhs) |
QuadraticExpression | operator+ (Variable lhs, const QuadraticTerm &rhs) |
QuadraticExpression | operator+ (Variable lhs, QuadraticExpression rhs) |
QuadraticExpression | operator+ (const LinearTerm &lhs, const QuadraticTerm &rhs) |
QuadraticExpression | operator+ (const LinearTerm &lhs, QuadraticExpression rhs) |
QuadraticExpression | operator+ (LinearExpression lhs, const QuadraticTerm &rhs) |
QuadraticExpression | operator+ (const LinearExpression &lhs, QuadraticExpression rhs) |
QuadraticExpression | operator+ (const QuadraticTerm &lhs, double rhs) |
QuadraticExpression | operator+ (const QuadraticTerm &lhs, Variable rhs) |
QuadraticExpression | operator+ (const QuadraticTerm &lhs, const LinearTerm &rhs) |
QuadraticExpression | operator+ (const QuadraticTerm &lhs, LinearExpression rhs) |
QuadraticExpression | operator+ (const QuadraticTerm &lhs, const QuadraticTerm &rhs) |
QuadraticExpression | operator+ (const QuadraticTerm &lhs, QuadraticExpression rhs) |
QuadraticExpression | operator+ (QuadraticExpression lhs, double rhs) |
QuadraticExpression | operator+ (QuadraticExpression lhs, Variable rhs) |
QuadraticExpression | operator+ (QuadraticExpression lhs, const LinearTerm &rhs) |
QuadraticExpression | operator+ (QuadraticExpression lhs, const LinearExpression &rhs) |
QuadraticExpression | operator+ (QuadraticExpression lhs, const QuadraticTerm &rhs) |
QuadraticExpression | operator+ (QuadraticExpression lhs, const QuadraticExpression &rhs) |
QuadraticExpression | operator- (double lhs, const QuadraticTerm &rhs) |
QuadraticExpression | operator- (double lhs, QuadraticExpression rhs) |
QuadraticExpression | operator- (Variable lhs, const QuadraticTerm &rhs) |
QuadraticExpression | operator- (Variable lhs, QuadraticExpression rhs) |
QuadraticExpression | operator- (const LinearTerm &lhs, const QuadraticTerm &rhs) |
QuadraticExpression | operator- (const LinearTerm &lhs, QuadraticExpression rhs) |
QuadraticExpression | operator- (LinearExpression lhs, const QuadraticTerm &rhs) |
QuadraticExpression | operator- (const LinearExpression &lhs, QuadraticExpression rhs) |
QuadraticExpression | operator- (const QuadraticTerm &lhs, double rhs) |
QuadraticExpression | operator- (const QuadraticTerm &lhs, Variable rhs) |
QuadraticExpression | operator- (const QuadraticTerm &lhs, const LinearTerm &rhs) |
QuadraticExpression | operator- (const QuadraticTerm &lhs, LinearExpression rhs) |
QuadraticExpression | operator- (const QuadraticTerm &lhs, const QuadraticTerm &rhs) |
QuadraticExpression | operator- (const QuadraticTerm &lhs, QuadraticExpression rhs) |
QuadraticExpression | operator- (QuadraticExpression lhs, double rhs) |
QuadraticExpression | operator- (QuadraticExpression lhs, Variable rhs) |
QuadraticExpression | operator- (QuadraticExpression lhs, const LinearTerm &rhs) |
QuadraticExpression | operator- (QuadraticExpression lhs, const LinearExpression &rhs) |
QuadraticExpression | operator- (QuadraticExpression lhs, const QuadraticTerm &rhs) |
QuadraticExpression | operator- (QuadraticExpression lhs, const QuadraticExpression &rhs) |
QuadraticExpression | operator* (double lhs, QuadraticExpression rhs) |
QuadraticExpression | operator* (Variable lhs, const LinearExpression &rhs) |
QuadraticExpression | operator* (LinearTerm lhs, const LinearExpression &rhs) |
QuadraticExpression | operator* (const LinearExpression &lhs, Variable rhs) |
QuadraticExpression | operator* (const LinearExpression &lhs, LinearTerm rhs) |
QuadraticExpression | operator* (const LinearExpression &lhs, const LinearExpression &rhs) |
QuadraticExpression | operator* (QuadraticExpression lhs, double rhs) |
QuadraticExpression | operator/ (QuadraticExpression lhs, double rhs) |
LowerBoundedQuadraticExpression | operator>= (QuadraticExpression lhs, double rhs) |
LowerBoundedQuadraticExpression | operator>= (QuadraticTerm lhs, double rhs) |
LowerBoundedQuadraticExpression | operator<= (double lhs, QuadraticExpression rhs) |
LowerBoundedQuadraticExpression | operator<= (double lhs, QuadraticTerm rhs) |
UpperBoundedQuadraticExpression | operator>= (double lhs, QuadraticExpression rhs) |
UpperBoundedQuadraticExpression | operator>= (double lhs, QuadraticTerm rhs) |
UpperBoundedQuadraticExpression | operator<= (QuadraticExpression lhs, double rhs) |
UpperBoundedQuadraticExpression | operator<= (QuadraticTerm lhs, double rhs) |
BoundedQuadraticExpression | operator>= (UpperBoundedQuadraticExpression lhs, double rhs) |
BoundedQuadraticExpression | operator>= (double lhs, LowerBoundedQuadraticExpression rhs) |
BoundedQuadraticExpression | operator<= (LowerBoundedQuadraticExpression lhs, double rhs) |
BoundedQuadraticExpression | operator<= (double lhs, UpperBoundedQuadraticExpression rhs) |
BoundedQuadraticExpression | operator>= (QuadraticExpression lhs, const QuadraticExpression &rhs) |
Comparisons with lhs = QuadraticExpression. | |
BoundedQuadraticExpression | operator>= (QuadraticExpression lhs, QuadraticTerm rhs) |
BoundedQuadraticExpression | operator>= (QuadraticExpression lhs, const LinearExpression &rhs) |
BoundedQuadraticExpression | operator>= (QuadraticExpression lhs, LinearTerm rhs) |
BoundedQuadraticExpression | operator>= (QuadraticExpression lhs, Variable rhs) |
BoundedQuadraticExpression | operator<= (QuadraticExpression lhs, const QuadraticExpression &rhs) |
BoundedQuadraticExpression | operator<= (QuadraticExpression lhs, QuadraticTerm rhs) |
BoundedQuadraticExpression | operator<= (QuadraticExpression lhs, const LinearExpression &rhs) |
BoundedQuadraticExpression | operator<= (QuadraticExpression lhs, LinearTerm rhs) |
BoundedQuadraticExpression | operator<= (QuadraticExpression lhs, Variable rhs) |
BoundedQuadraticExpression | operator== (QuadraticExpression lhs, const QuadraticExpression &rhs) |
BoundedQuadraticExpression | operator== (QuadraticExpression lhs, QuadraticTerm rhs) |
BoundedQuadraticExpression | operator== (QuadraticExpression lhs, const LinearExpression &rhs) |
BoundedQuadraticExpression | operator== (QuadraticExpression lhs, LinearTerm rhs) |
BoundedQuadraticExpression | operator== (QuadraticExpression lhs, Variable rhs) |
BoundedQuadraticExpression | operator== (QuadraticExpression lhs, double rhs) |
BoundedQuadraticExpression | operator>= (QuadraticTerm lhs, QuadraticExpression rhs) |
Comparisons with lhs = QuadraticTerm. | |
BoundedQuadraticExpression | operator>= (QuadraticTerm lhs, QuadraticTerm rhs) |
BoundedQuadraticExpression | operator>= (QuadraticTerm lhs, LinearExpression rhs) |
BoundedQuadraticExpression | operator>= (QuadraticTerm lhs, LinearTerm rhs) |
BoundedQuadraticExpression | operator>= (QuadraticTerm lhs, Variable rhs) |
BoundedQuadraticExpression | operator<= (QuadraticTerm lhs, QuadraticExpression rhs) |
BoundedQuadraticExpression | operator<= (QuadraticTerm lhs, QuadraticTerm rhs) |
BoundedQuadraticExpression | operator<= (QuadraticTerm lhs, LinearExpression rhs) |
BoundedQuadraticExpression | operator<= (QuadraticTerm lhs, LinearTerm rhs) |
BoundedQuadraticExpression | operator<= (QuadraticTerm lhs, Variable rhs) |
BoundedQuadraticExpression | operator== (QuadraticTerm lhs, QuadraticExpression rhs) |
BoundedQuadraticExpression | operator== (QuadraticTerm lhs, QuadraticTerm rhs) |
BoundedQuadraticExpression | operator== (QuadraticTerm lhs, LinearExpression rhs) |
BoundedQuadraticExpression | operator== (QuadraticTerm lhs, LinearTerm rhs) |
BoundedQuadraticExpression | operator== (QuadraticTerm lhs, Variable rhs) |
BoundedQuadraticExpression | operator== (QuadraticTerm lhs, double rhs) |
BoundedQuadraticExpression | operator>= (const LinearExpression &lhs, QuadraticExpression rhs) |
Comparisons with lhs = LinearExpression. | |
BoundedQuadraticExpression | operator>= (LinearExpression lhs, QuadraticTerm rhs) |
BoundedQuadraticExpression | operator<= (const LinearExpression &lhs, QuadraticExpression rhs) |
BoundedQuadraticExpression | operator<= (LinearExpression lhs, QuadraticTerm rhs) |
BoundedQuadraticExpression | operator== (const LinearExpression &lhs, QuadraticExpression rhs) |
BoundedQuadraticExpression | operator== (LinearExpression lhs, QuadraticTerm rhs) |
BoundedQuadraticExpression | operator>= (LinearTerm lhs, QuadraticExpression rhs) |
Comparisons with lhs = LinearTerm. | |
BoundedQuadraticExpression | operator>= (LinearTerm lhs, QuadraticTerm rhs) |
BoundedQuadraticExpression | operator<= (LinearTerm lhs, QuadraticExpression rhs) |
BoundedQuadraticExpression | operator<= (LinearTerm lhs, QuadraticTerm rhs) |
BoundedQuadraticExpression | operator== (LinearTerm lhs, QuadraticExpression rhs) |
BoundedQuadraticExpression | operator== (LinearTerm lhs, QuadraticTerm rhs) |
BoundedQuadraticExpression | operator>= (Variable lhs, QuadraticExpression rhs) |
Comparisons with lhs = Variable. | |
BoundedQuadraticExpression | operator>= (Variable lhs, QuadraticTerm rhs) |
BoundedQuadraticExpression | operator<= (Variable lhs, QuadraticExpression rhs) |
BoundedQuadraticExpression | operator<= (Variable lhs, QuadraticTerm rhs) |
BoundedQuadraticExpression | operator== (Variable lhs, QuadraticExpression rhs) |
BoundedQuadraticExpression | operator== (Variable lhs, QuadraticTerm rhs) |
BoundedQuadraticExpression | operator== (double lhs, QuadraticTerm rhs) |
Comparisons with lhs = Double. | |
BoundedQuadraticExpression | operator== (const double lhs, QuadraticExpression rhs) |
Double –. | |
template<typename H > | |
H | AbslHashValue (H h, const Variable &variable) |
template<typename LeftIterable , typename RightIterable > | |
LinearExpression | InnerProduct (const LeftIterable &left, const RightIterable &right) |
template<typename H > | |
H | AbslHashValue (H h, const QuadraticTermKey &key) |
absl::StatusOr< std::string > | ModelProtoToLp (const ModelProto &model) |
absl::StatusOr< ModelProto > | ModelProtoFromLp (const absl::string_view lp_data) |
absl::StatusOr< std::string > | ModelProtoToMps (const ModelProto &model) |
absl::StatusOr< ModelProto > | ReadMpsFile (const absl::string_view filename) |
absl::StatusOr< ModelProto > | MpsToModelProto (absl::string_view mps_data) |
Converts a string with the contents of an MPS file into a ModelProto. | |
void | RemoveNames (ModelProto &model) |
Removes the model, variables and constraints names of the provided model. | |
void | RemoveNames (ModelUpdateProto &update) |
Removes the variables and constraints names of the provided update. | |
absl::StatusOr<::operations_research::math_opt::ModelProto > | MPModelProtoToMathOptModel (const ::operations_research::MPModelProto &model) |
absl::StatusOr< std::optional< SolutionHintProto > > | MPModelProtoSolutionHintToMathOptHint (const MPModelProto &model) |
absl::StatusOr<::operations_research::MPModelProto > | MathOptModelToMPModelProto (const ::operations_research::math_opt::ModelProto &model) |
absl::StatusOr< ModelProto > | MPModelProtoToMathOptModel (const MPModelProto &model) |
absl::StatusOr< MPModelProto > | MathOptModelToMPModelProto (const ModelProto &model) |
void | AddRobustConstraint (const Model &uncertainty_model, const Variable rhs, absl::Span< const std::pair< LinearExpression, Variable > > uncertain_coefficients, Model &main_model) |
absl::Status | FormulateIndicatorConstraintAsMip (Model &model, const IndicatorConstraint indicator_constraint) |
double | LowerBound (const LinearExpression &linear_expression) |
double | UpperBound (const LinearExpression &linear_expression) |
absl::StatusOr< ModelSubset > | CheckPrimalSolutionFeasibility (const Model &model, const VariableMap< double > &variable_values, const FeasibilityCheckerOptions &options) |
absl::StatusOr< std::vector< std::string > > | ViolatedConstraintsAsStrings (const Model &model, const ModelSubset &violated_constraints, const VariableMap< double > &variable_values) |
absl::StatusOr< VariableMap< double > > | MoveVariablesToTheirBestFeasibleValue (const Model &model, const VariableMap< double > &input_solution, absl::Span< const Variable > variables, const MoveVariablesToTheirBestFeasibleValueOptions &options) |
double | RoundedLowerBound (const Variable v, const double tolerance) |
double | RoundedUpperBound (const Variable v, const double tolerance) |
Same as RoundedLowerBound() but for upper-bound. | |
bool | ActivatePrimalRay (SolverType solver_type, SolveParameters ¶ms) |
bool | ActivateDualRay (SolverType solver_type, SolveParameters ¶ms) |
std::ostream & | operator<< (std::ostream &out, const MessageCallbackTestParams ¶ms) |
std::ostream & | operator<< (std::ostream &out, const CallbackTestParams ¶ms) |
std::ostream & | operator<< (std::ostream &out, const TimeLimitTestParameters ¶ms) |
std::ostream & | operator<< (std::ostream &out, const GenericTestParameters ¶ms) |
std::ostream & | operator<< (std::ostream &ostr, const InfeasibleSubsystemSupport &support_menu) |
std::ostream & | operator<< (std::ostream &ostr, const InfeasibleSubsystemTestParameters ¶ms) |
TEST_P (InfeasibleSubsystemTest, CanComputeInfeasibleSubsystem) | |
TEST_P (InfeasibleSubsystemTest, InvertedVariableBounds) | |
TEST_P (InfeasibleSubsystemTest, IntegerVariableWithInfeasibleBounds) | |
≤ | TEST_P (InfeasibleSubsystemTest, InconsistentLessThanLinearConstraint) |
≤ | TEST_P (InfeasibleSubsystemTest, InconsistentGreaterThanLinearConstraint) |
TEST_P (InfeasibleSubsystemTest, InconsistentEqualityLinearConstraint) | |
TEST_P (InfeasibleSubsystemTest, InconsistentRangedLinearConstraint) | |
∞ ≤ x | ≤ (variable bounds) TEST_P(InfeasibleSubsystemTest |
The entire model is an IIS. | |
EXPECT_THAT (ComputeInfeasibleSubsystem(model, GetParam().solver_type), IsOkAndHolds(IsInfeasible(true, ModelSubset{ .variable_bounds={{x, ModelSubset::Bounds{.lower=false,.upper=true}}},.linear_constraints={ {c, ModelSubset::Bounds{.lower=true,.upper=false}}}}))) | |
≤ | TEST_P (InfeasibleSubsystemTest, InconsistentLessThanQuadraticConstraint) |
≤ | TEST_P (InfeasibleSubsystemTest, InconsistentGreaterThanQuadraticConstraint) |
TEST_P (InfeasibleSubsystemTest, InconsistentEqualityQuadraticConstraint) | |
EXPECT_THAT (ComputeInfeasibleSubsystem(model, GetParam().solver_type), IsOkAndHolds(IsInfeasible(true, ModelSubset{ .variable_bounds={{x, ModelSubset::Bounds{.lower=true,.upper=true}}},.quadratic_constraints={ {c, ModelSubset::Bounds{.lower=true,.upper=false}}}}))) | |
EXPECT_THAT (ComputeInfeasibleSubsystem(model, GetParam().solver_type), IsOkAndHolds(IsInfeasible(true, ModelSubset{ .variable_bounds={{x, ModelSubset::Bounds{.lower=true,.upper=false}}},.second_order_cone_constraints={c}}))) | |
EXPECT_THAT (ComputeInfeasibleSubsystem(model, GetParam().solver_type), IsOkAndHolds(IsInfeasible(true, ModelSubset{ .variable_bounds={{x, ModelSubset::Bounds{.lower=false,.upper=true}}},.second_order_cone_constraints={c}}))) | |
≤ y y | TEST_P (InfeasibleSubsystemTest, InconsistentSos1Constraint) |
TEST_P (InfeasibleSubsystemTest, InconsistentSos1ConstraintWithExpressions) | |
≤ z z ≤ y | TEST_P (InfeasibleSubsystemTest, InconsistentSos2Constraint) |
TEST_P (InfeasibleSubsystemTest, InconsistentSos2ConstraintWithExpressions) | |
EXPECT_THAT (ComputeInfeasibleSubsystem(model, GetParam().solver_type), IsOkAndHolds(IsInfeasible(true, ModelSubset{ .variable_bounds={{x, ModelSubset::Bounds{.lower=true,.upper=false}}},.variable_integrality={x},.indicator_constraints={c}}))) | |
TEST_P (InfeasibleSubsystemTest, IndicatorConstraintOkInconsistentImpliedNullIndicator) | |
TEST_P (InfeasibleSubsystemTest, NontrivialInfeasibleIpSolveWithoutLimitsFindsIIS) | |
TEST_P (InfeasibleSubsystemTest, NontrivialInfeasibleIpSolveTimeLimitZeroIsUndetermined) | |
TEST_P (InfeasibleSubsystemTest, NontrivialInfeasibleIpSolveInterruptedBeforeStartIsUndetermined) | |
TEST_P (InfeasibleSubsystemTest, NontrivialInfeasibleIpSolveWithMessageCallbackIsInvoked) | |
std::ostream & | operator<< (std::ostream &out, const InvalidInputTestParameters ¶ms) |
std::ostream & | operator<< (std::ostream &out, const InvalidParameterTestParams ¶ms) |
std::ostream & | operator<< (std::ostream &out, const SolutionHintTestParams ¶ms) |
std::ostream & | operator<< (std::ostream &out, const BranchPrioritiesTestParams ¶ms) |
std::ostream & | operator<< (std::ostream &out, const LazyConstraintsTestParams ¶ms) |
std::ostream & | operator<< (std::ostream &out, const IpMultipleSolutionsTestParams ¶ms) |
std::ostream & | operator<< (std::ostream &ostr, const SolveResultSupport &solve_result_support) |
std::ostream & | operator<< (std::ostream &ostr, const ParameterSupport ¶m_support) |
std::ostream & | operator<< (std::ostream &ostr, const IpParameterTestParameters ¶ms) |
std::ostream & | operator<< (std::ostream &out, const LargeInstanceTestParams ¶ms) |
std::ostream & | operator<< (std::ostream &out, const LogicalConstraintTestParameters ¶ms) |
std::ostream & | operator<< (std::ostream &out, const LpIncompleteSolveTestParams ¶ms) |
std::ostream & | operator<< (std::ostream &out, const LpModelSolveParametersTestParameters ¶ms) |
std::ostream & | operator<< (std::ostream &out, const LpParameterTestParams ¶ms) |
std::ostream & | operator<< (std::ostream &out, const SimpleLpTestParameters ¶ms) |
std::ostream & | operator<< (std::ostream &out, const SimpleMipTestParameters ¶ms) |
<=x<=1 IncrementalMipTest::IncrementalMipTest() :model_("incremental_solve_test"), x_(model_.AddContinuousVariable(0.0, 1.0, "x")), y_(model_.AddIntegerVariable(0.0, 2.0, "y")), c_(model_.AddLinearConstraint(0<=x_+y_<=1.5, "c")) { model_.Maximize(3.0 *x_+2.0 *y_+0.1);solver_=NewIncrementalSolver(&model_, TestedSolver()).value();const SolveResult first_solve=solver_->Solve().value();CHECK(first_solve.has_primal_feasible_solution());CHECK_LE(std::abs(first_solve.objective_value() - 3.6), kTolerance)<< first_solve.objective_value();} namespace { TEST_P(SimpleMipTest, OneVarMax) { Model model;const Variable x=model.AddVariable(0.0, 4.0, false, "x");model.Maximize(2.0 *x);ASSERT_OK_AND_ASSIGN(const SolveResult result, Solve(model, GetParam().solver_type));ASSERT_THAT(result, IsOptimal(8.0));EXPECT_THAT(result.variable_values(), IsNear({{x, 4.0}}));} TEST_P(SimpleMipTest, OneVarMin) { Model model;const Variable x=model.AddVariable(-2.4, 4.0, false, "x");model.Minimize(2.0 *x);ASSERT_OK_AND_ASSIGN(const SolveResult result, Solve(model, GetParam().solver_type));ASSERT_THAT(result, IsOptimal(-4.8));EXPECT_THAT(result.variable_values(), IsNear({{x, -2.4}}));} TEST_P(SimpleMipTest, OneIntegerVar) { Model model;const Variable x=model.AddVariable(0.0, 4.5, true, "x");model.Maximize(2.0 *x);ASSERT_OK_AND_ASSIGN(const SolveResult result, Solve(model, GetParam().solver_type));ASSERT_THAT(result, IsOptimal(8.0));EXPECT_THAT(result.variable_values(), IsNear({{x, 4.0}}));} TEST_P(SimpleMipTest, SimpleLinearConstraint) { Model model;const Variable x=model.AddBinaryVariable("x");const Variable y=model.AddBinaryVariable("y");model.Maximize(2.0 *x+y);model.AddLinearConstraint(0.0<=x+y<=1.5, "c");ASSERT_OK_AND_ASSIGN(const SolveResult result, Solve(model, GetParam().solver_type));ASSERT_THAT(result, IsOptimal(2.0));EXPECT_THAT(result.variable_values(), IsNear({{x, 1}, {y, 0}}));} TEST_P(SimpleMipTest, Unbounded) { Model model;const Variable x=model.AddVariable(0.0, kInf, true, "x");model.Maximize(2.0 *x);ASSERT_OK_AND_ASSIGN(const SolveResult result, Solve(model, GetParam().solver_type));if(GetParam().report_unboundness_correctly) { ASSERT_THAT(result, TerminatesWithOneOf({TerminationReason::kUnbounded, TerminationReason::kInfeasibleOrUnbounded}));} else { ASSERT_THAT(result, TerminatesWith(TerminationReason::kOtherError));} } TEST_P(SimpleMipTest, Infeasible) { Model model;const Variable x=model.AddVariable(0.0, 3.0, true, "x");model.Maximize(2.0 *x);model.AddLinearConstraint(x >=4.0);ASSERT_OK_AND_ASSIGN(const SolveResult result, Solve(model, GetParam().solver_type));ASSERT_THAT(result, TerminatesWith(TerminationReason::kInfeasible));} TEST_P(SimpleMipTest, FractionalBoundsContainNoInteger) { if(GetParam().solver_type==SolverType::kGurobi) { GTEST_SKIP()<< "TODO(b/272298816): Gurobi bindings are broken here.";} Model model;const Variable x=model.AddIntegerVariable(0.5, 0.6, "x");model.Maximize(x);EXPECT_THAT(Solve(model, GetParam().solver_type), IsOkAndHolds(TerminatesWith(TerminationReason::kInfeasible)));} TEST_P(IncrementalMipTest, EmptyUpdate) { ASSERT_THAT(solver_->Update(), IsOkAndHolds(DidUpdate()));ASSERT_OK_AND_ASSIGN(const SolveResult result, solver_->SolveWithoutUpdate());ASSERT_THAT(result, IsOptimal(3.6));EXPECT_THAT(result.variable_values(), IsNear({{x_, 0.5}, {y_, 1.0}}));} TEST_P(IncrementalMipTest, MakeContinuous) { model_.set_continuous(y_);ASSERT_THAT(solver_->Update(), IsOkAndHolds(DidUpdate()));ASSERT_OK_AND_ASSIGN(const SolveResult result, solver_->SolveWithoutUpdate());ASSERT_THAT(result, IsOptimal(4.1));EXPECT_THAT(result.variable_values(), IsNear({{x_, 1.0}, {y_, 0.5}}));} TEST_P(IncrementalMipTest, DISABLED_MakeContinuousWithNonIntegralBounds) { solver_.reset();Model model("bounds");const Variable x=model.AddIntegerVariable(0.5, 1.5, "x");model.Maximize(x);ASSERT_OK_AND_ASSIGN(const auto solver, NewIncrementalSolver(&model, TestedSolver()));ASSERT_THAT(solver->Solve(), IsOkAndHolds(IsOptimal(1.0)));model.set_continuous(x);ASSERT_THAT(solver->Update(), IsOkAndHolds(DidUpdate()));ASSERT_THAT(solver-> | SolveWithoutUpdate () |
<=x<=1 IncrementalMipTest::IncrementalMipTest() :model_("incremental_solve_test"), x_(model_.AddContinuousVariable(0.0, 1.0, "x")), y_(model_.AddIntegerVariable(0.0, 2.0, "y")), c_(model_.AddLinearConstraint(0<=x_+y_<=1.5, "c")) { model_.Maximize(3.0 *x_+2.0 *y_+0.1);solver_=NewIncrementalSolver(&model_, TestedSolver()).value();const SolveResult first_solve=solver_->Solve().value();CHECK(first_solve.has_primal_feasible_solution());CHECK_LE(std::abs(first_solve.objective_value() - 3.6), kTolerance)<< first_solve.objective_value();} namespace { TEST_P(SimpleMipTest, OneVarMax) { Model model;const Variable x=model.AddVariable(0.0, 4.0, false, "x");model.Maximize(2.0 *x);ASSERT_OK_AND_ASSIGN(const SolveResult result, Solve(model, GetParam().solver_type));ASSERT_THAT(result, IsOptimal(8.0));EXPECT_THAT(result.variable_values(), IsNear({{x, 4.0}}));} TEST_P(SimpleMipTest, OneVarMin) { Model model;const Variable x=model.AddVariable(-2.4, 4.0, false, "x");model.Minimize(2.0 *x);ASSERT_OK_AND_ASSIGN(const SolveResult result, Solve(model, GetParam().solver_type));ASSERT_THAT(result, IsOptimal(-4.8));EXPECT_THAT(result.variable_values(), IsNear({{x, -2.4}}));} TEST_P(SimpleMipTest, OneIntegerVar) { Model model;const Variable x=model.AddVariable(0.0, 4.5, true, "x");model.Maximize(2.0 *x);ASSERT_OK_AND_ASSIGN(const SolveResult result, Solve(model, GetParam().solver_type));ASSERT_THAT(result, IsOptimal(8.0));EXPECT_THAT(result.variable_values(), IsNear({{x, 4.0}}));} TEST_P(SimpleMipTest, SimpleLinearConstraint) { Model model;const Variable x=model.AddBinaryVariable("x");const Variable y=model.AddBinaryVariable("y");model.Maximize(2.0 *x+y);model.AddLinearConstraint(0.0<=x+y<=1.5, "c");ASSERT_OK_AND_ASSIGN(const SolveResult result, Solve(model, GetParam().solver_type));ASSERT_THAT(result, IsOptimal(2.0));EXPECT_THAT(result.variable_values(), IsNear({{x, 1}, {y, 0}}));} TEST_P(SimpleMipTest, Unbounded) { Model model;const Variable x=model.AddVariable(0.0, kInf, true, "x");model.Maximize(2.0 *x);ASSERT_OK_AND_ASSIGN(const SolveResult result, Solve(model, GetParam().solver_type));if(GetParam().report_unboundness_correctly) { ASSERT_THAT(result, TerminatesWithOneOf({TerminationReason::kUnbounded, TerminationReason::kInfeasibleOrUnbounded}));} else { ASSERT_THAT(result, TerminatesWith(TerminationReason::kOtherError));} } TEST_P(SimpleMipTest, Infeasible) { Model model;const Variable x=model.AddVariable(0.0, 3.0, true, "x");model.Maximize(2.0 *x);model.AddLinearConstraint(x >=4.0);ASSERT_OK_AND_ASSIGN(const SolveResult result, Solve(model, GetParam().solver_type));ASSERT_THAT(result, TerminatesWith(TerminationReason::kInfeasible));} TEST_P(SimpleMipTest, FractionalBoundsContainNoInteger) { if(GetParam().solver_type==SolverType::kGurobi) { GTEST_SKIP()<< "TODO(b/272298816): Gurobi bindings are broken here.";} Model model;const Variable x=model.AddIntegerVariable(0.5, 0.6, "x");model.Maximize(x);EXPECT_THAT(Solve(model, GetParam().solver_type), IsOkAndHolds(TerminatesWith(TerminationReason::kInfeasible)));} TEST_P(IncrementalMipTest, EmptyUpdate) { ASSERT_THAT(solver_->Update(), IsOkAndHolds(DidUpdate()));ASSERT_OK_AND_ASSIGN(const SolveResult result, solver_->SolveWithoutUpdate());ASSERT_THAT(result, IsOptimal(3.6));EXPECT_THAT(result.variable_values(), IsNear({{x_, 0.5}, {y_, 1.0}}));} TEST_P(IncrementalMipTest, MakeContinuous) { model_.set_continuous(y_);ASSERT_THAT(solver_->Update(), IsOkAndHolds(DidUpdate()));ASSERT_OK_AND_ASSIGN(const SolveResult result, solver_->SolveWithoutUpdate());ASSERT_THAT(result, IsOptimal(4.1));EXPECT_THAT(result.variable_values(), IsNear({{x_, 1.0}, {y_, 0.5}}));} TEST_P(IncrementalMipTest, DISABLED_MakeContinuousWithNonIntegralBounds) { solver_.reset();Model model("bounds");const Variable x=model.AddIntegerVariable(0.5, 1.5, "x");model.Maximize(x);ASSERT_OK_AND_ASSIGN(const auto solver, NewIncrementalSolver(&model, TestedSolver()));ASSERT_THAT(solver->Solve(), IsOkAndHolds(IsOptimal(1.0)));model.set_continuous(x);ASSERT_THAT(solver->Update(), IsOkAndHolds(DidUpdate()));ASSERT_THAT(solver-> | IsOkAndHolds (IsOptimal(1.5))) |
model | Minimize (x) |
ASSERT_THAT (solver->Update(), IsOkAndHolds(DidUpdate())) | |
ASSERT_THAT (solver->SolveWithoutUpdate(), IsOkAndHolds(IsOptimal(0.5))) | |
TEST_P (IncrementalMipTest, MakeIntegralWithNonIntegralBounds) | |
TEST_P (IncrementalMipTest, MakeInteger) | |
TEST_P (IncrementalMipTest, ObjDir) | |
TEST_P (IncrementalMipTest, ObjOffset) | |
TEST_P (IncrementalMipTest, LinearObjCoef) | |
TEST_P (IncrementalMipTest, VariableLb) | |
TEST_P (IncrementalMipTest, VariableUb) | |
TEST_P (IncrementalMipTest, LinearConstraintLb) | |
TEST_P (IncrementalMipTest, LinearConstraintUb) | |
TEST_P (IncrementalMipTest, LinearConstraintCoefficient) | |
TEST_P (IncrementalMipTest, AddVariable) | |
TEST_P (IncrementalMipTest, AddLinearConstraint) | |
TEST_P (IncrementalMipTest, DeleteVariable) | |
TEST_P (IncrementalMipTest, DeleteLinearConstraint) | |
TEST_P (IncrementalMipTest, ChangeBoundsWithTemporaryInversion) | |
std::ostream & | operator<< (std::ostream &out, const MultiObjectiveTestParameters ¶ms) |
std::ostream & | operator<< (std::ostream &out, const QcTestParameters ¶ms) |
std::string | ToString (QpSupportType qp_support) |
std::ostream & | operator<< (std::ostream &out, const QpTestParameters ¶ms) |
std::ostream & | operator<< (std::ostream &out, const SecondOrderConeTestParameters ¶ms) |
std::ostream & | operator<< (std::ostream &out, const StatusTestParameters ¶ms) |
std::unique_ptr< Model > | SmallModel (const bool integer) |
std::unique_ptr< Model > | DenseIndependentSet (const bool integer, const int n) |
ModelSolveParameters::SolutionHint | DenseIndependentSetHint5 (const Model &model) |
std::unique_ptr< Model > | IndependentSetCompleteGraph (const bool integer, const int n) |
MATH_OPT_REGISTER_SOLVER (SOLVER_TYPE_CP_SAT, CpSatSolver::New) | |
template<typename IndexType > | |
void | UpdateIdIndexMap (glop::StrictITIVector< IndexType, bool > indices_to_delete, IndexType num_indices, absl::flat_hash_map< int64_t, IndexType > &id_index_map) |
template<typename IndexType > | |
SparseDoubleVectorProto | FillSparseDoubleVector (absl::Span< const int64_t > ids_in_order, const absl::flat_hash_map< int64_t, IndexType > &id_map, const glop::StrictITIVector< IndexType, glop::Fractional > &values, const SparseVectorFilterProto &filter) |
template<typename ValueType > | |
BasisStatusProto | FromGlopBasisStatus (const ValueType glop_basis_status) |
ValueType should be glop's VariableStatus or ConstraintStatus. | |
template<typename IndexType , typename ValueType > | |
SparseBasisStatusVector | FillSparseBasisStatusVector (absl::Span< const int64_t > ids_in_order, const absl::flat_hash_map< int64_t, IndexType > &id_map, const glop::StrictITIVector< IndexType, ValueType > &values) |
template<typename ValueType > | |
ValueType | ToGlopBasisStatus (const BasisStatusProto basis_status) |
ValueType should be glop's VariableStatus or ConstraintStatus. | |
template<typename T > | |
std::vector< int64_t > | GetSortedIs (const absl::flat_hash_map< int64_t, T > &id_map) |
template<typename T > | |
glop::StrictITIVector< T, int64_t > | IndexToId (const absl::flat_hash_map< int64_t, T > &id_map) |
double | WorstGLPKDualBound (const bool is_maximize, const double objective_value, const double relative_gap_limit) |
absl::StatusOr< std::optional< GlpkRay > > | GlpkComputeUnboundRay (glp_prob *const problem) |
GScipParameters::MetaParamValue | ConvertMathOptEmphasis (EmphasisProto emphasis) |
absl::StatusOr< GRBenvUniquePtr > | GurobiNewPrimaryEnv (const std::optional< GurobiIsvKey > &isv_key) |
std::vector< bool > | EventToGurobiWhere (const absl::flat_hash_set< CallbackEventProto > &events) |
absl::Status | GurobiCallbackImpl (const Gurobi::CallbackContext &context, const GurobiCallbackInput &callback_input, MessageCallbackData &message_callback_data, SolveInterrupter *const local_interrupter) |
void | GurobiCallbackImplFlush (const GurobiCallbackInput &callback_input, MessageCallbackData &message_callback_data) |
absl::StatusOr< GRBenvUniquePtr > | NewPrimaryEnvironment (std::optional< GurobiInitializerProto::ISVKey > proto_isv_key) |
MATH_OPT_REGISTER_SOLVER (SOLVER_TYPE_HIGHS, HighsSolver::New) | |
MATH_OPT_REGISTER_SOLVER (SOLVER_TYPE_PDLP, PdlpSolver::New) | |
template<typename V , typename C > | |
V | MemberPointerValueType (V C::*) |
template<typename V , typename C > | |
C | MemberPointerClassType (V C::*) |
template<auto PointerToMember, typename BaseIter > | |
auto | MakeUpdateDataFieldIterator (BaseIter base_iter) |
template<auto PointerToMember, typename UpdateTrackers > | |
auto | MakeUpdateDataFieldRange (const UpdateTrackers &trackers) |
DEFINE_STRONG_INT_TYPE (VariableId, int64_t) | |
DEFINE_STRONG_INT_TYPE (AuxiliaryObjectiveId, int64_t) | |
DEFINE_STRONG_INT_TYPE (LinearConstraintId, int64_t) | |
DEFINE_STRONG_INT_TYPE (QuadraticConstraintId, int64_t) | |
DEFINE_STRONG_INT_TYPE (SecondOrderConeConstraintId, int64_t) | |
DEFINE_STRONG_INT_TYPE (Sos1ConstraintId, int64_t) | |
DEFINE_STRONG_INT_TYPE (Sos2ConstraintId, int64_t) | |
DEFINE_STRONG_INT_TYPE (IndicatorConstraintId, int64_t) | |
DEFINE_STRONG_INT_TYPE (UpdateTrackerId, int64_t) | |
template<typename T > | |
iterator_range< T > | make_range (T x, T y) |
template<typename T > | |
iterator_range< T > | make_range (std::pair< T, T > p) |
template<typename Collection > | |
auto | collection_to_range (Collection &c) |
template<typename T > | |
std::string | StreamToString (const T &value) |
absl::Span< const FileFormat > | AllFileFormats () |
std::string | AbslUnparseFlag (const FileFormat f) |
std::ostream & | operator<< (std::ostream &out, const FileFormat f) |
bool | AbslParseFlag (const absl::string_view text, FileFormat *const f, std::string *const error) |
absl::flat_hash_map< absl::string_view, FileFormat > | ExtensionToFileFormat () |
std::optional< FileFormat > | FormatFromFilePath (absl::string_view file_path) |
std::optional< FileFormat > | FormatFromFlagOrFilePath (const std::optional< FileFormat > format_flag_value, const absl::string_view file_path) |
std::string | OptionalFormatFlagPossibleValuesList () |
std::string | FormatFlagPossibleValuesList () |
absl::StatusOr< std::pair< ModelProto, std::optional< SolutionHintProto > > > | ReadModel (const absl::string_view file_path, const FileFormat format) |
absl::Status | WriteModel (const absl::string_view file_path, const ModelProto &model_proto, const std::optional< SolutionHintProto > &hint_proto, const FileFormat format) |
absl::Status | ValidateFeasibilityStatus (const FeasibilityStatusProto &status) |
absl::Status | ValidateProblemStatus (const ProblemStatusProto &status) |
absl::Status | CheckPrimalStatusIs (const ProblemStatusProto &status, const FeasibilityStatusProto required_status) |
Assumes ValidateProblemStatus(status) is ok. | |
absl::Status | CheckPrimalStatusIsNot (const ProblemStatusProto &status, const FeasibilityStatusProto forbidden_status) |
Assumes ValidateProblemStatus(status) is ok. | |
absl::Status | CheckDualStatusIsNot (const ProblemStatusProto &status, const FeasibilityStatusProto forbidden_status) |
Assumes ValidateProblemStatus(status) is ok. | |
absl::Status | CheckDualStatusIs (const ProblemStatusProto &status, const FeasibilityStatusProto required_status, const bool primal_or_dual_infeasible_also_ok) |
Assumes ValidateProblemStatus(status) is ok. | |
absl::Status | ValidateObjectiveBounds (const ObjectiveBoundsProto &bounds) |
absl::Status | CheckFinitePrimalBound (const ObjectiveBoundsProto &bounds) |
absl::Status | ValidateBoundStatusConsistency (const ObjectiveBoundsProto &objective_bounds, const ProblemStatusProto &status, bool is_maximize) |
absl::Status | ValidateCallbackRegistration (const CallbackRegistrationProto &callback_registration, const ModelSummary &model_summary) |
Checks that CallbackRegistrationProto is valid given a valid model summary. | |
absl::Status | ValidateCallbackDataProto (const CallbackDataProto &cb_data, const CallbackRegistrationProto &callback_registration, const ModelSummary &model_summary) |
absl::Status | ValidateCallbackResultProto (const CallbackResultProto &callback_result, const CallbackEventProto callback_event, const CallbackRegistrationProto &callback_registration, const ModelSummary &model_summary) |
absl::Status | CheckRegisteredCallbackEvents (const CallbackRegistrationProto ®istration, const absl::flat_hash_set< CallbackEventProto > &supported_events) |
absl::Status | CheckIdsRangeAndStrictlyIncreasing (absl::Span< const int64_t > ids) |
absl::Status | CheckIdsSubset (absl::Span< const int64_t > ids, const IdNameBiMap &universe, std::optional< int64_t > upper_bound) |
absl::Status | CheckIdsSubset (absl::Span< const int64_t > ids, const IdNameBiMap &universe, absl::string_view ids_description, absl::string_view universe_description) |
absl::Status | CheckIdsIdentical (absl::Span< const int64_t > first_ids, const IdNameBiMap &second_ids, absl::string_view first_description, absl::string_view second_description) |
first_ids and second_ids must include distinct ids. | |
absl::Status | ValidateModelSubset (const ModelSubsetProto &model_subset, const ModelSummary &model_summary) |
absl::Status | ValidateComputeInfeasibleSubsystemResult (const ComputeInfeasibleSubsystemResultProto &result, const ModelSummary &model_summary) |
absl::Status | ValidateComputeInfeasibleSubsystemResultNoModel (const ComputeInfeasibleSubsystemResultProto &result) |
Validates the internal consistency of the fields. | |
absl::Status | ValidateLinearExpression (const LinearExpressionProto &expression, const IdNameBiMap &variable_universe) |
absl::Status | ValidateSparseVectorFilter (const SparseVectorFilterProto &v, const IdNameBiMap &valid_ids) |
absl::Status | ValidateModelSolveParameters (const ModelSolveParametersProto ¶meters, const ModelSummary &model_summary) |
absl::StatusOr< ModelSummary > | ValidateModel (const ModelProto &model, const bool check_names) |
absl::Status | ValidateModelUpdate (const ModelUpdateProto &model_update, ModelSummary &model_summary) |
absl::Status | ValidateSolutions (const google::protobuf::RepeatedPtrField< SolutionProto > &solutions, const ModelSolveParametersProto ¶meters, const ModelSummary &model_summary) |
absl::Status | CheckHasPrimalSolution (const SolveResultProto &result) |
Returns absl::Ok only if a primal feasible solution is available. | |
absl::Status | CheckPrimalSolutionAndTerminationConsistency (const TerminationProto &termination, const google::protobuf::RepeatedPtrField< SolutionProto > &solutions, const bool maximize) |
absl::Status | CheckDualSolutionAndStatusConsistency (const TerminationProto &termination, const google::protobuf::RepeatedPtrField< SolutionProto > &solutions, const bool maximize) |
absl::Status | ValidateResult (const SolveResultProto &result, const ModelSolveParametersProto ¶meters, const ModelSummary &model_summary) |
Validates the input result. | |
absl::Status | CheckScalarNoNanNoInf (const double d) |
absl::Status | CheckScalar (double value, const DoubleOptions &options) |
Checks value is not NaN and satisfies the additional conditions in options. | |
absl::Status | ValidateSolution (const SolutionProto &solution, const ModelSolveParametersProto ¶meters, const ModelSummary &model_summary) |
absl::Status | ValidatePrimalSolutionVector (const SparseDoubleVectorProto &vector, const SparseVectorFilterProto &filter, const ModelSummary &model_summary) |
absl::Status | ValidatePrimalSolution (const PrimalSolutionProto &primal_solution, const SparseVectorFilterProto &filter, const ModelSummary &model_summary) |
absl::Status | ValidatePrimalRay (const PrimalRayProto &primal_ray, const SparseVectorFilterProto &filter, const ModelSummary &model_summary) |
absl::Status | ValidateDualSolution (const DualSolutionProto &dual_solution, const ModelSolveParametersProto ¶meters, const ModelSummary &model_summary) |
absl::Status | ValidateDualRay (const DualRayProto &dual_ray, const ModelSolveParametersProto ¶meters, const ModelSummary &model_summary) |
absl::Status | SparseBasisStatusVectorIsValid (const SparseVectorView< int > &status_vector_view) |
absl::Status | ValidateBasis (const BasisProto &basis, const ModelSummary &model_summary, const bool check_dual_feasibility) |
absl::Status | ValidateSolveParameters (const SolveParametersProto ¶meters) |
absl::Status | ValidateSolveStats (const SolveStatsProto &solve_stats) |
absl::Status | SparseMatrixValid (const SparseDoubleMatrixProto &matrix, const bool enforce_upper_triangular) |
absl::Status | SparseMatrixIdsAreKnown (const SparseDoubleMatrixProto &matrix, const IdNameBiMap &row_ids, const IdNameBiMap &column_ids) |
template<typename T > | |
absl::Status | CheckIdsAndValuesSize (const SparseVectorView< T > &vector_view, absl::string_view value_name="values") |
template<typename T , typename = std::enable_if_t<!std::is_floating_point<T>::value>> | |
absl::Status | CheckValues (const SparseVectorView< T > &vector_view, absl::string_view value_name="values") |
template<typename T , typename = std::enable_if_t<!std::is_floating_point<T>::value>> | |
absl::Status | CheckIdsAndValues (const SparseVectorView< T > &vector_view, absl::string_view value_name="values") |
template<typename T , typename = std::enable_if_t<std::is_floating_point<T>::value>> | |
absl::Status | CheckValues (const SparseVectorView< T > &vector_view, const DoubleOptions &options, absl::string_view value_name="values") |
template<typename T , typename = std::enable_if_t<std::is_floating_point<T>::value>> | |
absl::Status | CheckIdsAndValues (const SparseVectorView< T > &vector_view, const DoubleOptions &options, absl::string_view value_name="values") |
absl::Status | ValidateTermination (const TerminationProto &termination, bool is_maximize) |
Checks all messages are valid and compatible. | |
Variables | |
constexpr absl::string_view | kDeletedConstraintDefaultDescription |
constexpr double | kInf = std::numeric_limits<double>::infinity() |
constexpr std::size_t | kMaxNonBinaryIndicatorVariables = 10 |
The maximum number of non-binary indicator variables to report. | |
constexpr std::size_t | kMaxInvertedBounds = 10 |
The maximum number of variables/constraints with inverted bounds to report. | |
absl::string_view | detail = {}) |
template<typename T > | |
constexpr bool | is_key_type_v |
constexpr double | kMatcherDefaultTolerance = 1e-5 |
For infeasible and unbounded | problems |
For infeasible and unbounded see Not checked if options check_solutions_if_inf_or_unbounded and the If options first_solution_only is | false |
problem is infeasible or unbounded (default). | |
For infeasible and unbounded see Not checked if options check_solutions_if_inf_or_unbounded and the If options first_solution_only is check the entire list of Dual solution is not checked if options | check_dual |
solutions matches in the same order. | |
constexpr absl::string_view | kDeletedObjectiveDefaultDescription |
When | unset |
When the underlying default is used When the feature cannot be turned | off |
When the underlying default is used When the feature cannot be turned kOff will return an error If the feature is enabled by | default |
When the underlying default is used When the feature cannot be turned kOff will return an error If the feature is enabled by the solver default is typically If the feature is | supported |
mapped to kMedium. | |
When the underlying default is used When the feature cannot be turned kOff will return an error If the feature is enabled by the solver default is typically If the feature is | kLow |
When the underlying default is used When the feature cannot be turned kOff will return an error If the feature is enabled by the solver default is typically If the feature is | kMedium |
When the underlying default is used When the feature cannot be turned kOff will return an error If the feature is enabled by the solver default is typically If the feature is | kHigh |
constexpr double | kMaxIntegralityTolerance = 0.25 |
∞ ≤ x | InconsistentVariableBoundsAndLinearConstraint |
const Variable | x = model.AddContinuousVariable(-kInf, 0.0) |
const LinearConstraint | c = model.AddLinearConstraint(x >= 1.0) |
≤ x | InconsistentVariableBoundsAndQuadraticConstraint |
≤ x | InconsistentSecondOrderConeConstraint |
≤ x | InconsistentSecondOrderConeConstraintWithExpressionUnderNorm |
≤ x | InconsistentSecondOrderConeConstraintWithExpressionInUpperBound |
≤ x | InconsistentIndicatorConstraint |
constexpr double | kTolerance = 1e-6 |
constexpr absl::string_view | kNoMultiObjectiveSupportMessage |
constexpr std::string_view | kNoQpSupportMessage |
constexpr std::string_view | kNoNonDiagonalQpSupportMessage |
constexpr ObjectiveId | kPrimaryObjectiveId |
*If primal | bound |
*If primal *dual status is | infeasible |
*If primal *dual status is and *dual bound is equal to primal bound *is | finite |
An object oriented wrapper for quadratic constraints in ModelStorage.
Classes for modeling sparse matrices.
Holds MathOpt models that are shared across tests from this directory.
This file contains primal solution improvement heuristics.
Tools to extract some sub-components of sparse matrices.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. IWYU pragma: private, include "ortools/math_opt/cpp/math_opt.h" IWYU pragma: friend "ortools/math_opt/cpp/.*"
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. IWYU pragma: private, include "ortools/math_opt/cpp/math_opt.h" IWYU pragma: friend "ortools/math_opt/cpp/.*" The MathOpt C++ API defines enums that are used in parameters and results and that corresponds to Proto generated enums.
The tools in this header make sure the C++ enums provide the following features:
Example declaration:
my_file.proto: enum MyEnumProto { MY_ENUM_UNSPECIFIED = 0; MY_ENUM_FIRST_VALUE = 1; MY_ENUM_SECOND_VALUE = 2; }
my_file.h: enum class MyEnum { kFirstValue = MY_ENUM_FIRST_VALUE, kSecondValue = MY_ENUM_SECOND_VALUE, };
my_file.cc: std::optional<absl::string_view> Enum<MyEnum>::ToOptString(MyEnum value) { switch (value) { case MyEnum::kFirstValue: return "first_value"; case MyEnum::kSecondValue: return "second_value"; } return std::nullopt; }
my_file_test.cc: #include "ortools/math_opt/cpp/enums_testing.h" ... INSTANTIATE_TYPED_TEST_SUITE_P(MyEnum, EnumTest, MyEnum);
Once this is done, the following functions are available:
See examples of usage in the Enum struct documentation below.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. IWYU pragma: private, include "ortools/math_opt/cpp/math_opt.h" IWYU pragma: friend "ortools/math_opt/cpp/.*" This header defines the common properties of "key types" and some related constants.
Key types are types that are used as identifiers in the C++ interface where the ModelStorage is using typed integers. They are pairs of (storage, typed_index) where storage
is a pointer on an ModelStorage and typed_index
is the typed integer type used in ModelStorage (or a pair of typed integers for QuadraticTermKey).
A key type K must match the following requirements:
K::IdType K::typed_id() const
.const ModelStorage* K::storage() const
. It must return a non-null pointer.Printing
absl::flat_hash_map<K, double> Matchers
Matcher helpers
Primal Ray Matcher
Dual Ray Matcher
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. IWYU pragma: private, include "ortools/math_opt/cpp/math_opt.h" IWYU pragma: friend "ortools/math_opt/cpp/.*"
An object oriented wrapper for objectives in ModelStorage.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Parses a the model in "CPLEX LP" format using SCIP.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Functions to remove names from models and updates.
Input models can contain duplicated names which MathOpt solvers will refuse. The functions in this header can be use to mitigate that.
These functions can also be used to anonymize models before saving them.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Methods for manipulating LinearExpressions.
Why in labs? Lots of users seem to need this (e.g. for big-M calculations), but there are several possible algorithms, and it is not clear what, if anything, would be used widely. The function also makes many assumptions on the input that are not easy to verify and can lead to confusing errors, it is worth seeing if the API can be hardened a bit.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. This header defines primal/dual unboundness ray computation functions for GLPK solver. They use the index space of the computation form of the model as defined in operations_research/glpk/glpk_computational_form.h.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Google C++ bindings for Gurobi C API.
Attempts to be as close to the Gurobi C API as possible, with the following differences:
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Unimplemented features:
Solutions & Rays
using operations_research::math_opt::Callback = std::function<CallbackResult(const CallbackData&)> |
Definition at line 93 of file callback.h.
using operations_research::math_opt::GRBenvUniquePtr = std::unique_ptr<GRBenv, GurobiFreeEnv> |
Unique pointer to a GRBenv. It destroys the environment on destruction calling GRBfreeenv. Most users will not use this directly.
Definition at line 59 of file g_gurobi.h.
using operations_research::math_opt::LinearConstraintMap = absl::flat_hash_map<LinearConstraint, V> |
Definition at line 95 of file linear_constraint.h.
using operations_research::math_opt::MessageCallback = std::function<void(const std::vector<std::string>&)> |
Callback function for messages callback sent by the solver.
Each message represents a single output line from the solver, and each message does not contain any '
' character in it.
Thread-safety: a callback may be called concurrently from multiple threads. The users is expected to use proper synchronization primitives to deal with that.
Definition at line 40 of file message_callback.h.
Mocking
Definition at line 498 of file matchers.h.
using operations_research::math_opt::ObjectiveId = std::optional<AuxiliaryObjectiveId> |
nullopt denotes the primary objective.
Definition at line 31 of file model_storage_types.h.
using operations_research::math_opt::ObjectiveMap = absl::flat_hash_map<Objective, V> |
Definition at line 123 of file objective.h.
using operations_research::math_opt::ProtoEnumIsValid = bool (*)(int) |
using operations_research::math_opt::QuadraticProductId = std::pair<VariableId, VariableId> |
Id type used for quadratic terms, i.e. products of two variables.
Definition at line 641 of file variable_and_expressions.h.
using operations_research::math_opt::QuadraticTermMap = absl::flat_hash_map<QuadraticTermKey, V> |
Definition at line 731 of file variable_and_expressions.h.
using operations_research::math_opt::Range = std::pair<double, double> |
A range of values, first is the minimum, second is the maximum.
Definition at line 27 of file statistics.h.
The type of a standard function with the same signature as Solve() above.
If you want mock the Solve() for testing, you can take a SolveFunction as an argument, e.g. absl::Status DoMySolve(SolveFunction solve_function=Solve) { Model model; ///< fill in model... SolveArguments args; SolveInitArguments init_args; ASSIGN_OR_RETURN( const SolveResult result, solve_function(model, SolverType::kGscip, args, init_args)); ///< process result... return absl::OkStatus(); }
using operations_research::math_opt::Sos1ConstraintData = internal::SosConstraintData<Sos1ConstraintId> |
using operations_research::math_opt::Sos2ConstraintData = internal::SosConstraintData<Sos2ConstraintId> |
using operations_research::math_opt::sparse_value_type |
Recovers the values-type of a SparseVector type like SparseDoubleVector or SparseBoolVector.
Definition at line 70 of file sparse_vector_view.h.
A vector that contains one pair (row_id, columns_coefficients) per row, sorted by row_id. The columns_coefficients are views.
Definition at line 31 of file sparse_submatrix.h.
using operations_research::math_opt::VariableMap = absl::flat_hash_map<Variable, V> |
Definition at line 187 of file variable_and_expressions.h.
|
strong |
Status of a variable/constraint in a LP basis.
Definition at line 30 of file basis_status.h.
|
strong |
The supported events during a solve for callbacks.
Enumerator | |
---|---|
kPresolve | The solver is currently running presolve. This event is supported for SolverType::kGurobi only. |
kSimplex | The solver is currently running the simplex method. This event is supported for SolverType::kGurobi only. |
kMip | The solver is in the MIP loop (called periodically before starting a new node). Useful for early termination. Note that this event does not provide information on LP relaxations nor about new incumbent solutions. This event is supported for MIP models with SolverType::kGurobi only. |
kMipSolution | Called every time a new MIP incumbent is found. This event is fully supported for MIP models by SolverType::kGurobi. SolverType::kCpSat has partial support: you can view the solutions and request termination, but you cannot add lazy constraints. Other solvers don't support this event. |
kMipNode | Called inside a MIP node. Note that there is no guarantee that the callback function will be called on every node. That behavior is solver-dependent. Disabling cuts using SolveParameters may interfere with this event being called and/or adding cuts at this event, the behavior is solver specific. This event is supported for MIP models with SolverType::kGurobi only. |
kBarrier | Called in each iterate of an interior point/barrier method. This event is supported for SolverType::kGurobi only. |
Definition at line 96 of file callback.h.
|
strong |
never give an error, and will map onto their best match.
Enumerator | |
---|---|
kOff | |
kLow | |
kMedium | |
kHigh | |
kVeryHigh |
Definition at line 179 of file parameters.h.
|
strong |
Problem feasibility status as claimed by the solver (solver is not required to return a certificate for the claim).
Enumerator | |
---|---|
kUndetermined | Solver does not claim a status. |
kFeasible | Solver claims the problem is feasible. |
kInfeasible | Solver claims the problem is infeasible. |
Definition at line 43 of file solve_result.h.
The type of the GlpkRay.
|
strong |
When a Solve() stops early with TerminationReason kFeasible or kNoSolutionFound, the specific limit that was hit.
Enumerator | |
---|---|
kUndetermined | Used if the underlying solver cannot determine which limit was reached, or as a null value when we terminated not from a limit (e.g. kOptimal). |
kIteration | An iterative algorithm stopped after conducting the maximum number of iterations (e.g. simplex or barrier iterations). |
kTime | The algorithm stopped after a user-specified computation time. |
kNode | A branch-and-bound algorithm stopped because it explored a maximum number of nodes in the branch-and-bound tree. |
kSolution | The algorithm stopped because it found the required number of solutions. This is often used in MIPs to get the solver to return the first feasible solution it encounters. |
kMemory | The algorithm stopped because it ran out of memory. |
kCutoff | The solver was run with a cutoff (e.g. SolveParameters.cutoff_limit was set) on the objective, indicating that the user did not want any solution worse than the cutoff, and the solver concluded there were no solutions at least as good as the cutoff. Typically no further solution information is provided. |
kObjective | The algorithm stopped because it found a solution better than a minimum limit set by the user. |
kNorm | The algorithm stopped because the norm of an iterate became too large. |
kInterrupted | The algorithm stopped because of an interrupt signal or a user interrupt request. |
kSlowProgress | The algorithm stopped because it was unable to continue making progress towards the solution. |
kOther | The algorithm stopped due to a limit not covered by one of the above. Note that kUndetermined is used when the reason cannot be determined, and kOther is used when the reason is known but does not fit into any of the above alternatives. |
Definition at line 173 of file solve_result.h.
|
strong |
Selects an algorithm for solving linear programs.
Definition at line 128 of file parameters.h.
|
strong |
Enumerator | |
---|---|
kNoQpSupport | |
kDiagonalQpOnly | |
kConvexQp |
Definition at line 26 of file qp_tests.h.
|
strong |
Feasibility of a primal or dual solution as claimed by the solver.
Enumerator | |
---|---|
kUndetermined | Solver does not claim a feasibility status. |
kFeasible | Solver claims the solution is feasible. |
kInfeasible | Solver claims the solution is infeasible. |
Definition at line 39 of file solution.h.
|
strong |
The solvers supported by MathOpt.
Enumerator | |
---|---|
kGscip | Solving Constraint Integer Programs (SCIP) solver (third party). Supports LP, MIP, and nonconvex integer quadratic problems. No dual data for LPs is returned though. Prefer GLOP for LPs. |
kGurobi | Gurobi solver (third party). Supports LP, MIP, and nonconvex integer quadratic problems. Generally the fastest option, but has special licensing. |
kGlop | Google's Glop solver. Supports LP with primal and dual simplex methods. |
kCpSat | Google's CP-SAT solver. Supports problems where all variables are integer and bounded (or implied to be after presolve). Experimental support to rescale and discretize problems with continuous variables. |
kPdlp | Google's PDLP solver. Supports LP and convex diagonal quadratic objectives. Uses first order methods rather than simplex. Can solve very large problems. |
kGlpk | GNU Linear Programming Kit (GLPK) (third party). Supports MIP and LP. Thread-safety: GLPK use thread-local storage for memory allocations. As a consequence when using IncrementalSolver, the user must make sure that instances are destroyed on the same thread as they are created or GLPK will crash. It seems OK to call IncrementalSolver::Solve() from another thread than the one used to create the Solver but it is not documented by GLPK and should be avoided. Of course these limitations do not apply to the Solve() function that recreates a new GLPK problem in the calling thread and destroys before returning. When solving a LP with the presolver, a solution (and the unbound rays) are only returned if an optimal solution has been found. Else nothing is returned. See glpk-5.0/doc/glpk.pdf page #40 available from glpk-5.0.tar.gz for details. |
kEcos | The Embedded Conic Solver (ECOS). Supports LP and SOCP problems. Uses interior point methods (barrier). |
kScs | The Splitting Conic Solver (SCS) (third party). Supports LP and SOCP problems. Uses a first-order method. |
kHighs | The HiGHS Solver (third party). Supports LP and MIP problems (convex QPs are unimplemented). |
kSantorini | MathOpt's reference implementation of a MIP solver. Slow/not recommended for production. Not an LP solver (no dual information returned). |
Definition at line 42 of file parameters.h.
|
strong |
Enumerator | |
---|---|
kNotSupported | |
kSupported | |
kNotImplemented |
Definition at line 317 of file math_opt_proto_utils.h.
|
strong |
The reason a call to Solve() terminates.
Enumerator | |
---|---|
kOptimal | A provably optimal solution (up to numerical tolerances) has been found. |
kInfeasible | The primal problem has no feasible solutions. |
kUnbounded | The primal problem is feasible and arbitrarily good solutions can be found along a primal ray. |
kInfeasibleOrUnbounded | The primal problem is either infeasible or unbounded. More details on the problem status may be available in termination.problem_status. Note that Gurobi's unbounded status may be mapped here. |
kImprecise | The problem was solved to one of the criteria above (Optimal, Infeasible, Unbounded, or InfeasibleOrUnbounded), but one or more tolerances was not met. Some primal/dual solutions/rays may be present, but either they will be slightly infeasible, or (if the problem was nearly optimal) their may be a gap between the best solution objective and best objective bound. Users can still query primal/dual solutions/rays and solution stats, but they are responsible for dealing with the numerical imprecision. |
kFeasible | The optimizer reached some kind of limit and a primal feasible solution is returned. See SolveResultProto.limit_detail for detailed description of the kind of limit that was reached. |
kNoSolutionFound | The optimizer reached some kind of limit and it did not find a primal feasible solution. See SolveResultProto.limit_detail for detailed description of the kind of limit that was reached. |
kNumericalError | The algorithm stopped because it encountered unrecoverable numerical error. No solution information is available. |
kOtherError | The algorithm stopped because of an error not covered by one of the statuses defined above. No solution information is available. |
Definition at line 124 of file solve_result.h.
≤ x operations_research::math_opt::≤ | ( | variable | bounds | ) |
The entire model is an IIS.
x is integer
The model is: min 0 s.t. x ≥ 1 (linear constraint)
The model is: min 0 s.t. x² ≥ 1
The model is: min 0 s.t. ||{x}||₂ ≤ 1 An IIS is: ||{x}||₂ ≤ 1
The model is: min 0 s.t. ||{2x}||₂ ≤ 1 An IIS is: ||{2x}||₂ ≤ 1
The model is: min 0 s.t. ||{x}||₂ ≤ 2x - 2 An IIS is: ||{x}||₂ ≤ 2x - 2
An IIS is: {x, y} is SOS1
An IIS is: {x, y, z} is SOS2
The model is: min 0 s.t. x == 1 --> 1 ≤ 0 x is integer
An IIS is: x == 1 --> 1 ≤ 0
operations_research::math_opt::ABSL_DEPRECATED | ( | "Use TerminateForReason(bool, TerminationReasonProto, absl::string_view) " "instead" | ) |
H operations_research::math_opt::AbslHashValue | ( | H | h, |
const IndicatorConstraint & | constraint ) |
Definition at line 135 of file indicator_constraint.h.
H operations_research::math_opt::AbslHashValue | ( | H | h, |
const LinearConstraint & | linear_constraint ) |
Definition at line 172 of file linear_constraint.h.
H operations_research::math_opt::AbslHashValue | ( | H | h, |
const Objective & | objective ) |
Definition at line 213 of file objective.h.
H operations_research::math_opt::AbslHashValue | ( | H | h, |
const QuadraticConstraint & | quadratic_constraint ) |
Definition at line 189 of file quadratic_constraint.h.
H operations_research::math_opt::AbslHashValue | ( | H | h, |
const QuadraticTermKey & | key ) |
Definition at line 2097 of file variable_and_expressions.h.
H operations_research::math_opt::AbslHashValue | ( | H | h, |
const SecondOrderConeConstraint & | constraint ) |
Definition at line 125 of file second_order_cone_constraint.h.
H operations_research::math_opt::AbslHashValue | ( | H | h, |
const Sos1Constraint & | constraint ) |
Definition at line 125 of file sos1_constraint.h.
H operations_research::math_opt::AbslHashValue | ( | H | h, |
const Sos2Constraint & | constraint ) |
Definition at line 126 of file sos2_constraint.h.
H operations_research::math_opt::AbslHashValue | ( | H | h, |
const Variable & | variable ) |
Definition at line 1306 of file variable_and_expressions.h.
bool operations_research::math_opt::AbslParseFlag | ( | absl::string_view | text, |
Emphasis * | value, | ||
std::string * | error ) |
Parses a flag of type Emphasis.
The expected values are the one returned by EnumToString().
Definition at line 169 of file parameters.cc.
bool operations_research::math_opt::AbslParseFlag | ( | absl::string_view | text, |
LPAlgorithm * | value, | ||
std::string * | error ) |
Parses a flag of type LPAlgorithm.
The expected values are the one returned by EnumToString().
Definition at line 136 of file parameters.cc.
bool operations_research::math_opt::AbslParseFlag | ( | absl::string_view | text, |
SolveParameters * | solve_parameters, | ||
std::string * | error ) |
Definition at line 329 of file parameters.cc.
bool operations_research::math_opt::AbslParseFlag | ( | const absl::string_view | text, |
FileFormat *const | f, | ||
std::string *const | error ) |
Definition at line 79 of file file_format_flags.cc.
bool operations_research::math_opt::AbslParseFlag | ( | const absl::string_view | text, |
SolverResources *const | solver_resources, | ||
std::string *const | error ) |
Definition at line 49 of file solver_resources.cc.
bool operations_research::math_opt::AbslParseFlag | ( | absl::string_view | text, |
SolverType * | value, | ||
std::string * | error ) |
Parses a flag of type SolverType.
The expected values are the one returned by EnumToString().
Definition at line 102 of file parameters.cc.
std::string operations_research::math_opt::AbslUnparseFlag | ( | Emphasis | value | ) |
Unparses a flag of type Emphasis.
The returned values are the same as EnumToString().
Definition at line 174 of file parameters.cc.
std::string operations_research::math_opt::AbslUnparseFlag | ( | const FileFormat | f | ) |
Definition at line 57 of file file_format_flags.cc.
std::string operations_research::math_opt::AbslUnparseFlag | ( | LPAlgorithm | value | ) |
Unparses a flag of type LPAlgorithm.
The returned values are the same as EnumToString().
Definition at line 141 of file parameters.cc.
std::string operations_research::math_opt::AbslUnparseFlag | ( | const SolverResources & | solver_resources | ) |
Definition at line 68 of file solver_resources.cc.
std::string operations_research::math_opt::AbslUnparseFlag | ( | SolverType | value | ) |
Unparses a flag of type SolverType.
The returned values are the same as EnumToString().
Definition at line 107 of file parameters.cc.
std::string operations_research::math_opt::AbslUnparseFlag | ( | SolveParameters | solve_parameters | ) |
Definition at line 347 of file parameters.cc.
bool operations_research::math_opt::ActivateDualRay | ( | SolverType | solver_type, |
SolveParameters & | params ) |
Updates the input parameters so that the solver produces a dual ray for infeasible ones. Return true if the solver supports producing dual rays, else returns false.
bool operations_research::math_opt::ActivatePrimalRay | ( | SolverType | solver_type, |
SolveParameters & | params ) |
Updates the input parameters so that the solver produces a primal ray for unbounded problems for infeasible ones. Return true if the solver supports producing primal rays, else returns false.
void operations_research::math_opt::AddRobustConstraint | ( | const Model & | uncertainty_model, |
Variable | rhs, | ||
absl::Span< const std::pair< LinearExpression, Variable > > | uncertain_coefficients, | ||
Model & | main_model ) |
Uses LP duality to construct an extended formulation of
max_w{ a(w) * x : w in W} <= rhs
where W is described by uncertainty_model (the variables of uncertainty_model are w). All the variables and constraints of the extended formulation are added to main_model.
Requirements:
Input-only arguments:
Definition at line 202 of file dualizer.cc.
absl::Span< const FileFormat > operations_research::math_opt::AllFileFormats | ( | ) |
Definition at line 45 of file file_format_flags.cc.
void operations_research::math_opt::ApplyAllFilters | ( | const ModelSolveParametersProto & | model_solve_params, |
SolutionProto & | solution ) |
Applies the primal, dual and reduced costs filters from model_solve_params to the primal solution variable values, dual solution dual values, and dual solution reduced costs, respectively, and overwriting these values with the results.
Definition at line 119 of file math_opt_proto_utils.cc.
operations_research::math_opt::ASSERT_THAT | ( | solver-> | SolveWithoutUpdate(), |
IsOkAndHolds(IsOptimal(0.5)) | ) |
operations_research::math_opt::ASSERT_THAT | ( | solver-> | Update(), |
IsOkAndHolds(DidUpdate()) | ) |
std::vector< Variable > operations_research::math_opt::AtomicConstraintNonzeroVariables | ( | const ModelStorage & | storage, |
const IdType | id ) |
Definition at line 42 of file model_util.h.
std::vector< ConstraintType > operations_research::math_opt::AtomicConstraints | ( | const ModelStorage & | storage | ) |
Duck-types on ConstraintType
having a typedef for the associated IdType
, and having a (const ModelStorage*, IdType)
constructor.
Definition at line 57 of file model_util.h.
absl::StatusOr< absl::flat_hash_map< Objective, double > > operations_research::math_opt::AuxiliaryObjectiveValuesFromProto | ( | const ModelStorage * | model, |
const google::protobuf::Map< int64_t, double > & | aux_obj_proto ) |
Returns an absl::flat_hash_map<Objective, double> equivalent to aux_obj_proto
.
Requires that (or returns a status error):
aux_obj_proto
correspond to objectives in model
.aux_obj_proto
are not checked (it may have NaNs). Definition at line 163 of file sparse_containers.cc.
google::protobuf::Map< int64_t, double > operations_research::math_opt::AuxiliaryObjectiveValuesToProto | ( | const absl::flat_hash_map< Objective, double > & | aux_obj_values | ) |
Returns the proto equivalent of auxiliary_obj_values.
Requires that (or will CHECK-fail):
aux_obj_values
all correspond to auxiliary objectives. Definition at line 178 of file sparse_containers.cc.
Definition at line 449 of file matchers.cc.
absl::Status operations_research::math_opt::CheckDualSolutionAndStatusConsistency | ( | const TerminationProto & | termination, |
const google::protobuf::RepeatedPtrField< SolutionProto > & | solutions, | ||
const bool | maximize ) |
Definition at line 204 of file result_validator.cc.
absl::Status operations_research::math_opt::CheckDualStatusIs | ( | const ProblemStatusProto & | status, |
FeasibilityStatusProto | required_status, | ||
bool | primal_or_dual_infeasible_also_ok = false ) |
Assumes ValidateProblemStatus(status) is ok.
If primal_or_dual_infeasible_also_ok is false, returns absl::Ok only if status.dual_status = required_status. If primal_or_dual_infeasible_also_ok is true, it returns absl::Ok when status.dual_status = required_status and when primal_or_dual_infeasible is true. Assumes validateProblemStatus(status) returns absl::Ok.
ValidateProblemStatus call above guarantees primal and dual statuses are FEASIBILITY_STATUS_UNDETERMINED here.
Definition at line 102 of file bounds_and_status_validator.cc.
absl::Status operations_research::math_opt::CheckDualStatusIsNot | ( | const ProblemStatusProto & | status, |
FeasibilityStatusProto | forbidden_status ) |
Assumes ValidateProblemStatus(status) is ok.
Returns absl::Ok only if status.dual_status != forbidden_status. Assumes validateProblemStatus(status) returns absl::Ok.
Definition at line 89 of file bounds_and_status_validator.cc.
absl::Status operations_research::math_opt::CheckFinitePrimalBound | ( | const ObjectiveBoundsProto & | bounds | ) |
Definition at line 136 of file bounds_and_status_validator.cc.
absl::Status operations_research::math_opt::CheckHasPrimalSolution | ( | const SolveResultProto & | result | ) |
Returns absl::Ok only if a primal feasible solution is available.
Definition at line 171 of file result_validator.cc.
absl::Status operations_research::math_opt::CheckIdsAndValues | ( | const SparseVectorView< T > & | vector_view, |
absl::string_view | value_name = "values" ) |
Definition at line 50 of file sparse_vector_validator.h.
absl::Status operations_research::math_opt::CheckIdsAndValues | ( | const SparseVectorView< T > & | vector_view, |
const DoubleOptions & | options, | ||
absl::string_view | value_name = "values" ) |
Definition at line 73 of file sparse_vector_validator.h.
absl::Status operations_research::math_opt::CheckIdsAndValuesSize | ( | const SparseVectorView< T > & | vector_view, |
absl::string_view | value_name = "values" ) |
Definition at line 30 of file sparse_vector_validator.h.
absl::Status operations_research::math_opt::CheckIdsIdentical | ( | absl::Span< const int64_t > | first_ids, |
const IdNameBiMap & | second_ids, | ||
absl::string_view | first_description, | ||
absl::string_view | second_description ) |
first_ids and second_ids must include distinct ids.
Definition at line 86 of file ids_validator.cc.
absl::Status operations_research::math_opt::CheckIdsRangeAndStrictlyIncreasing | ( | absl::Span< const int64_t > | ids | ) |
Checks that the input ids are in [0, max(int64_t)) range and that they are strictly increasing.
Definition at line 36 of file ids_validator.cc.
absl::Status operations_research::math_opt::CheckIdsSubset | ( | absl::Span< const int64_t > | ids, |
const IdNameBiMap & | universe, | ||
absl::string_view | ids_description, | ||
absl::string_view | universe_description ) |
Checks that the elements of ids are a subset of universe. Elements of ids do not need to be sorted or distinct.
Definition at line 71 of file ids_validator.cc.
absl::Status operations_research::math_opt::CheckIdsSubset | ( | absl::Span< const int64_t > | ids, |
const IdNameBiMap & | universe, | ||
std::optional< int64_t > | upper_bound = std::nullopt ) |
Checks that the elements of ids are a subset of universe. Elements of ids do not need to be sorted or distinct. If upper_bound is set, elements must be strictly less than upper_bound.
Definition at line 55 of file ids_validator.cc.
absl::Status operations_research::math_opt::CheckPrimalSolutionAndTerminationConsistency | ( | const TerminationProto & | termination, |
const google::protobuf::RepeatedPtrField< SolutionProto > & | solutions, | ||
const bool | maximize ) |
Definition at line 180 of file result_validator.cc.
absl::StatusOr< ModelSubset > operations_research::math_opt::CheckPrimalSolutionFeasibility | ( | const Model & | model, |
const VariableMap< double > & | variable_values, | ||
const FeasibilityCheckerOptions & | options = {} ) |
Returns a subset of model
s constraints that are violated at the point in variable_values
. A point feasible with respect to all constraints will return an empty subset, which can be checked via ModelSubset::empty().
Feasibility is checked within tolerances that can be configured in options
.
Returns an InvalidArgument error if variable_values
does not contain an entry for each variable in model
(and no extras).
Definition at line 213 of file solution_feasibility_checker.cc.
absl::Status operations_research::math_opt::CheckPrimalStatusIs | ( | const ProblemStatusProto & | status, |
FeasibilityStatusProto | required_status ) |
Assumes ValidateProblemStatus(status) is ok.
Returns absl::Ok only if status.primal_status = required_status. Assumes validateProblemStatus(status) returns absl::Ok.
Definition at line 63 of file bounds_and_status_validator.cc.
absl::Status operations_research::math_opt::CheckPrimalStatusIsNot | ( | const ProblemStatusProto & | status, |
FeasibilityStatusProto | forbidden_status ) |
Assumes ValidateProblemStatus(status) is ok.
Returns absl::Ok only if status.primal_status != forbidden_status. Assumes validateProblemStatus(status) returns absl::Ok.
Definition at line 76 of file bounds_and_status_validator.cc.
absl::Status operations_research::math_opt::CheckRegisteredCallbackEvents | ( | const CallbackRegistrationProto & | registration, |
const absl::flat_hash_set< CallbackEventProto > & | supported_events ) |
Returns an InvalidArgumentError if some of the registered events are not supported.
Definition at line 299 of file callback_validator.cc.
absl::Status operations_research::math_opt::CheckScalar | ( | const double | value, |
const DoubleOptions & | options ) |
Checks value is not NaN and satisfies the additional conditions in options.
Definition at line 36 of file scalar_validator.cc.
absl::Status operations_research::math_opt::CheckScalarNoNanNoInf | ( | const double | d | ) |
Definition at line 28 of file scalar_validator.cc.
absl::Status operations_research::math_opt::CheckSolverSpecificOutputEmpty | ( | const SolveResultProto & | result | ) |
Definition at line 491 of file solve_result.cc.
absl::Status operations_research::math_opt::CheckValues | ( | const SparseVectorView< T > & | vector_view, |
absl::string_view | value_name = "values" ) |
Definition at line 42 of file sparse_vector_validator.h.
absl::Status operations_research::math_opt::CheckValues | ( | const SparseVectorView< T > & | vector_view, |
const DoubleOptions & | options, | ||
absl::string_view | value_name = "values" ) |
Definition at line 59 of file sparse_vector_validator.h.
auto operations_research::math_opt::collection_to_range | ( | Collection & | c | ) |
absl::StatusOr< ComputeInfeasibleSubsystemResult > operations_research::math_opt::ComputeInfeasibleSubsystem | ( | const Model & | model, |
SolverType | solver_type, | ||
const ComputeInfeasibleSubsystemArguments & | compute_args = {}, | ||
const SolverInitArguments & | init_args = {} ) |
Computes an infeasible subsystem of the input model.
A Status error will be returned if the inputs are invalid or there is an unexpected failure in an underlying solver or for some internal math_opt errors. Otherwise, check ComputeInfeasibleSubsystemResult::feasibility to see if an infeasible subsystem was found.
Memory model: the returned ComputeInfeasibleSubsystemResult owns its own memory (for subsystems, solve stats, etc.), EXCEPT for a pointer back to the model. As a result:
Thread-safety: this method is safe to call concurrently on the same Model.
ModelRanges operations_research::math_opt::ComputeModelRanges | ( | const Model & | model | ) |
Returns the ranges of the finite non-zero values in the given model.
Definition at line 97 of file statistics.cc.
GScipParameters::MetaParamValue operations_research::math_opt::ConvertMathOptEmphasis | ( | EmphasisProto | emphasis | ) |
Definition at line 605 of file gscip_solver.cc.
TerminationProto operations_research::math_opt::CutoffTerminationProto | ( | bool | is_maximize, |
const absl::string_view | detail ) |
Calls NoSolutionFoundTerminationProto() with LIMIT_CUTOFF LIMIT.
Definition at line 314 of file math_opt_proto_utils.cc.
operations_research::math_opt::DEFINE_STRONG_INT_TYPE | ( | AuxiliaryObjectiveId | , |
int64_t | ) |
operations_research::math_opt::DEFINE_STRONG_INT_TYPE | ( | IndicatorConstraintId | , |
int64_t | ) |
operations_research::math_opt::DEFINE_STRONG_INT_TYPE | ( | LinearConstraintId | , |
int64_t | ) |
operations_research::math_opt::DEFINE_STRONG_INT_TYPE | ( | QuadraticConstraintId | , |
int64_t | ) |
operations_research::math_opt::DEFINE_STRONG_INT_TYPE | ( | SecondOrderConeConstraintId | , |
int64_t | ) |
operations_research::math_opt::DEFINE_STRONG_INT_TYPE | ( | Sos1ConstraintId | , |
int64_t | ) |
operations_research::math_opt::DEFINE_STRONG_INT_TYPE | ( | Sos2ConstraintId | , |
int64_t | ) |
operations_research::math_opt::DEFINE_STRONG_INT_TYPE | ( | UpdateTrackerId | , |
int64_t | ) |
operations_research::math_opt::DEFINE_STRONG_INT_TYPE | ( | VariableId | , |
int64_t | ) |
std::unique_ptr< Model > operations_research::math_opt::DenseIndependentSet | ( | const bool | integer, |
const int | n ) |
Problem data.
Add the variables
Set the objective.
Constraints of type (A).
Constraints of type (B).
Definition at line 44 of file test_models.cc.
ModelSolveParameters::SolutionHint operations_research::math_opt::DenseIndependentSetHint5 | ( | const Model & | model | ) |
Definition at line 95 of file test_models.cc.
testing::Matcher< UpdateResult > operations_research::math_opt::DidUpdate | ( | ) |
std::optional< typename EnumProto< P >::Cpp > operations_research::math_opt::EnumFromProto | ( | P | proto_value | ) |
std::optional< E > operations_research::math_opt::EnumFromString | ( | absl::string_view | str | ) |
Returns the enum value that corresponds to the input string or nullopt if no enum matches.
The expected strings are the one returned by EnumToString().
This is O(n) in complexity so use with care.
std::optional< absl::string_view > operations_research::math_opt::EnumToOptString | ( | E | value | ) |
Enum< E >::Proto operations_research::math_opt::EnumToProto | ( | E | value | ) |
Enum< E >::Proto operations_research::math_opt::EnumToProto | ( | std::optional< E > | value | ) |
Returns the Proto enum that matches the input C++ proto, returns Enum<E>::kProtoUnspecifiedValue if the input is std::nullopt.
Template functions implementations after this point.
absl::string_view operations_research::math_opt::EnumToString | ( | E | value | ) |
Returns a unique string that represent the enum.
It CHECKs that the input is a valid enum value. For most users this should always be the case since MathOpt don't generates invalid data.
Prefer using operator<< when possible though. As a side benefice it does not CHECK but instead prints the integer value of the invalid input.
absl::flat_hash_set< CallbackEventProto > operations_research::math_opt::EventSet | ( | const CallbackRegistrationProto & | callback_registration | ) |
Returns the callback_registration.request_registration as a set of enums.
Here we don't use for-range loop since for repeated enum fields, the type used in C++ is RepeatedField<int>. Using the generated getter instead guarantees type safety.
Definition at line 141 of file math_opt_proto_utils.cc.
std::vector< bool > operations_research::math_opt::EventToGurobiWhere | ( | const absl::flat_hash_set< CallbackEventProto > & | events | ) |
Converts a set of CallbackEventProto enums to a bit vector indicating which Gurobi callback events need to run our callback.
The returned vector will have an entry for each possible value of "where" that Gurobi's callbacks can stop at, see the table here: https://www.gurobi.com/documentation/9.1/refman/cb_codes.html
Definition at line 310 of file gurobi_callback.cc.
operations_research::math_opt::EXPECT_THAT | ( | ComputeInfeasibleSubsystem(model, GetParam().solver_type) | , |
IsOkAndHolds(IsInfeasible(true, ModelSubset{ .variable_bounds={{x, ModelSubset::Bounds{.lower=false,.upper=true}}},.linear_constraints={ {c, ModelSubset::Bounds{.lower=true,.upper=false}}}})) | ) |
operations_research::math_opt::EXPECT_THAT | ( | ComputeInfeasibleSubsystem(model, GetParam().solver_type) | , |
IsOkAndHolds(IsInfeasible(true, ModelSubset{ .variable_bounds={{x, ModelSubset::Bounds{.lower=false,.upper=true}}},.second_order_cone_constraints={c}})) | ) |
operations_research::math_opt::EXPECT_THAT | ( | ComputeInfeasibleSubsystem(model, GetParam().solver_type) | , |
IsOkAndHolds(IsInfeasible(true, ModelSubset{ .variable_bounds={{x, ModelSubset::Bounds{.lower=true,.upper=false}}},.second_order_cone_constraints={c}})) | ) |
operations_research::math_opt::EXPECT_THAT | ( | ComputeInfeasibleSubsystem(model, GetParam().solver_type) | , |
IsOkAndHolds(IsInfeasible(true, ModelSubset{ .variable_bounds={{x, ModelSubset::Bounds{.lower=true,.upper=false}}},.variable_integrality={x},.indicator_constraints={c}})) | ) |
operations_research::math_opt::EXPECT_THAT | ( | ComputeInfeasibleSubsystem(model, GetParam().solver_type) | , |
IsOkAndHolds(IsInfeasible(true, ModelSubset{ .variable_bounds={{x, ModelSubset::Bounds{.lower=true,.upper=true}}},.quadratic_constraints={ {c, ModelSubset::Bounds{.lower=true,.upper=false}}}})) | ) |
absl::flat_hash_map< absl::string_view, FileFormat > operations_research::math_opt::ExtensionToFileFormat | ( | ) |
Definition at line 92 of file file_format_flags.cc.
TerminationProto operations_research::math_opt::FeasibleTermination | ( | const LimitProto | limit, |
const absl::string_view | detail ) |
Definition at line 168 of file math_opt_proto_utils.cc.
TerminationProto operations_research::math_opt::FeasibleTerminationProto | ( | bool | is_maximize, |
LimitProto | limit, | ||
double | finite_primal_objective, | ||
std::optional< double > | optional_dual_objective = std::nullopt, | ||
absl::string_view | detail = {} ) |
Returns a TERMINATION_REASON_FEASIBLE termination with a FEASIBILITY_STATUS_FEASIBLE primal status. The dual status depends on optional_dual_objective.
finite_primal_objective should be finite and limit should not be LIMIT_CUTOFF for a valid TerminationProto to be returned (use LimitCutoffTerminationProto() below instead).
Assumes dual solution exists iff optional_dual_objective is set even if infinite (some solvers return feasible dual solutions without an objective value). If set the dual status is set to FEASIBILITY_STATUS_FEASIBLE, else it is FEASIBILITY_STATUS_UNDETERMINED.
It sets the primal bound based on the primal objective. The dual bound is either set to the optional_dual_objective if set, else to a trivial value.
Definition at line 344 of file math_opt_proto_utils.cc.
SparseBasisStatusVector operations_research::math_opt::FillSparseBasisStatusVector | ( | absl::Span< const int64_t > | ids_in_order, |
const absl::flat_hash_map< int64_t, IndexType > & | id_map, | ||
const glop::StrictITIVector< IndexType, ValueType > & | values ) |
Definition at line 497 of file glop_solver.cc.
SparseDoubleVectorProto operations_research::math_opt::FillSparseDoubleVector | ( | absl::Span< const int64_t > | ids_in_order, |
const absl::flat_hash_map< int64_t, IndexType > & | id_map, | ||
const glop::StrictITIVector< IndexType, glop::Fractional > & | values, | ||
const SparseVectorFilterProto & | filter ) |
Definition at line 461 of file glop_solver.cc.
SparseDoubleVectorProto operations_research::math_opt::FilterSparseVector | ( | const SparseDoubleVectorProto & | input, |
const SparseVectorFilterProto & | filter ) |
Applies filter to each element of input and returns the elements that remain.
Definition at line 105 of file math_opt_proto_utils.cc.
|
inline |
Returns the id of the first linear constraint if there is one. If the input proto is valid, this will also be the smallest id.
Definition at line 70 of file math_opt_proto_utils.h.
|
inline |
Returns the id of the first variable if there is one. If the input proto is valid, this will also be the smallest id.
Definition at line 63 of file math_opt_proto_utils.h.
std::string operations_research::math_opt::FormatFlagPossibleValuesList | ( | ) |
Definition at line 179 of file file_format_flags.cc.
std::optional< FileFormat > operations_research::math_opt::FormatFromFilePath | ( | absl::string_view | file_path | ) |
Sort extensions in reverse lexicographic order. The point here would be to consider ".pb.txt" before we text for ".txt".
Definition at line 105 of file file_format_flags.cc.
std::optional< FileFormat > operations_research::math_opt::FormatFromFlagOrFilePath | ( | const std::optional< FileFormat > | format_flag_value, |
const absl::string_view | file_path ) |
Definition at line 127 of file file_format_flags.cc.
absl::Status operations_research::math_opt::FormulateIndicatorConstraintAsMip | ( | Model & | model, |
IndicatorConstraint | indicator_constraint ) |
Takes a model
and an indicator_constraint
from that same model, and models that constraint using mixed-integer programming (MIP). This entails deleting indicator_constraint
from model
and adding new linear constraints.
As of 2023-10-03, this formulation is a simple big-M formulation:
Indicator constraint: x = 1 --> lb ≤ <a, y> ≤ ub Becomes: if lb > -∞: <a, y> ≥ lb + (LowerBound(<a, y>) - lb) (1 - x) if ub < +∞: <a, y> ≤ ub + (UpperBound(<a, y>) - ub) (1 - x),
where LowerBound() and UpperBound() are from linear_expr_util.
Will return an error if indicator_constraint
is not valid or associated with model
, or if the simple bound computations are not able to prove that the indicator constraint is MIP representable (namely, if LowerBound() and/or UpperBound() return -∞ or +∞, respectively).
One if the implied constraint should hold; zero otherwise.
Definition at line 27 of file general_constraint_to_mip.cc.
BasisStatusProto operations_research::math_opt::FromGlopBasisStatus | ( | const ValueType | glop_basis_status | ) |
ValueType should be glop's VariableStatus or ConstraintStatus.
Definition at line 480 of file glop_solver.cc.
LinearExpressionData operations_research::math_opt::FromLinearExpression | ( | const LinearExpression & | expression | ) |
Converts a LinearExpression
to the associated "raw ID" format.
Definition at line 34 of file model_util.cc.
ObjectiveBoundsProto operations_research::math_opt::GetObjectiveBounds | ( | const SolveResultProto & | solve_result | ) |
Returns solve_result.termination.objective_bounds if present. Otherwise, it builds ObjectiveBoundsProto from solve_result.solve_stats.best_primal/dual_bound
Definition at line 45 of file math_opt_proto_utils.cc.
ProblemStatusProto operations_research::math_opt::GetProblemStatus | ( | const SolveResultProto & | solve_result | ) |
Returns solve_result.termination.problem_status if present. Otherwise, it returns solve_result.solve_stats.problem_status
Definition at line 56 of file math_opt_proto_utils.cc.
std::vector< int64_t > operations_research::math_opt::GetSortedIs | ( | const absl::flat_hash_map< int64_t, T > & | id_map | ) |
Definition at line 531 of file glop_solver.cc.
absl::StatusOr< std::optional< GlpkRay > > operations_research::math_opt::GlpkComputeUnboundRay | ( | glp_prob * | problem | ) |
Returns the primal or dual ray if one is identified by glp_get_unbnd_ray(). Returns an error status if an internal error occurs.
No ray, do nothing.
The factorization may not exists when GLPK's trivial_lp() is used to solve a trivial LP. Here we force the computation of the factorization if necessary.
The function glp_get_unbnd_ray() returns either:
absl::Status operations_research::math_opt::GurobiCallbackImpl | ( | const Gurobi::CallbackContext & | context, |
const GurobiCallbackInput & | callback_input, | ||
MessageCallbackData & | message_callback_data, | ||
SolveInterrupter *const | local_interrupter ) |
Gurobi 9 ignores early calls to GRBterminate(). For example calling GRBterminate() in the first call of a MESSAGE callback only will not interrupt the solve. The rationale is that it is likely Gurobi resets its own internal "terminated" flag at the beginning of the solve but do make some callbacks calls first.
Hence here we make sure to call GRBterminate() for every event once the interrupter has been triggered. This in particular includes POLLING which is regularly emitted by Gurobi during the solve.
The POLLING event is a way for interactive applications that uses Gurobi but don't want to deal with threading to regain some kind of interactivity while a long solve is running by being called back from time to time. No data can be retrieved from this event. This event if thus not wrapped by MathOpt.
At this point we know we have a user callback, thus we must have a local interrupter to deal with termination.
Definition at line 319 of file gurobi_callback.cc.
void operations_research::math_opt::GurobiCallbackImplFlush | ( | const GurobiCallbackInput & | callback_input, |
MessageCallbackData & | message_callback_data ) |
Makes the final calls to the message callback with any unfinished line if necessary. It must be called once at the end of the solve, even when the solve or one callback failed (in case the last unfinished line contains some details about that).
Here we know that message_callback_data has only been filled-in if message_cb was not nullptr. Hence it is safe to make this call without testing.
Definition at line 382 of file gurobi_callback.cc.
absl::StatusOr< GRBenvUniquePtr > operations_research::math_opt::GurobiNewPrimaryEnv | ( | const std::optional< GurobiIsvKey > & | isv_key = std::nullopt | ) |
Returns a new primary Gurobi environment, using the ISV key if provided, or a regular license otherwise. Gurobi::New() creates an environment automatically if not provided, so most users will not use this directly.
Surprisingly, Gurobi will still create an environment if initialization fails, so we want this wrapper even in the error case to free it properly.
Definition at line 154 of file g_gurobi.cc.
testing::Matcher< SolveResult > operations_research::math_opt::HasDualRay | ( | DualRay | expected, |
double | tolerance = kMatcherDefaultTolerance ) |
Actual SolveResult contains a dual ray that matches expected within tolerance.
Definition at line 851 of file matchers.cc.
testing::Matcher< SolveResult > operations_research::math_opt::HasDualSolution | ( | DualSolution | expected, |
double | tolerance = kMatcherDefaultTolerance ) |
SolveResult has a dual solution matching expected within tolerance.
Definition at line 831 of file matchers.cc.
testing::Matcher< SolveResult > operations_research::math_opt::HasPrimalRay | ( | PrimalRay | expected, |
double | tolerance = kMatcherDefaultTolerance ) |
Actual SolveResult contains a primal ray that matches expected within tolerance.
Definition at line 839 of file matchers.cc.
testing::Matcher< SolveResult > operations_research::math_opt::HasPrimalRay | ( | VariableMap< double > | expected_vars, |
double | tolerance = kMatcherDefaultTolerance ) |
Actual SolveResult contains a primal ray with variable values equivalent to (under L_inf scaling) expected_vars up to tolerance.
Definition at line 844 of file matchers.cc.
testing::Matcher< SolveResult > operations_research::math_opt::HasSolution | ( | PrimalSolution | expected, |
const double | tolerance ) |
SolveResult has a primal solution matching expected within tolerance.
Definition at line 823 of file matchers.cc.
std::unique_ptr< Model > operations_research::math_opt::IndependentSetCompleteGraph | ( | const bool | integer, |
const int | n ) |
Definition at line 109 of file test_models.cc.
glop::StrictITIVector< T, int64_t > operations_research::math_opt::IndexToId | ( | const absl::flat_hash_map< int64_t, T > & | id_map | ) |
Returns a vector of containing the MathOpt id of each row or column. Here T is either (Col|Row)Index and id_map is expected to be GlopSolver::(linear_constraints_|variables_).
Guard value used to identify not-yet-set elements of index_to_id.
At this point, index_to_id can't contain any kEmptyId values since index_to_id.size() == id_map.size() and we modified id_map.size() elements in the loop, after checking that the modified element was changed by a previous iteration.
Definition at line 546 of file glop_solver.cc.
TerminationProto operations_research::math_opt::InfeasibleOrUnboundedTerminationProto | ( | bool | is_maximize, |
FeasibilityStatusProto | dual_feasibility_status = FEASIBILITY_STATUS_UNDETERMINED, | ||
absl::string_view | detail = {} ) |
Returns a TERMINATION_REASON_INFEASIBLE_OR_UNBOUNDED termination with FEASIBILITY_STATUS_UNDETERMINED primal status and the provided dual status along with trivial bounds.
primal_or_dual_infeasible is set if dual_feasibility_status is FEASIBILITY_STATUS_UNDETERMINED.
dual_feasibility_status must be infeasible or undetermined for a valid TerminationProto to be returned.
Definition at line 369 of file math_opt_proto_utils.cc.
TerminationProto operations_research::math_opt::InfeasibleTerminationProto | ( | bool | is_maximize, |
FeasibilityStatusProto | dual_feasibility_status = FEASIBILITY_STATUS_UNDETERMINED, | ||
absl::string_view | detail = {} ) |
Returns a TERMINATION_REASON_INFEASIBLE termination with FEASIBILITY_STATUS_INFEASIBLE primal status and the provided dual status.
It sets a trivial primal bound and a dual bound based on the provided dual status, which should be FEASIBILITY_STATUS_FEASIBLE or FEASIBILITY_STATUS_UNDETERMINED. If the dual status is FEASIBILITY_STATUS_UNDETERMINED, then the dual bound will be trivial and if the dual status is FEASIBILITY_STATUS_FEASIBLE, then the dual bound will be equal to the primal bound.
The convention for infeasible MIPs is that dual_feasibility_status is feasible (There always exist a dual feasible convex relaxation of an infeasible MIP).
dual_feasibility_status must not be FEASIBILITY_STATUS_UNSPECIFIED for a valid TerminationProto to be returned.
Definition at line 251 of file math_opt_proto_utils.cc.
MessageCallback operations_research::math_opt::InfoLoggerMessageCallback | ( | absl::string_view | prefix = "", |
absl::SourceLocation | loc = absl::SourceLocation::current() ) |
Returns a message callback function that prints each line to LOG(INFO), prefixing each line with the given prefix.
Usage:
SolveArguments args; args.message_callback = InfoLoggerMessageCallback("[solver] ");
Definition at line 93 of file message_callback.cc.
|
inline |
LinearExpression operations_research::math_opt::InnerProduct | ( | const LeftIterable & | left, |
const RightIterable & | right ) |
Definition at line 1717 of file variable_and_expressions.h.
For infeasible and unbounded see Not checked if options check_solutions_if_inf_or_unbounded and the If options first_solution_only is check the entire list of Dual solution is not checked if options check the entire list of Enable with options check_basis testing::Matcher< SolveResult > operations_research::math_opt::IsConsistentWith | ( | const SolveResult & | expected, |
const SolveResultMatcherOptions & | options = {} ) |
solutions matches in the same order.
For problems with either primal or dual infeasibility, see SolveResultMatcherOptions::inf_or_unb_soft_match for guidance on how to best set the termination reason and inf_or_unb_soft_match.
Definition at line 942 of file matchers.cc.
testing::Matcher< ComputeInfeasibleSubsystemResult > operations_research::math_opt::IsFeasible | ( | ) |
ComputeInfeasibleSubsystemResult matchers
Matchers for a ComputeInfeasibleSubsystemResult Checks that ComputeInfeasibleSubsystemResult.feasibility is kFeasible, that the .infeasible_subsystem is empty and that is_minimal is false.
Definition at line 972 of file matchers.cc.
testing::Matcher< LinearExpression > operations_research::math_opt::IsIdentical | ( | LinearExpression | expected | ) |
Matchers for LinearExpression and QuadraticExpression
Matchers for various Variable expressions (e.g. LinearExpression) Checks that the expressions are structurally identical (i.e., internal maps have the same keys and storage, coefficients are exactly equal). This factory will CHECK-fail if expected contains any NaN values, and any NaN values in the expression compared against will result in the matcher failing.
Definition at line 278 of file matchers.cc.
testing::Matcher< QuadraticExpression > operations_research::math_opt::IsIdentical | ( | QuadraticExpression | expected | ) |
Checks that the expressions are structurally identical (i.e., internal maps have the same keys and storage, coefficients are exactly equal). This factory will CHECK-fail if expected contains any NaN values, and any NaN values in the expression compared against will result in the matcher failing.
Definition at line 319 of file matchers.cc.
testing::Matcher< ComputeInfeasibleSubsystemResult > operations_research::math_opt::IsInfeasible | ( | std::optional< bool > | expected_is_minimal = std::nullopt, |
std::optional< ModelSubset > | expected_infeasible_subsystem = std::nullopt ) |
Checks that ComputeInfeasibleSubsystemResult.feasibility is kInfeasible and that .infeasible_subsystem is not empty. If expected_is_minimal is set, test that .is_minimal has the same value. If expected_infeasible_subsystem is set, test that the resulting ModelSubset::Proto() are EqualsProto().
Definition at line 994 of file matchers.cc.
Matcher< absl::flat_hash_map< K, double > > operations_research::math_opt::IsNear | ( | absl::flat_hash_map< K, double > | expected, |
const double | tolerance ) |
Definition at line 259 of file matchers.cc.
testing::Matcher< absl::flat_hash_map< QuadraticConstraint, double > > operations_research::math_opt::IsNear | ( | absl::flat_hash_map< QuadraticConstraint, double > | expected, |
double | tolerance = kMatcherDefaultTolerance ) |
Checks that the maps have identical keys and values within tolerance. This factory will CHECK-fail if expected contains any NaN values.
Definition at line 241 of file matchers.cc.
testing::Matcher< DualRay > operations_research::math_opt::IsNear | ( | DualRay | expected, |
double | tolerance = kMatcherDefaultTolerance ) |
Checks that dual variables and reduced costs are defined for the same set of Variables/LinearConstraints, and that their rescaled values are within tolerance.
Definition at line 597 of file matchers.cc.
testing::Matcher< DualSolution > operations_research::math_opt::IsNear | ( | DualSolution | expected, |
double | tolerance = kMatcherDefaultTolerance, | ||
bool | allow_undetermined = false ) |
Checks dual variables, reduced costs and objective are within tolerance and feasibility statuses are identical.
Definition at line 434 of file matchers.cc.
testing::Matcher< LinearConstraintMap< double > > operations_research::math_opt::IsNear | ( | LinearConstraintMap< double > | expected, |
double | tolerance = kMatcherDefaultTolerance ) |
Checks that the maps have identical keys and values within tolerance. This factory will CHECK-fail if expected contains any NaN values, and any NaN values in the expression compared against will result in the matcher failing.
Definition at line 234 of file matchers.cc.
testing::Matcher< PrimalRay > operations_research::math_opt::IsNear | ( | PrimalRay | expected, |
double | tolerance = kMatcherDefaultTolerance ) |
Matchers for a Rays Checks variables match and that after rescaling, variable values are within tolerance.
Definition at line 533 of file matchers.cc.
testing::Matcher< PrimalSolution > operations_research::math_opt::IsNear | ( | PrimalSolution | expected, |
double | tolerance = kMatcherDefaultTolerance, | ||
bool | allow_undetermined = false ) |
Checks variables match and variable/objective values are within tolerance and feasibility statuses are identical.
Definition at line 423 of file matchers.cc.
testing::Matcher< Solution > operations_research::math_opt::IsNear | ( | Solution | expected, |
const SolutionMatcherOptions | options ) |
Definition at line 458 of file matchers.cc.
testing::Matcher< VariableMap< double > > operations_research::math_opt::IsNear | ( | VariableMap< double > | expected, |
double | tolerance = kMatcherDefaultTolerance ) |
Matchers for absl::flat_hash_map Checks that the maps have identical keys and values within tolerance. This factory will CHECK-fail if expected contains any NaN values.
Definition at line 221 of file matchers.cc.
testing::Matcher< BoundedLinearExpression > operations_research::math_opt::IsNearlyEquivalent | ( | const BoundedLinearExpression & | expected, |
double | tolerance = kMatcherDefaultTolerance ) |
Checks that the bounded linear expression is equivalent to expected, where equivalence is maintained by:
Definition at line 310 of file matchers.cc.
Matcher< absl::flat_hash_map< K, double > > operations_research::math_opt::IsNearlySubsetOf | ( | absl::flat_hash_map< K, double > | expected, |
const double | tolerance ) |
Definition at line 266 of file matchers.cc.
testing::Matcher< absl::flat_hash_map< QuadraticConstraint, double > > operations_research::math_opt::IsNearlySubsetOf | ( | absl::flat_hash_map< QuadraticConstraint, double > | expected, |
double | tolerance = kMatcherDefaultTolerance ) |
Checks that the keys of actual are a subset of the keys of expected, and that for all shared keys, the values are within tolerance. This factory will CHECK-fail if expected contains any NaN values, and any NaN values in the expression compared against will result in the matcher failing.
Definition at line 249 of file matchers.cc.
testing::Matcher< LinearConstraintMap< double > > operations_research::math_opt::IsNearlySubsetOf | ( | LinearConstraintMap< double > | expected, |
double | tolerance = kMatcherDefaultTolerance ) |
Checks that the keys of actual are a subset of the keys of expected, and that for all shared keys, the values are within tolerance. This factory will CHECK-fail if expected contains any NaN values, and any NaN values in the expression compared against will result in the matcher failing.
Definition at line 227 of file matchers.cc.
testing::Matcher< VariableMap< double > > operations_research::math_opt::IsNearlySubsetOf | ( | VariableMap< double > | expected, |
double | tolerance = kMatcherDefaultTolerance ) |
Checks that the keys of actual are a subset of the keys of expected, and that for all shared keys, the values are within tolerance. This factory will CHECK-fail if expected contains any NaN values, and any NaN values in the expression compared against will result in the matcher failing.
Definition at line 215 of file matchers.cc.
<=x<=1 IncrementalMipTest::IncrementalMipTest() :model_("incremental_solve_test"), x_(model_.AddContinuousVariable(0.0, 1.0, "x")), y_(model_.AddIntegerVariable(0.0, 2.0, "y")), c_(model_.AddLinearConstraint(0<=x_+y_<=1.5, "c")) { model_.Maximize(3.0 *x_+2.0 *y_+0.1);solver_=NewIncrementalSolver(&model_, TestedSolver()).value();const SolveResult first_solve=solver_->Solve().value();CHECK(first_solve.has_primal_feasible_solution());CHECK_LE(std::abs(first_solve.objective_value() - 3.6), kTolerance)<< first_solve.objective_value();} namespace { TEST_P(SimpleMipTest, OneVarMax) { Model model;const Variable x=model.AddVariable(0.0, 4.0, false, "x");model.Maximize(2.0 *x);ASSERT_OK_AND_ASSIGN(const SolveResult result, Solve(model, GetParam().solver_type));ASSERT_THAT(result, IsOptimal(8.0));EXPECT_THAT(result.variable_values(), IsNear({{x, 4.0}}));} TEST_P(SimpleMipTest, OneVarMin) { Model model;const Variable x=model.AddVariable(-2.4, 4.0, false, "x");model.Minimize(2.0 *x);ASSERT_OK_AND_ASSIGN(const SolveResult result, Solve(model, GetParam().solver_type));ASSERT_THAT(result, IsOptimal(-4.8));EXPECT_THAT(result.variable_values(), IsNear({{x, -2.4}}));} TEST_P(SimpleMipTest, OneIntegerVar) { Model model;const Variable x=model.AddVariable(0.0, 4.5, true, "x");model.Maximize(2.0 *x);ASSERT_OK_AND_ASSIGN(const SolveResult result, Solve(model, GetParam().solver_type));ASSERT_THAT(result, IsOptimal(8.0));EXPECT_THAT(result.variable_values(), IsNear({{x, 4.0}}));} TEST_P(SimpleMipTest, SimpleLinearConstraint) { Model model;const Variable x=model.AddBinaryVariable("x");const Variable y=model.AddBinaryVariable("y");model.Maximize(2.0 *x+y);model.AddLinearConstraint(0.0<=x+y<=1.5, "c");ASSERT_OK_AND_ASSIGN(const SolveResult result, Solve(model, GetParam().solver_type));ASSERT_THAT(result, IsOptimal(2.0));EXPECT_THAT(result.variable_values(), IsNear({{x, 1}, {y, 0}}));} TEST_P(SimpleMipTest, Unbounded) { Model model;const Variable x=model.AddVariable(0.0, kInf, true, "x");model.Maximize(2.0 *x);ASSERT_OK_AND_ASSIGN(const SolveResult result, Solve(model, GetParam().solver_type));if(GetParam().report_unboundness_correctly) { ASSERT_THAT(result, TerminatesWithOneOf({TerminationReason::kUnbounded, TerminationReason::kInfeasibleOrUnbounded}));} else { ASSERT_THAT(result, TerminatesWith(TerminationReason::kOtherError));} } TEST_P(SimpleMipTest, Infeasible) { Model model;const Variable x=model.AddVariable(0.0, 3.0, true, "x");model.Maximize(2.0 *x);model.AddLinearConstraint(x >=4.0);ASSERT_OK_AND_ASSIGN(const SolveResult result, Solve(model, GetParam().solver_type));ASSERT_THAT(result, TerminatesWith(TerminationReason::kInfeasible));} TEST_P(SimpleMipTest, FractionalBoundsContainNoInteger) { if(GetParam().solver_type==SolverType::kGurobi) { GTEST_SKIP()<< "TODO(b/272298816): Gurobi bindings are broken here.";} Model model;const Variable x=model.AddIntegerVariable(0.5, 0.6, "x");model.Maximize(x);EXPECT_THAT(Solve(model, GetParam().solver_type), IsOkAndHolds(TerminatesWith(TerminationReason::kInfeasible)));} TEST_P(IncrementalMipTest, EmptyUpdate) { ASSERT_THAT(solver_->Update(), IsOkAndHolds(DidUpdate()));ASSERT_OK_AND_ASSIGN(const SolveResult result, solver_->SolveWithoutUpdate());ASSERT_THAT(result, IsOptimal(3.6));EXPECT_THAT(result.variable_values(), IsNear({{x_, 0.5}, {y_, 1.0}}));} TEST_P(IncrementalMipTest, MakeContinuous) { model_.set_continuous(y_);ASSERT_THAT(solver_->Update(), IsOkAndHolds(DidUpdate()));ASSERT_OK_AND_ASSIGN(const SolveResult result, solver_->SolveWithoutUpdate());ASSERT_THAT(result, IsOptimal(4.1));EXPECT_THAT(result.variable_values(), IsNear({{x_, 1.0}, {y_, 0.5}}));} TEST_P(IncrementalMipTest, DISABLED_MakeContinuousWithNonIntegralBounds) { solver_.reset();Model model("bounds");const Variable x=model.AddIntegerVariable(0.5, 1.5, "x");model.Maximize(x);ASSERT_OK_AND_ASSIGN(const auto solver, NewIncrementalSolver(&model, TestedSolver()));ASSERT_THAT(solver->Solve(), IsOkAndHolds(IsOptimal(1.0)));model.set_continuous(x);ASSERT_THAT(solver->Update(), IsOkAndHolds(DidUpdate()));ASSERT_THAT(solver-> operations_research::math_opt::IsOkAndHolds | ( | IsOptimal(1.5) | ) |
testing::Matcher< SolveResult > operations_research::math_opt::IsOptimal | ( | std::optional< double > | expected_primal_objective = std::nullopt, |
double | tolerance = kMatcherDefaultTolerance ) |
Matchers for a SolveResult Checks the following:
Definition at line 762 of file matchers.cc.
testing::Matcher< SolveResult > operations_research::math_opt::IsOptimalWithDualSolution | ( | const double | expected_objective, |
const LinearConstraintMap< double > | expected_dual_values, | ||
const absl::flat_hash_map< QuadraticConstraint, double > | expected_quadratic_dual_values, | ||
const VariableMap< double > | expected_reduced_costs, | ||
const double | tolerance ) |
Definition at line 805 of file matchers.cc.
testing::Matcher< SolveResult > operations_research::math_opt::IsOptimalWithDualSolution | ( | const double | expected_objective, |
const LinearConstraintMap< double > | expected_dual_values, | ||
const VariableMap< double > | expected_reduced_costs, | ||
const double | tolerance ) |
Definition at line 790 of file matchers.cc.
testing::Matcher< SolveResult > operations_research::math_opt::IsOptimalWithSolution | ( | const double | expected_objective, |
const VariableMap< double > | expected_variable_values, | ||
const double | tolerance ) |
Definition at line 777 of file matchers.cc.
testing::Matcher< ComputeInfeasibleSubsystemResult > operations_research::math_opt::IsUndetermined | ( | ) |
Checks that ComputeInfeasibleSubsystemResult.feasibility is kUndetermined, that the .infeasible_subsystem is empty and that is_minimal is false..
Definition at line 983 of file matchers.cc.
testing::Matcher< Termination > operations_research::math_opt::LimitIs | ( | Limit | limit, |
testing::Matcher< std::string > | detail_matcher = testing::_ ) |
Checks the following:
detail_matcher
is provided, it matches the detail
.See TerminatesWithLimit() for a similar matcher for SolveResult.
Matcher< Termination > operations_research::math_opt::LimitIs | ( | math_opt::Limit | limit, |
const Matcher< std::string > | detail_matcher ) |
Definition at line 709 of file matchers.cc.
TerminationProto operations_research::math_opt::LimitTerminationProto | ( | bool | is_maximize, |
LimitProto | limit, | ||
std::optional< double > | optional_finite_primal_objective, | ||
std::optional< double > | optional_dual_objective = std::nullopt, | ||
absl::string_view | detail = {} ) |
Either calls FeasibleTerminationProto() or NoSolutionFoundTerminationProto() based on optional_finite_primal_objective having a value.
That is it assumes a primal feasible solution exists iff optional_finite_primal_objective has a value.
Definition at line 270 of file math_opt_proto_utils.cc.
TerminationProto operations_research::math_opt::LimitTerminationProto | ( | LimitProto | limit, |
double | primal_objective, | ||
double | dual_objective, | ||
bool | claim_dual_feasible_solution_exists, | ||
absl::string_view | detail = {} ) |
Returns either a TERMINATION_REASON_FEASIBLE or TERMINATION_REASON_NO_SOLUTION_FOUND termination depending on primal_objective being finite or not. That is it assumes there is a primal feasible solution iff primal_objective is finite.
If claim_dual_feasible_solution_exists is true, the dual_status is set as FEASIBILITY_STATUS_FEASIBLE, else FEASIBILITY_STATUS_UNDETERMINED.
This function assumes dual solution exists if claim_dual_feasible_solution_exists is true even if dual_objective is infinite (some solvers return feasible dual solutions without an objective value). If dual_objective is finite then claim_dual_feasible_solution_exists must be true for a valid termination to be returned.
Definition at line 284 of file math_opt_proto_utils.cc.
absl::StatusOr< LinearConstraintMap< BasisStatus > > operations_research::math_opt::LinearConstraintBasisFromProto | ( | const ModelStorage * | model, |
const SparseBasisStatusVector & | basis_proto ) |
Returns the LinearConstraintMap<BasisStatus> equivalent to basis_proto
.
Requires that (or returns a status error):
model
(this implies that each id is in [0, max(int64_t))).Definition at line 230 of file sparse_containers.cc.
SparseBasisStatusVector operations_research::math_opt::LinearConstraintBasisToProto | ( | const LinearConstraintMap< BasisStatus > & | basis_values | ) |
Returns the proto equivalent of basis_values.
Definition at line 238 of file sparse_containers.cc.
absl::StatusOr< MapFilter< LinearConstraint > > operations_research::math_opt::LinearConstraintFilterFromProto | ( | const Model & | model, |
const SparseVectorFilterProto & | proto ) |
Returns the MapFilter<LinearConstraint> equivalent to proto
.
Requires that (or returns a status error):
model
. Definition at line 46 of file map_filter.cc.
absl::StatusOr< LinearConstraintMap< double > > operations_research::math_opt::LinearConstraintValuesFromProto | ( | const ModelStorage * | model, |
const SparseDoubleVectorProto & | lin_cons_proto ) |
Returns the LinearConstraintMap<double> equivalent to lin_cons_proto
.
Requires that (or returns a status error):
model
(this implies that each id is in [0, max(int64_t))).Definition at line 189 of file sparse_containers.cc.
SparseDoubleVectorProto operations_research::math_opt::LinearConstraintValuesToProto | ( | const LinearConstraintMap< double > & | linear_constraint_values | ) |
Returns the proto equivalent of linear_constraint_values.
Definition at line 197 of file sparse_containers.cc.
testing::Matcher< LinearExpression > operations_research::math_opt::LinearExpressionIsNear | ( | const LinearExpression | expected, |
const double | tolerance ) |
Definition at line 282 of file matchers.cc.
double operations_research::math_opt::LowerBound | ( | const LinearExpression & | linear_expression | ) |
Computes a lower bound on the value a linear expression can take based on the variable bounds.
The user must ensure:
This function is deterministic, but runs in O(n log n) and will allocate.
Alternatives:
Definition at line 52 of file linear_expr_util.cc.
iterator_range< T > operations_research::math_opt::make_range | ( | std::pair< T, T > | p | ) |
iterator_range< T > operations_research::math_opt::make_range | ( | T | x, |
T | y ) |
MapFilter< ValueType > operations_research::math_opt::MakeKeepKeysFilter | ( | const Collection & | keys | ) |
Returns a filter that keeps the key-value pairs with the given keys.
Example: std::vector<Variable> decision_vars = ...; const auto filter = MakeKeepKeysFilter(decision_vars);
Definition at line 167 of file map_filter.h.
MapFilter< KeyType > operations_research::math_opt::MakeKeepKeysFilter | ( | std::initializer_list< KeyType > | keys | ) |
Returns a filter that keeps the key-value pairs with the given keys.
This overload is necessary since C++ does not automatically deduce the type when using the previous one.
Example: const Variable x = ...; const Variable y = ...; const auto filter = MakeKeepKeysFilter({x, y});
Definition at line 183 of file map_filter.h.
MapFilter< KeyType > operations_research::math_opt::MakeSkipAllFilter | ( | ) |
Returns a filter that skips all key-value pairs.
This is typically used to disable the dual data in SolveResult when these are ignored by the user.
Example: const auto filter = MakeSkipAllFilter<Variable>();
Definition at line 142 of file map_filter.h.
MapFilter< KeyType > operations_research::math_opt::MakeSkipZerosFilter | ( | ) |
Returns a filter that skips all key-value pairs with zero values (or false values for bool).
Example: const auto filter = MakeSkipZerosFilter<Variable>();
Definition at line 154 of file map_filter.h.
ObjectiveBoundsProto operations_research::math_opt::MakeTrivialBounds | ( | bool | is_maximize | ) |
Returns trivial bounds.
Trivial bounds are:
Definition at line 188 of file math_opt_proto_utils.cc.
auto operations_research::math_opt::MakeUpdateDataFieldIterator | ( | BaseIter | base_iter | ) |
Returns a new iterator on the field identified by the PointerToMember wrapping an iterator of a: std::vector<std::pair<ID, std::unique_ptr<UpdateData>>
Example: std::vector<std::pair<Id, std::unique_ptr<UpdateData>> update_trackers; const auto begin = MakeUpdateDataFieldIterator<&UpdateData::field>(update_trackers.cbegin());
Definition at line 104 of file iterators.h.
auto operations_research::math_opt::MakeUpdateDataFieldRange | ( | const UpdateTrackers & | trackers | ) |
Returns a range (begin and end iterator) pointing to the field identified by the PointerToMember from an iterable of std::pair<ID, std::unique_ptr<UpdateData>
Example: std::vector<std::pair<Id, std::unique_ptr<UpdateData>> trackers; for(auto& f : MakeUpdateDataFieldRange<&UpdateData::field>(trackers)) { ... }
Definition at line 121 of file iterators.h.
SparseVectorView< T > operations_research::math_opt::MakeView | ( | absl::Span< const int64_t > | ids, |
const Collection & | values ) |
Returns a view for values that are vector-like collection like std::vector<T> or google::protobuf::RepeatedField<T>. See other overloads for other values-types.
Definition at line 148 of file sparse_vector_view.h.
SparseVectorView< const T * > operations_research::math_opt::MakeView | ( | const google::protobuf::RepeatedField< int64_t > & | ids, |
const google::protobuf::RepeatedPtrField< T > & | values ) |
Returns a view for values that are google::protobuf::RepeatedPtrField<T>. Common use for this overload is when T = std::string. See other overloads for other values-types.
Definition at line 157 of file sparse_vector_view.h.
SparseVectorView< T > operations_research::math_opt::MakeView | ( | const SparseVector< T > & | sparse_vector | ) |
Returns a view for values in a SparseVector. For this case it is preferred over the two-argument overloads. See other overloads for other values-types.
Definition at line 175 of file sparse_vector_view.h.
SparseVectorView< T > operations_research::math_opt::MakeView | ( | const SparseVectorProto & | sparse_vector | ) |
Returns a view for values in a SparseDoubleVectorProto, SparseBoolVectorProto or similar structure. For such cases, it is preferred over the two-argument overloads. See other overloads for other values-types.
Definition at line 168 of file sparse_vector_view.h.
std::vector< K > operations_research::math_opt::MapKeys | ( | const absl::flat_hash_map< K, V > & | in_map | ) |
std::vector< K > operations_research::math_opt::MapKeys | ( | const google::protobuf::Map< K, V > & | in_map | ) |
operations_research::math_opt::MATCHER_P | ( | FirstElementIs | , |
first_element_matcher | , | ||
(negation ? absl::StrCat("is empty or first element ", MatcherToString(first_element_matcher, true)) :absl::StrCat("has at least one element and first element ", MatcherToString(first_element_matcher, false))) | ) |
Definition at line 699 of file matchers.cc.
std::string operations_research::math_opt::MatcherToString | ( | const ::testing::PolymorphicMatcher< T > & | matcher, |
bool | negate ) |
clang-format off Polymorphic matchers do not always define DescribeTo, The <T> type may not be a matcher, but it will implement DescribeTo. clang-format on
Definition at line 694 of file matchers.cc.
std::string operations_research::math_opt::MatcherToString | ( | const Matcher< T > & | matcher, |
bool | negate ) |
Definition at line 685 of file matchers.cc.
std::string operations_research::math_opt::MatcherToStringImpl | ( | const MatcherType & | matcher, |
const bool | negate ) |
Definition at line 674 of file matchers.cc.
operations_research::math_opt::MATH_OPT_DEFINE_ENUM | ( | BasisStatus | , |
BASIS_STATUS_UNSPECIFIED | ) |
operations_research::math_opt::MATH_OPT_DEFINE_ENUM | ( | CallbackEvent | , |
CALLBACK_EVENT_UNSPECIFIED | ) |
operations_research::math_opt::MATH_OPT_DEFINE_ENUM | ( | Emphasis | , |
EMPHASIS_UNSPECIFIED | ) |
operations_research::math_opt::MATH_OPT_DEFINE_ENUM | ( | FeasibilityStatus | , |
FEASIBILITY_STATUS_UNSPECIFIED | ) |
operations_research::math_opt::MATH_OPT_DEFINE_ENUM | ( | Limit | , |
LIMIT_UNSPECIFIED | ) |
operations_research::math_opt::MATH_OPT_DEFINE_ENUM | ( | LPAlgorithm | , |
LP_ALGORITHM_UNSPECIFIED | ) |
operations_research::math_opt::MATH_OPT_DEFINE_ENUM | ( | SolutionStatus | , |
SOLUTION_STATUS_UNSPECIFIED | ) |
operations_research::math_opt::MATH_OPT_DEFINE_ENUM | ( | SolverType | , |
SOLVER_TYPE_UNSPECIFIED | ) |
operations_research::math_opt::MATH_OPT_DEFINE_ENUM | ( | TerminationReason | , |
TERMINATION_REASON_UNSPECIFIED | ) |
operations_research::math_opt::MATH_OPT_REGISTER_SOLVER | ( | SOLVER_TYPE_CP_SAT | , |
CpSatSolver::New | ) |
operations_research::math_opt::MATH_OPT_REGISTER_SOLVER | ( | SOLVER_TYPE_HIGHS | , |
HighsSolver::New | ) |
operations_research::math_opt::MATH_OPT_REGISTER_SOLVER | ( | SOLVER_TYPE_PDLP | , |
PdlpSolver::New | ) |
absl::StatusOr<::operations_research::MPModelProto > operations_research::math_opt::MathOptModelToMPModelProto | ( | const ::operations_research::math_opt::ModelProto & | model | ) |
Definition at line 389 of file proto_converter.cc.
absl::StatusOr< MPModelProto > operations_research::math_opt::MathOptModelToMPModelProto | ( | const ModelProto & | model | ) |
Returns a linear_solver MPModelProto equivalent to the input math_opt Model. The input Model must be in a valid state, as checked by ValidateModel
.
Variables are created in the same order as they appear in model.variables
. Hence the returned .variable(i)
corresponds to input model.variables.ids(i)
.
The linear_solver Model stores all general constraints (e.g., quadratic, SOS) in a single repeated field, while ModelProto stores then in separate maps. Therefore neither the relative ordering, nor the raw IDs, of general constraints are preserved in the resulting Model.
C operations_research::math_opt::MemberPointerClassType | ( | V C::* | ) |
V operations_research::math_opt::MemberPointerValueType | ( | V C::* | ) |
The "functions" are used to extract the types of the field and of the class from pointers-to-member. They have no implementation since they are only used with decltype
.
Example: int A::* ptr = &A::x; decltype(MemberPointerValueType(PointerToMember)) v; decltype(MemberPointerClassType(PointerToMember)) c; ///< The type of v
is int
and the type of c
is A
.
absl::Status operations_research::math_opt::ModelIsSupported | ( | const ModelProto & | model, |
const SupportedProblemStructures & | support_menu, | ||
absl::string_view | solver_name ) |
Returns an InvalidArgumentError (respectively, UnimplementedError) if a problem structure is present in model
and not supported (resp., not yet implemented) according to support_menu
.
Definition at line 387 of file math_opt_proto_utils.cc.
absl::StatusOr< ModelProto > operations_research::math_opt::ModelProtoFromLp | ( | absl::string_view | lp_data | ) |
Parses a the model in "CPLEX LP" format.
This function creates and destroys local temporary files and thus is not portable.
For large models, this will not work on diskless jobs in prod.
Warnings:
OR-Tools does not have an LP file parser, so we go from LP file to SCIP, then export to MPS, parse the MPS to ModelProto. This is not efficient, but usually still much faster than solving an LP or MIP. Note the SCIP LP parser actually supports SOS and quadratics, but the OR-tools MPS reader does not.
It would be preferable to write an LP Parser from scratch and delete this.
For more information about the different LP file formats: http://lpsolve.sourceforge.net/5.5/lp-format.htm http://lpsolve.sourceforge.net/5.5/CPLEX-format.htm https://www.ibm.com/docs/en/icos/12.8.0.0?topic=cplex-lp-file-format-algebraic-representation http://www.gurobi.com/documentation/5.1/reference-manual/node871
Set up temporary files
Do the conversion
Definition at line 52 of file lp_parser.cc.
absl::StatusOr< std::string > operations_research::math_opt::ModelProtoToLp | ( | const ModelProto & | model | ) |
Returns the model in "CPLEX LP" format.
The RemoveNames() function can be used on the model to remove names if they should not be exported.
For more information about the different LP file formats: http://lpsolve.sourceforge.net/5.5/lp-format.htm http://lpsolve.sourceforge.net/5.5/CPLEX-format.htm https://www.ibm.com/docs/en/icos/12.8.0.0?topic=cplex-lp-file-format-algebraic-representation http://www.gurobi.com/documentation/5.1/reference-manual/node871
Definition at line 27 of file lp_converter.cc.
absl::StatusOr< std::string > operations_research::math_opt::ModelProtoToMps | ( | const ModelProto & | model | ) |
Returns the model in MPS format.
The RemoveNames() function can be used on the model to remove names if they should not be exported.
Definition at line 29 of file mps_converter.cc.
absl::StatusOr< VariableMap< double > > operations_research::math_opt::MoveVariablesToTheirBestFeasibleValue | ( | const Model & | model, |
const VariableMap< double > & | input_solution, | ||
absl::Span< const Variable > | variables, | ||
const MoveVariablesToTheirBestFeasibleValueOptions & | options = {} ) |
Returns a solution that improves the objective value of the input model by moving the input variables' values to the their best feasible value (as defined by the objective) based on the constraints and other variables' values.
The input_solution
has to contain a value for each variable in the model
. The input model must not be unbounded (and error is returned if this is the case).
Only the value of the variables listed in variables
are modified. The variables are considered in the order they appear in the vector. Thus the end result depends on this ordering:
If multiple variables appear in the same constraint, the first variable may use up all the constraint's slack; preventing next variables to improve the objective as much as they could.
This issue can be fixed by sorting variables by their objective coefficient. But this may conflict with the order picked to solve dependencies as explained below.
A variable improvement may be limited by another variable it depends on. If it appears first and the second variable's value changes, we may end up with some slack that the first variable could use.
This issue can be solved by either:
variables
in a correct order so that the limiting variable appear first.The variables' values are changed in the direction that improves the objective. Variables that are not in the objective are not modified.
This function is typically useful when solving MIP with a non-zero gap or when the time limit interrupts the solve early. In those cases a MIP solver can return a solution where some variables can trivially be changed to improve the objective but since the solution fits in the termination criteria (either the gap or the time limit) the solver did not do it.
Validate the inputs.
We maintain a solution with updated value for each variable in the order of traversal.
Invariant: values are finite.
We also maintain the values of each constraint in sync with the values in new_solution.
Invariant: constraints_value.at(c) == ConstraintValue(c, new_solution)
The variable can't change the objective. We ignore it.
We will then compute the best bound of the variable value based on its own bounds and all the constraints it belongs to. This best bound is based on the sign of the objective coefficient and the objective direction (min or max). The positive_v_change value tracks which direction this is.
The best_v_bound is the maximum variable's value. We initialize it with the variable's bounds, we use +/-inf if bounds are infinite.
Now iterate on constraints that contain the variable to find the most limiting one.
For reason explained below we also keep track of the fact that we found a limiting constraint, i.e. a constraint with a finite bound in the direction of improvement of v.
The ValidateModel() should have failed.
The variable has no influence on the constraint.
Based on the constraint coefficient's sign and the variable change sign, we compute which constraint bound we need to consider.
If the bound is not finite, ignore this constraint.
We have one constraint with a finite bound if we reach this point.
Compute the bound that the constraint put on the variable.
If the constraint value is not finite (could be +/-inf or NaN due to computation), we consider we can't improve the value of v.
We could here recompute the constraint value without v and do something if the value is finite but in practice it is likely to be an issue.
If we are out of the bounds of the constraint, we can't improve v.
c_value < used_bound
, i.e. we use < instead of <=. In practice though the case c_value == used_bound is covered by the computation and will return v_current_value.Can be +/-inf; see comment about some_constraints_are_limiting below.
Update best_v_bound based on the constraint.
Here we don't fail if constraints have finite bounds but computations lead to infinite values. This typically occurs when the limiting constraint has a huge bound and the variable coefficient in the constraint is small. We could improve the algorithm to pick a finite value for the variable that does not lead to an overflow but this is non trivial.
If there is no limiting constraint with a finite bound and the variable own bound is infinite, the model is actually unbounded.
Make sure the value is integral for integer variables. If we have a constraint limiting x <= 1.5 we want to use x = 1.
If we have find no improvement; skip this variable.
Apply the change to new_solution.
As v_improved_value is finite the invariant holds.
Restore the invariant of constraint_values based on the new_solution.
Here we could incrementally update values based on the change of new_solution.at(v) and the coefficient for (c, v). But since we are doing floating point computation, we may introduce some errors for each variable being changed. It is easier to recompute the constraints values from scratch instead.
Definition at line 87 of file solution_improvement.cc.
absl::StatusOr< std::optional< SolutionHintProto > > operations_research::math_opt::MPModelProtoSolutionHintToMathOptHint | ( | const MPModelProto & | model | ) |
Returns the optional model.solution_hint
as a MathOpt hint. Returns nullopt if no hint is set on the input model or if the hint is empty.
The input MPModelProto must be valid, as checked by FindErrorInMPModelProto()
.
Definition at line 370 of file proto_converter.cc.
absl::StatusOr<::operations_research::math_opt::ModelProto > operations_research::math_opt::MPModelProtoToMathOptModel | ( | const ::operations_research::MPModelProto & | model | ) |
This allocation is reused across loop iterations, use caution!
Definition at line 217 of file proto_converter.cc.
absl::StatusOr< ModelProto > operations_research::math_opt::MPModelProtoToMathOptModel | ( | const MPModelProto & | model | ) |
Returns a ModelProto equivalent to the input linear_solver Model. The input MPModelProto must be valid, as checked by FindErrorInMPModelProto()
.
The linear_solver Model stores all general constraints (e.g., quadratic, SOS) in a single repeated field, while ModelProto stores then in separate maps. The output constraint maps will each be populated with consecutive indices starting from 0 (hence the indices may change).
MPModelProto can contain an optional solution_hint
which is ignored by this function. In MathOpt the hints are parameters passed to the solve functions instead of being in the model. The MPModelProtoSolutionHintToMathOptHint()
function can be used to extract it.
absl::StatusOr< ModelProto > operations_research::math_opt::MpsToModelProto | ( | absl::string_view | mps_data | ) |
Converts a string with the contents of an MPS file into a ModelProto.
Definition at line 43 of file mps_converter.cc.
absl::StatusOr< std::unique_ptr< IncrementalSolver > > operations_research::math_opt::NewIncrementalSolver | ( | Model * | model, |
SolverType | solver_type, | ||
SolverInitArguments | arguments = {} ) |
Creates a new incremental solve for the given model. It may returns an error if the parameters are invalid (for example if the selected solver is not linked in the binary).
The returned IncrementalSolver keeps a copy of arguments
. Thus the content of arguments.non_streamable (for example pointers to solver specific struct) must be valid until the destruction of the IncrementalSolver. It also registers on the Model to keep track of updates (see class documentation for details).
absl::StatusOr< GRBenv * > operations_research::math_opt::NewPrimaryEnvFromISVKey | ( | const GurobiIsvKey & | isv_key | ) |
Returns a new primary Gurobi environment initialized with an ISV key.
See http://www.gurobi.com/products/licensing-pricing/isv-program.
Surprisingly, even when Gurobi fails to load the environment, it still creates one. Here we make sure to free it properly. If initialization succeeds, we Cancel() this below.
We use GRBgeterrormsg() to get the associated error message that goes with the error and the contains additional data like the user, the host, and the hostid.
We want to turn off logging before setting the ISV key so that it doesn't leak. We store the original logging state, and reset it at the end.
Reset output flag to its original value.
Environment initialization succeeded, we don't want to free it upon exiting this function.
Definition at line 30 of file gurobi_isv.cc.
absl::StatusOr< GRBenvUniquePtr > operations_research::math_opt::NewPrimaryEnvironment | ( | std::optional< GurobiInitializerProto::ISVKey > | proto_isv_key = {} | ) |
Returns a new primary environment.
The typical use of this function is to share the same environment between multiple solver instances. This is necessary when a single-use license is used since only one primary environment can exists in that case.
A single primary environment is not thread-safe and thus it should only be used in a single thread. Even if the user has a license that authorizes multiple primary environments, Gurobi still recommends to use only one and to share it as it is more efficient (see GRBloadenv() documentation).
Of course, if the user wants to run multiple solves in parallel and has a license that authorizes that, one environment should be used per thread.
The primary environment can be passed to MathOpt via the NonStreamableGurobiInitArguments structure and its primary_env field.
The optional ISV key can be used to build the environment from an ISV key instead of using the default license file. See http://www.gurobi.com/products/licensing-pricing/isv-program for details.
Example with default license file:
///< Solving two models on the same thread, sharing the same primary ///< environment. Model model_1; Model model_2;
...
ASSIGN_OR_RETURN(const GRBenvUniquePtr primary_env, NewPrimaryEnvironment());
NonStreamableGurobiInitArguments gurobi_args; gurobi_args.primary_env = primary_env.get();
ASSIGN_OR_RETURN( const std::unique_ptr<IncrementalSolver> incremental_solve_1, NewIncrementalSolver(model, SOLVER_TYPE_GUROBI, SolverInitArguments(gurobi_args))); ASSIGN_OR_RETURN( const std::unique_ptr<IncrementalSolver> incremental_solve_2, NewIncrementalSolver(model, SOLVER_TYPE_GUROBI, SolverInitArguments(gurobi_args)));
ASSIGN_OR_RETURN(const SolveResult result_1, incremental_solve_1->Solve()); ASSIGN_OR_RETURN(const SolveResult result_2, incremental_solve_2->Solve());
With ISV key:
ASSIGN_OR_RETURN(const GRBenvUniquePtr primary_env, NewPrimaryEnvironment(GurobiISVKey{ .name = "the name", .application_name = "the application", .expiration = 0, .key = "...", }.Proto()));
Definition at line 27 of file gurobi_init_arguments.cc.
TerminationProto operations_research::math_opt::NoSolutionFoundTermination | ( | const LimitProto | limit, |
const absl::string_view | detail ) |
Definition at line 173 of file math_opt_proto_utils.cc.
TerminationProto operations_research::math_opt::NoSolutionFoundTerminationProto | ( | bool | is_maximize, |
LimitProto | limit, | ||
std::optional< double > | optional_dual_objective = std::nullopt, | ||
absl::string_view | detail = {} ) |
Returns a TERMINATION_REASON_NO_SOLUTION_FOUND termination with FEASIBILITY_STATUS_UNDETERMINED primal status.
Assumes dual solution exists iff optional_dual_objective is set even if infinite (some solvers return feasible dual solutions without an objective value). optional_dual_objective should not be set when limit is LIMIT_CUTOFF for a valid TerminationProto to be returned (use LimitCutoffTerminationProto() below instead).
It sets a trivial primal bound. The dual bound is either set to the optional_dual_objective if set, else to a trivial value.
Definition at line 321 of file math_opt_proto_utils.cc.
|
inline |
Definition at line 53 of file math_opt_proto_utils.h.
|
inline |
Definition at line 57 of file math_opt_proto_utils.h.
|
inline |
Definition at line 49 of file math_opt_proto_utils.h.
testing::Matcher< ObjectiveBounds > operations_research::math_opt::ObjectiveBoundsNear | ( | const ObjectiveBounds & | expected, |
const double | tolerance ) |
SolveResult termination reason matchers
Definition at line 607 of file matchers.cc.
bool operations_research::math_opt::operator!= | ( | const IndicatorConstraint & | lhs, |
const IndicatorConstraint & | rhs ) |
Definition at line 129 of file indicator_constraint.h.
bool operations_research::math_opt::operator!= | ( | const LinearConstraint & | lhs, |
const LinearConstraint & | rhs ) |
Definition at line 167 of file linear_constraint.h.
Definition at line 208 of file objective.h.
bool operations_research::math_opt::operator!= | ( | const QuadraticConstraint & | lhs, |
const QuadraticConstraint & | rhs ) |
Definition at line 183 of file quadratic_constraint.h.
bool operations_research::math_opt::operator!= | ( | const SecondOrderConeConstraint & | lhs, |
const SecondOrderConeConstraint & | rhs ) |
Definition at line 119 of file second_order_cone_constraint.h.
bool operations_research::math_opt::operator!= | ( | const Sos1Constraint & | lhs, |
const Sos1Constraint & | rhs ) |
Definition at line 120 of file sos1_constraint.h.
bool operations_research::math_opt::operator!= | ( | const Sos2Constraint & | lhs, |
const Sos2Constraint & | rhs ) |
Definition at line 121 of file sos2_constraint.h.
|
inline |
Definition at line 1750 of file variable_and_expressions.h.
|
inline |
Definition at line 2112 of file variable_and_expressions.h.
|
inline |
-------------------------— Multiplication (*) --------------------------—
Definition at line 2474 of file variable_and_expressions.h.
|
inline |
Definition at line 2547 of file variable_and_expressions.h.
|
inline |
Definition at line 2536 of file variable_and_expressions.h.
|
inline |
Definition at line 2525 of file variable_and_expressions.h.
|
inline |
Definition at line 1348 of file variable_and_expressions.h.
|
inline |
Definition at line 1358 of file variable_and_expressions.h.
|
inline |
Definition at line 1577 of file variable_and_expressions.h.
|
inline |
Definition at line 2479 of file variable_and_expressions.h.
|
inline |
Definition at line 1572 of file variable_and_expressions.h.
|
inline |
Definition at line 2514 of file variable_and_expressions.h.
|
inline |
Definition at line 2509 of file variable_and_expressions.h.
|
inline |
Definition at line 2504 of file variable_and_expressions.h.
|
inline |
Definition at line 1353 of file variable_and_expressions.h.
|
inline |
Definition at line 2574 of file variable_and_expressions.h.
|
inline |
Definition at line 2569 of file variable_and_expressions.h.
|
inline |
Definition at line 2493 of file variable_and_expressions.h.
|
inline |
Definition at line 2488 of file variable_and_expressions.h.
|
inline |
Definition at line 2484 of file variable_and_expressions.h.
|
inline |
Definition at line 1362 of file variable_and_expressions.h.
|
inline |
--------------------------— Addition (+) -------------------------------—
The binary methods, listed in lexicographic order based on (operator, lhs type #, rhs type #), with the type #s are listed above, are:
Arithmetic operators (non-member).
These are NOT required to explicitly CHECK that the underlying model storages agree between linear_terms_ and quadratic_terms_ unless they are a friend of QuadraticExpression. As much as possible, defer to the assignment operators and the initializer list constructor for QuadraticExpression.
Definition at line 2243 of file variable_and_expressions.h.
|
inline |
Definition at line 2276 of file variable_and_expressions.h.
|
inline |
Definition at line 1468 of file variable_and_expressions.h.
|
inline |
Definition at line 2261 of file variable_and_expressions.h.
|
inline |
Definition at line 1452 of file variable_and_expressions.h.
|
inline |
Definition at line 2265 of file variable_and_expressions.h.
|
inline |
Definition at line 1460 of file variable_and_expressions.h.
|
inline |
Definition at line 2290 of file variable_and_expressions.h.
|
inline |
Definition at line 2300 of file variable_and_expressions.h.
|
inline |
Definition at line 2282 of file variable_and_expressions.h.
|
inline |
Definition at line 2294 of file variable_and_expressions.h.
|
inline |
Definition at line 2305 of file variable_and_expressions.h.
|
inline |
Definition at line 2286 of file variable_and_expressions.h.
|
inline |
Definition at line 1456 of file variable_and_expressions.h.
|
inline |
Definition at line 1477 of file variable_and_expressions.h.
|
inline |
Definition at line 2247 of file variable_and_expressions.h.
|
inline |
Definition at line 1444 of file variable_and_expressions.h.
|
inline |
Definition at line 1500 of file variable_and_expressions.h.
|
inline |
Definition at line 1490 of file variable_and_expressions.h.
|
inline |
Definition at line 2270 of file variable_and_expressions.h.
|
inline |
Definition at line 1472 of file variable_and_expressions.h.
|
inline |
Definition at line 1482 of file variable_and_expressions.h.
|
inline |
Definition at line 1495 of file variable_and_expressions.h.
|
inline |
Definition at line 2326 of file variable_and_expressions.h.
|
inline |
Definition at line 2321 of file variable_and_expressions.h.
|
inline |
Definition at line 2338 of file variable_and_expressions.h.
|
inline |
Definition at line 2332 of file variable_and_expressions.h.
|
inline |
Definition at line 2311 of file variable_and_expressions.h.
|
inline |
Definition at line 2316 of file variable_and_expressions.h.
|
inline |
Definition at line 1464 of file variable_and_expressions.h.
|
inline |
Definition at line 2252 of file variable_and_expressions.h.
|
inline |
Definition at line 1440 of file variable_and_expressions.h.
|
inline |
Definition at line 1486 of file variable_and_expressions.h.
|
inline |
Definition at line 2256 of file variable_and_expressions.h.
|
inline |
Definition at line 1448 of file variable_and_expressions.h.
|
inline |
Definition at line 2398 of file variable_and_expressions.h.
|
inline |
Definition at line 1533 of file variable_and_expressions.h.
|
inline |
Definition at line 2382 of file variable_and_expressions.h.
|
inline |
Definition at line 1517 of file variable_and_expressions.h.
|
inline |
Definition at line 2386 of file variable_and_expressions.h.
|
inline |
Definition at line 1525 of file variable_and_expressions.h.
|
inline |
Definition at line 2413 of file variable_and_expressions.h.
|
inline |
Definition at line 2423 of file variable_and_expressions.h.
|
inline |
Definition at line 2405 of file variable_and_expressions.h.
|
inline |
Definition at line 2417 of file variable_and_expressions.h.
|
inline |
Definition at line 2428 of file variable_and_expressions.h.
|
inline |
Definition at line 2409 of file variable_and_expressions.h.
|
inline |
Definition at line 1521 of file variable_and_expressions.h.
|
inline |
Definition at line 2364 of file variable_and_expressions.h.
|
inline |
Definition at line 1542 of file variable_and_expressions.h.
|
inline |
Definition at line 2368 of file variable_and_expressions.h.
|
inline |
Definition at line 1509 of file variable_and_expressions.h.
|
inline |
We intentionally pass one of the LinearExpression argument by value so that we don't make unnecessary copies of temporary objects by using the move constructor and the returned values optimization (RVO).
Definition at line 1432 of file variable_and_expressions.h.
|
inline |
Definition at line 1567 of file variable_and_expressions.h.
|
inline |
Definition at line 1556 of file variable_and_expressions.h.
|
inline |
Definition at line 2392 of file variable_and_expressions.h.
|
inline |
Definition at line 1537 of file variable_and_expressions.h.
|
inline |
Definition at line 1548 of file variable_and_expressions.h.
|
inline |
Definition at line 1561 of file variable_and_expressions.h.
|
inline |
We have 6 types that we must consider arithmetic among:
Definition at line 2353 of file variable_and_expressions.h.
|
inline |
Definition at line 2453 of file variable_and_expressions.h.
|
inline |
Definition at line 2441 of file variable_and_expressions.h.
|
inline |
Definition at line 2465 of file variable_and_expressions.h.
|
inline |
Definition at line 2459 of file variable_and_expressions.h.
|
inline |
Definition at line 2435 of file variable_and_expressions.h.
|
inline |
Definition at line 2446 of file variable_and_expressions.h.
|
inline |
------------------------— Subtraction (-) ------------------------------—
We declare those operator overloads that result in a QuadraticTerm, stated in lexicographic ordering based on lhs type, rhs type):
Definition at line 2347 of file variable_and_expressions.h.
|
inline |
Definition at line 1529 of file variable_and_expressions.h.
|
inline |
Definition at line 2374 of file variable_and_expressions.h.
|
inline |
Definition at line 1505 of file variable_and_expressions.h.
|
inline |
Definition at line 1552 of file variable_and_expressions.h.
|
inline |
Definition at line 2378 of file variable_and_expressions.h.
|
inline |
Definition at line 1513 of file variable_and_expressions.h.
|
inline |
Definition at line 1582 of file variable_and_expressions.h.
|
inline |
Definition at line 1366 of file variable_and_expressions.h.
|
inline |
Definition at line 2587 of file variable_and_expressions.h.
|
inline |
----------------------------— Division (/) -----------------------------—
Definition at line 2582 of file variable_and_expressions.h.
|
inline |
Definition at line 1371 of file variable_and_expressions.h.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | ostr, |
const BoundedLinearExpression & | bounded_expression ) |
Definition at line 101 of file variable_and_expressions.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | ostr, |
const BoundedQuadraticExpression & | bounded_expression ) |
Definition at line 185 of file variable_and_expressions.cc.
|
inline |
Streams the name of the constraint, as registered upon constraint creation, or a short default if none was provided.
Definition at line 139 of file indicator_constraint.h.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | ostr, |
const InfeasibleSubsystemSupport & | support_menu ) |
Definition at line 43 of file infeasible_subsystem_tests.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | ostr, |
const InfeasibleSubsystemTestParameters & | params ) |
Definition at line 51 of file infeasible_subsystem_tests.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | ostr, |
const IpParameterTestParameters & | params ) |
Definition at line 165 of file ip_parameter_tests.cc.
|
inline |
Streams the name of the constraint, as registered upon constraint creation, or a short default if none was provided.
Definition at line 177 of file linear_constraint.h.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | ostr, |
const LinearExpression & | expression ) |
Definition at line 81 of file variable_and_expressions.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | ostr, |
const Model & | model ) |
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | ostr, |
const Objective & | objective ) |
Streams the name of the objective, as registered upon objective creation, or a short default if none was provided.
Definition at line 61 of file objective.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | ostr, |
const ObjectiveBounds & | objective_bounds ) |
Definition at line 66 of file solve_result.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | ostr, |
const ParameterSupport & | param_support ) |
Definition at line 110 of file ip_parameter_tests.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | ostr, |
const ProblemStatus & | problem_status ) |
Definition at line 433 of file solve_result.cc.
|
inline |
Streams the name of the constraint, as registered upon constraint creation, or a short default if none was provided.
Definition at line 194 of file quadratic_constraint.h.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | ostr, |
const QuadraticExpression & | expr ) |
Definition at line 155 of file variable_and_expressions.cc.
|
inline |
Definition at line 2102 of file variable_and_expressions.h.
|
inline |
Streams the name of the constraint, as registered upon constraint creation, or a short default if none was provided.
Definition at line 129 of file second_order_cone_constraint.h.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | ostr, |
const SolveResultSupport & | solve_result_support ) |
Definition at line 94 of file ip_parameter_tests.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | ostr, |
const SolveStats & | solve_stats ) |
Definition at line 475 of file solve_result.cc.
|
inline |
Streams the name of the constraint, as registered upon constraint creation, or a short default if none was provided.
Definition at line 129 of file sos1_constraint.h.
|
inline |
Streams the name of the constraint, as registered upon constraint creation, or a short default if none was provided.
Definition at line 130 of file sos2_constraint.h.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | ostr, |
const Termination & | termination ) |
Definition at line 387 of file solve_result.cc.
|
inline |
Definition at line 1310 of file variable_and_expressions.h.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const BaseSolver::ComputeInfeasibleSubsystemArgs & | args ) |
Definition at line 43 of file base_solver.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const BaseSolver::SolveArgs & | args ) |
Definition at line 32 of file base_solver.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const BranchPrioritiesTestParams & | params ) |
Definition at line 54 of file ip_model_solve_parameters_tests.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const CallbackTestParams & | params ) |
Definition at line 108 of file callback_tests.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const ComputeInfeasibleSubsystemResult & | result ) |
Definition at line 388 of file compute_infeasible_subsystem_result.cc.
|
inline |
Do nothing.
Definition at line 72 of file formatters.h.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const E | value ) |
Overload of operator<< for enum types that implements Enum<E>.
It calls EnumToOptString(), printing the returned value if not nullopt. When nullopt it prints the enum numeric value instead.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const FileFormat | f ) |
Definition at line 74 of file file_format_flags.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const GenericTestParameters & | params ) |
Definition at line 66 of file generic_tests.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const InvalidInputTestParameters & | params ) |
Definition at line 40 of file invalid_input_tests.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const InvalidParameterTestParams & | params ) |
Definition at line 59 of file invalid_input_tests.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const IpMultipleSolutionsTestParams & | params ) |
Definition at line 29 of file ip_multiple_solutions_tests.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const LargeInstanceTestParams & | params ) |
Definition at line 178 of file ip_parameter_tests.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const LazyConstraintsTestParams & | params ) |
Definition at line 61 of file ip_model_solve_parameters_tests.cc.
|
inline |
Do nothing.
Definition at line 37 of file formatters.h.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const LogicalConstraintTestParameters & | params ) |
Definition at line 54 of file logical_constraint_tests.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const LpIncompleteSolveTestParams & | params ) |
Definition at line 56 of file lp_incomplete_solve_tests.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const LpModelSolveParametersTestParameters & | params ) |
Definition at line 31 of file lp_model_solve_parameters_tests.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const LpParameterTestParams & | params ) |
Definition at line 53 of file lp_parameter_tests.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const MessageCallbackTestParams & | params ) |
Definition at line 62 of file callback_tests.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const ModelRanges & | ranges ) |
Prints the ranges with std::setprecision(2) and std::scientific (restoring the stream flags after printing).
It prints a multi-line table list of ranges. The last line does NOT end with a new line thus the caller should use std::endl if appropriate (see example).
Example:
std::cout << "Model xxx ranges:\n" << ComputeModelRanges(model) << std::endl;
LOG(INFO) << "Model xxx ranges:\n" << ComputeModelRanges(model);
Numbers are printed in scientific notation with a precision of 2. Since they are expected to be positive we can ignore the optional leading minus sign. We thus expects d.dde[+-]dd(d)?
(the exponent is at least 2 digits but double can require 3 digits, with max +308 and min -308). Thus we can use a width of 9 to align the ranges properly.
Definition at line 70 of file statistics.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const ModelSubset & | model_subset ) |
Definition at line 306 of file compute_infeasible_subsystem_result.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const ModelSubset::Bounds & | bounds ) |
Definition at line 66 of file compute_infeasible_subsystem_result.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const MultiObjectiveTestParameters & | params ) |
Definition at line 59 of file multi_objective_tests.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const QcTestParameters & | params ) |
Definition at line 45 of file qc_tests.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const QpTestParameters & | params ) |
Definition at line 77 of file qp_tests.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const SecondOrderConeTestParameters & | params ) |
Definition at line 41 of file second_order_cone_tests.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const SimpleLpTestParameters & | params ) |
Definition at line 51 of file lp_tests.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const SimpleMipTestParameters & | params ) |
Definition at line 45 of file mip_tests.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const SolutionHintTestParams & | params ) |
Definition at line 45 of file ip_model_solve_parameters_tests.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const SolveResult & | result ) |
Prints a summary of the solve result on a single line.
This prints the number of available solutions and rays instead of their values.
Printing the whole solution could be problematic for huge models.
Definition at line 690 of file solve_result.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const StatusTestParameters & | params ) |
Definition at line 43 of file status_tests.cc.
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const std::optional< E > | opt_value ) |
std::ostream & operations_research::math_opt::operator<< | ( | std::ostream & | out, |
const TimeLimitTestParameters & | params ) |
Definition at line 47 of file generic_tests.cc.
|
inline |
Definition at line 3085 of file variable_and_expressions.h.
|
inline |
Definition at line 1955 of file variable_and_expressions.h.
|
inline |
Definition at line 1923 of file variable_and_expressions.h.
|
inline |
Definition at line 1970 of file variable_and_expressions.h.
|
inline |
Definition at line 1843 of file variable_and_expressions.h.
|
inline |
Definition at line 1818 of file variable_and_expressions.h.
|
inline |
Definition at line 1808 of file variable_and_expressions.h.
|
inline |
Definition at line 1828 of file variable_and_expressions.h.
|
inline |
Definition at line 2858 of file variable_and_expressions.h.
|
inline |
Definition at line 2862 of file variable_and_expressions.h.
|
inline |
Definition at line 1884 of file variable_and_expressions.h.
|
inline |
Definition at line 2899 of file variable_and_expressions.h.
|
inline |
Definition at line 1833 of file variable_and_expressions.h.
|
inline |
We intentionally pass one LinearExpression argument by value so that we don't make unnecessary copies of temporary objects by using the move constructor and the returned values optimization (RVO).
Definition at line 1891 of file variable_and_expressions.h.
|
inline |
Definition at line 1907 of file variable_and_expressions.h.
|
inline |
Definition at line 3091 of file variable_and_expressions.h.
|
inline |
Definition at line 1939 of file variable_and_expressions.h.
|
inline |
Definition at line 3117 of file variable_and_expressions.h.
|
inline |
Definition at line 3123 of file variable_and_expressions.h.
|
inline |
We intentionally pass the UpperBoundedLinearExpression and LowerBoundedLinearExpression arguments by value so that we don't make unnecessary copies of temporary objects by using the move constructor and the returned values optimization (RVO).
Definition at line 1863 of file variable_and_expressions.h.
|
inline |
Definition at line 2894 of file variable_and_expressions.h.
|
inline |
Definition at line 2947 of file variable_and_expressions.h.
|
inline |
Definition at line 2935 of file variable_and_expressions.h.
|
inline |
Definition at line 2875 of file variable_and_expressions.h.
|
inline |
Definition at line 2953 of file variable_and_expressions.h.
|
inline |
Definition at line 2941 of file variable_and_expressions.h.
|
inline |
Definition at line 2959 of file variable_and_expressions.h.
|
inline |
Definition at line 2879 of file variable_and_expressions.h.
|
inline |
Definition at line 3033 of file variable_and_expressions.h.
|
inline |
Definition at line 3038 of file variable_and_expressions.h.
|
inline |
Definition at line 3022 of file variable_and_expressions.h.
|
inline |
Definition at line 3028 of file variable_and_expressions.h.
|
inline |
Definition at line 3043 of file variable_and_expressions.h.
|
inline |
Definition at line 1978 of file variable_and_expressions.h.
|
inline |
Definition at line 1947 of file variable_and_expressions.h.
|
inline |
Definition at line 3149 of file variable_and_expressions.h.
|
inline |
Definition at line 3155 of file variable_and_expressions.h.
|
inline |
Definition at line 1986 of file variable_and_expressions.h.
|
inline |
Definition at line 1853 of file variable_and_expressions.h.
|
inline |
Double –.
Definition at line 3171 of file variable_and_expressions.h.
bool operations_research::math_opt::operator== | ( | const IndicatorConstraint & | lhs, |
const IndicatorConstraint & | rhs ) |
Definition at line 124 of file indicator_constraint.h.
bool operations_research::math_opt::operator== | ( | const LinearConstraint & | lhs, |
const LinearConstraint & | rhs ) |
Definition at line 163 of file linear_constraint.h.
|
inline |
Definition at line 3096 of file variable_and_expressions.h.
|
inline |
Definition at line 2035 of file variable_and_expressions.h.
|
inline |
Definition at line 2050 of file variable_and_expressions.h.
|
inline |
Definition at line 2008 of file variable_and_expressions.h.
|
inline |
Definition at line 2042 of file variable_and_expressions.h.
Definition at line 204 of file objective.h.
bool operations_research::math_opt::operator== | ( | const QuadraticConstraint & | lhs, |
const QuadraticConstraint & | rhs ) |
Definition at line 178 of file quadratic_constraint.h.
bool operations_research::math_opt::operator== | ( | const SecondOrderConeConstraint & | lhs, |
const SecondOrderConeConstraint & | rhs ) |
Definition at line 114 of file second_order_cone_constraint.h.
bool operations_research::math_opt::operator== | ( | const Sos1Constraint & | lhs, |
const Sos1Constraint & | rhs ) |
Definition at line 116 of file sos1_constraint.h.
bool operations_research::math_opt::operator== | ( | const Sos2Constraint & | lhs, |
const Sos2Constraint & | rhs ) |
Definition at line 117 of file sos2_constraint.h.
|
inline |
Definition at line 1745 of file variable_and_expressions.h.
|
inline |
Definition at line 2055 of file variable_and_expressions.h.
|
inline |
Definition at line 2029 of file variable_and_expressions.h.
|
inline |
Comparisons with lhs = Double.
Definition at line 3176 of file variable_and_expressions.h.
|
inline |
Definition at line 2064 of file variable_and_expressions.h.
|
inline |
Definition at line 1994 of file variable_and_expressions.h.
|
inline |
Definition at line 2001 of file variable_and_expressions.h.
|
inline |
Definition at line 2023 of file variable_and_expressions.h.
|
inline |
Definition at line 3101 of file variable_and_expressions.h.
|
inline |
Definition at line 2015 of file variable_and_expressions.h.
|
inline |
Definition at line 3128 of file variable_and_expressions.h.
|
inline |
Definition at line 3133 of file variable_and_expressions.h.
|
inline |
Definition at line 2975 of file variable_and_expressions.h.
|
inline |
Definition at line 2965 of file variable_and_expressions.h.
|
inline |
Definition at line 2990 of file variable_and_expressions.h.
|
inline |
Definition at line 2980 of file variable_and_expressions.h.
|
inline |
Definition at line 2970 of file variable_and_expressions.h.
|
inline |
Definition at line 2985 of file variable_and_expressions.h.
|
inline |
Definition at line 3069 of file variable_and_expressions.h.
|
inline |
Definition at line 3057 of file variable_and_expressions.h.
|
inline |
Definition at line 3061 of file variable_and_expressions.h.
|
inline |
Definition at line 3048 of file variable_and_expressions.h.
|
inline |
Definition at line 3053 of file variable_and_expressions.h.
|
inline |
Definition at line 3065 of file variable_and_expressions.h.
|
inline |
Definition at line 2108 of file variable_and_expressions.h.
|
inline |
Definition at line 2046 of file variable_and_expressions.h.
|
inline |
Definition at line 2060 of file variable_and_expressions.h.
|
inline |
Definition at line 2019 of file variable_and_expressions.h.
|
inline |
Definition at line 3160 of file variable_and_expressions.h.
|
inline |
Definition at line 3165 of file variable_and_expressions.h.
|
inline |
Comparisons with lhs = LinearExpression.
Definition at line 3074 of file variable_and_expressions.h.
|
inline |
Definition at line 1963 of file variable_and_expressions.h.
|
inline |
Definition at line 1931 of file variable_and_expressions.h.
|
inline |
Definition at line 1974 of file variable_and_expressions.h.
|
inline |
Definition at line 1813 of file variable_and_expressions.h.
|
inline |
Definition at line 1848 of file variable_and_expressions.h.
|
inline |
Definition at line 1838 of file variable_and_expressions.h.
|
inline |
Definition at line 1858 of file variable_and_expressions.h.
|
inline |
Definition at line 1870 of file variable_and_expressions.h.
|
inline |
Definition at line 2889 of file variable_and_expressions.h.
|
inline |
Definition at line 2867 of file variable_and_expressions.h.
|
inline |
Definition at line 2871 of file variable_and_expressions.h.
|
inline |
We intentionally pass the LinearExpression argument by value so that we don't make unnecessary copies of temporary objects by using the move constructor and the returned values optimization (RVO).
Definition at line 1803 of file variable_and_expressions.h.
|
inline |
Definition at line 1899 of file variable_and_expressions.h.
|
inline |
Definition at line 1915 of file variable_and_expressions.h.
|
inline |
Definition at line 3080 of file variable_and_expressions.h.
|
inline |
Definition at line 1943 of file variable_and_expressions.h.
|
inline |
Comparisons with lhs = LinearTerm.
LinearTerm –.
Definition at line 3106 of file variable_and_expressions.h.
|
inline |
Definition at line 3112 of file variable_and_expressions.h.
|
inline |
Definition at line 2917 of file variable_and_expressions.h.
|
inline |
Comparisons with lhs = QuadraticExpression.
We intentionally pass one QuadraticExpression argument by value so that we don't make unnecessary copies of temporary objects by using the move constructor and the returned values optimization (RVO).
Definition at line 2905 of file variable_and_expressions.h.
|
inline |
We intentionally pass the QuadraticExpression argument by value so that we don't make unnecessary copies of temporary objects by using the move constructor and the returned values optimization (RVO).
Definition at line 2850 of file variable_and_expressions.h.
|
inline |
Definition at line 2923 of file variable_and_expressions.h.
|
inline |
Definition at line 2911 of file variable_and_expressions.h.
|
inline |
Definition at line 2929 of file variable_and_expressions.h.
|
inline |
Definition at line 2854 of file variable_and_expressions.h.
|
inline |
Definition at line 3007 of file variable_and_expressions.h.
|
inline |
Definition at line 3012 of file variable_and_expressions.h.
|
inline |
Comparisons with lhs = QuadraticTerm.
Definition at line 2996 of file variable_and_expressions.h.
|
inline |
Definition at line 3002 of file variable_and_expressions.h.
|
inline |
Definition at line 3017 of file variable_and_expressions.h.
|
inline |
Definition at line 1877 of file variable_and_expressions.h.
|
inline |
We intentionally pass the UpperBoundedQuadraticExpression and LowerBoundedQuadraticExpression arguments by value so that we don't make unnecessary copies of temporary objects by using the move constructor and the returned values optimization (RVO).
Definition at line 2884 of file variable_and_expressions.h.
|
inline |
Definition at line 1982 of file variable_and_expressions.h.
|
inline |
Definition at line 1951 of file variable_and_expressions.h.
|
inline |
Comparisons with lhs = Variable.
Variable –.
Definition at line 3138 of file variable_and_expressions.h.
|
inline |
Definition at line 3144 of file variable_and_expressions.h.
|
inline |
Definition at line 1990 of file variable_and_expressions.h.
|
inline |
Definition at line 1823 of file variable_and_expressions.h.
TerminationProto operations_research::math_opt::OptimalTerminationProto | ( | double | finite_primal_objective, |
double | dual_objective, | ||
absl::string_view | detail = {} ) |
Returns a TERMINATION_REASON_OPTIMAL termination with the provided objective bounds and FEASIBILITY_STATUS_FEASIBLE primal and dual statuses.
finite_primal_objective must be finite for a valid TerminationProto to be returned.
Definition at line 220 of file math_opt_proto_utils.cc.
std::string operations_research::math_opt::OptionalFormatFlagPossibleValuesList | ( | ) |
Get the lines for each format and the introduction doc.
Add the doc of what happen when format is not specified.
Builds a map from formats to their extensions.
Here we iterate on all formats so that we list them in the same order as in the enum.
Here we use operator[] as it is not an issue to create new empty entries in the map.
Definition at line 143 of file file_format_flags.cc.
testing::Matcher< PrimalRay > operations_research::math_opt::PrimalRayIsNear | ( | VariableMap< double > | expected_var_values, |
double | tolerance = kMatcherDefaultTolerance ) |
Checks variables match and that after rescaling, variable values are within tolerance.
Definition at line 538 of file matchers.cc.
MessageCallback operations_research::math_opt::PrinterMessageCallback | ( | std::ostream & | output_stream = std::cout, |
absl::string_view | prefix = "" ) |
Returns a message callback function that prints its output to the given output stream, prefixing each line with the given prefix.
For each call to the returned message callback, the output_stream is flushed.
Usage:
SolveArguments args; args.message_callback = PrinterMessageCallback(std::cerr, "solver logs> ");
Here we must use an std::shared_ptr since std::function requires that its input is copyable. And PrinterMessageCallbackImpl can't be copyable since it uses an absl::Mutex that is not.
Definition at line 82 of file message_callback.cc.
void operations_research::math_opt::PrintTo | ( | const absl::flat_hash_map< K, V > & | id_map, |
std::ostream *const | os ) |
We do not want to rely on ::testing::internal::ContainerPrinter because we want to sort the keys.
Definition at line 553 of file matchers.h.
void operations_research::math_opt::PrintTo | ( | const Basis & | basis, |
std::ostream *const | os ) |
Definition at line 114 of file matchers.cc.
void operations_research::math_opt::PrintTo | ( | const DualRay & | dual_ray, |
std::ostream *const | os ) |
Definition at line 109 of file matchers.cc.
void operations_research::math_opt::PrintTo | ( | const DualSolution & | dual_solution, |
std::ostream *const | os ) |
Definition at line 95 of file matchers.cc.
void operations_research::math_opt::PrintTo | ( | const PrimalRay & | primal_ray, |
std::ostream *const | os ) |
Definition at line 105 of file matchers.cc.
void operations_research::math_opt::PrintTo | ( | const PrimalSolution & | primal_solution, |
std::ostream * | os ) |
Implementation details
Definition at line 88 of file matchers.cc.
void operations_research::math_opt::PrintTo | ( | const Solution & | solution, |
std::ostream *const | os ) |
Definition at line 121 of file matchers.cc.
void operations_research::math_opt::PrintTo | ( | const SolveResult & | result, |
std::ostream *const | os ) |
Definition at line 127 of file matchers.cc.
testing::Matcher< ProblemStatus > operations_research::math_opt::ProblemStatusIs | ( | const ProblemStatus & | expected | ) |
Definition at line 726 of file matchers.cc.
absl::StatusOr< MapFilter< QuadraticConstraint > > operations_research::math_opt::QuadraticConstraintFilterFromProto | ( | const Model & | model, |
const SparseVectorFilterProto & | proto ) |
Returns the MapFilter<QuadraticConstraint> equivalent to proto
.
Requires that (or returns a status error):
model
. Definition at line 67 of file map_filter.cc.
absl::StatusOr< absl::flat_hash_map< QuadraticConstraint, double > > operations_research::math_opt::QuadraticConstraintValuesFromProto | ( | const ModelStorage * | model, |
const SparseDoubleVectorProto & | quad_cons_proto ) |
Returns the absl::flat_hash_map<QuadraticConstraint, double> equivalent to quad_cons_proto
.
Requires that (or returns a status error):
model
(this implies that each id is in [0, max(int64_t))).Definition at line 203 of file sparse_containers.cc.
SparseDoubleVectorProto operations_research::math_opt::QuadraticConstraintValuesToProto | ( | const absl::flat_hash_map< QuadraticConstraint, double > & | quadratic_constraint_values | ) |
Returns the proto equivalent of quadratic_constraint_values.
Definition at line 211 of file sparse_containers.cc.
absl::StatusOr< std::pair< ModelProto, std::optional< SolutionHintProto > > > operations_research::math_opt::ReadModel | ( | const absl::string_view | file_path, |
const FileFormat | format ) |
Definition at line 198 of file file_format_flags.cc.
absl::StatusOr< ModelProto > operations_research::math_opt::ReadMpsFile | ( | absl::string_view | filename | ) |
Reads an MPS file and converts it to a ModelProto (like MpsToModelProto above, but takes a file name instead of the file contents and reads the file.
The file can be stored as plain text or gzipped (with the .gz extension).
Definition at line 36 of file mps_converter.cc.
testing::Matcher< Termination > operations_research::math_opt::ReasonIs | ( | TerminationReason | reason | ) |
Matchers for a Termination
Definition at line 718 of file matchers.cc.
testing::Matcher< Termination > operations_research::math_opt::ReasonIsOptimal | ( | ) |
Checks that the termination reason is optimal, but does not check the other fields of Termination are consistent with optimality.
Definition at line 722 of file matchers.cc.
void operations_research::math_opt::RemoveNames | ( | ModelProto & | model | ) |
Removes the model, variables and constraints names of the provided model.
Definition at line 32 of file names_removal.cc.
void operations_research::math_opt::RemoveNames | ( | ModelUpdateProto & | update | ) |
Removes the variables and constraints names of the provided update.
Definition at line 44 of file names_removal.cc.
void operations_research::math_opt::RemoveSparseDoubleVectorZeros | ( | SparseDoubleVectorProto & | sparse_vector | ) |
Removes the items in the sparse double vector for all indices whose value is exactly 0.0.
NaN values are kept in place.
The function asserts that input is a valid sparse vector, i.e. that the number of values and ids match.
Keep track of the next index that has not yet been used for a non zero value.
Se use !(== 0.0)
here so that we keep NaN values for which both v == / 0
and v != 0
returns false.
At the end of the iteration, next
contains the index of the first unused index. This means it contains the number of used elements.
Definition at line 70 of file math_opt_proto_utils.cc.
MessageCallback operations_research::math_opt::RepeatedPtrFieldMessageCallback | ( | google::protobuf::RepeatedPtrField< std::string > * | sink | ) |
Returns a message callback function that aggregates all messages in the provided RepeatedPtrField.
Usage:
google::protobuf::RepeatedPtrField<std::string> msgs; SolveArguments args; args.message_callback = RepeatedPtrFieldMessageCallback(&msgs);
Here we must use an std::shared_ptr since std::function requires that its input is copyable. And VectorMessageCallbackImpl can't be copyable since it uses an absl::Mutex that is not.
Definition at line 123 of file message_callback.cc.
SolveResultProto operations_research::math_opt::ResultForIntegerInfeasible | ( | bool | is_maximize, |
int64_t | bad_variable_id, | ||
double | lb, | ||
double | ub ) |
Returns an "infeasible" result for models where the infeasibility is caused by an integer variable whose bounds are nonempty but contain no integers.
Callers should make sure to set the SolveResultProto.solve_stats.solve_time field before returning the result.
Definition at line 26 of file empty_bounds.cc.
|
inline |
Returns the lower bound of the variable, rounding it up when the variable is integral and the bound's fractional value is outside the tolerance.
For example if the lower bound of an integer variable is 1.0000000000000002 and the tolerance is 0.0 this function will return 2.0. If the tolerance is 1e-6 though this function will return 1.0.
Tolerance should be a non-negative value < kMaxIntegralityTolerance (usually much smaller). A negative input value (or NaN) will be considered 0.0, a value >= kMaxIntegralityTolerance will be considered kMaxIntegralityTolerance (using a tolerance like 0.5 would lead to odd behavior for ties as integral bounds could be rounded to the next integer. For example with the integer 2^53 - 1, 2^53 - 1 + 0.5 = 2^53)
We use std::fmax() to treat NaN as 0.0.
Definition at line 101 of file solution_improvement.h.
|
inline |
Same as RoundedLowerBound() but for upper-bound.
See comment in RoundedLowerBound().
Definition at line 109 of file solution_improvement.h.
std::unique_ptr< Model > operations_research::math_opt::SmallModel | ( | const bool | integer | ) |
Definition at line 25 of file test_models.cc.
Matcher< SolutionStatus > operations_research::math_opt::SolutionStatusIs | ( | const SolutionStatus | expected, |
const bool | allow_undetermined ) |
Matchers for Solutions
Definition at line 415 of file matchers.cc.
absl::StatusOr< SolveResult > operations_research::math_opt::Solve | ( | const Model & | model, |
SolverType | solver_type, | ||
const SolveArguments & | solve_args = {}, | ||
const SolverInitArguments & | init_args = {} ) |
Solves the input model.
A Status error will be returned if the inputs are invalid or there is an unexpected failure in an underlying solver or for some internal math_opt errors. Otherwise, check SolveResult::termination.reason to see if an optimal solution was found.
Memory model: the returned SolveResult owns its own memory (for solutions, solve stats, etc.), EXCEPT for a pointer back to the model. As a result:
Thread-safety: this method is safe to call concurrently on the same Model.
Some solvers may add more restrictions regarding threading. Please see SolverType::kXxx documentation for details.
<=x<=1 IncrementalMipTest::IncrementalMipTest() :model_("incremental_solve_test"), x_(model_.AddContinuousVariable(0.0, 1.0, "x")), y_(model_.AddIntegerVariable(0.0, 2.0, "y")), c_(model_.AddLinearConstraint(0<=x_+y_<=1.5, "c")) { model_.Maximize(3.0 *x_+2.0 *y_+0.1);solver_=NewIncrementalSolver(&model_, TestedSolver()).value();const SolveResult first_solve=solver_->Solve().value();CHECK(first_solve.has_primal_feasible_solution());CHECK_LE(std::abs(first_solve.objective_value() - 3.6), kTolerance)<< first_solve.objective_value();} namespace { TEST_P(SimpleMipTest, OneVarMax) { Model model;const Variable x=model.AddVariable(0.0, 4.0, false, "x");model.Maximize(2.0 *x);ASSERT_OK_AND_ASSIGN(const SolveResult result, Solve(model, GetParam().solver_type));ASSERT_THAT(result, IsOptimal(8.0));EXPECT_THAT(result.variable_values(), IsNear({{x, 4.0}}));} TEST_P(SimpleMipTest, OneVarMin) { Model model;const Variable x=model.AddVariable(-2.4, 4.0, false, "x");model.Minimize(2.0 *x);ASSERT_OK_AND_ASSIGN(const SolveResult result, Solve(model, GetParam().solver_type));ASSERT_THAT(result, IsOptimal(-4.8));EXPECT_THAT(result.variable_values(), IsNear({{x, -2.4}}));} TEST_P(SimpleMipTest, OneIntegerVar) { Model model;const Variable x=model.AddVariable(0.0, 4.5, true, "x");model.Maximize(2.0 *x);ASSERT_OK_AND_ASSIGN(const SolveResult result, Solve(model, GetParam().solver_type));ASSERT_THAT(result, IsOptimal(8.0));EXPECT_THAT(result.variable_values(), IsNear({{x, 4.0}}));} TEST_P(SimpleMipTest, SimpleLinearConstraint) { Model model;const Variable x=model.AddBinaryVariable("x");const Variable y=model.AddBinaryVariable("y");model.Maximize(2.0 *x+y);model.AddLinearConstraint(0.0<=x+y<=1.5, "c");ASSERT_OK_AND_ASSIGN(const SolveResult result, Solve(model, GetParam().solver_type));ASSERT_THAT(result, IsOptimal(2.0));EXPECT_THAT(result.variable_values(), IsNear({{x, 1}, {y, 0}}));} TEST_P(SimpleMipTest, Unbounded) { Model model;const Variable x=model.AddVariable(0.0, kInf, true, "x");model.Maximize(2.0 *x);ASSERT_OK_AND_ASSIGN(const SolveResult result, Solve(model, GetParam().solver_type));if(GetParam().report_unboundness_correctly) { ASSERT_THAT(result, TerminatesWithOneOf({TerminationReason::kUnbounded, TerminationReason::kInfeasibleOrUnbounded}));} else { ASSERT_THAT(result, TerminatesWith(TerminationReason::kOtherError));} } TEST_P(SimpleMipTest, Infeasible) { Model model;const Variable x=model.AddVariable(0.0, 3.0, true, "x");model.Maximize(2.0 *x);model.AddLinearConstraint(x >=4.0);ASSERT_OK_AND_ASSIGN(const SolveResult result, Solve(model, GetParam().solver_type));ASSERT_THAT(result, TerminatesWith(TerminationReason::kInfeasible));} TEST_P(SimpleMipTest, FractionalBoundsContainNoInteger) { if(GetParam().solver_type==SolverType::kGurobi) { GTEST_SKIP()<< "TODO(b/272298816): Gurobi bindings are broken here.";} Model model;const Variable x=model.AddIntegerVariable(0.5, 0.6, "x");model.Maximize(x);EXPECT_THAT(Solve(model, GetParam().solver_type), IsOkAndHolds(TerminatesWith(TerminationReason::kInfeasible)));} TEST_P(IncrementalMipTest, EmptyUpdate) { ASSERT_THAT(solver_->Update(), IsOkAndHolds(DidUpdate()));ASSERT_OK_AND_ASSIGN(const SolveResult result, solver_->SolveWithoutUpdate());ASSERT_THAT(result, IsOptimal(3.6));EXPECT_THAT(result.variable_values(), IsNear({{x_, 0.5}, {y_, 1.0}}));} TEST_P(IncrementalMipTest, MakeContinuous) { model_.set_continuous(y_);ASSERT_THAT(solver_->Update(), IsOkAndHolds(DidUpdate()));ASSERT_OK_AND_ASSIGN(const SolveResult result, solver_->SolveWithoutUpdate());ASSERT_THAT(result, IsOptimal(4.1));EXPECT_THAT(result.variable_values(), IsNear({{x_, 1.0}, {y_, 0.5}}));} TEST_P(IncrementalMipTest, DISABLED_MakeContinuousWithNonIntegralBounds) { solver_.reset();Model model("bounds");const Variable x=model.AddIntegerVariable(0.5, 1.5, "x");model.Maximize(x);ASSERT_OK_AND_ASSIGN(const auto solver, NewIncrementalSolver(&model, TestedSolver()));ASSERT_THAT(solver->Solve(), IsOkAndHolds(IsOptimal(1.0))); model.set_continuous(x);ASSERT_THAT(solver->Update(), IsOkAndHolds(DidUpdate()));ASSERT_THAT(solver-> operations_research::math_opt::SolveWithoutUpdate | ( | ) |
max 3.0 *x + 2.0 * y + 0.1 s.t. 0 <= x + y <= 1.5 (c)
std::vector< ConstraintType > operations_research::math_opt::SortedAtomicConstraints | ( | const ModelStorage & | storage | ) |
ConstraintType
having a typed_id()
getter. Definition at line 69 of file model_util.h.
std::vector< typename Set::key_type > operations_research::math_opt::SortedElements | ( | const Set & | set | ) |
Returns the elements of the set sorted by their (storage(), type_id()).
Implementation note: here we must use std::enable_if to prevent Argument Dependent Lookup (ADL) from selecting this overload for maps which values are in MathOpt but keys are not.
Definition at line 110 of file key_types.h.
std::vector< typename Map::key_type > operations_research::math_opt::SortedKeys | ( | const Map & | map | ) |
Returns the keys of the map sorted by their (storage(), type_id()).
Implementation note: here we must use std::enable_if to prevent Argument Dependent Lookup (ADL) from selecting this overload for maps which values are in MathOpt but keys are not.
Definition at line 87 of file key_types.h.
std::vector< K > operations_research::math_opt::SortedMapKeys | ( | const absl::flat_hash_map< K, V > & | in_map | ) |
std::vector< K > operations_research::math_opt::SortedMapKeys | ( | const google::protobuf::Map< K, V > & | in_map | ) |
std::vector< T > operations_research::math_opt::SortedSetElements | ( | const absl::flat_hash_set< T > & | elements | ) |
absl::Status operations_research::math_opt::SparseBasisStatusVectorIsValid | ( | const SparseVectorView< int > & | status_vector_view | ) |
Definition at line 241 of file solution_validator.cc.
absl::Status operations_research::math_opt::SparseMatrixIdsAreKnown | ( | const SparseDoubleMatrixProto & | matrix, |
const IdNameBiMap & | row_ids, | ||
const IdNameBiMap & | column_ids ) |
Verifies that:
Definition at line 91 of file sparse_matrix_validator.cc.
absl::Status operations_research::math_opt::SparseMatrixValid | ( | const SparseDoubleMatrixProto & | matrix, |
bool | enforce_upper_triangular = false ) |
Validates that the input satisfies the following invariants:
When row > previous_row, we have a new row, nothing to check.
Definition at line 30 of file sparse_matrix_validator.cc.
SparseSubmatrixRowsView operations_research::math_opt::SparseSubmatrixByRows | ( | const SparseDoubleMatrixProto & | matrix, |
int64_t | start_row_id, | ||
std::optional< int64_t > | end_row_id, | ||
int64_t | start_col_id, | ||
std::optional< int64_t > | end_col_id ) |
Returns the coefficients of columns in the range [start_col_id, end_col_id) for each row in the range [start_row_id, end_row_id).
Returns a vector that contains one pair (row_id, columns_coefficients) per row. It CHECKs that the input matrix is valid. The coefficients are returned in a views that points to the input matrix's data. Therefore they should not be used after the proto is modified/deleted.
When end_(col|row)_id is nullopt, includes all indices greater or equal to start_(col|row)_id.
This functions runs in O(size of matrix).
Use TransposeSparseSubmatrix() to transpose the submatrix and get the columns instead of the rows.
Usage example:
///< With this input sparse matrix: ///< |0 1 2 3 4 5 6 ///< -+----------— ///< 0|2 - - - 3 4 - ///< 1|- - - - - - - ///< 2|- 5 - 1 - - 3 ///< 3|9 - - 8 - - 7 const SparseDoubleMatrixProto matrix = ...;
///< Keeping coefficients of lines >= 1 and columns in [1, 6). const auto rows = SparseSubmatrixByRows( matrix, /*start_row_id=*/1, /*end_row_id=*/std::nullopt, /*start_col_id=*/1, /*end_col_id=*/6);
///< The returned rows and coefficients will be: ///< {2, {{1, 5.0}, {3, 1.0}}} ///< {3, { {3, 8.0}}}
row_start, next_row_start and row_end are indices into the matrix data.
next_row_start is set from row_end once found at the start of the loop below.
Find the end of the current row such that all index in [start, end) are for the same row.
Prepare the next iteration.
Ignore rows not in the expected range.
Finds the first column or the row in the col_range.
Finds the first column greater of equal to row_cols_start that is not in the col_range.
Definition at line 47 of file sparse_submatrix.cc.
std::string operations_research::math_opt::StreamToString | ( | const T & | value | ) |
|
inline |
Returns the sum of the elements of items as a LinearExpression.
Specifically, letting (i_1, i_2, ..., i_n) = items returns i_1 + i_2 + ... + i_n.
Example: const Variable a = ...; const Variable b = ...; const std::vector<Variable> vars = {a, b, a}; Sum(vars) => 2.0 * a + b Note, instead of: LinearExpression expr(3.0); expr += Sum(items); Prefer: expr.AddSum(items);
See LinearExpression::AddSum() for a precise contract on the type Iterable.
If the inner product cannot be represented as a LinearExpression, consider instead QuadraticExpression::Sum().
Definition at line 1676 of file variable_and_expressions.h.
TerminationProto operations_research::math_opt::TerminateForLimit | ( | LimitProto | limit, |
bool | feasible, | ||
absl::string_view | detail = {} ) |
Sets the reason to TERMINATION_REASON_FEASIBLE if feasible = true and TERMINATION_REASON_NO_SOLUTION_FOUND otherwise.
Definition at line 153 of file math_opt_proto_utils.cc.
TerminationProto operations_research::math_opt::TerminateForReason | ( | bool | is_maximize, |
TerminationReasonProto | reason, | ||
absl::string_view | detail = {} ) |
Returns a TerminationProto with the provided reason and details along with trivial bounds and FEASIBILITY_STATUS_UNDETERMINED statuses.
Definition at line 204 of file math_opt_proto_utils.cc.
TerminationProto operations_research::math_opt::TerminateForReason | ( | const TerminationReasonProto | reason, |
const absl::string_view | detail ) |
Definition at line 178 of file math_opt_proto_utils.cc.
testing::Matcher< SolveResult > operations_research::math_opt::TerminatesWith | ( | TerminationReason | expected | ) |
Checks the following:
Definition at line 621 of file matchers.cc.
testing::Matcher< SolveResult > operations_research::math_opt::TerminatesWithLimit | ( | Limit | expected, |
bool | allow_limit_undetermined = false ) |
Checks the following:
See LimitIs() for a matcher for Termination only.
Definition at line 648 of file matchers.cc.
testing::Matcher< SolveResult > operations_research::math_opt::TerminatesWithOneOf | ( | const std::vector< TerminationReason > & | allowed | ) |
Checks that the result has one of the allowed termination reasons.
Definition at line 615 of file matchers.cc.
testing::Matcher< SolveResult > operations_research::math_opt::TerminatesWithReasonFeasible | ( | Limit | expected, |
bool | allow_limit_undetermined = false ) |
Checks the following:
Definition at line 657 of file matchers.cc.
testing::Matcher< SolveResult > operations_research::math_opt::TerminatesWithReasonNoSolutionFound | ( | Limit | expected, |
bool | allow_limit_undetermined = false ) |
Checks the following:
Definition at line 665 of file matchers.cc.
testing::Matcher< Termination > operations_research::math_opt::TerminationIsIgnoreDetail | ( | const Termination & | expected | ) |
Definition at line 757 of file matchers.cc.
testing::Matcher< Termination > operations_research::math_opt::TerminationIsOptimal | ( | ) |
Checks that the termination reason is optimal and that problem status is consistent with optimality (i.e. status is primal and dual feasible).
Definition at line 736 of file matchers.cc.
testing::Matcher< Termination > operations_research::math_opt::TerminationIsOptimal | ( | double | primal_objective_value, |
std::optional< double > | dual_objective_value = std::nullopt, | ||
double | tolerance = kMatcherDefaultTolerance ) |
Checks that the termination reason is optimal, that the objective bounds match the provided ones and that problem status is consistent with optimality (i.e. status is primal and dual feasible).
If dual_objective_value is not set, use the primal_objective_value.
Definition at line 745 of file matchers.cc.
operations_research::math_opt::TEST_P | ( | IncrementalMipTest | , |
AddLinearConstraint | ) |
Definition at line 305 of file mip_tests.cc.
operations_research::math_opt::TEST_P | ( | IncrementalMipTest | , |
AddVariable | ) |
Definition at line 294 of file mip_tests.cc.
operations_research::math_opt::TEST_P | ( | IncrementalMipTest | , |
ChangeBoundsWithTemporaryInversion | ) |
At this point x_ lower bound is 3.0 and upper bound is 1.0.
At this point x_ upper bound is 5.0 and so is greater than the new lower bound.
To make the problem feasible we update the bound of the constraint that contains x_; we take this opportunity to also test inverting bounds of constraints.
At this point c_ lower bound is 4.0 and upper bound is 1.5.
We restore valid bounds by setting c_ upper bound to 5.5.
Definition at line 329 of file mip_tests.cc.
operations_research::math_opt::TEST_P | ( | IncrementalMipTest | , |
DeleteLinearConstraint | ) |
Definition at line 321 of file mip_tests.cc.
operations_research::math_opt::TEST_P | ( | IncrementalMipTest | , |
DeleteVariable | ) |
Definition at line 313 of file mip_tests.cc.
operations_research::math_opt::TEST_P | ( | IncrementalMipTest | , |
LinearConstraintCoefficient | ) |
Definition at line 286 of file mip_tests.cc.
operations_research::math_opt::TEST_P | ( | IncrementalMipTest | , |
LinearConstraintLb | ) |
For this change, feasibility is preserved, so the solver should do no extra work (SCIP enumerates one node, though).
Definition at line 263 of file mip_tests.cc.
operations_research::math_opt::TEST_P | ( | IncrementalMipTest | , |
LinearConstraintUb | ) |
Definition at line 278 of file mip_tests.cc.
operations_research::math_opt::TEST_P | ( | IncrementalMipTest | , |
LinearObjCoef | ) |
Definition at line 239 of file mip_tests.cc.
operations_research::math_opt::TEST_P | ( | IncrementalMipTest | , |
MakeInteger | ) |
Definition at line 215 of file mip_tests.cc.
operations_research::math_opt::TEST_P | ( | IncrementalMipTest | , |
MakeIntegralWithNonIntegralBounds | ) |
With Gurobi we can only have one solver at a time.
Definition at line 194 of file mip_tests.cc.
operations_research::math_opt::TEST_P | ( | IncrementalMipTest | , |
ObjDir | ) |
Definition at line 223 of file mip_tests.cc.
operations_research::math_opt::TEST_P | ( | IncrementalMipTest | , |
ObjOffset | ) |
Definition at line 231 of file mip_tests.cc.
operations_research::math_opt::TEST_P | ( | IncrementalMipTest | , |
VariableLb | ) |
Definition at line 247 of file mip_tests.cc.
operations_research::math_opt::TEST_P | ( | IncrementalMipTest | , |
VariableUb | ) |
Definition at line 255 of file mip_tests.cc.
operations_research::math_opt::TEST_P | ( | InfeasibleSubsystemTest | , |
CanComputeInfeasibleSubsystem | ) |
Definition at line 58 of file infeasible_subsystem_tests.cc.
operations_research::math_opt::TEST_P | ( | InfeasibleSubsystemTest | , |
InconsistentEqualityLinearConstraint | ) |
The model is: min 0 s.t. 1 == 0
The entire model is an IIS.
Definition at line 159 of file infeasible_subsystem_tests.cc.
operations_research::math_opt::TEST_P | ( | InfeasibleSubsystemTest | , |
InconsistentEqualityQuadraticConstraint | ) |
The model is: min 0 s.t. 1 == 0 (quadratic constraint)
The entire model is an IIS.
Definition at line 265 of file infeasible_subsystem_tests.cc.
≤ operations_research::math_opt::TEST_P | ( | InfeasibleSubsystemTest | , |
InconsistentGreaterThanLinearConstraint | ) |
The model is: min 0 s.t. 1 ≤ 0 ≤ ∞
An IIS is:
Definition at line 139 of file infeasible_subsystem_tests.cc.
≤ operations_research::math_opt::TEST_P | ( | InfeasibleSubsystemTest | , |
InconsistentGreaterThanQuadraticConstraint | ) |
The model is: min 0 s.t. 1 ≤ 0 ≤ ∞ (quadratic constraint)
An IIS is:
Definition at line 245 of file infeasible_subsystem_tests.cc.
≤ operations_research::math_opt::TEST_P | ( | InfeasibleSubsystemTest | , |
InconsistentLessThanLinearConstraint | ) |
The model is: min 0 s.t. -∞ ≤ 1 ≤ 0
An IIS is:
Definition at line 118 of file infeasible_subsystem_tests.cc.
≤ operations_research::math_opt::TEST_P | ( | InfeasibleSubsystemTest | , |
InconsistentLessThanQuadraticConstraint | ) |
The model is: min 0 s.t. -∞ ≤ 1 ≤ 0 (quadratic constraint)
An IIS is:
Definition at line 224 of file infeasible_subsystem_tests.cc.
operations_research::math_opt::TEST_P | ( | InfeasibleSubsystemTest | , |
InconsistentRangedLinearConstraint | ) |
The model is: min 0 s.t. 0 ≤ 2 ≤ 1
The entire model is an IIS.
Definition at line 179 of file infeasible_subsystem_tests.cc.
≤ y y operations_research::math_opt::TEST_P | ( | InfeasibleSubsystemTest | , |
InconsistentSos1Constraint | ) |
Definition at line 395 of file infeasible_subsystem_tests.cc.
operations_research::math_opt::TEST_P | ( | InfeasibleSubsystemTest | , |
InconsistentSos1ConstraintWithExpressions | ) |
The model is: min 0 s.t. {1, 1} is SOS1
The entire problem is an IIS.
Definition at line 419 of file infeasible_subsystem_tests.cc.
≤ z z ≤ y operations_research::math_opt::TEST_P | ( | InfeasibleSubsystemTest | , |
InconsistentSos2Constraint | ) |
Definition at line 440 of file infeasible_subsystem_tests.cc.
operations_research::math_opt::TEST_P | ( | InfeasibleSubsystemTest | , |
InconsistentSos2ConstraintWithExpressions | ) |
The model is: min 0 s.t. {1, 0, 1} is SOS2
The entire model is an IIS.
Definition at line 465 of file infeasible_subsystem_tests.cc.
operations_research::math_opt::TEST_P | ( | InfeasibleSubsystemTest | , |
IndicatorConstraintOkInconsistentImpliedNullIndicator | ) |
The model is: min 0 s.t. {null} --> 1 ≤ 0
The model is feasible.
To get a null indicator variable, we: add a placeholder indicator variable, add the indicator constraint, and then delete the variable.
Definition at line 510 of file infeasible_subsystem_tests.cc.
operations_research::math_opt::TEST_P | ( | InfeasibleSubsystemTest | , |
IntegerVariableWithInfeasibleBounds | ) |
The model is: min 0 s.t. 0.2 ≤ x ≤ 0.8 (variable bounds) x is integer
The entire model is an IIS.
Definition at line 96 of file infeasible_subsystem_tests.cc.
operations_research::math_opt::TEST_P | ( | InfeasibleSubsystemTest | , |
InvertedVariableBounds | ) |
The model is: min 0 s.t. 1 ≤ x ≤ 0 (variable bounds)
The entire model is an IIS.
Definition at line 76 of file infeasible_subsystem_tests.cc.
operations_research::math_opt::TEST_P | ( | InfeasibleSubsystemTest | , |
NontrivialInfeasibleIpSolveInterruptedBeforeStartIsUndetermined | ) |
Definition at line 584 of file infeasible_subsystem_tests.cc.
operations_research::math_opt::TEST_P | ( | InfeasibleSubsystemTest | , |
NontrivialInfeasibleIpSolveTimeLimitZeroIsUndetermined | ) |
Definition at line 572 of file infeasible_subsystem_tests.cc.
operations_research::math_opt::TEST_P | ( | InfeasibleSubsystemTest | , |
NontrivialInfeasibleIpSolveWithMessageCallbackIsInvoked | ) |
Definition at line 597 of file infeasible_subsystem_tests.cc.
operations_research::math_opt::TEST_P | ( | InfeasibleSubsystemTest | , |
NontrivialInfeasibleIpSolveWithoutLimitsFindsIIS | ) |
Definition at line 555 of file infeasible_subsystem_tests.cc.
ValueType operations_research::math_opt::ToGlopBasisStatus | ( | const BasisStatusProto | basis_status | ) |
ValueType should be glop's VariableStatus or ConstraintStatus.
Definition at line 512 of file glop_solver.cc.
LinearExpression operations_research::math_opt::ToLinearExpression | ( | const ModelStorage & | storage, |
const LinearExpressionData & | expr_data ) |
Converts data from "raw ID" format to a LinearExpression, in the C++ API, associated with storage
.
Definition at line 25 of file model_util.cc.
std::string operations_research::math_opt::ToString | ( | QpSupportType | qp_support | ) |
Definition at line 64 of file qp_tests.cc.
std::vector< std::pair< int64_t, SparseVector< double > > > operations_research::math_opt::TransposeSparseSubmatrix | ( | const SparseSubmatrixRowsView & | submatrix_by_rows | ) |
Returns a vector that contains one pair (row_id, rows_coefficients) per column.
The coefficients are returned as copies of the input views.
This functions runs in: O(num_non_zeros + num_non_empty_cols * lg(num_non_empty_cols)).
Extract the columns by iterating on the filtered views of the rows (the matrix is row major).
The output should be sorted by column id.
Definition at line 108 of file sparse_submatrix.cc.
TerminationProto operations_research::math_opt::UnboundedTerminationProto | ( | bool | is_maximize, |
absl::string_view | detail = {} ) |
Returns a TERMINATION_REASON_UNBOUNDED termination with a FEASIBILITY_STATUS_FEASIBLE primal status and FEASIBILITY_STATUS_INFEASIBLE dual one along with corresponding trivial bounds.
Definition at line 236 of file math_opt_proto_utils.cc.
void operations_research::math_opt::UpdateIdIndexMap | ( | glop::StrictITIVector< IndexType, bool > | indices_to_delete, |
IndexType | num_indices, | ||
absl::flat_hash_map< int64_t, IndexType > & | id_index_map ) |
Mark deleted index
This safely deletes the entry and moves the iterator one step ahead.
Definition at line 187 of file glop_solver.cc.
bool operations_research::math_opt::UpdateIsSupported | ( | const ModelUpdateProto & | update, |
const SupportedProblemStructures & | support_menu ) |
Returns false if a problem structure is present in update
and not not implemented or supported according to support_menu
.
Duck-types that the proto parameter contains fields named new_constraints
and deleted_constraint_ids
. This is standard for "mapped" constraints.
Definition at line 463 of file math_opt_proto_utils.cc.
void operations_research::math_opt::UpgradeSolveResultProtoForStatsMigration | ( | SolveResultProto & | solve_result_proto | ) |
Definition at line 545 of file math_opt_proto_utils.cc.
double operations_research::math_opt::UpperBound | ( | const LinearExpression & | linear_expression | ) |
Computes an upper bound on the value a linear expression can take based on the variable bounds.
The returned value will be in (-inf, +inf] on valid input (see LowerBound() above, the requirements are the same).
See LowerBound() above for more details.
Definition at line 56 of file linear_expr_util.cc.
absl::Status operations_research::math_opt::ValidateBasis | ( | const BasisProto & | basis, |
const ModelSummary & | model_summary, | ||
const bool | check_dual_feasibility ) |
Definition at line 257 of file solution_validator.cc.
absl::Status operations_research::math_opt::ValidateBoundStatusConsistency | ( | const ObjectiveBoundsProto & | objective_bounds, |
const ProblemStatusProto & | status, | ||
bool | is_maximize ) |
Definition at line 215 of file bounds_and_status_validator.cc.
absl::Status operations_research::math_opt::ValidateCallbackDataProto | ( | const CallbackDataProto & | cb_data, |
const CallbackRegistrationProto & | callback_registration, | ||
const ModelSummary & | model_summary ) |
Checks that CallbackDataProto is valid given a valid model summary and CallbackRegistrationProto.
Check PresolveStats.
Check SimplexStats.
Check BarrierStats.
Check MipStats.
Check runtime.
Ensure required fields are available depending on event.
This can not happen as a valid callback_registration can not register a CALLBACK_EVENT_UNSPECIFIED.
The remaining events are just for information collection. No further test required.
Definition at line 152 of file callback_validator.cc.
absl::Status operations_research::math_opt::ValidateCallbackRegistration | ( | const CallbackRegistrationProto & | callback_registration, |
const ModelSummary & | model_summary ) |
Checks that CallbackRegistrationProto is valid given a valid model summary.
Unfortunately the range iterator return ints and not CallbackEventProtos.
Definition at line 107 of file callback_validator.cc.
absl::Status operations_research::math_opt::ValidateCallbackResultProto | ( | const CallbackResultProto & | callback_result, |
CallbackEventProto | event, | ||
const CallbackRegistrationProto & | callback_registration, | ||
const ModelSummary & | model_summary ) |
Checks that CallbackResultProto is valid given a valid model summary, CallbackEventProto (which since it is assumed to be valid, can not be CALLBACK_EVENT_UNSPECIFIED) and a CallbackRegistrationProto.
We assume that all arguments but the first are valid and concordant with each other. Otherwise this is an internal implementation error.
Definition at line 258 of file callback_validator.cc.
absl::Status operations_research::math_opt::ValidateComputeInfeasibleSubsystemResult | ( | const ComputeInfeasibleSubsystemResultProto & | result, |
const ModelSummary & | model_summary ) |
Definition at line 80 of file infeasible_subsystem_validator.cc.
absl::Status operations_research::math_opt::ValidateComputeInfeasibleSubsystemResultNoModel | ( | const ComputeInfeasibleSubsystemResultProto & | result | ) |
Validates the internal consistency of the fields.
Check that the infeasible_subsystem
is empty by validating against an empty ModelSummary.
Definition at line 91 of file infeasible_subsystem_validator.cc.
absl::Status operations_research::math_opt::ValidateConstraint | ( | const IndicatorConstraintProto & | constraint, |
const IdNameBiMap & | variable_universe ) |
Definition at line 27 of file validator.cc.
absl::Status operations_research::math_opt::ValidateConstraint | ( | const QuadraticConstraintProto & | constraint, |
const IdNameBiMap & | variable_universe ) |
Step 1: Validate linear terms.
Step 2: Validate quadratic terms.
Step 3: Validate bounds.
Definition at line 32 of file validator.cc.
absl::Status operations_research::math_opt::ValidateConstraint | ( | const SecondOrderConeConstraintProto & | constraint, |
const IdNameBiMap & | variable_universe ) |
Definition at line 29 of file validator.cc.
absl::Status operations_research::math_opt::ValidateConstraint | ( | const SosConstraintProto & | constraint, |
const IdNameBiMap & | variable_universe ) |
Check weights for uniqueness.
Definition at line 28 of file validator.cc.
absl::Status operations_research::math_opt::ValidateDualRay | ( | const DualRayProto & | dual_ray, |
const ModelSolveParametersProto & | parameters, | ||
const ModelSummary & | model_summary ) |
Definition at line 221 of file solution_validator.cc.
absl::Status operations_research::math_opt::ValidateDualSolution | ( | const DualSolutionProto & | dual_solution, |
const ModelSolveParametersProto & | parameters, | ||
const ModelSummary & | model_summary ) |
Definition at line 203 of file solution_validator.cc.
absl::Status operations_research::math_opt::ValidateFeasibilityStatus | ( | const FeasibilityStatusProto & | status | ) |
Problem status validators and utilities.
Definition at line 33 of file bounds_and_status_validator.cc.
absl::Status operations_research::math_opt::ValidateLinearExpression | ( | const LinearExpressionProto & | expression, |
const IdNameBiMap & | variable_universe ) |
Definition at line 28 of file linear_expression_validator.cc.
absl::StatusOr< ModelSummary > operations_research::math_opt::ValidateModel | ( | const ModelProto & | model, |
const bool | check_names ) |
Runs in O(size of model) and allocates O(#variables + #linear constraints) memory.
Definition at line 232 of file model_validator.cc.
absl::Status operations_research::math_opt::ValidateModelSolveParameters | ( | const ModelSolveParametersProto & | parameters, |
const ModelSummary & | model_summary ) |
Definition at line 114 of file model_parameters_validator.cc.
absl::Status operations_research::math_opt::ValidateModelSubset | ( | const ModelSubsetProto & | model_subset, |
const ModelSummary & | model_summary ) |
Definition at line 51 of file infeasible_subsystem_validator.cc.
absl::Status operations_research::math_opt::ValidateModelUpdate | ( | const ModelUpdateProto & | model_update, |
ModelSummary & | model_summary ) |
Model Update
Validates the update is consistent both internally and with current model (as given by model_summary) and updates the model_summary.
Performance: runs in O(size of update), allocates at most O(#new or deleted variables + #new or deleted linear constraints).
If the function returns an error, no guarantees are made on the state of model_summary.
Definition at line 279 of file model_validator.cc.
absl::Status operations_research::math_opt::ValidateObjectiveBounds | ( | const ObjectiveBoundsProto & | bounds | ) |
Objective bounds validators and utilities.
Definition at line 128 of file bounds_and_status_validator.cc.
absl::Status operations_research::math_opt::ValidatePrimalRay | ( | const PrimalRayProto & | primal_ray, |
const SparseVectorFilterProto & | filter, | ||
const ModelSummary & | model_summary ) |
Definition at line 194 of file solution_validator.cc.
absl::Status operations_research::math_opt::ValidatePrimalSolution | ( | const PrimalSolutionProto & | primal_solution, |
const SparseVectorFilterProto & | filter, | ||
const ModelSummary & | model_summary ) |
Definition at line 171 of file solution_validator.cc.
absl::Status operations_research::math_opt::ValidatePrimalSolutionVector | ( | const SparseDoubleVectorProto & | vector, |
const SparseVectorFilterProto & | filter, | ||
const ModelSummary & | model_summary ) |
Used to validate callback solutions, which are represented by a SparseDoubleVectorProto and not the full PrimalSolutionProto message. Does the same checks on a SparseDoubleVectorProto that ValidatePrimalSolution does on the variable_values sub-message of a PrimalSolutionProto.
Definition at line 163 of file solution_validator.cc.
absl::Status operations_research::math_opt::ValidateProblemStatus | ( | const ProblemStatusProto & | status | ) |
Definition at line 44 of file bounds_and_status_validator.cc.
absl::Status operations_research::math_opt::ValidateResult | ( | const SolveResultProto & | result, |
const ModelSolveParametersProto & | parameters, | ||
const ModelSummary & | model_summary ) |
Validates the input result.
Definition at line 278 of file result_validator.cc.
absl::Status operations_research::math_opt::ValidateSolution | ( | const SolutionProto & | solution, |
const ModelSolveParametersProto & | parameters, | ||
const ModelSummary & | model_summary ) |
Definition at line 119 of file solution_validator.cc.
absl::Status operations_research::math_opt::ValidateSolutions | ( | const google::protobuf::RepeatedPtrField< SolutionProto > & | solutions, |
const ModelSolveParametersProto & | parameters, | ||
const ModelSummary & | model_summary ) |
Validate individual solutions
Validate solution order.
Primal-feasible solutions must appear first.
Dual-feasible solutions must appear first within the groups of primal-feasible and other solutions. Equivalently, a dual-feasible solution must be preceded by a dual-feasible solution, except when we switch from the group of primal-feasible solutions to the group of other solutions.
Definition at line 66 of file result_validator.cc.
absl::Status operations_research::math_opt::ValidateSolveParameters | ( | const SolveParametersProto & | parameters | ) |
Definition at line 48 of file solve_parameters_validator.cc.
absl::Status operations_research::math_opt::ValidateSolveStats | ( | const SolveStatsProto & | solve_stats | ) |
Definition at line 26 of file solve_stats_validator.cc.
absl::Status operations_research::math_opt::ValidateSparseVectorFilter | ( | const SparseVectorFilterProto & | v, |
const IdNameBiMap & | valid_ids ) |
Definition at line 99 of file model_parameters_validator.cc.
absl::Status operations_research::math_opt::ValidateTermination | ( | const TerminationProto & | termination, |
const bool | is_maximize ) |
Checks all messages are valid and compatible.
Definition at line 127 of file termination_validator.cc.
std::vector< typename Map::mapped_type > operations_research::math_opt::Values | ( | const Map & | map, |
const Keys & | keys ) |
Returns the values corresponding to the keys. Keys must be present in the input map.
The keys must be in a type convertible to absl::Span<const K>.
Implementation note: here we must use std::enable_if to prevent Argument Dependent Lookup (ADL) from selecting this overload for maps which values are in MathOpt but keys are not.
Definition at line 136 of file key_types.h.
absl::StatusOr< VariableMap< BasisStatus > > operations_research::math_opt::VariableBasisFromProto | ( | const ModelStorage * | model, |
const SparseBasisStatusVector & | basis_proto ) |
Returns the VariableMap<BasisStatus> equivalent to basis_proto
.
Requires that (or returns a status error):
model
(this implies that each id is in [0, max(int64_t))).Definition at line 217 of file sparse_containers.cc.
SparseBasisStatusVector operations_research::math_opt::VariableBasisToProto | ( | const VariableMap< BasisStatus > & | basis_values | ) |
Returns the proto equivalent of basis_values.
Definition at line 225 of file sparse_containers.cc.
absl::StatusOr< MapFilter< Variable > > operations_research::math_opt::VariableFilterFromProto | ( | const Model & | model, |
const SparseVectorFilterProto & | proto ) |
Returns the MapFilter<Variable> equivalent to proto
.
Requires that (or returns a status error):
model
. Definition at line 28 of file map_filter.cc.
absl::StatusOr< VariableMap< double > > operations_research::math_opt::VariableValuesFromProto | ( | const ModelStorage * | model, |
const SparseDoubleVectorProto & | vars_proto ) |
Returns the VariableMap<double> equivalent to vars_proto
.
Requires that (or returns a status error):
model
(this implies that each id is in [0, max(int64_t))).Definition at line 142 of file sparse_containers.cc.
absl::StatusOr< VariableMap< int32_t > > operations_research::math_opt::VariableValuesFromProto | ( | const ModelStorage * | model, |
const SparseInt32VectorProto & | vars_proto ) |
Returns the VariableMap<int32_t> equivalent to vars_proto
.
Requires that (or returns a status error):
model
(this implies that each id is in [0, max(int64_t))). Definition at line 150 of file sparse_containers.cc.
SparseDoubleVectorProto operations_research::math_opt::VariableValuesToProto | ( | const VariableMap< double > & | variable_values | ) |
Returns the proto equivalent of variable_values.
Definition at line 157 of file sparse_containers.cc.
MessageCallback operations_research::math_opt::VectorMessageCallback | ( | std::vector< std::string > * | sink | ) |
Returns a message callback function that aggregates all messages in the provided vector.
Usage:
std::vector<std::string> msgs; SolveArguments args; args.message_callback = VectorMessageCallback(&msgs);
Here we must use an std::shared_ptr since std::function requires that its input is copyable. And VectorMessageCallbackImpl can't be copyable since it uses an absl::Mutex that is not.
Definition at line 111 of file message_callback.cc.
absl::StatusOr< std::vector< std::string > > operations_research::math_opt::ViolatedConstraintsAsStrings | ( | const Model & | model, |
const ModelSubset & | violated_constraints, | ||
const VariableMap< double > & | variable_values ) |
Returns a collection of strings that provide a human-readable representation of the violated_constraints
(one string for each violated constraint). Useful for logging.
Returns an InvalidArgument error if variable_values
does not contain an entry for each variable in model
(and no extras).
Definition at line 329 of file solution_feasibility_checker.cc.
MessageCallback operations_research::math_opt::VLoggerMessageCallback | ( | int | level, |
absl::string_view | prefix = "", | ||
absl::SourceLocation | loc = absl::SourceLocation::current() ) |
Returns a message callback function that prints each line to VLOG(level), prefixing each line with the given prefix.
Usage:
SolveArguments args; args.message_callback = VLoggerMessageCallback(1, "[solver] ");
Definition at line 102 of file message_callback.cc.
double operations_research::math_opt::WorstGLPKDualBound | ( | bool | is_maximize, |
double | objective_value, | ||
double | relative_gap_limit ) |
Returns the worst dual bound corresponding to the given objective value and relative gap limit. This should be used when glp_intopt() returns GLP_EMIPGAP (i.e. stopped because of the gap limit) but the best_dual_bound is not available.
GLPK define the relative gap as:
gap := -------------------------------------— best_objective_value
+ DBL_EPSILON
This function thus returns the value of best_dual_bound that makes gap match the relative_gap_limit.
Negative or NaN relative_gap_limit is considered 0. If the relative_gap_limit is +inf, returns the infinite dual bound corresponding to the is_maximize.
If the objective_value is infinite or NaN, returns the same value as the worst dual bound (in practice the objective_value should be finite).
absl::Status operations_research::math_opt::WriteModel | ( | const absl::string_view | file_path, |
const ModelProto & | model_proto, | ||
const std::optional< SolutionHintProto > & | hint_proto, | ||
const FileFormat | format ) |
Definition at line 237 of file file_format_flags.cc.
* If primal operations_research::math_opt::bound |
Status-Bounds consistency validators. Checks both bound-status compatibility rules. That is:
Definition at line 73 of file bounds_and_status_validator.h.
const IndicatorConstraint operations_research::math_opt::c = model.AddLinearConstraint(x >= 1.0) |
Definition at line 206 of file infeasible_subsystem_tests.cc.
For infeasible and unbounded see Not checked if options check_solutions_if_inf_or_unbounded and the If options first_solution_only is check the entire list of Dual solution is not checked if options operations_research::math_opt::check_dual |
solutions matches in the same order.
Definition at line 470 of file matchers.h.
When the underlying default is used When the feature cannot be turned kOff will return an error If the feature is enabled by operations_research::math_opt::default |
Definition at line 175 of file parameters.h.
absl::string_view operations_research::math_opt::detail = {}) |
Definition at line 165 of file math_opt_proto_utils.h.
For infeasible and unbounded see Not checked if options check_solutions_if_inf_or_unbounded and the If options first_solution_only is operations_research::math_opt::false |
problem is infeasible or unbounded (default).
options.inf_or_unb_soft_match.
Definition at line 468 of file matchers.h.
* If primal * dual status is and* dual bound is equal to primal bound* is operations_research::math_opt::finite |
Definition at line 79 of file bounds_and_status_validator.h.
Definition at line 486 of file infeasible_subsystem_tests.cc.
Definition at line 315 of file infeasible_subsystem_tests.cc.
Definition at line 369 of file infeasible_subsystem_tests.cc.
Definition at line 342 of file infeasible_subsystem_tests.cc.
Definition at line 200 of file infeasible_subsystem_tests.cc.
Definition at line 289 of file infeasible_subsystem_tests.cc.
* If primal * dual status is operations_research::math_opt::infeasible |
Definition at line 77 of file bounds_and_status_validator.h.
|
inlineconstexpr |
True for types in MathOpt that implements the keys interface defined at the top of this file.
This is used in conjunction with std::enable_if_t<> to prevent Argument Dependent Lookup (ADL) from selecting some overload defined in MathOpt because one of the template type is in MathOpt. For example the SortedKeys() function below could be selected as a valid overload in another namespace if the values in the hash map are in the math_opt namespace.
Definition at line 72 of file key_types.h.
|
constexpr |
A default way to describe a constraint that has been deleted from its associated model.
Definition at line 30 of file model_util.h.
|
constexpr |
Definition at line 36 of file objective.h.
When the underlying default is used When the feature cannot be turned kOff will return an error If the feature is enabled by the solver default is typically If the feature is operations_research::math_opt::kHigh |
Definition at line 177 of file parameters.h.
|
constexpr |
Definition at line 24 of file empty_bounds.cc.
When the underlying default is used When the feature cannot be turned kOff will return an error If the feature is enabled by the solver default is typically If the feature is operations_research::math_opt::kLow |
Definition at line 177 of file parameters.h.
|
constexpr |
Definition at line 113 of file matchers.h.
|
inlineconstexpr |
Maximum value for integrality_tolerance
and for RoundedLowerBound() and RoundedUpperBound().
Definition at line 30 of file solution_improvement.h.
|
constexpr |
The maximum number of variables/constraints with inverted bounds to report.
Definition at line 25 of file inverted_bounds.h.
|
constexpr |
The maximum number of non-binary indicator variables to report.
Definition at line 25 of file invalid_indicators.h.
When the underlying default is used When the feature cannot be turned kOff will return an error If the feature is enabled by the solver default is typically If the feature is operations_research::math_opt::kMedium |
Definition at line 177 of file parameters.h.
|
constexpr |
Definition at line 40 of file multi_objective_tests.cc.
|
constexpr |
Definition at line 44 of file qp_tests.cc.
|
constexpr |
Definition at line 41 of file qp_tests.cc.
|
constexpr |
Definition at line 32 of file model_storage_types.h.
|
constexpr |
Definition at line 79 of file lp_incomplete_solve_tests.cc.
When the underlying default is used When the feature cannot be turned operations_research::math_opt::off |
Definition at line 174 of file parameters.h.
For infeasible and unbounded operations_research::math_opt::problems |
Tests that two SolveResults are equivalent. Basic use:
SolveResult expected; ///< Fill in expected... ASSERT_OK_AND_ASSIGN(SolveResult actual, Solve(model, solver_type)); EXPECT_THAT(actual, IsConsistentWith(expected));
Equivalence is defined as follows:
Definition at line 461 of file matchers.h.
When the underlying default is used When the feature cannot be turned kOff will return an error If the feature is enabled by the solver default is typically If the feature is operations_research::math_opt::supported |
mapped to kMedium.
Definition at line 177 of file parameters.h.
When operations_research::math_opt::unset |
Effort level applied to an optional task while solving (see SolveParameters for use).
Typically used as a std::optional<Emphasis>. It's used to configure a solver feature as follows:
Definition at line 173 of file parameters.h.
The model is: min 0 s.t. {x, y} is SOS1
The model is: min 0 s.t. {x, y, z} is SOS2
Definition at line 205 of file infeasible_subsystem_tests.cc.