Changeset 1585 for trunk/Cbc/src/CbcHeuristicGreedy.cpp
 Timestamp:
 Jan 11, 2011 2:04:34 PM (9 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Cbc/src/CbcHeuristicGreedy.cpp
r1573 r1585 1064 1064 } 1065 1065 double offset2 = 0.0; 1066 char * sos = new char [numberRows]; 1066 1067 for (int iRow = 0;iRow < numberRows; iRow++) { 1068 sos[iRow]=0; 1069 if (rhs[iRow]<0.0) { 1070 sos[iRow]=1; 1071 rhs[iRow]=1.0; 1072 } 1067 1073 if( slackCost[iRow] == 1.0e30) { 1068 1074 slackCost[iRow]=0.0; 1069 1075 } else { 1070 1076 offset2 += slackCost[iRow]; 1071 rhs[iRow] = 2.0;1077 sos[iRow] = 2; 1072 1078 } 1073 1079 } … … 1095 1101 double * rowActivity = new double[numberRows]; 1096 1102 memset(rowActivity, 0, numberRows*sizeof(double)); 1097 if ((algorithm_& 2)==0) {1103 if ((algorithm_&(24))==0) { 1098 1104 // get solution as small as possible 1099 1105 for (iColumn = 0; iColumn < numberColumns; iColumn++) … … 1115 1121 } 1116 1122 } 1123 // get row activity 1124 for (iColumn = 0; iColumn < numberColumns; iColumn++) { 1125 CoinBigIndex j; 1126 double value = newSolution[iColumn]; 1127 for (j = columnStart[iColumn]; 1128 j < columnStart[iColumn] + columnLength[iColumn]; j++) { 1129 int iRow = row[j]; 1130 rowActivity[iRow] += value * element[j]; 1131 } 1132 } 1117 1133 double * contribution = new double [numberColumns]; 1118 1134 int * which = new int [numberColumns]; … … 1123 1139 double forSort = 0.0; 1124 1140 bool hasSlack=false; 1141 bool willFit=true; 1125 1142 newSolutionValue += value * cost; 1126 1143 for (j = columnStart[iColumn]; 1127 1144 j < columnStart[iColumn] + columnLength[iColumn]; j++) { 1128 1145 int iRow = row[j]; 1129 rowActivity[iRow] += value * element[j]; 1130 if (rhs[iRow] >0.0) { 1131 forSort += element[j]; 1132 } else if (rhs[iRow] == 2.0) { 1146 if (sos[iRow] == 2) 1133 1147 hasSlack = true; 1134 } 1148 forSort += element[j]; 1149 double gap = rhs[iRow]  rowActivity[iRow]+1.0e8; 1150 if (gap<element[j]) 1151 willFit = false; 1135 1152 } 1136 if (forSort && value == 0.0 && columnUpper[iColumn]) { 1153 bool isSlack = hasSlack && (columnLength[iColumn]==1); 1154 if ((algorithm_&4)!=0) 1155 forSort=1.0; 1156 // Use smallest cost if will fit 1157 if (willFit && hasSlack && 1158 value == 0.0 && columnUpper[iColumn]) { 1137 1159 if (hasSlack) { 1138 if (cost> =0.0) {1160 if (cost>0.0) { 1139 1161 forSort = 2.0e30; 1162 } else if (cost==0.0) { 1163 if (!isSlack) 1164 forSort = 1.0e29; 1165 else 1166 forSort = 1.0e28; 1140 1167 } else { 1141 1168 forSort = cost/forSort; … … 1163 1190 j < columnStart[iColumn] + columnLength[iColumn]; j++) { 1164 1191 int iRow = row[j]; 1165 if ( rhs[iRow]<0.0&&rowActivity[iRow]) {1192 if (sos[iRow]&&rowActivity[iRow]) { 1166 1193 possible = false; 1167 } else if (rhs[iRow]>=0.0){1194 } else { 1168 1195 double gap = rhs[iRow]  rowActivity[iRow]+1.0e8; 1169 1196 if (gap<element[j]) … … 1183 1210 } 1184 1211 } 1212 delete [] sos; 1185 1213 if (newSolutionValue < solutionValue) { 1186 1214 // check feasible
Note: See TracChangeset
for help on using the changeset viewer.