Skip to main content

Same optimization problem can be solved in MATLAB, but not in C#

Ongoing

Comments

5 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    This post is more than two years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support.
  • Michel Soares
    • Gurobi-versary
    • Thought Leader

    Hi Jianing Ding,

    I would recommend you export a LP file in both codes and compare them, it might show you differences in the model (C#, MATLAB).

    I am not sure by what you mean with "can't be dealt in C#". Does the code not run at all? Is the model infeasible? What happens?

     

    0
  • Gwyneth Butera
    • Gurobi Staff

    Can you check the bounds of the variables? I believe CVX does not use a lower bound of 0 while Gurobi does.

    0
  • Jianing Ding
    • Gurobi-versary
    • First Comment
    • First Question

    Hi Michel,

    Thanks a lot for you suggestion. But since I'm using both Gurobi and CVX in MATLAB, it seems that I can't export the LP file directly. Can you give me some advice?

    The C# function can run, but when using "model.Optimize()", it becomes infeasible, i.e., the model.Status equals to 4.

    0
  • Jianing Ding
    • Gurobi-versary
    • First Comment
    • First Question

    Hi Gwyneth,

    Thank you very much and you're right, Gurobi has a default lower bound of 0, and my constraints will result in negative values of variable u.
    I set the bounds of variable u to -GRB.INFINITY and GRB.INFINITY, the model.Status is still 4. Then I change this to -1000 and 1000, meanwhile I set the bounds of variable alpha(it's binary) to 0 and 1, model.Status becomes 3. Is there any other reason? 

    And I wonder why I need to set the bounds of binary variables, model.Status=4 without this additional constraint.

    0

Post is closed for comments.