c++ copy mode, infeasible
Awaiting user inputI want to copy model in c++ use the following code:
try {
modelo = new GRBModel(*in_modelo);
modelo->update();
modelo->optimize();
int status = modelo->get(GRB_IntAttr_Status);
if (status == GRB_OPTIMAL) {
double objVal = modelo->get(GRB_DoubleAttr_ObjVal);
std::cout << "Objective value: " << objVal << std::endl;
}
else {
std::cout << "Optimization did not finish successfully. Status code: " << status << std::endl;
}
}
catch (GRBException& e) {
std::cout << "Error code: " << e.getErrorCode() << std::endl;
std::cout << "Error message: " << e.getMessage() << std::endl;
}
catch (...) {
std::cout << "An unknown error occurred." << std::endl;
}
However, I got this message: "Optimization did not finish successfully. Status code: 3". I checked the status code, 3 means that infeasible. However, the input model in_model can be optimality solved, why modelo is infeasible? And what does it mean that "Optimization did not finish successfully"? How to solve this problem? Thanks in advance!
-
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. -
Just to be sure, you should call update() for the \(\texttt{in_modelo}\) object. You could try writing out both models and checking whether they are different. To write out the models, you can use the write method. It is best to write the models to a human-readable LP file.
modelo->write("myModel.LP")You can then open the generates files in any standard text editor and check whether there is any difference between them.
0
Post is closed for comments.
Comments
2 comments