<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    On 12-09-2013 08:08, Patrik Dufresne wrote:<br>
    <blockquote
cite="mid:CAJ=kj5z_na+2MpqJ0dAy1UzFQUTj6v2XLp9tSQAOBQZ2=f0zzw@mail.gmail.com"
      type="cite">
      <div dir="ltr"><br>
        <div class="gmail_quote">
          <div dir="ltr">Hi Haroldo,<br>
            <br>
            Your answer are very comprehensible. I'm very thankful to
            get a reply. As I understand,&nbsp;the main idea is to create the
            problem using OsiClpSolverInterface#addCol() or
            OsiClpSolverInterface#addRow(). Then I need to
            call&nbsp;OsiClpSolverInterface#initialSolve(). Questions:<br>
            <div><br>
            </div>
            <div>1. I had a look at all the Cbc examples and it does
              involve the class CbcModel. Should I care about it?&nbsp;</div>
            <div><br>
            </div>
            <div>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?</div>
            <div>OsiClpSolverInterface#initialSolve()<br>
            </div>
            <div>CbcModel#branchAndBound()</div>
          </div>
        </div>
      </div>
    </blockquote>
    Yes. initialSolve must be called before.<br>
    CbcModel.branchAndBound will perform a "pure" branch-and-bound (no
    cuts and heuristics). You can explicitly bind it to other Cbc
    classes to include these features (which often speed up a lot the
    search)&nbsp; or use the function &nbsp; CbcMain &nbsp; which will run everything
    using the same features as if you started the search from the
    command line.&nbsp; the code would look more or less as:<br>
    <br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CbcModel modelA(*linearProgram);<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CbcModel *model = &amp;modelA;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CbcMain0(modelA);<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const char * argv2[]={"problemName","-solve","-quit"};<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CbcMain1(3, argv2, modelA);<br>
    <br>
    <br>
    <br>
    <blockquote
cite="mid:CAJ=kj5z_na+2MpqJ0dAy1UzFQUTj6v2XLp9tSQAOBQZ2=f0zzw@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_quote">
          <div dir="ltr">
            <div><br>
            </div>
            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? <br>
            The following is what I think I should do:<br>
          </div>
        </div>
      </div>
    </blockquote>
    Since for MIPs there is no good reoptimization technique the cost of
    creating CbcModel again will probably be small comparedto the cost
    of reoptimizing an Integer Program.&nbsp; But the OsiClpSolverInterface
    you can change and do not need to recreated it again, probably.<br>
    <blockquote
cite="mid:CAJ=kj5z_na+2MpqJ0dAy1UzFQUTj6v2XLp9tSQAOBQZ2=f0zzw@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_quote">
          <div dir="ltr">a. create new instance of OsiClpSolverInterface
            named solver1<br>
            b. call solver1.addCol() and solver1.addRow() to build the
            problem<br>
            c. set objective value using solver1.setObjCoeff() and
            solver1.setObjSense()<br>
            d. call solver1.initialSolve()<br>
            e. create new instance of CbcModel(solver1) named model1
            <div>f. call model1.branchAndBound()<br>
              g. get the objective value model1.getObjValue() <br>
              <br>
              reusing the problem:<br>
              h. call addCol() or addRow() on solver1<br>
              i. run step c to g again<br>
              <br>
              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.</div>
            <div><br>
            </div>
            <div>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&nbsp;to create a new instance of
              CbcHeuristicFPump and call CbcModel.addHeuristic( ).<br>
            </div>
            <div>
              <div><br>
              </div>
              <div><br>
              </div>
            </div>
          </div>
          <div class="gmail_extra">
            <div class="im"><br clear="all">
              <div>
                <div dir="ltr">
                  <div>--</div>
                  Patrik Dufresne Service Logiciel
                  <div><a moz-do-not-send="true"
                      href="http://patrikdufresne.com/" target="_blank">http://patrikdufresne.com</a>/<br>
                    <div>
                      <div><a moz-do-not-send="true"
                          href="tel:514-971-6442" value="+15149716442"
                          target="_blank">514-971-6442</a></div>
                      <div><a moz-do-not-send="true"
                          href="tel:438-738-1376" value="+14387381376"
                          target="_blank">438-738-1376</a></div>
                      <div>114 rue des Hautbois, app1</div>
                      <div>St-Colomban, QC J5K 2H6</div>
                    </div>
                  </div>
                </div>
              </div>
              <br>
              <br>
            </div>
            <div>
              <div class="h5">
                <div class="gmail_quote">On Wed, Sep 11, 2013 at 8:47
                  PM, Haroldo Gambini Santos <span dir="ltr">&lt;<a
                      moz-do-not-send="true"
                      href="mailto:haroldo.santos@gmail.com"
                      target="_blank">haroldo.santos@gmail.com</a>&gt;</span>
                  wrote:<br>
                  <blockquote class="gmail_quote" style="margin:0 0 0
                    .8ex;border-left:1px #ccc solid;padding-left:1ex">
                    <div bgcolor="#FFFFFF" text="#000000"> Hi Patrick,
                      <div><br>
                        <br>
                        <br>
                        <div>On 11-09-2013 21:23, Patrik Dufresne wrote:<br>
                        </div>
                        <blockquote type="cite">
                          <div dir="ltr">Hello,
                            <div><br>
                            </div>
                            <div>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.</div>
                            <div><br>
                            </div>
                            <div>1. If I want to create a representation
                              of my problem using variables(columns) and
                              constraints(rows), should I use the&nbsp;<span
