 Timestamp:
 Jun 10, 2008 11:07:57 PM (12 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

branches/dynamicbranching/dynamicbranching.cpp
r975 r976 532 532 533 533 #include <vector> 534 #define FUNNY_BRANCHING 1534 // #define FUNNY_BRANCHING 1 535 535 536 536 // Must code up by hand … … 700 700 if (chosen_<0) { 701 701 chosen_=last_; 702 #if FUNNY_BRANCHING703 702 while (nodes_[chosen_].descendants_==2) { 704 703 chosen_ = nodes_[chosen_].previous_; 705 704 assert (chosen_>=0); 706 705 } 707 #endif708 706 } 709 707 return chosen_; … … 1195 1193 did_reduced_cost_fixing_for_child = true; 1196 1194 } 1197 if (model.isAbandoned()) { 1198 // THINK: What the heck should we do??? 1199 abort(); 1195 } 1196 if (model.isAbandoned()) { 1197 // THINK: What the heck should we do??? 1198 abort(); 1199 } 1200 if (model.isIterationLimitReached()) { 1201 // maximum iterations  exit 1202 std::cout<<"Exiting on maximum iterations\n"; 1203 break; 1204 } 1205 1206 while (node.canSwitchParentWithGrandparent(which, model, 1207 originalLower, 1208 originalUpper, 1209 branchingTree)) { 1210 branchingTree.moveNodeUp(which, model, node); 1211 } 1212 if ((numberNodes%1000)==0) 1213 printf("%d nodes, tree size %d\n", 1214 numberNodes,branchingTree.size()); 1215 if (CoinCpuTime()time1>3600.0) { 1216 printf("stopping after 3600 seconds\n"); 1217 exit(77); 1218 } 1219 DBNodeSimple newNode(model,numberIntegers,which,ws); 1220 // something extra may have been fixed by strong branching 1221 // if so go round again 1222 while (newNode.variable_==numberIntegers) { 1223 model.resolve(); 1224 newNode = DBNodeSimple(model,numberIntegers,which,model.getWarmStart()); 1225 newNode.strong_branching_fixed_vars_ = true; 1226 } 1227 newNode.reduced_cost_fixed_vars_ = did_reduced_cost_fixing_for_child; 1228 if (newNode.objectiveValue_<1.0e100) { 1229 newNode.parent_ = kNode; 1230 // push on stack 1231 branchingTree.push_back(newNode); 1232 if(branchingTree.nodes_[kNode].child_down_ < 0) 1233 branchingTree.nodes_[kNode].child_down_ = branchingTree.last_; 1234 else 1235 branchingTree.nodes_[kNode].child_up_ = branchingTree.last_; 1236 if (newNode.variable_>=0) { 1237 assert (fabs(newNode.value_floor(newNode.value_+0.5))>1.0e6); 1200 1238 } 1201 if (model.isIterationLimitReached()) { 1202 // maximum iterations  exit 1203 std::cout<<"Exiting on maximum iterations\n"; 1204 break; 1239 #if 0 1240 else { 1241 // integer solution  save 1242 bestNode = node; 1243 // set cutoff (hard coded tolerance) 1244 model.setDblParam(OsiDualObjectiveLimit,(bestNode.objectiveValue_1.0e5)*direction); 1245 std::cout<<"Integer solution of " 1246 <<bestNode.objectiveValue_ 1247 <<" found after "<<numberIterations 1248 <<" iterations and "<<numberNodes<<" nodes" 1249 <<std::endl; 1205 1250 } 1206 1207 while (node.canSwitchParentWithGrandparent(which, model,1208 originalLower,1209 originalUpper,1210 branchingTree)) {1211 branchingTree.moveNodeUp(which, model, node);1212 }1213 if ((numberNodes%1000)==0)1214 printf("%d nodes, tree size %d\n",1215 numberNodes,branchingTree.size());1216 if (CoinCpuTime()time1>3600.0) {1217 printf("stopping after 3600 seconds\n");1218 exit(77);1219 }1220 DBNodeSimple newNode(model,numberIntegers,which,ws);1221 // something extra may have been fixed by strong branching1222 // if so go round again1223 while (newNode.variable_==numberIntegers) {1224 model.resolve();1225 newNode = DBNodeSimple(model,numberIntegers,which,model.getWarmStart());1226 newNode.strong_branching_fixed_vars_ = true;1227 }1228 newNode.reduced_cost_fixed_vars_ = did_reduced_cost_fixing_for_child;1229 if (newNode.objectiveValue_<1.0e100) {1230 newNode.parent_ = kNode;1231 // push on stack1232 branchingTree.push_back(newNode);1233 if(branchingTree.nodes_[kNode].child_down_ < 0)1234 branchingTree.nodes_[kNode].child_down_ = branchingTree.last_;1235 else1236 branchingTree.nodes_[kNode].child_up_ = branchingTree.last_;1237 if (newNode.variable_>=0) {1238 assert (fabs(newNode.value_floor(newNode.value_+0.5))>1.0e6);1239 }1240 #if 01241 else {1242 // integer solution  save1243 bestNode = node;1244 // set cutoff (hard coded tolerance)1245 model.setDblParam(OsiDualObjectiveLimit,(bestNode.objectiveValue_1.0e5)*direction);1246 std::cout<<"Integer solution of "1247 <<bestNode.objectiveValue_1248 <<" found after "<<numberIterations1249 <<" iterations and "<<numberNodes<<" nodes"1250 <<std::endl;1251 }1252 1251 #endif 1253 }1254 1252 } 1255 1253 } else { … … 1313 1311 int main(int argc, char* argv[]) 1314 1312 { 1313 OsiClpSolverInterface model; 1314 model.readMps(argv[1]); 1315 branchAndBound(model); 1315 1316 return 0; 1316 1317 }
Note: See TracChangeset
for help on using the changeset viewer.