Equivalences to certain CPLEX API calls/parameters
Hello,
I want to find out whether there are any advantages to switching from CPLEX to Gurobi routines for my model. I plan to use the C API in GRB as well, just like I do in CPLEX.
Although I have reviewed the helpful introductory page found here (https://www.gurobi.com/resources/switching-from-cplex/), I am unable to locate equivalent options for a few CPLEX parameters. I would appreciate any help in resolving these and determining the equivalencies, or else to determine whether there is no equivalent or whether there is an alternative method of achieving the same objective.
(1) CPXPARAM_Read_Datacheck (https://www.ibm.com/docs/en/cofz/12.8.0?topic=parameters-data-consistency-checking-modeling-assistance)
In CPLEX, I usually turn this on in debug builds as I am stepping through the code and this offers modelling assistance in terms of whether variables have some odd coefficients, whether some constraints are being repeated, etc.
(2) CPXPARAM_ScreenOutput (https://www.ibm.com/docs/en/icos/12.9.0?topic=parameters-messages-screen-switch)
This displays screen/console output instead of silently proceeding without displaying anything on the screen.
This adds empty columns to the model which later on can be referred to when adding constraints. The CPLEX way allows for specifying all attributes such as cost, lb, ub, varname and variable type as arrays in a single call.
Is it correct that the equivalent way to do it in GRB is via separate individual scalar calls to:
for(int j = 0; j < number_of_variables; j++){
GRBsetdblattrelement(model, "Obj", j, cost[j]);
GRBsetdblattrelement(model, "LB", j, lb[j]);
GRBsetdblattrelement(model, "UB", j, ub[j]);
GRBsetstrattrelement(model, "VarName", j , Varname[j]);
GRBsetcharattrelement(model, "VType", j, VType[j]);
}
(4) CPXsolution (https://www.ibm.com/docs/en/icos/12.9.0?topic=s-cpxxsolution-cpxsolution)
This allows querying an LP's solved model's output as arrays (Xs, dual variables, reduced costs, etc.) Is the recommended equivalent in GRB to query, say, the X variable by variable in a loop?
for(int i = 0; i < total_variables; i++)
GRBgetdblattrelement(model, "X", i, &Sol[i]);
Is there a way to get the entire solution value by having something like
GRBgetdblattrelements(model, "Xs", Sol);
where Sol is a double* ?
(5) CPXPARAM_Parallel (https://www.ibm.com/docs/en/icos/12.9.0?topic=parameters-parallel-mode-switch)
Is there any equivalent setting for choosing between Opportunistic, Auto-parallel and deterministic?
(6) CPXPARAM_Advance (https://www.ibm.com/docs/en/icos/12.9.0?topic=parameters-advanced-start-switch)
Is there an equivalent GRB parameter which controls whether on starting an MIP, to use or not to use advanced start information or to crush a basis? A similar question before elicited this answer (https://support.gurobi.com/hc/en-us/community/posts/360077078831/comments/5547578159249) but if I understand correctly, LPWarmStart applies to LPs only, while CPXPARAM_Advance applies to MIPs as well and in the context of MIPs whether presolve can happen to the MIP even though there could be a basis for the root node relaxation LP. From my understanding, CPXPARAM_Advance setting of 0 means that even though an LP basis might be available, do not use it and start solving the MIP from scratch applying presolve and other problem reductions, etc.
Thank you.
0
-
Hello
pls check below-
-
Data Consistency Checking
- CPLEX:
CPXPARAM_Read_Datacheck
(debugging assistance) - Gurobi: No direct equivalent, but errors/warnings help detect issues.
- CPLEX:
-
Screen Output
- CPLEX:
CPXPARAM_ScreenOutput
(1 = enable output) - Gurobi:
OutputFlag
(1 = enable, 0 = disable).
- CPLEX:
-
Adding Columns
- CPLEX:
CPXnewcols
(adds multiple variables at once). - Gurobi: Use
GRBaddvar
in a loop andGRBsetattrarray
for bulk updates.
- CPLEX:
-
Retrieving Solutions
- CPLEX:
CPXsolution
(fetches all values in one call). - Gurobi: Use
GRBgetdblattrarray(model, "X", 0, total_variables, Sol)
.
- CPLEX:
-
Parallel Optimization
- CPLEX:
CPXPARAM_Parallel
(Auto, Deterministic, Opportunistic). - Gurobi: Always deterministic, no opportunistic mode.
- CPLEX:
-
Advanced Start
- CPLEX:
CPXPARAM_Advance
(controls basis use in MIP/LP). - Gurobi: No direct equivalent; use "Start" attribute for MIP warm starts.
- CPLEX:
1 -
-
Thank you. I will test these out. Regarding:
"Advanced Start
CPLEX: CPXPARAM_Advance (controls basis use in MIP/LP).
Gurobi: No direct equivalent; use "Start" attribute for MIP warm starts."Since I posted this more than a month ago, I got a chance to delve deeper into gurobi manual. It appears to me that setting CPXPARAM_Advance to 0 in CPLEX is equivalent to essentially running GRBreset() in Gurobi:
https://docs.gurobi.com/projects/optimizer/en/current/reference/c/solving.html#c.GRBreset
0
サインインしてコメントを残してください。
コメント
2件のコメント