Changeset 2433 for trunk


Ignore:
Timestamp:
Nov 22, 2018 7:19:01 AM (7 months ago)
Author:
unxusr
Message:

querying rows in the C Interface

Location:
trunk/Cbc/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cbc/src/Cbc_C_Interface.cpp

    r2432 r2433  
    689689CbcGetProperty(int, getNumRows)
    690690CbcGetProperty(int, getIterationCount)
     691
     692/** Number of non-zero entries in a row */
     693COINLIBAPI int COINLINKAGE
     694Cbc_getRowNz(Cbc_Model * model, int row)
     695{
     696    const CoinPackedMatrix *cpmRow = model->model_->solver()->getMatrixByRow();
     697    return cpmRow->getVectorLengths()[row];
     698}
     699
     700/** Indices of variables that appear on this row */
     701COINLIBAPI const int * COINLINKAGE
     702Cbc_getRowIndices(Cbc_Model * model, int row)
     703{
     704    const CoinPackedMatrix *cpmRow = model->model_->solver()->getMatrixByRow();
     705    const CoinBigIndex *starts = cpmRow->getVectorStarts();
     706    const int *ridx = cpmRow->getIndices() + starts[row];
     707    return ridx;
     708}
     709
     710/** Coefficients of variables that appear on this row */
     711COINLIBAPI const double * COINLINKAGE
     712Cbc_getRowCoeffs(Cbc_Model * model, int row)
     713{
     714    const CoinPackedMatrix *cpmRow = model->model_->solver()->getMatrixByRow();
     715    const CoinBigIndex *starts = cpmRow->getVectorStarts();
     716    const double *rcoef = cpmRow->getElements() + starts[row];
     717    return rcoef;
     718}
     719
     720/** Right hand side of a row */
     721COINLIBAPI double COINLINKAGE
     722Cbc_getRowRHS(Cbc_Model * model, int row)
     723{
     724    return model->model_->solver()->getRightHandSide()[row];
     725}
     726
     727/** Sense a row */
     728COINLIBAPI char COINLINKAGE
     729Cbc_getRowSense(Cbc_Model * model, int row)
     730{
     731    return model->model_->solver()->getRowSense()[row];
     732}
    691733
    692734/** Are there a numerical difficulties? */
  • trunk/Cbc/src/Cbc_C_Interface.h

    r2428 r2433  
    152152    COINLIBAPI int COINLINKAGE
    153153    Cbc_getNumRows(Cbc_Model * model)
     154    ;
     155    /** Number of non-zero entries in a row */
     156    COINLIBAPI int COINLINKAGE
     157    Cbc_getRowNz(Cbc_Model * model, int row)
     158    ;
     159    /** Indices of variables that appear on this row */
     160    COINLIBAPI const int * COINLINKAGE
     161    Cbc_getRowIndices(Cbc_Model * model, int row)
     162    ;
     163    /** Coefficients of variables that appear on this row */
     164    COINLIBAPI const double * COINLINKAGE
     165    Cbc_getRowCoeffs(Cbc_Model * model, int row)
     166    ;
     167    /** Right hand side of a row */
     168    COINLIBAPI double COINLINKAGE
     169    Cbc_getRowRHS(Cbc_Model * model, int row)
     170    ;
     171    /** Sense a row */
     172    COINLIBAPI char COINLINKAGE
     173    Cbc_getRowSense(Cbc_Model * model, int row)
    154174    ;
    155175    /** Number of variables in the model */
Note: See TracChangeset for help on using the changeset viewer.