<html><body>
<p>Jan-Willem,<br>
<br>
Looking at your driver, maybe a very simple approach will work best.  I have put a driver into Cbc/trunk as Cbc/examples/simpleBAB.cpp but it can be used from stable.  If USE_CBC is defined it uses CbcModel to solve two IPs and if it is not defined uses OsiCl branchAndBound.<br>
<br>
Hope it helps.<br>
<br>
John<br>
--------------------------<br>
  OsiClpSolverInterface model;<br>
 <br>
  int start[] = { 0, 1, 2};<br>
  int index[] = { 0, 0};<br>
  double values[] = {1.0, 2.0};<br>
  double collb[] = {0.0, 0.0};<br>
  double colub[] = {10.0, 10.0};<br>
  double obj[] = { 1.0, 1.0};<br>
  double rowlb[] = { 0.0};<br>
  double rowub[]= { 3.9};<br>
  <br>
  // obj: Max x0 + x1<br>
  //  st. x0 + 2 x1 &lt;= 3.9<br>
  //          0 &lt;= x0 &lt;= 10 and integer<br>
  //          0 &lt;= x1 &lt;= 10<br>
  model.loadProblem(2, 1, start, index, values, collb, colub, obj, rowlb, rowub);<br>
  model.setInteger(0);<br>
  model.setObjSense(-1.0);<br>
  bool optimal;<br>
  <br>
#ifndef USE_CBC<br>
  // Save bounds - that and dual limit should be all that is needed<br>
  // For this simple example we could just re-use collb and colub<br>
  double saveLower[2];<br>
  double saveUpper[2];<br>
  int numberColumns = model.getNumCols();<br>
  CoinCopyN(model.getColLower(),numberColumns,saveLower);<br>
  CoinCopyN(model.getColUpper(),numberColumns,saveUpper);<br>
  double objLimit;<br>
  model.getDblParam(OsiDualObjectiveLimit,objLimit);<br>
  model.branchAndBound();<br>
  optimal = model.isProvenOptimal(); <br>
  const double *val = model.getColSolution(); // x0 = 3, x1 = 0.45<br>
  printf(&quot;Solution %g %g\n&quot;,val[0],val[1]);<br>
  // Restore bounds and dual limit<br>
  model.setColLower(saveLower);<br>
  model.setColUpper(saveUpper);<br>
  model.setDblParam(OsiDualObjectiveLimit,objLimit);<br>
#else<br>
  {<br>
    CbcModel model2(model);<br>
    model2.branchAndBound();<br>
    optimal = model2.isProvenOptimal(); <br>
    const double *val = model2.getColSolution(); // x0 = 3, x1 = 0.45<br>
    printf(&quot;Solution %g %g\n&quot;,val[0],val[1]);<br>
  }<br>
#endif<br>
  <br>
  const int rowCols[] = {0};<br>
  const double rowElements = { 1.0};<br>
  <br>
  // add x0 &lt;= 2, and solve once again.<br>
  CoinPackedVector v(1, rowCols, rowElements);<br>
  model.addRow(v, 0.0, 2.0);<br>
#ifndef USE_CBC<br>
  model.branchAndBound();<br>
  optimal = model.isProvenOptimal(); // should be x0 = 2, x1 = 0.95<br>
  // Address of solution will be same as only adding rows - but be safe<br>
  val = model.getColSolution();<br>
  printf(&quot;Solution %g %g\n&quot;,val[0],val[1]);<br>
#else<br>
  {<br>
    CbcModel model2(model);<br>
    model2.branchAndBound();<br>
    optimal = model2.isProvenOptimal(); // should be x0 = 2, x1 = 0.95<br>
    const double *val = model2.getColSolution(); <br>
    printf(&quot;Solution %g %g\n&quot;,val[0],val[1]);<br>
  }<br>
#endif<br>
 <br>
<br>
<img width="16" height="16" src="cid:1__=0ABBFF01DFA706A48f9e8a93df938@us.ibm.com" border="0" alt="Inactive hide details for Goossens Jan-Willem ---04/06/2009 11:55:38 AM---Hi,"><font color="#424282">Goossens Jan-Willem ---04/06/2009 11:55:38 AM---Hi,</font><br>
<br>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top"><td width="1%"><img width="96" height="1" src="cid:2__=0ABBFF01DFA706A48f9e8a93df938@us.ibm.com" border="0" alt=""><br>
<font size="2" color="#5F5F5F">From:</font></td><td width="100%"><img width="1" height="1" src="cid:2__=0ABBFF01DFA706A48f9e8a93df938@us.ibm.com" border="0" alt=""><br>
<font size="2">Goossens Jan-Willem &lt;Jan-Willem.Goossens@nc3a.nato.int&gt;</font></td></tr>

<tr valign="top"><td width="1%"><img width="96" height="1" src="cid:2__=0ABBFF01DFA706A48f9e8a93df938@us.ibm.com" border="0" alt=""><br>
<font size="2" color="#5F5F5F">To:</font></td><td width="100%"><img width="1" height="1" src="cid:2__=0ABBFF01DFA706A48f9e8a93df938@us.ibm.com" border="0" alt=""><br>
<font size="2">&quot;osi@list.coin-or.org&quot; &lt;osi@list.coin-or.org&gt;</font></td></tr>

