Optimality can be checked through a call to model.isProvenOptimal(). Also available are isProvenInfeasible(), isSolutionLimitReached(), isNodeLimitReached() or the feared isAbandoned(). There is also int status() which returns 0 if finished (which includes the case when the algorithm is finished because it has been proved infeasible), 1 if stopped by user, and 2 if difficulties arose.
In addition to these CbcModel methods, solution values can be accessed via OSI methods. The OSI methods pick up the current solution in the CBCModel. The current solution will match the best solution found so far if called after branchAndBound() and a solution was found.
Table 2.1. Methods for Getting Solution Information from OSI
Purpose | Name | Notes |
---|---|---|
Primal column solution | const double * getColSolution() | The OSI method will return the best solution found thus far, unless none has been found. It is safer to use CbcModel version, CbcModel::bestSolution() |
Dual row solution | const double * getRowPrice() | Identical CbcModel version available, CbcModel::getRowPrice(). |
Primal row solution | const double * getRowActivity() | Identical CbcModel version available, CbcModel::getRowActivity(). |
Dual column solution | const double * getReducedCost() | Identical CbcModel version available, CbcModel::gtReducedCost(). |
Number of rows in model | int getNumRows() | Identical CbcModel version available, CbcModel::getNumRows(). Note: the number of rows can change due to cuts. |
Number of columns in model | int getNumCols() | Identical CbcModel version available, CbcModel::getNumCols(). |