Note that there are some explanatory texts on larger screens.

plurals
  1. POsolver solve constraint programming problem
    primarykey
    data
    text
    <p>Do anyone know any simple solver that can solve linear constraint math models? Example a simple model:</p> <pre><code>a + b + c = 100; a/b/c = 2/3/4; a &gt; d </code></pre> <p>I'm using MS Solver foundation and this is my C# code, but it throw UnsolvableModelException:</p> <pre><code> 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); </code></pre> <p>Thanks for any help</p> <p><strong>Edit:</strong></p> <p>Because int CSP(constraint sstisfaction programming) problem, you shouldn't use any Directive when solving it. The code should be:</p> <pre><code> 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); </code></pre> <p>However, I don't know why I ran to slowly I only need the first solution in the solution set.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload