[Coin-discuss] non-integer solution for integer linear program? what goes wrong?

Matthew Galati magh at lehigh.edu
Tue Aug 15 15:13:22 EDT 2006


modelForILP is a ClpSimplex object which only knows how to solve linear 
programs -- not integer linear programs. You need to use CBC for integer 
programs. I am not sure why ClpSimplex/Model::setInteger even exists - 
probably for the sake of interfacing with CBC.

Matt


> Hello,
> what can go wrong if I get a non-integer solution to the 
> following integer linear program :
>  
>
> // initialize model for MPS
>
> modelForILP = new ClpSimplex;
>
> //set columns
>
> modelForILP->resize(0,nrCol);
>
> // x-variables are binary and
>
> // have coefficient weight[i][j] in the objective
>
> for ( int i=0;i<nrJournals-1;i++)
>
> {
>
>    for ( int j=i+1;j<nrJournals;j++)
>
>    {
>
>       counter[i][j] = counterNrCol;
>
>       counterNrCol++;
>
>       //putting (c[i][j]-c[j][i])*x[i][j]+ c[j][i] in the objective
>
>       modelForILP->setObjCoeff(counter[i][j],c[i][j]-c[j][i]);
>
>       modelForILP->setColLower(counter[i][j],0.0);
>
>       modelForILP->setColumnUpper(counter[i][j],1.0);
>
>       modelForILP->setInteger(counter[i][j]);
>
>    }
>
> }
>
> modelForILP->setOptimizationDirection(1.0); //1.0 minimizing, -1.0 
> maximizing
>
> //add constraints
>
> // 0 <= x[i][j] + x[j][k] - x[i][k] <= 1
>
> rowIndex = new int [3];
>
> rowValue = new double [3];
>
> for ( int i=0;i<nrJournals-2;i++) //nrJournals-2 oder nrJournals
>
> {
>
>    for ( int j=i+1;j<nrJournals;j++) //j=i+1 and nrJournals-1 oder 0 
> and nrJournals
>
>    {
>
>       for ( int k=j+1;k<nrJournals;k++) //k=j+1 oder k=0
>
>       {
>
>          if (i!=j && j<k && k!=i)
>
>          {
>
>             rowIndex[0] = counter[i][j];
>
>             rowIndex[1] = counter[j][k];
>
>             rowIndex[2] = counter[i][k];
>
>             rowValue[0] = 1;
>
>             rowValue[1] = 1;
>
>             rowValue[2] = -1;
>
>             modelForILP->addRow(3,rowIndex,rowValue,0.0,1.0);
>
>          }
>
>       }
>
>    }
>
> }
>
> delete []rowIndex;
>
> delete []rowValue;
>
>  
> and then depending on the situation, add the following type of 
> contraints, where temp4 = 0 or 1
>  
>
> rowIndex = new int [1];
>
> rowValue = new double [1];
>
> rowIndex[0] = variable; //column-number, i.e. the variable that has to 
> be fixed
>
> rowValue[0] = 1;
>
> modelForILP->addRow(1,rowIndex,rowValue,temp4,temp4);
>
> delete []rowIndex;
>
> delete []rowValue;
>
>  
> I'd be very happy if anyone of you has an idea!!!
> kind regards
> Kirsten
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Coin-discuss mailing list
>Coin-discuss at list.coin-or.org
>http://list.coin-or.org/mailman/listinfo/coin-discuss
>  
>



More information about the Coin-discuss mailing list