9 package com.google.ortools.linearsolver;
11 import java.lang.reflect.*;
18 private transient long swigCPtr;
19 protected transient boolean swigCMemOwn;
21 protected MPSolver(
long cPtr,
boolean cMemoryOwn) {
22 swigCMemOwn = cMemoryOwn;
26 protected static long getCPtr(
MPSolver obj) {
27 return (obj ==
null) ? 0 : obj.swigCPtr;
30 @SuppressWarnings(
"deprecation")
31 protected
void finalize() {
35 public synchronized void delete() {
39 main_research_linear_solverJNI.delete_MPSolver(swigCPtr);
50 for (
int i = 0; i < count; ++i) {
51 array[i] =
makeVar(lb, ub, integer,
"");
62 for (
int i = 0; i < count; ++i) {
63 array[i] =
makeVar(lb, ub, integer, var_name + i);
96 this(main_research_linear_solverJNI.new_MPSolver(name, problem_type.swigValue()),
true);
104 return main_research_linear_solverJNI.MPSolver_supportsProblemType(problem_type.swigValue());
113 main_research_linear_solverJNI.MPSolver_clear(swigCPtr,
this);
120 return main_research_linear_solverJNI.MPSolver_numVariables(swigCPtr,
this);
128 return main_research_linear_solverJNI.MPSolver_variables(swigCPtr,
this);
137 long cPtr = main_research_linear_solverJNI.MPSolver_lookupVariableOrNull(swigCPtr,
this, var_name);
138 return (cPtr == 0) ? null :
new MPVariable(cPtr,
false);
149 long cPtr = main_research_linear_solverJNI.MPSolver_makeVar(swigCPtr,
this, lb, ub, integer, name);
150 return (cPtr == 0) ? null :
new MPVariable(cPtr,
false);
157 long cPtr = main_research_linear_solverJNI.MPSolver_makeNumVar(swigCPtr,
this, lb, ub, name);
158 return (cPtr == 0) ? null :
new MPVariable(cPtr,
false);
165 long cPtr = main_research_linear_solverJNI.MPSolver_makeIntVar(swigCPtr,
this, lb, ub, name);
166 return (cPtr == 0) ? null :
new MPVariable(cPtr,
false);
173 long cPtr = main_research_linear_solverJNI.MPSolver_makeBoolVar(swigCPtr,
this, name);
174 return (cPtr == 0) ? null :
new MPVariable(cPtr,
false);
181 return main_research_linear_solverJNI.MPSolver_numConstraints(swigCPtr,
this);
190 return main_research_linear_solverJNI.MPSolver_constraints(swigCPtr,
this);
201 long cPtr = main_research_linear_solverJNI.MPSolver_lookupConstraintOrNull(swigCPtr,
this, constraint_name);
202 return (cPtr == 0) ? null :
new MPConstraint(cPtr,
false);
214 long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_0(swigCPtr,
this, lb, ub);
215 return (cPtr == 0) ? null :
new MPConstraint(cPtr,
false);
222 long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_1(swigCPtr,
this);
223 return (cPtr == 0) ? null :
new MPConstraint(cPtr,
false);
230 long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_2(swigCPtr,
this, lb, ub, name);
231 return (cPtr == 0) ? null :
new MPConstraint(cPtr,
false);
238 long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_3(swigCPtr,
this, name);
239 return (cPtr == 0) ? null :
new MPConstraint(cPtr,
false);
246 long cPtr = main_research_linear_solverJNI.MPSolver_objective(swigCPtr,
this);
247 return (cPtr == 0) ? null :
new MPObjective(cPtr,
false);
271 return main_research_linear_solverJNI.MPSolver_computeConstraintActivities(swigCPtr,
this);
293 return main_research_linear_solverJNI.MPSolver_verifySolution(swigCPtr,
this, tolerance, log_errors);
305 main_research_linear_solverJNI.MPSolver_reset(swigCPtr,
this);
317 return main_research_linear_solverJNI.MPSolver_interruptSolve(swigCPtr,
this);
331 return main_research_linear_solverJNI.MPSolver_setSolverSpecificParametersAsString(swigCPtr,
this, parameters);
340 return main_research_linear_solverJNI.MPSolver_infinity();
344 main_research_linear_solverJNI.MPSolver_enableOutput(swigCPtr,
this);
351 main_research_linear_solverJNI.MPSolver_suppressOutput(swigCPtr,
this);
358 return main_research_linear_solverJNI.MPSolver_iterations(swigCPtr,
this);
367 return main_research_linear_solverJNI.MPSolver_nodes(swigCPtr,
this);
395 return main_research_linear_solverJNI.MPSolver_computeExactConditionNumber(swigCPtr,
this);
399 main_research_linear_solverJNI.MPSolver_setTimeLimit(swigCPtr,
this, time_limit_milliseconds);
403 return main_research_linear_solverJNI.MPSolver_wallTime(swigCPtr,
this);
411 return main_research_linear_solverJNI.MPSolver_loadModelFromProto(swigCPtr,
this, input_model.toByteArray());
415 return main_research_linear_solverJNI.MPSolver_loadModelFromProtoWithUniqueNamesOrDie(swigCPtr,
this, input_model.toByteArray());
422 byte[] buf = main_research_linear_solverJNI.MPSolver_exportModelToProto(swigCPtr,
this);
423 if (buf ==
null || buf.length == 0) {
428 }
catch (
com.
google.protobuf.InvalidProtocolBufferException e) {
429 throw new RuntimeException(
430 "Unable to parse com.google.ortools.linearsolver.MPModelProto protocol message.");
438 byte[] buf = main_research_linear_solverJNI.MPSolver_createSolutionResponseProto(swigCPtr,
this);
439 if (buf ==
null || buf.length == 0) {
444 }
catch (
com.
google.protobuf.InvalidProtocolBufferException e) {
445 throw new RuntimeException(
446 "Unable to parse com.google.ortools.linearsolver.MPSolutionResponse protocol message.");
482 return main_research_linear_solverJNI.MPSolver_loadSolutionFromProto(swigCPtr,
this, response.toByteArray());
489 byte[] buf = main_research_linear_solverJNI.MPSolver_solveWithProto(model_request.toByteArray());
490 if (buf ==
null || buf.length == 0) {
495 }
catch (
com.
google.protobuf.InvalidProtocolBufferException e) {
496 throw new RuntimeException(
497 "Unable to parse com.google.ortools.linearsolver.MPSolutionResponse protocol message.");
505 return main_research_linear_solverJNI.MPSolver_exportModelAsLpFormat__SWIG_0(swigCPtr,
this,
MPModelExportOptions.getCPtr(options), options);
512 return main_research_linear_solverJNI.MPSolver_exportModelAsLpFormat__SWIG_1(swigCPtr,
this);
519 return main_research_linear_solverJNI.MPSolver_exportModelAsMpsFormat__SWIG_0(swigCPtr,
this,
MPModelExportOptions.getCPtr(options), options);
526 return main_research_linear_solverJNI.MPSolver_exportModelAsMpsFormat__SWIG_1(swigCPtr,
this);
543 main_research_linear_solverJNI.MPSolver_setHint(swigCPtr,
this,
variables, values);
550 return main_research_linear_solverJNI.MPSolver_setNumThreads(swigCPtr,
this, num_theads);
583 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
584 return swigValues[swigValue];
586 if (swigEnum.swigValue == swigValue)
591 @SuppressWarnings(
"unused")
593 this.swigValue = SwigNext.next++;
596 @SuppressWarnings(
"unused")
597 private OptimizationProblemType(
int swigValue) {
598 this.swigValue = swigValue;
599 SwigNext.next = swigValue+1;
602 @SuppressWarnings(
"unused")
603 private OptimizationProblemType(OptimizationProblemType swigEnum) {
604 this.swigValue = swigEnum.swigValue;
605 SwigNext.next = this.swigValue+1;
608 private final int swigValue;
610 private static class SwigNext {
611 private static int next = 0;
645 NOT_SOLVED(main_research_linear_solverJNI.MPSolver_NOT_SOLVED_get());
653 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
654 return swigValues[swigValue];
656 if (swigEnum.swigValue == swigValue)
658 throw new IllegalArgumentException(
"No enum " +
ResultStatus.class +
" with value " + swigValue);
661 @SuppressWarnings(
"unused")
663 this.swigValue = SwigNext.next++;
666 @SuppressWarnings(
"unused")
667 private ResultStatus(
int swigValue) {
668 this.swigValue = swigValue;
669 SwigNext.next = swigValue+1;
672 @SuppressWarnings(
"unused")
673 private ResultStatus(ResultStatus swigEnum) {
674 this.swigValue = swigEnum.swigValue;
675 SwigNext.next = this.swigValue+1;
678 private final int swigValue;
680 private static class SwigNext {
681 private static int next = 0;
690 FREE(main_research_linear_solverJNI.MPSolver_FREE_get()),
702 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
703 return swigValues[swigValue];
705 if (swigEnum.swigValue == swigValue)
707 throw new IllegalArgumentException(
"No enum " +
BasisStatus.class +
" with value " + swigValue);
710 @SuppressWarnings(
"unused")
712 this.swigValue = SwigNext.next++;
715 @SuppressWarnings(
"unused")
716 private BasisStatus(
int swigValue) {
717 this.swigValue = swigValue;
718 SwigNext.next = swigValue+1;
721 @SuppressWarnings(
"unused")
722 private BasisStatus(BasisStatus swigEnum) {
723 this.swigValue = swigEnum.swigValue;
724 SwigNext.next = this.swigValue+1;
727 private final int swigValue;
729 private static class SwigNext {
730 private static int next = 0;