Java Reference

Java Reference

MPSolver.java
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2  * This file was automatically generated by SWIG (http://www.swig.org).
3  * Version 4.0.2
4  *
5  * Do not make changes to this file unless you know what you are doing--modify
6  * the SWIG interface file instead.
7  * ----------------------------------------------------------------------------- */
8 
9 package com.google.ortools.linearsolver;
10 
11 import java.lang.reflect.*;
12 
17 public class MPSolver {
18  private transient long swigCPtr;
19  protected transient boolean swigCMemOwn;
20 
21  protected MPSolver(long cPtr, boolean cMemoryOwn) {
22  swigCMemOwn = cMemoryOwn;
23  swigCPtr = cPtr;
24  }
25 
26  protected static long getCPtr(MPSolver obj) {
27  return (obj == null) ? 0 : obj.swigCPtr;
28  }
29 
30  @SuppressWarnings("deprecation")
31  protected void finalize() {
32  delete();
33  }
34 
35  public synchronized void delete() {
36  if (swigCPtr != 0) {
37  if (swigCMemOwn) {
38  swigCMemOwn = false;
39  main_research_linear_solverJNI.delete_MPSolver(swigCPtr);
40  }
41  swigCPtr = 0;
42  }
43  }
44 
48  public MPVariable[] makeVarArray(int count, double lb, double ub, boolean integer) {
49  MPVariable[] array = new MPVariable[count];
50  for (int i = 0; i < count; ++i) {
51  array[i] = makeVar(lb, ub, integer, "");
52  }
53  return array;
54  }
55 
59  public MPVariable[] makeVarArray(int count, double lb, double ub, boolean integer,
60  String var_name) {
61  MPVariable[] array = new MPVariable[count];
62  for (int i = 0; i < count; ++i) {
63  array[i] = makeVar(lb, ub, integer, var_name + i);
64  }
65  return array;
66  }
67 
68  public MPVariable[] makeNumVarArray(int count, double lb, double ub) {
69  return makeVarArray(count, lb, ub, false);
70  }
71 
72  public MPVariable[] makeNumVarArray(int count, double lb, double ub, String var_name) {
73  return makeVarArray(count, lb, ub, false, var_name);
74  }
75 
76  public MPVariable[] makeIntVarArray(int count, double lb, double ub) {
77  return makeVarArray(count, lb, ub, true);
78  }
79 
80  public MPVariable[] makeIntVarArray(int count, double lb, double ub, String var_name) {
81  return makeVarArray(count, lb, ub, true, var_name);
82  }
83 
84  public MPVariable[] makeBoolVarArray(int count) {
85  return makeVarArray(count, 0.0, 1.0, true);
86  }
87 
88  public MPVariable[] makeBoolVarArray(int count, String var_name) {
89  return makeVarArray(count, 0.0, 1.0, true, var_name);
90  }
91 
95  public MPSolver(String name, MPSolver.OptimizationProblemType problem_type) {
96  this(main_research_linear_solverJNI.new_MPSolver(name, problem_type.swigValue()), true);
97  }
98 
127  public static MPSolver createSolver(String solver_id) {
128  long cPtr = main_research_linear_solverJNI.MPSolver_createSolver(solver_id);
129  return (cPtr == 0) ? null : new MPSolver(cPtr, true);
130  }
131 
136  public static boolean supportsProblemType(MPSolver.OptimizationProblemType problem_type) {
137  return main_research_linear_solverJNI.MPSolver_supportsProblemType(problem_type.swigValue());
138  }
139 
140  public boolean isMip() {
141  return main_research_linear_solverJNI.MPSolver_isMip(swigCPtr, this);
142  }
143 
149  public void clear() {
150  main_research_linear_solverJNI.MPSolver_clear(swigCPtr, this);
151  }
152 
156  public int numVariables() {
157  return main_research_linear_solverJNI.MPSolver_numVariables(swigCPtr, this);
158  }
159 
164  public MPVariable[] variables() {
165  return main_research_linear_solverJNI.MPSolver_variables(swigCPtr, this);
166 }
167 
173  public MPVariable lookupVariableOrNull(String var_name) {
174  long cPtr = main_research_linear_solverJNI.MPSolver_lookupVariableOrNull(swigCPtr, this, var_name);
175  return (cPtr == 0) ? null : new MPVariable(cPtr, false);
176  }
177 
185  public MPVariable makeVar(double lb, double ub, boolean integer, String name) {
186  long cPtr = main_research_linear_solverJNI.MPSolver_makeVar(swigCPtr, this, lb, ub, integer, name);
187  return (cPtr == 0) ? null : new MPVariable(cPtr, false);
188  }
189 
193  public MPVariable makeNumVar(double lb, double ub, String name) {
194  long cPtr = main_research_linear_solverJNI.MPSolver_makeNumVar(swigCPtr, this, lb, ub, name);
195  return (cPtr == 0) ? null : new MPVariable(cPtr, false);
196  }
197 
201  public MPVariable makeIntVar(double lb, double ub, String name) {
202  long cPtr = main_research_linear_solverJNI.MPSolver_makeIntVar(swigCPtr, this, lb, ub, name);
203  return (cPtr == 0) ? null : new MPVariable(cPtr, false);
204  }
205 
209  public MPVariable makeBoolVar(String name) {
210  long cPtr = main_research_linear_solverJNI.MPSolver_makeBoolVar(swigCPtr, this, name);
211  return (cPtr == 0) ? null : new MPVariable(cPtr, false);
212  }
213 
217  public int numConstraints() {
218  return main_research_linear_solverJNI.MPSolver_numConstraints(swigCPtr, this);
219  }
220 
227  return main_research_linear_solverJNI.MPSolver_constraints(swigCPtr, this);
228 }
229 
237  public MPConstraint lookupConstraintOrNull(String constraint_name) {
238  long cPtr = main_research_linear_solverJNI.MPSolver_lookupConstraintOrNull(swigCPtr, this, constraint_name);
239  return (cPtr == 0) ? null : new MPConstraint(cPtr, false);
240  }
241 
250  public MPConstraint makeConstraint(double lb, double ub) {
251  long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_0(swigCPtr, this, lb, ub);
252  return (cPtr == 0) ? null : new MPConstraint(cPtr, false);
253  }
254 
259  long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_1(swigCPtr, this);
260  return (cPtr == 0) ? null : new MPConstraint(cPtr, false);
261  }
262 
266  public MPConstraint makeConstraint(double lb, double ub, String name) {
267  long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_2(swigCPtr, this, lb, ub, name);
268  return (cPtr == 0) ? null : new MPConstraint(cPtr, false);
269  }
270 
274  public MPConstraint makeConstraint(String name) {
275  long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_3(swigCPtr, this, name);
276  return (cPtr == 0) ? null : new MPConstraint(cPtr, false);
277  }
278 
283  long cPtr = main_research_linear_solverJNI.MPSolver_objective(swigCPtr, this);
284  return (cPtr == 0) ? null : new MPObjective(cPtr, false);
285  }
286 
291  return MPSolver.ResultStatus.swigToEnum(main_research_linear_solverJNI.MPSolver_solve__SWIG_0(swigCPtr, this));
292  }
293 
298  return MPSolver.ResultStatus.swigToEnum(main_research_linear_solverJNI.MPSolver_solve__SWIG_1(swigCPtr, this, MPSolverParameters.getCPtr(param), param));
299  }
300 
307  public double[] computeConstraintActivities() {
308  return main_research_linear_solverJNI.MPSolver_computeConstraintActivities(swigCPtr, this);
309 }
310 
329  public boolean verifySolution(double tolerance, boolean log_errors) {
330  return main_research_linear_solverJNI.MPSolver_verifySolution(swigCPtr, this, tolerance, log_errors);
331  }
332 
341  public void reset() {
342  main_research_linear_solverJNI.MPSolver_reset(swigCPtr, this);
343  }
344 
353  public boolean interruptSolve() {
354  return main_research_linear_solverJNI.MPSolver_interruptSolve(swigCPtr, this);
355  }
356 
363  public boolean setSolverSpecificParametersAsString(String parameters) {
364  return main_research_linear_solverJNI.MPSolver_setSolverSpecificParametersAsString(swigCPtr, this, parameters);
365  }
366 
372  public static double infinity() {
373  return main_research_linear_solverJNI.MPSolver_infinity();
374  }
375 
379  public void enableOutput() {
380  main_research_linear_solverJNI.MPSolver_enableOutput(swigCPtr, this);
381  }
382 
386  public void suppressOutput() {
387  main_research_linear_solverJNI.MPSolver_suppressOutput(swigCPtr, this);
388  }
389 
393  public long iterations() {
394  return main_research_linear_solverJNI.MPSolver_iterations(swigCPtr, this);
395  }
396 
402  public long nodes() {
403  return main_research_linear_solverJNI.MPSolver_nodes(swigCPtr, this);
404  }
405 
430  public double computeExactConditionNumber() {
431  return main_research_linear_solverJNI.MPSolver_computeExactConditionNumber(swigCPtr, this);
432  }
433 
434  public void setTimeLimit(long time_limit_milliseconds) {
435  main_research_linear_solverJNI.MPSolver_setTimeLimit(swigCPtr, this, time_limit_milliseconds);
436  }
437 
438  public long wallTime() {
439  return main_research_linear_solverJNI.MPSolver_wallTime(swigCPtr, this);
440  }
441 
442  public static void setGurobiLibraryPath(String full_library_path) {
443  main_research_linear_solverJNI.MPSolver_setGurobiLibraryPath(full_library_path);
444  }
445 
451  return main_research_linear_solverJNI.MPSolver_loadModelFromProto(swigCPtr, this, input_model.toByteArray());
452  }
453 
455  return main_research_linear_solverJNI.MPSolver_loadModelFromProtoWithUniqueNamesOrDie(swigCPtr, this, input_model.toByteArray());
456  }
457 
462  byte[] buf = main_research_linear_solverJNI.MPSolver_exportModelToProto(swigCPtr, this);
463  if (buf == null || buf.length == 0) {
464  return null;
465  }
466  try {
468  } catch (com.google.protobuf.InvalidProtocolBufferException e) {
469  throw new RuntimeException(
470  "Unable to parse com.google.ortools.linearsolver.MPModelProto protocol message.");
471  }
472 }
473 
478  byte[] buf = main_research_linear_solverJNI.MPSolver_createSolutionResponseProto(swigCPtr, this);
479  if (buf == null || buf.length == 0) {
480  return null;
481  }
482  try {
484  } catch (com.google.protobuf.InvalidProtocolBufferException e) {
485  throw new RuntimeException(
486  "Unable to parse com.google.ortools.linearsolver.MPSolutionResponse protocol message.");
487  }
488 }
489 
522  return main_research_linear_solverJNI.MPSolver_loadSolutionFromProto(swigCPtr, this, response.toByteArray());
523  }
524 
529  byte[] buf = main_research_linear_solverJNI.MPSolver_solveWithProto(model_request.toByteArray());
530  if (buf == null || buf.length == 0) {
531  return null;
532  }
533  try {
535  } catch (com.google.protobuf.InvalidProtocolBufferException e) {
536  throw new RuntimeException(
537  "Unable to parse com.google.ortools.linearsolver.MPSolutionResponse protocol message.");
538  }
539 }
540 
545  return main_research_linear_solverJNI.MPSolver_exportModelAsLpFormat__SWIG_0(swigCPtr, this, MPModelExportOptions.getCPtr(options), options);
546  }
547 
551  public String exportModelAsLpFormat() {
552  return main_research_linear_solverJNI.MPSolver_exportModelAsLpFormat__SWIG_1(swigCPtr, this);
553  }
554 
559  return main_research_linear_solverJNI.MPSolver_exportModelAsMpsFormat__SWIG_0(swigCPtr, this, MPModelExportOptions.getCPtr(options), options);
560  }
561 
565  public String exportModelAsMpsFormat() {
566  return main_research_linear_solverJNI.MPSolver_exportModelAsMpsFormat__SWIG_1(swigCPtr, this);
567  }
568 
582  public void setHint(MPVariable[] variables, double[] values) {
583  main_research_linear_solverJNI.MPSolver_setHint(swigCPtr, this, variables, values);
584  }
585 
589  public boolean setNumThreads(int num_theads) {
590  return main_research_linear_solverJNI.MPSolver_setNumThreads(swigCPtr, this, num_theads);
591  }
592 
600  CLP_LINEAR_PROGRAMMING(main_research_linear_solverJNI.MPSolver_CLP_LINEAR_PROGRAMMING_get()),
601  GLPK_LINEAR_PROGRAMMING(main_research_linear_solverJNI.MPSolver_GLPK_LINEAR_PROGRAMMING_get()),
602  GLOP_LINEAR_PROGRAMMING(main_research_linear_solverJNI.MPSolver_GLOP_LINEAR_PROGRAMMING_get()),
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()),
612  BOP_INTEGER_PROGRAMMING(main_research_linear_solverJNI.MPSolver_BOP_INTEGER_PROGRAMMING_get()),
613  SAT_INTEGER_PROGRAMMING(main_research_linear_solverJNI.MPSolver_SAT_INTEGER_PROGRAMMING_get());
614 
615  public final int swigValue() {
616  return swigValue;
617  }
618 
619  public static OptimizationProblemType swigToEnum(int swigValue) {
620  OptimizationProblemType[] swigValues = OptimizationProblemType.class.getEnumConstants();
621  if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
622  return swigValues[swigValue];
623  for (OptimizationProblemType swigEnum : swigValues)
624  if (swigEnum.swigValue == swigValue)
625  return swigEnum;
626  throw new IllegalArgumentException("No enum " + OptimizationProblemType.class + " with value " + swigValue);
627  }
628 
629  @SuppressWarnings("unused")
630  private OptimizationProblemType() {
631  this.swigValue = SwigNext.next++;
632  }
633 
634  @SuppressWarnings("unused")
635  private OptimizationProblemType(int swigValue) {
636  this.swigValue = swigValue;
637  SwigNext.next = swigValue+1;
638  }
639 
640  @SuppressWarnings("unused")
641  private OptimizationProblemType(OptimizationProblemType swigEnum) {
642  this.swigValue = swigEnum.swigValue;
643  SwigNext.next = this.swigValue+1;
644  }
645 
646  private final int swigValue;
647 
648  private static class SwigNext {
649  private static int next = 0;
650  }
651  }
652 
659  public enum ResultStatus {
683  NOT_SOLVED(main_research_linear_solverJNI.MPSolver_NOT_SOLVED_get());
684 
685  public final int swigValue() {
686  return swigValue;
687  }
688 
689  public static ResultStatus swigToEnum(int swigValue) {
690  ResultStatus[] swigValues = ResultStatus.class.getEnumConstants();
691  if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
692  return swigValues[swigValue];
693  for (ResultStatus swigEnum : swigValues)
694  if (swigEnum.swigValue == swigValue)
695  return swigEnum;
696  throw new IllegalArgumentException("No enum " + ResultStatus.class + " with value " + swigValue);
697  }
698 
699  @SuppressWarnings("unused")
700  private ResultStatus() {
701  this.swigValue = SwigNext.next++;
702  }
703 
704  @SuppressWarnings("unused")
705  private ResultStatus(int swigValue) {
706  this.swigValue = swigValue;
707  SwigNext.next = swigValue+1;
708  }
709 
710  @SuppressWarnings("unused")
711  private ResultStatus(ResultStatus swigEnum) {
712  this.swigValue = swigEnum.swigValue;
713  SwigNext.next = this.swigValue+1;
714  }
715 
716  private final int swigValue;
717 
718  private static class SwigNext {
719  private static int next = 0;
720  }
721  }
722 
727  public enum BasisStatus {
728  FREE(main_research_linear_solverJNI.MPSolver_FREE_get()),
733 
734  public final int swigValue() {
735  return swigValue;
736  }
737 
738  public static BasisStatus swigToEnum(int swigValue) {
739  BasisStatus[] swigValues = BasisStatus.class.getEnumConstants();
740  if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
741  return swigValues[swigValue];
742  for (BasisStatus swigEnum : swigValues)
743  if (swigEnum.swigValue == swigValue)
744  return swigEnum;
745  throw new IllegalArgumentException("No enum " + BasisStatus.class + " with value " + swigValue);
746  }
747 
748  @SuppressWarnings("unused")
749  private BasisStatus() {
750  this.swigValue = SwigNext.next++;
751  }
752 
753  @SuppressWarnings("unused")
754  private BasisStatus(int swigValue) {
755  this.swigValue = swigValue;
756  SwigNext.next = swigValue+1;
757  }
758 
759  @SuppressWarnings("unused")
760  private BasisStatus(BasisStatus swigEnum) {
761  this.swigValue = swigEnum.swigValue;
762  SwigNext.next = this.swigValue+1;
763  }
764 
765  private final int swigValue;
766 
767  private static class SwigNext {
768  private static int next = 0;
769  }
770  }
771 
772 }
boolean interruptSolve()
Interrupts the Solve() execution to terminate processing if possible.
Definition: MPSolver.java:353
final int swigValue()
Definition: MPSolver.java:734
MPObjective objective()
Returns the mutable objective object.
Definition: MPSolver.java:282
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
void enableOutput()
Enables solver logging.
Definition: MPSolver.java:379
UNBOUNDED
proven unbounded.
Definition: MPSolver.java:675
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
String exportModelAsLpFormat()
Export the loaded model in LP format.
Definition: MPSolver.java:551
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.
GLOP_LINEAR_PROGRAMMING
Definition: MPSolver.java:602
Protobuf type.
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
INFEASIBLE
proven infeasible.
Definition: MPSolver.java:671
XPRESS_MIXED_INTEGER_PROGRAMMING
Definition: MPSolver.java:611
MPConstraint[] constraints()
Returns the array of constraints handled by the MPSolver.
Definition: MPSolver.java:226
boolean isMip()
Definition: MPSolver.java:140
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)
GUROBI_MIXED_INTEGER_PROGRAMMING
Definition: MPSolver.java:607
static BasisStatus swigToEnum(int swigValue)
Definition: MPSolver.java:738
GUROBI_LINEAR_PROGRAMMING
Definition: MPSolver.java:606
FEASIBLE
feasible, or stopped by limit.
Definition: MPSolver.java:667
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
FREE
Definition: MPSolver.java:728
NOT_SOLVED
not been solved yet.
Definition: MPSolver.java:683
The status of solving the problem.
Definition: MPSolver.java:659
static double infinity()
Infinity.
Definition: MPSolver.java:372
String exportModelAsMpsFormat()
Export the loaded model in MPS format.
Definition: MPSolver.java:565
MPVariable makeBoolVar(String name)
Creates a boolean variable.
Definition: MPSolver.java:209
BASIC
Definition: MPSolver.java:732
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.
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
long wallTime()
Definition: MPSolver.java:438
long iterations()
Returns the number of simplex iterations.
Definition: MPSolver.java:393
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
OPTIMAL
optimal.
Definition: MPSolver.java:663
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
void suppressOutput()
Suppresses solver logging.
Definition: MPSolver.java:386
A class to express a linear objective.
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
int numVariables()
Returns the number of variables.
Definition: MPSolver.java:156
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)
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.
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
int numConstraints()
Returns the number of constraints.
Definition: MPSolver.java:217
MPSolver.ResultStatus solve()
Solves the problem using the default parameter values.
Definition: MPSolver.java:290
ABNORMAL
abnormal, i.e., error of some kind.
Definition: MPSolver.java:679
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