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) |
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 (const std::string &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 (const std::string &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 (const std::string &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 (const std::string &name, MPSolverResponseStatus *value) |
Enumeration Type Documentation
◆ MPModelRequest_SolverType
enum MPModelRequest_SolverType : int |
Definition at line 192 of file linear_solver.pb.h.
◆ MPSolverCommonParameters_LPAlgorithmValues
enum MPSolverCommonParameters_LPAlgorithmValues : int |
Definition at line 167 of file linear_solver.pb.h.
◆ MPSolverResponseStatus
enum MPSolverResponseStatus : int |
Definition at line 228 of file linear_solver.pb.h.
◆ MPSosConstraint_Type
enum MPSosConstraint_Type : int |
Enumerator | |
---|---|
MPSosConstraint_Type_SOS1_DEFAULT | |
MPSosConstraint_Type_SOS2 |
Definition at line 144 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 884 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()
std::string operations_research::ExportModelAsLpFormatReturnString | ( | const MPModelProto & | input_model, |
const MPModelExportOptions & | options = MPModelExportOptions() |
||
) |
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()
std::string operations_research::ExportModelAsMpsFormatReturnString | ( | const MPModelProto & | input_model, |
const MPModelExportOptions & | options = MPModelExportOptions() |
||
) |
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 | ) |
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.
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 216 of file linear_solver.pb.h.
◆ MPModelRequest_SolverType_Parse()
|
inline |
Definition at line 223 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 180 of file linear_solver.pb.h.
◆ MPSolverCommonParameters_LPAlgorithmValues_Parse()
|
inline |
Definition at line 187 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 249 of file linear_solver.pb.h.
◆ MPSolverResponseStatus_Parse()
|
inline |
Definition at line 256 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 155 of file linear_solver.pb.h.
◆ MPSosConstraint_Type_Parse()
|
inline |
Definition at line 162 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 868 of file linear_solver.h.
◆ operator<<() [2/3]
|
inline |
Definition at line 874 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 861 of file linear_solver.h.
◆ ToString()
const absl::string_view operations_research::ToString | ( | MPSolver::OptimizationProblemType | optimization_problem_type | ) |
Variable Documentation
◆ _MPAbsConstraint_default_instance_
MPAbsConstraintDefaultTypeInternal _MPAbsConstraint_default_instance_ |
◆ _MPArrayConstraint_default_instance_
MPArrayConstraintDefaultTypeInternal _MPArrayConstraint_default_instance_ |
◆ _MPArrayWithConstantConstraint_default_instance_
MPArrayWithConstantConstraintDefaultTypeInternal _MPArrayWithConstantConstraint_default_instance_ |
◆ _MPConstraintProto_default_instance_
MPConstraintProtoDefaultTypeInternal _MPConstraintProto_default_instance_ |
◆ _MPGeneralConstraintProto_default_instance_
MPGeneralConstraintProtoDefaultTypeInternal _MPGeneralConstraintProto_default_instance_ |
◆ _MPIndicatorConstraint_default_instance_
MPIndicatorConstraintDefaultTypeInternal _MPIndicatorConstraint_default_instance_ |
◆ _MPModelDeltaProto_ConstraintOverridesEntry_DoNotUse_default_instance_
MPModelDeltaProto_ConstraintOverridesEntry_DoNotUseDefaultTypeInternal _MPModelDeltaProto_ConstraintOverridesEntry_DoNotUse_default_instance_ |
◆ _MPModelDeltaProto_default_instance_
MPModelDeltaProtoDefaultTypeInternal _MPModelDeltaProto_default_instance_ |
◆ _MPModelDeltaProto_VariableOverridesEntry_DoNotUse_default_instance_
MPModelDeltaProto_VariableOverridesEntry_DoNotUseDefaultTypeInternal _MPModelDeltaProto_VariableOverridesEntry_DoNotUse_default_instance_ |
◆ _MPModelProto_default_instance_
MPModelProtoDefaultTypeInternal _MPModelProto_default_instance_ |
◆ _MPModelRequest_default_instance_
MPModelRequestDefaultTypeInternal _MPModelRequest_default_instance_ |
◆ _MPQuadraticConstraint_default_instance_
MPQuadraticConstraintDefaultTypeInternal _MPQuadraticConstraint_default_instance_ |
◆ _MPQuadraticObjective_default_instance_
MPQuadraticObjectiveDefaultTypeInternal _MPQuadraticObjective_default_instance_ |
◆ _MPSolutionResponse_default_instance_
MPSolutionResponseDefaultTypeInternal _MPSolutionResponse_default_instance_ |
◆ _MPSolverCommonParameters_default_instance_
MPSolverCommonParametersDefaultTypeInternal _MPSolverCommonParameters_default_instance_ |
◆ _MPSosConstraint_default_instance_
MPSosConstraintDefaultTypeInternal _MPSosConstraint_default_instance_ |
◆ _MPVariableProto_default_instance_
MPVariableProtoDefaultTypeInternal _MPVariableProto_default_instance_ |
◆ _OptionalDouble_default_instance_
OptionalDoubleDefaultTypeInternal _OptionalDouble_default_instance_ |
◆ _PartialVariableAssignment_default_instance_
PartialVariableAssignmentDefaultTypeInternal _PartialVariableAssignment_default_instance_ |
◆ kDefaultPrimalTolerance
|
constexpr |
Definition at line 162 of file linear_solver.h.
◆ MPModelRequest_SolverType_SolverType_ARRAYSIZE
|
constexpr |
Definition at line 212 of file linear_solver.pb.h.
◆ MPModelRequest_SolverType_SolverType_MAX
|
constexpr |
Definition at line 211 of file linear_solver.pb.h.
◆ MPModelRequest_SolverType_SolverType_MIN
|
constexpr |
Definition at line 210 of file linear_solver.pb.h.
◆ MPSolverCommonParameters_LPAlgorithmValues_LPAlgorithmValues_ARRAYSIZE
|
constexpr |
Definition at line 176 of file linear_solver.pb.h.
◆ MPSolverCommonParameters_LPAlgorithmValues_LPAlgorithmValues_MAX
|
constexpr |
Definition at line 175 of file linear_solver.pb.h.
◆ MPSolverCommonParameters_LPAlgorithmValues_LPAlgorithmValues_MIN
|
constexpr |
Definition at line 174 of file linear_solver.pb.h.
◆ MPSolverResponseStatus_ARRAYSIZE
|
constexpr |
Definition at line 245 of file linear_solver.pb.h.
◆ MPSolverResponseStatus_MAX
|
constexpr |
Definition at line 244 of file linear_solver.pb.h.
◆ MPSolverResponseStatus_MIN
|
constexpr |
Definition at line 243 of file linear_solver.pb.h.
◆ MPSosConstraint_Type_Type_ARRAYSIZE
|
constexpr |
Definition at line 151 of file linear_solver.pb.h.
◆ MPSosConstraint_Type_Type_MAX
|
constexpr |
Definition at line 150 of file linear_solver.pb.h.
◆ MPSosConstraint_Type_Type_MIN
|
constexpr |
Definition at line 149 of file linear_solver.pb.h.