Microsoft Solver Foundation constraint

Posted by emaster70 on Stack Overflow See other posts from Stack Overflow or by emaster70
Published on 2010-05-09T22:06:15Z Indexed on 2010/05/09 22:08 UTC
Read the original article Hit count: 341

Hello,
I'm trying to use Microsoft Solver Foundation 2 to solve a fairly complicated situation, however I'm stuck with an UnsupportedModelException even when I dumb down the model as much as possible.
Does anyone have an idea of what I'm doing wrong?
Following is the least example required to reproduce the problematic behavior.

var ctx = SolverContext.GetContext();
var model = ctx.CreateModel();
var someConstant = 1337.0;

var decisionA = new Decision(Domain.Real, "decisionA");
var decisionB = new Decision(Domain.Real, "decisionB");
var decisionC = new Decision(Domain.Real, "decisionC");

model.AddConstraint("ca", decisionA <= someConstant);
model.AddConstraint("cb", decisionB <= someConstant);
model.AddConstraint("cc", decisionC <= someConstant);

model.AddConstraint("mainConstraint", Model.Equal(Model.Sum(decisionA, decisionB, decisionC), someConstant))

model.AddGoal("myComplicatedGoal", GoalKind.Minimize, decisionC);

var solution = ctx.Solve();

solution.GetReport().WriteTo(Console.Out);

Console.ReadKey();

Please consider that my actual model should include, once complete, a few constraints in the form of a*a+b*a <= someValue, so if what I'm willing to do ultimately isn't supported, please let me know in advance. If that's the case I'd also appreciate a suggestion of some other solver with a .NET friendly interface that I could use (only well-known commercial packages, please).

Thanks in advance

© Stack Overflow or respective owner

Related posts about solver

Related posts about ms-solver-foundation