style="text-align:center;font-family:Arial,Helvetica,sans-serif">OsiClpSolverInterface

                                or CoinModel?</span></div>
                          </div>
                        </blockquote>
                      </div>
                      <b>OsiClpSolverInterface</b> - 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 <br>
                      by using OsiCpxSolverInterface)<br>
                      <br>
                      <a moz-do-not-send="true"
                        href="http://www.coin-or.org/Doxygen/Osi/classOsiSolverInterface.html"
                        target="_blank">http://www.coin-or.org/Doxygen/Osi/classOsiSolverInterface.html</a>
                      <div><br>
                        <br>
                        <blockquote type="cite">
                          <div dir="ltr">
                            <div><span
                                style="text-align:center;font-family:Arial,Helvetica,sans-serif"><br>
                              </span></div>
                            <div><span
                                style="text-align:center;font-family:Arial,Helvetica,sans-serif">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?</span></div>
                          </div>
                        </blockquote>
                      </div>
                      <b>Yes</b>
                      <div>
                        <blockquote type="cite">
                          <div dir="ltr">
                            <div>Basically, I need to create a problem.
                              Solve it. Add a new constraint. Solve it.
                              etc. etc. A snippet would be very welcome.</div>
                          </div>
                        </blockquote>
                      </div>
                      I do not have a small code here, but basically
                      what you need to do is:<br>
                      <br>
                      create an OsiClpSolverInterface<br>
                      <br>
                      after that you can cast the object to an
                      OsiSolverInterface pointer, so that all your calls
                      will be solver independent (not required)<br>
                      <br>
                      to create your problem:<br>
                      use methods <br>
                      <br>
                      &nbsp;addCol/addCols, addRow/addRows<br>
                      <br>
                      you can also use a CoinBuild object to to create
                      and populate constraints (I think this is easier)
                      :<br>
                      <a moz-do-not-send="true"
                        href="http://www.coin-or.org/Doxygen/CoinAll/class_coin_build.html"
                        target="_blank">http://www.coin-or.org/Doxygen/CoinAll/class_coin_build.html</a><br>
                      <br>
                      basically you add rows to a CoinBuild object and
                      then add this object to OsiSolverInterface<br>
                      <br>
                      after your problem is built you can&nbsp;&nbsp; call&nbsp;&nbsp;
                      initialSolve&nbsp;&nbsp; to solve the LP<br>
                      <br>
                      Cheers<br>
                      <br>
                      <blockquote type="cite">
                        <div>
                          <div dir="ltr">
                            <div><br>
                            </div>
                            <div>Thanks</div>
                            <div><br>
                            </div>
                            <div>
                              <div>
                                <div dir="ltr">
                                  <div>--</div>
                                  Patrik Dufresne Service Logiciel
                                  <div><a moz-do-not-send="true"
                                      href="http://patrikdufresne.com/"
                                      target="_blank">http://patrikdufresne.com</a>/<br>
                                    <div>
                                      <div><a moz-do-not-send="true"
                                          href="tel:514-971-6442"
                                          value="+15149716442"
                                          target="_blank">514-971-6442</a></div>
                                      <div><a moz-do-not-send="true"
                                          href="tel:438-738-1376"
                                          value="+14387381376"
                                          target="_blank">438-738-1376</a></div>
                                      <div>114 rue des Hautbois, app1</div>
                                      <div>St-Colomban, QC J5K 2H6</div>
                                    </div>
                                  </div>
                                </div>
                              </div>
                            </div>
                          </div>
                          <br>
                          <fieldset></fieldset>
                          <br>
                        </div>
                        <pre>_______________________________________________
Cbc mailing list
<a moz-do-not-send="true" href="mailto:Cbc@list.coin-or.org" target="_blank">Cbc@list.coin-or.org</a>
<a moz-do-not-send="true" href="http://list.coin-or.org/mailman/listinfo/cbc" target="_blank">http://list.coin-or.org/mailman/listinfo/cbc</a><span><font color="#888888">
</font></span></pre>
                        <span><font color="#888888"> </font></span></blockquote>
                      <span><font color="#888888"> <br>
                          <pre cols="72">-- 
==================================================
Haroldo Gambini Santos
D.Sc, Computer Science
Universidade Federal de Ouro Preto
<a moz-do-not-send="true" href="http://www.decom.ufop.br/haroldo/" target="_blank">http://www.decom.ufop.br/haroldo/</a></pre>
                        </font></span></div>
                  </blockquote>
                </div>
                <br>
              </div>
            </div>
          </div>
        </div>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Cbc mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Cbc@list.coin-or.org">Cbc@list.coin-or.org</a>
<a class="moz-txt-link-freetext" href="http://list.coin-or.org/mailman/listinfo/cbc">http://list.coin-or.org/mailman/listinfo/cbc</a>
</pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
==================================================
Haroldo Gambini Santos
D.Sc, Computer Science
Universidade Federal de Ouro Preto
<a class="moz-txt-link-freetext" href="http://www.decom.ufop.br/haroldo/">http://www.decom.ufop.br/haroldo/</a></pre>
  </body>
</html>