What's wrong with this code?:
SolverContext sc = SolverContext.GetContext();
Model m = sc.CreateModel();
m.AddDecision(new Decision(Domain.IntegerNonnegative, "a"));
m.AddDecision(new Decision(Domain.IntegerNonnegative, "b"));
m.AddConstraint(null, "a < 2");
m.AddConstraint(null, "b == If[a == 2, 2, 1]");
var sol = sc.Solve();
Console.WriteLine(sol.GetReport());
The solver freezes and doesn't give any result. I'm playing with the If
operator trying to see how it works but doesn't seem to do what I expect. Not sure I'm using it the right way (I'm trying to say, if a
equals 2
then b
must equal 2
, otherwise 1
).
I also tried
m.AddConstraint(null, "If[a == 2, b == 2, b == 1]");
with the same result.