you need call initial solve before branchAndBound.<br><br><div style="margin-left:40px"> CbcModel solver(solver1);<br> solver.initialSolve();<br>
 solver.branchAndBound();<br><br></div>Att.<br>Ivan<br><br><div class="gmail_quote">On Wed, Sep 19, 2012 at 4:45 AM, 刘峰 <span dir="ltr">&lt;<a href="mailto:liufengaarr@gmail.com" target="_blank">liufengaarr@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>Dear Sir:</div><div>         My name is LiuFeng, I am a student of Computer Science In Ji Lin University of China. I am learning to use CBC Library to solve some MIP problems. I met a problem,but I don&#39;t know how to solve it.</div>

<div>         The problem is as follows.</div><div>          It is an Integer Programming problem.</div><div>          The target function is Min z=x1 + x2 + x3 + x4</div><div>          The Constraints are</div><div>                                             4*x1 + 3*x2  + 2*x3             =2</div>

<div>                                                            x2 +  2*x3 + 5*x4 = 2</div><div>                                             xi &gt;= 0 (i=1,2,3,4) all of them have the constraint of integer.</div><div>          </div>

<div>          The CBC Codes is as follows:</div><div>int _tmain(int argc, _TCHAR* argv[])<br>{</div><div>     OsiClpSolverInterface solver1;<br>     const int numcols = 4;<br>     const int numrows = 2;<br>     int nnz = 6;<br>

    CoinBigIndex *start = new int[numcols+1];<br>    int* index = new int[nnz];<br>    double* value = new double[nnz];<br>    double *collb = new double[numcols];<br>    double *colub = new double[numcols];<br>    double *obj = new double[numcols];<br>

    double *rowlb = new double[numrows];<br>    double *rowub = new double[numrows];<br> //object<br> obj[0] = -1.0; obj[1] = -1.0; obj[2]=-1.0; obj[3]=-1.0;</div><div>  // column bounds<br>    collb[0] = 0;  colub[0] = solver1.getInfinity(); <br>

    collb[1] = 0;  colub[1] = solver1.getInfinity(); <br>    collb[2] = 0;  colub[2] = solver1.getInfinity(); <br>    collb[3] = 0;  colub[3] = solver1.getInfinity(); </div><div> // matrix<br> start[0]=0; index[0] = 0; value[0] = 4.0;<br>

 start[1]=1; index[1] = 0; value[4] = 3.0;<br>    index[2] = 1; value[5] = 1.0;<br> start[2]=3; index[3] = 0; value[6] = 2.0;<br>    index[4] = 1; value[7] = 2.0;<br> start[3]=5; index[5] = 1; value[8] = 5.0;<br> start[4]=6;</div>

<div> // row bounds<br> rowlb[0] = 2.; rowub[0] = 2.;<br>    rowlb[1] = 2.; rowub[1] = 2.;<br> solver1.loadProblem(numcols, numrows, start, index, value, collb, colub, obj, rowlb, rowub);<br> solver1.setInteger(0); // Sets x0 to integer<br>

 solver1.setInteger(1); // Sets x1 to integer<br> solver1.setInteger(2); // Sets x2 to integer<br> solver1.setInteger(3); // Sets x3 to integer<br> solver1.setObjSense(-1000.0); // Maximise</div><div> CbcModel solver(solver1);<br>

 solver.branchAndBound();<br> bool optimal = solver.isProvenOptimal();<br> const double *val = solver.getColSolution();<br> printf(&quot;Solution %g %g %g %g\n&quot;, val[0], val[1], val[2], val[3]);<br> return 0;</div><div>

}</div><div> </div><div>       I can&#39;t get the result. Would you please tell me how to solve them?Thank you very much!<br></div>
<br>_______________________________________________<br>
Cbc mailing list<br>
<a href="mailto:Cbc@list.coin-or.org">Cbc@list.coin-or.org</a><br>
<a href="http://list.coin-or.org/mailman/listinfo/cbc" target="_blank">http://list.coin-or.org/mailman/listinfo/cbc</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><table width="591" border="0" cellpadding="2" cellspacing="2"><tbody><tr><td style="font-family:Arial,Helvetica,sans-serif;font-size:11px;color:rgb(102,102,102)" rowspan="2" valign="middle" width="150">
<b>Ivan Meireles Costa</b><br>

        <b>Estágiario em otimização</b><br> <b>Telefone:</b> 31 3508-1323<br> <b>Celular:</b> 31 9869-6987<br>
    </td>
    <td rowspan="2" width="19"><img src="http://www.gapso.com.br/wp-content/uploads/2011/03/pontilhado.jpg" width="19" border="0" height="150"></td>
    <td width="372" height="57"><img src="http://www.gapso.com.br/wp-content/uploads/2011/03/logo_gapso_sig.jpg" width="372" height="57"></td>
  </tr>
  <tr>
    <td style="font-family:Arial,Helvetica,sans-serif;font-size:9px;color:rgb(102,102,102)" valign="top" width="372">
    A Gapso é a escolha das empresas que buscam se diferenciar pela gestão da complexidade.<br>
     Desenvolvemos sistemas analíticos de planejamento, que auxiliam a definir estratégias,<br> 
         planejar operações, reduzir riscos e lidar melhor com as incertezas do futuro. <br>
    <a href="http://www.gapso.com.br/" target="_blank">www.gapso.com.br</a></td></tr></tbody></table><br>