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);
160 return MPSolver.OptimizationProblemType.swigToEnum(mainJNI.MPSolver_problemType(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);
326 return MPSolver.ResultStatus.swigToEnum(mainJNI.MPSolver_solve__SWIG_0(swigCPtr,
this));
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);
494 return mainJNI.MPSolver_wallTime(swigCPtr,
this);
502 return mainJNI.MPSolver_loadModelFromProto(swigCPtr,
this, input_model.toByteArray());
510 return mainJNI.MPSolver_loadModelFromProtoKeepNames(swigCPtr,
this, input_model.toByteArray());
514 return mainJNI.MPSolver_loadModelFromProtoWithUniqueNamesOrDie(swigCPtr,
this, input_model.toByteArray());
521 byte[] buf = mainJNI.MPSolver_exportModelToProto(swigCPtr,
this);
522 if (buf ==
null || buf.length == 0) {
526 return com.google.ortools.linearsolver.MPModelProto.parseFrom(buf);
527 }
catch (com.google.protobuf.InvalidProtocolBufferException e) {
528 throw new RuntimeException(
529 "Unable to parse com.google.ortools.linearsolver.MPModelProto protocol message.");
537 byte[] buf = mainJNI.MPSolver_createSolutionResponseProto(swigCPtr,
this);
538 if (buf ==
null || buf.length == 0) {
542 return com.google.ortools.linearsolver.MPSolutionResponse.parseFrom(buf);
543 }
catch (com.google.protobuf.InvalidProtocolBufferException e) {
544 throw new RuntimeException(
545 "Unable to parse com.google.ortools.linearsolver.MPSolutionResponse protocol message.");
581 return mainJNI.MPSolver_loadSolutionFromProto(swigCPtr,
this, response.toByteArray());
588 byte[] buf = mainJNI.MPSolver_solveWithProto(model_request.toByteArray());
589 if (buf ==
null || buf.length == 0) {
593 return com.google.ortools.linearsolver.MPSolutionResponse.parseFrom(buf);
594 }
catch (com.google.protobuf.InvalidProtocolBufferException e) {
595 throw new RuntimeException(
596 "Unable to parse com.google.ortools.linearsolver.MPSolutionResponse protocol message.");
604 return mainJNI.MPSolver_exportModelAsLpFormat__SWIG_0(swigCPtr,
this, obfuscate);
611 return mainJNI.MPSolver_exportModelAsLpFormat__SWIG_1(swigCPtr,
this);
618 return mainJNI.MPSolver_exportModelAsMpsFormat(swigCPtr,
this, fixed_format, obfuscate);
625 return mainJNI.MPSolver_writeModelToMpsFile(swigCPtr,
this, filename, fixed_format, obfuscate);
642 mainJNI.MPSolver_setHint(swigCPtr,
this,
variables, values);
649 return mainJNI.MPSolver_setNumThreads(swigCPtr,
this, num_theads);
658 public enum OptimizationProblemType {
679 public static OptimizationProblemType
swigToEnum(
int swigValue) {
680 OptimizationProblemType[] swigValues = OptimizationProblemType.class.getEnumConstants();
681 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
682 return swigValues[swigValue];
683 for (OptimizationProblemType swigEnum : swigValues)
684 if (swigEnum.swigValue == swigValue)
686 throw new IllegalArgumentException(
"No enum " + OptimizationProblemType.class +
" with value " + swigValue);
689 @SuppressWarnings(
"unused")
691 this.swigValue = SwigNext.next++;
694 @SuppressWarnings(
"unused")
695 private OptimizationProblemType(
int swigValue) {
696 this.swigValue = swigValue;
697 SwigNext.next = swigValue+1;
700 @SuppressWarnings(
"unused")
701 private OptimizationProblemType(OptimizationProblemType swigEnum) {
702 this.swigValue = swigEnum.swigValue;
703 SwigNext.next = this.swigValue+1;
706 private final int swigValue;
708 private static class SwigNext {
709 private static int next = 0;
719 public enum ResultStatus {
754 ResultStatus[] swigValues = ResultStatus.class.getEnumConstants();
755 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
756 return swigValues[swigValue];
757 for (ResultStatus swigEnum : swigValues)
758 if (swigEnum.swigValue == swigValue)
760 throw new IllegalArgumentException(
"No enum " + ResultStatus.class +
" with value " + swigValue);
763 @SuppressWarnings(
"unused")
765 this.swigValue = SwigNext.next++;
768 @SuppressWarnings(
"unused")
769 private ResultStatus(
int swigValue) {
770 this.swigValue = swigValue;
771 SwigNext.next = swigValue+1;
774 @SuppressWarnings(
"unused")
775 private ResultStatus(ResultStatus swigEnum) {
776 this.swigValue = swigEnum.swigValue;
777 SwigNext.next = this.swigValue+1;
780 private final int swigValue;
782 private static class SwigNext {
783 private static int next = 0;
791 public enum BasisStatus {
792 FREE(mainJNI.MPSolver_FREE_get()),
803 BasisStatus[] swigValues = BasisStatus.class.getEnumConstants();
804 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
805 return swigValues[swigValue];
806 for (BasisStatus swigEnum : swigValues)
807 if (swigEnum.swigValue == swigValue)
809 throw new IllegalArgumentException(
"No enum " + BasisStatus.class +
" with value " + swigValue);
812 @SuppressWarnings(
"unused")
814 this.swigValue = SwigNext.next++;
817 @SuppressWarnings(
"unused")
818 private BasisStatus(
int swigValue) {
819 this.swigValue = swigValue;
820 SwigNext.next = swigValue+1;
823 @SuppressWarnings(
"unused")
824 private BasisStatus(BasisStatus swigEnum) {
825 this.swigValue = swigEnum.swigValue;
826 SwigNext.next = this.swigValue+1;
829 private final int swigValue;
831 private static class SwigNext {
832 private static int next = 0;