[Clp] Solving multiple LPs with ClpSimplex

Eugenio Bargiacchi svalorzen at gmail.com
Thu Oct 9 08:37:05 EDT 2014


Hello,

I'm trying to solve a series of LPs, where I incrementally add rows
one by one. The process is like this:

1 - Add a row to current LP
2 - Try to obtain primal solution
3 - Remove row
4 - If there is a solution, add a different row permanently to the LP.
5 - Repeat from 1.

I've implemented this using lp_solve, but I've read that Clp is
supposed to be faster so I was trying to reproduce my implementation
using Clp.

Unfortunately, my Clp implementation is way slower than my lp_solve
implementation (although the logic is pretty much the same), so it
could possibly be that I'm not using Clp facilities in the correct
way, or maybe memory reallocations are just incredibly taxing.

I have two questions, in particular:

- Since I have to frequently add and delete rows, what is the best way
to reduce memory allocations within Clp? I've tried using
`setPersistenceFlag(1)`, but my program crashes. I've also tried it on
the very simple example in the Clp user guide, but still it crashes.
Is it the correct approach?
- I'm curious how you would suggest calling the solution method.
Before I've trying simply calling `primal()`, but as the problem grows
more complex I've noticed that calling `dual(); primal();` in sequence
can get over 4 times as fast (for small problems it's a bit slower),
and returns the correct results. Does this even make sense?

If you have any other comments or suggestions I'd be happy to hear
them. Thanks in advance.

Best,
Eugenio Bargiacchi


More information about the Clp mailing list