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
-
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
Please sign in to leave a comment.
Comments
2 comments