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.0
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 
13 public class MPSolver {
14  private transient long swigCPtr;
15  protected transient boolean swigCMemOwn;
16 
17  protected MPSolver(long cPtr, boolean cMemoryOwn) {
18  swigCMemOwn = cMemoryOwn;
19  swigCPtr = cPtr;
20  }
21 
22  protected static long getCPtr(MPSolver obj) {
23  return (obj == null) ? 0 : obj.swigCPtr;
24  }
25 
26  @SuppressWarnings("deprecation")
27  protected void finalize() {
28  delete();
29  }
30 
31  public synchronized void delete() {
32  if (swigCPtr != 0) {
33  if (swigCMemOwn) {
34  swigCMemOwn = false;
36  }
37  swigCPtr = 0;
38  }
39  }
40 
41  public MPVariable[] makeVarArray(int count, double lb, double ub, boolean integer) {
42  MPVariable[] array = new MPVariable[count];
43  for (int i = 0; i < count; ++i) {
44  array[i] = makeVar(lb, ub, integer, "");
45  }
46  return array;
47  }
48 
49  public MPVariable[] makeVarArray(int count, double lb, double ub, boolean integer,
50  String var_name) {
51  MPVariable[] array = new MPVariable[count];
52  for (int i = 0; i < count; ++i) {
53  array[i] = makeVar(lb, ub, integer, var_name + i);
54  }
55  return array;
56  }
57 
58  public MPVariable[] makeNumVarArray(int count, double lb, double ub) {
59  return makeVarArray(count, lb, ub, false);
60  }
61 
62  public MPVariable[] makeNumVarArray(int count, double lb, double ub, String var_name) {
63  return makeVarArray(count, lb, ub, false, var_name);
64  }
65 
66  public MPVariable[] makeIntVarArray(int count, double lb, double ub) {
67  return makeVarArray(count, lb, ub, true);
68  }
69 
70  public MPVariable[] makeIntVarArray(int count, double lb, double ub, String var_name) {
71  return makeVarArray(count, lb, ub, true, var_name);
72  }
73 
74  public MPVariable[] makeBoolVarArray(int count) {
75  return makeVarArray(count, 0.0, 1.0, true);
76  }
77 
78  public MPVariable[] makeBoolVarArray(int count, String var_name) {
79  return makeVarArray(count, 0.0, 1.0, true, var_name);
80  }
81 
82  public MPSolver(String name, MPSolver.OptimizationProblemType problem_type) {
83  this(main_research_linear_solverJNI.new_MPSolver(name, problem_type.swigValue()), true);
84  }
85 
86  public static boolean supportsProblemType(MPSolver.OptimizationProblemType problem_type) {
87  return main_research_linear_solverJNI.MPSolver_supportsProblemType(problem_type.swigValue());
88  }
89 
90  public void clear() {
92  }
93 
94  public int numVariables() {
96  }
97 
98  public MPVariable lookupVariableOrNull(String var_name) {
99  long cPtr = main_research_linear_solverJNI.MPSolver_lookupVariableOrNull(swigCPtr, this, var_name);
100  return (cPtr == 0) ? null : new MPVariable(cPtr, false);
101  }
102 
103  public MPVariable makeVar(double lb, double ub, boolean integer, String name) {
104  long cPtr = main_research_linear_solverJNI.MPSolver_makeVar(swigCPtr, this, lb, ub, integer, name);
105  return (cPtr == 0) ? null : new MPVariable(cPtr, false);
106  }
107 
108  public MPVariable makeNumVar(double lb, double ub, String name) {
109  long cPtr = main_research_linear_solverJNI.MPSolver_makeNumVar(swigCPtr, this, lb, ub, name);
110  return (cPtr == 0) ? null : new MPVariable(cPtr, false);
111  }
112 
113  public MPVariable makeIntVar(double lb, double ub, String name) {
114  long cPtr = main_research_linear_solverJNI.MPSolver_makeIntVar(swigCPtr, this, lb, ub, name);
115  return (cPtr == 0) ? null : new MPVariable(cPtr, false);
116  }
117 
118  public MPVariable makeBoolVar(String name) {
119  long cPtr = main_research_linear_solverJNI.MPSolver_makeBoolVar(swigCPtr, this, name);
120  return (cPtr == 0) ? null : new MPVariable(cPtr, false);
121  }
122 
123  public int numConstraints() {
125  }
126 
127  public MPConstraint lookupConstraintOrNull(String constraint_name) {
128  long cPtr = main_research_linear_solverJNI.MPSolver_lookupConstraintOrNull(swigCPtr, this, constraint_name);
129  return (cPtr == 0) ? null : new MPConstraint(cPtr, false);
130  }
131 
132  public MPConstraint makeConstraint(double lb, double ub) {
133  long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_0(swigCPtr, this, lb, ub);
134  return (cPtr == 0) ? null : new MPConstraint(cPtr, false);
135  }
136 
139  return (cPtr == 0) ? null : new MPConstraint(cPtr, false);
140  }
141 
142  public MPConstraint makeConstraint(double lb, double ub, String name) {
143  long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_2(swigCPtr, this, lb, ub, name);
144  return (cPtr == 0) ? null : new MPConstraint(cPtr, false);
145  }
146 
147  public MPConstraint makeConstraint(String name) {
148  long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_3(swigCPtr, this, name);
149  return (cPtr == 0) ? null : new MPConstraint(cPtr, false);
150  }
151 
153  long cPtr = main_research_linear_solverJNI.MPSolver_objective(swigCPtr, this);
154  return (cPtr == 0) ? null : new MPObjective(cPtr, false);
155  }
156 
159  }
160 
163  }
164 
165  public double[] computeConstraintActivities() {
167 }
168 
169  public boolean verifySolution(double tolerance, boolean log_errors) {
170  return main_research_linear_solverJNI.MPSolver_verifySolution(swigCPtr, this, tolerance, log_errors);
171  }
172 
173  public void reset() {
175  }
176 
177  public boolean interruptSolve() {
179  }
180 
181  public boolean setSolverSpecificParametersAsString(String parameters) {
183  }
184 
185  public static double infinity() {
187  }
188 
189  public void enableOutput() {
191  }
192 
193  public void suppressOutput() {
195  }
196 
197  public long iterations() {
199  }
200 
201  public long nodes() {
202  return main_research_linear_solverJNI.MPSolver_nodes(swigCPtr, this);
203  }
204 
205  public double computeExactConditionNumber() {
207  }
208 
209  public void setTimeLimit(long time_limit_milliseconds) {
210  main_research_linear_solverJNI.MPSolver_setTimeLimit(swigCPtr, this, time_limit_milliseconds);
211  }
212 
213  public long wallTime() {
214  return main_research_linear_solverJNI.MPSolver_wallTime(swigCPtr, this);
215  }
216 
218  return main_research_linear_solverJNI.MPSolver_exportModelAsLpFormat__SWIG_0(swigCPtr, this, MPModelExportOptions.getCPtr(options), options);
219  }
220 
221  public String exportModelAsLpFormat() {
223  }
224 
226  return main_research_linear_solverJNI.MPSolver_exportModelAsMpsFormat__SWIG_0(swigCPtr, this, MPModelExportOptions.getCPtr(options), options);
227  }
228 
229  public String exportModelAsMpsFormat() {
231  }
232 
236  public void setHint(MPVariable[] variables, double[] values) {
237  main_research_linear_solverJNI.MPSolver_setHint(swigCPtr, this, variables, values);
238  }
239 
243  public boolean setNumThreads(int num_theads) {
244  return main_research_linear_solverJNI.MPSolver_setNumThreads(swigCPtr, this, num_theads);
245  }
246 
252 
253  public final int swigValue() {
254  return swigValue;
255  }
256 
257  public static OptimizationProblemType swigToEnum(int swigValue) {
258  OptimizationProblemType[] swigValues = OptimizationProblemType.class.getEnumConstants();
259  if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
260  return swigValues[swigValue];
261  for (OptimizationProblemType swigEnum : swigValues)
262  if (swigEnum.swigValue == swigValue)
263  return swigEnum;
264  throw new IllegalArgumentException("No enum " + OptimizationProblemType.class + " with value " + swigValue);
265  }
266 
267  @SuppressWarnings("unused")
268  private OptimizationProblemType() {
269  this.swigValue = SwigNext.next++;
270  }
271 
272  @SuppressWarnings("unused")
273  private OptimizationProblemType(int swigValue) {
274  this.swigValue = swigValue;
275  SwigNext.next = swigValue+1;
276  }
277 
278  @SuppressWarnings("unused")
279  private OptimizationProblemType(OptimizationProblemType swigEnum) {
280  this.swigValue = swigEnum.swigValue;
281  SwigNext.next = this.swigValue+1;
282  }
283 
284  private final int swigValue;
285 
286  private static class SwigNext {
287  private static int next = 0;
288  }
289  }
290 
291  public enum ResultStatus {
298 
299  public final int swigValue() {
300  return swigValue;
301  }
302 
303  public static ResultStatus swigToEnum(int swigValue) {
304  ResultStatus[] swigValues = ResultStatus.class.getEnumConstants();
305  if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
306  return swigValues[swigValue];
307  for (ResultStatus swigEnum : swigValues)
308  if (swigEnum.swigValue == swigValue)
309  return swigEnum;
310  throw new IllegalArgumentException("No enum " + ResultStatus.class + " with value " + swigValue);
311  }
312 
313  @SuppressWarnings("unused")
314  private ResultStatus() {
315  this.swigValue = SwigNext.next++;
316  }
317 
318  @SuppressWarnings("unused")
319  private ResultStatus(int swigValue) {
320  this.swigValue = swigValue;
321  SwigNext.next = swigValue+1;
322  }
323 
324  @SuppressWarnings("unused")
325  private ResultStatus(ResultStatus swigEnum) {
326  this.swigValue = swigEnum.swigValue;
327  SwigNext.next = this.swigValue+1;
328  }
329 
330  private final int swigValue;
331 
332  private static class SwigNext {
333  private static int next = 0;
334  }
335  }
336 
337  public enum BasisStatus {
339  AT_LOWER_BOUND,
340  AT_UPPER_BOUND,
341  FIXED_VALUE,
342  BASIC;
343 
344  public final int swigValue() {
345  return swigValue;
346  }
347 
348  public static BasisStatus swigToEnum(int swigValue) {
349  BasisStatus[] swigValues = BasisStatus.class.getEnumConstants();
350  if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
351  return swigValues[swigValue];
352  for (BasisStatus swigEnum : swigValues)
353  if (swigEnum.swigValue == swigValue)
354  return swigEnum;
355  throw new IllegalArgumentException("No enum " + BasisStatus.class + " with value " + swigValue);
356  }
357 
358  @SuppressWarnings("unused")
359  private BasisStatus() {
360  this.swigValue = SwigNext.next++;
361  }
362 
363  @SuppressWarnings("unused")
364  private BasisStatus(int swigValue) {
365  this.swigValue = swigValue;
366  SwigNext.next = swigValue+1;
367  }
368 
369  @SuppressWarnings("unused")
370  private BasisStatus(BasisStatus swigEnum) {
371  this.swigValue = swigEnum.swigValue;
372  SwigNext.next = this.swigValue+1;
373  }
374 
375  private final int swigValue;
376 
377  private static class SwigNext {
378  private static int next = 0;
379  }
380  }
381 
382 }
static final native long MPSolver_iterations(long jarg1, MPSolver jarg1_)
static final native int MPSolver_solve__SWIG_0(long jarg1, MPSolver jarg1_)
static final native void MPSolver_suppressOutput(long jarg1, MPSolver jarg1_)
static final native int MPSolver_numConstraints(long jarg1, MPSolver jarg1_)
static final native long MPSolver_makeConstraint__SWIG_1(long jarg1, MPSolver jarg1_)
MPVariable [] makeVarArray(int count, double lb, double ub, boolean integer, String var_name)
Definition: MPSolver.java:49
MPVariable [] makeNumVarArray(int count, double lb, double ub, String var_name)
Definition: MPSolver.java:62
boolean setNumThreads(int num_theads)
Sets the number of threads to be used by the solver.
Definition: MPSolver.java:243
MPVariable makeIntVar(double lb, double ub, String name)
Definition: MPSolver.java:113
void setHint(MPVariable[] variables, double[] values)
Set a hint for solution.
Definition: MPSolver.java:236
MPConstraint makeConstraint(String name)
Definition: MPSolver.java:147
static final native long MPSolver_makeConstraint__SWIG_0(long jarg1, MPSolver jarg1_, double jarg2, double jarg3)
MPConstraint makeConstraint(double lb, double ub, String name)
Definition: MPSolver.java:142
void setTimeLimit(long time_limit_milliseconds)
Definition: MPSolver.java:209
MPVariable [] makeBoolVarArray(int count)
Definition: MPSolver.java:74
static final native String MPSolver_exportModelAsLpFormat__SWIG_1(long jarg1, MPSolver jarg1_)
String exportModelAsLpFormat(MPModelExportOptions options)
Definition: MPSolver.java:217
static final native boolean MPSolver_supportsProblemType(int jarg1)
static final native long MPSolver_makeIntVar(long jarg1, MPSolver jarg1_, double jarg2, double jarg3, String jarg4)
static final native boolean MPSolver_setSolverSpecificParametersAsString(long jarg1, MPSolver jarg1_, String jarg2)
static BasisStatus swigToEnum(int swigValue)
Definition: MPSolver.java:348
MPVariable [] makeIntVarArray(int count, double lb, double ub)
Definition: MPSolver.java:66
MPVariable [] makeVarArray(int count, double lb, double ub, boolean integer)
Definition: MPSolver.java:41
static final native void MPSolver_setHint(long jarg1, MPSolver jarg1_, MPVariable[] jarg2, double[] jarg3)
static final native String MPSolver_exportModelAsMpsFormat__SWIG_1(long jarg1, MPSolver jarg1_)
static final native void MPSolver_setTimeLimit(long jarg1, MPSolver jarg1_, long jarg2)
MPConstraint makeConstraint(double lb, double ub)
Definition: MPSolver.java:132
static final native int MPSolver_solve__SWIG_1(long jarg1, MPSolver jarg1_, long jarg2, MPSolverParameters jarg2_)
MPSolver(long cPtr, boolean cMemoryOwn)
Definition: MPSolver.java:17
static final native long MPSolver_makeConstraint__SWIG_2(long jarg1, MPSolver jarg1_, double jarg2, double jarg3, String jarg4)
MPVariable [] makeBoolVarArray(int count, String var_name)
Definition: MPSolver.java:78
MPSolver(String name, MPSolver.OptimizationProblemType problem_type)
Definition: MPSolver.java:82
static final native void MPSolver_reset(long jarg1, MPSolver jarg1_)
MPVariable [] makeIntVarArray(int count, double lb, double ub, String var_name)
Definition: MPSolver.java:70
MPSolver.ResultStatus solve(MPSolverParameters param)
Definition: MPSolver.java:161
static final native boolean MPSolver_setNumThreads(long jarg1, MPSolver jarg1_, int jarg2)
String exportModelAsMpsFormat(MPModelExportOptions options)
Definition: MPSolver.java:225
static ResultStatus swigToEnum(int swigValue)
Definition: MPSolver.java:303
static final native long MPSolver_makeBoolVar(long jarg1, MPSolver jarg1_, String jarg2)
static boolean supportsProblemType(MPSolver.OptimizationProblemType problem_type)
Definition: MPSolver.java:86
static final native String MPSolver_exportModelAsMpsFormat__SWIG_0(long jarg1, MPSolver jarg1_, long jarg2, MPModelExportOptions jarg2_)
MPVariable makeVar(double lb, double ub, boolean integer, String name)
Definition: MPSolver.java:103
static final native void MPSolver_enableOutput(long jarg1, MPSolver jarg1_)
boolean setSolverSpecificParametersAsString(String parameters)
Definition: MPSolver.java:181
boolean verifySolution(double tolerance, boolean log_errors)
Definition: MPSolver.java:169
static final native long MPSolver_objective(long jarg1, MPSolver jarg1_)
static final native boolean MPSolver_verifySolution(long jarg1, MPSolver jarg1_, double jarg2, boolean jarg3)
static final native long MPSolver_makeConstraint__SWIG_3(long jarg1, MPSolver jarg1_, String jarg2)
MPVariable makeNumVar(double lb, double ub, String name)
Definition: MPSolver.java:108
MPConstraint lookupConstraintOrNull(String constraint_name)
Definition: MPSolver.java:127
static final native long MPSolver_wallTime(long jarg1, MPSolver jarg1_)
static final native long new_MPSolver(String jarg1, int jarg2)
MPVariable [] makeNumVarArray(int count, double lb, double ub)
Definition: MPSolver.java:58
MPVariable makeBoolVar(String name)
Definition: MPSolver.java:118
static final native long MPSolver_lookupVariableOrNull(long jarg1, MPSolver jarg1_, String jarg2)
static final native long MPSolver_makeVar(long jarg1, MPSolver jarg1_, double jarg2, double jarg3, boolean jarg4, String jarg5)
static final native double [] MPSolver_computeConstraintActivities(long jarg1, MPSolver jarg1_)
static final native void MPSolver_clear(long jarg1, MPSolver jarg1_)
static final native long MPSolver_lookupConstraintOrNull(long jarg1, MPSolver jarg1_, String jarg2)
static OptimizationProblemType swigToEnum(int swigValue)
Definition: MPSolver.java:257
static final native String MPSolver_exportModelAsLpFormat__SWIG_0(long jarg1, MPSolver jarg1_, long jarg2, MPModelExportOptions jarg2_)
static final native int MPSolver_numVariables(long jarg1, MPSolver jarg1_)
MPVariable lookupVariableOrNull(String var_name)
Definition: MPSolver.java:98
static final native void delete_MPSolver(long jarg1)
static final native long MPSolver_nodes(long jarg1, MPSolver jarg1_)
static final native boolean MPSolver_interruptSolve(long jarg1, MPSolver jarg1_)
static final native long MPSolver_makeNumVar(long jarg1, MPSolver jarg1_, double jarg2, double jarg3, String jarg4)
static final native double MPSolver_computeExactConditionNumber(long jarg1, MPSolver jarg1_)