Java Reference
Java Reference
MPSolver.java
Go to the documentation of this file.
137 long cPtr = main_research_linear_solverJNI.MPSolver_lookupVariableOrNull(swigCPtr, this, var_name);
149 long cPtr = main_research_linear_solverJNI.MPSolver_makeVar(swigCPtr, this, lb, ub, integer, name);
201 long cPtr = main_research_linear_solverJNI.MPSolver_lookupConstraintOrNull(swigCPtr, this, constraint_name);
214 long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_0(swigCPtr, this, lb, ub);
230 long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_2(swigCPtr, this, lb, ub, name);
238 long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_3(swigCPtr, this, name);
254 return MPSolver.ResultStatus.swigToEnum(main_research_linear_solverJNI.MPSolver_solve__SWIG_0(swigCPtr, this));
261 return MPSolver.ResultStatus.swigToEnum(main_research_linear_solverJNI.MPSolver_solve__SWIG_1(swigCPtr, this, MPSolverParameters.getCPtr(param), param));
293 return main_research_linear_solverJNI.MPSolver_verifySolution(swigCPtr, this, tolerance, log_errors);
327 return main_research_linear_solverJNI.MPSolver_setSolverSpecificParametersAsString(swigCPtr, this, parameters);
341 public void SetStartingLpBasis(SWIGTYPE_p_std__vectorT_operations_research__MPSolver__BasisStatus_t variable_statuses, SWIGTYPE_p_std__vectorT_operations_research__MPSolver__BasisStatus_t constraint_statuses) {
342 main_research_linear_solverJNI.MPSolver_SetStartingLpBasis(swigCPtr, this, SWIGTYPE_p_std__vectorT_operations_research__MPSolver__BasisStatus_t.getCPtr(variable_statuses), SWIGTYPE_p_std__vectorT_operations_research__MPSolver__BasisStatus_t.getCPtr(constraint_statuses));
425 return main_research_linear_solverJNI.MPSolver_loadModelFromProto(swigCPtr, this, input_model.toByteArray());
428 public String loadModelFromProtoWithUniqueNamesOrDie(com.google.ortools.linearsolver.MPModelProto input_model) {
429 return main_research_linear_solverJNI.MPSolver_loadModelFromProtoWithUniqueNamesOrDie(swigCPtr, this, input_model.toByteArray());
452 byte[] buf = main_research_linear_solverJNI.MPSolver_createSolutionResponseProto(swigCPtr, this);
495 public boolean loadSolutionFromProto(com.google.ortools.linearsolver.MPSolutionResponse response) {
496 return main_research_linear_solverJNI.MPSolver_loadSolutionFromProto(swigCPtr, this, response.toByteArray());
502 public static com.google.ortools.linearsolver.MPSolutionResponse solveWithProto(com.google.ortools.linearsolver.MPModelRequest model_request) {
503 byte[] buf = main_research_linear_solverJNI.MPSolver_solveWithProto(model_request.toByteArray());
519 return main_research_linear_solverJNI.MPSolver_exportModelAsLpFormat__SWIG_0(swigCPtr, this, MPModelExportOptions.getCPtr(options), options);
533 return main_research_linear_solverJNI.MPSolver_exportModelAsMpsFormat__SWIG_0(swigCPtr, this, MPModelExportOptions.getCPtr(options), options);
585 CBC_MIXED_INTEGER_PROGRAMMING(main_research_linear_solverJNI.MPSolver_CBC_MIXED_INTEGER_PROGRAMMING_get()),
597 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
602 throw new IllegalArgumentException("No enum " + OptimizationProblemType.class + " with value " + swigValue);
667 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
672 throw new IllegalArgumentException("No enum " + ResultStatus.class + " with value " + swigValue);
705 AT_LOWER_BOUND,
706 AT_UPPER_BOUND,
707 FIXED_VALUE,
708 BASIC;
716 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
721 throw new IllegalArgumentException("No enum " + BasisStatus.class + " with value " + swigValue);
static ResultStatus swigToEnum(int swigValue)
Definition: MPSolver.java:665
com.google.ortools.linearsolver.MPModelProto exportModelToProto()
Export the loaded model to proto and returns it.
Definition: MPSolver.java:435
void clear()
Clears the objective (including the optimization direction), all variables and constraints.
Definition: MPSolver.java:112
final int swigValue()
Definition: MPSolver.java:591
MPConstraint lookupConstraintOrNull(String constraint_name)
Looks up a constraint by name, and returns nullptr if it does not exist.
Definition: MPSolver.java:200
The class for variables of a Mathematical Programming (MP) model.
Definition: MPVariable.java:16
MPConstraint [] constraints()
Returns the array of constraints handled by the MPSolver.
Definition: MPSolver.java:189
MPVariable [] makeBoolVarArray(int count)
Definition: MPSolver.java:84
Export options.
Definition: MPModelExportOptions.java:16
GLOP_LINEAR_PROGRAMMING
Linear Programming solver using GLOP (Recommended solver).
Definition: MPSolver.java:581
static com.google.ortools.linearsolver.MPSolutionResponse solveWithProto(com.google.ortools.linearsolver.MPModelRequest model_request)
Solves the given model proto and returns a response proto.
Definition: MPSolver.java:502
String exportModelAsLpFormat(MPModelExportOptions options)
Export the loaded model in LP format.
Definition: MPSolver.java:518
MPVariable [] makeIntVarArray(int count, double lb, double ub)
Definition: MPSolver.java:76
static com.google.ortools.linearsolver.MPSolutionResponse parseFrom(java.nio.ByteBuffer data)
Definition: MPSolutionResponse.java:670
MPVariable [] makeIntVarArray(int count, double lb, double ub, String var_name)
Definition: MPSolver.java:80
The status of solving the problem.
Definition: MPSolver.java:635
MPConstraint makeConstraint(double lb, double ub)
Creates a linear constraint with given bounds.
Definition: MPSolver.java:213
final int swigValue()
Definition: MPSolver.java:710
String exportModelAsMpsFormat(MPModelExportOptions options)
Export the loaded model in MPS format.
Definition: MPSolver.java:532
final int swigValue()
Definition: MPSolver.java:661
MPVariable [] variables()
Returns the array of variables handled by the MPSolver.
Definition: MPSolver.java:127
The class for constraints of a Mathematical Programming (MP) model.
Definition: MPConstraint.java:18
long nodes()
Returns the number of branch-and-bound nodes evaluated during the solve.
Definition: MPSolver.java:380
MPVariable [] makeBoolVarArray(int count, String var_name)
Definition: MPSolver.java:88
MPSolver.ResultStatus solve()
Solves the problem using default parameter values.
Definition: MPSolver.java:253
void SetStartingLpBasis(SWIGTYPE_p_std__vectorT_operations_research__MPSolver__BasisStatus_t variable_statuses, SWIGTYPE_p_std__vectorT_operations_research__MPSolver__BasisStatus_t constraint_statuses)
Advanced usage: Incrementality.
Definition: MPSolver.java:341
MPVariable [] makeVarArray(int count, double lb, double ub, boolean integer, String var_name)
Creates and returns an array of named variables.
Definition: MPSolver.java:59
MPConstraint makeConstraint(String name)
Creates a named constraint with -infinity and +infinity bounds.
Definition: MPSolver.java:237
boolean setSolverSpecificParametersAsString(String parameters)
Advanced usage: pass solver specific parameters in text format.
Definition: MPSolver.java:326
static com.google.ortools.linearsolver.MPModelProto parseFrom(java.nio.ByteBuffer data)
Definition: MPModelProto.java:709
MPSolver.ResultStatus solve(MPSolverParameters param)
Solves the problem using the specified parameter values.
Definition: MPSolver.java:260
void setTimeLimit(long time_limit_milliseconds)
Definition: MPSolver.java:412
MPVariable lookupVariableOrNull(String var_name)
Looks up a variable by name, and returns nullptr if it does not exist.
Definition: MPSolver.java:136
This mathematical programming (MP) solver class is the main class though which users build and solve...
Definition: MPSolver.java:17
Protobuf type.
Definition: MPSolutionResponse.java:9
String loadModelFromProtoWithUniqueNamesOrDie(com.google.ortools.linearsolver.MPModelProto input_model)
Definition: MPSolver.java:428
boolean loadSolutionFromProto(com.google.ortools.linearsolver.MPSolutionResponse response)
Load a solution encoded in a protocol buffer onto this solver for easy access via the MPSolver inter...
Definition: MPSolver.java:495
The type of problems (LP or MIP) that will be solved and the underlying solver (GLOP,...
Definition: MPSolver.java:573
Advanced usage: possible basis status values for a variable and the slack variable of a linear const...
Definition: MPSolver.java:703
MPVariable makeIntVar(double lb, double ub, String name)
Creates an integer variable.
Definition: MPSolver.java:164
This class stores parameter settings for LP and MIP solvers.
Definition: MPSolverParameters.java:39
MPConstraint makeConstraint()
Creates a constraint with -infinity and +infinity bounds.
Definition: MPSolver.java:221
static BasisStatus swigToEnum(int swigValue)
Definition: MPSolver.java:714
MPSolver(long cPtr, boolean cMemoryOwn)
Definition: MPSolver.java:21
void reset()
Advanced usage: resets extracted model to solve from scratch.
Definition: MPSolver.java:304
com.google.ortools.linearsolver.MPSolutionResponse createSolutionResponseProto()
Fills the solution found to a response proto and returns it.
Definition: MPSolver.java:451
MPVariable [] makeVarArray(int count, double lb, double ub, boolean integer)
Creates and returns an array of variables.
Definition: MPSolver.java:48
double computeExactConditionNumber()
Advanced usage: computes the exact condition number of the current scaled basis: L1norm(B) * L1norm(...
Definition: MPSolver.java:408
boolean verifySolution(double tolerance, boolean log_errors)
Advanced usage: Verifies the correctness of the solution.
Definition: MPSolver.java:292
A class to express a linear objective.
Definition: MPObjective.java:16
void setHint(MPVariable[] variables, double[] values)
Sets a hint for solution.
Definition: MPSolver.java:556
MPVariable [] makeNumVarArray(int count, double lb, double ub, String var_name)
Definition: MPSolver.java:72
static OptimizationProblemType swigToEnum(int swigValue)
Definition: MPSolver.java:595
String loadModelFromProto(com.google.ortools.linearsolver.MPModelProto input_model)
Loads a model and returns the error message, which will be empty iff the model is valid.
Definition: MPSolver.java:424
MPVariable makeVar(double lb, double ub, boolean integer, String name)
Creates a variable with the given bounds, integrality requirement and name.
Definition: MPSolver.java:148
MPSolver(String name, MPSolver.OptimizationProblemType problem_type)
Create a solver with the given name and underlying solver backend.
Definition: MPSolver.java:95
double [] computeConstraintActivities()
Advanced usage: compute the "activities" of all constraints, which are the sums of their linear term...
Definition: MPSolver.java:270
boolean setNumThreads(int num_theads)
Sets the number of threads to be used by the solver.
Definition: MPSolver.java:563
MPConstraint makeConstraint(double lb, double ub, String name)
Creates a named constraint with given bounds.
Definition: MPSolver.java:229
MPVariable [] makeNumVarArray(int count, double lb, double ub)
Definition: MPSolver.java:68
boolean interruptSolve()
Interrupts the Solve() execution to terminate processing if possible.
Definition: MPSolver.java:316
CBC_MIXED_INTEGER_PROGRAMMING
Mixed integer Programming Solver using Coin CBC.
Definition: MPSolver.java:585
MPVariable makeNumVar(double lb, double ub, String name)
Creates a continuous variable.
Definition: MPSolver.java:156
static boolean supportsProblemType(MPSolver.OptimizationProblemType problem_type)
Whether the given problem type is supported (this will depend on the targets that you linked).
Definition: MPSolver.java:103