[Cbc] Fwd: Beginner here

Patrik Dufresne info at patrikdufresne.com
Thu Sep 12 07:08:24 EDT 2013


Hi Haroldo,

Your answer are very comprehensible. I'm very thankful to get a reply. As I
understand, the main idea is to create the problem using
OsiClpSolverInterface#addCol() or OsiClpSolverInterface#addRow(). Then I
need to call OsiClpSolverInterface#initialSolve(). Questions:

1. I had a look at all the Cbc examples and it does involve the class
CbcModel. Should I care about it?

2. As I understand, clp is used to run the simplex algorithm. Cbc is used
to run the branch and bound. So I guess I need to run both step explicitly?
OsiClpSolverInterface#initialSolve()
CbcModel#branchAndBound()

3. Reading the doc about CbcModel, it copy the solver passed in the
constructor. What is the suggested approach if I need to reuse the problem
over and over?
The following is what I think I should do:
a. create new instance of OsiClpSolverInterface named solver1
b. call solver1.addCol() and solver1.addRow() to build the problem
c. set objective value using solver1.setObjCoeff() and solver1.setObjSense()
d. call solver1.initialSolve()
e. create new instance of CbcModel(solver1) named model1
f. call model1.branchAndBound()
g. get the objective value model1.getObjValue()

reusing the problem:
h. call addCol() or addRow() on solver1
i. run step c to g again

The end result: I will create a single instance of OsiClpSolverInterface
and multiple instance of CbcModel. I also sees a different approach to
create a single CbcModel and call CbcModel.solver() to update the problem
multiple time. I guess both would work, but what is the "faster" one. The
one avoiding memory copy, useless recomputation etc.

4. Using the command line, I notice a performance improvement to solve my
problem using the following arguments: cbc .. mps -feas both -doh -solve
... Basically, activating the feasibility pump help alot. As I understand,
I need to create a new instance of CbcHeuristicFPump and call
CbcModel.addHeuristic( ).



--
Patrik Dufresne Service Logiciel
http://patrikdufresne.com/
514-971-6442
438-738-1376
114 rue des Hautbois, app1
St-Colomban, QC J5K 2H6


On Wed, Sep 11, 2013 at 8:47 PM, Haroldo Gambini Santos <
haroldo.santos at gmail.com> wrote:

>  Hi Patrick,
>
>
>
> On 11-09-2013 21:23, Patrik Dufresne wrote:
>
> Hello,
>
>  I'm just getting started with CoinCbc. I found the learning curve very
> steep compare to GLPK where everything is documented in details. I'm
> struggling with all the object available to create a model and solve it. To
> avoid any beginner mistake, I'm asking the mailing list in hope to get tips
> for my very specific needs.
>
>  1. If I want to create a representation of my problem using
> variables(columns) and constraints(rows), should I use the OsiClpSolverInterface
> or CoinModel?
>
> *OsiClpSolverInterface* - this class inherits from OsiSolverInterface so
> that any method you use to create/modify your problem will be compatible
> with other Osi Interfaces (e.g.: cplex
> by using OsiCpxSolverInterface)
>
> http://www.coin-or.org/Doxygen/Osi/classOsiSolverInterface.html
>
>
>
>  2. If I need to do subsequent modification to the problem (e.g.: adding
> variables or constraints), can I reuse the same object over and over again?
>
> *Yes*
>
>  Basically, I need to create a problem. Solve it. Add a new constraint.
> Solve it. etc. etc. A snippet would be very welcome.
>
> I do not have a small code here, but basically what you need to do is:
>
> create an OsiClpSolverInterface
>
> after that you can cast the object to an OsiSolverInterface pointer, so
> that all your calls will be solver independent (not required)
>
> to create your problem:
> use methods
>
>  addCol/addCols, addRow/addRows
>
> you can also use a CoinBuild object to to create and populate constraints
> (I think this is easier) :
> http://www.coin-or.org/Doxygen/CoinAll/class_coin_build.html
>
> basically you add rows to a CoinBuild object and then add this object to
> OsiSolverInterface
>
> after your problem is built you can   call   initialSolve   to solve the LP
>
> Cheers
>
>
>  Thanks
>
>   --
> Patrik Dufresne Service Logiciel
> http://patrikdufresne.com/
>  514-971-6442
> 438-738-1376
> 114 rue des Hautbois, app1
> St-Colomban, QC J5K 2H6
>
>
> _______________________________________________
> Cbc mailing listCbc at list.coin-or.orghttp://list.coin-or.org/mailman/listinfo/cbc
>
>
> --
> ==================================================
> Haroldo Gambini Santos
> D.Sc, Computer Science
> Universidade Federal de Ouro Pretohttp://www.decom.ufop.br/haroldo/
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/cbc/attachments/20130912/4b688362/attachment-0001.html>


More information about the Cbc mailing list