c++ copy mode, infeasible
ユーザーの入力を待っています。I 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!
-
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
サインインしてコメントを残してください。
コメント
1件のコメント