[Coin-lpsolver] How model.setInteger works?

Yunjing Xu yunjingxu at gmail.com
Thu Dec 6 06:45:06 EST 2007


Hi all,

In some cases, some of the variables must be of integer type. However, when
I tried the method: model.setInteger with the following code, it does not
work as expected:


int main()
{
    ClpSimplex  model;

    model.resize(0, 2);
    int columns[] = {0, 1};
    double elements[]={0.0, 1.0};
    model.addRow(2, columns, elements, 1.1, COIN_DBL_MAX);

    model.setInteger(1);
    model.primal();

    int numberColumns = model.numberColumns();
    double * columnPrimal = model.primalColumnSolution();
    double * columnDual = model.dualColumnSolution();

    int iColumn;
    for (iColumn=0;iColumn<numberColumns;iColumn++)
    printf("Column %d, primal %g, dual %g\n",iColumn,
    columnPrimal[iColumn],columnDual[iColumn]);

    return 0;
}


The result is:

Column 0, primal 0, dual 0
Column 1, primal 1.1, dual 0

How could I make the second column to equal to 2.0?

Thank you.

-- 
Yunjing Xu
Software Institute, Nanjing University
Tel:+86-25-5874-5159, +86-1580-147-0200
Email: yunjingxu at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/clp/attachments/20071206/08dd2ff7/attachment.html>


More information about the Clp mailing list