Same optimization problem can be solved in MATLAB, but not in C#
OngoingI am transferring a mixed integer optimization program from MATLAB to C#, the MATLAB code is written as:
and the C# version:

With the same input parameters, this function can be successfully solved in MATLAB, but can't be dealt in C#. I've checked my code and there seems nothing wrong. What difference causes this?
-
Official comment
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. -
Can you check the bounds of the variables? I believe CVX does not use a lower bound of 0 while Gurobi does.
0 -
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 -
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.
Comments
5 comments