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.1
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 
148  return MPSolver.OptimizationProblemType.swigToEnum(main_research_linear_solverJNI.MPSolver_problemType(swigCPtr, this));
149  }
150 
156  public void clear() {
157  main_research_linear_solverJNI.MPSolver_clear(swigCPtr, this);
158  }
159 
163  public int numVariables() {
164  return main_research_linear_solverJNI.MPSolver_numVariables(swigCPtr, this);
165  }
166 
171  public MPVariable[] variables() {
172  return main_research_linear_solverJNI.MPSolver_variables(swigCPtr, this);
173 }
174 
178  public MPVariable variable(int index) {
179  long cPtr = main_research_linear_solverJNI.MPSolver_variable(swigCPtr, this, index);
180  return (cPtr == 0) ? null : new MPVariable(cPtr, false);
181  }
182 
188  public MPVariable lookupVariableOrNull(String var_name) {
189  long cPtr = main_research_linear_solverJNI.MPSolver_lookupVariableOrNull(swigCPtr, this, var_name);
190  return (cPtr == 0) ? null : new MPVariable(cPtr, false);
191  }
192 
200  public MPVariable makeVar(double lb, double ub, boolean integer, String name) {
201  long cPtr = main_research_linear_solverJNI.MPSolver_makeVar(swigCPtr, this, lb, ub, integer, name);
202  return (cPtr == 0) ? null : new MPVariable(cPtr, false);
203  }
204 
208  public MPVariable makeNumVar(double lb, double ub, String name) {
209  long cPtr = main_research_linear_solverJNI.MPSolver_makeNumVar(swigCPtr, this, lb, ub, name);
210  return (cPtr == 0) ? null : new MPVariable(cPtr, false);
211  }
212 
216  public MPVariable makeIntVar(double lb, double ub, String name) {
217  long cPtr = main_research_linear_solverJNI.MPSolver_makeIntVar(swigCPtr, this, lb, ub, name);
218  return (cPtr == 0) ? null : new MPVariable(cPtr, false);
219  }
220 
224  public MPVariable makeBoolVar(String name) {
225  long cPtr = main_research_linear_solverJNI.MPSolver_makeBoolVar(swigCPtr, this, name);
226  return (cPtr == 0) ? null : new MPVariable(cPtr, false);
227  }
228 
232  public int numConstraints() {
233  return main_research_linear_solverJNI.MPSolver_numConstraints(swigCPtr, this);
234  }
235 
242  return main_research_linear_solverJNI.MPSolver_constraints(swigCPtr, this);
243 }
244 
248  public MPConstraint constraint(int index) {
249  long cPtr = main_research_linear_solverJNI.MPSolver_constraint(swigCPtr, this, index);
250  return (cPtr == 0) ? null : new MPConstraint(cPtr, false);
251  }
252 
260  public MPConstraint lookupConstraintOrNull(String constraint_name) {
261  long cPtr = main_research_linear_solverJNI.MPSolver_lookupConstraintOrNull(swigCPtr, this, constraint_name);
262  return (cPtr == 0) ? null : new MPConstraint(cPtr, false);
263  }
264 
273  public MPConstraint makeConstraint(double lb, double ub) {
274  long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_0(swigCPtr, this, lb, ub);
275  return (cPtr == 0) ? null : new MPConstraint(cPtr, false);
276  }
277 
282  long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_1(swigCPtr, this);
283  return (cPtr == 0) ? null : new MPConstraint(cPtr, false);
284  }
285 
289  public MPConstraint makeConstraint(double lb, double ub, String name) {
290  long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_2(swigCPtr, this, lb, ub, name);
291  return (cPtr == 0) ? null : new MPConstraint(cPtr, false);
292  }
293 
297  public MPConstraint makeConstraint(String name) {
298  long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_3(swigCPtr, this, name);
299  return (cPtr == 0) ? null : new MPConstraint(cPtr, false);
300  }
301 
306  long cPtr = main_research_linear_solverJNI.MPSolver_objective(swigCPtr, this);
307  return (cPtr == 0) ? null : new MPObjective(cPtr, false);
308  }
309 
314  return MPSolver.ResultStatus.swigToEnum(main_research_linear_solverJNI.MPSolver_solve__SWIG_0(swigCPtr, this));
315  }
316 
321  return MPSolver.ResultStatus.swigToEnum(main_research_linear_solverJNI.MPSolver_solve__SWIG_1(swigCPtr, this, MPSolverParameters.getCPtr(param), param));
322  }
323 
330  public double[] computeConstraintActivities() {
331  return main_research_linear_solverJNI.MPSolver_computeConstraintActivities(swigCPtr, this);
332 }
333 
352  public boolean verifySolution(double tolerance, boolean log_errors) {
353  return main_research_linear_solverJNI.MPSolver_verifySolution(swigCPtr, this, tolerance, log_errors);
354  }
355 
364  public void reset() {
365  main_research_linear_solverJNI.MPSolver_reset(swigCPtr, this);
366  }
367 
378  public boolean interruptSolve() {
379  return main_research_linear_solverJNI.MPSolver_interruptSolve(swigCPtr, this);
380  }
381 
388  public boolean setSolverSpecificParametersAsString(String parameters) {
389  return main_research_linear_solverJNI.MPSolver_setSolverSpecificParametersAsString(swigCPtr, this, parameters);
390  }
391 
397  public static double infinity() {
398  return main_research_linear_solverJNI.MPSolver_infinity();
399  }
400 
404  public void enableOutput() {
405  main_research_linear_solverJNI.MPSolver_enableOutput(swigCPtr, this);
406  }
407 
411  public void suppressOutput() {
412  main_research_linear_solverJNI.MPSolver_suppressOutput(swigCPtr, this);
413  }
414 
418  public long iterations() {
419  return main_research_linear_solverJNI.MPSolver_iterations(swigCPtr, this);
420  }
421 
427  public long nodes() {
428  return main_research_linear_solverJNI.MPSolver_nodes(swigCPtr, this);
429  }
430 
455  public double computeExactConditionNumber() {
456  return main_research_linear_solverJNI.MPSolver_computeExactConditionNumber(swigCPtr, this);
457  }
458 
459  public void setTimeLimit(long time_limit_milliseconds) {
460  main_research_linear_solverJNI.MPSolver_setTimeLimit(swigCPtr, this, time_limit_milliseconds);
461  }
462 
463  public long wallTime() {
464  return main_research_linear_solverJNI.MPSolver_wallTime(swigCPtr, this);
465  }
466 
472  return main_research_linear_solverJNI.MPSolver_loadModelFromProto(swigCPtr, this, input_model.toByteArray());
473  }
474 
476  return main_research_linear_solverJNI.MPSolver_loadModelFromProtoWithUniqueNamesOrDie(swigCPtr, this, input_model.toByteArray());
477  }
478 
483  byte[] buf = main_research_linear_solverJNI.MPSolver_exportModelToProto(swigCPtr, this);
484  if (buf == null || buf.length == 0) {
485  return null;
486  }
487  try {
489  } catch (com.google.protobuf.InvalidProtocolBufferException e) {
490  throw new RuntimeException(
491  "Unable to parse com.google.ortools.linearsolver.MPModelProto protocol message.");
492  }
493 }
494 
499  byte[] buf = main_research_linear_solverJNI.MPSolver_createSolutionResponseProto(swigCPtr, this);
500  if (buf == null || buf.length == 0) {
501  return null;
502  }
503  try {
505  } catch (com.google.protobuf.InvalidProtocolBufferException e) {
506  throw new RuntimeException(
507  "Unable to parse com.google.ortools.linearsolver.MPSolutionResponse protocol message.");
508  }
509 }
510 
543  return main_research_linear_solverJNI.MPSolver_loadSolutionFromProto(swigCPtr, this, response.toByteArray());
544  }
545 
550  byte[] buf = main_research_linear_solverJNI.MPSolver_solveWithProto(model_request.toByteArray());
551  if (buf == null || buf.length == 0) {
552  return null;
553  }
554  try {
556  } catch (com.google.protobuf.InvalidProtocolBufferException e) {
557  throw new RuntimeException(
558  "Unable to parse com.google.ortools.linearsolver.MPSolutionResponse protocol message.");
559  }
560 }
561 
566  return main_research_linear_solverJNI.MPSolver_exportModelAsLpFormat__SWIG_0(swigCPtr, this, MPModelExportOptions.getCPtr(options), options);
567  }
568 
572  public String exportModelAsLpFormat() {
573  return main_research_linear_solverJNI.MPSolver_exportModelAsLpFormat__SWIG_1(swigCPtr, this);
574  }
575 
580  return main_research_linear_solverJNI.MPSolver_exportModelAsMpsFormat__SWIG_0(swigCPtr, this, MPModelExportOptions.getCPtr(options), options);
581  }
582 
586  public String exportModelAsMpsFormat() {
587  return main_research_linear_solverJNI.MPSolver_exportModelAsMpsFormat__SWIG_1(swigCPtr, this);
588  }
589 
603  public void setHint(MPVariable[] variables, double[] values) {
604  main_research_linear_solverJNI.MPSolver_setHint(swigCPtr, this, variables, values);
605  }
606 
610  public boolean setNumThreads(int num_theads) {
611  return main_research_linear_solverJNI.MPSolver_setNumThreads(swigCPtr, this, num_theads);
612  }
613 
621  CLP_LINEAR_PROGRAMMING(main_research_linear_solverJNI.MPSolver_CLP_LINEAR_PROGRAMMING_get()),
622  GLPK_LINEAR_PROGRAMMING(main_research_linear_solverJNI.MPSolver_GLPK_LINEAR_PROGRAMMING_get()),
623  GLOP_LINEAR_PROGRAMMING(main_research_linear_solverJNI.MPSolver_GLOP_LINEAR_PROGRAMMING_get()),
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()),
633  BOP_INTEGER_PROGRAMMING(main_research_linear_solverJNI.MPSolver_BOP_INTEGER_PROGRAMMING_get()),
634  SAT_INTEGER_PROGRAMMING(main_research_linear_solverJNI.MPSolver_SAT_INTEGER_PROGRAMMING_get());
635 
636  public final int swigValue() {
637  return swigValue;
638  }
639 
640  public static OptimizationProblemType swigToEnum(int swigValue) {
641  OptimizationProblemType[] swigValues = OptimizationProblemType.class.getEnumConstants();
642  if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
643  return swigValues[swigValue];
644  for (OptimizationProblemType swigEnum : swigValues)
645  if (swigEnum.swigValue == swigValue)
646  return swigEnum;
647  throw new IllegalArgumentException("No enum " + OptimizationProblemType.class + " with value " + swigValue);
648  }
649 
650  @SuppressWarnings("unused")
651  private OptimizationProblemType() {
652  this.swigValue = SwigNext.next++;
653  }
654 
655  @SuppressWarnings("unused")
656  private OptimizationProblemType(int swigValue) {
657  this.swigValue = swigValue;
658  SwigNext.next = swigValue+1;
659  }
660 
661  @SuppressWarnings("unused")
662  private OptimizationProblemType(OptimizationProblemType swigEnum) {
663  this.swigValue = swigEnum.swigValue;
664  SwigNext.next = this.swigValue+1;
665  }
666 
667  private final int swigValue;
668 
669  private static class SwigNext {
670  private static int next = 0;
671  }
672  }
673 
680  public enum ResultStatus {
704  NOT_SOLVED(main_research_linear_solverJNI.MPSolver_NOT_SOLVED_get());
705 
706  public final int swigValue() {
707  return swigValue;
708  }
709 
710  public static ResultStatus swigToEnum(int swigValue) {
711  ResultStatus[] swigValues = ResultStatus.class.getEnumConstants();
712  if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
713  return swigValues[swigValue];
714  for (ResultStatus swigEnum : swigValues)
715  if (swigEnum.swigValue == swigValue)
716  return swigEnum;
717  throw new IllegalArgumentException("No enum " + ResultStatus.class + " with value " + swigValue);
718  }
719 
720  @SuppressWarnings("unused")
721  private ResultStatus() {
722  this.swigValue = SwigNext.next++;
723  }
724 
725  @SuppressWarnings("unused")
726  private ResultStatus(int swigValue) {
727  this.swigValue = swigValue;
728  SwigNext.next = swigValue+1;
729  }
730 
731  @SuppressWarnings("unused")
732  private ResultStatus(ResultStatus swigEnum) {
733  this.swigValue = swigEnum.swigValue;
734  SwigNext.next = this.swigValue+1;
735  }
736 
737  private final int swigValue;
738 
739  private static class SwigNext {
740  private static int next = 0;
741  }
742  }
743 
748  public enum BasisStatus {
749  FREE(main_research_linear_solverJNI.MPSolver_FREE_get()),
750  AT_LOWER_BOUND,
751  AT_UPPER_BOUND,
752  FIXED_VALUE,
753  BASIC;
754 
755  public final int swigValue() {
756  return swigValue;
757  }
758 
759  public static BasisStatus swigToEnum(int swigValue) {
760  BasisStatus[] swigValues = BasisStatus.class.getEnumConstants();
761  if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
762  return swigValues[swigValue];
763  for (BasisStatus swigEnum : swigValues)
764  if (swigEnum.swigValue == swigValue)
765  return swigEnum;
766  throw new IllegalArgumentException("No enum " + BasisStatus.class + " with value " + swigValue);
767  }
768 
769  @SuppressWarnings("unused")
770  private BasisStatus() {
771  this.swigValue = SwigNext.next++;
772  }
773 
774  @SuppressWarnings("unused")
775  private BasisStatus(int swigValue) {
776  this.swigValue = swigValue;
777  SwigNext.next = swigValue+1;
778  }
779 
780  @SuppressWarnings("unused")
781  private BasisStatus(BasisStatus swigEnum) {
782  this.swigValue = swigEnum.swigValue;
783  SwigNext.next = this.swigValue+1;
784  }
785 
786  private final int swigValue;
787 
788  private static class SwigNext {
789  private static int next = 0;
790  }
791  }
792 
793 }
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
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
MPConstraint constraint(int index)
Returns the constraint at the given index.
Definition: MPSolver.java:248
void suppressOutput()
Suppresses solver logging.
Definition: MPSolver.java:411
static MPSolver createSolver(String solver_id)
Recommended factory method to create a MPSolver instance, especially in non C++ languages.
Definition: MPSolver.java:127
ABNORMAL
abnormal, i.e., error of some kind.
Definition: MPSolver.java:700
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)
MPVariable [] makeIntVarArray(int count, double lb, double ub, String var_name)
Definition: MPSolver.java:80
MPConstraint makeConstraint(double lb, double ub)
Creates a linear constraint with given bounds.
Definition: MPSolver.java:273
String exportModelAsMpsFormat(MPModelExportOptions options)
Export the loaded model in MPS format.
Definition: MPSolver.java:579
long iterations()
Returns the number of simplex iterations.
Definition: MPSolver.java:418
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.
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
void enableOutput()
Enables solver logging.
Definition: MPSolver.java:404
MPSolver.OptimizationProblemType problemType()
Returns the optimization problem type set at construction.
Definition: MPSolver.java:147
int numConstraints()
Returns the number of constraints.
Definition: MPSolver.java:232
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: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)
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
MPVariable variable(int index)
Returns the variable at position index.
Definition: MPSolver.java:178
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.
MPConstraint makeConstraint()
Creates a constraint with -infinity and +infinity bounds.
Definition: MPSolver.java:281
static BasisStatus swigToEnum(int swigValue)
Definition: MPSolver.java:759
MPSolver(long cPtr, boolean cMemoryOwn)
Definition: MPSolver.java:21
String exportModelAsLpFormat()
Export the loaded model in LP format.
Definition: MPSolver.java:572
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
MPVariable [] makeVarArray(int count, double lb, double ub, boolean integer)
Creates and returns an array of variables.
Definition: MPSolver.java:48
MPVariable makeBoolVar(String name)
Creates a boolean variable.
Definition: MPSolver.java:224
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.
void setHint(MPVariable[] variables, double[] values)
Sets a hint for solution.
Definition: MPSolver.java:603
int numVariables()
Returns the number of variables.
Definition: MPSolver.java:163
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
MPObjective objective()
Returns the mutable objective object.
Definition: MPSolver.java:305
String exportModelAsMpsFormat()
Export the loaded model in MPS format.
Definition: MPSolver.java:586
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
static double infinity()
Infinity.
Definition: MPSolver.java:397
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
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