9package com.google.ortools.linearsolver;
11import java.lang.reflect.*;
18 private transient long swigCPtr;
21 protected MPSolver(
long cPtr,
boolean cMemoryOwn) {
27 return (obj ==
null) ? 0 : obj.swigCPtr;
34 throw new RuntimeException(
"Cannot release ownership as memory is not owned");
36 obj.swigCMemOwn =
false;
42 @SuppressWarnings({
"deprecation",
"removal"})
51 mainJNI.delete_MPSolver(swigCPtr);
62 for (
int i = 0; i < count; ++i) {
63 array[i] =
makeVar(lb, ub, integer,
"");
74 for (
int i = 0; i < count; ++i) {
75 array[i] =
makeVar(lb, ub, integer, var_name + i);
108 this(mainJNI.new_MPSolver(name, problem_type.swigValue()),
true);
140 long cPtr = mainJNI.MPSolver_createSolver(solver_id);
141 return (cPtr == 0) ? null :
new MPSolver(cPtr,
true);
149 return mainJNI.MPSolver_supportsProblemType(problem_type.swigValue());
153 return mainJNI.MPSolver_isMip(swigCPtr,
this);
169 mainJNI.MPSolver_clear(swigCPtr,
this);
176 return mainJNI.MPSolver_numVariables(swigCPtr,
this);
184 return mainJNI.MPSolver_variables(swigCPtr,
this);
191 long cPtr = mainJNI.MPSolver_variable(swigCPtr,
this, index);
192 return (cPtr == 0) ? null :
new MPVariable(cPtr,
false);
201 long cPtr = mainJNI.MPSolver_lookupVariableOrNull(swigCPtr,
this, var_name);
202 return (cPtr == 0) ? null :
new MPVariable(cPtr,
false);
213 long cPtr = mainJNI.MPSolver_makeVar(swigCPtr,
this, lb, ub, integer, name);
214 return (cPtr == 0) ? null :
new MPVariable(cPtr,
false);
221 long cPtr = mainJNI.MPSolver_makeNumVar(swigCPtr,
this, lb, ub, name);
222 return (cPtr == 0) ? null :
new MPVariable(cPtr,
false);
229 long cPtr = mainJNI.MPSolver_makeIntVar(swigCPtr,
this, lb, ub, name);
230 return (cPtr == 0) ? null :
new MPVariable(cPtr,
false);
237 long cPtr = mainJNI.MPSolver_makeBoolVar(swigCPtr,
this, name);
238 return (cPtr == 0) ? null :
new MPVariable(cPtr,
false);
245 return mainJNI.MPSolver_numConstraints(swigCPtr,
this);
254 return mainJNI.MPSolver_constraints(swigCPtr,
this);
261 long cPtr = mainJNI.MPSolver_constraint(swigCPtr,
this, index);
262 return (cPtr == 0) ? null :
new MPConstraint(cPtr,
false);
273 long cPtr = mainJNI.MPSolver_lookupConstraintOrNull(swigCPtr,
this, constraint_name);
274 return (cPtr == 0) ? null :
new MPConstraint(cPtr,
false);
286 long cPtr = mainJNI.MPSolver_makeConstraint__SWIG_0(swigCPtr,
this, lb, ub);
287 return (cPtr == 0) ? null :
new MPConstraint(cPtr,
false);
294 long cPtr = mainJNI.MPSolver_makeConstraint__SWIG_1(swigCPtr,
this);
295 return (cPtr == 0) ? null :
new MPConstraint(cPtr,
false);
302 long cPtr = mainJNI.MPSolver_makeConstraint__SWIG_2(swigCPtr,
this, lb, ub, name);
303 return (cPtr == 0) ? null :
new MPConstraint(cPtr,
false);
310 long cPtr = mainJNI.MPSolver_makeConstraint__SWIG_3(swigCPtr,
this, name);
311 return (cPtr == 0) ? null :
new MPConstraint(cPtr,
false);
318 long cPtr = mainJNI.MPSolver_objective(swigCPtr,
this);
319 return (cPtr == 0) ? null :
new MPObjective(cPtr,
false);
325 public MPSolver.ResultStatus
solve() {
340 public void write(String file_name) {
341 mainJNI.MPSolver_write(swigCPtr,
this, file_name);
351 return mainJNI.MPSolver_computeConstraintActivities(swigCPtr,
this);
373 return mainJNI.MPSolver_verifySolution(swigCPtr,
this, tolerance, log_errors);
385 mainJNI.MPSolver_reset(swigCPtr,
this);
399 return mainJNI.MPSolver_interruptSolve(swigCPtr,
this);
409 return mainJNI.MPSolver_setSolverSpecificParametersAsString(swigCPtr,
this, parameters);
418 return mainJNI.MPSolver_infinity();
425 mainJNI.MPSolver_enableOutput(swigCPtr,
this);
432 mainJNI.MPSolver_suppressOutput(swigCPtr,
this);
439 return mainJNI.MPSolver_iterations(swigCPtr,
this);
448 return mainJNI.MPSolver_nodes(swigCPtr,
this);
455 return mainJNI.MPSolver_solverVersion(swigCPtr,
this);
483 return mainJNI.MPSolver_computeExactConditionNumber(swigCPtr,
this);
487 mainJNI.MPSolver_setTimeLimit(swigCPtr,
this, time_limit_milliseconds);
491 return mainJNI.MPSolver_wallTime(swigCPtr,
this);
499 return mainJNI.MPSolver_loadModelFromProto(swigCPtr,
this, input_model.toByteArray());
507 return mainJNI.MPSolver_loadModelFromProtoKeepNames(swigCPtr,
this, input_model.toByteArray());
511 return mainJNI.MPSolver_loadModelFromProtoWithUniqueNamesOrDie(swigCPtr,
this, input_model.toByteArray());
518 byte[] buf = mainJNI.MPSolver_exportModelToProto(swigCPtr,
this);
519 if (buf ==
null || buf.length == 0) {
523 return com.google.ortools.linearsolver.MPModelProto.parseFrom(buf);
524 }
catch (com.google.protobuf.InvalidProtocolBufferException e) {
525 throw new RuntimeException(
526 "Unable to parse com.google.ortools.linearsolver.MPModelProto protocol message.");
534 byte[] buf = mainJNI.MPSolver_createSolutionResponseProto(swigCPtr,
this);
535 if (buf ==
null || buf.length == 0) {
539 return com.google.ortools.linearsolver.MPSolutionResponse.parseFrom(buf);
540 }
catch (com.google.protobuf.InvalidProtocolBufferException e) {
541 throw new RuntimeException(
542 "Unable to parse com.google.ortools.linearsolver.MPSolutionResponse protocol message.");
578 return mainJNI.MPSolver_loadSolutionFromProto(swigCPtr,
this, response.toByteArray());
585 byte[] buf = mainJNI.MPSolver_solveWithProto(model_request.toByteArray());
586 if (buf ==
null || buf.length == 0) {
590 return com.google.ortools.linearsolver.MPSolutionResponse.parseFrom(buf);
591 }
catch (com.google.protobuf.InvalidProtocolBufferException e) {
592 throw new RuntimeException(
593 "Unable to parse com.google.ortools.linearsolver.MPSolutionResponse protocol message.");
608 return mainJNI.MPSolver_exportModelAsLpFormat__SWIG_1(swigCPtr,
this);
622 return mainJNI.MPSolver_exportModelAsMpsFormat__SWIG_1(swigCPtr,
this);
639 mainJNI.MPSolver_setHint(swigCPtr,
this,
variables, values);
646 return mainJNI.MPSolver_setNumThreads(swigCPtr,
this, num_theads);
678 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
679 return swigValues[swigValue];
681 if (swigEnum.swigValue == swigValue)
686 @SuppressWarnings(
"unused")
688 this.swigValue = SwigNext.next++;
691 @SuppressWarnings(
"unused")
692 private OptimizationProblemType(
int swigValue) {
693 this.swigValue = swigValue;
694 SwigNext.next = swigValue+1;
697 @SuppressWarnings(
"unused")
698 private OptimizationProblemType(OptimizationProblemType swigEnum) {
699 this.swigValue = swigEnum.swigValue;
700 SwigNext.next = this.swigValue+1;
703 private final int swigValue;
705 private static class SwigNext {
706 private static int next = 0;
752 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
753 return swigValues[swigValue];
755 if (swigEnum.swigValue == swigValue)
757 throw new IllegalArgumentException(
"No enum " +
ResultStatus.class +
" with value " + swigValue);
760 @SuppressWarnings(
"unused")
762 this.swigValue = SwigNext.next++;
765 @SuppressWarnings(
"unused")
766 private ResultStatus(
int swigValue) {
767 this.swigValue = swigValue;
768 SwigNext.next = swigValue+1;
771 @SuppressWarnings(
"unused")
772 private ResultStatus(ResultStatus swigEnum) {
773 this.swigValue = swigEnum.swigValue;
774 SwigNext.next = this.swigValue+1;
777 private final int swigValue;
779 private static class SwigNext {
780 private static int next = 0;
789 FREE(mainJNI.MPSolver_FREE_get()),
801 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
802 return swigValues[swigValue];
804 if (swigEnum.swigValue == swigValue)
806 throw new IllegalArgumentException(
"No enum " +
BasisStatus.class +
" with value " + swigValue);
809 @SuppressWarnings(
"unused")
811 this.swigValue = SwigNext.next++;
814 @SuppressWarnings(
"unused")
815 private BasisStatus(
int swigValue) {
816 this.swigValue = swigValue;
817 SwigNext.next = swigValue+1;
820 @SuppressWarnings(
"unused")
821 private BasisStatus(BasisStatus swigEnum) {
822 this.swigValue = swigEnum.swigValue;
823 SwigNext.next = this.swigValue+1;
826 private final int swigValue;
828 private static class SwigNext {
829 private static int next = 0;