GRBgeterrormsg() vs GRBgetmerrormsg()
進行中We have a fair number of places in code that look like the following
int ret = GRBaddvar(model, numnz, vind, vval, obj, lb, ub, vtype, name);
if (ret)
{
printf("GRBaddvar() failed. Failed to add Gurobi variable. Error code %d: %s", ret, GRBgeterrormsg(GRBgetenv(model)));
}
I recently noticed in the gurobi_c.h header file that there is a GRBgetmerrormsg() function defined which takes a GRBmodel instead of a GRBenv struct. Does this mean we could change all these to just do:
int ret = GRBaddvar(model, numnz, vind, vval, obj, lb, ub, vtype, name);
if (ret)
{
printf("GRBaddvar() failed. Failed to add Gurobi variable. Error code %d: %s", ret, GRBgetmerrormsg(model));
}
-
Hi Mike,
As you know, only
GRBgeterrormsg()
function is included in our official documentation. Therefore, we recommend using this officially documented function.You are correct that the Gurobi C API includes a function named
GRBgetmerrormsg(GRBmodel *model)
. However, this function internally callsGRBgeterrormsg()
after verifying the validity of the model pointer. Is there a specific reason you prefer to useGRBgetmerrormsg
instead ofGRBgeterrormsg
?Best regards,
Maliheh
0 -
No reason other than making the code a little cleaner on our end.
0
サインインしてコメントを残してください。
コメント
2件のコメント