MPSolver.java
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2  * This file was automatically generated by SWIG (http://www.swig.org).
3  * Version 3.0.12
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  protected void finalize() {
27  delete();
28  }
29 
30  public synchronized void delete() {
31  if (swigCPtr != 0) {
32  if (swigCMemOwn) {
33  swigCMemOwn = false;
35  }
36  swigCPtr = 0;
37  }
38  }
39 
40  public MPVariable[] makeVarArray(int count, double lb, double ub, boolean integer) {
41  MPVariable[] array = new MPVariable[count];
42  for (int i = 0; i < count; ++i) {
43  array[i] = makeVar(lb, ub, integer, "");
44  }
45  return array;
46  }
47 
48  public MPVariable[] makeVarArray(int count, double lb, double ub, boolean integer,
49  String var_name) {
50  MPVariable[] array = new MPVariable[count];
51  for (int i = 0; i < count; ++i) {
52  array[i] = makeVar(lb, ub, integer, var_name + i);
53  }
54  return array;
55  }
56 
57  public MPVariable[] makeNumVarArray(int count, double lb, double ub) {
58  return makeVarArray(count, lb, ub, false);
59  }
60 
61  public MPVariable[] makeNumVarArray(int count, double lb, double ub, String var_name) {
62  return makeVarArray(count, lb, ub, false, var_name);
63  }
64 
65  public MPVariable[] makeIntVarArray(int count, double lb, double ub) {
66  return makeVarArray(count, lb, ub, true);
67  }
68 
69  public MPVariable[] makeIntVarArray(int count, double lb, double ub, String var_name) {
70  return makeVarArray(count, lb, ub, true, var_name);
71  }
72 
73  public MPVariable[] makeBoolVarArray(int count) {
74  return makeVarArray(count, 0.0, 1.0, true);
75  }
76 
77  public MPVariable[] makeBoolVarArray(int count, String var_name) {
78  return makeVarArray(count, 0.0, 1.0, true, var_name);
79  }
80 
81  public MPSolver(String name, MPSolver.OptimizationProblemType problem_type) {
82  this(main_research_linear_solverJNI.new_MPSolver(name, problem_type.swigValue()), true);
83  }
84 
85  public static boolean supportsProblemType(MPSolver.OptimizationProblemType problem_type) {
86  return main_research_linear_solverJNI.MPSolver_supportsProblemType(problem_type.swigValue());
87  }
88 
89  public void clear() {
91  }
92 
93  public int numVariables() {
95  }
96 
97  public MPVariable lookupVariableOrNull(String var_name) {
98  long cPtr = main_research_linear_solverJNI.MPSolver_lookupVariableOrNull(swigCPtr, this, var_name);
99  return (cPtr == 0) ? null : new MPVariable(cPtr, false);
100  }
101 
102  public MPVariable makeVar(double lb, double ub, boolean integer, String name) {
103  long cPtr = main_research_linear_solverJNI.MPSolver_makeVar(swigCPtr, this, lb, ub, integer, name);
104  return (cPtr == 0) ? null : new MPVariable(cPtr, false);
105  }
106 
107  public MPVariable makeNumVar(double lb, double ub, String name) {
108  long cPtr = main_research_linear_solverJNI.MPSolver_makeNumVar(swigCPtr, this, lb, ub, name);
109  return (cPtr == 0) ? null : new MPVariable(cPtr, false);
110  }
111 
112  public MPVariable makeIntVar(double lb, double ub, String name) {
113  long cPtr = main_research_linear_solverJNI.MPSolver_makeIntVar(swigCPtr, this, lb, ub, name);
114  return (cPtr == 0) ? null : new MPVariable(cPtr, false);
115  }
116 
117  public MPVariable makeBoolVar(String name) {
118  long cPtr = main_research_linear_solverJNI.MPSolver_makeBoolVar(swigCPtr, this, name);
119  return (cPtr == 0) ? null : new MPVariable(cPtr, false);
120  }
121 
122  public int numConstraints() {
124  }
125 
126  public MPConstraint lookupConstraintOrNull(String constraint_name) {
127  long cPtr = main_research_linear_solverJNI.MPSolver_lookupConstraintOrNull(swigCPtr, this, constraint_name);
128  return (cPtr == 0) ? null : new MPConstraint(cPtr, false);
129  }
130 
131  public MPConstraint makeConstraint(double lb, double ub) {
132  long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_0(swigCPtr, this, lb, ub);
133  return (cPtr == 0) ? null : new MPConstraint(cPtr, false);
134  }
135 
138  return (cPtr == 0) ? null : new MPConstraint(cPtr, false);
139  }
140 
141  public MPConstraint makeConstraint(double lb, double ub, String name) {
142  long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_2(swigCPtr, this, lb, ub, name);
143  return (cPtr == 0) ? null : new MPConstraint(cPtr, false);
144  }
145 
146  public MPConstraint makeConstraint(String name) {
147  long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_3(swigCPtr, this, name);
148  return (cPtr == 0) ? null : new MPConstraint(cPtr, false);
149  }
150 
152  long cPtr = main_research_linear_solverJNI.MPSolver_objective(swigCPtr, this);
153  return (cPtr == 0) ? null : new MPObjective(cPtr, false);
154  }
155 
158  }
159 
162  }
163 
164  public double[] computeConstraintActivities() {
166 }
167 
168  public boolean verifySolution(double tolerance, boolean log_errors) {
169  return main_research_linear_solverJNI.MPSolver_verifySolution(swigCPtr, this, tolerance, log_errors);
170  }
171 
172  public void reset() {
174  }
175 
176  public boolean interruptSolve() {
178  }
179 
180  public boolean setSolverSpecificParametersAsString(String parameters) {
182  }
183 
184  public static double infinity() {
186  }
187 
188  public void enableOutput() {
190  }
191 
192  public void suppressOutput() {
194  }
195 
196  public long iterations() {
198  }
199 
200  public long nodes() {
201  return main_research_linear_solverJNI.MPSolver_nodes(swigCPtr, this);
202  }
203 
204  public double computeExactConditionNumber() {
206  }
207 
208  public void setTimeLimit(long time_limit_milliseconds) {
209  main_research_linear_solverJNI.MPSolver_setTimeLimit(swigCPtr, this, time_limit_milliseconds);
210  }
211 
212  public long wallTime() {
213  return main_research_linear_solverJNI.MPSolver_wallTime(swigCPtr, this);
214  }
215 
218  }
219 
220  public String exportModelAsLpFormat() {
222  }
223 
226  }
227 
228  public String exportModelAsMpsFormat() {
230  }
231 
232  public void setHint(SWIGTYPE_p_std__vectorT_operations_research__MPVariable_p_t variables, double[] values) {
233  main_research_linear_solverJNI.MPSolver_setHint(swigCPtr, this, SWIGTYPE_p_std__vectorT_operations_research__MPVariable_p_t.getCPtr(variables), values);
234  }
235 
241 
242  public final int swigValue() {
243  return swigValue;
244  }
245 
246  public static OptimizationProblemType swigToEnum(int swigValue) {
247  OptimizationProblemType[] swigValues = OptimizationProblemType.class.getEnumConstants();
248  if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
249  return swigValues[swigValue];
250  for (OptimizationProblemType swigEnum : swigValues)
251  if (swigEnum.swigValue == swigValue)
252  return swigEnum;
253  throw new IllegalArgumentException("No enum " + OptimizationProblemType.class + " with value " + swigValue);
254  }
255 
256  @SuppressWarnings("unused")
257  private OptimizationProblemType() {
258  this.swigValue = SwigNext.next++;
259  }
260 
261  @SuppressWarnings("unused")
262  private OptimizationProblemType(int swigValue) {
263  this.swigValue = swigValue;
264  SwigNext.next = swigValue+1;
265  }
266 
267  @SuppressWarnings("unused")
268  private OptimizationProblemType(OptimizationProblemType swigEnum) {
269  this.swigValue = swigEnum.swigValue;
270  SwigNext.next = this.swigValue+1;
271  }
272 
273  private final int swigValue;
274 
275  private static class SwigNext {
276  private static int next = 0;
277  }
278  }
279 
280  public enum ResultStatus {
287 
288  public final int swigValue() {
289  return swigValue;
290  }
291 
292  public static ResultStatus swigToEnum(int swigValue) {
293  ResultStatus[] swigValues = ResultStatus.class.getEnumConstants();
294  if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
295  return swigValues[swigValue];
296  for (ResultStatus swigEnum : swigValues)
297  if (swigEnum.swigValue == swigValue)
298  return swigEnum;
299  throw new IllegalArgumentException("No enum " + ResultStatus.class + " with value " + swigValue);
300  }
301 
302  @SuppressWarnings("unused")
303  private ResultStatus() {
304  this.swigValue = SwigNext.next++;
305  }
306 
307  @SuppressWarnings("unused")
308  private ResultStatus(int swigValue) {
309  this.swigValue = swigValue;
310  SwigNext.next = swigValue+1;
311  }
312 
313  @SuppressWarnings("unused")
314  private ResultStatus(ResultStatus swigEnum) {
315  this.swigValue = swigEnum.swigValue;
316  SwigNext.next = this.swigValue+1;
317  }
318 
319  private final int swigValue;
320 
321  private static class SwigNext {
322  private static int next = 0;
323  }
324  }
325 
326  public enum BasisStatus {
328  AT_LOWER_BOUND,
329  AT_UPPER_BOUND,
330  FIXED_VALUE,
331  BASIC;
332 
333  public final int swigValue() {
334  return swigValue;
335  }
336 
337  public static BasisStatus swigToEnum(int swigValue) {
338  BasisStatus[] swigValues = BasisStatus.class.getEnumConstants();
339  if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
340  return swigValues[swigValue];
341  for (BasisStatus swigEnum : swigValues)
342  if (swigEnum.swigValue == swigValue)
343  return swigEnum;
344  throw new IllegalArgumentException("No enum " + BasisStatus.class + " with value " + swigValue);
345  }
346 
347  @SuppressWarnings("unused")
348  private BasisStatus() {
349  this.swigValue = SwigNext.next++;
350  }
351 
352  @SuppressWarnings("unused")
353  private BasisStatus(int swigValue) {
354  this.swigValue = swigValue;
355  SwigNext.next = swigValue+1;
356  }
357 
358  @SuppressWarnings("unused")
359  private BasisStatus(BasisStatus swigEnum) {
360  this.swigValue = swigEnum.swigValue;
361  SwigNext.next = this.swigValue+1;
362  }
363 
364  private final int swigValue;
365 
366  private static class SwigNext {
367  private static int next = 0;
368  }
369  }
370 
371 }
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:48
MPVariable [] makeNumVarArray(int count, double lb, double ub, String var_name)
Definition: MPSolver.java:61
MPVariable makeIntVar(double lb, double ub, String name)
Definition: MPSolver.java:112
MPConstraint makeConstraint(String name)
Definition: MPSolver.java:146
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:141
void setTimeLimit(long time_limit_milliseconds)
Definition: MPSolver.java:208
MPVariable [] makeBoolVarArray(int count)
Definition: MPSolver.java:73
static final native String MPSolver_exportModelAsLpFormat__SWIG_1(long jarg1, MPSolver jarg1_)
String exportModelAsLpFormat(MPModelExportOptions options)
Definition: MPSolver.java:216
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:337
MPVariable [] makeIntVarArray(int count, double lb, double ub)
Definition: MPSolver.java:65
MPVariable [] makeVarArray(int count, double lb, double ub, boolean integer)
Definition: MPSolver.java:40
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:131
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:77
MPSolver(String name, MPSolver.OptimizationProblemType problem_type)
Definition: MPSolver.java:81
static final native void MPSolver_reset(long jarg1, MPSolver jarg1_)
MPVariable [] makeIntVarArray(int count, double lb, double ub, String var_name)
Definition: MPSolver.java:69
MPSolver.ResultStatus solve(MPSolverParameters param)
Definition: MPSolver.java:160
String exportModelAsMpsFormat(MPModelExportOptions options)
Definition: MPSolver.java:224
static ResultStatus swigToEnum(int swigValue)
Definition: MPSolver.java:292
static final native long MPSolver_makeBoolVar(long jarg1, MPSolver jarg1_, String jarg2)
static boolean supportsProblemType(MPSolver.OptimizationProblemType problem_type)
Definition: MPSolver.java:85
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:102
static final native void MPSolver_enableOutput(long jarg1, MPSolver jarg1_)
boolean setSolverSpecificParametersAsString(String parameters)
Definition: MPSolver.java:180
boolean verifySolution(double tolerance, boolean log_errors)
Definition: MPSolver.java:168
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:232
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:107
MPConstraint lookupConstraintOrNull(String constraint_name)
Definition: MPSolver.java:126
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:57
MPVariable makeBoolVar(String name)
Definition: MPSolver.java:117
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:246
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:97
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_)