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);
47 for (
int i = 0; i < count; ++i) {
48 array[i] =
makeVar(lb, ub, integer,
"");
56 for (
int i = 0; i < count; ++i) {
57 array[i] =
makeVar(lb, ub, integer, var_name + i);
90 this(main_research_linear_solverJNI.new_MPSolver(name, problem_type.swigValue()),
true);
98 return main_research_linear_solverJNI.MPSolver_supportsProblemType(problem_type.swigValue());
107 main_research_linear_solverJNI.MPSolver_clear(swigCPtr,
this);
114 return main_research_linear_solverJNI.MPSolver_numVariables(swigCPtr,
this);
122 return main_research_linear_solverJNI.MPSolver_variables(swigCPtr,
this);
131 long cPtr = main_research_linear_solverJNI.MPSolver_lookupVariableOrNull(swigCPtr,
this, var_name);
132 return (cPtr == 0) ? null :
new MPVariable(cPtr,
false);
143 long cPtr = main_research_linear_solverJNI.MPSolver_makeVar(swigCPtr,
this, lb, ub, integer, name);
144 return (cPtr == 0) ? null :
new MPVariable(cPtr,
false);
151 long cPtr = main_research_linear_solverJNI.MPSolver_makeNumVar(swigCPtr,
this, lb, ub, name);
152 return (cPtr == 0) ? null :
new MPVariable(cPtr,
false);
159 long cPtr = main_research_linear_solverJNI.MPSolver_makeIntVar(swigCPtr,
this, lb, ub, name);
160 return (cPtr == 0) ? null :
new MPVariable(cPtr,
false);
167 long cPtr = main_research_linear_solverJNI.MPSolver_makeBoolVar(swigCPtr,
this, name);
168 return (cPtr == 0) ? null :
new MPVariable(cPtr,
false);
175 return main_research_linear_solverJNI.MPSolver_numConstraints(swigCPtr,
this);
184 return main_research_linear_solverJNI.MPSolver_constraints(swigCPtr,
this);
195 long cPtr = main_research_linear_solverJNI.MPSolver_lookupConstraintOrNull(swigCPtr,
this, constraint_name);
196 return (cPtr == 0) ? null :
new MPConstraint(cPtr,
false);
208 long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_0(swigCPtr,
this, lb, ub);
209 return (cPtr == 0) ? null :
new MPConstraint(cPtr,
false);
216 long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_1(swigCPtr,
this);
217 return (cPtr == 0) ? null :
new MPConstraint(cPtr,
false);
224 long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_2(swigCPtr,
this, lb, ub, name);
225 return (cPtr == 0) ? null :
new MPConstraint(cPtr,
false);
232 long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_3(swigCPtr,
this, name);
233 return (cPtr == 0) ? null :
new MPConstraint(cPtr,
false);
240 long cPtr = main_research_linear_solverJNI.MPSolver_objective(swigCPtr,
this);
241 return (cPtr == 0) ? null :
new MPObjective(cPtr,
false);
265 return main_research_linear_solverJNI.MPSolver_computeConstraintActivities(swigCPtr,
this);
287 return main_research_linear_solverJNI.MPSolver_verifySolution(swigCPtr,
this, tolerance, log_errors);
299 main_research_linear_solverJNI.MPSolver_reset(swigCPtr,
this);
311 return main_research_linear_solverJNI.MPSolver_interruptSolve(swigCPtr,
this);
346 return new SWIGTYPE_p_util__Status(main_research_linear_solverJNI.MPSolver_loadSolutionFromProto__SWIG_0(swigCPtr,
this, response.toByteArray(), tolerance),
true);
381 return new SWIGTYPE_p_util__Status(main_research_linear_solverJNI.MPSolver_loadSolutionFromProto__SWIG_1(swigCPtr,
this, response.toByteArray()),
true);
395 return main_research_linear_solverJNI.MPSolver_setSolverSpecificParametersAsString(swigCPtr,
this, parameters);
404 return main_research_linear_solverJNI.MPSolver_infinity();
411 main_research_linear_solverJNI.MPSolver_enableOutput(swigCPtr,
this);
418 main_research_linear_solverJNI.MPSolver_suppressOutput(swigCPtr,
this);
425 return main_research_linear_solverJNI.MPSolver_iterations(swigCPtr,
this);
434 return main_research_linear_solverJNI.MPSolver_nodes(swigCPtr,
this);
462 return main_research_linear_solverJNI.MPSolver_computeExactConditionNumber(swigCPtr,
this);
466 main_research_linear_solverJNI.MPSolver_setTimeLimit(swigCPtr,
this, time_limit_milliseconds);
470 return main_research_linear_solverJNI.MPSolver_wallTime(swigCPtr,
this);
474 return main_research_linear_solverJNI.MPSolver_loadModelFromProto(swigCPtr,
this, input_model.toByteArray());
478 return main_research_linear_solverJNI.MPSolver_loadModelFromProtoWithUniqueNamesOrDie(swigCPtr,
this, input_model.toByteArray());
482 byte[] buf = main_research_linear_solverJNI.MPSolver_exportModelToProto(swigCPtr,
this);
483 if (buf ==
null || buf.length == 0) {
488 }
catch (
com.
google.protobuf.InvalidProtocolBufferException e) {
489 throw new RuntimeException(
490 "Unable to parse com.google.ortools.linearsolver.MPModelProto protocol message.");
495 byte[] buf = main_research_linear_solverJNI.MPSolver_createSolutionResponseProto(swigCPtr,
this);
496 if (buf ==
null || buf.length == 0) {
501 }
catch (
com.
google.protobuf.InvalidProtocolBufferException e) {
502 throw new RuntimeException(
503 "Unable to parse com.google.ortools.linearsolver.MPSolutionResponse protocol message.");
508 byte[] buf = main_research_linear_solverJNI.MPSolver_solveWithProto(model_request.toByteArray());
509 if (buf ==
null || buf.length == 0) {
514 }
catch (
com.
google.protobuf.InvalidProtocolBufferException e) {
515 throw new RuntimeException(
516 "Unable to parse com.google.ortools.linearsolver.MPSolutionResponse protocol message.");
521 return main_research_linear_solverJNI.MPSolver_exportModelAsLpFormat__SWIG_0(swigCPtr,
this,
MPModelExportOptions.getCPtr(options), options);
525 return main_research_linear_solverJNI.MPSolver_exportModelAsLpFormat__SWIG_1(swigCPtr,
this);
529 return main_research_linear_solverJNI.MPSolver_exportModelAsMpsFormat__SWIG_0(swigCPtr,
this,
MPModelExportOptions.getCPtr(options), options);
533 return main_research_linear_solverJNI.MPSolver_exportModelAsMpsFormat__SWIG_1(swigCPtr,
this);
540 main_research_linear_solverJNI.MPSolver_setHint(swigCPtr,
this,
variables, values);
547 return main_research_linear_solverJNI.MPSolver_setNumThreads(swigCPtr,
this, num_theads);
580 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
581 return swigValues[swigValue];
583 if (swigEnum.swigValue == swigValue)
588 @SuppressWarnings(
"unused")
590 this.swigValue = SwigNext.next++;
593 @SuppressWarnings(
"unused")
594 private OptimizationProblemType(
int swigValue) {
595 this.swigValue = swigValue;
596 SwigNext.next = swigValue+1;
599 @SuppressWarnings(
"unused")
600 private OptimizationProblemType(OptimizationProblemType swigEnum) {
601 this.swigValue = swigEnum.swigValue;
602 SwigNext.next = this.swigValue+1;
605 private final int swigValue;
607 private static class SwigNext {
608 private static int next = 0;
642 NOT_SOLVED(main_research_linear_solverJNI.MPSolver_NOT_SOLVED_get());
650 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
651 return swigValues[swigValue];
653 if (swigEnum.swigValue == swigValue)
655 throw new IllegalArgumentException(
"No enum " +
ResultStatus.class +
" with value " + swigValue);
658 @SuppressWarnings(
"unused")
660 this.swigValue = SwigNext.next++;
663 @SuppressWarnings(
"unused")
664 private ResultStatus(
int swigValue) {
665 this.swigValue = swigValue;
666 SwigNext.next = swigValue+1;
669 @SuppressWarnings(
"unused")
670 private ResultStatus(ResultStatus swigEnum) {
671 this.swigValue = swigEnum.swigValue;
672 SwigNext.next = this.swigValue+1;
675 private final int swigValue;
677 private static class SwigNext {
678 private static int next = 0;
687 FREE(main_research_linear_solverJNI.MPSolver_FREE_get()),
699 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
700 return swigValues[swigValue];
702 if (swigEnum.swigValue == swigValue)
704 throw new IllegalArgumentException(
"No enum " +
BasisStatus.class +
" with value " + swigValue);
707 @SuppressWarnings(
"unused")
709 this.swigValue = SwigNext.next++;
712 @SuppressWarnings(
"unused")
713 private BasisStatus(
int swigValue) {
714 this.swigValue = swigValue;
715 SwigNext.next = swigValue+1;
718 @SuppressWarnings(
"unused")
719 private BasisStatus(BasisStatus swigEnum) {
720 this.swigValue = swigEnum.swigValue;
721 SwigNext.next = this.swigValue+1;
724 private final int swigValue;
726 private static class SwigNext {
727 private static int next = 0;