Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3423302
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:20:18+00:00 2026-05-18T06:20:18+00:00

Do anyone know any simple solver that can solve linear constraint math models? Example

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T06:20:19+00:00Added an answer on May 18, 2026 at 6:20 am

    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.

    http://www.wolframalpha.com/input/?i=solve+a+%2B+b+%2B+c+%3D%3D+100%3B+a%2Fb+%3D%3D+2%2F3%3B+b%2Fc%3D%3D3%2F4%3B+a+%3E+d

    alt text

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know any good tool that I can use to perform stress tests
Does anyone know of any existing packages or libraries that can be used to
Does anyone know any simple way to retrieve the country from a given IP
Does anyone know of any way to convert a simple gif to xaml? E.G.
Does anyone know of any tools to provide simple, fast queries of flat files
Does anyone know of any sample code for restoring a window's position and size
Does anyone know any good tutorial about using NAnt for native code build process
Does anyone know any good and free .NET Windows Controls Library
Does anyone know any source of examples and templates for software requirements, build environment
Does anyone know any resources (books/websites/whatever) related to parsing. I'm not so much interested

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.