15using System.Collections.Generic;
16using System.Runtime.CompilerServices;
36 if (string_parameters_ is not
null)
40 if (log_callback_ is not
null)
44 if (best_bound_callback_ is not
null)
60 ReleaseSolveWrapper();
66 [ObsoleteAttribute(
"This method is obsolete. Call Solve instead.",
false)]
69 return Solve(model, cb);
73 [ObsoleteAttribute(
"This method is obsolete. Call Solve instead with the enumerate_all_solutions parameter.",
77 string old_parameters = string_parameters_;
78 string_parameters_ +=
" enumerate_all_solutions:true";
80 string_parameters_ = old_parameters;
85 [MethodImpl(MethodImplOptions.Synchronized)]
88 if (solve_wrapper_ is not
null)
94 [MethodImpl(MethodImplOptions.Synchronized)]
95 private void CreateSolveWrapper()
100 [MethodImpl(MethodImplOptions.Synchronized)]
101 private void ReleaseSolveWrapper()
103 solve_wrapper_ =
null;
136 return string_parameters_;
139 string_parameters_ = value;
150 log_callback_ =
null;
160 best_bound_callback_ =
null;
178 long value = index >= 0 ? response_.
Solution[index] : -response_.
Solution[-index - 1];
190 long coefficient = 1;
194 terms_ =
new Queue<Term>();
206 constant += coefficient * a.
Offset;
207 if (coefficient == 1)
209 foreach (
Term sub
in a.Terms)
216 foreach (
Term sub
in a.Terms)
224 long value = index >= 0 ? response_.
Solution[index] : -response_.
Solution[-index - 1];
225 constant += coefficient * value;
228 throw new ArgumentException(
"Cannot evaluate a literal in an integer expression.");
230 throw new ArgumentException(
"Cannot evaluate '" + expr +
"' in an integer expression");
233 if (!terms_.TryDequeue(out var term))
238 coefficient = term.coefficient;
256 return response_.
Solution[index] != 0;
260 return response_.
Solution[-index - 1] == 0;
265 throw new ArgumentException(
"Cannot evaluate '" + literal.ToString() +
"' as a boolean literal");
306 private string string_parameters_;
308 private Queue<Term> terms_;
315 this.delegate_ = del;
330 this.delegate_ = del;