Do anyone know any simple solver that can solve linear constraint math models? Example a simple model:
a + b + c = 100;
a/b/c = 2/3/4;
a > d
I'm using MS Solver foundation and this is my C# code, but it throw UnsolvableModelException:
SolverContext solverContext = SolverContext.GetContext();
Model model = solverContext.CreateModel();
Decision a = new Decision(Domain.Real, "a");
Decision b = new Decision(Domain.Real, "b");
model.AddDecisions(a, b);
model.AddConstraint("fator", a / b == 4);
model.AddConstraint("sum", a + b == 5);
Solution solution = solverContext.Solve(new ConstraintProgrammingDirective());
Report report = solution.GetReport();
Console.WriteLine("a = {0} ; b = {1}", a, b);
Thanks for any help
Edit:
Because int CSP(constraint sstisfaction programming) problem, you shouldn't use any Directive when solving it. The code should be:
SolverContext solverContext = SolverContext.GetContext();
Model model = solverContext.CreateModel();
Decision a = new Decision(Domain.Real, "a");
Decision b = new Decision(Domain.Real, "b");
model.AddDecisions(a, b);
model.AddConstraint("fator", a / b == 4);
model.AddConstraint("sum", a + b == 5);
Solution solution = solverContext.Solve();
Report report = solution.GetReport();
Console.WriteLine("a = {0} ; b = {1}", a, b);
However, I don't know why I ran to slowly I only need the first solution in the solution set.
Depending on your needs, Wolfram Alpha may be useful (at least for verification). I doubt you can solve complex problems, because the input is lenght-limited. But for simple problems as your example, it's OK.