[Clp] get row/constraint coefficients
Stefan Vigerske
stefan at math.hu-berlin.de
Thu Apr 26 04:52:47 EDT 2012
Hi,
the coefficients are stored in sparse format
(http://en.wikipedia.org/wiki/Sparse_matrix) by Clp, i.e., it stores
only nonzero elements to save memory space and computing time.
See http://www.coin-or.org/Doxygen/Clp/classClpMatrixBase.html .
If the matrix is row major ordered (CSR) (!isColOrdered()), then
getElements() gives you the nonzero coefficients in the matrix,
getIndices() gives the column index for each coefficient,
getVectorStarts()[i] tells you, at which index in getElements() and
getIndices() the information for the i'th row are starting, and
getVectorLengths()[i] give you the number of nonzero elements in the
i'th row.
That is,
for( j = getVectorStarts()[i];
j < getVectorStarts()[i] + getVectorLengths()[i];
j++ )
{
printf("row %d col %d has coef. %g\n",
i, getIndices()[j], getElements()[j]);
}
should print you all nonzero coeffizients of the i'th row, together with
their column index.
Column major ordered (CSC) matrices are analogeous, getIndices() gives
you row indices and getVectorStarts() gives you the positions where
columns start in the indices and elements arrays.
Hope that helps,
Stefan
> Hi All,
>
> I read a lp model in mps format model using the readMps command. Then some
> constraints are added and deleted during the program run
> What methods can I use to obtain coefficients of the constraints present in
> the model. I am finding it difficult to understand the ClpMatrixBase class.
> Is there a straight forward way to do so.
> something like,
>
> double* getRowCoefficients(int rowIdx)
>
> or else, if someone can tell how to use the ClpMatrixBase class to obtain
> the coefficients
>
> Thanks,
> Akhil
>
>
>
>
> _______________________________________________
> Clp mailing list
> Clp at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/clp
--
Stefan Vigerske
Humboldt University Berlin, Numerical Mathematics
http://www.math.hu-berlin.de/~stefan
More information about the Clp
mailing list