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 
219  }
220 
221  public String exportModelAsLpFormat() {
223  }
224 
227  }
228 
229  public String exportModelAsMpsFormat() {
231  }
232 
233  public void setHint(SWIGTYPE_p_std__vectorT_operations_research__MPVariable_p_t variables, double[] values) {
234  main_research_linear_solverJNI.MPSolver_setHint(swigCPtr, this, SWIGTYPE_p_std__vectorT_operations_research__MPVariable_p_t.getCPtr(variables), values);
235  }
236 
242 
243  public final int swigValue() {
244  return swigValue;
245  }
246 
247  public static OptimizationProblemType swigToEnum(int swigValue) {
248  OptimizationProblemType[] swigValues = OptimizationProblemType.class.getEnumConstants();
249  if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
250  return swigValues[swigValue];
251  for (OptimizationProblemType swigEnum : swigValues)
252  if (swigEnum.swigValue == swigValue)
253  return swigEnum;
254  throw new IllegalArgumentException("No enum " + OptimizationProblemType.class + " with value " + swigValue);
255  }
256 
257  @SuppressWarnings("unused")
258  private OptimizationProblemType() {
259  this.swigValue = SwigNext.next++;
260  }
261 
262  @SuppressWarnings("unused")
263  private OptimizationProblemType(int swigValue) {
264  this.swigValue = swigValue;
265  SwigNext.next = swigValue+1;
266  }
267 
268  @SuppressWarnings("unused")
269  private OptimizationProblemType(OptimizationProblemType swigEnum) {
270  this.swigValue = swigEnum.swigValue;
271  SwigNext.next = this.swigValue+1;
272  }
273 
274  private final int swigValue;
275 
276  private static class SwigNext {
277  private static int next = 0;
278  }
279  }
280 
281  public enum ResultStatus {
288 
289  public final int swigValue() {
290  return swigValue;
291  }
292 
293  public static ResultStatus swigToEnum(int swigValue) {
294  ResultStatus[] swigValues = ResultStatus.class.getEnumConstants();
295  if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
296  return swigValues[swigValue];
297  for (ResultStatus swigEnum : swigValues)
298  if (swigEnum.swigValue == swigValue)
299  return swigEnum;
300  throw new IllegalArgumentException("No enum " + ResultStatus.class + " with value " + swigValue);
301  }
302 
303  @SuppressWarnings("unused")
304  private ResultStatus() {
305  this.swigValue = SwigNext.next++;
306  }
307 
308  @SuppressWarnings("unused")
309  private ResultStatus(int swigValue) {
310  this.swigValue = swigValue;
311  SwigNext.next = swigValue+1;
312  }
313 
314  @SuppressWarnings("unused")
315  private ResultStatus(ResultStatus swigEnum) {
316  this.swigValue = swigEnum.swigValue;
317  SwigNext.next = this.swigValue+1;
318  }
319 
320  private final int swigValue;
321 
322  private static class SwigNext {
323  private static int next = 0;
324  }
325  }
326 
327  public enum BasisStatus {
329  AT_LOWER_BOUND,
330  AT_UPPER_BOUND,
331  FIXED_VALUE,
332  BASIC;
333 
334  public final int swigValue() {
335  return swigValue;
336  }
337 
338  public static BasisStatus swigToEnum(int swigValue) {
339  BasisStatus[] swigValues = BasisStatus.class.getEnumConstants();
340  if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
341  return swigValues[swigValue];
342  for (BasisStatus swigEnum : swigValues)
343  if (swigEnum.swigValue == swigValue)
344  return swigEnum;
345  throw new IllegalArgumentException("No enum " + BasisStatus.class + " with value " + swigValue);
346  }
347 
348  @SuppressWarnings("unused")
349  private BasisStatus() {
350  this.swigValue = SwigNext.next++;
351  }
352 
353  @SuppressWarnings("unused")
354  private BasisStatus(int swigValue) {
355  this.swigValue = swigValue;
356  SwigNext.next = swigValue+1;
357  }
358 
359  @SuppressWarnings("unused")
360  private BasisStatus(BasisStatus swigEnum) {
361  this.swigValue = swigEnum.swigValue;
362  SwigNext.next = this.swigValue+1;
363  }
364 
365  private final int swigValue;
366 
367  private static class SwigNext {
368  private static int next = 0;
369  }
370  }
371 
372 }
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
MPVariable makeIntVar(double lb, double ub, String name)
Definition: MPSolver.java:113
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:338
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 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
String exportModelAsMpsFormat(MPModelExportOptions options)
Definition: MPSolver.java:225
static ResultStatus swigToEnum(int swigValue)
Definition: MPSolver.java:293
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)
void setHint(SWIGTYPE_p_std__vectorT_operations_research__MPVariable_p_t variables, double[] values)
Definition: MPSolver.java:233
static final native long MPSolver_makeConstraint__SWIG_3(long jarg1, MPSolver jarg1_, String jarg2)
static long getCPtr(MPSolver obj)
Definition: MPSolver.java:22
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 final native void MPSolver_setHint(long jarg1, MPSolver jarg1_, long jarg2, double[] jarg3)
static OptimizationProblemType swigToEnum(int swigValue)
Definition: MPSolver.java:247
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_)