[Clp] get row/constraint coefficients

Akhil langer akhilanger at gmail.com
Sat May 26 22:27:39 EDT 2012


Thanks a lot Stefan. I am able to use it now!

On Thu, Apr 26, 2012 at 3:52 AM, Stefan Vigerske
<stefan at math.hu-berlin.de>wrote:

> Hi,
>
> the coefficients are stored in sparse format (
> http://en.wikipedia.org/wiki/**Sparse_matrix<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<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<http://list.coin-or.org/mailman/listinfo/clp>
>>
>
>
> --
> Stefan Vigerske
> Humboldt University Berlin, Numerical Mathematics
> http://www.math.hu-berlin.de/~**stefan<http://www.math.hu-berlin.de/~stefan>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/clp/attachments/20120526/05bcc478/attachment.html>


More information about the Clp mailing list