I'm using Coin-or Linear Programming library. I want to construct a ClpPlusMinusOneMatrix. Its constructor is:
ClpPlusMinusOneMatrix (int numberRows,
int numberColumns,
bool columnOrdered,
const int *indices,
const CoinBigIndex *startPositive,
const CoinBigIndex *startNegative);
It's not exactly clear what startPositive
and startNegative
are. If it's the same concept as described for another class here, then how does the matrix differentiate +1 and -1 vales?
For example, if I want to implement 1x4 matrix: [1 -1 1 -1]
. How does Clp know the value of the last two elements?
#include <coin/ClpPlusMinusOneMatrix.hpp>
int main()
{
int indices [4] {0, 1, 2, 3};
CoinBigIndex startPositive [2] {0, 4};
CoinBigIndex startNegative [2] {1, 4};
ClpPlusMinusOneMatrix(1, 4, false, indices, startPositive, startNegative);
}
Thanks
If you browse the source code here, you can deduce what startPositve
and startNegative
are. First, the matrix must be constructed such that all +1 elements must precede all -1 values in a row, if row major, or column, if column major. Then startPositive[i]
is simply the element index of the first +1 in row i
, if row major, or column i
if column major.