15using System.Collections.Generic;
16using System.Runtime.CompilerServices;
36 if (string_parameters_ is not
null)
40 if (log_callback_ is not
null)
56 ReleaseSolveWrapper();
62 [ObsoleteAttribute(
"This method is obsolete. Call Solve instead.",
false)]
65 return Solve(model, cb);
69 [ObsoleteAttribute(
"This method is obsolete. Call Solve instead with the enumerate_all_solutions parameter.",
73 string old_parameters = string_parameters_;
74 string_parameters_ +=
" enumerate_all_solutions:true";
76 string_parameters_ = old_parameters;
81 [MethodImpl(MethodImplOptions.Synchronized)]
84 if (solve_wrapper_ is not
null)
90 [MethodImpl(MethodImplOptions.Synchronized)]
91 private void CreateSolveWrapper()
96 [MethodImpl(MethodImplOptions.Synchronized)]
97 private void ReleaseSolveWrapper()
99 solve_wrapper_ =
null;
132 return string_parameters_;
135 string_parameters_ = value;
159 long value = index >= 0 ? response_.
Solution[index] : -response_.
Solution[-index - 1];
171 long coefficient = 1;
175 terms_ =
new Queue<Term>();
187 constant += coefficient * a.
Offset;
188 if (coefficient == 1)
190 foreach (
Term sub
in a.Terms)
197 foreach (
Term sub
in a.Terms)
205 long value = index >= 0 ? response_.
Solution[index] : -response_.
Solution[-index - 1];
206 constant += coefficient * value;
209 throw new ArgumentException(
"Cannot evaluate a literal in an integer expression.");
211 throw new ArgumentException(
"Cannot evaluate '" + expr +
"' in an integer expression");
214 if (!terms_.TryDequeue(out var term))
219 coefficient = term.coefficient;
237 return response_.
Solution[index] != 0;
241 return response_.
Solution[-index - 1] == 0;
246 throw new ArgumentException(
"Cannot evaluate '" + literal.ToString() +
"' as a boolean literal");
286 private string string_parameters_;
288 private Queue<Term> terms_;
295 this.delegate_ = del;