Java Reference
Java Reference
MPSolver.java
Go to the documentation of this file.
148 return MPSolver.OptimizationProblemType.swigToEnum(main_research_linear_solverJNI.MPSolver_problemType(swigCPtr, this));
189 long cPtr = main_research_linear_solverJNI.MPSolver_lookupVariableOrNull(swigCPtr, this, var_name);
201 long cPtr = main_research_linear_solverJNI.MPSolver_makeVar(swigCPtr, this, lb, ub, integer, name);
261 long cPtr = main_research_linear_solverJNI.MPSolver_lookupConstraintOrNull(swigCPtr, this, constraint_name);
274 long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_0(swigCPtr, this, lb, ub);
290 long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_2(swigCPtr, this, lb, ub, name);
298 long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_3(swigCPtr, this, name);
314 return MPSolver.ResultStatus.swigToEnum(main_research_linear_solverJNI.MPSolver_solve__SWIG_0(swigCPtr, this));
321 return MPSolver.ResultStatus.swigToEnum(main_research_linear_solverJNI.MPSolver_solve__SWIG_1(swigCPtr, this, MPSolverParameters.getCPtr(param), param));
353 return main_research_linear_solverJNI.MPSolver_verifySolution(swigCPtr, this, tolerance, log_errors);
389 return main_research_linear_solverJNI.MPSolver_setSolverSpecificParametersAsString(swigCPtr, this, parameters);
472 return main_research_linear_solverJNI.MPSolver_loadModelFromProto(swigCPtr, this, input_model.toByteArray());
475 public String loadModelFromProtoWithUniqueNamesOrDie(com.google.ortools.linearsolver.MPModelProto input_model) {
476 return main_research_linear_solverJNI.MPSolver_loadModelFromProtoWithUniqueNamesOrDie(swigCPtr, this, input_model.toByteArray());
499 byte[] buf = main_research_linear_solverJNI.MPSolver_createSolutionResponseProto(swigCPtr, this);
542 public boolean loadSolutionFromProto(com.google.ortools.linearsolver.MPSolutionResponse response) {
543 return main_research_linear_solverJNI.MPSolver_loadSolutionFromProto(swigCPtr, this, response.toByteArray());
549 public static com.google.ortools.linearsolver.MPSolutionResponse solveWithProto(com.google.ortools.linearsolver.MPModelRequest model_request) {
550 byte[] buf = main_research_linear_solverJNI.MPSolver_solveWithProto(model_request.toByteArray());
566 return main_research_linear_solverJNI.MPSolver_exportModelAsLpFormat__SWIG_0(swigCPtr, this, MPModelExportOptions.getCPtr(options), options);
580 return main_research_linear_solverJNI.MPSolver_exportModelAsMpsFormat__SWIG_0(swigCPtr, this, MPModelExportOptions.getCPtr(options), options);
624 SCIP_MIXED_INTEGER_PROGRAMMING(main_research_linear_solverJNI.MPSolver_SCIP_MIXED_INTEGER_PROGRAMMING_get()),
625 GLPK_MIXED_INTEGER_PROGRAMMING(main_research_linear_solverJNI.MPSolver_GLPK_MIXED_INTEGER_PROGRAMMING_get()),
626 CBC_MIXED_INTEGER_PROGRAMMING(main_research_linear_solverJNI.MPSolver_CBC_MIXED_INTEGER_PROGRAMMING_get()),
627 GUROBI_LINEAR_PROGRAMMING(main_research_linear_solverJNI.MPSolver_GUROBI_LINEAR_PROGRAMMING_get()),
628 GUROBI_MIXED_INTEGER_PROGRAMMING(main_research_linear_solverJNI.MPSolver_GUROBI_MIXED_INTEGER_PROGRAMMING_get()),
629 CPLEX_LINEAR_PROGRAMMING(main_research_linear_solverJNI.MPSolver_CPLEX_LINEAR_PROGRAMMING_get()),
630 CPLEX_MIXED_INTEGER_PROGRAMMING(main_research_linear_solverJNI.MPSolver_CPLEX_MIXED_INTEGER_PROGRAMMING_get()),
631 XPRESS_LINEAR_PROGRAMMING(main_research_linear_solverJNI.MPSolver_XPRESS_LINEAR_PROGRAMMING_get()),
632 XPRESS_MIXED_INTEGER_PROGRAMMING(main_research_linear_solverJNI.MPSolver_XPRESS_MIXED_INTEGER_PROGRAMMING_get()),
642 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
647 throw new IllegalArgumentException("No enum " + OptimizationProblemType.class + " with value " + swigValue);
712 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
717 throw new IllegalArgumentException("No enum " + ResultStatus.class + " with value " + swigValue);
750 AT_LOWER_BOUND,
751 AT_UPPER_BOUND,
752 FIXED_VALUE,
753 BASIC;
761 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
766 throw new IllegalArgumentException("No enum " + BasisStatus.class + " with value " + swigValue);
static ResultStatus swigToEnum(int swigValue)
Definition: MPSolver.java:710
com.google.ortools.linearsolver.MPModelProto exportModelToProto()
Export the loaded model to proto and returns it.
Definition: MPSolver.java:482
void clear()
Clears the objective (including the optimization direction), all variables and constraints.
Definition: MPSolver.java:156
final int swigValue()
Definition: MPSolver.java:636
MPConstraint lookupConstraintOrNull(String constraint_name)
Looks up a constraint by name, and returns nullptr if it does not exist.
Definition: MPSolver.java:260
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:241
MPVariable [] makeBoolVarArray(int count)
Definition: MPSolver.java:84
Export options.
Definition: MPModelExportOptions.java:16
MPConstraint constraint(int index)
Returns the constraint at the given index.
Definition: MPSolver.java:248
GLOP_LINEAR_PROGRAMMING
Definition: MPSolver.java:623
static MPSolver createSolver(String solver_id)
Recommended factory method to create a MPSolver instance, especially in non C++ languages.
Definition: MPSolver.java:127
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:549
String exportModelAsLpFormat(MPModelExportOptions options)
Export the loaded model in LP format.
Definition: MPSolver.java:565
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:884
MPVariable [] makeIntVarArray(int count, double lb, double ub, String var_name)
Definition: MPSolver.java:80
The status of solving the problem.
Definition: MPSolver.java:680
BOP_INTEGER_PROGRAMMING
Definition: MPSolver.java:633
MPConstraint makeConstraint(double lb, double ub)
Creates a linear constraint with given bounds.
Definition: MPSolver.java:273
final int swigValue()
Definition: MPSolver.java:755
String exportModelAsMpsFormat(MPModelExportOptions options)
Export the loaded model in MPS format.
Definition: MPSolver.java:579
final int swigValue()
Definition: MPSolver.java:706
XPRESS_MIXED_INTEGER_PROGRAMMING
Definition: MPSolver.java:632
MPVariable [] variables()
Returns the array of variables handled by the MPSolver.
Definition: MPSolver.java:171
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:427
MPVariable [] makeBoolVarArray(int count, String var_name)
Definition: MPSolver.java:88
MPSolver.ResultStatus solve()
Solves the problem using the default parameter values.
Definition: MPSolver.java:313
GUROBI_LINEAR_PROGRAMMING
Definition: MPSolver.java:627
MPSolver.OptimizationProblemType problemType()
Returns the optimization problem type set at construction.
Definition: MPSolver.java:147
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
CPLEX_LINEAR_PROGRAMMING
Definition: MPSolver.java:629
MPConstraint makeConstraint(String name)
Creates a named constraint with -infinity and +infinity bounds.
Definition: MPSolver.java:297
boolean setSolverSpecificParametersAsString(String parameters)
Advanced usage: pass solver specific parameters in text format.
Definition: MPSolver.java:388
static com.google.ortools.linearsolver.MPModelProto parseFrom(java.nio.ByteBuffer data)
Definition: MPModelProto.java:748
MPSolver.ResultStatus solve(MPSolverParameters param)
Solves the problem using the specified parameter values.
Definition: MPSolver.java:320
void setTimeLimit(long time_limit_milliseconds)
Definition: MPSolver.java:459
MPVariable lookupVariableOrNull(String var_name)
Looks up a variable by name, and returns nullptr if it does not exist.
Definition: MPSolver.java:188
This mathematical programming (MP) solver class is the main class though which users build and solve...
Definition: MPSolver.java:17
String loadModelFromProtoWithUniqueNamesOrDie(com.google.ortools.linearsolver.MPModelProto input_model)
Definition: MPSolver.java:475
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:542
CPLEX_MIXED_INTEGER_PROGRAMMING
Definition: MPSolver.java:630
SAT_INTEGER_PROGRAMMING
Definition: MPSolver.java:634
The type of problems (LP or MIP) that will be solved and the underlying solver (GLOP,...
Definition: MPSolver.java:620
Advanced usage: possible basis status values for a variable and the slack variable of a linear const...
Definition: MPSolver.java:748
MPVariable makeIntVar(double lb, double ub, String name)
Creates an integer variable.
Definition: MPSolver.java:216
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:281
GLPK_LINEAR_PROGRAMMING
Definition: MPSolver.java:622
static BasisStatus swigToEnum(int swigValue)
Definition: MPSolver.java:759
MPSolver(long cPtr, boolean cMemoryOwn)
Definition: MPSolver.java:21
void reset()
Advanced usage: resets extracted model to solve from scratch.
Definition: MPSolver.java:364
com.google.ortools.linearsolver.MPSolutionResponse createSolutionResponseProto()
Fills the solution found to a response proto and returns it.
Definition: MPSolver.java:498
CLP_LINEAR_PROGRAMMING
Definition: MPSolver.java:621
MPVariable [] makeVarArray(int count, double lb, double ub, boolean integer)
Creates and returns an array of variables.
Definition: MPSolver.java:48
GUROBI_MIXED_INTEGER_PROGRAMMING
Definition: MPSolver.java:628
double computeExactConditionNumber()
Advanced usage: computes the exact condition number of the current scaled basis: L1norm(B) * L1norm(...
Definition: MPSolver.java:455
boolean verifySolution(double tolerance, boolean log_errors)
Advanced usage: Verifies the correctness of the solution.
Definition: MPSolver.java:352
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:603
MPVariable [] makeNumVarArray(int count, double lb, double ub, String var_name)
Definition: MPSolver.java:72
static OptimizationProblemType swigToEnum(int swigValue)
Definition: MPSolver.java:640
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:471
GLPK_MIXED_INTEGER_PROGRAMMING
Definition: MPSolver.java:625
MPVariable makeVar(double lb, double ub, boolean integer, String name)
Creates a variable with the given bounds, integrality requirement and name.
Definition: MPSolver.java:200
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:330
boolean setNumThreads(int num_theads)
Sets the number of threads to be used by the solver.
Definition: MPSolver.java:610
MPConstraint makeConstraint(double lb, double ub, String name)
Creates a named constraint with given bounds.
Definition: MPSolver.java:289
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:378
SCIP_MIXED_INTEGER_PROGRAMMING
Definition: MPSolver.java:624
CBC_MIXED_INTEGER_PROGRAMMING
Definition: MPSolver.java:626
XPRESS_LINEAR_PROGRAMMING
Definition: MPSolver.java:631
MPVariable makeNumVar(double lb, double ub, String name)
Creates a continuous variable.
Definition: MPSolver.java:208
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