[Cbc] adding to a system after solving
John.Perry at usm.edu
Wed Jan 11 17:28:33 EST 2012
Thanks to everyone who replied to my earlier messages. I have a followup question that should hopefully finish things for me.
In the context* I'm working on, I have to do the following:
(1) set up a system of linear inequalities;
(2) if not "done" (whatever "done" might mean),
(2a) solve the system; and
(2b) add linear inequalities to the system, perhaps after copying it;
(2c) retrieve solutions to evaluate "done".
At first I tried the following approach:
(1) create si, an OsiSolverInterface;
(2) create a model m with si;
(3) if not "done",
(3a) add linear inequalities to si, perhaps after copying it;
(3b) solve by calling m's branchAndBound();
(3c) retrieve solutions from si to evaluate "done".
This was problematic, for all kinds of reasons. By reading the examples carefully, I discovered that I had to retrieve the solutions from m, not from si. In addition, I can't add new inequalities to m's solver after it solves.
So it seems that what I have to do is this:
(1) create si, an OsiSolverInterfaace;
(2) if not "done",
(2a) add linear inequalities to si, perhaps after copying it;
(2b) create a model m with si;
(2c) solve by calling m's branchAndBound();
(2d) retrieve solutions from si to evaluate "done".
In short, a new model must be created whenever we want to add inequalities to a system.
Is this correct, or am I missing something?
Thanks in advance!
* The context is an interface between Coin and the Sage computer algebra system. This is why the scenario depicted might look a little strange: it replicates how a Sage user might try to play around with a linear system. (Me, for example, but other people, too.)
More information about the Cbc