<tr valign="top"><td width="1%"><img width="96" height="1" src="cid:2__=0ABBFF01DFA706A48f9e8a93df938@us.ibm.com" border="0" alt=""><br>
<font size="2" color="#5F5F5F">Date:</font></td><td width="100%"><img width="1" height="1" src="cid:2__=0ABBFF01DFA706A48f9e8a93df938@us.ibm.com" border="0" alt=""><br>
<font size="2">04/06/2009 11:55 AM</font></td></tr>

<tr valign="top"><td width="1%"><img width="96" height="1" src="cid:2__=0ABBFF01DFA706A48f9e8a93df938@us.ibm.com" border="0" alt=""><br>
<font size="2" color="#5F5F5F">Subject:</font></td><td width="100%"><img width="1" height="1" src="cid:2__=0ABBFF01DFA706A48f9e8a93df938@us.ibm.com" border="0" alt=""><br>
<font size="2">[Osi] re-solving with osiclp branchAndBound</font></td></tr>
</table>
<hr width="100%" size="2" align="left" noshade style="color:#8091A5; "><br>
<br>
<br>
Hi,<br>
 <br>
I understand that the branchAndBound support within OsiClp is meant to be only basic. Still:<br>
 <br>
How can I branchAndBound(), then add a constraint, and branchAndBound() again?<br>
Just like that, it doesn’t work. With CBC’s saveReferenceModel in mind, I tried<br>
 <br>
      OsiClpSolverInterface model;<br>
 <br>
      <font color="#0000FF">int</font> start[] = { 0, 1, 2};<br>
      <font color="#0000FF">int</font> index[] = { 0, 0};<br>
      <font color="#0000FF">double</font> values[] = {1.0, 2.0};<br>
      <font color="#0000FF">double</font> collb[] = {0.0, 0.0};<br>
      <font color="#0000FF">double</font> colub[] = {10.0, 10.0};<br>
      <font color="#0000FF">double</font> obj[] = { 1.0, 1.0};<br>
      <font color="#0000FF">double</font> rowlb[] = { 0.0};<br>
      <font color="#0000FF">double</font> rowub[]= { 3.9};<br>
 <br>
      <font color="#008000">// obj: Max x0 + x1</font><br>
      <font color="#008000">//  st. x0 + 2 x1 &lt;= 3.9</font><br>
      <font color="#008000">//          0 &lt;= x0 &lt;= 10 and integer</font><br>
      <font color="#008000">//          0 &lt;= x1 &lt;= 10</font><br>
      model.loadProblem(2, 1, start, index, values, collb, colub, obj, rowlb, rowub);<br>
      model.setInteger(0);<br>
      model.setObjSense(-1.0);<br>
 <br>
      model.saveBaseModel(); <font color="#008000">// maybe this helps, and restoreBaseModel(1)</font><br>
      model.branchAndBound();<br>
      <font color="#0000FF">bool</font> optimal = model.isProvenOptimal(); <br>
      <font color="#0000FF">const</font> <font color="#0000FF">double</font> *val = model.getColSolution(); <font color="#008000">// x0 = 3, x1 = 0.45</font><br>
      model.restoreBaseModel(1);<br>
 <br>
      <font color="#0000FF">const</font> <font color="#0000FF">int</font> rowCols[] = {0};<br>
      <font color="#0000FF">const</font> <font color="#0000FF">double</font> rowElements = { 1.0};<br>
 <br>
      <font color="#008000">// add x0 &lt;= 2, and solve once again.</font><br>
      CoinPackedVector v(1, rowCols, rowElements);<br>
      model.addRow(v, 0.0, 2.0);<br>
      model.branchAndBound();<br>
      optimal = model.isProvenOptimal(); <font color="#008000">// should be x0 = 2, x1 = 0.95</font><br>
 <br>
Gives the output<br>
 <br>
<b>Clp0006I 0  Obj 3.45 Primal inf 1 (1) Dual inf 1e+010 (1)</b><br>
<b>Clp0006I 1  Obj 2.95</b><br>
<b>Clp0000I Optimal - objective value 2.95</b><br>
<b>The LP relaxation is infeasible</b><br>
<b> </b><br>
So, almost there, but for some reason “The LP relaxation is infeasible”. The reasons seems to be that within branchAndBound, the test “isDualObjLimitReached” of the initialSolve returns true..<br>
 <br>
Note, I’m not working with the very latest sources, so if you cannot reproduce this…<br>
 <br>
Thanks,<br>
 <br>
Jan-Willem<br>
<font color="#1F497D"> </font><tt>_______________________________________________<br>
Osi mailing list<br>
Osi@list.coin-or.org<br>
</tt><tt><a href="http://list.coin-or.org/mailman/listinfo/osi">http://list.coin-or.org/mailman/listinfo/osi</a></tt><tt><br>
</tt><br>
<br>
</body></html>