Java Reference
Java Reference
MPSolver.java
Go to the documentation of this file.
174 long cPtr = main_research_linear_solverJNI.MPSolver_lookupVariableOrNull(swigCPtr, this, var_name);
186 long cPtr = main_research_linear_solverJNI.MPSolver_makeVar(swigCPtr, this, lb, ub, integer, name);
238 long cPtr = main_research_linear_solverJNI.MPSolver_lookupConstraintOrNull(swigCPtr, this, constraint_name);
251 long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_0(swigCPtr, this, lb, ub);
267 long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_2(swigCPtr, this, lb, ub, name);
275 long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_3(swigCPtr, this, name);
291 return MPSolver.ResultStatus.swigToEnum(main_research_linear_solverJNI.MPSolver_solve__SWIG_0(swigCPtr, this));
298 return MPSolver.ResultStatus.swigToEnum(main_research_linear_solverJNI.MPSolver_solve__SWIG_1(swigCPtr, this, MPSolverParameters.getCPtr(param), param));
330 return main_research_linear_solverJNI.MPSolver_verifySolution(swigCPtr, this, tolerance, log_errors);
364 return main_research_linear_solverJNI.MPSolver_setSolverSpecificParametersAsString(swigCPtr, this, parameters);
451 return main_research_linear_solverJNI.MPSolver_loadModelFromProto(swigCPtr, this, input_model.toByteArray());
454 public String loadModelFromProtoWithUniqueNamesOrDie(com.google.ortools.linearsolver.MPModelProto input_model) {
455 return main_research_linear_solverJNI.MPSolver_loadModelFromProtoWithUniqueNamesOrDie(swigCPtr, this, input_model.toByteArray());
478 byte[] buf = main_research_linear_solverJNI.MPSolver_createSolutionResponseProto(swigCPtr, this);
521 public boolean loadSolutionFromProto(com.google.ortools.linearsolver.MPSolutionResponse response) {
522 return main_research_linear_solverJNI.MPSolver_loadSolutionFromProto(swigCPtr, this, response.toByteArray());
528 public static com.google.ortools.linearsolver.MPSolutionResponse solveWithProto(com.google.ortools.linearsolver.MPModelRequest model_request) {
529 byte[] buf = main_research_linear_solverJNI.MPSolver_solveWithProto(model_request.toByteArray());
545 return main_research_linear_solverJNI.MPSolver_exportModelAsLpFormat__SWIG_0(swigCPtr, this, MPModelExportOptions.getCPtr(options), options);
559 return main_research_linear_solverJNI.MPSolver_exportModelAsMpsFormat__SWIG_0(swigCPtr, this, MPModelExportOptions.getCPtr(options), options);
603 SCIP_MIXED_INTEGER_PROGRAMMING(main_research_linear_solverJNI.MPSolver_SCIP_MIXED_INTEGER_PROGRAMMING_get()),
604 GLPK_MIXED_INTEGER_PROGRAMMING(main_research_linear_solverJNI.MPSolver_GLPK_MIXED_INTEGER_PROGRAMMING_get()),
605 CBC_MIXED_INTEGER_PROGRAMMING(main_research_linear_solverJNI.MPSolver_CBC_MIXED_INTEGER_PROGRAMMING_get()),
606 GUROBI_LINEAR_PROGRAMMING(main_research_linear_solverJNI.MPSolver_GUROBI_LINEAR_PROGRAMMING_get()),
607 GUROBI_MIXED_INTEGER_PROGRAMMING(main_research_linear_solverJNI.MPSolver_GUROBI_MIXED_INTEGER_PROGRAMMING_get()),
608 CPLEX_LINEAR_PROGRAMMING(main_research_linear_solverJNI.MPSolver_CPLEX_LINEAR_PROGRAMMING_get()),
609 CPLEX_MIXED_INTEGER_PROGRAMMING(main_research_linear_solverJNI.MPSolver_CPLEX_MIXED_INTEGER_PROGRAMMING_get()),
610 XPRESS_LINEAR_PROGRAMMING(main_research_linear_solverJNI.MPSolver_XPRESS_LINEAR_PROGRAMMING_get()),
611 XPRESS_MIXED_INTEGER_PROGRAMMING(main_research_linear_solverJNI.MPSolver_XPRESS_MIXED_INTEGER_PROGRAMMING_get()),
621 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
626 throw new IllegalArgumentException("No enum " + OptimizationProblemType.class + " with value " + swigValue);
691 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
696 throw new IllegalArgumentException("No enum " + ResultStatus.class + " with value " + swigValue);
740 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
745 throw new IllegalArgumentException("No enum " + BasisStatus.class + " with value " + swigValue);
boolean interruptSolve()
Interrupts the Solve() execution to terminate processing if possible.
Definition: MPSolver.java:353
final int swigValue()
Definition: MPSolver.java:734
MPVariable makeVar(double lb, double ub, boolean integer, String name)
Creates a variable with the given bounds, integrality requirement and name.
Definition: MPSolver.java:185
FIXED_VALUE
Definition: MPSolver.java:731
MPVariable lookupVariableOrNull(String var_name)
Looks up a variable by name, and returns nullptr if it does not exist.
Definition: MPSolver.java:173
static MPSolver createSolver(String solver_id)
Recommended factory method to create a MPSolver instance, especially in non C++ languages.
Definition: MPSolver.java:127
com.google.ortools.linearsolver.MPSolutionResponse createSolutionResponseProto()
Fills the solution found to a response proto and returns it.
Definition: MPSolver.java:477
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
Definition: MPSolver.java:602
Protobuf type.
Definition: MPSolutionResponse.java:12
CLP_LINEAR_PROGRAMMING
Definition: MPSolver.java:600
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:450
void setHint(MPVariable[] variables, double[] values)
Sets a hint for solution.
Definition: MPSolver.java:582
boolean setSolverSpecificParametersAsString(String parameters)
Advanced usage: pass solver specific parameters in text format.
Definition: MPSolver.java:363
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:528
AT_UPPER_BOUND
Definition: MPSolver.java:730
MPVariable makeNumVar(double lb, double ub, String name)
Creates a continuous variable.
Definition: MPSolver.java:193
MPConstraint makeConstraint(double lb, double ub, String name)
Creates a named constraint with given bounds.
Definition: MPSolver.java:266
XPRESS_MIXED_INTEGER_PROGRAMMING
Definition: MPSolver.java:611
MPConstraint[] constraints()
Returns the array of constraints handled by the MPSolver.
Definition: MPSolver.java:226
Advanced usage: possible basis status values for a variable and the slack variable of a linear const...
Definition: MPSolver.java:727
static com.google.ortools.linearsolver.MPSolutionResponse parseFrom(java.nio.ByteBuffer data)
Definition: MPSolutionResponse.java:701
GUROBI_MIXED_INTEGER_PROGRAMMING
Definition: MPSolver.java:607
static BasisStatus swigToEnum(int swigValue)
Definition: MPSolver.java:738
GUROBI_LINEAR_PROGRAMMING
Definition: MPSolver.java:606
MPVariable[] makeIntVarArray(int count, double lb, double ub)
Definition: MPSolver.java:76
static void setGurobiLibraryPath(String full_library_path)
Definition: MPSolver.java:442
boolean verifySolution(double tolerance, boolean log_errors)
Advanced usage: Verifies the correctness of the solution.
Definition: MPSolver.java:329
BOP_INTEGER_PROGRAMMING
Definition: MPSolver.java:612
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:307
void reset()
Advanced usage: resets extracted model to solve from scratch.
Definition: MPSolver.java:341
The status of solving the problem.
Definition: MPSolver.java:659
boolean setNumThreads(int num_theads)
Sets the number of threads to be used by the solver.
Definition: MPSolver.java:589
GLPK_LINEAR_PROGRAMMING
Definition: MPSolver.java:601
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:250
void setTimeLimit(long time_limit_milliseconds)
Definition: MPSolver.java:434
CPLEX_LINEAR_PROGRAMMING
Definition: MPSolver.java:608
static OptimizationProblemType swigToEnum(int swigValue)
Definition: MPSolver.java:619
MPConstraint makeConstraint()
Creates a constraint with -infinity and +infinity bounds.
Definition: MPSolver.java:258
GLPK_MIXED_INTEGER_PROGRAMMING
Definition: MPSolver.java:604
AT_LOWER_BOUND
Definition: MPSolver.java:729
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:454
static ResultStatus swigToEnum(int swigValue)
Definition: MPSolver.java:689
final int swigValue()
Definition: MPSolver.java:615
MPVariable makeIntVar(double lb, double ub, String name)
Creates an integer variable.
Definition: MPSolver.java:201
The type of problems (LP or MIP) that will be solved and the underlying solver (GLOP,...
Definition: MPSolver.java:599
SCIP_MIXED_INTEGER_PROGRAMMING
Definition: MPSolver.java:603
CBC_MIXED_INTEGER_PROGRAMMING
Definition: MPSolver.java:605
long nodes()
Returns the number of branch-and-bound nodes evaluated during the solve.
Definition: MPSolver.java:402
void clear()
Clears the objective (including the optimization direction), all variables and constraints.
Definition: MPSolver.java:149
String exportModelAsLpFormat(MPModelExportOptions options)
Export the loaded model in LP format.
Definition: MPSolver.java:544
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:136
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:164
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:461
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:558
MPConstraint makeConstraint(String name)
Creates a named constraint with -infinity and +infinity bounds.
Definition: MPSolver.java:274
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:685
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:521
MPSolver.ResultStatus solve(MPSolverParameters param)
Solves the problem using the specified parameter values.
Definition: MPSolver.java:297
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:237
XPRESS_LINEAR_PROGRAMMING
Definition: MPSolver.java:610
double computeExactConditionNumber()
Advanced usage: computes the exact condition number of the current scaled basis: L1norm(B) * L1norm(...
Definition: MPSolver.java:430
MPSolver.ResultStatus solve()
Solves the problem using the default parameter values.
Definition: MPSolver.java:290
CPLEX_MIXED_INTEGER_PROGRAMMING
Definition: MPSolver.java:609
This mathematical programming (MP) solver class is the main class though which users build and solve...
Definition: MPSolver.java:17
SAT_INTEGER_PROGRAMMING
Definition: MPSolver.java:613