Java Reference

Java Reference

MPSolver.java
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2  * This file was automatically generated by SWIG (http://www.swig.org).
3  * Version 4.0.2
4  *
5  * Do not make changes to this file unless you know what you are doing--modify
6  * the SWIG interface file instead.
7  * ----------------------------------------------------------------------------- */
8 
9 package com.google.ortools.linearsolver;
10 
11 import java.lang.reflect.*;
12 
17 public class MPSolver {
18  private transient long swigCPtr;
19  protected transient boolean swigCMemOwn;
20 
21  protected MPSolver(long cPtr, boolean cMemoryOwn) {
22  swigCMemOwn = cMemoryOwn;
23  swigCPtr = cPtr;
24  }
25 
26  protected static long getCPtr(MPSolver obj) {
27  return (obj == null) ? 0 : obj.swigCPtr;
28  }
29 
30  @SuppressWarnings("deprecation")
31  protected void finalize() {
32  delete();
33  }
34 
35  public synchronized void delete() {
36  if (swigCPtr != 0) {
37  if (swigCMemOwn) {
38  swigCMemOwn = false;
39  main_research_linear_solverJNI.delete_MPSolver(swigCPtr);
40  }
41  swigCPtr = 0;
42  }
43  }
44 
48  public MPVariable[] makeVarArray(int count, double lb, double ub, boolean integer) {
49  MPVariable[] array = new MPVariable[count];
50  for (int i = 0; i < count; ++i) {
51  array[i] = makeVar(lb, ub, integer, "");
52  }
53  return array;
54  }
55 
59  public MPVariable[] makeVarArray(int count, double lb, double ub, boolean integer,
60  String var_name) {
61  MPVariable[] array = new MPVariable[count];
62  for (int i = 0; i < count; ++i) {
63  array[i] = makeVar(lb, ub, integer, var_name + i);
64  }
65  return array;
66  }
67 
68  public MPVariable[] makeNumVarArray(int count, double lb, double ub) {
69  return makeVarArray(count, lb, ub, false);
70  }
71 
72  public MPVariable[] makeNumVarArray(int count, double lb, double ub, String var_name) {
73  return makeVarArray(count, lb, ub, false, var_name);
74  }
75 
76  public MPVariable[] makeIntVarArray(int count, double lb, double ub) {
77  return makeVarArray(count, lb, ub, true);
78  }
79 
80  public MPVariable[] makeIntVarArray(int count, double lb, double ub, String var_name) {
81  return makeVarArray(count, lb, ub, true, var_name);
82  }
83 
84  public MPVariable[] makeBoolVarArray(int count) {
85  return makeVarArray(count, 0.0, 1.0, true);
86  }
87 
88  public MPVariable[] makeBoolVarArray(int count, String var_name) {
89  return makeVarArray(count, 0.0, 1.0, true, var_name);
90  }
91 
95  public MPSolver(String name, MPSolver.OptimizationProblemType problem_type) {
96  this(main_research_linear_solverJNI.new_MPSolver(name, problem_type.swigValue()), true);
97  }
98 
127  public static MPSolver createSolver(String solver_id) {
128  long cPtr = main_research_linear_solverJNI.MPSolver_createSolver(solver_id);
129  return (cPtr == 0) ? null : new MPSolver(cPtr, true);
130  }
131 
136  public static boolean supportsProblemType(MPSolver.OptimizationProblemType problem_type) {
137  return main_research_linear_solverJNI.MPSolver_supportsProblemType(problem_type.swigValue());
138  }
139 
140  public boolean isMip() {
141  return main_research_linear_solverJNI.MPSolver_isMip(swigCPtr, this);
142  }
143 
149  public void clear() {
150  main_research_linear_solverJNI.MPSolver_clear(swigCPtr, this);
151  }
152 
156  public int numVariables() {
157  return main_research_linear_solverJNI.MPSolver_numVariables(swigCPtr, this);
158  }
159 
164  public MPVariable[] variables() {
165  return main_research_linear_solverJNI.MPSolver_variables(swigCPtr, this);
166 }
167 
171  public MPVariable variable(int index) {
172  long cPtr = main_research_linear_solverJNI.MPSolver_variable(swigCPtr, this, index);
173  return (cPtr == 0) ? null : new MPVariable(cPtr, false);
174  }
175 
181  public MPVariable lookupVariableOrNull(String var_name) {
182  long cPtr = main_research_linear_solverJNI.MPSolver_lookupVariableOrNull(swigCPtr, this, var_name);
183  return (cPtr == 0) ? null : new MPVariable(cPtr, false);
184  }
185 
193  public MPVariable makeVar(double lb, double ub, boolean integer, String name) {
194  long cPtr = main_research_linear_solverJNI.MPSolver_makeVar(swigCPtr, this, lb, ub, integer, name);
195  return (cPtr == 0) ? null : new MPVariable(cPtr, false);
196  }
197 
201  public MPVariable makeNumVar(double lb, double ub, String name) {
202  long cPtr = main_research_linear_solverJNI.MPSolver_makeNumVar(swigCPtr, this, lb, ub, name);
203  return (cPtr == 0) ? null : new MPVariable(cPtr, false);
204  }
205 
209  public MPVariable makeIntVar(double lb, double ub, String name) {
210  long cPtr = main_research_linear_solverJNI.MPSolver_makeIntVar(swigCPtr, this, lb, ub, name);
211  return (cPtr == 0) ? null : new MPVariable(cPtr, false);
212  }
213 
217  public MPVariable makeBoolVar(String name) {
218  long cPtr = main_research_linear_solverJNI.MPSolver_makeBoolVar(swigCPtr, this, name);
219  return (cPtr == 0) ? null : new MPVariable(cPtr, false);
220  }
221 
225  public int numConstraints() {
226  return main_research_linear_solverJNI.MPSolver_numConstraints(swigCPtr, this);
227  }
228 
235  return main_research_linear_solverJNI.MPSolver_constraints(swigCPtr, this);
236 }
237 
241  public MPConstraint constraint(int index) {
242  long cPtr = main_research_linear_solverJNI.MPSolver_constraint(swigCPtr, this, index);
243  return (cPtr == 0) ? null : new MPConstraint(cPtr, false);
244  }
245 
253  public MPConstraint lookupConstraintOrNull(String constraint_name) {
254  long cPtr = main_research_linear_solverJNI.MPSolver_lookupConstraintOrNull(swigCPtr, this, constraint_name);
255  return (cPtr == 0) ? null : new MPConstraint(cPtr, false);
256  }
257 
266  public MPConstraint makeConstraint(double lb, double ub) {
267  long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_0(swigCPtr, this, lb, ub);
268  return (cPtr == 0) ? null : new MPConstraint(cPtr, false);
269  }
270 
275  long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_1(swigCPtr, this);
276  return (cPtr == 0) ? null : new MPConstraint(cPtr, false);
277  }
278 
282  public MPConstraint makeConstraint(double lb, double ub, String name) {
283  long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_2(swigCPtr, this, lb, ub, name);
284  return (cPtr == 0) ? null : new MPConstraint(cPtr, false);
285  }
286 
290  public MPConstraint makeConstraint(String name) {
291  long cPtr = main_research_linear_solverJNI.MPSolver_makeConstraint__SWIG_3(swigCPtr, this, name);
292  return (cPtr == 0) ? null : new MPConstraint(cPtr, false);
293  }
294 
299  long cPtr = main_research_linear_solverJNI.MPSolver_objective(swigCPtr, this);
300  return (cPtr == 0) ? null : new MPObjective(cPtr, false);
301  }
302 
307  return MPSolver.ResultStatus.swigToEnum(main_research_linear_solverJNI.MPSolver_solve__SWIG_0(swigCPtr, this));
308  }
309 
314  return MPSolver.ResultStatus.swigToEnum(main_research_linear_solverJNI.MPSolver_solve__SWIG_1(swigCPtr, this, MPSolverParameters.getCPtr(param), param));
315  }
316 
323  public double[] computeConstraintActivities() {
324  return main_research_linear_solverJNI.MPSolver_computeConstraintActivities(swigCPtr, this);
325 }
326 
345  public boolean verifySolution(double tolerance, boolean log_errors) {
346  return main_research_linear_solverJNI.MPSolver_verifySolution(swigCPtr, this, tolerance, log_errors);
347  }
348 
357  public void reset() {
358  main_research_linear_solverJNI.MPSolver_reset(swigCPtr, this);
359  }
360 
369  public boolean interruptSolve() {
370  return main_research_linear_solverJNI.MPSolver_interruptSolve(swigCPtr, this);
371  }
372 
379  public boolean setSolverSpecificParametersAsString(String parameters) {
380  return main_research_linear_solverJNI.MPSolver_setSolverSpecificParametersAsString(swigCPtr, this, parameters);
381  }
382 
388  public static double infinity() {
389  return main_research_linear_solverJNI.MPSolver_infinity();
390  }
391 
395  public void enableOutput() {
396  main_research_linear_solverJNI.MPSolver_enableOutput(swigCPtr, this);
397  }
398 
402  public void suppressOutput() {
403  main_research_linear_solverJNI.MPSolver_suppressOutput(swigCPtr, this);
404  }
405 
409  public long iterations() {
410  return main_research_linear_solverJNI.MPSolver_iterations(swigCPtr, this);
411  }
412 
418  public long nodes() {
419  return main_research_linear_solverJNI.MPSolver_nodes(swigCPtr, this);
420  }
421 
446  public double computeExactConditionNumber() {
447  return main_research_linear_solverJNI.MPSolver_computeExactConditionNumber(swigCPtr, this);
448  }
449 
450  public void setTimeLimit(long time_limit_milliseconds) {
451  main_research_linear_solverJNI.MPSolver_setTimeLimit(swigCPtr, this, time_limit_milliseconds);
452  }
453 
454  public long wallTime() {
455  return main_research_linear_solverJNI.MPSolver_wallTime(swigCPtr, this);
456  }
457 
462  public String loadModelFromProto(com.google.ortools.linearsolver.MPModelProto input_model) {
463  return main_research_linear_solverJNI.MPSolver_loadModelFromProto(swigCPtr, this, input_model.toByteArray());
464  }
465 
466  public String loadModelFromProtoWithUniqueNamesOrDie(com.google.ortools.linearsolver.MPModelProto input_model) {
467  return main_research_linear_solverJNI.MPSolver_loadModelFromProtoWithUniqueNamesOrDie(swigCPtr, this, input_model.toByteArray());
468  }
469 
473  public com.google.ortools.linearsolver.MPModelProto exportModelToProto() {
474  byte[] buf = main_research_linear_solverJNI.MPSolver_exportModelToProto(swigCPtr, this);
475  if (buf == null || buf.length == 0) {
476  return null;
477  }
478  try {
479  return com.google.ortools.linearsolver.MPModelProto.parseFrom(buf);
480  } catch (com.google.protobuf.InvalidProtocolBufferException e) {
481  throw new RuntimeException(
482  "Unable to parse com.google.ortools.linearsolver.MPModelProto protocol message.");
483  }
484 }
485 
489  public com.google.ortools.linearsolver.MPSolutionResponse createSolutionResponseProto() {
490  byte[] buf = main_research_linear_solverJNI.MPSolver_createSolutionResponseProto(swigCPtr, this);
491  if (buf == null || buf.length == 0) {
492  return null;
493  }
494  try {
495  return com.google.ortools.linearsolver.MPSolutionResponse.parseFrom(buf);
496  } catch (com.google.protobuf.InvalidProtocolBufferException e) {
497  throw new RuntimeException(
498  "Unable to parse com.google.ortools.linearsolver.MPSolutionResponse protocol message.");
499  }
500 }
501 
533  public boolean loadSolutionFromProto(com.google.ortools.linearsolver.MPSolutionResponse response) {
534  return main_research_linear_solverJNI.MPSolver_loadSolutionFromProto(swigCPtr, this, response.toByteArray());
535  }
536 
540  public static com.google.ortools.linearsolver.MPSolutionResponse solveWithProto(com.google.ortools.linearsolver.MPModelRequest model_request) {
541  byte[] buf = main_research_linear_solverJNI.MPSolver_solveWithProto(model_request.toByteArray());
542  if (buf == null || buf.length == 0) {
543  return null;
544  }
545  try {
546  return com.google.ortools.linearsolver.MPSolutionResponse.parseFrom(buf);
547  } catch (com.google.protobuf.InvalidProtocolBufferException e) {
548  throw new RuntimeException(
549  "Unable to parse com.google.ortools.linearsolver.MPSolutionResponse protocol message.");
550  }
551 }
552 
557  return main_research_linear_solverJNI.MPSolver_exportModelAsLpFormat__SWIG_0(swigCPtr, this, MPModelExportOptions.getCPtr(options), options);
558  }
559 
563  public String exportModelAsLpFormat() {
564  return main_research_linear_solverJNI.MPSolver_exportModelAsLpFormat__SWIG_1(swigCPtr, this);
565  }
566 
571  return main_research_linear_solverJNI.MPSolver_exportModelAsMpsFormat__SWIG_0(swigCPtr, this, MPModelExportOptions.getCPtr(options), options);
572  }
573 
577  public String exportModelAsMpsFormat() {
578  return main_research_linear_solverJNI.MPSolver_exportModelAsMpsFormat__SWIG_1(swigCPtr, this);
579  }
580 
594  public void setHint(MPVariable[] variables, double[] values) {
595  main_research_linear_solverJNI.MPSolver_setHint(swigCPtr, this, variables, values);
596  }
597 
601  public boolean setNumThreads(int num_theads) {
602  return main_research_linear_solverJNI.MPSolver_setNumThreads(swigCPtr, this, num_theads);
603  }
604 
612  CLP_LINEAR_PROGRAMMING(main_research_linear_solverJNI.MPSolver_CLP_LINEAR_PROGRAMMING_get()),
613  GLPK_LINEAR_PROGRAMMING(main_research_linear_solverJNI.MPSolver_GLPK_LINEAR_PROGRAMMING_get()),
614  GLOP_LINEAR_PROGRAMMING(main_research_linear_solverJNI.MPSolver_GLOP_LINEAR_PROGRAMMING_get()),
615  SCIP_MIXED_INTEGER_PROGRAMMING(main_research_linear_solverJNI.MPSolver_SCIP_MIXED_INTEGER_PROGRAMMING_get()),
616  GLPK_MIXED_INTEGER_PROGRAMMING(main_research_linear_solverJNI.MPSolver_GLPK_MIXED_INTEGER_PROGRAMMING_get()),
617  CBC_MIXED_INTEGER_PROGRAMMING(main_research_linear_solverJNI.MPSolver_CBC_MIXED_INTEGER_PROGRAMMING_get()),
618  GUROBI_LINEAR_PROGRAMMING(main_research_linear_solverJNI.MPSolver_GUROBI_LINEAR_PROGRAMMING_get()),
619  GUROBI_MIXED_INTEGER_PROGRAMMING(main_research_linear_solverJNI.MPSolver_GUROBI_MIXED_INTEGER_PROGRAMMING_get()),
620  CPLEX_LINEAR_PROGRAMMING(main_research_linear_solverJNI.MPSolver_CPLEX_LINEAR_PROGRAMMING_get()),
621  CPLEX_MIXED_INTEGER_PROGRAMMING(main_research_linear_solverJNI.MPSolver_CPLEX_MIXED_INTEGER_PROGRAMMING_get()),
622  XPRESS_LINEAR_PROGRAMMING(main_research_linear_solverJNI.MPSolver_XPRESS_LINEAR_PROGRAMMING_get()),
623  XPRESS_MIXED_INTEGER_PROGRAMMING(main_research_linear_solverJNI.MPSolver_XPRESS_MIXED_INTEGER_PROGRAMMING_get()),
624  BOP_INTEGER_PROGRAMMING(main_research_linear_solverJNI.MPSolver_BOP_INTEGER_PROGRAMMING_get()),
625  SAT_INTEGER_PROGRAMMING(main_research_linear_solverJNI.MPSolver_SAT_INTEGER_PROGRAMMING_get());
626 
627  public final int swigValue() {
628  return swigValue;
629  }
630 
631  public static OptimizationProblemType swigToEnum(int swigValue) {
632  OptimizationProblemType[] swigValues = OptimizationProblemType.class.getEnumConstants();
633  if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
634  return swigValues[swigValue];
635  for (OptimizationProblemType swigEnum : swigValues)
636  if (swigEnum.swigValue == swigValue)
637  return swigEnum;
638  throw new IllegalArgumentException("No enum " + OptimizationProblemType.class + " with value " + swigValue);
639  }
640 
641  @SuppressWarnings("unused")
642  private OptimizationProblemType() {
643  this.swigValue = SwigNext.next++;
644  }
645 
646  @SuppressWarnings("unused")
647  private OptimizationProblemType(int swigValue) {
648  this.swigValue = swigValue;
649  SwigNext.next = swigValue+1;
650  }
651 
652  @SuppressWarnings("unused")
653  private OptimizationProblemType(OptimizationProblemType swigEnum) {
654  this.swigValue = swigEnum.swigValue;
655  SwigNext.next = this.swigValue+1;
656  }
657 
658  private final int swigValue;
659 
660  private static class SwigNext {
661  private static int next = 0;
662  }
663  }
664 
671  public enum ResultStatus {
695  NOT_SOLVED(main_research_linear_solverJNI.MPSolver_NOT_SOLVED_get());
696 
697  public final int swigValue() {
698  return swigValue;
699  }
700 
701  public static ResultStatus swigToEnum(int swigValue) {
702  ResultStatus[] swigValues = ResultStatus.class.getEnumConstants();
703  if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
704  return swigValues[swigValue];
705  for (ResultStatus swigEnum : swigValues)
706  if (swigEnum.swigValue == swigValue)
707  return swigEnum;
708  throw new IllegalArgumentException("No enum " + ResultStatus.class + " with value " + swigValue);
709  }
710 
711  @SuppressWarnings("unused")
712  private ResultStatus() {
713  this.swigValue = SwigNext.next++;
714  }
715 
716  @SuppressWarnings("unused")
717  private ResultStatus(int swigValue) {
718  this.swigValue = swigValue;
719  SwigNext.next = swigValue+1;
720  }
721 
722  @SuppressWarnings("unused")
723  private ResultStatus(ResultStatus swigEnum) {
724  this.swigValue = swigEnum.swigValue;
725  SwigNext.next = this.swigValue+1;
726  }
727 
728  private final int swigValue;
729 
730  private static class SwigNext {
731  private static int next = 0;
732  }
733  }
734 
739  public enum BasisStatus {
740  FREE(main_research_linear_solverJNI.MPSolver_FREE_get()),
745 
746  public final int swigValue() {
747  return swigValue;
748  }
749 
750  public static BasisStatus swigToEnum(int swigValue) {
751  BasisStatus[] swigValues = BasisStatus.class.getEnumConstants();
752  if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
753  return swigValues[swigValue];
754  for (BasisStatus swigEnum : swigValues)
755  if (swigEnum.swigValue == swigValue)
756  return swigEnum;
757  throw new IllegalArgumentException("No enum " + BasisStatus.class + " with value " + swigValue);
758  }
759 
760  @SuppressWarnings("unused")
761  private BasisStatus() {
762  this.swigValue = SwigNext.next++;
763  }
764 
765  @SuppressWarnings("unused")
766  private BasisStatus(int swigValue) {
767  this.swigValue = swigValue;
768  SwigNext.next = swigValue+1;
769  }
770 
771  @SuppressWarnings("unused")
772  private BasisStatus(BasisStatus swigEnum) {
773  this.swigValue = swigEnum.swigValue;
774  SwigNext.next = this.swigValue+1;
775  }
776 
777  private final int swigValue;
778 
779  private static class SwigNext {
780  private static int next = 0;
781  }
782  }
783 
784 }
The class for constraints of a Mathematical Programming (MP) model.
A class to express a linear objective.
This class stores parameter settings for LP and MIP solvers.
This mathematical programming (MP) solver class is the main class though which users build and solve...
Definition: MPSolver.java:17
MPVariable[] makeVarArray(int count, double lb, double ub, boolean integer)
Creates and returns an array of variables.
Definition: MPSolver.java:48
MPVariable[] makeIntVarArray(int count, double lb, double ub, String var_name)
Definition: MPSolver.java:80
int numVariables()
Returns the number of variables.
Definition: MPSolver.java:156
String loadModelFromProtoWithUniqueNamesOrDie(com.google.ortools.linearsolver.MPModelProto input_model)
Definition: MPSolver.java:466
double computeExactConditionNumber()
Advanced usage: computes the exact condition number of the current scaled basis: L1norm(B) * L1norm(...
Definition: MPSolver.java:446
com.google.ortools.linearsolver.MPSolutionResponse createSolutionResponseProto()
Fills the solution found to a response proto and returns it.
Definition: MPSolver.java:489
boolean interruptSolve()
Interrupts the Solve() execution to terminate processing if possible.
Definition: MPSolver.java:369
long nodes()
Returns the number of branch-and-bound nodes evaluated during the solve.
Definition: MPSolver.java:418
static MPSolver createSolver(String solver_id)
Recommended factory method to create a MPSolver instance, especially in non C++ languages.
Definition: MPSolver.java:127
MPSolver.ResultStatus solve()
Solves the problem using the default parameter values.
Definition: MPSolver.java:306
MPConstraint makeConstraint(String name)
Creates a named constraint with -infinity and +infinity bounds.
Definition: MPSolver.java:290
String exportModelAsMpsFormat()
Export the loaded model in MPS format.
Definition: MPSolver.java:577
String exportModelAsLpFormat(MPModelExportOptions options)
Export the loaded model in LP format.
Definition: MPSolver.java:556
MPConstraint makeConstraint(double lb, double ub, String name)
Creates a named constraint with given bounds.
Definition: MPSolver.java:282
MPVariable makeNumVar(double lb, double ub, String name)
Creates a continuous variable.
Definition: MPSolver.java:201
MPVariable variable(int index)
Returns the variable at position index.
Definition: MPSolver.java:171
MPVariable makeBoolVar(String name)
Creates a boolean variable.
Definition: MPSolver.java:217
MPVariable makeIntVar(double lb, double ub, String name)
Creates an integer variable.
Definition: MPSolver.java:209
MPVariable[] makeNumVarArray(int count, double lb, double ub, String var_name)
Definition: MPSolver.java:72
boolean verifySolution(double tolerance, boolean log_errors)
Advanced usage: Verifies the correctness of the solution.
Definition: MPSolver.java:345
int numConstraints()
Returns the number of constraints.
Definition: MPSolver.java:225
MPVariable[] makeIntVarArray(int count, double lb, double ub)
Definition: MPSolver.java:76
MPVariable makeVar(double lb, double ub, boolean integer, String name)
Creates a variable with the given bounds, integrality requirement and name.
Definition: MPSolver.java:193
MPObjective objective()
Returns the mutable objective object.
Definition: MPSolver.java:298
MPVariable lookupVariableOrNull(String var_name)
Looks up a variable by name, and returns nullptr if it does not exist.
Definition: MPSolver.java:181
MPSolver.ResultStatus solve(MPSolverParameters param)
Solves the problem using the specified parameter values.
Definition: MPSolver.java:313
com.google.ortools.linearsolver.MPModelProto exportModelToProto()
Export the loaded model to proto and returns it.
Definition: MPSolver.java:473
MPVariable[] makeBoolVarArray(int count)
Definition: MPSolver.java:84
void enableOutput()
Enables solver logging.
Definition: MPSolver.java:395
MPSolver(String name, MPSolver.OptimizationProblemType problem_type)
Create a solver with the given name and underlying solver backend.
Definition: MPSolver.java:95
static double infinity()
Infinity.
Definition: MPSolver.java:388
void setTimeLimit(long time_limit_milliseconds)
Definition: MPSolver.java:450
MPConstraint[] constraints()
Returns the array of constraints handled by the MPSolver.
Definition: MPSolver.java:234
MPConstraint makeConstraint(double lb, double ub)
Creates a linear constraint with given bounds.
Definition: MPSolver.java:266
long iterations()
Returns the number of simplex iterations.
Definition: MPSolver.java:409
MPVariable[] makeVarArray(int count, double lb, double ub, boolean integer, String var_name)
Creates and returns an array of named variables.
Definition: MPSolver.java:59
MPSolver(long cPtr, boolean cMemoryOwn)
Definition: MPSolver.java:21
void suppressOutput()
Suppresses solver logging.
Definition: MPSolver.java:402
void setHint(MPVariable[] variables, double[] values)
Sets a hint for solution.
Definition: MPSolver.java:594
double[] computeConstraintActivities()
Advanced usage: compute the "activities" of all constraints, which are the sums of their linear term...
Definition: MPSolver.java:323
boolean loadSolutionFromProto(com.google.ortools.linearsolver.MPSolutionResponse response)
Load a solution encoded in a protocol buffer onto this solver for easy access via the MPSolver inter...
Definition: MPSolver.java:533
void clear()
Clears the objective (including the optimization direction), all variables and constraints.
Definition: MPSolver.java:149
MPConstraint makeConstraint()
Creates a constraint with -infinity and +infinity bounds.
Definition: MPSolver.java:274
static boolean supportsProblemType(MPSolver.OptimizationProblemType problem_type)
Whether the given problem type is supported (this will depend on the targets that you linked).
Definition: MPSolver.java:136
boolean setNumThreads(int num_theads)
Sets the number of threads to be used by the solver.
Definition: MPSolver.java:601
MPConstraint constraint(int index)
Returns the constraint at the given index.
Definition: MPSolver.java:241
boolean setSolverSpecificParametersAsString(String parameters)
Advanced usage: pass solver specific parameters in text format.
Definition: MPSolver.java:379
void reset()
Advanced usage: resets extracted model to solve from scratch.
Definition: MPSolver.java:357
String loadModelFromProto(com.google.ortools.linearsolver.MPModelProto input_model)
Loads a model and returns the error message, which will be empty iff the model is valid.
Definition: MPSolver.java:462
String exportModelAsLpFormat()
Export the loaded model in LP format.
Definition: MPSolver.java:563
MPVariable[] makeNumVarArray(int count, double lb, double ub)
Definition: MPSolver.java:68
String exportModelAsMpsFormat(MPModelExportOptions options)
Export the loaded model in MPS format.
Definition: MPSolver.java:570
MPVariable[] makeBoolVarArray(int count, String var_name)
Definition: MPSolver.java:88
static com.google.ortools.linearsolver.MPSolutionResponse solveWithProto(com.google.ortools.linearsolver.MPModelRequest model_request)
Solves the given model proto and returns a response proto.
Definition: MPSolver.java:540
MPConstraint lookupConstraintOrNull(String constraint_name)
Looks up a constraint by name, and returns nullptr if it does not exist.
Definition: MPSolver.java:253
MPVariable[] variables()
Returns the array of variables handled by the MPSolver.
Definition: MPSolver.java:164
The class for variables of a Mathematical Programming (MP) model.
Definition: MPVariable.java:16
Advanced usage: possible basis status values for a variable and the slack variable of a linear const...
Definition: MPSolver.java:739
static BasisStatus swigToEnum(int swigValue)
Definition: MPSolver.java:750
The type of problems (LP or MIP) that will be solved and the underlying solver (GLOP,...
Definition: MPSolver.java:611
static OptimizationProblemType swigToEnum(int swigValue)
Definition: MPSolver.java:631
static ResultStatus swigToEnum(int swigValue)
Definition: MPSolver.java:701
ABNORMAL
abnormal, i.e., error of some kind.
Definition: MPSolver.java:691