Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
Solver.cs
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// <auto-generated />
3//
4// This file was automatically generated by SWIG (https://www.swig.org).
5// Version 4.2.1
6//
7// Do not make changes to this file unless you know what you are doing - modify
8// the SWIG interface file instead.
9//------------------------------------------------------------------------------
10
12
13public partial class Solver : global::System.IDisposable {
14 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
15 protected bool swigCMemOwn;
16
17 internal Solver(global::System.IntPtr cPtr, bool cMemoryOwn) {
18 swigCMemOwn = cMemoryOwn;
19 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
20 }
21
22 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Solver obj) {
23 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
24 }
25
26 internal static global::System.Runtime.InteropServices.HandleRef swigRelease(Solver obj) {
27 if (obj != null) {
28 if (!obj.swigCMemOwn)
29 throw new global::System.ApplicationException("Cannot release ownership as memory is not owned");
30 global::System.Runtime.InteropServices.HandleRef ptr = obj.swigCPtr;
31 obj.swigCMemOwn = false;
32 obj.Dispose();
33 return ptr;
34 } else {
35 return new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
36 }
37 }
38
39 ~Solver() {
40 Dispose(false);
41 }
42
43 public void Dispose() {
44 Dispose(true);
45 global::System.GC.SuppressFinalize(this);
46 }
47
48 protected virtual void Dispose(bool disposing) {
49 lock(this) {
50 if (swigCPtr.Handle != global::System.IntPtr.Zero) {
51 if (swigCMemOwn) {
52 swigCMemOwn = false;
54 }
55 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
56 }
57 }
58 }
59
60 public Solver(string name, Solver.OptimizationProblemType problem_type) : this(operations_research_linear_solverPINVOKE.new_Solver(name, (int)problem_type), true) {
61 if (operations_research_linear_solverPINVOKE.SWIGPendingException.Pending) throw operations_research_linear_solverPINVOKE.SWIGPendingException.Retrieve();
62 }
63
64 public static Solver CreateSolver(string solver_id) {
65 global::System.IntPtr cPtr = operations_research_linear_solverPINVOKE.Solver_CreateSolver(solver_id);
66 Solver ret = (cPtr == global::System.IntPtr.Zero) ? null : new Solver(cPtr, true);
68 return ret;
69 }
70
71 public static bool SupportsProblemType(Solver.OptimizationProblemType problem_type) {
73 return ret;
74 }
75
76 public bool IsMip() {
78 return ret;
79 }
80
81 public void Clear() {
83 }
84
85 public int NumVariables() {
87 return ret;
88 }
89
92 return ret;
93 }
94
95 public Variable Variable(int index) {
96 global::System.IntPtr cPtr = operations_research_linear_solverPINVOKE.Solver_Variable(swigCPtr, index);
97 Variable ret = (cPtr == global::System.IntPtr.Zero) ? null : new Variable(cPtr, false);
98 return ret;
99 }
100
101 public Variable LookupVariableOrNull(string var_name) {
102 global::System.IntPtr cPtr = operations_research_linear_solverPINVOKE.Solver_LookupVariableOrNull(swigCPtr, var_name);
103 Variable ret = (cPtr == global::System.IntPtr.Zero) ? null : new Variable(cPtr, false);
105 return ret;
106 }
107
108 public Variable MakeVar(double lb, double ub, bool integer, string name) {
109 global::System.IntPtr cPtr = operations_research_linear_solverPINVOKE.Solver_MakeVar(swigCPtr, lb, ub, integer, name);
110 Variable ret = (cPtr == global::System.IntPtr.Zero) ? null : new Variable(cPtr, false);
112 return ret;
113 }
114
115 public Variable MakeNumVar(double lb, double ub, string name) {
116 global::System.IntPtr cPtr = operations_research_linear_solverPINVOKE.Solver_MakeNumVar(swigCPtr, lb, ub, name);
117 Variable ret = (cPtr == global::System.IntPtr.Zero) ? null : new Variable(cPtr, false);
119 return ret;
120 }
121
122 public Variable MakeIntVar(double lb, double ub, string name) {
123 global::System.IntPtr cPtr = operations_research_linear_solverPINVOKE.Solver_MakeIntVar(swigCPtr, lb, ub, name);
124 Variable ret = (cPtr == global::System.IntPtr.Zero) ? null : new Variable(cPtr, false);
126 return ret;
127 }
128
129 public Variable MakeBoolVar(string name) {
130 global::System.IntPtr cPtr = operations_research_linear_solverPINVOKE.Solver_MakeBoolVar(swigCPtr, name);
131 Variable ret = (cPtr == global::System.IntPtr.Zero) ? null : new Variable(cPtr, false);
133 return ret;
134 }
135
136 public int NumConstraints() {
138 return ret;
139 }
140
143 return ret;
144 }
145
146 public Constraint Constraint(int index) {
147 global::System.IntPtr cPtr = operations_research_linear_solverPINVOKE.Solver_Constraint(swigCPtr, index);
148 Constraint ret = (cPtr == global::System.IntPtr.Zero) ? null : new Constraint(cPtr, false);
149 return ret;
150 }
151
152 public Constraint LookupConstraintOrNull(string constraint_name) {
153 global::System.IntPtr cPtr = operations_research_linear_solverPINVOKE.Solver_LookupConstraintOrNull(swigCPtr, constraint_name);
154 Constraint ret = (cPtr == global::System.IntPtr.Zero) ? null : new Constraint(cPtr, false);
156 return ret;
157 }
158
159 public Constraint MakeConstraint(double lb, double ub) {
160 global::System.IntPtr cPtr = operations_research_linear_solverPINVOKE.Solver_MakeConstraint__SWIG_0(swigCPtr, lb, ub);
161 Constraint ret = (cPtr == global::System.IntPtr.Zero) ? null : new Constraint(cPtr, false);
162 return ret;
163 }
164
165 public Constraint MakeConstraint() {
166 global::System.IntPtr cPtr = operations_research_linear_solverPINVOKE.Solver_MakeConstraint__SWIG_1(swigCPtr);
167 Constraint ret = (cPtr == global::System.IntPtr.Zero) ? null : new Constraint(cPtr, false);
168 return ret;
169 }
170
171 public Constraint MakeConstraint(double lb, double ub, string name) {
172 global::System.IntPtr cPtr = operations_research_linear_solverPINVOKE.Solver_MakeConstraint__SWIG_2(swigCPtr, lb, ub, name);
173 Constraint ret = (cPtr == global::System.IntPtr.Zero) ? null : new Constraint(cPtr, false);
175 return ret;
176 }
177
178 public Constraint MakeConstraint(string name) {
179 global::System.IntPtr cPtr = operations_research_linear_solverPINVOKE.Solver_MakeConstraint__SWIG_3(swigCPtr, name);
180 Constraint ret = (cPtr == global::System.IntPtr.Zero) ? null : new Constraint(cPtr, false);
182 return ret;
183 }
184
185 public Objective Objective() {
186 global::System.IntPtr cPtr = operations_research_linear_solverPINVOKE.Solver_Objective(swigCPtr);
187 Objective ret = (cPtr == global::System.IntPtr.Zero) ? null : new Objective(cPtr, false);
188 return ret;
189 }
190
191 public Solver.ResultStatus Solve() {
193 return ret;
194 }
195
204 DoubleVector tmpVector = null;
205 if (cPtr != global::System.IntPtr.Zero) {
206 tmpVector = new DoubleVector(cPtr, true);
207 double[] outArray = new double[tmpVector.Count];
208 tmpVector.CopyTo(outArray);
209 return outArray;
210 }
211 return null;
212}
213
214 public bool VerifySolution(double tolerance, bool log_errors) {
215 bool ret = operations_research_linear_solverPINVOKE.Solver_VerifySolution(swigCPtr, tolerance, log_errors);
216 return ret;
217 }
218
219 public void Reset() {
222
223 public bool InterruptSolve() {
225 return ret;
226 }
227
228 public bool SetSolverSpecificParametersAsString(string parameters) {
237
238 public void SuppressOutput() {
241
242 public long Iterations() {
244 return ret;
245 }
246
247 public long Nodes() {
249 return ret;
250 }
251
252 public string SolverVersion() {
254 return ret;
255 }
256
257 public double ComputeExactConditionNumber() {
259 return ret;
260 }
261
262 public void SetTimeLimit(long time_limit_milliseconds) {
263 operations_research_linear_solverPINVOKE.Solver_SetTimeLimit(swigCPtr, time_limit_milliseconds);
265
266 public long WallTime() {
268 return ret;
269 }
270
271 public string ExportModelAsLpFormat(bool obfuscated) {
273 return ret;
274 }
275
276 public string ExportModelAsMpsFormat(bool fixed_format, bool obfuscated) {
277 string ret = operations_research_linear_solverPINVOKE.Solver_ExportModelAsMpsFormat(swigCPtr, fixed_format, obfuscated);
278 return ret;
279 }
280
281 public void SetHint(MPVariableVector variables, double[] values) {
282 operations_research_linear_solverPINVOKE.Solver_SetHint(swigCPtr, MPVariableVector.getCPtr(variables), values.Length, values );
287 bool ret = operations_research_linear_solverPINVOKE.Solver_SetNumThreads(swigCPtr, num_theads);
288 return ret;
289 }
290
291 public enum OptimizationProblemType {
310 OPTIMAL,
313 UNBOUNDED,
314 ABNORMAL,
316 NOT_SOLVED = 6
317 }
318
319 public enum BasisStatus {
320 FREE = 0,
324 BASIC
325 }
326
327}
328
329}
Variable MakeVar(double lb, double ub, bool integer, string name)
Definition Solver.cs:110
void SetTimeLimit(long time_limit_milliseconds)
Definition Solver.cs:264
bool VerifySolution(double tolerance, bool log_errors)
Definition Solver.cs:216
Solver.ResultStatus Solve()
Definition Solver.cs:193
MPConstraintVector constraints()
Definition Solver.cs:143
bool SetSolverSpecificParametersAsString(string parameters)
Definition Solver.cs:230
void SetHint(MPVariableVector variables, double[] values)
Definition Solver.cs:283
bool SetNumThreads(int num_theads)
Definition Solver.cs:288
Variable MakeBoolVar(string name)
Definition Solver.cs:131
string ExportModelAsMpsFormat(bool fixed_format, bool obfuscated)
Definition Solver.cs:278
string ExportModelAsLpFormat(bool obfuscated)
Definition Solver.cs:273
Variable MakeIntVar(double lb, double ub, string name)
Definition Solver.cs:124
static Solver CreateSolver(string solver_id)
Definition Solver.cs:66
static bool SupportsProblemType(Solver.OptimizationProblemType problem_type)
Definition Solver.cs:73
Variable Variable(int index)
Definition Solver.cs:97
Variable MakeNumVar(double lb, double ub, string name)
Definition Solver.cs:117
MPVariableVector variables()
Definition Solver.cs:92
Constraint LookupConstraintOrNull(string constraint_name)
Definition Solver.cs:154
Constraint Constraint(int index)
Definition Solver.cs:148
Variable LookupVariableOrNull(string var_name)
Definition Solver.cs:103
Patch the MPVariable class to support the natural language API.
Definition Variable.cs:15
static global::System.IntPtr Solver_MakeConstraint__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1)
static global::System.IntPtr Solver_ComputeConstraintActivities(global::System.Runtime.InteropServices.HandleRef jarg1)
static global::System.IntPtr Solver_LookupVariableOrNull(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2)
static double Solver_ComputeExactConditionNumber(global::System.Runtime.InteropServices.HandleRef jarg1)
static global::System.IntPtr Solver_MakeConstraint__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1, double jarg2, double jarg3)
static global::System.IntPtr Solver_MakeVar(global::System.Runtime.InteropServices.HandleRef jarg1, double jarg2, double jarg3, bool jarg4, string jarg5)
static bool Solver_SetNumThreads(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2)
static int Solver_NumConstraints(global::System.Runtime.InteropServices.HandleRef jarg1)
static global::System.IntPtr Solver_variables(global::System.Runtime.InteropServices.HandleRef jarg1)
static void delete_Solver(global::System.Runtime.InteropServices.HandleRef jarg1)
static int Solver_Solve__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1)
static global::System.IntPtr Solver_Variable(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2)
static void Solver_EnableOutput(global::System.Runtime.InteropServices.HandleRef jarg1)
static global::System.IntPtr Solver_MakeConstraint__SWIG_2(global::System.Runtime.InteropServices.HandleRef jarg1, double jarg2, double jarg3, string jarg4)
static string Solver_SolverVersion(global::System.Runtime.InteropServices.HandleRef jarg1)
static void Solver_Reset(global::System.Runtime.InteropServices.HandleRef jarg1)
static global::System.IntPtr Solver_constraints(global::System.Runtime.InteropServices.HandleRef jarg1)
static global::System.IntPtr Solver_MakeConstraint__SWIG_3(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2)
static global::System.IntPtr Solver_MakeBoolVar(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2)
static void Solver_SuppressOutput(global::System.Runtime.InteropServices.HandleRef jarg1)
static global::System.IntPtr Solver_MakeIntVar(global::System.Runtime.InteropServices.HandleRef jarg1, double jarg2, double jarg3, string jarg4)
static void Solver_SetHint(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, int length3, double[] jarg3)
static long Solver_WallTime(global::System.Runtime.InteropServices.HandleRef jarg1)
static global::System.IntPtr Solver_Constraint(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2)
static global::System.IntPtr Solver_Objective(global::System.Runtime.InteropServices.HandleRef jarg1)
static bool Solver_IsMip(global::System.Runtime.InteropServices.HandleRef jarg1)
static string Solver_ExportModelAsLpFormat(global::System.Runtime.InteropServices.HandleRef jarg1, bool jarg2)
static void Solver_Clear(global::System.Runtime.InteropServices.HandleRef jarg1)
static global::System.IntPtr Solver_MakeNumVar(global::System.Runtime.InteropServices.HandleRef jarg1, double jarg2, double jarg3, string jarg4)
static int Solver_Solve__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2)
static long Solver_Nodes(global::System.Runtime.InteropServices.HandleRef jarg1)
static bool Solver_SetSolverSpecificParametersAsString(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2)
static global::System.IntPtr Solver_CreateSolver(string jarg1)
static int Solver_NumVariables(global::System.Runtime.InteropServices.HandleRef jarg1)
static global::System.IntPtr Solver_LookupConstraintOrNull(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2)
static void Solver_SetTimeLimit(global::System.Runtime.InteropServices.HandleRef jarg1, long jarg2)
static bool Solver_InterruptSolve(global::System.Runtime.InteropServices.HandleRef jarg1)
static long Solver_Iterations(global::System.Runtime.InteropServices.HandleRef jarg1)
static string Solver_ExportModelAsMpsFormat(global::System.Runtime.InteropServices.HandleRef jarg1, bool jarg2, bool jarg3)