Migrating from CPLEX to Gurobi
AnsweredHi there,
I have a code, which solves the model by CPLEX. I am trying to make necessary changes to solve the model by Gurobi other than CPLEX. However, I do not know what is the Gurobi equivalent of IloCplex. What do I have to write other than
IloCplex* cplex;
Thanks
Masoud
0
-
Official comment
This post is more than three 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. -
Hi Masoud,To solve an optimization problem with CPLEX C++ API, we typically follow the steps below:
# Create an environment
IloEnv env;
# Create an empty model
IloModel model(env);
...
# Create a solver object
IloCplex cplex(model);
# Optimize
cplex.solve()In Gurobi C++ API, we follow similar steps with one difference where there is no need to create a solver object. The optimize() method is directly called on the model object.# Create an environment and start it
GRBEnv env = GRBEnv(true);
env.start();
# Create an empty model
GRBModel model = GRBModel(env);
...
# Optimize
model.optimize()Best regards,Maliheh0 -
Thank you, Maliheh!
Your explanation clears up everything for me.
Regards!
Masoud
0
Post is closed for comments.
Comments
3 comments