[Coin-discuss] non-integer solution for integer linear program? what goes wrong?
Wiebe Kirsten (Stud. FdEWB)
K.Wiebe at Student.Unimaas.NL
Sat Aug 12 14:41:06 EDT 2006
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 8330 bytes
Desc: not available
URL: <http://list.coin-or.org/pipermail/coin-discuss/attachments/20060812/c11ae37d/attachment.bin>
More information about the Coin-discuss
mailing list