Originally posted by: SystemAdmin
If I understand you correctly, you want to
1. solve the root node for a given model,
2. write the model including CPLEX root node cuts to a file,
3. modify the file (for example, adding your own cuts),
4. goto 1.
In this case, the PRE format is not what you want to use. First, this is a binary format (like SAV), and you cannot extend it with your own cuts.
Second, it does not store what you want, namely the cuts added by CPLEX.
In order to get the cuts (only possible in the C API!), you need to use a callback and get the nodelp with CPXgetcallbacknodelp(). The nodelp contains the cuts, and you can write it to disk. But note that the nodelp is specified in terms of the presolved model, and it does not contain the integrality conditions, i.e., it is a pure LP.
In order to implement your procedure as above, you need to use a more complicated approach:
1. Make sure that the MIPCBREDLP parameter is set to 1, and set the nodelimit to 1.
2. Install a branch callback that
(a) gets the MIP with CPXgetcallbacklp(env, cbdata, wherefrom, &lp),
(b) queries the number of original rows: origrows = CPXgetnumrows(env, lp),
(c) gets the nodelp with CPXgetcallbacknodelp(env, cbdata, wherefrom, &nodelp),
(d) gets the number of rows in nodelp: cutrows = CPXgetnumrows(env, nodelp),
(e) for i = origrows..cutrows-1:
(i) Get the row from nodelp: CPXgetrows
(ii) Uncrush the row to the original variable space: CPXuncrushform(). Note that this may fail, in which case you just skip the row.
(iii) Store the uncrushed row somewhere.
3. After CPXmipopt() comes back, add the rows stored in 2.(e)(iii) to your model. Then write the model to disk, for example in LP file format.
Hope this helps..
Tobias
(b) does nothing on subsequent calls
#CPLEXOptimizers#DecisionOptimization