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);
410 return main_research_linear_solverJNI.MPSolver_loadModelFromProto(swigCPtr, this, input_model.toByteArray());
413 public String loadModelFromProtoWithUniqueNamesOrDie(com.google.ortools.linearsolver.MPModelProto input_model) {
414 return main_research_linear_solverJNI.MPSolver_loadModelFromProtoWithUniqueNamesOrDie(swigCPtr, this, input_model.toByteArray());
437 byte[] buf = main_research_linear_solverJNI.MPSolver_createSolutionResponseProto(swigCPtr, this);
480 public boolean loadSolutionFromProto(com.google.ortools.linearsolver.MPSolutionResponse response) {
481 return main_research_linear_solverJNI.MPSolver_loadSolutionFromProto(swigCPtr, this, response.toByteArray());
487 public static com.google.ortools.linearsolver.MPSolutionResponse solveWithProto(com.google.ortools.linearsolver.MPModelRequest model_request) {
488 byte[] buf = main_research_linear_solverJNI.MPSolver_solveWithProto(model_request.toByteArray());
504 return main_research_linear_solverJNI.MPSolver_exportModelAsLpFormat__SWIG_0(swigCPtr, this, MPModelExportOptions.getCPtr(options), options);
518 return main_research_linear_solverJNI.MPSolver_exportModelAsMpsFormat__SWIG_0(swigCPtr, this, MPModelExportOptions.getCPtr(options), options);
570 CBC_MIXED_INTEGER_PROGRAMMING(main_research_linear_solverJNI.MPSolver_CBC_MIXED_INTEGER_PROGRAMMING_get()),
586 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
591 throw new IllegalArgumentException("No enum " + OptimizationProblemType.class + " with value " + swigValue);
656 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
661 throw new IllegalArgumentException("No enum " + ResultStatus.class + " with value " + swigValue);
705 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
710 throw new IllegalArgumentException("No enum " + BasisStatus.class + " with value " + swigValue);
boolean interruptSolve()
Interrupts the Solve() execution to terminate processing if possible.
Definition: MPSolver.java:316
final int swigValue()
Definition: MPSolver.java:699
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
FIXED_VALUE
Definition: MPSolver.java:696
MPVariable lookupVariableOrNull(String var_name)
Looks up a variable by name, and returns nullptr if it does not exist.
Definition: MPSolver.java:136
com.google.ortools.linearsolver.MPSolutionResponse createSolutionResponseProto()
Fills the solution found to a response proto and returns it.
Definition: MPSolver.java:436
MPVariable[] makeVarArray(int count, double lb, double ub, boolean integer)
Creates and returns an array of variables.
Definition: MPSolver.java:48
This class stores parameter settings for LP and MIP solvers.
Definition: MPSolverParameters.java:39
GLOP_LINEAR_PROGRAMMING
Linear Programming solver using GLOP (Recommended solver).
Definition: MPSolver.java:566
Protobuf type.
Definition: MPSolutionResponse.java:12
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:409
void setHint(MPVariable[] variables, double[] values)
Sets a hint for solution.
Definition: MPSolver.java:541
boolean setSolverSpecificParametersAsString(String parameters)
Advanced usage: pass solver specific parameters in text format.
Definition: MPSolver.java:326
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:487
AT_UPPER_BOUND
Definition: MPSolver.java:695
MPVariable makeNumVar(double lb, double ub, String name)
Creates a continuous variable.
Definition: MPSolver.java:156
MPConstraint makeConstraint(double lb, double ub, String name)
Creates a named constraint with given bounds.
Definition: MPSolver.java:229
MPConstraint[] constraints()
Returns the array of constraints handled by the MPSolver.
Definition: MPSolver.java:189
Advanced usage: possible basis status values for a variable and the slack variable of a linear const...
Definition: MPSolver.java:692
static com.google.ortools.linearsolver.MPSolutionResponse parseFrom(java.nio.ByteBuffer data)
Definition: MPSolutionResponse.java:701
static BasisStatus swigToEnum(int swigValue)
Definition: MPSolver.java:703
MPVariable[] makeIntVarArray(int count, double lb, double ub)
Definition: MPSolver.java:76
boolean verifySolution(double tolerance, boolean log_errors)
Advanced usage: Verifies the correctness of the solution.
Definition: MPSolver.java:292
MPSolver(long cPtr, boolean cMemoryOwn)
Definition: MPSolver.java:21
MPVariable[] makeNumVarArray(int count, double lb, double ub)
Definition: MPSolver.java:68
double[] computeConstraintActivities()
Advanced usage: compute the "activities" of all constraints, which are the sums of their linear term...
Definition: MPSolver.java:270
void reset()
Advanced usage: resets extracted model to solve from scratch.
Definition: MPSolver.java:304
The status of solving the problem.
Definition: MPSolver.java:624
boolean setNumThreads(int num_theads)
Sets the number of threads to be used by the solver.
Definition: MPSolver.java:548
The class for constraints of a Mathematical Programming (MP) model.
Definition: MPConstraint.java:18
MPConstraint makeConstraint(double lb, double ub)
Creates a linear constraint with given bounds.
Definition: MPSolver.java:213
void setTimeLimit(long time_limit_milliseconds)
Definition: MPSolver.java:397
static OptimizationProblemType swigToEnum(int swigValue)
Definition: MPSolver.java:584
MPConstraint makeConstraint()
Creates a constraint with -infinity and +infinity bounds.
Definition: MPSolver.java:221
AT_LOWER_BOUND
Definition: MPSolver.java:694
MPVariable[] makeNumVarArray(int count, double lb, double ub, String var_name)
Definition: MPSolver.java:72
String loadModelFromProtoWithUniqueNamesOrDie(com.google.ortools.linearsolver.MPModelProto input_model)
Definition: MPSolver.java:413
static ResultStatus swigToEnum(int swigValue)
Definition: MPSolver.java:654
final int swigValue()
Definition: MPSolver.java:580
MPVariable makeIntVar(double lb, double ub, String name)
Creates an integer variable.
Definition: MPSolver.java:164
The type of problems (LP or MIP) that will be solved and the underlying solver (GLOP,...
Definition: MPSolver.java:558
CBC_MIXED_INTEGER_PROGRAMMING
Mixed integer Programming Solver using Coin CBC.
Definition: MPSolver.java:570
long nodes()
Returns the number of branch-and-bound nodes evaluated during the solve.
Definition: MPSolver.java:365
void clear()
Clears the objective (including the optimization direction), all variables and constraints.
Definition: MPSolver.java:112
String exportModelAsLpFormat(MPModelExportOptions options)
Export the loaded model in LP format.
Definition: MPSolver.java:503
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
MPVariable[] makeBoolVarArray(int count)
Definition: MPSolver.java:84
A class to express a linear objective.
Definition: MPObjective.java:16
MPVariable[] variables()
Returns the array of variables handled by the MPSolver.
Definition: MPSolver.java:127
MPVariable[] makeBoolVarArray(int count, String var_name)
Definition: MPSolver.java:88
com.google.ortools.linearsolver.MPModelProto exportModelToProto()
Export the loaded model to proto and returns it.
Definition: MPSolver.java:420
MPSolver(String name, MPSolver.OptimizationProblemType problem_type)
Create a solver with the given name and underlying solver backend.
Definition: MPSolver.java:95
String exportModelAsMpsFormat(MPModelExportOptions options)
Export the loaded model in MPS format.
Definition: MPSolver.java:517
MPConstraint makeConstraint(String name)
Creates a named constraint with -infinity and +infinity bounds.
Definition: MPSolver.java:237
The class for variables of a Mathematical Programming (MP) model.
Definition: MPVariable.java:16
static com.google.ortools.linearsolver.MPModelProto parseFrom(java.nio.ByteBuffer data)
Definition: MPModelProto.java:748
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
MPVariable[] makeIntVarArray(int count, double lb, double ub, String var_name)
Definition: MPSolver.java:80
final int swigValue()
Definition: MPSolver.java:650
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:480
MPSolver.ResultStatus solve(MPSolverParameters param)
Solves the problem using the specified parameter values.
Definition: MPSolver.java:260
Export options.
Definition: MPModelExportOptions.java:16
MPConstraint lookupConstraintOrNull(String constraint_name)
Looks up a constraint by name, and returns nullptr if it does not exist.
Definition: MPSolver.java:200
double computeExactConditionNumber()
Advanced usage: computes the exact condition number of the current scaled basis: L1norm(B) * L1norm(...
Definition: MPSolver.java:393
MPSolver.ResultStatus solve()
Solves the problem using the default parameter values.
Definition: MPSolver.java:253
This mathematical programming (MP) solver class is the main class though which users build and solve...
Definition: MPSolver.java:17
SAT_INTEGER_PROGRAMMING
SAT based solver (requires only integer and Boolean variables).
Definition: MPSolver.java:578