C++ Reference
C++ Reference: Linear solver
Classes | |
class | LinearExpr |
LinearExpr models a quantity that is linear in the decision variables (MPVariable) of an optimization problem, i.e. More... | |
class | LinearRange |
An expression of the form: More... | |
class | MPConstraint |
The class for constraints of a Mathematical Programming (MP) model. More... | |
class | MPModelDeltaProto_ConstraintOverridesEntry_DoNotUse |
class | MPModelDeltaProto_VariableOverridesEntry_DoNotUse |
struct | MPModelExportOptions |
Export options. More... | |
class | MPObjective |
A class to express a linear objective. More... | |
class | MPSolver |
This mathematical programming (MP) solver class is the main class though which users build and solve problems. More... | |
class | MPSolverInterface |
class | MPSolverParameters |
This class stores parameter settings for LP and MIP solvers. More... | |
class | MPVariable |
The class for variables of a Mathematical Programming (MP) model. More... | |
class | PROTOBUF_FINAL |
Functions | |
std::ostream & | operator<< (std::ostream &stream, const LinearExpr &linear_expr) |
LinearExpr | operator+ (LinearExpr lhs, const LinearExpr &rhs) |
LinearExpr | operator- (LinearExpr lhs, const LinearExpr &rhs) |
LinearExpr | operator* (LinearExpr lhs, double rhs) |
LinearExpr | operator/ (LinearExpr lhs, double rhs) |
LinearExpr | operator* (double lhs, LinearExpr rhs) |
LinearRange | operator<= (const LinearExpr &lhs, const LinearExpr &rhs) |
LinearRange | operator== (const LinearExpr &lhs, const LinearExpr &rhs) |
LinearRange | operator>= (const LinearExpr &lhs, const LinearExpr &rhs) |
bool | SolverTypeIsMip (MPModelRequest::SolverType solver_type) |
bool | SolverTypeIsMip (MPSolver::OptimizationProblemType solver_type) |
const absl::string_view | ToString (MPSolver::OptimizationProblemType optimization_problem_type) |
std::ostream & | operator<< (std::ostream &os, MPSolver::OptimizationProblemType optimization_problem_type) |
std::ostream & | operator<< (std::ostream &os, MPSolver::ResultStatus status) |
bool | AbslParseFlag (absl::string_view text, MPSolver::OptimizationProblemType *solver_type, std::string *error) |
std::string | AbslUnparseFlag (MPSolver::OptimizationProblemType solver_type) |
bool | MPSolverResponseStatusIsRpcError (MPSolverResponseStatus status) |
absl::StatusOr< std::string > | ExportModelAsLpFormat (const MPModelProto &model, const MPModelExportOptions &options=MPModelExportOptions()) |
Outputs the current model (variables, constraints, objective) as a string encoded in the so-called "CPLEX LP file format" as generated by SCIP. More... | |
absl::StatusOr< std::string > | ExportModelAsMpsFormat (const MPModelProto &model, const MPModelExportOptions &options=MPModelExportOptions()) |
Outputs the current model (variables, constraints, objective) as a string encoded in MPS file format, using the "free" MPS format. More... | |
std::string | ExportModelAsLpFormatReturnString (const MPModelProto &input_model, const MPModelExportOptions &options=MPModelExportOptions()) |
std::string | ExportModelAsMpsFormatReturnString (const MPModelProto &input_model, const MPModelExportOptions &options=MPModelExportOptions()) |
std::string | FindErrorInMPModelProto (const MPModelProto &model, double abs_value_threshold=0.0) |
Returns an empty string iff the model is valid and not trivially infeasible. More... | |
std::string | FindErrorInMPModelDeltaProto (const MPModelDeltaProto &delta, const MPModelProto &model) |
Like FindErrorInMPModelProto, but for a MPModelDeltaProto applied to a given baseline model (assumed valid, eg. More... | |
absl::optional< LazyMutableCopy< MPModelProto > > | ExtractValidMPModelOrPopulateResponseStatus (const MPModelRequest &request, MPSolutionResponse *response) |
If the model is valid and non-empty, returns it (possibly after extracting the model_delta). More... | |
bool | ExtractValidMPModelInPlaceOrPopulateResponseStatus (MPModelRequest *request, MPSolutionResponse *response) |
Like ExtractValidMPModelOrPopulateResponseStatus(), but works in-place: if the MPModel needed extraction, it will be populated in the request, and it returns the success boolean. More... | |
std::string | FindFeasibilityErrorInSolutionHint (const MPModelProto &model, double tolerance) |
Returns an empty string if the solution hint given in the model is a feasible solution. More... | |
void | MergeMPConstraintProtoExceptTerms (const MPConstraintProto &from, MPConstraintProto *to) |
void | ApplyVerifiedMPModelDelta (const MPModelDeltaProto &delta, MPModelProto *model) |
bool | MPSosConstraint_Type_IsValid (int value) |
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor * | MPSosConstraint_Type_descriptor () |
template<typename T > | |
const std::string & | MPSosConstraint_Type_Name (T enum_t_value) |
bool | MPSosConstraint_Type_Parse (::PROTOBUF_NAMESPACE_ID::ConstStringParam name, MPSosConstraint_Type *value) |
bool | MPSolverCommonParameters_LPAlgorithmValues_IsValid (int value) |
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor * | MPSolverCommonParameters_LPAlgorithmValues_descriptor () |
template<typename T > | |
const std::string & | MPSolverCommonParameters_LPAlgorithmValues_Name (T enum_t_value) |
bool | MPSolverCommonParameters_LPAlgorithmValues_Parse (::PROTOBUF_NAMESPACE_ID::ConstStringParam name, MPSolverCommonParameters_LPAlgorithmValues *value) |
bool | MPModelRequest_SolverType_IsValid (int value) |
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor * | MPModelRequest_SolverType_descriptor () |
template<typename T > | |
const std::string & | MPModelRequest_SolverType_Name (T enum_t_value) |
bool | MPModelRequest_SolverType_Parse (::PROTOBUF_NAMESPACE_ID::ConstStringParam name, MPModelRequest_SolverType *value) |
bool | MPSolverResponseStatus_IsValid (int value) |
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor * | MPSolverResponseStatus_descriptor () |
template<typename T > | |
const std::string & | MPSolverResponseStatus_Name (T enum_t_value) |
bool | MPSolverResponseStatus_Parse (::PROTOBUF_NAMESPACE_ID::ConstStringParam name, MPSolverResponseStatus *value) |
Enumeration Type Documentation
◆ MPModelRequest_SolverType
enum MPModelRequest_SolverType : int |
Definition at line 191 of file linear_solver.pb.h.
◆ MPSolverCommonParameters_LPAlgorithmValues
enum MPSolverCommonParameters_LPAlgorithmValues : int |
Definition at line 166 of file linear_solver.pb.h.
◆ MPSolverResponseStatus
enum MPSolverResponseStatus : int |
Definition at line 227 of file linear_solver.pb.h.
◆ MPSosConstraint_Type
enum MPSosConstraint_Type : int |
Enumerator | |
---|---|
MPSosConstraint_Type_SOS1_DEFAULT | |
MPSosConstraint_Type_SOS2 |
Definition at line 143 of file linear_solver.pb.h.
Function Documentation
◆ AbslParseFlag()
bool operations_research::AbslParseFlag | ( | absl::string_view | text, |
MPSolver::OptimizationProblemType * | solver_type, | ||
std::string * | error | ||
) |
◆ AbslUnparseFlag()
|
inline |
Definition at line 919 of file linear_solver.h.
◆ ApplyVerifiedMPModelDelta()
void operations_research::ApplyVerifiedMPModelDelta | ( | const MPModelDeltaProto & | delta, |
MPModelProto * | model | ||
) |
◆ ExportModelAsLpFormat()
absl::StatusOr<std::string> operations_research::ExportModelAsLpFormat | ( | const MPModelProto & | model, |
const MPModelExportOptions & | options = MPModelExportOptions() |
||
) |
Outputs the current model (variables, constraints, objective) as a string encoded in the so-called "CPLEX LP file format" as generated by SCIP.
The LP file format is easily readable by a human.
Returns false if some error has occurred during execution. The validity of names is automatically checked. If a variable name or a constraint name is invalid or non-existent, a new valid name is automatically generated.
If 'obfuscated' is true, the variable and constraint names of proto_ are not used. Variable and constraint names of the form "V12345" and "C12345" are used instead.
For more information about the different LP file formats: http://lpsolve.sourceforge.net/5.5/lp-format.htm The following give a reasonable idea of the CPLEX LP file format: http://lpsolve.sourceforge.net/5.5/CPLEX-format.htm http://tinyurl.com/cplex-lp-format http://www.gurobi.com/documentation/5.1/reference-manual/node871
◆ ExportModelAsLpFormatReturnString()
|
inline |
Definition at line 24 of file model_exporter_swig_helper.h.
◆ ExportModelAsMpsFormat()
absl::StatusOr<std::string> operations_research::ExportModelAsMpsFormat | ( | const MPModelProto & | model, |
const MPModelExportOptions & | options = MPModelExportOptions() |
||
) |
Outputs the current model (variables, constraints, objective) as a string encoded in MPS file format, using the "free" MPS format.
Returns false if some error has occurred during execution. Models with maximization objectives trigger an error, because MPS can encode only minimization problems.
The validity of names is automatically checked. If a variable name or a constraint name is invalid or non-existent, a new valid name is automatically generated.
Name validity and obfuscation works exactly as in ExportModelAsLpFormat().
For more information about the MPS format: http://en.wikipedia.org/wiki/MPS_(format) A close-to-original description coming from OSL: http://tinyurl.com/mps-format-by-osl A recent description from CPLEX: http://tinyurl.com/mps-format-by-cplex CPLEX extensions: http://tinyurl.com/mps-extensions-by-cplex Gurobi's description: http://www.gurobi.com/documentation/5.1/reference-manual/node869
◆ ExportModelAsMpsFormatReturnString()
|
inline |
Definition at line 31 of file model_exporter_swig_helper.h.
◆ ExtractValidMPModelInPlaceOrPopulateResponseStatus()
bool operations_research::ExtractValidMPModelInPlaceOrPopulateResponseStatus | ( | MPModelRequest * | request, |
MPSolutionResponse * | response | ||
) |
Like ExtractValidMPModelOrPopulateResponseStatus(), but works in-place: if the MPModel needed extraction, it will be populated in the request, and it returns the success boolean.
◆ ExtractValidMPModelOrPopulateResponseStatus()
absl::optional<LazyMutableCopy<MPModelProto> > operations_research::ExtractValidMPModelOrPopulateResponseStatus | ( | const MPModelRequest & | request, |
MPSolutionResponse * | response | ||
) |
If the model is valid and non-empty, returns it (possibly after extracting the model_delta).
If invalid or empty, updates response
and returns null.
◆ FindErrorInMPModelDeltaProto()
std::string operations_research::FindErrorInMPModelDeltaProto | ( | const MPModelDeltaProto & | delta, |
const MPModelProto & | model | ||
) |
Like FindErrorInMPModelProto, but for a MPModelDeltaProto applied to a given baseline model (assumed valid, eg.
FindErrorInMPModelProto(model)=""). Works in O(|model_delta|) + O(num_vars in model), but the latter term has a very small constant factor.
◆ FindErrorInMPModelProto()
std::string operations_research::FindErrorInMPModelProto | ( | const MPModelProto & | model, |
double | abs_value_threshold = 0.0 |
||
) |
Returns an empty string iff the model is valid and not trivially infeasible.
Otherwise, returns a description of the first error or trivial infeasibility encountered.
abs_value_threshold is the (exclusive) limit for the abs value of constraint coefficients, objective coefficients, etc. If unspecified, or 0, it defaults to FLAGS_model_validator_infinity.
NOTE(user): the code of this method (and the client code too!) is considerably simplified by this string-based, simple API. If clients require it, we could add a formal error status enum.
◆ FindFeasibilityErrorInSolutionHint()
std::string operations_research::FindFeasibilityErrorInSolutionHint | ( | const MPModelProto & | model, |
double | tolerance | ||
) |
Returns an empty string if the solution hint given in the model is a feasible solution.
Otherwise, returns a description of the first reason for infeasibility.
This function can be useful for debugging/checking that the given solution hint is feasible when it is expected to be the case. The feasibility is checked up to the given tolerance using the ::operations_research::IsLowerWithinTolerance() function.
◆ MergeMPConstraintProtoExceptTerms()
void operations_research::MergeMPConstraintProtoExceptTerms | ( | const MPConstraintProto & | from, |
MPConstraintProto * | to | ||
) |
◆ MPModelRequest_SolverType_descriptor()
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* operations_research::MPModelRequest_SolverType_descriptor | ( | ) |
◆ MPModelRequest_SolverType_IsValid()
bool operations_research::MPModelRequest_SolverType_IsValid | ( | int | value | ) |
◆ MPModelRequest_SolverType_Name()
|
inline |
Definition at line 215 of file linear_solver.pb.h.
◆ MPModelRequest_SolverType_Parse()
|
inline |
Definition at line 222 of file linear_solver.pb.h.
◆ MPSolverCommonParameters_LPAlgorithmValues_descriptor()
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* operations_research::MPSolverCommonParameters_LPAlgorithmValues_descriptor | ( | ) |
◆ MPSolverCommonParameters_LPAlgorithmValues_IsValid()
bool operations_research::MPSolverCommonParameters_LPAlgorithmValues_IsValid | ( | int | value | ) |
◆ MPSolverCommonParameters_LPAlgorithmValues_Name()
|
inline |
Definition at line 179 of file linear_solver.pb.h.
◆ MPSolverCommonParameters_LPAlgorithmValues_Parse()
|
inline |
Definition at line 186 of file linear_solver.pb.h.
◆ MPSolverResponseStatus_descriptor()
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* operations_research::MPSolverResponseStatus_descriptor | ( | ) |
◆ MPSolverResponseStatus_IsValid()
bool operations_research::MPSolverResponseStatus_IsValid | ( | int | value | ) |
◆ MPSolverResponseStatus_Name()
|
inline |
Definition at line 248 of file linear_solver.pb.h.
◆ MPSolverResponseStatus_Parse()
|
inline |
Definition at line 255 of file linear_solver.pb.h.
◆ MPSolverResponseStatusIsRpcError()
bool operations_research::MPSolverResponseStatusIsRpcError | ( | MPSolverResponseStatus | status | ) |
◆ MPSosConstraint_Type_descriptor()
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* operations_research::MPSosConstraint_Type_descriptor | ( | ) |
◆ MPSosConstraint_Type_IsValid()
bool operations_research::MPSosConstraint_Type_IsValid | ( | int | value | ) |
◆ MPSosConstraint_Type_Name()
|
inline |
Definition at line 154 of file linear_solver.pb.h.
◆ MPSosConstraint_Type_Parse()
|
inline |
Definition at line 161 of file linear_solver.pb.h.
◆ operator*() [1/2]
LinearExpr operations_research::operator* | ( | double | lhs, |
LinearExpr | rhs | ||
) |
◆ operator*() [2/2]
LinearExpr operations_research::operator* | ( | LinearExpr | lhs, |
double | rhs | ||
) |
◆ operator+()
LinearExpr operations_research::operator+ | ( | LinearExpr | lhs, |
const LinearExpr & | rhs | ||
) |
◆ operator-()
LinearExpr operations_research::operator- | ( | LinearExpr | lhs, |
const LinearExpr & | rhs | ||
) |
◆ operator/()
LinearExpr operations_research::operator/ | ( | LinearExpr | lhs, |
double | rhs | ||
) |
◆ operator<<() [1/3]
|
inline |
Definition at line 903 of file linear_solver.h.
◆ operator<<() [2/3]
|
inline |
Definition at line 909 of file linear_solver.h.
◆ operator<<() [3/3]
std::ostream& operations_research::operator<< | ( | std::ostream & | stream, |
const LinearExpr & | linear_expr | ||
) |
◆ operator<=()
LinearRange operations_research::operator<= | ( | const LinearExpr & | lhs, |
const LinearExpr & | rhs | ||
) |
◆ operator==()
LinearRange operations_research::operator== | ( | const LinearExpr & | lhs, |
const LinearExpr & | rhs | ||
) |
◆ operator>=()
LinearRange operations_research::operator>= | ( | const LinearExpr & | lhs, |
const LinearExpr & | rhs | ||
) |
◆ SolverTypeIsMip() [1/2]
bool operations_research::SolverTypeIsMip | ( | MPModelRequest::SolverType | solver_type | ) |
◆ SolverTypeIsMip() [2/2]
|
inline |
Definition at line 896 of file linear_solver.h.
◆ ToString()
const absl::string_view operations_research::ToString | ( | MPSolver::OptimizationProblemType | optimization_problem_type | ) |
Variable Documentation
◆ _MPAbsConstraint_default_instance_
|
extern |
◆ _MPArrayConstraint_default_instance_
|
extern |
◆ _MPArrayWithConstantConstraint_default_instance_
|
extern |
◆ _MPConstraintProto_default_instance_
|
extern |
◆ _MPGeneralConstraintProto_default_instance_
|
extern |
◆ _MPIndicatorConstraint_default_instance_
|
extern |
◆ _MPModelDeltaProto_ConstraintOverridesEntry_DoNotUse_default_instance_
|
extern |
◆ _MPModelDeltaProto_default_instance_
|
extern |
◆ _MPModelDeltaProto_VariableOverridesEntry_DoNotUse_default_instance_
|
extern |
◆ _MPModelProto_default_instance_
|
extern |
◆ _MPModelRequest_default_instance_
|
extern |
◆ _MPQuadraticConstraint_default_instance_
|
extern |
◆ _MPQuadraticObjective_default_instance_
|
extern |
◆ _MPSolutionResponse_default_instance_
|
extern |
◆ _MPSolverCommonParameters_default_instance_
|
extern |
◆ _MPSosConstraint_default_instance_
|
extern |
◆ _MPVariableProto_default_instance_
|
extern |
◆ _OptionalDouble_default_instance_
|
extern |
◆ _PartialVariableAssignment_default_instance_
|
extern |
◆ kDefaultPrimalTolerance
|
constexpr |
Definition at line 164 of file linear_solver.h.
◆ MPModelRequest_SolverType_SolverType_ARRAYSIZE
|
constexpr |
Definition at line 211 of file linear_solver.pb.h.
◆ MPModelRequest_SolverType_SolverType_MAX
|
constexpr |
Definition at line 210 of file linear_solver.pb.h.
◆ MPModelRequest_SolverType_SolverType_MIN
|
constexpr |
Definition at line 209 of file linear_solver.pb.h.
◆ MPSolverCommonParameters_LPAlgorithmValues_LPAlgorithmValues_ARRAYSIZE
|
constexpr |
Definition at line 175 of file linear_solver.pb.h.
◆ MPSolverCommonParameters_LPAlgorithmValues_LPAlgorithmValues_MAX
|
constexpr |
Definition at line 174 of file linear_solver.pb.h.
◆ MPSolverCommonParameters_LPAlgorithmValues_LPAlgorithmValues_MIN
|
constexpr |
Definition at line 173 of file linear_solver.pb.h.
◆ MPSolverResponseStatus_ARRAYSIZE
|
constexpr |
Definition at line 244 of file linear_solver.pb.h.
◆ MPSolverResponseStatus_MAX
|
constexpr |
Definition at line 243 of file linear_solver.pb.h.
◆ MPSolverResponseStatus_MIN
|
constexpr |
Definition at line 242 of file linear_solver.pb.h.
◆ MPSosConstraint_Type_Type_ARRAYSIZE
|
constexpr |
Definition at line 150 of file linear_solver.pb.h.
◆ MPSosConstraint_Type_Type_MAX
|
constexpr |
Definition at line 149 of file linear_solver.pb.h.
◆ MPSosConstraint_Type_Type_MIN
|
constexpr |
Definition at line 148 of file linear_solver.pb.h.