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