2

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

user207421
  • 305,947
  • 44
  • 307
  • 483
Agrim Pathak
  • 3,047
  • 4
  • 27
  • 43
  • Are you sure this example gives you `[[1 -1] [1 -1]]`? – Holt Aug 16 '16 at 06:57
  • I don't know what this answer gives, which is partly the question. I'm asking how would I construct the 1x4 matrix [1, -1, 1 -1]. – Agrim Pathak Aug 16 '16 at 16:13
  • Linear programming has nothing to do with [tag:linear-algebra]. – user207421 Aug 22 '16 at 03:08
  • @EJP While i get your point, this statement is quite unfortunate in isolated form :-) – sascha Aug 22 '16 at 11:07
  • @sascha Please clarify your remark. I do not understand. – user207421 Aug 23 '16 at 01:45
  • @AgrimPathak If it isn't a linear-programming question either, why is it so tagged? – user207421 Aug 23 '16 at 01:46
  • @EJP I just meant, that the phrase *Linear programming has nothing to do with linear-algebra* is as wrong as it gets. – sascha Aug 23 '16 at 01:47
  • @sascha I studied them both in my mathematics degree. The connection eludes me. – user207421 Aug 23 '16 at 01:48
  • @EJP No kidding? Ever implemented a LP-solver? Random simplex quote (from [here](http://web.mit.edu/15.053/www/AMP-Chapter-02.pdf)): ```Though the simplex algorithm has solved each of our previous examples, we have yet to show that it solves any linear program. A formal proof requires results from linear algebra```. And some slides only talking about LA-concepts in [Interior-point solvers](https://en.wikipedia.org/wiki/Interior_point_method) [here](http://www.maths.ed.ac.uk/~gondzio/talks/dundee03.pdf) – sascha Aug 23 '16 at 01:54
  • @sascha I was doing it in a mathematics unit, not a computer programming unit. We weren't taught this stuff, indeed at the time I don't think the LA-based proof existed: I seem to remember there wasn't a proof at the time. I may be out of date on this. Still unsure why the question was so tagged, though. – user207421 Aug 23 '16 at 02:03

1 Answers1

0

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.

Agrim Pathak
  • 3,047
  • 4
  • 27
  • 43