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();
347 main_research_linear_solverJNI.MPSolver_enableOutput(swigCPtr,
this);
354 main_research_linear_solverJNI.MPSolver_suppressOutput(swigCPtr,
this);
361 return main_research_linear_solverJNI.MPSolver_iterations(swigCPtr,
this);
370 return main_research_linear_solverJNI.MPSolver_nodes(swigCPtr,
this);
398 return main_research_linear_solverJNI.MPSolver_computeExactConditionNumber(swigCPtr,
this);
402 main_research_linear_solverJNI.MPSolver_setTimeLimit(swigCPtr,
this, time_limit_milliseconds);
406 return main_research_linear_solverJNI.MPSolver_wallTime(swigCPtr,
this);
414 return main_research_linear_solverJNI.MPSolver_loadModelFromProto(swigCPtr,
this, input_model.toByteArray());
418 return main_research_linear_solverJNI.MPSolver_loadModelFromProtoWithUniqueNamesOrDie(swigCPtr,
this, input_model.toByteArray());
425 byte[] buf = main_research_linear_solverJNI.MPSolver_exportModelToProto(swigCPtr,
this);
426 if (buf ==
null || buf.length == 0) {
431 }
catch (
com.
google.protobuf.InvalidProtocolBufferException e) {
432 throw new RuntimeException(
433 "Unable to parse com.google.ortools.linearsolver.MPModelProto protocol message.");
441 byte[] buf = main_research_linear_solverJNI.MPSolver_createSolutionResponseProto(swigCPtr,
this);
442 if (buf ==
null || buf.length == 0) {
447 }
catch (
com.
google.protobuf.InvalidProtocolBufferException e) {
448 throw new RuntimeException(
449 "Unable to parse com.google.ortools.linearsolver.MPSolutionResponse protocol message.");
485 return main_research_linear_solverJNI.MPSolver_loadSolutionFromProto(swigCPtr,
this, response.toByteArray());
492 byte[] buf = main_research_linear_solverJNI.MPSolver_solveWithProto(model_request.toByteArray());
493 if (buf ==
null || buf.length == 0) {
498 }
catch (
com.
google.protobuf.InvalidProtocolBufferException e) {
499 throw new RuntimeException(
500 "Unable to parse com.google.ortools.linearsolver.MPSolutionResponse protocol message.");
508 return main_research_linear_solverJNI.MPSolver_exportModelAsLpFormat__SWIG_0(swigCPtr,
this,
MPModelExportOptions.getCPtr(options), options);
515 return main_research_linear_solverJNI.MPSolver_exportModelAsLpFormat__SWIG_1(swigCPtr,
this);
522 return main_research_linear_solverJNI.MPSolver_exportModelAsMpsFormat__SWIG_0(swigCPtr,
this,
MPModelExportOptions.getCPtr(options), options);
529 return main_research_linear_solverJNI.MPSolver_exportModelAsMpsFormat__SWIG_1(swigCPtr,
this);
546 main_research_linear_solverJNI.MPSolver_setHint(swigCPtr,
this,
variables, values);
553 return main_research_linear_solverJNI.MPSolver_setNumThreads(swigCPtr,
this, num_theads);
586 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
587 return swigValues[swigValue];
589 if (swigEnum.swigValue == swigValue)
594 @SuppressWarnings(
"unused")
596 this.swigValue = SwigNext.next++;
599 @SuppressWarnings(
"unused")
600 private OptimizationProblemType(
int swigValue) {
601 this.swigValue = swigValue;
602 SwigNext.next = swigValue+1;
605 @SuppressWarnings(
"unused")
606 private OptimizationProblemType(OptimizationProblemType swigEnum) {
607 this.swigValue = swigEnum.swigValue;
608 SwigNext.next = this.swigValue+1;
611 private final int swigValue;
613 private static class SwigNext {
614 private static int next = 0;
648 NOT_SOLVED(main_research_linear_solverJNI.MPSolver_NOT_SOLVED_get());
656 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
657 return swigValues[swigValue];
659 if (swigEnum.swigValue == swigValue)
661 throw new IllegalArgumentException(
"No enum " +
ResultStatus.class +
" with value " + swigValue);
664 @SuppressWarnings(
"unused")
666 this.swigValue = SwigNext.next++;
669 @SuppressWarnings(
"unused")
670 private ResultStatus(
int swigValue) {
671 this.swigValue = swigValue;
672 SwigNext.next = swigValue+1;
675 @SuppressWarnings(
"unused")
676 private ResultStatus(ResultStatus swigEnum) {
677 this.swigValue = swigEnum.swigValue;
678 SwigNext.next = this.swigValue+1;
681 private final int swigValue;
683 private static class SwigNext {
684 private static int next = 0;
693 FREE(main_research_linear_solverJNI.MPSolver_FREE_get()),
705 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
706 return swigValues[swigValue];
708 if (swigEnum.swigValue == swigValue)
710 throw new IllegalArgumentException(
"No enum " +
BasisStatus.class +
" with value " + swigValue);
713 @SuppressWarnings(
"unused")
715 this.swigValue = SwigNext.next++;
718 @SuppressWarnings(
"unused")
719 private BasisStatus(
int swigValue) {
720 this.swigValue = swigValue;
721 SwigNext.next = swigValue+1;
724 @SuppressWarnings(
"unused")
725 private BasisStatus(BasisStatus swigEnum) {
726 this.swigValue = swigEnum.swigValue;
727 SwigNext.next = this.swigValue+1;
730 private final int swigValue;
732 private static class SwigNext {
733 private static int next = 0;