C++ Reference: class MPSolver

Note: This documentation is automatically generated.

Method
ClampSolutionWithinBounds

Return type: absl::Status

Clear

Return type: void

ComputeConstraintActivities

Return type: std::vector<double>

ComputeExactConditionNumber

Return type: double

constraint

Return type: MPConstraint*

Arguments: int index

constraints

Return type: const std::vector<MPConstraint*>&

CreateSolver

Return type: static MPSolver*

Arguments: const std::string& solver_id

DurationSinceConstruction

Return type: absl::Duration

EnableOutput

Return type: void

Enables solver logging.

ExportModelAsLpFormat

Return type: bool

Arguments: bool obfuscate, std::string* model_str

ExportModelAsMpsFormat

Return type: bool

Arguments: bool fixed_format, bool obfuscate, std::string* model_str

ExportModelToProto

Return type: void

Arguments: MPModelProto* output_model

Exports model to protocol buffer.

FillSolutionResponseProto

Return type: void

Arguments: MPSolutionResponse* response

Encodes the current solution in a solution response protocol buffer.

GetNumThreads

Return type: int

Returns the number of threads to be used during solve.

GetSolverSpecificParametersAsString

Return type: std::string

global_num_constraints

Return type: static int64_t

global_num_variables

Return type: static int64_t

Global counters of variables and constraints ever created across all MPSolver instances. Those are only updated after the destruction (or Clear()) of each MPSolver instance.

infinity

Return type: static double

InterruptSolve

Return type: bool

IsMIP

Return type: bool

iterations

Return type: int64_t

Returns the number of simplex iterations.

LoadModelFromProto

Return type: MPSolverResponseStatus

Arguments: const MPModelProto& input_model, std::string* error_message

LoadModelFromProtoWithUniqueNamesOrDie

Return type: MPSolverResponseStatus

Arguments: const MPModelProto& input_model, std::string* error_message

LoadSolutionFromProto

Return type: absl::Status

Arguments: const MPSolutionResponse& response, double tolerance = std::numeric_limits<double>::infinity()

LookupConstraintOrNull

Return type: MPConstraint*

Arguments: const std::string& constraint_name

LookupVariableOrNull

Return type: MPVariable*

Arguments: const std::string& var_name

MakeBoolVar

Return type: MPVariable*

Arguments: const std::string& name

Creates a boolean variable.

MakeBoolVarArray

Return type: void

Arguments: int nb, const std::string& name, std::vector<MPVariable*>* vars

Creates an array of boolean variables.

MakeIntVar

Return type: MPVariable*

Arguments: double lb, double ub, const std::string& name

Creates an integer variable.

MakeIntVarArray

Return type: void

Arguments: int nb, double lb, double ub, const std::string& name, std::vector<MPVariable*>* vars

Creates an array of integer variables.

MakeNumVar

Return type: MPVariable*

Arguments: double lb, double ub, const std::string& name

Creates a continuous variable.

MakeNumVarArray

Return type: void

Arguments: int nb, double lb, double ub, const std::string& name, std::vector<MPVariable*>* vars

Creates an array of continuous variables.

MakeRowConstraint

Return type: MPConstraint*

Arguments: double lb, double ub

MakeRowConstraint

Return type: MPConstraint*

Creates a constraint with -infinity and +infinity bounds.

MakeRowConstraint

Return type: MPConstraint*

Arguments: double lb, double ub, const std::string& name

Creates a named constraint with given bounds.

MakeRowConstraint

Return type: MPConstraint*

Arguments: const std::string& name

Creates a named constraint with -infinity and +infinity bounds.

MakeRowConstraint

Return type: MPConstraint*

Arguments: const LinearRange& range

MakeRowConstraint

Return type: MPConstraint*

Arguments: const LinearRange& range, const std::string& name

As above, but also names the constraint.

MakeVar

Return type: MPVariable*

Arguments: double lb, double ub, bool integer, const std::string& name

MakeVarArray

Return type: void

Arguments: int nb, double lb, double ub, bool integer, const std::string& name_prefix, std::vector<MPVariable*>* vars

MPSolver

Arguments: const std::string& name, OptimizationProblemType problem_type

Create a solver with the given name and underlying solver backend.

~MPSolver

Return type: virtual

MutableObjective

Return type: MPObjective*

Returns the mutable objective object.

Name

Return type: const std::string&

Returns the name of the model set at construction.

NextSolution

Return type: ABSL_MUST_USE_RESULT bool

nodes

Return type: int64_t

NumConstraints

Return type: int

Returns the number of constraints.

NumVariables

Return type: int

Returns the number of variables.

Objective

Return type: const MPObjective&

OutputIsEnabled

Return type: bool

OwnsVariable

Return type: bool

Arguments: const MPVariable* var

Debugging: verify that the given MPVariable* belongs to this solver.

ParseSolverType

Return type: static bool

Arguments: absl::string_view solver_id, OptimizationProblemType* type

ParseSolverTypeOrDie

Return type: static OptimizationProblemType

Arguments: const std::string& solver_id

ProblemType

Return type: virtual OptimizationProblemType

Returns the optimization problem type set at construction.

Reset

Return type: void

set_time_limit

Return type: void

Arguments: int64_t time_limit_milliseconds

SetCallback

Return type: void

Arguments: MPCallback* mp_callback

Does not take ownership of "mp_callback". As of 2019-10-22, only SCIP and Gurobi support Callbacks. SCIP does not support suggesting a heuristic solution in the callback. See go/mpsolver-callbacks for additional documentation.

SetHint

Return type: void

Arguments: std::vector<std::pair<const MPVariable*, double> > hint

SetNumThreads

Return type: absl::Status

Arguments: int num_threads

SetSolverSpecificParametersAsString

Return type: bool

Arguments: const std::string& parameters

SetStartingLpBasis

Return type: void

Arguments: const std::vector<MPSolver::BasisStatus>& variable_statuses, const std::vector<MPSolver::BasisStatus>& constraint_statuses

SetTimeLimit

Return type: void

Arguments: absl::Duration time_limit

Solve

Return type: ResultStatus

Solves the problem using the default parameter values.

Solve

Return type: ResultStatus

Arguments: const MPSolverParameters& param

Solves the problem using the specified parameter values.

SolverTypeSupportsInterruption

Return type: static bool

Arguments: const MPModelRequest::SolverType solver

SolverVersion

Return type: std::string

Returns a string describing the underlying solver and its version.

SolveWithProto

Return type: static void

Arguments: const MPModelRequest& model_request, MPSolutionResponse* response, // `interrupt` is non-const because the internal // solver may set it to true itself, in some cases. std::atomic<bool>* interrupt = nullptr

SupportsCallbacks

Return type: bool

SupportsProblemType

Return type: static bool

Arguments: OptimizationProblemType problem_type

SuppressOutput

Return type: void

Suppresses solver logging.

time_limit

Return type: int64_t

DEPRECATED: Use TimeLimit() and SetTimeLimit(absl::Duration) instead. NOTE: These deprecated functions used the convention time_limit = 0 to mean "no limit", which now corresponds to time_limit_ = InfiniteDuration().

time_limit_in_secs

Return type: double

TimeLimit

Return type: absl::Duration

underlying_solver

Return type: void*

variable

Return type: MPVariable*

Arguments: int index

variables

Return type: const std::vector<MPVariable*>&

VerifySolution

Return type: bool

Arguments: double tolerance, bool log_errors

wall_time

Return type: int64_t

DEPRECATED: Use DurationSinceConstruction() instead.

Write

Return type: void

Arguments: const std::string& file_name