- Timestamp:
- Jan 28, 2011 4:16:51 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cbc/src/CbcHeuristicGreedy.cpp
r1587 r1589 989 989 const CoinBigIndex * columnStart = matrix_.getVectorStarts(); 990 990 const int * columnLength = matrix_.getVectorLengths(); 991 int * sosRow = new int [numberColumns]; 991 992 // If bit set then use current 992 993 if ((algorithm_&1)!=0) { … … 1017 1018 CoinBigIndex j; 1018 1019 int nSOS=0; 1019 if (!solver->isInteger(iColumn)) 1020 good = false; 1020 int iSOS=-1; 1021 1021 for (j = columnStart[iColumn]; 1022 1022 j < columnStart[iColumn] + columnLength[iColumn]; j++) { … … 1027 1027 if (element[j] != 1.0) 1028 1028 good = false; 1029 iSOS=iRow; 1029 1030 nSOS++; 1030 1031 } 1031 1032 } 1032 if (nSOS !=1)1033 if (nSOS>1||!solver->isBinary(iColumn)) 1033 1034 good = false; 1035 sosRow[iColumn] = iSOS; 1034 1036 } 1035 1037 if (!good) { 1036 1038 delete [] rhs; 1039 delete [] sosRow; 1037 1040 setWhen(0); // switch off 1038 1041 return 0; 1039 1042 } 1043 } else { 1044 abort(); // not allowed yet 1040 1045 } 1041 1046 const double * solution = solver->getColSolution(); … … 1055 1060 // Take off cost of gub slack 1056 1061 for (int iColumn = 0; iColumn < numberColumns; iColumn++) { 1057 if (columnLength[iColumn] == 1) { 1062 int iRow = sosRow[iColumn]; 1063 if (columnLength[iColumn] == 1&&iRow>=0) { 1058 1064 // SOS slack 1059 1065 double cost = direction*objective[iColumn]; 1060 int iRow = row[columnStart[iColumn]];1061 1066 assert (rhs[iRow]<0.0); 1062 1067 slackCost[iRow]=CoinMin(slackCost[iRow],cost); … … 1155 1160 forSort=1.0; 1156 1161 // Use smallest cost if will fit 1157 if (willFit && hasSlack&&1162 if (willFit /*&& hasSlack*/ && 1158 1163 value == 0.0 && columnUpper[iColumn]) { 1159 1164 if (hasSlack) { … … 1249 1254 } 1250 1255 } 1256 delete [] sosRow; 1251 1257 delete [] newSolution; 1252 1258 delete [] rowActivity; … … 1320 1326 CoinBigIndex j; 1321 1327 int nSOS=0; 1322 if (!solver->isInteger(iColumn))1323 good = false;1324 1328 for (j = columnStart[iColumn]; 1325 1329 j < columnStart[iColumn] + columnLength[iColumn]; j++) { … … 1333 1337 } 1334 1338 } 1335 if (nSOS !=1)1339 if (nSOS>1||!solver->isBinary(iColumn)) 1336 1340 good = false; 1337 1341 }
Note: See TracChangeset
for help on using the changeset viewer.