How to copy a model in c++
AnsweredGreetings,
I want to make a copy of a GRBModel, but I don't know how in c++. model.copy() works in python but not in c++.
I first have the followng class:
class MasterProblem
{
public:
GRBEnv* env = new GRBEnv();
GRBModel* modelo;
void set_init(GRBModel* in_modelo);
}
Then in the set_init function:
void MasterProblem::set_init(GRBModel* in_modelo){
if (in_modelo == NULL){
modelo = new GRBModel(*env);
}
else {
*modelo = in_modelo->copy();
}
}
However, it is said that GRBModel has no menber copy. Could anyone told me how to fix this?
Thanks!
-
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 Kechen,
To copy a model in C++, you have to use the GRBModel constructor and pass the existing model as a parameter. This is explained here: GRBModel().
I hope that helps!
Cheers,
Matthias0 -
It helped! Thank you!
0
Post is closed for comments.
Comments
3 comments