Skip to main content

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

Ongoing

Comments

4 comments

  • 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 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

Please sign in to leave a comment.