Changeset 2386
 Timestamp:
 Jan 6, 2019 6:03:50 PM (13 months ago)
 Location:
 trunk/Clp/src/OsiClp
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Clp/src/OsiClp/OsiClpSolverInterface.cpp
r2370 r2386 10 10 extern int osi_dual; 11 11 extern int osi_hot; 12 #endif 12 #endif 13 13 #include "CoinTime.hpp" 14 14 #include "CoinHelperFunctions.hpp" … … 38 38 //#define PRINT_TIME 39 39 #ifdef PRINT_TIME 40 static double totalTime =0.0;40 static double totalTime = 0.0; 41 41 #endif 42 42 //#define SAVE_MODEL 1 43 43 #ifdef SAVE_MODEL 44 static int resolveTry =0;45 static int loResolveTry =0;46 static int hiResolveTry =9999999;44 static int resolveTry = 0; 45 static int loResolveTry = 0; 46 static int hiResolveTry = 9999999; 47 47 #endif 48 48 //############################################################################# … … 54 54 #ifdef KEEP_SMALL 55 55 if (smallModel_) { 56 delete 56 delete[] spareArrays_; 57 57 spareArrays_ = NULL; 58 58 delete smallModel_; 59 smallModel_ =NULL;60 } 61 #endif 62 if ((specialOptions_ &2097152)!=0(specialOptions_&4194304)!=0) {59 smallModel_ = NULL; 60 } 61 #endif 62 if ((specialOptions_ & 2097152) != 0  (specialOptions_ & 4194304) != 0) { 63 63 bool takeHint; 64 64 OsiHintStrength strength; 65 65 int algorithm = 0; 66 getHintParam(OsiDoDualInInitial, takeHint,strength);67 if (strength !=OsiHintIgnore)66 getHintParam(OsiDoDualInInitial, takeHint, strength); 67 if (strength != OsiHintIgnore) 68 68 algorithm = takeHint ? 1 : 1; 69 if (algorithm >0(specialOptions_&4194304)!=0) {69 if (algorithm > 0  (specialOptions_ & 4194304) != 0) { 70 70 // Gub 71 resolveGub((9 *modelPtr_>numberRows())/10);71 resolveGub((9 * modelPtr_>numberRows()) / 10); 72 72 return; 73 73 } 74 74 } 75 75 bool deleteSolver; 76 ClpSimplex * 76 ClpSimplex *solver; 77 77 #ifdef PRINT_TIME 78 78 double time1 = CoinCpuTime(); 79 79 #endif 80 80 int userFactorizationFrequency = modelPtr_>factorization()>maximumPivots(); 81 int totalIterations =0;82 bool abortSearch =false;83 ClpObjective * savedObjective=NULL;84 double savedDualLimit =modelPtr_>dblParam_[ClpDualObjectiveLimit];81 int totalIterations = 0; 82 bool abortSearch = false; 83 ClpObjective *savedObjective = NULL; 84 double savedDualLimit = modelPtr_>dblParam_[ClpDualObjectiveLimit]; 85 85 if (fakeObjective_) { 86 86 // Clear (no objective, 01 and in B&B) 87 modelPtr_>setMoreSpecialOptions(modelPtr_>moreSpecialOptions() &(~128));87 modelPtr_>setMoreSpecialOptions(modelPtr_>moreSpecialOptions() & (~128)); 88 88 // See if all with costs fixed 89 89 int numberColumns = modelPtr_>numberColumns_; 90 const double * 91 const double * 92 const double * 90 const double *obj = modelPtr_>objective(); 91 const double *lower = modelPtr_>columnLower(); 92 const double *upper = modelPtr_>columnUpper(); 93 93 int i; 94 for (i =0;i<numberColumns;i++) {94 for (i = 0; i < numberColumns; i++) { 95 95 double objValue = obj[i]; 96 96 if (objValue) { 97 if (lower[i]!=upper[i])98 99 } 100 } 101 if (i ==numberColumns) {97 if (lower[i] != upper[i]) 98 break; 99 } 100 } 101 if (i == numberColumns) { 102 102 // Check (Clp fast dual) 103 if ((specialOptions_ &524288)==0) {104 105 savedObjective=modelPtr_>objective_;106 modelPtr_>objective_=fakeObjective_;107 modelPtr_>dblParam_[ClpDualObjectiveLimit]=COIN_DBL_MAX;103 if ((specialOptions_ & 524288) == 0) { 104 // Set fake 105 savedObjective = modelPtr_>objective_; 106 modelPtr_>objective_ = fakeObjective_; 107 modelPtr_>dblParam_[ClpDualObjectiveLimit] = COIN_DBL_MAX; 108 108 } else { 109 110 modelPtr_>setMoreSpecialOptions(modelPtr_>moreSpecialOptions()128);109 // Set (no objective, 01 and in B&B) 110 modelPtr_>setMoreSpecialOptions(modelPtr_>moreSpecialOptions()  128); 111 111 } 112 112 } 113 113 } 114 114 // Check (in branch and bound) 115 if ((specialOptions_ &1024)==0) {115 if ((specialOptions_ & 1024) == 0) { 116 116 solver = new ClpSimplex(true); 117 deleteSolver =true;117 deleteSolver = true; 118 118 solver>borrowModel(*modelPtr_); 119 119 // See if user set factorization frequency … … 122 122 } else { 123 123 solver = modelPtr_; 124 deleteSolver =false;124 deleteSolver = false; 125 125 } 126 126 // Treat as if user simplex not enabled 127 int saveSolveType =solver>solveType();128 bool doingPrimal = solver>algorithm() >0;129 if (saveSolveType ==2) {127 int saveSolveType = solver>solveType(); 128 bool doingPrimal = solver>algorithm() > 0; 129 if (saveSolveType == 2) { 130 130 disableSimplexInterface(); 131 131 solver>setSolveType(1); 132 132 } 133 133 int saveOptions = solver>specialOptions(); 134 solver>setSpecialOptions(saveOptions 6432768); // go as far as possible134 solver>setSpecialOptions(saveOptions  64  32768); // go as far as possible 135 135 // get original log levels 136 int saveMessageLevel =modelPtr_>logLevel();137 int messageLevel =messageHandler()>logLevel();136 int saveMessageLevel = modelPtr_>logLevel(); 137 int messageLevel = messageHandler()>logLevel(); 138 138 int saveMessageLevel2 = messageLevel; 139 139 // Set message handler … … 146 146 OsiHintStrength strength; 147 147 // Switch off printing if asked to 148 bool gotHint = (getHintParam(OsiDoReducePrint, takeHint,strength));149 assert 150 if (strength !=OsiHintIgnore&&takeHint) {151 if (messageLevel >0)148 bool gotHint = (getHintParam(OsiDoReducePrint, takeHint, strength)); 149 assert(gotHint); 150 if (strength != OsiHintIgnore && takeHint) { 151 if (messageLevel > 0) 152 152 messageLevel; 153 153 } 154 if (messageLevel <saveMessageLevel)154 if (messageLevel < saveMessageLevel) 155 155 solver>messageHandler()>setLogLevel(messageLevel); 156 156 // Allow for specialOptions_==1+8 forcing saving factorization 157 int startFinishOptions =0;158 if ((specialOptions_ &9)==(1+8)) {159 startFinishOptions = 1+2+4; // allow reuse of factorization160 } 161 bool defaultHints =true;157 int startFinishOptions = 0; 158 if ((specialOptions_ & 9) == (1 + 8)) { 159 startFinishOptions = 1 + 2 + 4; // allow reuse of factorization 160 } 161 bool defaultHints = true; 162 162 { 163 163 int hint; 164 for (hint=OsiDoPresolveInInitial;hint<OsiLastHintParam;hint++) { 165 if (hint!=OsiDoReducePrint&& 166 hint!=OsiDoInBranchAndCut) { 164 for (hint = OsiDoPresolveInInitial; hint < OsiLastHintParam; hint++) { 165 if (hint != OsiDoReducePrint && hint != OsiDoInBranchAndCut) { 167 166 bool yesNo; 168 167 OsiHintStrength strength; 169 getHintParam(static_cast< OsiHintParam> (hint),yesNo,strength);168 getHintParam(static_cast< OsiHintParam >(hint), yesNo, strength); 170 169 if (yesNo) { 171 defaultHints =false;170 defaultHints = false; 172 171 break; 173 172 } 174 173 if (strength != OsiHintIgnore) { 175 defaultHints =false;174 defaultHints = false; 176 175 break; 177 176 } … … 179 178 } 180 179 } 181 ClpPresolve * 180 ClpPresolve *pinfo = NULL; 182 181 /* 183 182 If basis then do primal (as user could do dual with resolve) 184 183 If not then see if dual feasible (and allow for gubs etc?) 185 184 */ 186 bool doPrimal = (basis_.numberBasicStructurals() >0);187 setBasis(basis_, solver);188 bool inCbcOrOther = (modelPtr_>specialOptions() &0x03000000)!=0;189 if ((!defaultHints doPrimal)&&!solveOptions_.getSpecialOption(6)) {185 bool doPrimal = (basis_.numberBasicStructurals() > 0); 186 setBasis(basis_, solver); 187 bool inCbcOrOther = (modelPtr_>specialOptions() & 0x03000000) != 0; 188 if ((!defaultHints  doPrimal) && !solveOptions_.getSpecialOption(6)) { 190 189 // scaling 191 190 // save initial state 192 const double * 193 if (modelPtr_>solveType() ==1) {194 gotHint = (getHintParam(OsiDoScale, takeHint,strength));195 assert 196 if (strength ==OsiHintIgnoretakeHint) {191 const double *rowScale1 = solver>rowScale(); 192 if (modelPtr_>solveType() == 1) { 193 gotHint = (getHintParam(OsiDoScale, takeHint, strength)); 194 assert(gotHint); 195 if (strength == OsiHintIgnore  takeHint) { 197 196 if (!solver>scalingFlag()) 198 197 solver>scaling(3); … … 205 204 //solver>setDualBound(1.0e6); 206 205 //solver>setDualTolerance(1.0e7); 207 206 208 207 //ClpDualRowSteepest steep; 209 208 //solver>setDualRowPivotAlgorithm(steep); … … 211 210 //ClpPrimalColumnSteepest steepP; 212 211 //solver>setPrimalColumnPivotAlgorithm(steepP); 213 212 214 213 // sort out hints; 215 214 // algorithm 0 whatever, 1 force dual, +1 force primal 216 int algorithm = 0; 217 gotHint = (getHintParam(OsiDoDualInInitial, takeHint,strength));218 assert 219 if (strength !=OsiHintIgnore)215 int algorithm = 0; 216 gotHint = (getHintParam(OsiDoDualInInitial, takeHint, strength)); 217 assert(gotHint); 218 if (strength != OsiHintIgnore) 220 219 algorithm = takeHint ? 1 : 1; 221 220 // crash 0 do lightweight if all slack, 1 do, 1 don't 222 int doCrash =0;223 gotHint = (getHintParam(OsiDoCrash, takeHint,strength));224 assert 225 if (strength !=OsiHintIgnore)221 int doCrash = 0; 222 gotHint = (getHintParam(OsiDoCrash, takeHint, strength)); 223 assert(gotHint); 224 if (strength != OsiHintIgnore) 226 225 doCrash = takeHint ? 1 : 1; 227 226 // doPrimal set true if any structurals in basis so switch off crash 228 227 if (doPrimal) 229 228 doCrash = 1; 230 229 231 230 // presolve 232 gotHint = (getHintParam(OsiDoPresolveInInitial, takeHint,strength));233 assert 234 if (strength !=OsiHintIgnore&&takeHint) {231 gotHint = (getHintParam(OsiDoPresolveInInitial, takeHint, strength)); 232 assert(gotHint); 233 if (strength != OsiHintIgnore && takeHint) { 235 234 pinfo = new ClpPresolve(); 236 ClpSimplex * model2 = pinfo>presolvedModel(*solver,1.0e8);235 ClpSimplex *model2 = pinfo>presolvedModel(*solver, 1.0e8); 237 236 if (!model2) { 238 237 // problem found to be infeasible  whats best? 239 238 model2 = solver; 240 241 239 delete pinfo; 240 pinfo = NULL; 242 241 } else { 243 244 } 245 242 model2>setSpecialOptions(solver>specialOptions()); 243 } 244 246 245 // change from 200 (unless changed) 247 if (modelPtr_>factorization()>maximumPivots() ==200)248 model2>factorization()>maximumPivots(100 +model2>numberRows()/50);246 if (modelPtr_>factorization()>maximumPivots() == 200) 247 model2>factorization()>maximumPivots(100 + model2>numberRows() / 50); 249 248 else 250 249 model2>factorization()>maximumPivots(userFactorizationFrequency); 251 250 int savePerturbation = model2>perturbation(); 252 if (savePerturbation ==100)251 if (savePerturbation == 100) 253 252 model2>setPerturbation(50); 254 253 if (!doPrimal) { … … 257 256 model2>tightenPrimalBounds(); 258 257 // look further 259 bool crashResult =false;260 if (doCrash >0)261 crashResult = (solver>crash(1000.0,1)>0);262 else if (doCrash ==0&&algorithm>0)263 crashResult = (solver>crash(1000.0,1)>0);264 doPrimal =crashResult;265 } 266 if (algorithm <0)267 doPrimal =false;268 else if (algorithm >0)269 doPrimal =true;258 bool crashResult = false; 259 if (doCrash > 0) 260 crashResult = (solver>crash(1000.0, 1) > 0); 261 else if (doCrash == 0 && algorithm > 0) 262 crashResult = (solver>crash(1000.0, 1) > 0); 263 doPrimal = crashResult; 264 } 265 if (algorithm < 0) 266 doPrimal = false; 267 else if (algorithm > 0) 268 doPrimal = true; 270 269 if (!doPrimal) { 271 270 //if (numberInfeasibilities) … … 274 273 // up dual bound for safety 275 274 //model2>setDualBound(1.0e11); 276 277 278 279 280 281 275 disasterHandler_>setOsiModel(this); 276 if (inCbcOrOther) { 277 disasterHandler_>setSimplex(model2); 278 disasterHandler_>setWhereFrom(4); 279 model2>setDisasterHandler(disasterHandler_); 280 } 282 281 model2>dual(0); 283 284 285 if(disasterHandler_>inTrouble()) {282 totalIterations += model2>numberIterations(); 283 if (inCbcOrOther) { 284 if (disasterHandler_>inTrouble()) { 286 285 #ifdef COIN_DEVELOP 287 288 #endif 289 290 // We want to abort 291 abortSearch=true;292 293 294 295 296 297 298 286 printf("dual trouble a\n"); 287 #endif 288 if (disasterHandler_>typeOfDisaster()) { 289 // We want to abort 290 abortSearch = true; 291 goto disaster; 292 } 293 // try just going back in 294 disasterHandler_>setPhase(1); 295 model2>dual(); 296 totalIterations += model2>numberIterations(); 297 if (disasterHandler_>inTrouble()) { 299 298 #ifdef COIN_DEVELOP 300 301 #endif 302 303 // We want to abort 304 abortSearch=true;305 306 307 308 309 setBasis(basis_,model2);310 311 312 313 if(disasterHandler_>inTrouble()) {299 printf("dual trouble b\n"); 300 #endif 301 if (disasterHandler_>typeOfDisaster()) { 302 // We want to abort 303 abortSearch = true; 304 goto disaster; 305 } 306 // try primal with original basis 307 disasterHandler_>setPhase(2); 308 setBasis(basis_, model2); 309 model2>primal(); 310 totalIterations += model2>numberIterations(); 311 } 312 if (disasterHandler_>inTrouble()) { 314 313 #ifdef COIN_DEVELOP 315 316 #endif 317 318 // We want to abort 319 abortSearch=true;320 321 322 323 324 325 326 327 314 printf("disaster  treat as infeasible\n"); 315 #endif 316 if (disasterHandler_>typeOfDisaster()) { 317 // We want to abort 318 abortSearch = true; 319 goto disaster; 320 } 321 model2>setProblemStatus(1); 322 } 323 } 324 // reset 325 model2>setDisasterHandler(NULL); 326 } 328 327 // check if clp thought it was in a loop 329 if (model2>status() ==3&&!model2>hitMaximumIterations()) {328 if (model2>status() == 3 && !model2>hitMaximumIterations()) { 330 329 // switch algorithm 331 332 333 334 335 336 330 disasterHandler_>setOsiModel(this); 331 if (inCbcOrOther) { 332 disasterHandler_>setSimplex(model2); 333 disasterHandler_>setWhereFrom(6); 334 model2>setDisasterHandler(disasterHandler_); 335 } 337 336 model2>primal(); 338 339 340 if(disasterHandler_>inTrouble()) {337 totalIterations += model2>numberIterations(); 338 if (inCbcOrOther) { 339 if (disasterHandler_>inTrouble()) { 341 340 #ifdef COIN_DEVELOP 342 343 #endif 344 345 // We want to abort 346 abortSearch=true;347 348 349 350 351 352 353 341 printf("primal trouble a\n"); 342 #endif 343 if (disasterHandler_>typeOfDisaster()) { 344 // We want to abort 345 abortSearch = true; 346 goto disaster; 347 } 348 // try just going back in (but with dual) 349 disasterHandler_>setPhase(1); 350 model2>dual(); 351 totalIterations += model2>numberIterations(); 352 if (disasterHandler_>inTrouble()) { 354 353 #ifdef COIN_DEVELOP 355 356 #endif 357 358 // We want to abort 359 abortSearch=true;360 361 362 363 364 setBasis(basis_,model2);365 366 367 368 if(disasterHandler_>inTrouble()) {354 printf("primal trouble b\n"); 355 #endif 356 if (disasterHandler_>typeOfDisaster()) { 357 // We want to abort 358 abortSearch = true; 359 goto disaster; 360 } 361 // try primal with original basis 362 disasterHandler_>setPhase(2); 363 setBasis(basis_, model2); 364 model2>dual(); 365 totalIterations += model2>numberIterations(); 366 } 367 if (disasterHandler_>inTrouble()) { 369 368 #ifdef COIN_DEVELOP 370 371 #endif 372 373 // We want to abort 374 abortSearch=true;375 376 377 378 379 380 381 382 369 printf("disaster  treat as infeasible\n"); 370 #endif 371 if (disasterHandler_>typeOfDisaster()) { 372 // We want to abort 373 abortSearch = true; 374 goto disaster; 375 } 376 model2>setProblemStatus(1); 377 } 378 } 379 // reset 380 model2>setDisasterHandler(NULL); 381 } 383 382 } 384 383 } else { 385 384 // up infeasibility cost for safety 386 385 //model2>setInfeasibilityCost(1.0e10); 387 388 389 390 391 392 386 disasterHandler_>setOsiModel(this); 387 if (inCbcOrOther) { 388 disasterHandler_>setSimplex(model2); 389 disasterHandler_>setWhereFrom(6); 390 model2>setDisasterHandler(disasterHandler_); 391 } 393 392 model2>primal(1); 394 395 396 if(disasterHandler_>inTrouble()) {393 totalIterations += model2>numberIterations(); 394 if (inCbcOrOther) { 395 if (disasterHandler_>inTrouble()) { 397 396 #ifdef COIN_DEVELOP 398 399 #endif 400 401 // We want to abort 402 abortSearch=true;403 404 405 406 407 408 409 397 printf("primal trouble a\n"); 398 #endif 399 if (disasterHandler_>typeOfDisaster()) { 400 // We want to abort 401 abortSearch = true; 402 goto disaster; 403 } 404 // try just going back in (but with dual) 405 disasterHandler_>setPhase(1); 406 model2>dual(); 407 totalIterations += model2>numberIterations(); 408 if (disasterHandler_>inTrouble()) { 410 409 #ifdef COIN_DEVELOP 411 412 #endif 413 414 // We want to abort 415 abortSearch=true;416 417 418 419 420 setBasis(basis_,model2);421 422 423 424 if(disasterHandler_>inTrouble()) {410 printf("primal trouble b\n"); 411 #endif 412 if (disasterHandler_>typeOfDisaster()) { 413 // We want to abort 414 abortSearch = true; 415 goto disaster; 416 } 417 // try primal with original basis 418 disasterHandler_>setPhase(2); 419 setBasis(basis_, model2); 420 model2>dual(); 421 totalIterations += model2>numberIterations(); 422 } 423 if (disasterHandler_>inTrouble()) { 425 424 #ifdef COIN_DEVELOP 426 427 #endif 428 429 // We want to abort 430 abortSearch=true;431 432 433 434 435 436 437 438 425 printf("disaster  treat as infeasible\n"); 426 #endif 427 if (disasterHandler_>typeOfDisaster()) { 428 // We want to abort 429 abortSearch = true; 430 goto disaster; 431 } 432 model2>setProblemStatus(1); 433 } 434 } 435 // reset 436 model2>setDisasterHandler(NULL); 437 } 439 438 // check if clp thought it was in a loop 440 if (model2>status() ==3&&!model2>hitMaximumIterations()) {439 if (model2>status() == 3 && !model2>hitMaximumIterations()) { 441 440 // switch algorithm 442 443 444 445 446 447 448 449 450 451 if(disasterHandler_>inTrouble()) {441 disasterHandler_>setOsiModel(this); 442 if (inCbcOrOther) { 443 disasterHandler_>setSimplex(model2); 444 disasterHandler_>setWhereFrom(4); 445 model2>setDisasterHandler(disasterHandler_); 446 } 447 model2>dual(0); 448 totalIterations += model2>numberIterations(); 449 if (inCbcOrOther) { 450 if (disasterHandler_>inTrouble()) { 452 451 #ifdef COIN_DEVELOP 453 454 #endif 455 456 // We want to abort 457 abortSearch=true;458 459 460 461 462 463 464 452 printf("dual trouble a\n"); 453 #endif 454 if (disasterHandler_>typeOfDisaster()) { 455 // We want to abort 456 abortSearch = true; 457 goto disaster; 458 } 459 // try just going back in 460 disasterHandler_>setPhase(1); 461 model2>dual(); 462 totalIterations += model2>numberIterations(); 463 if (disasterHandler_>inTrouble()) { 465 464 #ifdef COIN_DEVELOP 466 467 #endif 468 469 // We want to abort 470 abortSearch=true;471 472 473 474 475 setBasis(basis_,model2);476 477 478 479 if(disasterHandler_>inTrouble()) {465 printf("dual trouble b\n"); 466 #endif 467 if (disasterHandler_>typeOfDisaster()) { 468 // We want to abort 469 abortSearch = true; 470 goto disaster; 471 } 472 // try primal with original basis 473 disasterHandler_>setPhase(2); 474 setBasis(basis_, model2); 475 model2>primal(); 476 totalIterations += model2>numberIterations(); 477 } 478 if (disasterHandler_>inTrouble()) { 480 479 #ifdef COIN_DEVELOP 481 482 #endif 483 484 // We want to abort 485 abortSearch=true;486 487 488 489 490 491 492 493 480 printf("disaster  treat as infeasible\n"); 481 #endif 482 if (disasterHandler_>typeOfDisaster()) { 483 // We want to abort 484 abortSearch = true; 485 goto disaster; 486 } 487 model2>setProblemStatus(1); 488 } 489 } 490 // reset 491 model2>setDisasterHandler(NULL); 492 } 494 493 } 495 494 } 496 495 model2>setPerturbation(savePerturbation); 497 if (model2 !=solver) {496 if (model2 != solver) { 498 497 int presolvedStatus = model2>status(); 499 498 pinfo>postsolve(true); 500 501 502 499 delete pinfo; 500 pinfo = NULL; 501 503 502 delete model2; 504 int oldStatus=solver>status();505 506 if (solver>logLevel()==63) // for gcc 4.6 bug507 printf("pstat %d stat %d\n",presolvedStatus,oldStatus);503 int oldStatus = solver>status(); 504 solver>setProblemStatus(presolvedStatus); 505 if (solver>logLevel() == 63) // for gcc 4.6 bug 506 printf("pstat %d stat %d\n", presolvedStatus, oldStatus); 508 507 //printf("Resolving from postsolved model\n"); 509 508 // later try without (1) and check duals before solve 510 if (presolvedStatus!=3511 &&(presolvedStatusoldStatus==1)) {512 if (!inCbcOrOtherpresolvedStatus!=1) {513 514 515 516 517 518 519 520 521 522 if(disasterHandler_>inTrouble()) {509 if (presolvedStatus != 3 510 && (presolvedStatus  oldStatus == 1)) { 511 if (!inCbcOrOther  presolvedStatus != 1) { 512 disasterHandler_>setOsiModel(this); 513 if (inCbcOrOther) { 514 disasterHandler_>setSimplex(solver); // as "borrowed" 515 disasterHandler_>setWhereFrom(6); 516 solver>setDisasterHandler(disasterHandler_); 517 } 518 solver>primal(1); 519 totalIterations += solver>numberIterations(); 520 if (inCbcOrOther) { 521 if (disasterHandler_>inTrouble()) { 523 522 #ifdef COIN_DEVELOP 524 525 #endif 526 527 // We want to abort 528 abortSearch=true;529 530 531 532 533 534 535 523 printf("primal trouble a\n"); 524 #endif 525 if (disasterHandler_>typeOfDisaster()) { 526 // We want to abort 527 abortSearch = true; 528 goto disaster; 529 } 530 // try just going back in (but with dual) 531 disasterHandler_>setPhase(1); 532 solver>dual(); 533 totalIterations += solver>numberIterations(); 534 if (disasterHandler_>inTrouble()) { 536 535 #ifdef COIN_DEVELOP 537 538 #endif 539 540 // We want to abort 541 abortSearch=true;542 543 544 545 546 setBasis(basis_,solver);547 548 549 550 if(disasterHandler_>inTrouble()) {536 printf("primal trouble b\n"); 537 #endif 538 if (disasterHandler_>typeOfDisaster()) { 539 // We want to abort 540 abortSearch = true; 541 goto disaster; 542 } 543 // try primal with original basis 544 disasterHandler_>setPhase(2); 545 setBasis(basis_, solver); 546 solver>dual(); 547 totalIterations += solver>numberIterations(); 548 } 549 if (disasterHandler_>inTrouble()) { 551 550 #ifdef COIN_DEVELOP 552 553 #endif 554 555 // We want to abort 556 abortSearch=true;557 558 559 560 561 562 563 564 565 566 567 } 568 lastAlgorithm_ =1; // primal551 printf("disaster  treat as infeasible\n"); 552 #endif 553 if (disasterHandler_>typeOfDisaster()) { 554 // We want to abort 555 abortSearch = true; 556 goto disaster; 557 } 558 solver>setProblemStatus(1); 559 } 560 } 561 // reset 562 solver>setDisasterHandler(NULL); 563 } 564 } 565 } 566 } 567 lastAlgorithm_ = 1; // primal 569 568 //if (solver>numberIterations()) 570 569 //printf("****** iterated %d\n",solver>numberIterations()); 571 570 } else { 572 571 // do we want crash 573 if (doCrash >0)574 solver>crash(1000.0, 2);575 else if (doCrash ==0)576 solver>crash(1000.0, 0);577 if (algorithm <0)578 doPrimal =false;579 else if (algorithm >0)580 doPrimal =true;572 if (doCrash > 0) 573 solver>crash(1000.0, 2); 574 else if (doCrash == 0) 575 solver>crash(1000.0, 0); 576 if (algorithm < 0) 577 doPrimal = false; 578 else if (algorithm > 0) 579 doPrimal = true; 581 580 disasterHandler_>setOsiModel(this); 582 581 disasterHandler_>setSimplex(solver); // as "borrowed" 583 bool inCbcOrOther = (modelPtr_>specialOptions() &0x03000000)!=0;584 if (!doPrimal) 585 582 bool inCbcOrOther = (modelPtr_>specialOptions() & 0x03000000) != 0; 583 if (!doPrimal) 584 disasterHandler_>setWhereFrom(4); 586 585 else 587 586 disasterHandler_>setWhereFrom(6); 588 587 if (inCbcOrOther) 589 588 solver>setDisasterHandler(disasterHandler_); 590 589 if (!doPrimal) { 591 590 //printf("doing dual\n"); 592 591 solver>dual(0); 593 594 595 if(disasterHandler_>inTrouble()) {592 totalIterations += solver>numberIterations(); 593 if (inCbcOrOther) { 594 if (disasterHandler_>inTrouble()) { 596 595 #ifdef COIN_DEVELOP 597 598 #endif 599 600 // We want to abort 601 abortSearch=true;602 603 604 605 606 607 608 596 printf("dual trouble a\n"); 597 #endif 598 if (disasterHandler_>typeOfDisaster()) { 599 // We want to abort 600 abortSearch = true; 601 goto disaster; 602 } 603 // try just going back in 604 disasterHandler_>setPhase(1); 605 solver>dual(); 606 totalIterations += solver>numberIterations(); 607 if (disasterHandler_>inTrouble()) { 609 608 #ifdef COIN_DEVELOP 610 611 #endif 612 613 // We want to abort 614 abortSearch=true;615 616 617 618 619 setBasis(basis_,solver);620 621 622 623 if(disasterHandler_>inTrouble()) {609 printf("dual trouble b\n"); 610 #endif 611 if (disasterHandler_>typeOfDisaster()) { 612 // We want to abort 613 abortSearch = true; 614 goto disaster; 615 } 616 // try primal with original basis 617 disasterHandler_>setPhase(2); 618 setBasis(basis_, solver); 619 solver>primal(); 620 totalIterations += solver>numberIterations(); 621 } 622 if (disasterHandler_>inTrouble()) { 624 623 #ifdef COIN_DEVELOP 625 626 #endif 627 628 // We want to abort 629 abortSearch=true;630 631 632 633 634 635 636 637 638 lastAlgorithm_ =2; // dual624 printf("disaster  treat as infeasible\n"); 625 #endif 626 if (disasterHandler_>typeOfDisaster()) { 627 // We want to abort 628 abortSearch = true; 629 goto disaster; 630 } 631 solver>setProblemStatus(1); 632 } 633 } 634 // reset 635 solver>setDisasterHandler(NULL); 636 } 637 lastAlgorithm_ = 2; // dual 639 638 // check if clp thought it was in a loop 640 if (solver>status() ==3&&!solver>hitMaximumIterations()) {639 if (solver>status() == 3 && !solver>hitMaximumIterations()) { 641 640 // switch algorithm 642 641 solver>primal(0); 643 644 lastAlgorithm_ =1; // primal642 totalIterations += solver>numberIterations(); 643 lastAlgorithm_ = 1; // primal 645 644 } 646 645 } else { 647 646 //printf("doing primal\n"); 648 647 solver>primal(1); 649 650 651 if(disasterHandler_>inTrouble()) {648 totalIterations += solver>numberIterations(); 649 if (inCbcOrOther) { 650 if (disasterHandler_>inTrouble()) { 652 651 #ifdef COIN_DEVELOP 653 654 #endif 655 656 // We want to abort 657 abortSearch=true;658 659 660 661 662 663 664 652 printf("primal trouble a\n"); 653 #endif 654 if (disasterHandler_>typeOfDisaster()) { 655 // We want to abort 656 abortSearch = true; 657 goto disaster; 658 } 659 // try just going back in (but with dual) 660 disasterHandler_>setPhase(1); 661 solver>dual(); 662 totalIterations += solver>numberIterations(); 663 if (disasterHandler_>inTrouble()) { 665 664 #ifdef COIN_DEVELOP 666 667 #endif 668 669 // We want to abort 670 abortSearch=true;671 672 673 674 675 setBasis(basis_,solver);676 677 678 679 if(disasterHandler_>inTrouble()) {665 printf("primal trouble b\n"); 666 #endif 667 if (disasterHandler_>typeOfDisaster()) { 668 // We want to abort 669 abortSearch = true; 670 goto disaster; 671 } 672 // try primal with original basis 673 disasterHandler_>setPhase(2); 674 setBasis(basis_, solver); 675 solver>dual(); 676 totalIterations += solver>numberIterations(); 677 } 678 if (disasterHandler_>inTrouble()) { 680 679 #ifdef COIN_DEVELOP 681 682 #endif 683 684 // We want to abort 685 abortSearch=true;686 687 688 689 690 691 692 693 694 lastAlgorithm_ =1; // primal680 printf("disaster  treat as infeasible\n"); 681 #endif 682 if (disasterHandler_>typeOfDisaster()) { 683 // We want to abort 684 abortSearch = true; 685 goto disaster; 686 } 687 solver>setProblemStatus(1); 688 } 689 } 690 // reset 691 solver>setDisasterHandler(NULL); 692 } 693 lastAlgorithm_ = 1; // primal 695 694 // check if clp thought it was in a loop 696 if (solver>status() ==3&&!solver>hitMaximumIterations()) {695 if (solver>status() == 3 && !solver>hitMaximumIterations()) { 697 696 // switch algorithm 698 697 solver>dual(0); 699 700 lastAlgorithm_ =2; // dual698 totalIterations += solver>numberIterations(); 699 lastAlgorithm_ = 2; // dual 701 700 } 702 701 } 703 702 } 704 703 // If scaled feasible but unscaled infeasible take action 705 if (!solver>status() &&cleanupScaling_) {704 if (!solver>status() && cleanupScaling_) { 706 705 solver>cleanup(cleanupScaling_); 707 706 } 708 707 basis_ = getBasis(solver); 709 708 //basis_.print(); 710 const double * 709 const double *rowScale2 = solver>rowScale(); 711 710 solver>setSpecialOptions(saveOptions); 712 if (!rowScale1 &&rowScale2) {711 if (!rowScale1 && rowScale2) { 713 712 // need to release memory 714 713 if (!solver>savedRowScale_) { 715 716 714 solver>setRowScale(NULL); 715 solver>setColumnScale(NULL); 717 716 } else { 718 solver>rowScale_=NULL;719 solver>columnScale_=NULL;717 solver>rowScale_ = NULL; 718 solver>columnScale_ = NULL; 720 719 } 721 720 } 722 721 } else { 723 722 // User doing nothing and all slack basis 724 ClpSolve options =solveOptions_;723 ClpSolve options = solveOptions_; 725 724 bool yesNo; 726 725 OsiHintStrength strength; 727 getHintParam(OsiDoInBranchAndCut, yesNo,strength);726 getHintParam(OsiDoInBranchAndCut, yesNo, strength); 728 727 if (yesNo) { 729 solver>setSpecialOptions(solver>specialOptions() 1024);728 solver>setSpecialOptions(solver>specialOptions()  1024); 730 729 } 731 730 solver>initialSolve(options); … … 733 732 lastAlgorithm_ = 2; // say dual 734 733 // If scaled feasible but unscaled infeasible take action 735 if (!solver>status() &&cleanupScaling_) {734 if (!solver>status() && cleanupScaling_) { 736 735 solver>cleanup(cleanupScaling_); 737 736 } … … 740 739 } 741 740 solver>messageHandler()>setLogLevel(saveMessageLevel); 742 741 disaster: 743 742 if (deleteSolver) { 744 743 solver>returnModel(*modelPtr_); … … 747 746 if (startFinishOptions) { 748 747 int save = modelPtr_>logLevel(); 749 if (save<2) modelPtr_>setLogLevel(0); 750 modelPtr_>dual(0,startFinishOptions); 748 if (save < 2) 749 modelPtr_>setLogLevel(0); 750 modelPtr_>dual(0, startFinishOptions); 751 751 totalIterations += modelPtr_>numberIterations(); 752 752 modelPtr_>setLogLevel(save); 753 753 } 754 if (saveSolveType ==2) {754 if (saveSolveType == 2) { 755 755 enableSimplexInterface(doingPrimal); 756 756 } 757 757 if (savedObjective) { 758 758 // fix up 759 modelPtr_>dblParam_[ClpDualObjectiveLimit] =savedDualLimit;759 modelPtr_>dblParam_[ClpDualObjectiveLimit] = savedDualLimit; 760 760 //modelPtr_>setMoreSpecialOptions(modelPtr_>moreSpecialOptions()&(~32)); 761 modelPtr_>objective_ =savedObjective;761 modelPtr_>objective_ = savedObjective; 762 762 if (!modelPtr_>problemStatus_) { 763 CoinZeroN(modelPtr_>dual_, modelPtr_>numberRows_);764 CoinZeroN(modelPtr_>reducedCost_, modelPtr_>numberColumns_);765 if (modelPtr_>dj_ &&(modelPtr_>whatsChanged_&1)!=0)766 CoinZeroN(modelPtr_>dj_,modelPtr_>numberColumns_+modelPtr_>numberRows_);763 CoinZeroN(modelPtr_>dual_, modelPtr_>numberRows_); 764 CoinZeroN(modelPtr_>reducedCost_, modelPtr_>numberColumns_); 765 if (modelPtr_>dj_ && (modelPtr_>whatsChanged_ & 1) != 0) 766 CoinZeroN(modelPtr_>dj_, modelPtr_>numberColumns_ + modelPtr_>numberRows_); 767 767 modelPtr_>computeObjectiveValue(); 768 768 } … … 770 770 modelPtr_>setNumberIterations(totalIterations); 771 771 handler_>setLogLevel(saveMessageLevel2); 772 if (modelPtr_>problemStatus_ ==3&&lastAlgorithm_==2)772 if (modelPtr_>problemStatus_ == 3 && lastAlgorithm_ == 2) 773 773 modelPtr_>computeObjectiveValue(); 774 774 // mark so we can pick up objective value quickly 775 modelPtr_>upperIn_ =0.0;775 modelPtr_>upperIn_ = 0.0; 776 776 #ifdef PRINT_TIME 777 time1 = CoinCpuTime() time1;777 time1 = CoinCpuTime()  time1; 778 778 totalTime += time1; 779 779 #endif 780 assert 781 if (lastAlgorithm_ <1lastAlgorithm_>2)782 lastAlgorithm_ =1;780 assert(!modelPtr_>disasterHandler()); 781 if (lastAlgorithm_ < 1  lastAlgorithm_ > 2) 782 lastAlgorithm_ = 1; 783 783 if (abortSearch) { 784 lastAlgorithm_ =911;784 lastAlgorithm_ = 911; 785 785 modelPtr_>setProblemStatus(4); 786 786 } … … 794 794 #endif 795 795 #ifdef PRINT_TIME 796 std::cout <<time1<<" seconds  total "<<totalTime<<std::endl;796 std::cout << time1 << " seconds  total " << totalTime << std::endl; 797 797 #endif 798 798 delete pinfo; … … 805 805 int i; 806 806 int n = getNumCols(); 807 const double *lower = getColLower() 808 const double *upper = getColUpper() 809 for (i =0;i<n;i++) {810 assert (lower[i]<1.0e12);811 assert (upper[i]>1.0e12);807 const double *lower = getColLower(); 808 const double *upper = getColUpper(); 809 for (i = 0; i < n; i++) { 810 assert(lower[i] < 1.0e12); 811 assert(upper[i] > 1.0e12); 812 812 } 813 813 n = getNumRows(); 814 lower = getRowLower() 815 upper = getRowUpper() 816 for (i =0;i<n;i++) {817 assert (lower[i]<1.0e12);818 assert (upper[i]>1.0e12);819 } 820 } 821 #endif 822 if ((stuff_.solverOptions_ &65536)!=0) {814 lower = getRowLower(); 815 upper = getRowUpper(); 816 for (i = 0; i < n; i++) { 817 assert(lower[i] < 1.0e12); 818 assert(upper[i] > 1.0e12); 819 } 820 } 821 #endif 822 if ((stuff_.solverOptions_ & 65536) != 0) { 823 823 modelPtr_>fastDual2(&stuff_); 824 824 return; 825 825 } 826 if ((specialOptions_ &2097152)!=0(specialOptions_&4194304)!=0) {826 if ((specialOptions_ & 2097152) != 0  (specialOptions_ & 4194304) != 0) { 827 827 bool takeHint; 828 828 OsiHintStrength strength; 829 829 int algorithm = 0; 830 getHintParam(OsiDoDualInResolve, takeHint,strength);831 if (strength !=OsiHintIgnore)830 getHintParam(OsiDoDualInResolve, takeHint, strength); 831 if (strength != OsiHintIgnore) 832 832 algorithm = takeHint ? 1 : 1; 833 if (algorithm >0(specialOptions_&4194304)!=0) {833 if (algorithm > 0  (specialOptions_ & 4194304) != 0) { 834 834 // Gub 835 resolveGub((9 *modelPtr_>numberRows())/10);835 resolveGub((9 * modelPtr_>numberRows()) / 10); 836 836 return; 837 837 } … … 841 841 bool takeHint; 842 842 OsiHintStrength strength; 843 bool gotHint = (getHintParam(OsiDoInBranchAndCut, takeHint,strength));844 assert 843 bool gotHint = (getHintParam(OsiDoInBranchAndCut, takeHint, strength)); 844 assert(gotHint); 845 845 // mark so we can pick up objective value quickly 846 modelPtr_>upperIn_ =0.0;847 if ((specialOptions_ &4096)!=0) {846 modelPtr_>upperIn_ = 0.0; 847 if ((specialOptions_ & 4096) != 0) { 848 848 // Quick check to see if optimal 849 849 modelPtr_>checkSolutionInternal(); 850 if (modelPtr_>problemStatus() ==0) {850 if (modelPtr_>problemStatus() == 0) { 851 851 modelPtr_>setNumberIterations(0); 852 852 return; 853 853 } 854 854 } 855 int totalIterations =0;856 bool abortSearch =false;857 ClpObjective * savedObjective=NULL;858 double savedDualLimit =modelPtr_>dblParam_[ClpDualObjectiveLimit];855 int totalIterations = 0; 856 bool abortSearch = false; 857 ClpObjective *savedObjective = NULL; 858 double savedDualLimit = modelPtr_>dblParam_[ClpDualObjectiveLimit]; 859 859 if (fakeObjective_) { 860 modelPtr_>setMoreSpecialOptions(modelPtr_>moreSpecialOptions() &(~128));860 modelPtr_>setMoreSpecialOptions(modelPtr_>moreSpecialOptions() & (~128)); 861 861 // See if all with costs fixed 862 862 int numberColumns = modelPtr_>numberColumns_; 863 const double * 864 const double * 865 const double * 863 const double *obj = modelPtr_>objective(); 864 const double *lower = modelPtr_>columnLower(); 865 const double *upper = modelPtr_>columnUpper(); 866 866 int i; 867 for (i =0;i<numberColumns;i++) {867 for (i = 0; i < numberColumns; i++) { 868 868 double objValue = obj[i]; 869 869 if (objValue) { 870 if (lower[i]!=upper[i])871 872 } 873 } 874 if (i ==numberColumns) {875 if ((specialOptions_ &524288)==0) {876 877 savedObjective=modelPtr_>objective_;878 modelPtr_>objective_=fakeObjective_;879 modelPtr_>dblParam_[ClpDualObjectiveLimit]=COIN_DBL_MAX;870 if (lower[i] != upper[i]) 871 break; 872 } 873 } 874 if (i == numberColumns) { 875 if ((specialOptions_ & 524288) == 0) { 876 // Set fake 877 savedObjective = modelPtr_>objective_; 878 modelPtr_>objective_ = fakeObjective_; 879 modelPtr_>dblParam_[ClpDualObjectiveLimit] = COIN_DBL_MAX; 880 880 } else { 881 modelPtr_>setMoreSpecialOptions(modelPtr_>moreSpecialOptions()128);881 modelPtr_>setMoreSpecialOptions(modelPtr_>moreSpecialOptions()  128); 882 882 } 883 883 } 884 884 } 885 885 // If using Clp initialSolve and primal  just do here 886 gotHint = (getHintParam(OsiDoDualInResolve, takeHint,strength));887 assert 888 if (strength !=OsiHintIgnore&&!takeHint&&solveOptions_.getSpecialOption(6)) {889 ClpSolve options =solveOptions_;886 gotHint = (getHintParam(OsiDoDualInResolve, takeHint, strength)); 887 assert(gotHint); 888 if (strength != OsiHintIgnore && !takeHint && solveOptions_.getSpecialOption(6)) { 889 ClpSolve options = solveOptions_; 890 890 // presolve 891 getHintParam(OsiDoPresolveInResolve, takeHint,strength);892 if (strength !=OsiHintIgnore&&!takeHint)891 getHintParam(OsiDoPresolveInResolve, takeHint, strength); 892 if (strength != OsiHintIgnore && !takeHint) 893 893 options.setPresolveType(ClpSolve::presolveOff); 894 894 int saveOptions = modelPtr_>specialOptions(); 895 getHintParam(OsiDoInBranchAndCut, takeHint,strength);895 getHintParam(OsiDoInBranchAndCut, takeHint, strength); 896 896 if (takeHint) { 897 modelPtr_>setSpecialOptions(modelPtr_>specialOptions() 1024);898 } 899 setBasis(basis_, modelPtr_);897 modelPtr_>setSpecialOptions(modelPtr_>specialOptions()  1024); 898 } 899 setBasis(basis_, modelPtr_); 900 900 modelPtr_>initialSolve(options); 901 901 lastAlgorithm_ = 1; // say primal 902 902 // If scaled feasible but unscaled infeasible take action 903 if (!modelPtr_>status() &&cleanupScaling_) {903 if (!modelPtr_>status() && cleanupScaling_) { 904 904 modelPtr_>cleanup(cleanupScaling_); 905 905 } … … 907 907 basis_ = getBasis(modelPtr_); 908 908 } 909 int saveSolveType =modelPtr_>solveType();910 bool doingPrimal = modelPtr_>algorithm() >0;911 if (saveSolveType ==2) {909 int saveSolveType = modelPtr_>solveType(); 910 bool doingPrimal = modelPtr_>algorithm() > 0; 911 if (saveSolveType == 2) { 912 912 disableSimplexInterface(); 913 913 } 914 914 int saveOptions = modelPtr_>specialOptions(); 915 int startFinishOptions =0;916 if (specialOptions_ !=0x80000000) {917 if ((specialOptions_&1)==0) {918 startFinishOptions =0;919 modelPtr_>setSpecialOptions(saveOptions (64102432768));915 int startFinishOptions = 0; 916 if (specialOptions_ != 0x80000000) { 917 if ((specialOptions_ & 1) == 0) { 918 startFinishOptions = 0; 919 modelPtr_>setSpecialOptions(saveOptions  (64  1024  32768)); 920 920 } else { 921 startFinishOptions =1+4;922 if ((specialOptions_ &8)!=0)923 startFinishOptions += 2; // allow reuse of factorization924 if ((specialOptions_&4)==0!takeHint)925 modelPtr_>setSpecialOptions(saveOptions (641285121024409632768));921 startFinishOptions = 1 + 4; 922 if ((specialOptions_ & 8) != 0) 923 startFinishOptions += 2; // allow reuse of factorization 924 if ((specialOptions_ & 4) == 0  !takeHint) 925 modelPtr_>setSpecialOptions(saveOptions  (64  128  512  1024  4096  32768)); 926 926 else 927 modelPtr_>setSpecialOptions(saveOptions (6412851210242048409632768));927 modelPtr_>setSpecialOptions(saveOptions  (64  128  512  1024  2048  4096  32768)); 928 928 } 929 929 } else { 930 modelPtr_>setSpecialOptions(saveOptions 6432768);930 modelPtr_>setSpecialOptions(saveOptions  64  32768); 931 931 } 932 932 //printf("options %d size %d\n",modelPtr_>specialOptions(),modelPtr_>numberColumns()); 933 933 //modelPtr_>setSolveType(1); 934 934 // Set message handler to have same levels etc 935 int saveMessageLevel =modelPtr_>logLevel();936 int messageLevel =messageHandler()>logLevel();935 int saveMessageLevel = modelPtr_>logLevel(); 936 int messageLevel = messageHandler()>logLevel(); 937 937 bool oldDefault; 938 CoinMessageHandler * 938 CoinMessageHandler *saveHandler = NULL; 939 939 if (!defaultHandler_) 940 saveHandler = modelPtr_>pushMessageHandler(handler_, oldDefault);940 saveHandler = modelPtr_>pushMessageHandler(handler_, oldDefault); 941 941 //printf("basis before dual\n"); 942 942 //basis_.print(); 943 setBasis(basis_, modelPtr_);943 setBasis(basis_, modelPtr_); 944 944 #ifdef SAVE_MODEL 945 945 resolveTry++; 946 946 #if SAVE_MODEL > 1 947 if (resolveTry>=loResolveTry&& 948 resolveTry<=hiResolveTry) { 947 if (resolveTry >= loResolveTry && resolveTry <= hiResolveTry) { 949 948 char fileName[20]; 950 sprintf(fileName, "save%d.mod",resolveTry);949 sprintf(fileName, "save%d.mod", resolveTry); 951 950 modelPtr_>saveModel(fileName); 952 951 } … … 955 954 // set reasonable defaults 956 955 // Switch off printing if asked to 957 gotHint = (getHintParam(OsiDoReducePrint, takeHint,strength));958 assert 959 if (strength !=OsiHintIgnore&&takeHint) {960 if (messageLevel >0)956 gotHint = (getHintParam(OsiDoReducePrint, takeHint, strength)); 957 assert(gotHint); 958 if (strength != OsiHintIgnore && takeHint) { 959 if (messageLevel > 0) 961 960 messageLevel; 962 961 } 963 if (messageLevel <modelPtr_>messageHandler()>logLevel())962 if (messageLevel < modelPtr_>messageHandler()>logLevel()) 964 963 modelPtr_>messageHandler()>setLogLevel(messageLevel); 965 964 // See if user set factorization frequency 966 965 int userFactorizationFrequency = modelPtr_>factorization()>maximumPivots(); 967 966 // scaling 968 if (modelPtr_>solveType() ==1) {969 gotHint = (getHintParam(OsiDoScale, takeHint,strength));970 assert 971 if (strength ==OsiHintIgnoretakeHint) {967 if (modelPtr_>solveType() == 1) { 968 gotHint = (getHintParam(OsiDoScale, takeHint, strength)); 969 assert(gotHint); 970 if (strength == OsiHintIgnore  takeHint) { 972 971 if (!modelPtr_>scalingFlag()) 973 972 modelPtr_>scaling(3); 974 973 } else { 975 974 modelPtr_>scaling(0); … … 981 980 // algorithm 1 force dual, +1 force primal 982 981 int algorithm = 1; 983 gotHint = (getHintParam(OsiDoDualInResolve, takeHint,strength));984 assert 985 if (strength !=OsiHintIgnore)982 gotHint = (getHintParam(OsiDoDualInResolve, takeHint, strength)); 983 assert(gotHint); 984 if (strength != OsiHintIgnore) 986 985 algorithm = takeHint ? 1 : 1; 987 986 //modelPtr_>saveModel("save.bad"); 988 987 // presolve 989 gotHint = (getHintParam(OsiDoPresolveInResolve, takeHint,strength));990 assert 991 if (strength !=OsiHintIgnore&&takeHint) {988 gotHint = (getHintParam(OsiDoPresolveInResolve, takeHint, strength)); 989 assert(gotHint); 990 if (strength != OsiHintIgnore && takeHint) { 992 991 #ifdef KEEP_SMALL 993 992 if (smallModel_) { 994 delete 993 delete[] spareArrays_; 995 994 spareArrays_ = NULL; 996 995 delete smallModel_; 997 smallModel_ =NULL;996 smallModel_ = NULL; 998 997 } 999 998 #endif 1000 999 ClpPresolve pinfo; 1001 if ((specialOptions_ &128)!=0) {1000 if ((specialOptions_ & 128) != 0) { 1002 1001 specialOptions_ &= ~128; 1003 1002 } 1004 if ((modelPtr_>specialOptions() &1024)!=0) {1003 if ((modelPtr_>specialOptions() & 1024) != 0) { 1005 1004 pinfo.setDoDual(false); 1006 1005 pinfo.setDoTripleton(false); … … 1009 1008 pinfo.setDoSingletonColumn(false); 1010 1009 } 1011 ClpSimplex * model2 = pinfo.presolvedModel(*modelPtr_,1.0e8);1010 ClpSimplex *model2 = pinfo.presolvedModel(*modelPtr_, 1.0e8); 1012 1011 if (!model2) { 1013 1012 // problem found to be infeasible  whats best? … … 1015 1014 } 1016 1015 // return number of rows 1017 int * stats = reinterpret_cast<int *>(getApplicationData());1016 int *stats = reinterpret_cast< int * >(getApplicationData()); 1018 1017 if (stats) { 1019 stats[0] =model2>numberRows();1020 stats[1] =model2>numberColumns();1018 stats[0] = model2>numberRows(); 1019 stats[1] = model2>numberColumns(); 1021 1020 } 1022 1021 //printf("rows %d > %d, columns %d > %d\n", … … 1024 1023 // modelPtr_>numberColumns(),model2>numberColumns()); 1025 1024 // change from 200 1026 if (modelPtr_>factorization()>maximumPivots() ==200)1027 model2>factorization()>maximumPivots(100 +model2>numberRows()/50);1025 if (modelPtr_>factorization()>maximumPivots() == 200) 1026 model2>factorization()>maximumPivots(100 + model2>numberRows() / 50); 1028 1027 else 1029 1028 model2>factorization()>maximumPivots(userFactorizationFrequency); 1030 if (algorithm <0) {1029 if (algorithm < 0) { 1031 1030 model2>dual(); 1032 1031 totalIterations += model2>numberIterations(); 1033 1032 // check if clp thought it was in a loop 1034 if (model2>status() ==3&&!model2>hitMaximumIterations()) {1035 1036 1037 1033 if (model2>status() == 3 && !model2>hitMaximumIterations()) { 1034 // switch algorithm 1035 model2>primal(); 1036 totalIterations += model2>numberIterations(); 1038 1037 } 1039 1038 } else { … … 1041 1040 totalIterations += model2>numberIterations(); 1042 1041 // check if clp thought it was in a loop 1043 if (model2>status() ==3&&!model2>hitMaximumIterations()) {1044 1045 1046 1047 } 1048 } 1049 if (model2 !=modelPtr_) {1050 int finalStatus =model2>status();1042 if (model2>status() == 3 && !model2>hitMaximumIterations()) { 1043 // switch algorithm 1044 model2>dual(); 1045 totalIterations += model2>numberIterations(); 1046 } 1047 } 1048 if (model2 != modelPtr_) { 1049 int finalStatus = model2>status(); 1051 1050 pinfo.postsolve(true); 1052 1051 1053 1052 delete model2; 1054 1053 // later try without (1) and check duals before solve 1055 if (finalStatus !=3&&(finalStatusmodelPtr_>status()==1)) {1054 if (finalStatus != 3 && (finalStatus  modelPtr_>status() == 1)) { 1056 1055 modelPtr_>primal(1); 1057 1058 lastAlgorithm_ =1; // primal1056 totalIterations += modelPtr_>numberIterations(); 1057 lastAlgorithm_ = 1; // primal 1059 1058 //if (modelPtr_>numberIterations()) 1060 1059 //printf("****** iterated %d\n",modelPtr_>numberIterations()); … … 1064 1063 //modelPtr_>setLogLevel(63); 1065 1064 //modelPtr_>setDualTolerance(1.0e7); 1066 if (false&&modelPtr_>scalingFlag_>0&&!modelPtr_>rowScale_&& 1067 !modelPtr_>rowCopy_&&matrixByRow_) { 1068 assert (matrixByRow_>getNumElements()==modelPtr_>clpMatrix()>getNumElements()); 1065 if (false && modelPtr_>scalingFlag_ > 0 && !modelPtr_>rowScale_ && !modelPtr_>rowCopy_ && matrixByRow_) { 1066 assert(matrixByRow_>getNumElements() == modelPtr_>clpMatrix()>getNumElements()); 1069 1067 modelPtr_>setNewRowCopy(new ClpPackedMatrix(*matrixByRow_)); 1070 1068 } 1071 if (algorithm <0) {1069 if (algorithm < 0) { 1072 1070 //writeMps("try1"); 1073 1071 int savePerturbation = modelPtr_>perturbation(); 1074 if ((specialOptions_ &2)!=0)1075 1072 if ((specialOptions_ & 2) != 0) 1073 modelPtr_>setPerturbation(100); 1076 1074 //modelPtr_>messageHandler()>setLogLevel(1); 1077 1075 //writeMpsNative("bad",NULL,NULL,2,1,1.0); 1078 1076 disasterHandler_>setOsiModel(this); 1079 bool inCbcOrOther = (modelPtr_>specialOptions() &0x03000000)!=0;1077 bool inCbcOrOther = (modelPtr_>specialOptions() & 0x03000000) != 0; 1080 1078 #if 0 1081 1079 // See how many integers fixed … … 1100 1098 } 1101 1099 #endif 1102 if((specialOptions_&1)==0 1103 (specialOptions_&2048)!=0 1104 (modelPtr_>specialOptions_&2097152)!=0/*skipCrunch*/) { 1105 disasterHandler_>setWhereFrom(0); // dual 1106 if (inCbcOrOther) 1107 modelPtr_>setDisasterHandler(disasterHandler_); 1108 bool specialScale; 1109 if ((specialOptions_&131072)!=0&&!modelPtr_>rowScale_) { 1110 modelPtr_>rowScale_ = rowScale_.array(); 1111 modelPtr_>columnScale_ = columnScale_.array(); 1112 specialScale=true; 1113 } else { 1114 specialScale=false; 1115 } 1100 if ((specialOptions_ & 1) == 0  (specialOptions_ & 2048) != 0  (modelPtr_>specialOptions_ & 2097152) != 0 /*skipCrunch*/) { 1101 disasterHandler_>setWhereFrom(0); // dual 1102 if (inCbcOrOther) 1103 modelPtr_>setDisasterHandler(disasterHandler_); 1104 bool specialScale; 1105 if ((specialOptions_ & 131072) != 0 && !modelPtr_>rowScale_) { 1106 modelPtr_>rowScale_ = rowScale_.array(); 1107 modelPtr_>columnScale_ = columnScale_.array(); 1108 specialScale = true; 1109 } else { 1110 specialScale = false; 1111 } 1116 1112 #ifdef KEEP_SMALL 1117 1118 delete[] spareArrays_;1119 1120 1121 smallModel_=NULL;1122 1113 if (smallModel_) { 1114 delete[] spareArrays_; 1115 spareArrays_ = NULL; 1116 delete smallModel_; 1117 smallModel_ = NULL; 1118 } 1123 1119 #endif 1124 1120 #ifdef CBC_STATISTICS 1125 1126 #endif 1127 modelPtr_>dual(0,startFinishOptions);1128 1129 1130 1131 1132 1121 osi_dual++; 1122 #endif 1123 modelPtr_>dual(0, startFinishOptions); 1124 totalIterations += modelPtr_>numberIterations(); 1125 if (specialScale) { 1126 modelPtr_>rowScale_ = NULL; 1127 modelPtr_>columnScale_ = NULL; 1128 } 1133 1129 } else { 1134 1130 #ifdef CBC_STATISTICS 1135 1136 #endif 1137 1138 1139 if (modelPtr_>problemStatus()==4)1140 1141 1142 inCbcOrOther=false;1131 osi_crunch++; 1132 #endif 1133 crunch(); 1134 totalIterations += modelPtr_>numberIterations(); 1135 if (modelPtr_>problemStatus() == 4) 1136 goto disaster; 1137 // should have already been fixed if problems 1138 inCbcOrOther = false; 1143 1139 } 1144 1140 if (inCbcOrOther) { 1145 if(disasterHandler_>inTrouble()) {1146 1147 // We want to abort 1148 abortSearch=true;1149 1150 1151 1152 1153 1154 1155 1156 1157 // We want to abort 1158 abortSearch=true;1159 1160 1161 1162 1163 setBasis(basis_,modelPtr_);1164 1165 1166 1167 if(disasterHandler_>inTrouble()) {1141 if (disasterHandler_>inTrouble()) { 1142 if (disasterHandler_>typeOfDisaster()) { 1143 // We want to abort 1144 abortSearch = true; 1145 goto disaster; 1146 } 1147 // try just going back in 1148 disasterHandler_>setPhase(1); 1149 modelPtr_>dual(); 1150 totalIterations += modelPtr_>numberIterations(); 1151 if (disasterHandler_>inTrouble()) { 1152 if (disasterHandler_>typeOfDisaster()) { 1153 // We want to abort 1154 abortSearch = true; 1155 goto disaster; 1156 } 1157 // try primal with original basis 1158 disasterHandler_>setPhase(2); 1159 setBasis(basis_, modelPtr_); 1160 modelPtr_>primal(); 1161 totalIterations += modelPtr_>numberIterations(); 1162 } 1163 if (disasterHandler_>inTrouble()) { 1168 1164 #ifdef COIN_DEVELOP 1169 1170 #endif 1171 1172 // We want to abort 1173 abortSearch=true;1174 1175 1176 1177 1178 1179 1180 1181 } 1182 if (modelPtr_>problemStatus() ==4) {1183 1184 1185 } 1186 if (!modelPtr_>problemStatus() &&0) {1165 printf("disaster  treat as infeasible\n"); 1166 #endif 1167 if (disasterHandler_>typeOfDisaster()) { 1168 // We want to abort 1169 abortSearch = true; 1170 goto disaster; 1171 } 1172 modelPtr_>setProblemStatus(1); 1173 } 1174 } 1175 // reset 1176 modelPtr_>setDisasterHandler(NULL); 1177 } 1178 if (modelPtr_>problemStatus() == 4) { 1179 // bad bounds? 1180 modelPtr_>setProblemStatus(1); 1181 } 1182 if (!modelPtr_>problemStatus() && 0) { 1187 1183 int numberColumns = modelPtr_>numberColumns(); 1188 const double * 1189 const double * 1190 int nBad =0;1191 for (int i =0;i<numberColumns;i++) {1192 if (columnLower[i] ==columnUpper[i]&&modelPtr_>getColumnStatus(i)==ClpSimplex::basic) {1184 const double *columnLower = modelPtr_>columnLower(); 1185 const double *columnUpper = modelPtr_>columnUpper(); 1186 int nBad = 0; 1187 for (int i = 0; i < numberColumns; i++) { 1188 if (columnLower[i] == columnUpper[i] && modelPtr_>getColumnStatus(i) == ClpSimplex::basic) { 1193 1189 nBad++; 1194 modelPtr_>setColumnStatus(i, ClpSimplex::isFixed);1190 modelPtr_>setColumnStatus(i, ClpSimplex::isFixed); 1195 1191 } 1196 1192 } 1197 1193 if (nBad) { 1198 1194 modelPtr_>primal(1); 1199 totalIterations += modelPtr_>numberIterations();1200 printf("%d fixed basic  %d iterations\n", nBad,modelPtr_>numberIterations());1195 totalIterations += modelPtr_>numberIterations(); 1196 printf("%d fixed basic  %d iterations\n", nBad, modelPtr_>numberIterations()); 1201 1197 } 1202 1198 } 1203 assert (modelPtr_>objectiveValue()<1.0e100);1199 assert(modelPtr_>objectiveValue() < 1.0e100); 1204 1200 modelPtr_>setPerturbation(savePerturbation); 1205 lastAlgorithm_ =2; // dual1201 lastAlgorithm_ = 2; // dual 1206 1202 // check if clp thought it was in a loop 1207 if (modelPtr_>status() ==3&&!modelPtr_>hitMaximumIterations()) {1208 1209 1210 1211 1212 1213 1214 1215 1216 if (modelPtr_>maximumIterations()>100000+numberIterations)1217 modelPtr_>setMaximumIterations(numberIterations + 1000 + 2*numberRows+numberColumns);1218 modelPtr_>primal(0,startFinishOptions);1219 1220 1221 lastAlgorithm_=1; // primal1222 if (modelPtr_>status() ==3&&!modelPtr_>hitMaximumIterations()) {1203 if (modelPtr_>status() == 3 && !modelPtr_>hitMaximumIterations()) { 1204 modelPtr_>setSpecialOptions(saveOptions); 1205 // switch algorithm 1206 //modelPtr_>messageHandler()>setLogLevel(63); 1207 // Allow for catastrophe 1208 int saveMax = modelPtr_>maximumIterations(); 1209 int numberIterations = modelPtr_>numberIterations(); 1210 int numberRows = modelPtr_>numberRows(); 1211 int numberColumns = modelPtr_>numberColumns(); 1212 if (modelPtr_>maximumIterations() > 100000 + numberIterations) 1213 modelPtr_>setMaximumIterations(numberIterations + 1000 + 2 * numberRows + numberColumns); 1214 modelPtr_>primal(0, startFinishOptions); 1215 totalIterations += modelPtr_>numberIterations(); 1216 modelPtr_>setMaximumIterations(saveMax); 1217 lastAlgorithm_ = 1; // primal 1218 if (modelPtr_>status() == 3 && !modelPtr_>hitMaximumIterations()) { 1223 1219 #ifdef COIN_DEVELOP 1224 1225 #endif 1226 1227 setBasis(allSlack,modelPtr_);1228 1229 1230 if (modelPtr_>status() ==3&&!modelPtr_>hitMaximumIterations()) {1231 1220 printf("in trouble  try all slack\n"); 1221 #endif 1222 CoinWarmStartBasis allSlack; 1223 setBasis(allSlack, modelPtr_); 1224 modelPtr_>dual(); 1225 totalIterations += modelPtr_>numberIterations(); 1226 if (modelPtr_>status() == 3 && !modelPtr_>hitMaximumIterations()) { 1227 if (modelPtr_>numberPrimalInfeasibilities()) { 1232 1228 #ifdef COIN_DEVELOP 1233 1234 #endif 1235 1236 1229 printf("Real real trouble  treat as infeasible\n"); 1230 #endif 1231 modelPtr_>setProblemStatus(1); 1232 } else { 1237 1233 #ifdef COIN_DEVELOP 1238 1239 #endif 1240 1241 1242 1243 1244 } 1245 assert (modelPtr_>objectiveValue()<1.0e100);1234 printf("Real real trouble  treat as optimal\n"); 1235 #endif 1236 modelPtr_>setProblemStatus(0); 1237 } 1238 } 1239 } 1240 } 1241 assert(modelPtr_>objectiveValue() < 1.0e100); 1246 1242 } else { 1247 1243 #ifdef KEEP_SMALL 1248 1244 if (smallModel_) { 1249 delete[] spareArrays_;1250 1251 1252 smallModel_=NULL;1245 delete[] spareArrays_; 1246 spareArrays_ = NULL; 1247 delete smallModel_; 1248 smallModel_ = NULL; 1253 1249 } 1254 1250 #endif … … 1256 1252 #ifdef CBC_STATISTICS 1257 1253 osi_primal++; 1258 #endif 1259 modelPtr_>primal(1, startFinishOptions);1254 #endif 1255 modelPtr_>primal(1, startFinishOptions); 1260 1256 totalIterations += modelPtr_>numberIterations(); 1261 lastAlgorithm_ =1; // primal1257 lastAlgorithm_ = 1; // primal 1262 1258 // check if clp thought it was in a loop 1263 if (modelPtr_>status() ==3&&!modelPtr_>hitMaximumIterations()) {1264 1265 1266 1267 lastAlgorithm_=2; // dual1259 if (modelPtr_>status() == 3 && !modelPtr_>hitMaximumIterations()) { 1260 // switch algorithm 1261 modelPtr_>dual(); 1262 totalIterations += modelPtr_>numberIterations(); 1263 lastAlgorithm_ = 2; // dual 1268 1264 } 1269 1265 } … … 1275 1271 } 1276 1272 basis_ = getBasis(modelPtr_); 1277 1273 disaster: 1278 1274 //printf("basis after dual\n"); 1279 1275 //basis_.print(); 1280 1276 if (!defaultHandler_) 1281 modelPtr_>popMessageHandler(saveHandler, oldDefault);1277 modelPtr_>popMessageHandler(saveHandler, oldDefault); 1282 1278 modelPtr_>messageHandler()>setLogLevel(saveMessageLevel); 1283 if (saveSolveType ==2) {1279 if (saveSolveType == 2) { 1284 1280 int saveStatus = modelPtr_>problemStatus_; 1285 1281 enableSimplexInterface(doingPrimal); 1286 modelPtr_>problemStatus_ =saveStatus;1282 modelPtr_>problemStatus_ = saveStatus; 1287 1283 } 1288 1284 #ifdef COIN_DEVELOP_x … … 1290 1286 if (doingDoneBranch) { 1291 1287 if (modelPtr_>numberIterations()) 1292 printf("***** done %d iterations after general\n", modelPtr_>numberIterations());1293 doingDoneBranch =false;1288 printf("***** done %d iterations after general\n", modelPtr_>numberIterations()); 1289 doingDoneBranch = false; 1294 1290 } 1295 1291 #endif … … 1297 1293 //modelPtr_>setSolveType(saveSolveType); 1298 1294 if (abortSearch) { 1299 lastAlgorithm_ =911;1295 lastAlgorithm_ = 911; 1300 1296 modelPtr_>setProblemStatus(4); 1301 1297 } 1302 1298 if (savedObjective) { 1303 1299 // fix up 1304 modelPtr_>dblParam_[ClpDualObjectiveLimit] =savedDualLimit;1300 modelPtr_>dblParam_[ClpDualObjectiveLimit] = savedDualLimit; 1305 1301 //modelPtr_>setMoreSpecialOptions(modelPtr_>moreSpecialOptions()&(~32)); 1306 modelPtr_>objective_ =savedObjective;1302 modelPtr_>objective_ = savedObjective; 1307 1303 if (!modelPtr_>problemStatus_) { 1308 CoinZeroN(modelPtr_>dual_, modelPtr_>numberRows_);1309 CoinZeroN(modelPtr_>reducedCost_, modelPtr_>numberColumns_);1310 if (modelPtr_>dj_ &&(modelPtr_>whatsChanged_&1)!=0)1311 CoinZeroN(modelPtr_>dj_,modelPtr_>numberColumns_+modelPtr_>numberRows_);1304 CoinZeroN(modelPtr_>dual_, modelPtr_>numberRows_); 1305 CoinZeroN(modelPtr_>reducedCost_, modelPtr_>numberColumns_); 1306 if (modelPtr_>dj_ && (modelPtr_>whatsChanged_ & 1) != 0) 1307 CoinZeroN(modelPtr_>dj_, modelPtr_>numberColumns_ + modelPtr_>numberRows_); 1312 1308 modelPtr_>computeObjectiveValue(); 1313 1309 } 1314 1310 } 1315 1311 modelPtr_>setSpecialOptions(saveOptions); // restore 1316 if (modelPtr_>problemStatus_ ==3&&lastAlgorithm_==2)1312 if (modelPtr_>problemStatus_ == 3 && lastAlgorithm_ == 2) 1317 1313 modelPtr_>computeObjectiveValue(); 1318 if (lastAlgorithm_ <1lastAlgorithm_>2)1319 lastAlgorithm_ =1;1314 if (lastAlgorithm_ < 1  lastAlgorithm_ > 2) 1315 lastAlgorithm_ = 1; 1320 1316 #ifdef SAVE_MODEL 1321 if (resolveTry>=loResolveTry&& 1322 resolveTry<=hiResolveTry) { 1323 printf("resolve %d took %d iterations  algorithm %d\n",resolveTry,modelPtr_>numberIterations(),lastAlgorithm_); 1317 if (resolveTry >= loResolveTry && resolveTry <= hiResolveTry) { 1318 printf("resolve %d took %d iterations  algorithm %d\n", resolveTry, modelPtr_>numberIterations(), lastAlgorithm_); 1324 1319 } 1325 1320 #endif … … 1331 1326 #include "ClpSimplexOther.hpp" 1332 1327 // Resolve an LP relaxation after problem modification (try GUB) 1333 void 1334 OsiClpSolverInterface::resolveGub(int needed) 1328 void OsiClpSolverInterface::resolveGub(int needed) 1335 1329 { 1336 1330 bool takeHint; 1337 1331 OsiHintStrength strength; 1338 1332 // Switch off printing if asked to 1339 getHintParam(OsiDoReducePrint, takeHint,strength);1340 int saveMessageLevel =modelPtr_>logLevel();1341 if (strength !=OsiHintIgnore&&takeHint) {1342 int messageLevel =messageHandler()>logLevel();1343 if (messageLevel >0)1344 modelPtr_>messageHandler()>setLogLevel(messageLevel 1);1333 getHintParam(OsiDoReducePrint, takeHint, strength); 1334 int saveMessageLevel = modelPtr_>logLevel(); 1335 if (strength != OsiHintIgnore && takeHint) { 1336 int messageLevel = messageHandler()>logLevel(); 1337 if (messageLevel > 0) 1338 modelPtr_>messageHandler()>setLogLevel(messageLevel  1); 1345 1339 else 1346 1340 modelPtr_>messageHandler()>setLogLevel(0); 1347 1341 } 1348 1342 //modelPtr_>messageHandler()>setLogLevel(1); 1349 setBasis(basis_, modelPtr_);1343 setBasis(basis_, modelPtr_); 1350 1344 // find gub 1351 1345 int numberRows = modelPtr_>numberRows(); 1352 int * 1346 int *which = new int[numberRows]; 1353 1347 int numberColumns = modelPtr_>numberColumns(); 1354 int * whichC = new int[numberColumns+numberRows]; 1355 ClpSimplex * model2 = 1356 static_cast<ClpSimplexOther *> (modelPtr_)>gubVersion(which,whichC, 1357 needed,100); 1348 int *whichC = new int[numberColumns + numberRows]; 1349 ClpSimplex *model2 = static_cast< ClpSimplexOther * >(modelPtr_)>gubVersion(which, whichC, 1350 needed, 100); 1358 1351 if (model2) { 1359 1352 // move in solution 1360 static_cast< ClpSimplexOther *>(model2)>setGubBasis(*modelPtr_,1361 which,whichC);1362 model2>setLogLevel(CoinMin(1, model2>logLevel()));1353 static_cast< ClpSimplexOther * >(model2)>setGubBasis(*modelPtr_, 1354 which, whichC); 1355 model2>setLogLevel(CoinMin(1, model2>logLevel())); 1363 1356 ClpPrimalColumnSteepest steepest(5); 1364 1357 model2>setPrimalColumnPivotAlgorithm(steepest); … … 1366 1359 model2>primal(); 1367 1360 //printf("Primal took %g seconds\n",CoinCpuTime()time1); 1368 static_cast< ClpSimplexOther *>(model2)>getGubBasis(*modelPtr_,1369 which,whichC);1361 static_cast< ClpSimplexOther * >(model2)>getGubBasis(*modelPtr_, 1362 which, whichC); 1370 1363 int totalIterations = model2>numberIterations(); 1371 1364 delete model2; 1372 1365 //modelPtr_>setLogLevel(63); 1373 1366 modelPtr_>primal(1); 1374 modelPtr_>setNumberIterations(totalIterations +modelPtr_>numberIterations());1367 modelPtr_>setNumberIterations(totalIterations + modelPtr_>numberIterations()); 1375 1368 } else { 1376 1369 modelPtr_>dual(); 1377 1370 } 1378 delete 1379 delete 1371 delete[] which; 1372 delete[] whichC; 1380 1373 basis_ = getBasis(modelPtr_); 1381 1374 modelPtr_>messageHandler()>setLogLevel(saveMessageLevel); 1382 1375 } 1383 1376 // Sort of lexicographic resolve 1384 void 1385 OsiClpSolverInterface::lexSolve() 1377 void OsiClpSolverInterface::lexSolve() 1386 1378 { 1387 1379 #if 1 1388 1380 abort(); 1389 1381 #else 1390 ((ClpSimplexPrimal *) 1391 printf("itA %d\n", modelPtr_>numberIterations());1382 ((ClpSimplexPrimal *)modelPtr_)>lexSolve(); 1383 printf("itA %d\n", modelPtr_>numberIterations()); 1392 1384 modelPtr_>primal(); 1393 printf("itB %d\n", modelPtr_>numberIterations());1385 printf("itB %d\n", modelPtr_>numberIterations()); 1394 1386 basis_ = getBasis(modelPtr_); 1395 1387 #endif … … 1411 1403 1 leaves 1412 1404 */ 1413 void 1414 OsiClpSolverInterface::setupForRepeatedUse(int senseOfAdventure, int printOut) 1405 void OsiClpSolverInterface::setupForRepeatedUse(int senseOfAdventure, int printOut) 1415 1406 { 1416 1407 // First try 1417 1408 switch (senseOfAdventure) { 1418 1409 case 0: 1419 specialOptions_ =8;1410 specialOptions_ = 8; 1420 1411 break; 1421 1412 case 1: 1422 specialOptions_ =1+2+8;1413 specialOptions_ = 1 + 2 + 8; 1423 1414 break; 1424 1415 case 2: 1425 specialOptions_ =1+2+4+8;1416 specialOptions_ = 1 + 2 + 4 + 8; 1426 1417 break; 1427 1418 case 3: 1428 specialOptions_ =1+8;1419 specialOptions_ = 1 + 8; 1429 1420 break; 1430 1421 } … … 1433 1424 specialOptions_ &= ~1; 1434 1425 #endif 1435 bool stopPrinting =false;1436 if (printOut <0) {1437 stopPrinting =true;1426 bool stopPrinting = false; 1427 if (printOut < 0) { 1428 stopPrinting = true; 1438 1429 } else if (!printOut) { 1439 1430 bool takeHint; 1440 1431 OsiHintStrength strength; 1441 getHintParam(OsiDoReducePrint, takeHint,strength);1442 int messageLevel =messageHandler()>logLevel();1443 if (strength !=OsiHintIgnore&&takeHint)1432 getHintParam(OsiDoReducePrint, takeHint, strength); 1433 int messageLevel = messageHandler()>logLevel(); 1434 if (strength != OsiHintIgnore && takeHint) 1444 1435 messageLevel; 1445 stopPrinting = (messageLevel <=0);1436 stopPrinting = (messageLevel <= 0); 1446 1437 } 1447 1438 #ifndef COIN_DEVELOP 1448 1439 if (stopPrinting) { 1449 CoinMessages * 1450 // won't even build messages 1451 messagesPointer>setDetailMessages(100, 10000,reinterpret_cast<int *>(NULL));1440 CoinMessages *messagesPointer = modelPtr_>messagesPointer(); 1441 // won't even build messages 1442 messagesPointer>setDetailMessages(100, 10000, reinterpret_cast< int * >(NULL)); 1452 1443 } 1453 1444 #endif … … 1457 1448 // only called in debug mode 1458 1449 static void indexError(int index, 1459 1460 { 1461 std::cerr <<"Illegal index "<<index<<" in OsiClpSolverInterface::"<<methodName<<std::endl;1462 throw CoinError("Illegal index", methodName,"OsiClpSolverInterface");1450 std::string methodName) 1451 { 1452 std::cerr << "Illegal index " << index << " in OsiClpSolverInterface::" << methodName << std::endl; 1453 throw CoinError("Illegal index", methodName, "OsiClpSolverInterface"); 1463 1454 } 1464 1455 #endif … … 1467 1458 //############################################################################# 1468 1459 1469 bool 1470 OsiClpSolverInterface::setIntParam(OsiIntParam key, int value) 1471 { 1472 return modelPtr_>setIntParam(static_cast<ClpIntParam> (key), value); 1460 bool OsiClpSolverInterface::setIntParam(OsiIntParam key, int value) 1461 { 1462 return modelPtr_>setIntParam(static_cast< ClpIntParam >(key), value); 1473 1463 } 1474 1464 1475 1465 // 1476 1466 1477 bool 1478 OsiClpSolverInterface::setDblParam(OsiDblParam key, double value) 1479 { 1480 if (key != OsiLastDblParam ) { 1481 if (key==OsiDualObjectiveLimitkey==OsiPrimalObjectiveLimit) 1467 bool OsiClpSolverInterface::setDblParam(OsiDblParam key, double value) 1468 { 1469 if (key != OsiLastDblParam) { 1470 if (key == OsiDualObjectiveLimit  key == OsiPrimalObjectiveLimit) 1482 1471 value *= modelPtr_>optimizationDirection(); 1483 return modelPtr_>setDblParam(static_cast< ClpDblParam>(key), value);1472 return modelPtr_>setDblParam(static_cast< ClpDblParam >(key), value); 1484 1473 } else { 1485 1474 return false; … … 1489 1478 // 1490 1479 1491 bool 1492 OsiClpSolverInterface::setStrParam(OsiStrParam key, const std::string & value) 1493 { 1494 assert (key!=OsiSolverName); 1495 if (key != OsiLastStrParam ) { 1496 return modelPtr_>setStrParam(static_cast<ClpStrParam> (key), value); 1480 bool OsiClpSolverInterface::setStrParam(OsiStrParam key, const std::string &value) 1481 { 1482 assert(key != OsiSolverName); 1483 if (key != OsiLastStrParam) { 1484 return modelPtr_>setStrParam(static_cast< ClpStrParam >(key), value); 1497 1485 } else { 1498 1486 return false; … … 1500 1488 } 1501 1489 1502 1503 1490 // 1504 1491 1505 bool 1506 OsiClpSolverInterface::getIntParam(OsiIntParam key, int& value) const 1507 { 1508 return modelPtr_>getIntParam(static_cast<ClpIntParam> (key), value); 1492 bool OsiClpSolverInterface::getIntParam(OsiIntParam key, int &value) const 1493 { 1494 return modelPtr_>getIntParam(static_cast< ClpIntParam >(key), value); 1509 1495 } 1510 1496 1511 1497 // 1512 1498 1513 bool 1514 OsiClpSolverInterface::getDblParam(OsiDblParam key, double& value) const 1515 { 1516 if (key != OsiLastDblParam ) { 1517 bool condition = modelPtr_>getDblParam(static_cast<ClpDblParam> (key), value); 1518 if (key==OsiDualObjectiveLimitkey==OsiPrimalObjectiveLimit) 1499 bool OsiClpSolverInterface::getDblParam(OsiDblParam key, double &value) const 1500 { 1501 if (key != OsiLastDblParam) { 1502 bool condition = modelPtr_>getDblParam(static_cast< ClpDblParam >(key), value); 1503 if (key == OsiDualObjectiveLimit  key == OsiPrimalObjectiveLimit) 1519 1504 value *= modelPtr_>optimizationDirection(); 1520 1505 return condition; … … 1526 1511 // 1527 1512 1528 bool 1529 OsiClpSolverInterface::getStrParam(OsiStrParam key, std::string & value) const 1530 { 1531 if ( key==OsiSolverName ) { 1513 bool OsiClpSolverInterface::getStrParam(OsiStrParam key, std::string &value) const 1514 { 1515 if (key == OsiSolverName) { 1532 1516 value = "clp"; 1533 1517 return true; 1534 1518 } 1535 if (key != OsiLastStrParam 1536 return modelPtr_>getStrParam(static_cast< ClpStrParam>(key), value);1519 if (key != OsiLastStrParam) { 1520 return modelPtr_>getStrParam(static_cast< ClpStrParam >(key), value); 1537 1521 } else { 1538 1522 return false; 1539 1523 } 1540 1524 } 1541 1542 1525 1543 1526 //############################################################################# … … 1548 1531 { 1549 1532 // not sure about 1 (should not happen) 1550 return (modelPtr_>status()==4modelPtr_>status()==1 1551 (modelPtr_>status()==1&&modelPtr_>secondaryStatus()==8)); 1533 return (modelPtr_>status() == 4  modelPtr_>status() == 1  (modelPtr_>status() == 1 && modelPtr_>secondaryStatus() == 8)); 1552 1534 } 1553 1535 … … 1564 1546 const int stat = modelPtr_>status(); 1565 1547 if (stat != 1) 1566 1548 return false; 1567 1549 return true; 1568 1550 } … … 1585 1567 return false; 1586 1568 } 1587 1569 1588 1570 const double obj = modelPtr_>objectiveValue(); 1589 int maxmin = static_cast< int>(modelPtr_>optimizationDirection());1571 int maxmin = static_cast< int >(modelPtr_>optimizationDirection()); 1590 1572 1591 1573 switch (lastAlgorithm_) { 1592 1593 1594 1595 1596 1597 1598 1599 1574 case 0: // no simplex was needed 1575 return maxmin > 0 ? (obj < limit) /*minim*/ : (obj < limit) /*maxim*/; 1576 case 2: // dual simplex 1577 if (modelPtr_>status() == 0) // optimal 1578 return maxmin > 0 ? (obj < limit) /*minim*/ : (obj < limit) /*maxim*/; 1579 return false; 1580 case 1: // primal simplex 1581 return maxmin > 0 ? (obj < limit) /*minim*/ : (obj < limit) /*maxim*/; 1600 1582 } 1601 1583 return false; // fake return … … 1608 1590 if (stat == 1) 1609 1591 return true; 1610 else if (stat <0)1592 else if (stat < 0) 1611 1593 return false; 1612 1594 double limit = 0.0; … … 1616 1598 return false; 1617 1599 } 1618 1600 1619 1601 const double obj = modelPtr_>objectiveValue(); 1620 int maxmin = static_cast< int>(modelPtr_>optimizationDirection());1602 int maxmin = static_cast< int >(modelPtr_>optimizationDirection()); 1621 1603 1622 1604 switch (lastAlgorithm_) { 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1605 case 0: // no simplex was needed 1606 return maxmin > 0 ? (obj > limit) /*minim*/ : (obj > limit) /*maxim*/; 1607 case 1: // primal simplex 1608 if (stat == 0) // optimal 1609 return maxmin > 0 ? (obj > limit) /*minim*/ : (obj > limit) /*maxim*/; 1610 return false; 1611 case 2: // dual simplex 1612 if (stat != 0 && stat != 3) 1613 // over dual limit 1614 return true; 1615 return maxmin > 0 ? (obj > limit) /*minim*/ : (obj > limit) /*maxim*/; 1634 1616 } 1635 1617 return false; // fake return … … 1646 1628 // WarmStart related methods 1647 1629 //############################################################################# 1648 CoinWarmStart *OsiClpSolverInterface::getEmptyWarmStart () const 1649 { return (static_cast<CoinWarmStart *>(new CoinWarmStartBasis())) ; } 1650 1651 CoinWarmStart* OsiClpSolverInterface::getWarmStart() const 1630 CoinWarmStart *OsiClpSolverInterface::getEmptyWarmStart() const 1631 { 1632 return (static_cast< CoinWarmStart * >(new CoinWarmStartBasis())); 1633 } 1634 1635 CoinWarmStart *OsiClpSolverInterface::getWarmStart() const 1652 1636 { 1653 1637 … … 1662 1646 OsiClp version always returns pointer and false. 1663 1647 */ 1664 CoinWarmStart *1665 OsiClpSolverInterface::getPointerToWarmStart(bool & mustDelete)1648 CoinWarmStart * 1649 OsiClpSolverInterface::getPointerToWarmStart(bool &mustDelete) 1666 1650 { 1667 1651 mustDelete = false; … … 1671 1655 // 1672 1656 1673 bool OsiClpSolverInterface::setWarmStart(const CoinWarmStart *warmstart)1657 bool OsiClpSolverInterface::setWarmStart(const CoinWarmStart *warmstart) 1674 1658 { 1675 1659 modelPtr_>whatsChanged_ &= 0xffff; 1676 const CoinWarmStartBasis* ws = 1677 dynamic_cast<const CoinWarmStartBasis*>(warmstart); 1660 const CoinWarmStartBasis *ws = dynamic_cast< const CoinWarmStartBasis * >(warmstart); 1678 1661 if (ws) { 1679 1662 basis_ = CoinWarmStartBasis(*ws); … … 1695 1678 #ifdef CBC_STATISTICS 1696 1679 osi_hot++; 1697 #endif 1680 #endif 1698 1681 //printf("HotStart options %x changed %x, small %x spare %x\n", 1699 1682 // specialOptions_,modelPtr_>whatsChanged_, 1700 1683 // smallModel_,spareArrays_); 1701 1684 modelPtr_>setProblemStatus(0); 1702 saveData_.perturbation_ =0;1685 saveData_.perturbation_ = 0; 1703 1686 saveData_.specialOptions_ = modelPtr_>specialOptions_; 1704 1687 modelPtr_>specialOptions_ = 0x1000000; 1705 modelPtr_>specialOptions_ = saveData_.specialOptions_; 1706 ClpObjective * savedObjective=NULL;1707 double savedDualLimit =modelPtr_>dblParam_[ClpDualObjectiveLimit];1688 modelPtr_>specialOptions_ = saveData_.specialOptions_; 1689 ClpObjective *savedObjective = NULL; 1690 double savedDualLimit = modelPtr_>dblParam_[ClpDualObjectiveLimit]; 1708 1691 if (fakeObjective_) { 1709 modelPtr_>setMoreSpecialOptions(modelPtr_>moreSpecialOptions() &(~128));1692 modelPtr_>setMoreSpecialOptions(modelPtr_>moreSpecialOptions() & (~128)); 1710 1693 // See if all with costs fixed 1711 1694 int numberColumns = modelPtr_>numberColumns_; 1712 const double * 1713 const double * 1714 const double * 1695 const double *obj = modelPtr_>objective(); 1696 const double *lower = modelPtr_>columnLower(); 1697 const double *upper = modelPtr_>columnUpper(); 1715 1698 int i; 1716 for (i =0;i<numberColumns;i++) {1699 for (i = 0; i < numberColumns; i++) { 1717 1700 double objValue = obj[i]; 1718 1701 if (objValue) { 1719 if (lower[i]!=upper[i])1720 1721 } 1722 } 1723 if (i ==numberColumns) {1724 if ((specialOptions_ &524288)==0) {1725 1726 savedObjective=modelPtr_>objective_;1727 modelPtr_>objective_=fakeObjective_;1728 modelPtr_>dblParam_[ClpDualObjectiveLimit]=COIN_DBL_MAX;1729 saveData_.perturbation_=1;1702 if (lower[i] != upper[i]) 1703 break; 1704 } 1705 } 1706 if (i == numberColumns) { 1707 if ((specialOptions_ & 524288) == 0) { 1708 // Set fake 1709 savedObjective = modelPtr_>objective_; 1710 modelPtr_>objective_ = fakeObjective_; 1711 modelPtr_>dblParam_[ClpDualObjectiveLimit] = COIN_DBL_MAX; 1712 saveData_.perturbation_ = 1; 1730 1713 } else { 1731 modelPtr_>setMoreSpecialOptions(modelPtr_>moreSpecialOptions()128);1714 modelPtr_>setMoreSpecialOptions(modelPtr_>moreSpecialOptions()  128); 1732 1715 } 1733 1716 } … … 1735 1718 #define CLEAN_HOT_START 1736 1719 #ifdef CLEAN_HOT_START 1737 if ((specialOptions_ &65536)!=0) {1720 if ((specialOptions_ & 65536) != 0) { 1738 1721 //specialOptions_ = 65536; 1739 saveData_.scalingFlag_ =modelPtr_>logLevel();1740 if (modelPtr_>logLevel() <2)1722 saveData_.scalingFlag_ = modelPtr_>logLevel(); 1723 if (modelPtr_>logLevel() < 2) 1741 1724 modelPtr_>setLogLevel(0); 1742 assert ((specialOptions_&128)==0);1725 assert((specialOptions_ & 128) == 0); 1743 1726 // space for save arrays 1744 1727 int numberColumns = modelPtr_>numberColumns(); 1745 1728 int numberRows = modelPtr_>numberRows(); 1746 // Get space for strong branching 1747 int size = static_cast< int>((1+4*(numberRows+numberColumns))*sizeof(double));1729 // Get space for strong branching 1730 int size = static_cast< int >((1 + 4 * (numberRows + numberColumns)) * sizeof(double)); 1748 1731 // and for save of original column bounds 1749 size += static_cast< int>(2*numberColumns*sizeof(double));1750 size += static_cast< int>((1+4*numberRows+2*numberColumns)*sizeof(int));1751 size += numberRows +numberColumns;1752 assert (spareArrays_==NULL);1732 size += static_cast< int >(2 * numberColumns * sizeof(double)); 1733 size += static_cast< int >((1 + 4 * numberRows + 2 * numberColumns) * sizeof(int)); 1734 size += numberRows + numberColumns; 1735 assert(spareArrays_ == NULL); 1753 1736 spareArrays_ = new char[size]; 1754 1737 //memset(spareArrays_,0x20,size); 1755 1738 // Setup for strong branching 1756 assert (factorization_==NULL);1757 if ((specialOptions_ &131072)!=0) {1758 assert (lastNumberRows_>=0);1759 if (modelPtr_>rowScale_ !=rowScale_.array()) {1760 assert(modelPtr_>columnScale_!=columnScale_.array());1761 delete[] modelPtr_>rowScale_;1762 modelPtr_>rowScale_=NULL;1763 delete[] modelPtr_>columnScale_;1764 modelPtr_>columnScale_=NULL;1765 if (lastNumberRows_==modelPtr_>numberRows()) {1766 1767 1768 1769 1770 1771 1772 } 1773 lastNumberRows_ = 1  lastNumberRows_;1774 } 1775 factorization_ = static_cast< ClpSimplexDual *>(modelPtr_)>setupForStrongBranching(spareArrays_,numberRows,1776 numberColumns,true);1777 double * arrayD = reinterpret_cast<double *>(spareArrays_);1778 arrayD[0] =modelPtr_>objectiveValue()* modelPtr_>optimizationDirection();1779 double * saveSolution = arrayD+1;1780 double * saveLower = saveSolution + (numberRows+numberColumns);1781 double * saveUpper = saveLower + (numberRows+numberColumns);1782 double * saveObjective = saveUpper + (numberRows+numberColumns);1783 double * saveLowerOriginal = saveObjective + (numberRows+numberColumns);1784 double * 1785 CoinMemcpyN( modelPtr_>columnLower(),numberColumns, saveLowerOriginal);1786 CoinMemcpyN( modelPtr_>columnUpper(),numberColumns, saveUpperOriginal);1739 assert(factorization_ == NULL); 1740 if ((specialOptions_ & 131072) != 0) { 1741 assert(lastNumberRows_ >= 0); 1742 if (modelPtr_>rowScale_ != rowScale_.array()) { 1743 assert(modelPtr_>columnScale_ != columnScale_.array()); 1744 delete[] modelPtr_>rowScale_; 1745 modelPtr_>rowScale_ = NULL; 1746 delete[] modelPtr_>columnScale_; 1747 modelPtr_>columnScale_ = NULL; 1748 if (lastNumberRows_ == modelPtr_>numberRows()) { 1749 // use scaling 1750 modelPtr_>rowScale_ = rowScale_.array(); 1751 modelPtr_>columnScale_ = columnScale_.array(); 1752 } else { 1753 specialOptions_ &= ~131072; 1754 } 1755 } 1756 lastNumberRows_ = 1  lastNumberRows_; 1757 } 1758 factorization_ = static_cast< ClpSimplexDual * >(modelPtr_)>setupForStrongBranching(spareArrays_, numberRows, 1759 numberColumns, true); 1760 double *arrayD = reinterpret_cast< double * >(spareArrays_); 1761 arrayD[0] = modelPtr_>objectiveValue() * modelPtr_>optimizationDirection(); 1762 double *saveSolution = arrayD + 1; 1763 double *saveLower = saveSolution + (numberRows + numberColumns); 1764 double *saveUpper = saveLower + (numberRows + numberColumns); 1765 double *saveObjective = saveUpper + (numberRows + numberColumns); 1766 double *saveLowerOriginal = saveObjective + (numberRows + numberColumns); 1767 double *saveUpperOriginal = saveLowerOriginal + numberColumns; 1768 CoinMemcpyN(modelPtr_>columnLower(), numberColumns, saveLowerOriginal); 1769 CoinMemcpyN(modelPtr_>columnUpper(), numberColumns, saveUpperOriginal); 1787 1770 #if 0 1788 1771 if (whichRange_&&whichRange_[0]) { … … 1811 1794 columnActivity_=downRange; 1812 1795 } 1813 #endif 1796 #endif 1814 1797 if (savedObjective) { 1815 1798 // fix up 1816 modelPtr_>dblParam_[ClpDualObjectiveLimit] =savedDualLimit;1799 modelPtr_>dblParam_[ClpDualObjectiveLimit] = savedDualLimit; 1817 1800 //modelPtr_>setMoreSpecialOptions(modelPtr_>moreSpecialOptions()&(~32)); 1818 modelPtr_>objective_ =savedObjective;1801 modelPtr_>objective_ = savedObjective; 1819 1802 if (!modelPtr_>problemStatus_) { 1820 CoinZeroN(modelPtr_>dual_,modelPtr_>numberRows_);1821 CoinZeroN(modelPtr_>reducedCost_,modelPtr_>numberColumns_);1822 if (modelPtr_>dj_&&(modelPtr_>whatsChanged_&1)!=0)1823 CoinZeroN(modelPtr_>dj_,modelPtr_>numberColumns_+modelPtr_>numberRows_);1824 1803 CoinZeroN(modelPtr_>dual_, modelPtr_>numberRows_); 1804 CoinZeroN(modelPtr_>reducedCost_, modelPtr_>numberColumns_); 1805 if (modelPtr_>dj_ && (modelPtr_>whatsChanged_ & 1) != 0) 1806 CoinZeroN(modelPtr_>dj_, modelPtr_>numberColumns_ + modelPtr_>numberRows_); 1807 modelPtr_>computeObjectiveValue(); 1825 1808 } 1826 1809 } … … 1828 1811 } 1829 1812 #endif 1830 if ((specialOptions_ &8192)==0&&false) { // (specialOptions_&65536)!=0) {1813 if ((specialOptions_ & 8192) == 0 && false) { // (specialOptions_&65536)!=0) { 1831 1814 delete ws_; 1832 ws_ = dynamic_cast< CoinWarmStartBasis*>(getWarmStart());1815 ws_ = dynamic_cast< CoinWarmStartBasis * >(getWarmStart()); 1833 1816 int numberRows = modelPtr_>numberRows(); 1834 rowActivity_ = new double[numberRows];1835 CoinMemcpyN(modelPtr_>primalRowSolution(), numberRows,rowActivity_);1817 rowActivity_ = new double[numberRows]; 1818 CoinMemcpyN(modelPtr_>primalRowSolution(), numberRows, rowActivity_); 1836 1819 int numberColumns = modelPtr_>numberColumns(); 1837 columnActivity_ = new double[numberColumns];1838 CoinMemcpyN(modelPtr_>primalColumnSolution(), numberColumns,columnActivity_);1820 columnActivity_ = new double[numberColumns]; 1821 CoinMemcpyN(modelPtr_>primalColumnSolution(), numberColumns, columnActivity_); 1839 1822 } else { 1840 1823 #if 0 … … 1853 1836 int numberRows = modelPtr_>numberRows(); 1854 1837 // Get space for crunch and strong branching (too much) 1855 int size = static_cast< int>((1+4*(numberRows+numberColumns))*sizeof(double));1838 int size = static_cast< int >((1 + 4 * (numberRows + numberColumns)) * sizeof(double)); 1856 1839 // and for save of original column bounds 1857 size += static_cast< int>(2*numberColumns*sizeof(double));1858 size += static_cast< int>((1+4*numberRows+2*numberColumns)*sizeof(int));1859 size += numberRows +numberColumns;1840 size += static_cast< int >(2 * numberColumns * sizeof(double)); 1841 size += static_cast< int >((1 + 4 * numberRows + 2 * numberColumns) * sizeof(int)); 1842 size += numberRows + numberColumns; 1860 1843 #ifdef KEEP_SMALL 1861 if (smallModel_&&(modelPtr_>whatsChanged_&0x30000)!=0x30000) {1844 if (smallModel_ && (modelPtr_>whatsChanged_ & 0x30000) != 0x30000) { 1862 1845 //printf("Bounds changed ? %x\n",modelPtr_>whatsChanged_); 1863 1846 delete smallModel_; 1864 smallModel_ =NULL;1847 smallModel_ = NULL; 1865 1848 } 1866 1849 if (!smallModel_) { 1867 delete 1850 delete[] spareArrays_; 1868 1851 spareArrays_ = NULL; 1869 1852 } 1870 1853 #endif 1871 if (spareArrays_ ==NULL) {1854 if (spareArrays_ == NULL) { 1872 1855 //if (smallModel_) 1873 1856 //printf("small model %x\n",smallModel_); 1874 1857 delete smallModel_; 1875 smallModel_ =NULL;1858 smallModel_ = NULL; 1876 1859 spareArrays_ = new char[size]; 1877 1860 //memset(spareArrays_,0x20,size); 1878 1861 } else { 1879 double * arrayD = reinterpret_cast<double *>(spareArrays_);1880 double * saveSolution = arrayD+1;1881 double * saveLower = saveSolution + (numberRows+numberColumns);1882 double * saveUpper = saveLower + (numberRows+numberColumns);1883 double * saveObjective = saveUpper + (numberRows+numberColumns);1884 double * saveLowerOriginal = saveObjective + (numberRows+numberColumns);1885 double * 1886 double * 1887 double * 1862 double *arrayD = reinterpret_cast< double * >(spareArrays_); 1863 double *saveSolution = arrayD + 1; 1864 double *saveLower = saveSolution + (numberRows + numberColumns); 1865 double *saveUpper = saveLower + (numberRows + numberColumns); 1866 double *saveObjective = saveUpper + (numberRows + numberColumns); 1867 double *saveLowerOriginal = saveObjective + (numberRows + numberColumns); 1868 double *saveUpperOriginal = saveLowerOriginal + numberColumns; 1869 double *lowerOriginal = modelPtr_>columnLower(); 1870 double *upperOriginal = modelPtr_>columnUpper(); 1888 1871 arrayD = saveUpperOriginal + numberColumns; 1889 int * savePivot = reinterpret_cast<int *>(arrayD);1890 int * whichRow = savePivot+numberRows;1891 int * whichColumn = whichRow + 3*numberRows;1892 int nSame =0;1893 int nSub =0;1894 for (int i =0;i<numberColumns;i++) {1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 if (lo>=loOld&&up<=upOld) {1905 if (lo==loOld&&up==upOld) {1906 1907 1908 1909 1910 1911 1912 1872 int *savePivot = reinterpret_cast< int * >(arrayD); 1873 int *whichRow = savePivot + numberRows; 1874 int *whichColumn = whichRow + 3 * numberRows; 1875 int nSame = 0; 1876 int nSub = 0; 1877 for (int i = 0; i < numberColumns; i++) { 1878 double lo = lowerOriginal[i]; 1879 //char * xx = (char *) (saveLowerOriginal+i); 1880 //assert (xx[0]!=0x20xx[1]!=0x20); 1881 //xx = (char *) (saveUpperOriginal+i); 1882 //assert (xx[0]!=0x20xx[1]!=0x20); 1883 double loOld = saveLowerOriginal[i]; 1884 //assert (!loOldfabs(loOld)>1.0e30); 1885 double up = upperOriginal[i]; 1886 double upOld = saveUpperOriginal[i]; 1887 if (lo >= loOld && up <= upOld) { 1888 if (lo == loOld && up == upOld) { 1889 nSame++; 1890 } else { 1891 nSub++; 1892 //if (!isInteger(i)) 1893 //nSub+=10; 1894 } 1895 } 1913 1896 } 1914 1897 //printf("Mark Hot %d bounds same, %d interior, %d bad\n", 1915 1898 // nSame,nSub,numberColumnsnSamenSub); 1916 if (nSame <numberColumns) {1917 if (nSame+nSub<numberColumns) {1918 1919 smallModel_=NULL;1920 1921 1922 assert(smallModel_);1923 double *lowerSmall = smallModel_>columnLower();1924 double *upperSmall = smallModel_>columnUpper();1925 1926 for (int i=0;i<numberColumns2;i++) {1927 1928 lowerSmall[i]=lowerOriginal[iColumn];1929 upperSmall[i]=upperOriginal[iColumn];1930 1931 1932 } 1933 } 1934 double * arrayD = reinterpret_cast<double *>(spareArrays_);1935 arrayD[0] =modelPtr_>objectiveValue()* modelPtr_>optimizationDirection();1936 double * saveSolution = arrayD+1;1937 double * saveLower = saveSolution + (numberRows+numberColumns);1938 double * saveUpper = saveLower + (numberRows+numberColumns);1939 double * saveObjective = saveUpper + (numberRows+numberColumns);1940 double * saveLowerOriginal = saveObjective + (numberRows+numberColumns);1941 double * 1899 if (nSame < numberColumns) { 1900 if (nSame + nSub < numberColumns) { 1901 delete smallModel_; 1902 smallModel_ = NULL; 1903 } else { 1904 // we can fix up (but should we if large number fixed?) 1905 assert(smallModel_); 1906 double *lowerSmall = smallModel_>columnLower(); 1907 double *upperSmall = smallModel_>columnUpper(); 1908 int numberColumns2 = smallModel_>numberColumns(); 1909 for (int i = 0; i < numberColumns2; i++) { 1910 int iColumn = whichColumn[i]; 1911 lowerSmall[i] = lowerOriginal[iColumn]; 1912 upperSmall[i] = upperOriginal[iColumn]; 1913 } 1914 } 1915 } 1916 } 1917 double *arrayD = reinterpret_cast< double * >(spareArrays_); 1918 arrayD[0] = modelPtr_>objectiveValue() * modelPtr_>optimizationDirection(); 1919 double *saveSolution = arrayD + 1; 1920 double *saveLower = saveSolution + (numberRows + numberColumns); 1921 double *saveUpper = saveLower + (numberRows + numberColumns); 1922 double *saveObjective = saveUpper + (numberRows + numberColumns); 1923 double *saveLowerOriginal = saveObjective + (numberRows + numberColumns); 1924 double *saveUpperOriginal = saveLowerOriginal + numberColumns; 1942 1925 arrayD = saveUpperOriginal + numberColumns; 1943 int * savePivot = reinterpret_cast<int *>(arrayD);1944 int * whichRow = savePivot+numberRows;1945 int * whichColumn = whichRow + 3*numberRows;1946 int * arrayI = whichColumn + 2*numberColumns;1926 int *savePivot = reinterpret_cast< int * >(arrayD); 1927 int *whichRow = savePivot + numberRows; 1928 int *whichColumn = whichRow + 3 * numberRows; 1929 int *arrayI = whichColumn + 2 * numberColumns; 1947 1930 //unsigned char * saveStatus = (unsigned char *) (arrayI+1); 1948 1931 // Use dual region 1949 double * 1950 int nBound =0;1951 ClpSimplex * 1932 double *rhs = modelPtr_>dualRowSolution(); 1933 int nBound = 0; 1934 ClpSimplex *small; 1952 1935 #ifndef KEEP_SMALL 1953 assert 1954 small = static_cast< ClpSimplexOther *> (modelPtr_)>crunch(rhs,whichRow,whichColumn,nBound,true);1955 bool needSolveInSetupHotStart =true;1936 assert(!smallModel_); 1937 small = static_cast< ClpSimplexOther * >(modelPtr_)>crunch(rhs, whichRow, whichColumn, nBound, true); 1938 bool needSolveInSetupHotStart = true; 1956 1939 #else 1957 bool needSolveInSetupHotStart =true;1940 bool needSolveInSetupHotStart = true; 1958 1941 if (!smallModel_) { 1959 1942 #ifndef NDEBUG 1960 CoinFillN(whichRow, 3*numberRows+2*numberColumns,1);1961 #endif 1962 small = static_cast< ClpSimplexOther *> (modelPtr_)>crunch(rhs,whichRow,whichColumn,nBound,true);1943 CoinFillN(whichRow, 3 * numberRows + 2 * numberColumns, 1); 1944 #endif 1945 small = static_cast< ClpSimplexOther * >(modelPtr_)>crunch(rhs, whichRow, whichColumn, nBound, true); 1963 1946 #ifndef NDEBUG 1964 int nCopy = 3 *numberRows+2*numberColumns;1965 for (int i =0;i<nCopy;i++)1966 assert (whichRow[i]>=CoinMax(numberRows,numberColumns)&&whichRow[i]<CoinMax(numberRows,numberColumns));1967 #endif 1968 smallModel_ =small;1947 int nCopy = 3 * numberRows + 2 * numberColumns; 1948 for (int i = 0; i < nCopy; i++) 1949 assert(whichRow[i] >= CoinMax(numberRows, numberColumns) && whichRow[i] < CoinMax(numberRows, numberColumns)); 1950 #endif 1951 smallModel_ = small; 1969 1952 //int hotIts = small>intParam_[ClpMaxNumIterationHotStart]; 1970 1953 //if (5*small>factorization_>maximumPivots()> … … 1972 1955 //small>factorization_>maximumPivots(hotIts+1); 1973 1956 } else { 1974 assert((modelPtr_>whatsChanged_ &0x30000)==0x30000);1957 assert((modelPtr_>whatsChanged_ & 0x30000) == 0x30000); 1975 1958 //delete [] spareArrays_; 1976 1959 //spareArrays_ = NULL; 1977 assert 1978 int nCopy = 3 *numberRows+2*numberColumns;1960 assert(spareArrays_); 1961 int nCopy = 3 * numberRows + 2 * numberColumns; 1979 1962 nBound = whichRow[nCopy]; 1980 1963 #ifndef NDEBUG 1981 for (int i =0;i<nCopy;i++)1982 assert (whichRow[i]>=CoinMax(numberRows,numberColumns)&&whichRow[i]<CoinMax(numberRows,numberColumns));1983 #endif 1984 needSolveInSetupHotStart =false;1964 for (int i = 0; i < nCopy; i++) 1965 assert(whichRow[i] >= CoinMax(numberRows, numberColumns) && whichRow[i] < CoinMax(numberRows, numberColumns)); 1966 #endif 1967 needSolveInSetupHotStart = false; 1985 1968 small = smallModel_; 1986 1969 } … … 1990 1973 small>specialOptions_ &= ~65536; 1991 1974 } 1992 if (small &&(specialOptions_&131072)!=0) {1993 assert (lastNumberRows_>=0);1975 if (small && (specialOptions_ & 131072) != 0) { 1976 assert(lastNumberRows_ >= 0); 1994 1977 int numberRows2 = small>numberRows(); 1995 1978 int numberColumns2 = small>numberColumns(); 1996 double * rowScale2 = new double [2*numberRows2];1997 const double * 1998 double * inverseScale2 = rowScale2+numberRows2;1999 const double * inverseScale = rowScale+modelPtr_>numberRows_;1979 double *rowScale2 = new double[2 * numberRows2]; 1980 const double *rowScale = rowScale_.array(); 1981 double *inverseScale2 = rowScale2 + numberRows2; 1982 const double *inverseScale = rowScale + modelPtr_>numberRows_; 2000 1983 int i; 2001 for (i =0;i<numberRows2;i++) {2002 2003 rowScale2[i]=rowScale[iRow];2004 inverseScale2[i]=inverseScale[iRow];1984 for (i = 0; i < numberRows2; i++) { 1985 int iRow = whichRow[i]; 1986 rowScale2[i] = rowScale[iRow]; 1987 inverseScale2[i] = inverseScale[iRow]; 2005 1988 } 2006 1989 small>setRowScale(rowScale2); 2007 double * columnScale2 = new double [2*numberColumns2];2008 const double * 2009 inverseScale2 = columnScale2 +numberColumns2;2010 inverseScale = columnScale +modelPtr_>numberColumns_;2011 for (i =0;i<numberColumns2;i++) {2012 2013 columnScale2[i]=columnScale[iColumn];2014 inverseScale2[i]=inverseScale[iColumn];1990 double *columnScale2 = new double[2 * numberColumns2]; 1991 const double *columnScale = columnScale_.array(); 1992 inverseScale2 = columnScale2 + numberColumns2; 1993 inverseScale = columnScale + modelPtr_>numberColumns_; 1994 for (i = 0; i < numberColumns2; i++) { 1995 int iColumn = whichColumn[i]; 1996 columnScale2[i] = columnScale[iColumn]; 1997 inverseScale2[i] = inverseScale[iColumn]; 2015 1998 } 2016 1999 small>setColumnScale(columnScale2); … … 2018 2001 if (!small) { 2019 2002 // should never be infeasible .... but 2020 delete 2021 spareArrays_ =NULL;2003 delete[] spareArrays_; 2004 spareArrays_ = NULL; 2022 2005 delete ws_; 2023 ws_ = dynamic_cast< CoinWarmStartBasis*>(getWarmStart());2006 ws_ = dynamic_cast< CoinWarmStartBasis * >(getWarmStart()); 2024 2007 int numberRows = modelPtr_>numberRows(); 2025 rowActivity_ = new double[numberRows];2026 CoinMemcpyN(modelPtr_>primalRowSolution(), numberRows,rowActivity_);2008 rowActivity_ = new double[numberRows]; 2009 CoinMemcpyN(modelPtr_>primalRowSolution(), numberRows, rowActivity_); 2027 2010 int numberColumns = modelPtr_>numberColumns(); 2028 columnActivity_ = new double[numberColumns];2029 CoinMemcpyN(modelPtr_>primalColumnSolution(), numberColumns,columnActivity_);2011 columnActivity_ = new double[numberColumns]; 2012 CoinMemcpyN(modelPtr_>primalColumnSolution(), numberColumns, columnActivity_); 2030 2013 modelPtr_>setProblemStatus(1); 2031 2014 if (savedObjective) { 2032 2033 modelPtr_>dblParam_[ClpDualObjectiveLimit]=savedDualLimit;2034 2035 modelPtr_>objective_=savedObjective;2015 // fix up 2016 modelPtr_>dblParam_[ClpDualObjectiveLimit] = savedDualLimit; 2017 //modelPtr_>setMoreSpecialOptions(modelPtr_>moreSpecialOptions()&(~32)); 2018 modelPtr_>objective_ = savedObjective; 2036 2019 } 2037 2020 return; … … 2039 2022 int clpOptions = modelPtr_>specialOptions(); 2040 2023 clpOptions &= ~65536; 2041 if ((specialOptions_&1)==0) {2042 small>setSpecialOptions(clpOptions (641024));2024 if ((specialOptions_ & 1) == 0) { 2025 small>setSpecialOptions(clpOptions  (64  1024)); 2043 2026 } else { 2044 if ((specialOptions_&4)==0)2045 small>setSpecialOptions(clpOptions (6412851210244096));2027 if ((specialOptions_ & 4) == 0) 2028 small>setSpecialOptions(clpOptions  (64  128  512  1024  4096)); 2046 2029 else 2047 small>setSpecialOptions(clpOptions (64128512102420484096));2048 } 2049 arrayI[0] =nBound;2050 assert (smallModel_==NULLsmall==smallModel_);2051 if ((specialOptions_ &256)!=01) {2030 small>setSpecialOptions(clpOptions  (64  128  512  1024  2048  4096)); 2031 } 2032 arrayI[0] = nBound; 2033 assert(smallModel_ == NULL  small == smallModel_); 2034 if ((specialOptions_ & 256) != 0  1) { 2052 2035 // only need to do this on second pass in CbcNode 2053 if (modelPtr_>logLevel()<2) small>setLogLevel(0); 2036 if (modelPtr_>logLevel() < 2) 2037 small>setLogLevel(0); 2054 2038 small>specialOptions_ = 262144; 2055 2039 small>moreSpecialOptions_ = modelPtr_>moreSpecialOptions_; … … 2058 2042 small>dual(); 2059 2043 #else 2060 assert (factorization_==NULL);2044 assert(factorization_ == NULL); 2061 2045 //needSolveInSetupHotStart=true; 2062 ClpFactorization * factorization = static_cast<ClpSimplexDual *>(small)>setupForStrongBranching(spareArrays_,2063 numberRows,numberColumns,2064 2065 #endif 2066 if (small>numberIterations() >0&&small>logLevel()>2)2067 printf("**** iterated small %d\n",small>numberIterations());2046 ClpFactorization *factorization = static_cast< ClpSimplexDual * >(small)>setupForStrongBranching(spareArrays_, 2047 numberRows, numberColumns, 2048 needSolveInSetupHotStart); 2049 #endif 2050 if (small>numberIterations() > 0 && small>logLevel() > 2) 2051 printf("**** iterated small %d\n", small>numberIterations()); 2068 2052 //small>setLogLevel(0); 2069 2053 // Could be infeasible if forced one way (and other way stopped on iterations) … … 2071 2055 if (small>status()) { 2072 2056 #ifndef KEEP_SMALL 2073 if (small!=modelPtr_)2074 2075 2076 2077 assert(!smallModel_);2057 if (small != modelPtr_) 2058 delete small; 2059 //delete smallModel_; 2060 //smallModel_=NULL; 2061 assert(!smallModel_); 2078 2062 #else 2079 assert (small==smallModel_);2080 if (smallModel_!=modelPtr_) {2081 2082 2083 smallModel_=NULL;2084 #endif 2085 delete[] spareArrays_;2086 spareArrays_=NULL;2087 2088 ws_ = dynamic_cast<CoinWarmStartBasis*>(getWarmStart());2089 2090 rowActivity_= new double[numberRows];2091 CoinMemcpyN(modelPtr_>primalRowSolution(), numberRows,rowActivity_);2092 2093 columnActivity_= new double[numberColumns];2094 CoinMemcpyN(modelPtr_>primalColumnSolution(), numberColumns,columnActivity_);2095 2096 2097 2098 modelPtr_>dblParam_[ClpDualObjectiveLimit]=savedDualLimit;2099 2100 modelPtr_>objective_=savedObjective;2101 2102 2063 assert(small == smallModel_); 2064 if (smallModel_ != modelPtr_) { 2065 delete smallModel_; 2066 } 2067 smallModel_ = NULL; 2068 #endif 2069 delete[] spareArrays_; 2070 spareArrays_ = NULL; 2071 delete ws_; 2072 ws_ = dynamic_cast< CoinWarmStartBasis * >(getWarmStart()); 2073 int numberRows = modelPtr_>numberRows(); 2074 rowActivity_ = new double[numberRows]; 2075 CoinMemcpyN(modelPtr_>primalRowSolution(), numberRows, rowActivity_); 2076 int numberColumns = modelPtr_>numberColumns(); 2077 columnActivity_ = new double[numberColumns]; 2078 CoinMemcpyN(modelPtr_>primalColumnSolution(), numberColumns, columnActivity_); 2079 modelPtr_>setProblemStatus(1); 2080 if (savedObjective) { 2081 // fix up 2082 modelPtr_>dblParam_[ClpDualObjectiveLimit] = savedDualLimit; 2083 //modelPtr_>setMoreSpecialOptions(modelPtr_>moreSpecialOptions()&(~32)); 2084 modelPtr_>objective_ = savedObjective; 2085 } 2086 return; 2103 2087 } else { 2104 2105 static_cast<ClpSimplexOther *> (modelPtr_)>afterCrunch(*small,whichRow,whichColumn,nBound);2106 } 2088 // update model 2089 static_cast< ClpSimplexOther * >(modelPtr_)>afterCrunch(*small, whichRow, whichColumn, nBound); 2090 } 2107 2091 #ifndef SETUP_HOT 2108 assert (factorization_==NULL);2109 factorization_ = static_cast< ClpSimplexDual *>(small)>setupForStrongBranching(spareArrays_,numberRows,2110 numberColumns,false);2092 assert(factorization_ == NULL); 2093 factorization_ = static_cast< ClpSimplexDual * >(small)>setupForStrongBranching(spareArrays_, numberRows, 2094 numberColumns, false); 2111 2095 #else 2112 assert (factorization!=NULL  small>problemStatus_);2096 assert(factorization != NULL  small>problemStatus_); 2113 2097 factorization_ = factorization; 2114 2098 if (factorization_ == NULL) 2115 factorization_ = static_cast<ClpSimplexDual *>(small)>setupForStrongBranching(spareArrays_,numberRows,numberColumns,false);2099 factorization_ = static_cast< ClpSimplexDual * >(small)>setupForStrongBranching(spareArrays_, numberRows, numberColumns, false); 2116 2100 #endif 2117 2101 } else { 2118 assert (factorization_==NULL); 2119 factorization_ = static_cast<ClpSimplexDual *>(small)>setupForStrongBranching(spareArrays_,numberRows, 2120 numberColumns,false); 2121 } 2122 smallModel_=small; 2123 if (modelPtr_>logLevel()<2) smallModel_>setLogLevel(0); 2102 assert(factorization_ == NULL); 2103 factorization_ = static_cast< ClpSimplexDual * >(small)>setupForStrongBranching(spareArrays_, numberRows, 2104 numberColumns, false); 2105 } 2106 smallModel_ = small; 2107 if (modelPtr_>logLevel() < 2) 2108 smallModel_>setLogLevel(0); 2124 2109 // Setup for strong branching 2125 2110 int numberColumns2 = smallModel_>numberColumns(); 2126 CoinMemcpyN( modelPtr_>columnLower(),numberColumns, saveLowerOriginal);2127 CoinMemcpyN( modelPtr_>columnUpper(),numberColumns, saveUpperOriginal);2128 const double * 2129 const double * 2111 CoinMemcpyN(modelPtr_>columnLower(), numberColumns, saveLowerOriginal); 2112 CoinMemcpyN(modelPtr_>columnUpper(), numberColumns, saveUpperOriginal); 2113 const double *smallLower = smallModel_>columnLower(); 2114 const double *smallUpper = smallModel_>columnUpper(); 2130 2115 // But modify if bounds changed in small 2131 for (int i =0;i<numberColumns2;i++) {2116 for (int i = 0; i < numberColumns2; i++) { 2132 2117 int iColumn = whichColumn[i]; 2133 2118 saveLowerOriginal[iColumn] = CoinMax(saveLowerOriginal[iColumn], 2134 2119 smallLower[i]); 2135 2120 saveUpperOriginal[iColumn] = CoinMin(saveUpperOriginal[iColumn], 2136 2137 } 2138 if (whichRange_ &&whichRange_[0]) {2121 smallUpper[i]); 2122 } 2123 if (whichRange_ && whichRange_[0]) { 2139 2124 // get ranging information 2140 2125 int numberToDo = whichRange_[0]; 2141 int * which = new int[numberToDo];2126 int *which = new int[numberToDo]; 2142 2127 // Convert column numbers 2143 int * backColumn = whichColumn+numberColumns;2144 for (int i =0;i<numberToDo;i++) {2145 int iColumn = whichRange_[i +1];2146 which[i] =backColumn[iColumn];2147 } 2148 double * downRange=new double[numberToDo];2149 double * upRange=new double[numberToDo];2150 int * whichDown = new int[numberToDo];2151 int * whichUp = new int[numberToDo];2128 int *backColumn = whichColumn + numberColumns; 2129 for (int i = 0; i < numberToDo; i++) { 2130 int iColumn = whichRange_[i + 1]; 2131 which[i] = backColumn[iColumn]; 2132 } 2133 double *downRange = new double[numberToDo]; 2134 double *upRange = new double[numberToDo]; 2135 int *whichDown = new int[numberToDo]; 2136 int *whichUp = new int[numberToDo]; 2152 2137 smallModel_>setFactorization(*factorization_); 2153 smallModel_>gutsOfSolution(NULL, NULL,false);2138 smallModel_>gutsOfSolution(NULL, NULL, false); 2154 2139 // Tell code we can increase costs in some cases 2155 2140 smallModel_>setCurrentDualTolerance(0.0); 2156 static_cast<ClpSimplexOther *> (smallModel_)>dualRanging(numberToDo,which, 2157 upRange, whichUp, downRange, whichDown); 2158 delete [] whichDown; 2159 delete [] whichUp; 2160 delete [] which; 2161 rowActivity_=upRange; 2162 columnActivity_=downRange; 2163 } 2164 } 2165 if (savedObjective) { 2166 // fix up 2167 modelPtr_>dblParam_[ClpDualObjectiveLimit]=savedDualLimit; 2168 //modelPtr_>setMoreSpecialOptions(modelPtr_>moreSpecialOptions()&(~32)); 2169 modelPtr_>objective_=savedObjective; 2170 if (!modelPtr_>problemStatus_) { 2171 CoinZeroN(modelPtr_>dual_,modelPtr_>numberRows_); 2172 CoinZeroN(modelPtr_>reducedCost_,modelPtr_>numberColumns_); 2173 if (modelPtr_>dj_&&(modelPtr_>whatsChanged_&1)!=0) 2174 CoinZeroN(modelPtr_>dj_,modelPtr_>numberColumns_+modelPtr_>numberRows_); 2175 modelPtr_>computeObjectiveValue(); 2176 } 2177 } 2141 static_cast< ClpSimplexOther * >(smallModel_)>dualRanging(numberToDo, which, upRange, whichUp, downRange, whichDown); 2142 delete[] whichDown; 2143 delete[] whichUp; 2144 delete[] which; 2145 rowActivity_ = upRange; 2146 columnActivity_ = downRange; 2147 } 2148 } 2149 if (savedObjective) { 2150 // fix up 2151 modelPtr_>dblParam_[ClpDualObjectiveLimit] = savedDualLimit; 2152 //modelPtr_>setMoreSpecialOptions(modelPtr_>moreSpecialOptions()&(~32)); 2153 modelPtr_>objective_ = savedObjective; 2154 if (!modelPtr_>problemStatus_) { 2155 CoinZeroN(modelPtr_>dual_, modelPtr_>numberRows_); 2156 CoinZeroN(modelPtr_>reducedCost_, modelPtr_>numberColumns_); 2157 if (modelPtr_>dj_ && (modelPtr_>whatsChanged_ & 1) != 0) 2158 CoinZeroN(modelPtr_>dj_, modelPtr_>numberColumns_ + modelPtr_>numberRows_); 2159 modelPtr_>computeObjectiveValue(); 2160 } 2161 } 2178 2162 } 2179 2163 … … 2182 2166 #ifdef KEEP_SMALL 2183 2167 if (!spareArrays_) { 2184 assert 2185 assert (modelPtr_>problemStatus_==1);2168 assert(!smallModel_); 2169 assert(modelPtr_>problemStatus_ == 1); 2186 2170 return; 2187 2171 } 2188 2172 #endif 2189 ClpObjective * savedObjective=NULL;2190 double savedDualLimit =modelPtr_>dblParam_[ClpDualObjectiveLimit];2173 ClpObjective *savedObjective = NULL; 2174 double savedDualLimit = modelPtr_>dblParam_[ClpDualObjectiveLimit]; 2191 2175 if (saveData_.perturbation_) { 2192 2176 // Set fake 2193 savedObjective =modelPtr_>objective_;2194 modelPtr_>objective_ =fakeObjective_;2195 modelPtr_>dblParam_[ClpDualObjectiveLimit] =COIN_DBL_MAX;2177 savedObjective = modelPtr_>objective_; 2178 modelPtr_>objective_ = fakeObjective_; 2179 modelPtr_>dblParam_[ClpDualObjectiveLimit] = COIN_DBL_MAX; 2196 2180 } 2197 2181 int numberRows = modelPtr_>numberRows(); 2198 2182 int numberColumns = modelPtr_>numberColumns(); 2199 modelPtr_>getIntParam(ClpMaxNumIteration, itlimOrig_);2183 modelPtr_>getIntParam(ClpMaxNumIteration, itlimOrig_); 2200 2184 int itlim; 2201 2185 modelPtr_>getIntParam(ClpMaxNumIterationHotStart, itlim); 2202 2186 // Is there an extra copy of scaled bounds 2203 int extraCopy = (modelPtr_>maximumRows_ >0) ? modelPtr_>maximumRows_+modelPtr_>maximumColumns_ : 0;2187 int extraCopy = (modelPtr_>maximumRows_ > 0) ? modelPtr_>maximumRows_ + modelPtr_>maximumColumns_ : 0; 2204 2188 #ifdef CLEAN_HOT_START 2205 if ((specialOptions_ &65536)!=0) {2206 double * arrayD = reinterpret_cast<double *>(spareArrays_);2189 if ((specialOptions_ & 65536) != 0) { 2190 double *arrayD = reinterpret_cast< double * >(spareArrays_); 2207 2191 double saveObjectiveValue = arrayD[0]; 2208 double * saveSolution = arrayD+1;2209 int number = numberRows +numberColumns;2210 CoinMemcpyN(saveSolution, number,modelPtr_>solutionRegion());2211 double * saveLower = saveSolution + (numberRows+numberColumns);2212 CoinMemcpyN(saveLower, number,modelPtr_>lowerRegion());2213 double * saveUpper = saveLower + (numberRows+numberColumns);2214 CoinMemcpyN(saveUpper, number,modelPtr_>upperRegion());2215 double * saveObjective = saveUpper + (numberRows+numberColumns);2216 CoinMemcpyN(saveObjective, number,modelPtr_>costRegion());2217 double * saveLowerOriginal = saveObjective + (numberRows+numberColumns);2218 double * 2192 double *saveSolution = arrayD + 1; 2193 int number = numberRows + numberColumns; 2194 CoinMemcpyN(saveSolution, number, modelPtr_>solutionRegion()); 2195 double *saveLower = saveSolution + (numberRows + numberColumns); 2196 CoinMemcpyN(saveLower, number, modelPtr_>lowerRegion()); 2197 double *saveUpper = saveLower + (numberRows + numberColumns); 2198 CoinMemcpyN(saveUpper, number, modelPtr_>upperRegion()); 2199 double *saveObjective = saveUpper + (numberRows + numberColumns); 2200 CoinMemcpyN(saveObjective, number, modelPtr_>costRegion()); 2201 double *saveLowerOriginal = saveObjective + (numberRows + numberColumns); 2202 double *saveUpperOriginal = saveLowerOriginal + numberColumns; 2219 2203 arrayD = saveUpperOriginal + numberColumns; 2220 int * savePivot = reinterpret_cast<int *>(arrayD);2221 CoinMemcpyN(savePivot, numberRows,modelPtr_>pivotVariable());2222 int * whichRow = savePivot+numberRows;2223 int * whichColumn = whichRow + 3*numberRows;2224 int * arrayI = whichColumn + 2*numberColumns;2225 unsigned char * saveStatus = reinterpret_cast<unsigned char *> (arrayI+1);2226 CoinMemcpyN(saveStatus, number,modelPtr_>statusArray());2204 int *savePivot = reinterpret_cast< int * >(arrayD); 2205 CoinMemcpyN(savePivot, numberRows, modelPtr_>pivotVariable()); 2206 int *whichRow = savePivot + numberRows; 2207 int *whichColumn = whichRow + 3 * numberRows; 2208 int *arrayI = whichColumn + 2 * numberColumns; 2209 unsigned char *saveStatus = reinterpret_cast< unsigned char * >(arrayI + 1); 2210 CoinMemcpyN(saveStatus, number, modelPtr_>statusArray()); 2227 2211 modelPtr_>setFactorization(*factorization_); 2228 double * 2229 double * 2212 double *columnLower = modelPtr_>columnLower(); 2213 double *columnUpper = modelPtr_>columnUpper(); 2230 2214 // make sure whatsChanged_ has 1 set 2231 2215 modelPtr_>setWhatsChanged(511); 2232 double * 2233 double * 2216 double *lowerInternal = modelPtr_>lowerRegion(); 2217 double *upperInternal = modelPtr_>upperRegion(); 2234 2218 double rhsScale = modelPtr_>rhsScale(); 2235 const double * 2236 if (modelPtr_>scalingFlag() >0)2237 columnScale = modelPtr_>columnScale() 2219 const double *columnScale = NULL; 2220 if (modelPtr_>scalingFlag() > 0) 2221 columnScale = modelPtr_>columnScale(); 2238 2222 // and do bounds in case dual needs them 2239 2223 int iColumn; 2240 for (iColumn =0;iColumn<numberColumns;iColumn++) {2241 if (columnLower[iColumn] >saveLowerOriginal[iColumn]) {2242 2243 2244 2245 2246 lowerInternal[iColumn]=value;2247 2248 lowerInternal[iColumn+extraCopy]=value;2249 } 2250 if (columnUpper[iColumn] <saveUpperOriginal[iColumn]) {2251 2252 2253 2254 2255 upperInternal[iColumn]=value;2256 2257 upperInternal[iColumn+extraCopy]=value;2224 for (iColumn = 0; iColumn < numberColumns; iColumn++) { 2225 if (columnLower[iColumn] > saveLowerOriginal[iColumn]) { 2226 double value = columnLower[iColumn]; 2227 value *= rhsScale; 2228 if (columnScale) 2229 value /= columnScale[iColumn]; 2230 lowerInternal[iColumn] = value; 2231 if (extraCopy) 2232 lowerInternal[iColumn + extraCopy] = value; 2233 } 2234 if (columnUpper[iColumn] < saveUpperOriginal[iColumn]) { 2235 double value = columnUpper[iColumn]; 2236 value *= rhsScale; 2237 if (columnScale) 2238 value /= columnScale[iColumn]; 2239 upperInternal[iColumn] = value; 2240 if (extraCopy) 2241 upperInternal[iColumn + extraCopy] = value; 2258 2242 } 2259 2243 } 2260 2244 // Start of fast iterations 2261 bool alwaysFinish = ((specialOptions_&32)==0) ? true : false;2245 bool alwaysFinish = ((specialOptions_ & 32) == 0) ? true : false; 2262 2246 //modelPtr_>setLogLevel(1); 2263 modelPtr_>setIntParam(ClpMaxNumIteration, itlim);2264 int saveNumberFake = (static_cast< ClpSimplexDual *>(modelPtr_))>numberFake_;2265 int status = (static_cast< ClpSimplexDual *>(modelPtr_))>fastDual(alwaysFinish);2266 (static_cast< ClpSimplexDual *>(modelPtr_))>numberFake_ = saveNumberFake;2267 2247 modelPtr_>setIntParam(ClpMaxNumIteration, itlim); 2248 int saveNumberFake = (static_cast< ClpSimplexDual * >(modelPtr_))>numberFake_; 2249 int status = (static_cast< ClpSimplexDual * >(modelPtr_))>fastDual(alwaysFinish); 2250 (static_cast< ClpSimplexDual * >(modelPtr_))>numberFake_ = saveNumberFake; 2251 2268 2252 int problemStatus = modelPtr_>problemStatus(); 2269 double objectiveValue = modelPtr_>objectiveValue() * modelPtr_>optimizationDirection();2270 CoinAssert (modelPtr_>problemStatus()modelPtr_>objectiveValue()<1.0e50);2253 double objectiveValue = modelPtr_>objectiveValue() * modelPtr_>optimizationDirection(); 2254 CoinAssert(modelPtr_>problemStatus()  modelPtr_>objectiveValue() < 1.0e50); 2271 2255 // make sure plausible 2272 double obj = CoinMax(objectiveValue, saveObjectiveValue);2273 if (problemStatus ==10problemStatus<0) {2256 double obj = CoinMax(objectiveValue, saveObjectiveValue); 2257 if (problemStatus == 10  problemStatus < 0) { 2274 2258 // was trying to clean up or something odd 2275 if (problemStatus ==10) {2276 2277 lastAlgorithm_=1; // so won't fail on cutoff (in CbcNode)2278 } 2279 status =1;2259 if (problemStatus == 10) { 2260 obj = saveObjectiveValue; 2261 lastAlgorithm_ = 1; // so won't fail on cutoff (in CbcNode) 2262 } 2263 status = 1; 2280 2264 } 2281 2265 if (status) { 2282 2266 // not finished  might be optimal 2283 2267 modelPtr_>checkPrimalSolution(modelPtr_>solutionRegion(0), 2284 2268 modelPtr_>solutionRegion(1)); 2285 2269 //modelPtr_>gutsOfSolution(NULL,NULL,0); 2286 2270 //if (problemStatus==3) 2287 2271 //modelPtr_>computeObjectiveValue(); 2288 objectiveValue =modelPtr_>objectiveValue() * 2289 modelPtr_>optimizationDirection(); 2290 obj = CoinMax(objectiveValue,saveObjectiveValue); 2291 if (!modelPtr_>numberDualInfeasibilities()) { 2292 double limit = 0.0; 2293 modelPtr_>getDblParam(ClpDualObjectiveLimit, limit); 2294 if (modelPtr_>secondaryStatus()==1&&!problemStatus&&obj<limit) { 2295 obj=limit; 2296 problemStatus=3; 2297 } 2298 if (!modelPtr_>numberPrimalInfeasibilities()&&obj<limit) { 2299 problemStatus=0; 2300 } else if (problemStatus==10) { 2301 problemStatus=3; 2302 obj = saveObjectiveValue; 2303 } else if (!modelPtr_>numberPrimalInfeasibilities()) { 2304 problemStatus=1; // infeasible 2305 } 2272 objectiveValue = modelPtr_>objectiveValue() * modelPtr_>optimizationDirection(); 2273 obj = CoinMax(objectiveValue, saveObjectiveValue); 2274 if (!modelPtr_>numberDualInfeasibilities()) { 2275 double limit = 0.0; 2276 modelPtr_>getDblParam(ClpDualObjectiveLimit, limit); 2277 if (modelPtr_>secondaryStatus() == 1 && !problemStatus && obj < limit) { 2278 obj = limit; 2279 problemStatus = 3; 2280 } 2281 if (!modelPtr_>numberPrimalInfeasibilities() && obj < limit) { 2282 problemStatus = 0; 2283 } else if (problemStatus == 10) { 2284 problemStatus = 3; 2285 obj = saveObjectiveValue; 2286 } else if (!modelPtr_>numberPrimalInfeasibilities()) { 2287 problemStatus = 1; // infeasible 2288 } 2306 2289 } else { 2307 2308 2309 2310 lastAlgorithm_=1; // so won't fail on cutoff (in CbcNode)2311 2312 problemStatus=3;2290 // can't say much 2291 //if (problemStatus==3) 2292 //modelPtr_>computeObjectiveValue(); 2293 lastAlgorithm_ = 1; // so won't fail on cutoff (in CbcNode) 2294 obj = saveObjectiveValue; 2295 problemStatus = 3; 2313 2296 } 2314 2297 } else if (!problemStatus) { 2315 if (modelPtr_>isDualObjectiveLimitReached()) 2316 problemStatus=1; // infeasible2317 } 2318 if (status &&!problemStatus) {2319 problemStatus =3; // can't be sure2320 lastAlgorithm_ =1;2321 } 2322 if (problemStatus <0)2323 problemStatus =3;2298 if (modelPtr_>isDualObjectiveLimitReached()) 2299 problemStatus = 1; // infeasible 2300 } 2301 if (status && !problemStatus) { 2302 problemStatus = 3; // can't be sure 2303 lastAlgorithm_ = 1; 2304 } 2305 if (problemStatus < 0) 2306 problemStatus = 3; 2324 2307 modelPtr_>setProblemStatus(problemStatus); 2325 modelPtr_>setObjectiveValue(obj *modelPtr_>optimizationDirection());2326 double * 2327 const double * 2308 modelPtr_>setObjectiveValue(obj * modelPtr_>optimizationDirection()); 2309 double *solution = modelPtr_>primalColumnSolution(); 2310 const double *solution2 = modelPtr_>solutionRegion(); 2328 2311 // could just do changed bounds  also try double size scale so can use * not / 2329 2312 if (!columnScale) { 2330 for (iColumn =0;iColumn<numberColumns;iColumn++) {2331 solution[iColumn]= solution2[iColumn];2313 for (iColumn = 0; iColumn < numberColumns; iColumn++) { 2314 solution[iColumn] = solution2[iColumn]; 2332 2315 } 2333 2316 } else { 2334 for (iColumn =0;iColumn<numberColumns;iColumn++) {2335 solution[iColumn]= solution2[iColumn]*columnScale[iColumn];2336 } 2337 } 2338 CoinMemcpyN(saveLowerOriginal, numberColumns,columnLower);2339 CoinMemcpyN(saveUpperOriginal, numberColumns,columnUpper);2317 for (iColumn = 0; iColumn < numberColumns; iColumn++) { 2318 solution[iColumn] = solution2[iColumn] * columnScale[iColumn]; 2319 } 2320 } 2321 CoinMemcpyN(saveLowerOriginal, numberColumns, columnLower); 2322 CoinMemcpyN(saveUpperOriginal, numberColumns, columnUpper); 2340 2323 #if 0 2341 2324 // could combine with loop above … … 2356 2339 #endif 2357 2340 // and back bounds 2358 CoinMemcpyN(saveLower, number,modelPtr_>lowerRegion());2359 CoinMemcpyN(saveUpper, number,modelPtr_>upperRegion());2341 CoinMemcpyN(saveLower, number, modelPtr_>lowerRegion()); 2342 CoinMemcpyN(saveUpper, number, modelPtr_>upperRegion()); 2360 2343 if (extraCopy) { 2361 CoinMemcpyN(saveLower, number,modelPtr_>lowerRegion()+extraCopy);2362 CoinMemcpyN(saveUpper, number,modelPtr_>upperRegion()+extraCopy);2363 } 2364 modelPtr_>setIntParam(ClpMaxNumIteration, itlimOrig_);2344 CoinMemcpyN(saveLower, number, modelPtr_>lowerRegion() + extraCopy); 2345 CoinMemcpyN(saveUpper, number, modelPtr_>upperRegion() + extraCopy); 2346 } 2347 modelPtr_>setIntParam(ClpMaxNumIteration, itlimOrig_); 2365 2348 if (savedObjective) { 2366 2349 // fix up 2367 modelPtr_>dblParam_[ClpDualObjectiveLimit] =savedDualLimit;2350 modelPtr_>dblParam_[ClpDualObjectiveLimit] = savedDualLimit; 2368 2351 //modelPtr_>setMoreSpecialOptions(modelPtr_>moreSpecialOptions()&(~32)); 2369 modelPtr_>objective_ =savedObjective;2352 modelPtr_>objective_ = savedObjective; 2370 2353 if (!modelPtr_>problemStatus_) { 2371 CoinZeroN(modelPtr_>dual_,modelPtr_>numberRows_);2372 CoinZeroN(modelPtr_>reducedCost_,modelPtr_>numberColumns_);2373 if (modelPtr_>dj_&&(modelPtr_>whatsChanged_&1)!=0)2374 CoinZeroN(modelPtr_>dj_,modelPtr_>numberColumns_+modelPtr_>numberRows_);2375 2354 CoinZeroN(modelPtr_>dual_, modelPtr_>numberRows_); 2355 CoinZeroN(modelPtr_>reducedCost_, modelPtr_>numberColumns_); 2356 if (modelPtr_>dj_ && (modelPtr_>whatsChanged_ & 1) != 0) 2357 CoinZeroN(modelPtr_>dj_, modelPtr_>numberColumns_ + modelPtr_>numberRows_); 2358 modelPtr_>computeObjectiveValue(); 2376 2359 } 2377 2360 } … … 2379 2362 } 2380 2363 #endif 2381 if (smallModel_ ==NULL) {2364 if (smallModel_ == NULL) { 2382 2365 setWarmStart(ws_); 2383 CoinMemcpyN( rowActivity_,numberRows,modelPtr_>primalRowSolution());2384 CoinMemcpyN(columnActivity_, numberColumns,modelPtr_>primalColumnSolution());2385 modelPtr_>setIntParam(ClpMaxNumIteration, CoinMin(itlim,9999));2366 CoinMemcpyN(rowActivity_, numberRows, modelPtr_>primalRowSolution()); 2367 CoinMemcpyN(columnActivity_, numberColumns, modelPtr_>primalColumnSolution()); 2368 modelPtr_>setIntParam(ClpMaxNumIteration, CoinMin(itlim, 9999)); 2386 2369 resolve(); 2387 2370 } else { 2388 assert 2389 double * arrayD = reinterpret_cast<double *>(spareArrays_);2371 assert(spareArrays_); 2372 double *arrayD = reinterpret_cast< double * >(spareArrays_); 2390 2373 double saveObjectiveValue = arrayD[0]; 2391 double * saveSolution = arrayD+1;2374 double *saveSolution = arrayD + 1; 2392 2375 // double check arrays exist (? for nonlinear) 2393 2376 //if (!smallModel_>solutionRegion()) … … 2395 2378 int numberRows2 = smallModel_>numberRows(); 2396 2379 int numberColumns2 = smallModel_>numberColumns(); 2397 int number = numberRows2 +numberColumns2;2398 CoinMemcpyN(saveSolution, number,smallModel_>solutionRegion());2399 double * saveLower = saveSolution + (numberRows+numberColumns);2400 CoinMemcpyN(saveLower, number,smallModel_>lowerRegion());2401 double * saveUpper = saveLower + (numberRows+numberColumns);2402 CoinMemcpyN(saveUpper, number,smallModel_>upperRegion());2403 double * saveObjective = saveUpper + (numberRows+numberColumns);2404 CoinMemcpyN(saveObjective, number,smallModel_>costRegion());2405 double * saveLowerOriginal = saveObjective + (numberRows+numberColumns);2406 double * 2380 int number = numberRows2 + numberColumns2; 2381 CoinMemcpyN(saveSolution, number, smallModel_>solutionRegion()); 2382 double *saveLower = saveSolution + (numberRows + numberColumns); 2383 CoinMemcpyN(saveLower, number, smallModel_>lowerRegion()); 2384 double *saveUpper = saveLower + (numberRows + numberColumns); 2385 CoinMemcpyN(saveUpper, number, smallModel_>upperRegion()); 2386 double *saveObjective = saveUpper + (numberRows + numberColumns); 2387 CoinMemcpyN(saveObjective, number, smallModel_>costRegion()); 2388 double *saveLowerOriginal = saveObjective + (numberRows + numberColumns); 2389 double *saveUpperOriginal = saveLowerOriginal + numberColumns; 2407 2390 arrayD = saveUpperOriginal + numberColumns; 2408 int * savePivot = reinterpret_cast<int *>(arrayD);2409 CoinMemcpyN(savePivot, numberRows2,smallModel_>pivotVariable());2410 int * whichRow = savePivot+numberRows;2411 int * whichColumn = whichRow + 3*numberRows;2412 int * arrayI = whichColumn + 2*numberColumns;2413 unsigned char * saveStatus = reinterpret_cast<unsigned char *> (arrayI+1);2414 CoinMemcpyN(saveStatus, number,smallModel_>statusArray());2391 int *savePivot = reinterpret_cast< int * >(arrayD); 2392 CoinMemcpyN(savePivot, numberRows2, smallModel_>pivotVariable()); 2393 int *whichRow = savePivot + numberRows; 2394 int *whichColumn = whichRow + 3 * numberRows; 2395 int *arrayI = whichColumn + 2 * numberColumns; 2396 unsigned char *saveStatus = reinterpret_cast< unsigned char * >(arrayI + 1); 2397 CoinMemcpyN(saveStatus, number, smallModel_>statusArray()); 2415 2398 /* If factorization_ NULL then infeasible 2416 2399 not really sure how could have slipped through. 2417 2400 But this can't make situation worse */ 2418 if (factorization_) 2401 if (factorization_) 2419 2402 smallModel_>setFactorization(*factorization_); 2420 2403 //int * backColumn = whichColumn+numberColumns; 2421 const double * 2422 const double * 2404 const double *lowerBig = modelPtr_>columnLower(); 2405 const double *upperBig = modelPtr_>columnUpper(); 2423 2406 // make sure whatsChanged_ has 1 set 2424 2407 smallModel_>setWhatsChanged(511); 2425 double * 2426 double * 2427 double * 2428 double * 2429 double * 2408 double *lowerSmall = smallModel_>lowerRegion(); 2409 double *upperSmall = smallModel_>upperRegion(); 2410 double *solutionSmall = smallModel_>solutionRegion(); 2411 double *lowerSmallReal = smallModel_>columnLower(); 2412 double *upperSmallReal = smallModel_>columnUpper(); 2430 2413 int i; 2431 2414 double rhsScale = smallModel_>rhsScale(); 2432 const double * 2433 const double * 2434 if (smallModel_>scalingFlag() >0) {2415 const double *columnScale = NULL; 2416 const double *rowScale = NULL; 2417 if (smallModel_>scalingFlag() > 0) { 2435 2418 columnScale = smallModel_>columnScale(); 2436 2419 rowScale = smallModel_>rowScale(); … … 2438 2421 // and do bounds in case dual needs them 2439 2422 // may be infeasible 2440 for (i =0;i<numberColumns2;i++) {2423 for (i = 0; i < numberColumns2; i++) { 2441 2424 int iColumn = whichColumn[i]; 2442 if (lowerBig[iColumn] >saveLowerOriginal[iColumn]) {2425 if (lowerBig[iColumn] > saveLowerOriginal[iColumn]) { 2443 2426 double value = lowerBig[iColumn]; 2444 lowerSmallReal[i] =value;2427 lowerSmallReal[i] = value; 2445 2428 value *= rhsScale; 2446 2429 if (columnScale) 2447 2430 value /= columnScale[i]; 2448 lowerSmall[i] =value;2449 if (smallModel_>getColumnStatus(i)==ClpSimplex::atLowerBound)2450 solutionSmall[i]=value;2451 } 2452 if (upperBig[iColumn] <saveUpperOriginal[iColumn]) {2431 lowerSmall[i] = value; 2432 if (smallModel_>getColumnStatus(i) == ClpSimplex::atLowerBound) 2433 solutionSmall[i] = value; 2434 } 2435 if (upperBig[iColumn] < saveUpperOriginal[iColumn]) { 2453 2436 double value = upperBig[iColumn]; 2454 upperSmallReal[i] =value;2437 upperSmallReal[i] = value; 2455 2438 value *= rhsScale; 2456 2439 if (columnScale) 2457 2440 value /= columnScale[i]; 2458 upperSmall[i] =value;2459 if (smallModel_>getColumnStatus(i)==ClpSimplex::atUpperBound)2460 solutionSmall[i]=value;2461 } 2462 if (upperSmall[i] <lowerSmall[i]1.0e8)2463 2441 upperSmall[i] = value; 2442 if (smallModel_>getColumnStatus(i) == ClpSimplex::atUpperBound) 2443 solutionSmall[i] = value; 2444 } 2445 if (upperSmall[i] < lowerSmall[i]  1.0e8) 2446 break; 2464 2447 } 2465 2448 /* If factorization_ NULL then infeasible 2466 2449 not really sure how could have slipped through. 2467 2450 But this can't make situation worse */ 2468 bool infeasible = (i <numberColumns2!factorization_);2451 bool infeasible = (i < numberColumns2  !factorization_); 2469 2452 // Start of fast iterations 2470 bool alwaysFinish = ((specialOptions_&32)==0) ? true : false;2453 bool alwaysFinish = ((specialOptions_ & 32) == 0) ? true : false; 2471 2454 //smallModel_>setLogLevel(1); 2472 smallModel_>setIntParam(ClpMaxNumIteration, itlim);2473 int saveNumberFake = (static_cast< ClpSimplexDual *>(smallModel_))>numberFake_;2455 smallModel_>setIntParam(ClpMaxNumIteration, itlim); 2456 int saveNumberFake = (static_cast< ClpSimplexDual * >(smallModel_))>numberFake_; 2474 2457 int status; 2475 2458 if (!infeasible) { 2476 if ((modelPtr_>specialOptions()&0x011200000)==0x11200000) {2477 smallModel_>specialOptions_=2097152;2478 2479 delete[] modelPtr_>ray_;2480 delete[] smallModel_>ray_;2481 modelPtr_>ray_=NULL;2482 smallModel_>ray_=NULL;2483 } 2484 status = static_cast< ClpSimplexDual *>(smallModel_)>fastDual(alwaysFinish);2485 if ((modelPtr_>specialOptions()&0x011200000)==0x11200000&&smallModel_>ray_) {2486 if (smallModel_>sequenceOut_<smallModel_>numberColumns_) 2487 2488 2489 modelPtr_>sequenceOut_ = whichRow[smallModel_>sequenceOut_smallModel_>numberColumns_]+modelPtr_>numberColumns_;2490 2491 2492 double scaleFactor=1.0;2493 if (smallModel_>sequenceOut_<smallModel_>numberColumns_) 2494 2495 2496 smallModel_>ray_[i] *= smallModel_>rowScale_[i]*scaleFactor;2497 2498 2499 } 2459 if ((modelPtr_>specialOptions() & 0x011200000) == 0x11200000) { 2460 smallModel_>specialOptions_ = 2097152; 2461 //smallModel_>specialOptions_&=~2097152; 2462 delete[] modelPtr_>ray_; 2463 delete[] smallModel_>ray_; 2464 modelPtr_>ray_ = NULL; 2465 smallModel_>ray_ = NULL; 2466 } 2467 status = static_cast< ClpSimplexDual * >(smallModel_)>fastDual(alwaysFinish); 2468 if ((modelPtr_>specialOptions() & 0x011200000) == 0x11200000 && smallModel_>ray_) { 2469 if (smallModel_>sequenceOut_ < smallModel_>numberColumns_) 2470 modelPtr_>sequenceOut_ = whichColumn[smallModel_>sequenceOut_]; 2471 else 2472 modelPtr_>sequenceOut_ = whichRow[smallModel_>sequenceOut_  smallModel_>numberColumns_] + modelPtr_>numberColumns_; 2473 if (smallModel_>rowScale_) { 2474 // scale ray 2475 double scaleFactor = 1.0; 2476 if (smallModel_>sequenceOut_ < smallModel_>numberColumns_) 2477 scaleFactor = smallModel_>columnScale_[smallModel_>sequenceOut_]; 2478 for (int i = 0; i < smallModel_>numberRows_; i++) { 2479 smallModel_>ray_[i] *= smallModel_>rowScale_[i] * scaleFactor; 2480 } 2481 } 2482 } 2500 2483 } else { 2501 status =0;2484 status = 0; 2502 2485 smallModel_>setProblemStatus(1); 2503 2486 } 2504 (static_cast< ClpSimplexDual *>(smallModel_))>numberFake_ = saveNumberFake;2505 if (smallModel_>numberIterations() ==98) {2487 (static_cast< ClpSimplexDual * >(smallModel_))>numberFake_ = saveNumberFake; 2488 if (smallModel_>numberIterations() == 98) { 2506 2489 printf("rrrrrrrrrrrr\n"); 2507 2490 smallModel_>checkPrimalSolution(smallModel_>solutionRegion(0), 2508 2491 smallModel_>solutionRegion(1)); 2509 2492 //smallModel_>gutsOfSolution(NULL,NULL,0); 2510 2493 //if (problemStatus==3) 2511 2494 //smallModel_>computeObjectiveValue(); 2512 printf("robj %g\n",smallModel_>objectiveValue() * 2513 modelPtr_>optimizationDirection()); 2495 printf("robj %g\n", smallModel_>objectiveValue() * modelPtr_>optimizationDirection()); 2514 2496 writeMps("rr.mps"); 2515 2497 smallModel_>writeMps("rr_small.mps"); … … 2520 2502 double limit = 0.0; 2521 2503 modelPtr_>getDblParam(ClpDualObjectiveLimit, limit); 2522 if (temp.problemStatus() ==0&&temp.objectiveValue()<limit) {2523 printf("inf obj %g, true %g  offsets %g %g\n",smallModel_>objectiveValue(),2524 2525 smallModel_>objectiveOffset(),temp.objectiveOffset());2504 if (temp.problemStatus() == 0 && temp.objectiveValue() < limit) { 2505 printf("inf obj %g, true %g  offsets %g %g\n", smallModel_>objectiveValue(), 2506 temp.objectiveValue(), 2507 smallModel_>objectiveOffset(), temp.objectiveOffset()); 2526 2508 } 2527 2509 printf("big\n"); 2528 2510 temp = *modelPtr_; 2529 2511 temp.dual(); 2530 if (temp.problemStatus() ==0&&temp.objectiveValue()<limit) {2531 printf("inf obj %g, true %g  offsets %g %g\n",smallModel_>objectiveValue(),2532 2533 smallModel_>objectiveOffset(),temp.objectiveOffset());2512 if (temp.problemStatus() == 0 && temp.objectiveValue() < limit) { 2513 printf("inf obj %g, true %g  offsets %g %g\n", smallModel_>objectiveValue(), 2514 temp.objectiveValue(), 2515 smallModel_>objectiveOffset(), temp.objectiveOffset()); 2534 2516 } 2535 2517 } 2536 2518 int problemStatus = smallModel_>problemStatus(); 2537 double objectiveValue = smallModel_>objectiveValue() * modelPtr_>optimizationDirection();2538 CoinAssert (smallModel_>problemStatus()smallModel_>objectiveValue()<1.0e50);2519 double objectiveValue = smallModel_>objectiveValue() * modelPtr_>optimizationDirection(); 2520 CoinAssert(smallModel_>problemStatus()  smallModel_>objectiveValue() < 1.0e50); 2539 2521 // make sure plausible 2540 double obj = CoinMax(objectiveValue, saveObjectiveValue);2541 if (problemStatus ==10problemStatus<0) {2522 double obj = CoinMax(objectiveValue, saveObjectiveValue); 2523 if (problemStatus == 10  problemStatus < 0) { 2542 2524 // was trying to clean up or something odd 2543 if (problemStatus ==10)2544 lastAlgorithm_ =1; // so won't fail on cutoff (in CbcNode)2545 status =1;2525 if (problemStatus == 10) 2526 lastAlgorithm_ = 1; // so won't fail on cutoff (in CbcNode) 2527 status = 1; 2546 2528 } 2547 2529 if (status) { 2548 2530 // not finished  might be optimal 2549 2531 smallModel_>checkPrimalSolution(smallModel_>solutionRegion(0), 2550 2532 smallModel_>solutionRegion(1)); 2551 2533 //smallModel_>gutsOfSolution(NULL,NULL,0); 2552 2534 //if (problemStatus==3) 2553 2535 //smallModel_>computeObjectiveValue(); 2554 objectiveValue =smallModel_>objectiveValue() * 2555 modelPtr_>optimizationDirection(); 2556 if (problemStatus!=10) 2557 obj = CoinMax(objectiveValue,saveObjectiveValue); 2558 if (!smallModel_>numberDualInfeasibilities()) { 2536 objectiveValue = smallModel_>objectiveValue() * modelPtr_>optimizationDirection(); 2537 if (problemStatus != 10) 2538 obj = CoinMax(objectiveValue, saveObjectiveValue); 2539 if (!smallModel_>numberDualInfeasibilities()) { 2559 2540 double limit = 0.0; 2560 2541 modelPtr_>getDblParam(ClpDualObjectiveLimit, limit); 2561 if (smallModel_>secondaryStatus() ==1&&!problemStatus&&obj<limit) {2542 if (smallModel_>secondaryStatus() == 1 && !problemStatus && obj < limit) { 2562 2543 #if 0 2563 2544 // switch off … … 2573 2554 problemStatus=10; 2574 2555 #else 2575 obj =limit;2576 problemStatus =3;2556 obj = limit; 2557 problemStatus = 3; 2577 2558 #endif 2578 2559 } 2579 if (!smallModel_>numberPrimalInfeasibilities() &&obj<limit) {2580 problemStatus =0;2560 if (!smallModel_>numberPrimalInfeasibilities() && obj < limit) { 2561 problemStatus = 0; 2581 2562 #if 0 2582 2563 ClpSimplex temp = *smallModel_; … … 2586 2567 assert (temp.problemStatus()==0&&temp.objectiveValue()<limit); 2587 2568 #endif 2588 } else if (problemStatus ==10) {2589 problemStatus =3;2569 } else if (problemStatus == 10) { 2570 problemStatus = 3; 2590 2571 } else if (!smallModel_>numberPrimalInfeasibilities()) { 2591 problemStatus =1; // infeasible2592 } 2572 problemStatus = 1; // infeasible 2573 } 2593 2574 } else { 2594 2575 // can't say much 2595 2576 //if (problemStatus==3) 2596 2577 //smallModel_>computeObjectiveValue(); 2597 lastAlgorithm_ =1; // so won't fail on cutoff (in CbcNode)2598 problemStatus =3;2578 lastAlgorithm_ = 1; // so won't fail on cutoff (in CbcNode) 2579 problemStatus = 3; 2599 2580 } 2600 2581 } else if (!problemStatus) { 2601 if (smallModel_>isDualObjectiveLimitReached()) 2602 problemStatus =1; // infeasible2603 } 2604 if (status &&!problemStatus) {2605 problemStatus =3; // can't be sure2606 lastAlgorithm_ =1;2607 } 2608 if (problemStatus <0)2609 problemStatus =3;2582 if (smallModel_>isDualObjectiveLimitReached()) 2583 problemStatus = 1; // infeasible 2584 } 2585 if (status && !problemStatus) { 2586 problemStatus = 3; // can't be sure 2587 lastAlgorithm_ = 1; 2588 } 2589 if (problemStatus < 0) 2590 problemStatus = 3; 2610 2591 modelPtr_>setProblemStatus(problemStatus); 2611 modelPtr_>setObjectiveValue(obj *modelPtr_>optimizationDirection());2592 modelPtr_>setObjectiveValue(obj * modelPtr_>optimizationDirection()); 2612 2593 modelPtr_>setSumDualInfeasibilities(smallModel_>sumDualInfeasibilities()); 2613 2594 modelPtr_>setNumberDualInfeasibilities(smallModel_>numberDualInfeasibilities()); 2614 2595 modelPtr_>setSumPrimalInfeasibilities(smallModel_>sumPrimalInfeasibilities()); 2615 2596 modelPtr_>setNumberPrimalInfeasibilities(smallModel_>numberPrimalInfeasibilities()); 2616 double * 2617 const double * 2618 double * 2597 double *solution = modelPtr_>primalColumnSolution(); 2598 const double *solution2 = smallModel_>solutionRegion(); 2599 double *djs = modelPtr_>dualColumnSolution(); 2619 2600 if (!columnScale) { 2620 for (i =0;i<numberColumns2;i++) {2601 for (i = 0; i < numberColumns2; i++) { 2621 2602 int iColumn = whichColumn[i]; 2622 solution[iColumn] = solution2[i];2623 lowerSmallReal[i] =saveLowerOriginal[iColumn];2624 upperSmallReal[i] =saveUpperOriginal[iColumn];2603 solution[iColumn] = solution2[i]; 2604 lowerSmallReal[i] = saveLowerOriginal[iColumn]; 2605 upperSmallReal[i] = saveUpperOriginal[iColumn]; 2625 2606 } 2626 2607 } else { 2627 for (i =0;i<numberColumns2;i++) {2608 for (i = 0; i < numberColumns2; i++) { 2628 2609 int iColumn = whichColumn[i]; 2629 solution[iColumn] = solution2[i]*columnScale[i];2630 lowerSmallReal[i] =saveLowerOriginal[iColumn];2631 upperSmallReal[i] =saveUpperOriginal[iColumn];2610 solution[iColumn] = solution2[i] * columnScale[i]; 2611 lowerSmallReal[i] = saveLowerOriginal[iColumn]; 2612 upperSmallReal[i] = saveUpperOriginal[iColumn]; 2632 2613 } 2633 2614 } 2634 2615 // compute duals and djs 2635 double * 2636 const double * 2616 double *dual = modelPtr_>dualRowSolution(); 2617 const double *dual2 = smallModel_>dualRowSolution(); 2637 2618 if (!rowScale) { 2638 for (i =0;i<numberRows2;i++) {2619 for (i = 0; i < numberRows2; i++) { 2639 2620 int iRow = whichRow[i]; 2640 dual[iRow] = dual2[i];2621 dual[iRow] = dual2[i]; 2641 2622 } 2642 2623 } else { 2643 for (i =0;i<numberRows2;i++) {2624 for (i = 0; i < numberRows2; i++) { 2644 2625 int iRow = whichRow[i]; 2645 dual[iRow] = dual2[i]*rowScale[i];2646 } 2647 } 2648 memcpy(djs, modelPtr_>objective(),numberColumns*sizeof(double));2649 modelPtr_>clpMatrix()>transposeTimes(1.0, dual,djs);2626 dual[iRow] = dual2[i] * rowScale[i]; 2627 } 2628 } 2629 memcpy(djs, modelPtr_>objective(), numberColumns * sizeof(double)); 2630 modelPtr_>clpMatrix()>transposeTimes(1.0, dual, djs); 2650 2631 // could combine with loop above 2651 if (modelPtr_ ==smallModel_)2632 if (modelPtr_ == smallModel_) 2652 2633 modelPtr_>computeObjectiveValue(); 2653 if (problemStatus ==1&&smallModel_>ray_) {2654 delete 2634 if (problemStatus == 1 && smallModel_>ray_) { 2635 delete[] modelPtr_>ray_; 2655 2636 // get ray to full problem 2656 2637 int numberRows = modelPtr_>numberRows(); 2657 2638 int numberRows2 = smallModel_>numberRows(); 2658 int nCopy = 3 *numberRows+2*numberColumns;2639 int nCopy = 3 * numberRows + 2 * numberColumns; 2659 2640 int nBound = whichRow[nCopy]; 2660 double * ray = new double[numberRows];2661 memset(ray, 0,numberRows*sizeof(double));2641 double *ray = new double[numberRows]; 2642 memset(ray, 0, numberRows * sizeof(double)); 2662 2643 for (int i = 0; i < numberRows2; i++) { 2663 2664 2644 int iRow = whichRow[i]; 2645 ray[iRow] = smallModel_>ray_[i]; 2665 2646 } 2666 2647 // Column copy of matrix 2667 const double * 2668 const int * 2669 const CoinBigIndex * 2670 const int * 2648 const double *element = getMatrixByCol()>getElements(); 2649 const int *row = getMatrixByCol()>getIndices(); 2650 const CoinBigIndex *columnStart = getMatrixByCol()>getVectorStarts(); 2651 const int *columnLength = getMatrixByCol()>getVectorLengths(); 2671 2652 // translate 2672 2653 for (int jRow = nBound; jRow < 2 * numberRows; jRow++) { 2673 int iRow = whichRow[jRow]; 2674 int iColumn = whichRow[jRow+numberRows]; 2675 if (modelPtr_>getColumnStatus(iColumn) == ClpSimplex::basic) { 2676 double value = 0.0; 2677 double sum = 0.0; 2678 for (CoinBigIndex j = columnStart[iColumn]; 2679 j < columnStart[iColumn] + columnLength[iColumn]; j++) { 2680 if (iRow == row[j]) { 2681 value = element[j]; 2682 } else { 2683 sum += ray[row[j]]*element[j]; 2684 } 2685 } 2686 ray[iRow] = sum / value; 2687 } 2688 } 2689 for (int i=0;i<modelPtr_>numberColumns_;i++) { 2690 if (modelPtr_>getStatus(i)!=ClpSimplex::basic&& 2691 modelPtr_>columnLower_[i]==modelPtr_>columnUpper_[i]) 2692 modelPtr_>setStatus(i,ClpSimplex::isFixed); 2693 } 2694 modelPtr_>ray_=ray; 2654 int iRow = whichRow[jRow]; 2655 int iColumn = whichRow[jRow + numberRows]; 2656 if (modelPtr_>getColumnStatus(iColumn) == ClpSimplex::basic) { 2657 double value = 0.0; 2658 double sum = 0.0; 2659 for (CoinBigIndex j = columnStart[iColumn]; 2660 j < columnStart[iColumn] + columnLength[iColumn]; j++) { 2661 if (iRow == row[j]) { 2662 value = element[j]; 2663 } else { 2664 sum += ray[row[j]] * element[j]; 2665 } 2666 } 2667 ray[iRow] = sum / value; 2668 } 2669 } 2670 for (int i = 0; i < modelPtr_>numberColumns_; i++) { 2671 if (modelPtr_>getStatus(i) != ClpSimplex::basic && modelPtr_>columnLower_[i] == modelPtr_>columnUpper_[i]) 2672 modelPtr_>setStatus(i, ClpSimplex::isFixed); 2673 } 2674 modelPtr_>ray_ = ray; 2695 2675 //delete [] smallModel_>ray_; 2696 2676 //smallModel_>ray_=NULL; 2697 modelPtr_>directionOut_ =smallModel_>directionOut_;2698 lastAlgorithm_ =2; // dual2677 modelPtr_>directionOut_ = smallModel_>directionOut_; 2678 lastAlgorithm_ = 2; // dual 2699 2679 } 2700 2680 #if 1 2701 if (status &&!problemStatus) {2702 memset(modelPtr_>primalRowSolution(), 0,numberRows*sizeof(double));2703 modelPtr_>clpMatrix()>times(1.0, solution,modelPtr_>primalRowSolution());2681 if (status && !problemStatus) { 2682 memset(modelPtr_>primalRowSolution(), 0, numberRows * sizeof(double)); 2683 modelPtr_>clpMatrix()>times(1.0, solution, modelPtr_>primalRowSolution()); 2704 2684 modelPtr_>checkSolutionInternal(); 2705 2685 //modelPtr_>setLogLevel(1); … … 2709 2689 //modelPtr_>clpMatrix()>times(1.0,solution,modelPtr_>primalRowSolution()); 2710 2690 //modelPtr_>checkSolutionInternal(); 2711 assert 2691 assert(!modelPtr_>problemStatus()); 2712 2692 } 2713 2693 #endif 2714 2694 modelPtr_>setNumberIterations(smallModel_>numberIterations()); 2715 2695 // and back bounds 2716 CoinMemcpyN(saveLower, number,smallModel_>lowerRegion());2717 CoinMemcpyN(saveUpper, number,smallModel_>upperRegion());2696 CoinMemcpyN(saveLower, number, smallModel_>lowerRegion()); 2697 CoinMemcpyN(saveUpper, number, smallModel_>upperRegion()); 2718 2698 } 2719 2699 if (savedObjective) { 2720 2700 // fix up 2721 modelPtr_>dblParam_[ClpDualObjectiveLimit] =savedDualLimit;2701 modelPtr_>dblParam_[ClpDualObjectiveLimit] = savedDualLimit; 2722 2702 //modelPtr_>setMoreSpecialOptions(modelPtr_>moreSpecialOptions()&(~32)); 2723 modelPtr_>objective_ =savedObjective;2703 modelPtr_>objective_ = savedObjective; 2724 2704 if (!modelPtr_>problemStatus_) { 2725 CoinZeroN(modelPtr_>dual_, modelPtr_>numberRows_);2726 CoinZeroN(modelPtr_>reducedCost_, modelPtr_>numberColumns_);2727 if (modelPtr_>dj_ &&(modelPtr_>whatsChanged_&1)!=0)2728 CoinZeroN(modelPtr_>dj_,modelPtr_>numberColumns_+modelPtr_>numberRows_);2705 CoinZeroN(modelPtr_>dual_, modelPtr_>numberRows_); 2706 CoinZeroN(modelPtr_>reducedCost_, modelPtr_>numberColumns_); 2707 if (modelPtr_>dj_ && (modelPtr_>whatsChanged_ & 1) != 0) 2708 CoinZeroN(modelPtr_>dj_, modelPtr_>numberColumns_ + modelPtr_>numberRows_); 2729 2709 modelPtr_>computeObjectiveValue(); 2730 2710 } 2731 2711 } 2732 modelPtr_>setIntParam(ClpMaxNumIteration, itlimOrig_);2712 modelPtr_>setIntParam(ClpMaxNumIteration, itlimOrig_); 2733 2713 } 2734 2714 … … 2736 2716 { 2737 2717 #ifdef CLEAN_HOT_START 2738 if ((specialOptions_ &65536)!=0) {2718 if ((specialOptions_ & 65536) != 0) { 2739 2719 modelPtr_>setLogLevel(saveData_.scalingFlag_); 2740 2720 modelPtr_>deleteRim(0); 2741 if (lastNumberRows_ <0) {2721 if (lastNumberRows_ < 0) { 2742 2722 specialOptions_ = 131072; 2743 lastNumberRows_ = 1  lastNumberRows_;2723 lastNumberRows_ = 1  lastNumberRows_; 2744 2724 if (modelPtr_>rowScale_) { 2745 if (modelPtr_>rowScale_!=rowScale_.array()) {2746 delete[] modelPtr_>rowScale_;2747 delete[] modelPtr_>columnScale_;2748 2749 modelPtr_>rowScale_=NULL;2750 modelPtr_>columnScale_=NULL;2725 if (modelPtr_>rowScale_ != rowScale_.array()) { 2726 delete[] modelPtr_>rowScale_; 2727 delete[] modelPtr_>columnScale_; 2728 } 2729 modelPtr_>rowScale_ = NULL; 2730 modelPtr_>columnScale_ = NULL; 2751 2731 } 2752 2732 } 2753 2733 delete factorization_; 2754 delete 2755 smallModel_ =NULL;2756 spareArrays_ =NULL;2757 factorization_ =NULL;2758 delete 2759 delete 2760 rowActivity_ =NULL;2761 columnActivity_ =NULL;2734 delete[] spareArrays_; 2735 smallModel_ = NULL; 2736 spareArrays_ = NULL; 2737 factorization_ = NULL; 2738 delete[] rowActivity_; 2739 delete[] columnActivity_; 2740 rowActivity_ = NULL; 2741 columnActivity_ = NULL; 2762 2742 return; 2763 2743 } 2764 2744 #endif 2765 if (smallModel_ ==NULL) {2745 if (smallModel_ == NULL) { 2766 2746 setWarmStart(ws_); 2767 2747 int numberRows = modelPtr_>numberRows(); 2768 2748 int numberColumns = modelPtr_>numberColumns(); 2769 CoinMemcpyN( rowActivity_,numberRows,modelPtr_>primalRowSolution());2770 CoinMemcpyN(columnActivity_, numberColumns,modelPtr_>primalColumnSolution());2749 CoinMemcpyN(rowActivity_, numberRows, modelPtr_>primalRowSolution()); 2750 CoinMemcpyN(columnActivity_, numberColumns, modelPtr_>primalColumnSolution()); 2771 2751 delete ws_; 2772 2752 ws_ = NULL; 2773 2753 } else { 2774 2754 #ifndef KEEP_SMALL 2775 if (smallModel_ !=modelPtr_)2755 if (smallModel_ != modelPtr_) 2776 2756 delete smallModel_; 2777 smallModel_ =NULL;2757 smallModel_ = NULL; 2778 2758 #else 2779 if (smallModel_ ==modelPtr_) {2780 smallModel_ =NULL;2759 if (smallModel_ == modelPtr_) { 2760 smallModel_ = NULL; 2781 2761 } else if (smallModel_) { 2782 if (!spareArrays_) {2783 2784 smallModel_=NULL;2785 2786 factorization_=NULL;2762 if (!spareArrays_) { 2763 delete smallModel_; 2764 smallModel_ = NULL; 2765 delete factorization_; 2766 factorization_ = NULL; 2787 2767 } else { 2788 static_cast<ClpSimplexDual *> (smallModel_)>cleanupAfterStrongBranching(factorization_);2789 if ((smallModel_>specialOptions_&4096)==0) {2790 2791 2768 static_cast< ClpSimplexDual * >(smallModel_)>cleanupAfterStrongBranching(factorization_); 2769 if ((smallModel_>specialOptions_ & 4096) == 0) { 2770 delete factorization_; 2771 } 2792 2772 } 2793 2773 } … … 2795 2775 //delete [] spareArrays_; 2796 2776 //spareArrays_=NULL; 2797 factorization_ =NULL;2798 } 2799 delete 2800 delete 2801 rowActivity_ =NULL;2802 columnActivity_ =NULL;2777 factorization_ = NULL; 2778 } 2779 delete[] rowActivity_; 2780 delete[] columnActivity_; 2781 rowActivity_ = NULL; 2782 columnActivity_ = NULL; 2803 2783 // Make sure whatsChanged not out of sync 2804 2784 if (!modelPtr_>columnUpperWork_) 2805 2785 modelPtr_>whatsChanged_ &= ~0xffff; 2806 modelPtr_>specialOptions_ = saveData_.specialOptions_; 2807 } 2808 2809 #ifdef CONFLICT_CUTS 2786 modelPtr_>specialOptions_ = saveData_.specialOptions_; 2787 } 2788 2789 #ifdef CONFLICT_CUTS 2810 2790 // Return a conflict analysis cut from small model 2811 OsiRowCut * 2812 OsiClpSolverInterface::smallModelCut(const double * originalLower, const double *originalUpper,2813 int numberRowsAtContinuous,const int *whichGenerator,2814 2815 { 2816 if (smallModel_&&smallModel_>ray_) {2791 OsiRowCut * 2792 OsiClpSolverInterface::smallModelCut(const double *originalLower, const double *originalUpper, 2793 int numberRowsAtContinuous, const int *whichGenerator, 2794 int typeCut) 2795 { 2796 if (smallModel_ && smallModel_>ray_) { 2817 2797 //printf("Could do small cut\n"); 2818 2798 int numberRows = modelPtr_>numberRows(); … … 2820 2800 int numberColumns = modelPtr_>numberColumns(); 2821 2801 int numberColumns2 = smallModel_>numberColumns(); 2822 double * arrayD = reinterpret_cast<double *>(spareArrays_);2823 double * saveSolution = arrayD+1;2824 double * saveLower = saveSolution + (numberRows+numberColumns);2825 double * saveUpper = saveLower + (numberRows+numberColumns);2826 double * saveObjective = saveUpper + (numberRows+numberColumns);2827 double * saveLowerOriginal = saveObjective + (numberRows+numberColumns);2828 double * 2802 double *arrayD = reinterpret_cast< double * >(spareArrays_); 2803 double *saveSolution = arrayD + 1; 2804 double *saveLower = saveSolution + (numberRows + numberColumns); 2805 double *saveUpper = saveLower + (numberRows + numberColumns); 2806 double *saveObjective = saveUpper + (numberRows + numberColumns); 2807 double *saveLowerOriginal = saveObjective + (numberRows + numberColumns); 2808 double *saveUpperOriginal = saveLowerOriginal + numberColumns; 2829 2809 //double * lowerOriginal = modelPtr_>columnLower(); 2830 2810 //double * upperOriginal = modelPtr_>columnUpper(); 2831 int * savePivot = reinterpret_cast<int *>(saveUpperOriginal + numberColumns);2832 int * whichRow = savePivot+numberRows;2833 int * whichColumn = whichRow + 3*numberRows;2834 int nCopy = 3 *numberRows+2*numberColumns;2811 int *savePivot = reinterpret_cast< int * >(saveUpperOriginal + numberColumns); 2812 int *whichRow = savePivot + numberRows; 2813 int *whichColumn = whichRow + 3 * numberRows; 2814 int nCopy = 3 * numberRows + 2 * numberColumns; 2835 2815 int nBound = whichRow[nCopy]; 2836 if (smallModel_>sequenceOut_ >=0&&smallModel_>sequenceOut_<numberColumns2)2816 if (smallModel_>sequenceOut_ >= 0 && smallModel_>sequenceOut_ < numberColumns2) 2837 2817 modelPtr_>sequenceOut_ = whichColumn[smallModel_>sequenceOut_]; 2838 2818 else 2839 modelPtr_>sequenceOut_ = modelPtr_>numberColumns_ +whichRow[smallModel_>sequenceOut_];2840 unsigned char * 2841 numberRows+numberColumns);2819 modelPtr_>sequenceOut_ = modelPtr_>numberColumns_ + whichRow[smallModel_>sequenceOut_]; 2820 unsigned char *saveStatus = CoinCopyOfArray(modelPtr_>status_, 2821 numberRows + numberColumns); 2842 2822 // get ray to full problem 2843 2823 for (int i = 0; i < numberColumns2; i++) { … … 2845 2825 modelPtr_>setStatus(iColumn, smallModel_>getStatus(i)); 2846 2826 } 2847 double * ray = new double [numberRows+numberColumns2+numberColumns];2848 char * mark = new char[numberRows];2849 memset(ray, 0,(numberRows+numberColumns2+numberColumns)*sizeof(double));2850 double * smallFarkas = ray+numberRows;2851 double * farkas = smallFarkas+numberColumns2;2852 double * 2853 smallModel_>rowScale_ =NULL;2854 smallModel_>transposeTimes(1.0, smallModel_>ray_,smallFarkas);2855 smallModel_>rowScale_ =saveScale;2856 for (int i =0;i<numberColumns2;i++)2857 farkas[whichColumn[i]] =smallFarkas[i];2858 memset(mark, 0,numberRows);2827 double *ray = new double[numberRows + numberColumns2 + numberColumns]; 2828 char *mark = new char[numberRows]; 2829 memset(ray, 0, (numberRows + numberColumns2 + numberColumns) * sizeof(double)); 2830 double *smallFarkas = ray + numberRows; 2831 double *farkas = smallFarkas + numberColumns2; 2832 double *saveScale = smallModel_>rowScale_; 2833 smallModel_>rowScale_ = NULL; 2834 smallModel_>transposeTimes(1.0, smallModel_>ray_, smallFarkas); 2835 smallModel_>rowScale_ = saveScale; 2836 for (int i = 0; i < numberColumns2; i++) 2837 farkas[whichColumn[i]] = smallFarkas[i]; 2838 memset(mark, 0, numberRows); 2859 2839 for (int i = 0; i < numberRows2; i++) { 2860 2840 int iRow = whichRow[i]; 2861 2841 modelPtr_>setRowStatus(iRow, smallModel_>getRowStatus(i)); 2862 2842 ray[iRow] = smallModel_>ray_[i]; 2863 mark[iRow] =1;2843 mark[iRow] = 1; 2864 2844 } 2865 2845 // Column copy of matrix 2866 const double * 2867 const int * 2868 const CoinBigIndex * 2869 const int * 2846 const double *element = getMatrixByCol()>getElements(); 2847 const int *row = getMatrixByCol()>getIndices(); 2848 const CoinBigIndex *columnStart = getMatrixByCol()>getVectorStarts(); 2849 const int *columnLength = getMatrixByCol()>getVectorLengths(); 2870 2850 // pick up small pivot row 2871 2851 int pivotRow = smallModel_>spareIntArray_[3]; 2872 2852 // translate 2873 if (pivotRow >=0)2874 pivotRow =whichRow[pivotRow];2875 modelPtr_>spareIntArray_[3] =pivotRow;2853 if (pivotRow >= 0) 2854 pivotRow = whichRow[pivotRow]; 2855 modelPtr_>spareIntArray_[3] = pivotRow; 2876 2856 for (int jRow = nBound; jRow < 2 * numberRows; jRow++) { 2877 2857 int iRow = whichRow[jRow]; 2878 int iColumn = whichRow[jRow +numberRows];2858 int iColumn = whichRow[jRow + numberRows]; 2879 2859 if (modelPtr_>getColumnStatus(iColumn) == ClpSimplex::basic) { 2880 double value = 0.0; 2881 double sum = 0.0; 2882 for (CoinBigIndex j = columnStart[iColumn]; 2883 j < columnStart[iColumn] + columnLength[iColumn]; j++) { 2884 if (iRow == row[j]) { 2885 value = element[j]; 2886 } else if (mark[row[j]]) { 2887 sum += ray[row[j]]*element[j]; 2888 } 2889 } 2890 double target=farkas[iColumn]; 2891 if (iRow!=pivotRow) { 2892 ray[iRow] = (targetsum) / value; 2893 } else { 2894 printf("what now  direction %d wanted %g sum %g value %g\n", 2895 smallModel_>directionOut_,ray[iRow], 2896 sum,value); 2897 } 2898 mark[iRow]=1; 2899 } 2900 } 2901 delete [] mark; 2902 for (int i=0;i<modelPtr_>numberColumns_;i++) { 2903 if (modelPtr_>getStatus(i)!=ClpSimplex::basic&& 2904 modelPtr_>columnLower_[i]==modelPtr_>columnUpper_[i]) 2905 modelPtr_>setStatus(i,ClpSimplex::isFixed); 2860 double value = 0.0; 2861 double sum = 0.0; 2862 for (CoinBigIndex j = columnStart[iColumn]; 2863 j < columnStart[iColumn] + columnLength[iColumn]; j++) { 2864 if (iRow == row[j]) { 2865 value = element[j]; 2866 } else if (mark[row[j]]) { 2867 sum += ray[row[j]] * element[j]; 2868 } 2869 } 2870 double target = farkas[iColumn]; 2871 if (iRow != pivotRow) { 2872 ray[iRow] = (target  sum) / value; 2873 } else { 2874 printf("what now  direction %d wanted %g sum %g value %g\n", 2875 smallModel_>directionOut_, ray[iRow], 2876 sum, value); 2877 } 2878 mark[iRow] = 1; 2879 } 2880 } 2881 delete[] mark; 2882 for (int i = 0; i < modelPtr_>numberColumns_; i++) { 2883 if (modelPtr_>getStatus(i) != ClpSimplex::basic && modelPtr_>columnLower_[i] == modelPtr_>columnUpper_[i]) 2884 modelPtr_>setStatus(i, ClpSimplex::isFixed); 2906 2885 } 2907 2886 #if 0 … … 3025 3004 } 3026 3005 #endif 3027 modelPtr_>ray_ =ray;3028 lastAlgorithm_ =2;3029 modelPtr_>directionOut_ =smallModel_>directionOut_;3030 OsiRowCut * cut = modelCut(originalLower,originalUpper,3031 numberRowsAtContinuous,whichGenerator,typeCut);3006 modelPtr_>ray_ = ray; 3007 lastAlgorithm_ = 2; 3008 modelPtr_>directionOut_ = smallModel_>directionOut_; 3009 OsiRowCut *cut = modelCut(originalLower, originalUpper, 3010 numberRowsAtContinuous, whichGenerator, typeCut); 3032 3011 smallModel_>deleteRay(); 3033 memcpy(modelPtr_>status_, saveStatus,numberRows+numberColumns);3034 delete 3012 memcpy(modelPtr_>status_, saveStatus, numberRows + numberColumns); 3013 delete[] saveStatus; 3035 3014 if (cut) { 3036 3015 //printf("got small cut\n"); … … 3043 3022 } 3044 3023 } 3045 static int debugMode =0;3024 static int debugMode = 0; 3046 3025 // Return a conflict analysis cut from model 3047 3026 // If type is 0 then genuine cut, if 1 then only partially processed 3048 OsiRowCut * 3049 OsiClpSolverInterface::modelCut(const double * originalLower, const double *originalUpper,3050 int numberRowsAtContinuous,const int *whichGenerator,3051 3052 { 3053 OsiRowCut * cut=NULL;3027 OsiRowCut * 3028 OsiClpSolverInterface::modelCut(const double *originalLower, const double *originalUpper, 3029 int numberRowsAtContinuous, const int *whichGenerator, 3030 int typeCut) 3031 { 3032 OsiRowCut *cut = NULL; 3054 3033 //return NULL; 3055 if (modelPtr_>ray_) {3056 if (lastAlgorithm_ ==2) {3034 if (modelPtr_>ray_) { 3035 if (lastAlgorithm_ == 2) { 3057 3036 //printf("Could do normal cut\n"); 3058 3037 // could use existing arrays 3059 int numberRows =modelPtr_>numberRows_;3060 int numberColumns =modelPtr_>numberColumns_;3061 double * farkas = new double [2*numberColumns+numberRows];3062 double * 3063 double * 3064 /*const*/ double * 3038 int numberRows = modelPtr_>numberRows_; 3039 int numberColumns = modelPtr_>numberColumns_; 3040 double *farkas = new double[2 * numberColumns + numberRows]; 3041 double *bound = farkas + numberColumns; 3042 double *effectiveRhs = bound + numberColumns; 3043 /*const*/ double *ray = modelPtr_>ray_; 3065 3044 // have to get rid of local cut rows 3066 3045 whichGenerator = numberRowsAtContinuous; 3067 int badRows =0;3068 for (int iRow =numberRowsAtContinuous;iRow<numberRows;iRow++) {3069 int iType=whichGenerator[iRow];3070 if ((iType>=0&&iType<20000)) {3071 if (fabs(ray[iRow])>1.0e10) {3072 3073 3074 ray[iRow]=0.0;3075 3046 int badRows = 0; 3047 for (int iRow = numberRowsAtContinuous; iRow < numberRows; iRow++) { 3048 int iType = whichGenerator[iRow]; 3049 if ((iType >= 0 && iType < 20000)) { 3050 if (fabs(ray[iRow]) > 1.0e10) { 3051 badRows++; 3052 } 3053 ray[iRow] = 0.0; 3054 } 3076 3055 } 3077 3056 ClpSimplex debugModel; 3078 if ((debugMode &4)!=0)3079 3080 if (badRows &&(debugMode&1)!=0)3081 printf("%d rows from local cuts\n",badRows);3057 if ((debugMode & 4) != 0) 3058 debugModel = *modelPtr_; 3059 if (badRows && (debugMode & 1) != 0) 3060 printf("%d rows from local cuts\n", badRows); 3082 3061 // get farkas row 3083 ClpPackedMatrix * 3084 double * 3085 modelPtr_>rowScale_ =NULL;3086 modelPtr_>scaledMatrix_ =NULL;3087 memset(farkas, 0,(2*numberColumns+numberRows)*sizeof(double));3088 modelPtr_>transposeTimes(1.0, ray,farkas);3062 ClpPackedMatrix *saveMatrix = modelPtr_>scaledMatrix_; 3063 double *saveScale = modelPtr_>rowScale_; 3064 modelPtr_>rowScale_ = NULL; 3065 modelPtr_>scaledMatrix_ = NULL; 3066 memset(farkas, 0, (2 * numberColumns + numberRows) * sizeof(double)); 3067 modelPtr_>transposeTimes(1.0, ray, farkas); 3089 3068 //const char * integerInformation = modelPtr_>integerType_; 3090 3069 //assert (integerInformation); … … 3092 3071 int sequenceOut = modelPtr_>sequenceOut_; 3093 3072 // Put nonzero bounds in bound 3094 const double * 3095 const double * 3096 const double * 3097 int numberBad =0;3098 int nNonzeroBasic =0;3099 for (int i =0;i<numberColumns;i++) {3100 3101 double boundValue=0.0;3102 if (modelPtr_>getStatus(i)==ClpSimplex::basic) {3103 3104 if (fabs(value)<1.0e8) {3105 value=0.0;3106 farkas[i]=0.0;3107 3108 3109 3110 3111 3112 if (value<0.0) 3113 boundValue=columnLower[i];3114 3115 boundValue=columnUpper[i];3116 3117 } else if (fabs(value)>1.0e10) {3118 if (value<0.0) {3119 if (columnValue[i]>columnLower[i]+1.0e5&&value<1.0e7) {3120 3121 3122 3123 boundValue=columnLower[i];3124 3125 if (columnValue[i]<columnUpper[i]1.0e5&&value>1.0e7) {3126 3127 3128 3129 boundValue=columnUpper[i];3130 3131 3132 bound[i]=boundValue;3133 if (fabs(boundValue)>1.0e10)3134 3135 } 3136 const double * 3137 const double * 3073 const double *columnLower = modelPtr_>columnLower_; 3074 const double *columnUpper = modelPtr_>columnUpper_; 3075 const double *columnValue = modelPtr_>columnActivity_; 3076 int numberBad = 0; 3077 int nNonzeroBasic = 0; 3078 for (int i = 0; i < numberColumns; i++) { 3079 double value = farkas[i]; 3080 double boundValue = 0.0; 3081 if (modelPtr_>getStatus(i) == ClpSimplex::basic) { 3082 // treat as zero if small 3083 if (fabs(value) < 1.0e8) { 3084 value = 0.0; 3085 farkas[i] = 0.0; 3086 } 3087 if (value) { 3088 //printf("basic %d direction %d farkas %g\n", 3089 //i,modelPtr_>directionOut_,value); 3090 nNonzeroBasic++; 3091 if (value < 0.0) 3092 boundValue = columnLower[i]; 3093 else 3094 boundValue = columnUpper[i]; 3095 } 3096 } else if (fabs(value) > 1.0e10) { 3097 if (value < 0.0) { 3098 if (columnValue[i] > columnLower[i] + 1.0e5 && value < 1.0e7) { 3099 //printf("bad %d alpha %g not at lower\n",i,value); 3100 numberBad++; 3101 } 3102 boundValue = columnLower[i]; 3103 } else { 3104 if (columnValue[i] < columnUpper[i]  1.0e5 && value > 1.0e7) { 3105 //printf("bad %d alpha %g not at upper\n",i,value); 3106 numberBad++; 3107 } 3108 boundValue = columnUpper[i]; 3109 } 3110 } 3111 bound[i] = boundValue; 3112 if (fabs(boundValue) > 1.0e10) 3113 numberBad++; 3114 } 3115 const double *rowLower = modelPtr_>rowLower_; 3116 const double *rowUpper = modelPtr_>rowUpper_; 3138 3117 //int pivotRow = modelPtr_>spareIntArray_[3]; 3139 3118 //bool badPivot=pivotRow<0; 3140 for (int i =0;i<numberRows;i++) {3141 3142 double rhsValue=0.0;3143 if (modelPtr_>getRowStatus(i)==ClpSimplex::basic) {3144 3145 if (fabs(value)<1.0e8) {3146 value=0.0;3147 ray[i]=0.0;3148 3149 3150 3151 3152 3153 if (value<0.0) 3154 rhsValue=rowLower[i];3155 3156 rhsValue=rowUpper[i];3157 3158 } else if (fabs(value)>1.0e10) {3159 if (value<0.0) 3160 rhsValue=rowLower[i];3161 3162 rhsValue=rowUpper[i];3163 3164 effectiveRhs[i]=rhsValue;3119 for (int i = 0; i < numberRows; i++) { 3120 double value = ray[i]; 3121 double rhsValue = 0.0; 3122 if (modelPtr_>getRowStatus(i) == ClpSimplex::basic) { 3123 // treat as zero if small 3124 if (fabs(value) < 1.0e8) { 3125 value = 0.0; 3126 ray[i] = 0.0; 3127 } 3128 if (value) { 3129 //printf("row basic %d direction %d ray %g\n", 3130 // i,modelPtr_>directionOut_,value); 3131 nNonzeroBasic++; 3132 if (value < 0.0) 3133 rhsValue = rowLower[i]; 3134 else 3135 rhsValue = rowUpper[i]; 3136 } 3137 } else if (fabs(value) > 1.0e10) { 3138 if (value < 0.0) 3139 rhsValue = rowLower[i]; 3140 else 3141 rhsValue = rowUpper[i]; 3142 } 3143 effectiveRhs[i] = rhsValue; 3165 3144 } 3166 3145 { 3167 double bSum=0.0;3168 for (int i=0;i<numberRows;i++) {3169 bSum += effectiveRhs[i]*ray[i];3170 3171 3172 } 3173 modelPtr_>times(1.0, bound,effectiveRhs);3174 double bSum =0.0;3175 for (int i =0;i<numberRows;i++) {3176 bSum += effectiveRhs[i]*ray[i];3146 double bSum = 0.0; 3147 for (int i = 0; i < numberRows; i++) { 3148 bSum += effectiveRhs[i] * ray[i]; 3149 } 3150 //printf("before bounds  bSum %g\n",bSum); 3151 } 3152 modelPtr_>times(1.0, bound, effectiveRhs); 3153 double bSum = 0.0; 3154 for (int i = 0; i < numberRows; i++) { 3155 bSum += effectiveRhs[i] * ray[i]; 3177 3156 } 3178 3157 #if 0 … … 3215 3194 #endif 3216 3195 #endif 3217 modelPtr_>scaledMatrix_ =saveMatrix;3218 modelPtr_>rowScale_ =saveScale;3219 if (numberBad bSum>1.0e4/*nNonzeroBasic>1*/ /*bSum2>1.0e4*/) {3220 #if PRINT_CONFLICT >1 //ndef NDEBUG3221 3222 bSum,bSum2,numberBad,nNonzeroBasic);3196 modelPtr_>scaledMatrix_ = saveMatrix; 3197 modelPtr_>rowScale_ = saveScale; 3198 if (numberBad  bSum > 1.0e4 /*nNonzeroBasic>1*/ /*bSum2>1.0e4*/) { 3199 #if PRINT_CONFLICT > 1 //ndef NDEBUG 3200 printf("bad BOUND bSum %g (bSum2 %g)  %d bad  %d basic\n", 3201 bSum, bSum2, numberBad, nNonzeroBasic); 3223 3202 #endif 3224 3203 } else { 3225 if (numberColumns<0) 3226 debugMode=numberColumns; 3227 if ((debugMode&4)!=0) { 3228 int * tempC = new int[numberColumns]; 3229 double * temp = new double[numberColumns]; 3230 int n=0; 3231 for (int i=0;i<numberColumns;i++) { 3232 if (fabs(farkas[i])>1.0e12) { 3233 temp[n]=farkas[i]; 3234 tempC[n++]=i; 3235 } 3236 } 3237 debugModel.addRow(n,tempC,temp,bSum,bSum); 3238 delete [] tempC; 3239 delete [] temp; 3240 } 3241 if ((debugMode&2)!=0) { 3242 ClpSimplex dual=*modelPtr_; 3243 dual.setLogLevel(63); 3244 dual.scaling(0); 3245 dual.dual(); 3246 assert (dual.problemStatus_==1); 3247 if (dual.ray_) { 3248 double * farkas2 = dual.reducedCost_; 3249 // Put nonzero bounds in farkas 3250 const double * columnLower = dual.columnLower_; 3251 const double * columnUpper = dual.columnUpper_; 3252 for (int i=0;i<numberColumns;i++) { 3253 farkas2[i]=0.0; 3254 if (dual.getStatus(i)==ClpSimplex::atLowerBound 3255 columnLower[i]==columnUpper[i]) { 3256 farkas2[i]=columnLower[i]; 3257 } else if (dual.getStatus(i)==ClpSimplex::atUpperBound) { 3258 farkas2[i]=columnUpper[i]; 3259 } else if (i==dual.sequenceOut_) { 3260 if (dual.directionOut_<0) { 3261 // above upper bound 3262 farkas2[i]=columnUpper[i]; 3263 } else { 3264 // below lower bound 3265 farkas2[i]=columnLower[i]; 3266 } 3267 } else if (columnLower[i]==columnUpper[i]) { 3268 farkas2[i]=columnLower[i]; 3269 } 3270 } 3271 double * effectiveRhs2 = dual.rowActivity_; 3272 const double * rowLower = dual.rowLower_; 3273 const double * rowUpper = dual.rowUpper_; 3274 int pivotRow = dual.spareIntArray_[3]; 3275 for (int i=0;i<numberRows;i++) { 3276 if (dual.getRowStatus(i)==ClpSimplex::atLowerBound 3277 rowUpper[i]==rowLower[i] 3278 dual.getRowStatus(i)==ClpSimplex::isFixed) { 3279 effectiveRhs2[i]=rowLower[i]; 3280 } else if (dual.getRowStatus(i)==ClpSimplex::atUpperBound) { 3281 effectiveRhs2[i]=rowUpper[i]; 3282 } else { 3283 if (dual.getRowStatus(i)!=ClpSimplex::basic) { 3284 assert (rowUpper[i]>1.0e30rowLower[i]<1.0e30); // eventually skip 3285 if (rowUpper[i]<1.0e30) 3286 effectiveRhs2[i]=rowUpper[i]; 3287 else 3288 effectiveRhs2[i]=rowLower[i]; 3289 } 3290 } 3291 if (dual.getRowStatus(i)==ClpSimplex::basic) { 3292 effectiveRhs2[i]=0.0; 3293 // we should leave pivot row in and use direction for bound 3294 if (fabs(dual.ray_[i])>1.0e8) { 3295 printf("Basic slack value %g on %d  pivotRow %d\n",ray[i],i,pivotRow); 3296 if (i==pivotRow) { 3297 if (dual.directionOut_<0) 3298 effectiveRhs[i]=rowUpper[i]; 3299 else 3300 effectiveRhs[i]=rowLower[i]; 3301 } else { 3302 dual.ray_[i]=0.0; 3303 } 3304 } 3305 } 3306 } 3307 dual.times(1.0,farkas2,effectiveRhs2); 3308 double bSum2=0.0; 3309 for (int i=0;i<numberRows;i++) { 3310 bSum2 += effectiveRhs2[i]*dual.ray_[i]; 3311 } 3312 printf("Alternate bSum %g\n",bSum2); 3313 memset(farkas2,0,numberColumns*sizeof(double)); 3314 dual.transposeTimes(1.0,dual.ray_,farkas2); 3315 int nBad=0; 3316 double largest=1.0; 3317 double smallest=1.0e30; 3318 for (int i=0;i<numberColumns;i++) { 3319 //if (fabs(farkas[i])>1.0e12) 3320 //printf("%d ptr farkas %g dual farkas %g\n",i,farkas[i],farkas2[i]); 3321 if (fabs(farkas[i]farkas2[i])>1.0e7) { 3322 nBad++; 3323 largest=CoinMax(largest,fabs(farkas[i]farkas2[i])); 3324 smallest=CoinMin(smallest,fabs(farkas[i]farkas2[i])); 3325 //printf("%d ptr farkas %g dual farkas %g\n",i,farkas[i],farkas2[i]); 3326 } 3327 } 3328 if (nBad) 3329 printf("%d farkas difference %g to %g\n",nBad,smallest,largest); 3330 dual.primal(); 3331 assert (dual.problemStatus_==1); 3332 assert (!nBad); 3333 } 3334 } 3335 const char * integerInformation = modelPtr_>integerType_; 3336 assert (integerInformation); 3337 int * conflict = new int[numberColumns]; 3338 double * sort = new double [numberColumns]; 3339 double relax=0.0; 3340 int nConflict=0; 3341 int nOriginal=0; 3342 int nFixed=0; 3343 for (int iColumn=0;iColumn<numberColumns;iColumn++) { 3344 double thisRelax = 0.0; 3345 if (integerInformation[iColumn]) { 3346 if ((debugMode&1)!=0) 3347 printf("%d status %d %g <= %g <=%g (orig %g, %g) farkas %g\n", 3348 iColumn,modelPtr_>getStatus(iColumn),columnLower[iColumn], 3349 modelPtr_>columnActivity_[iColumn],columnUpper[iColumn], 3350 originalLower[iColumn],originalUpper[iColumn], 3351 farkas[iColumn]); 3352 double gap = originalUpper[iColumn]originalLower[iColumn]; 3353 if (!gap) 3354 continue; 3355 if (gap==columnUpper[iColumn]columnLower[iColumn]) 3356 nOriginal++; 3357 if (columnUpper[iColumn]==columnLower[iColumn]) 3358 nFixed++; 3359 if (fabs(farkas[iColumn])<1.0e15) { 3360 farkas[iColumn]=0.0; 3361 continue; 3362 } 3363 // temp 3364 if (gap>=20000.0&&false) { 3365 // can't use 3366 if (farkas[iColumn]<0.0) { 3367 assert(originalLower[iColumn]columnLower[iColumn]<=0.0); 3368 // farkas is negative  relax lower bound all way 3369 relax += 3370 farkas[iColumn]*(originalLower[iColumn]columnLower[iColumn]); 3371 } else { 3372 assert(originalUpper[iColumn]columnUpper[iColumn]>=0.0); 3373 // farkas is positive  relax upper bound all way 3374 relax += 3375 farkas[iColumn]*(originalUpper[iColumn]columnUpper[iColumn]); 3376 } 3377 continue; 3378 } 3379 if (originalLower[iColumn]==columnLower[iColumn]) { 3380 // may need to be careful if odd basic (due to local cut) 3381 if (farkas[iColumn]>0.0/*&&(modelPtr_>getStatus(iColumn)==ClpSimplex::atUpperBound 3204 if (numberColumns < 0) 3205 debugMode = numberColumns; 3206 if ((debugMode & 4) != 0) { 3207 int *tempC = new int[numberColumns]; 3208 double *temp = new double[numberColumns]; 3209 int n = 0; 3210 for (int i = 0; i < numberColumns; i++) { 3211 if (fabs(farkas[i]) > 1.0e12) { 3212 temp[n] = farkas[i]; 3213 tempC[n++] = i; 3214 } 3215 } 3216 debugModel.addRow(n, tempC, temp, bSum, bSum); 3217 delete[] tempC; 3218 delete[] temp; 3219 } 3220 if ((debugMode & 2) != 0) { 3221 ClpSimplex dual = *modelPtr_; 3222 dual.setLogLevel(63); 3223 dual.scaling(0); 3224 dual.dual(); 3225 assert(dual.problemStatus_ == 1); 3226 if (dual.ray_) { 3227 double *farkas2 = dual.reducedCost_; 3228 // Put nonzero bounds in farkas 3229 const double *columnLower = dual.columnLower_; 3230 const double *columnUpper = dual.columnUpper_; 3231 for (int i = 0; i < numberColumns; i++) { 3232 farkas2[i] = 0.0; 3233 if (dual.getStatus(i) == ClpSimplex::atLowerBound  columnLower[i] == columnUpper[i]) { 3234 farkas2[i] = columnLower[i]; 3235 } else if (dual.getStatus(i) == ClpSimplex::atUpperBound) { 3236 farkas2[i] = columnUpper[i]; 3237 } else if (i == dual.sequenceOut_) { 3238 if (dual.directionOut_ < 0) { 3239 // above upper bound 3240 farkas2[i] = columnUpper[i]; 3241 } else { 3242 // below lower bound 3243 farkas2[i] = columnLower[i]; 3244 } 3245 } else if (columnLower[i] == columnUpper[i]) { 3246 farkas2[i] = columnLower[i]; 3247 } 3248 } 3249 double *effectiveRhs2 = dual.rowActivity_; 3250 const double *rowLower = dual.rowLower_; 3251 const double *rowUpper = dual.rowUpper_; 3252 int pivotRow = dual.spareIntArray_[3]; 3253 for (int i = 0; i < numberRows; i++) { 3254 if (dual.getRowStatus(i) == ClpSimplex::atLowerBound  rowUpper[i] == rowLower[i]  dual.getRowStatus(i) == ClpSimplex::isFixed) { 3255 effectiveRhs2[i] = rowLower[i]; 3256 } else if (dual.getRowStatus(i) == ClpSimplex::atUpperBound) { 3257 effectiveRhs2[i] = rowUpper[i]; 3258 } else { 3259 if (dual.getRowStatus(i) != ClpSimplex::basic) { 3260 assert(rowUpper[i] > 1.0e30  rowLower[i] < 1.0e30); // eventually skip 3261 if (rowUpper[i] < 1.0e30) 3262 effectiveRhs2[i] = rowUpper[i]; 3263 else 3264 effectiveRhs2[i] = rowLower[i]; 3265 } 3266 } 3267 if (dual.getRowStatus(i) == ClpSimplex::basic) { 3268 effectiveRhs2[i] = 0.0; 3269 // we should leave pivot row in and use direction for bound 3270 if (fabs(dual.ray_[i]) > 1.0e8) { 3271 printf("Basic slack value %g on %d  pivotRow %d\n", ray[i], i, pivotRow); 3272 if (i == pivotRow) { 3273 if (dual.directionOut_ < 0) 3274 effectiveRhs[i] = rowUpper[i]; 3275 else 3276 effectiveRhs[i] = rowLower[i]; 3277 } else { 3278 dual.ray_[i] = 0.0; 3279 } 3280 } 3281 } 3282 } 3283 dual.times(1.0, farkas2, effectiveRhs2); 3284 double bSum2 = 0.0; 3285 for (int i = 0; i < numberRows; i++) { 3286 bSum2 += effectiveRhs2[i] * dual.ray_[i]; 3287 } 3288 printf("Alternate bSum %g\n", bSum2); 3289 memset(farkas2, 0, numberColumns * sizeof(double)); 3290 dual.transposeTimes(1.0, dual.ray_, farkas2); 3291 int nBad = 0; 3292 double largest = 1.0; 3293 double smallest = 1.0e30; 3294 for (int i = 0; i < numberColumns; i++) { 3295 //if (fabs(farkas[i])>1.0e12) 3296 //printf("%d ptr farkas %g dual farkas %g\n",i,farkas[i],farkas2[i]); 3297 if (fabs(farkas[i]  farkas2[i]) > 1.0e7) { 3298 nBad++; 3299 largest = CoinMax(largest, fabs(farkas[i]  farkas2[i])); 3300 smallest = CoinMin(smallest, fabs(farkas[i]  farkas2[i])); 3301 //printf("%d ptr farkas %g dual farkas %g\n",i,farkas[i],farkas2[i]); 3302 } 3303 } 3304 if (nBad) 3305 printf("%d farkas difference %g to %g\n", nBad, smallest, largest); 3306 dual.primal(); 3307 assert(dual.problemStatus_ == 1); 3308 assert(!nBad); 3309 } 3310 } 3311 const char *integerInformation = modelPtr_>integerType_; 3312 assert(integerInformation); 3313 int *conflict = new int[numberColumns]; 3314 double *sort = new double[numberColumns]; 3315 double relax = 0.0; 3316 int nConflict = 0; 3317 int nOriginal = 0; 3318 int nFixed = 0; 3319 for (int iColumn = 0; iColumn < numberColumns; iColumn++) { 3320 double thisRelax = 0.0; 3321 if (integerInformation[iColumn]) { 3322 if ((debugMode & 1) != 0) 3323 printf("%d status %d %g <= %g <=%g (orig %g, %g) farkas %g\n", 3324 iColumn, modelPtr_>getStatus(iColumn), columnLower[iColumn], 3325 modelPtr_>columnActivity_[iColumn], columnUpper[iColumn], 3326 originalLower[iColumn], originalUpper[iColumn], 3327 farkas[iColumn]); 3328 double gap = originalUpper[iColumn]  originalLower[iColumn]; 3329 if (!gap) 3330 continue; 3331 if (gap == columnUpper[iColumn]  columnLower[iColumn]) 3332 nOriginal++; 3333 if (columnUpper[iColumn] == columnLower[iColumn]) 3334 nFixed++; 3335 if (fabs(farkas[iColumn]) < 1.0e15) { 3336 farkas[iColumn] = 0.0; 3337 continue; 3338 } 3339 // temp 3340 if (gap >= 20000.0 && false) { 3341 // can't use 3342 if (farkas[iColumn] < 0.0) { 3343 assert(originalLower[iColumn]  columnLower[iColumn] <= 0.0); 3344 // farkas is negative  relax lower bound all way 3345 relax += farkas[iColumn] * (originalLower[iColumn]  columnLower[iColumn]); 3346 } else { 3347 assert(originalUpper[iColumn]  columnUpper[iColumn] >= 0.0); 3348 // farkas is positive  relax upper bound all way 3349 relax += farkas[iColumn] * (originalUpper[iColumn]  columnUpper[iColumn]); 3350 } 3351 continue; 3352 } 3353 if (originalLower[iColumn] == columnLower[iColumn]) { 3354 // may need to be careful if odd basic (due to local cut) 3355 if (farkas[iColumn] > 0.0 /*&&(modelPtr_>getStatus(iColumn)==ClpSimplex::atUpperBound 3382 3356 modelPtr_>getStatus(iColumn)==ClpSimplex::isFixed 3383 iColumn==sequenceOut)*/) { 3384 // farkas is positive  add to list 3385 gap=originalUpper[iColumn]columnUpper[iColumn]; 3386 if (gap) { 3387 sort[nConflict]=farkas[iColumn]*gap; 3388 conflict[nConflict++]=iColumn; 3389 } 3390 //assert (gap>columnUpper[iColumn]columnLower[iColumn]); 3391 } 3392 } else if (originalUpper[iColumn]==columnUpper[iColumn]) { 3393 // may need to be careful if odd basic (due to local cut) 3394 if (farkas[iColumn]<0.0/*&&(modelPtr_>getStatus(iColumn)==ClpSimplex::atLowerBound 3357 iColumn==sequenceOut)*/ 3358 ) { 3359 // farkas is positive  add to list 3360 gap = originalUpper[iColumn]  columnUpper[iColumn]; 3361 if (gap) { 3362 sort[nConflict] = farkas[iColumn] * gap; 3363 conflict[nConflict++] = iColumn; 3364 } 3365 //assert (gap>columnUpper[iColumn]columnLower[iColumn]); 3366 } 3367 } else if (originalUpper[iColumn] == columnUpper[iColumn]) { 3368 // may need to be careful if odd basic (due to local cut) 3369 if (farkas[iColumn] < 0.0 /*&&(modelPtr_>getStatus(iColumn)==ClpSimplex::atLowerBound 3395 3370 modelPtr_>getStatus(iColumn)==ClpSimplex::isFixed 3396 iColumn==sequenceOut)*/) { 3397 // farkas is negative  add to list 3398 gap=columnLower[iColumn]originalLower[iColumn]; 3399 if (gap) { 3400 sort[nConflict]=farkas[iColumn]*gap; 3401 conflict[nConflict++]=iColumn; 3402 } 3403 //assert (gap>columnUpper[iColumn]columnLower[iColumn]); 3404 } 3405 } else { 3406 // can't use 3407 if (farkas[iColumn]<0.0) { 3408 assert(originalLower[iColumn]columnLower[iColumn]<=0.0); 3409 // farkas is negative  relax lower bound all way 3410 thisRelax = 3411 farkas[iColumn]*(originalLower[iColumn]columnLower[iColumn]); 3412 } else { 3413 assert(originalUpper[iColumn]columnUpper[iColumn]>=0.0); 3414 // farkas is positive  relax upper bound all way 3415 thisRelax = 3416 farkas[iColumn]*(originalUpper[iColumn]columnUpper[iColumn]); 3417 } 3418 } 3419 } else { 3420 // not integer  but may have been got at 3421 double gap = originalUpper[iColumn]originalLower[iColumn]; 3422 if (gap>columnUpper[iColumn]columnLower[iColumn]) { 3423 // can't use 3424 if (farkas[iColumn]<0.0) { 3425 assert(originalLower[iColumn]columnLower[iColumn]<=0.0); 3426 // farkas is negative  relax lower bound all way 3427 thisRelax = 3428 farkas[iColumn]*(originalLower[iColumn]columnLower[iColumn]); 3429 } else { 3430 assert(originalUpper[iColumn]columnUpper[iColumn]>=0.0); 3431 // farkas is positive  relax upper bound all way 3432 thisRelax = 3433 farkas[iColumn]*(originalUpper[iColumn]columnUpper[iColumn]); 3434 } 3435 } 3436 } 3437 assert (thisRelax>=0.0); 3438 relax += thisRelax; 3439 } 3440 if (relax+bSum>1.0e4!nConflict) { 3441 if (relax+bSum>1.0e4) { 3442 #if PRINT_CONFLICT>1 //ndef NDEBUG 3443 printf("General integers relax bSum to %g\n",relax+bSum); 3444 #endif 3445 } else { 3371 iColumn==sequenceOut)*/ 3372 ) { 3373 // farkas is negative  add to list 3374 gap = columnLower[iColumn]  originalLower[iColumn]; 3375 if (gap) { 3376 sort[nConflict] = farkas[iColumn] * gap; 3377 conflict[nConflict++] = iColumn; 3378 } 3379 //assert (gap>columnUpper[iColumn]columnLower[iColumn]); 3380 } 3381 } else { 3382 // can't use 3383 if (farkas[iColumn] < 0.0) { 3384 assert(originalLower[iColumn]  columnLower[iColumn] <= 0.0); 3385 // farkas is negative  relax lower bound all way 3386 thisRelax = farkas[iColumn] * (originalLower[iColumn]  columnLower[iColumn]); 3387 } else { 3388 assert(originalUpper[iColumn]  columnUpper[iColumn] >= 0.0); 3389 // farkas is positive  relax upper bound all way 3390 thisRelax = farkas[iColumn] * (originalUpper[iColumn]  columnUpper[iColumn]); 3391 } 3392 } 3393 } else { 3394 // not integer  but may have been got at 3395 double gap = originalUpper[iColumn]  originalLower[iColumn]; 3396 if (gap > columnUpper[iColumn]  columnLower[iColumn]) { 3397 // can't use 3398 if (farkas[iColumn] < 0.0) { 3399 assert(originalLower[iColumn]  columnLower[iColumn] <= 0.0); 3400 // farkas is negative  relax lower bound all way 3401 thisRelax = farkas[iColumn] * (originalLower[iColumn]  columnLower[iColumn]); 3402 } else { 3403 assert(originalUpper[iColumn]  columnUpper[iColumn] >= 0.0); 3404 // farkas is positive  relax upper bound all way 3405 thisRelax = farkas[iColumn] * (originalUpper[iColumn]  columnUpper[iColumn]); 3406 } 3407 } 3408 } 3409 assert(thisRelax >= 0.0); 3410 relax += thisRelax; 3411 } 3412 if (relax + bSum > 1.0e4  !nConflict) { 3413 if (relax + bSum > 1.0e4) { 3414 #if PRINT_CONFLICT > 1 //ndef NDEBUG 3415 printf("General integers relax bSum to %g\n", relax + bSum); 3416 #endif 3417 } else { 3446 3418 #if PRINT_CONFLICT 3447 3448 #endif 3449 int nR=0;3450 for (int i=0;i<numberRows;i++) {3451 if (fabs(ray[i])>1.0e10)3452 3453 3454 ray[i]=0.0;3455 3456 int nC=0;3457 for (int i=0;i<numberColumns;i++) {3458 if (fabs(farkas[i])>1.0e10)3459 3460 3461 farkas[i]=0.0;3462 3463 if (nR<3&&nC<5) {3464 printf("BAD %d nonzero rows, %d nonzero columns\n",nR,nC);3465 3466 3467 3468 #if PRINT_CONFLICT >1 //ndef NDEBUG3469 if (nConflict<5)3470 printf("BOUNDS violation bSum %g (relaxed %g)  %d at original bounds, %d fixed  %d in conflict\n",bSum,3471 relax+bSum,nOriginal,nFixed,nConflict);3472 #endif 3473 CoinSort_2(sort,sort+nConflict,conflict);3474 if ((debugMode&4)!=0) {3475 double *temp = new double[numberColumns];3476 int *tempC = new int[numberColumns];3477 int n=0;3478 for (int j=0;j<nConflict;j++) {3479 int i=conflict[j];3480 if (fabs(farkas[i])>1.0e12) {3481 temp[n]=farkas[i];3482 tempC[n++]=i;3483 3484 3485 debugModel.addRow(n,tempC,temp,bSum,bSum);3486 delete[] tempC;3487 delete[] temp;3488 3489 int nC=nConflict;3490 for (int i=0;i<nConflict;i++) {3491 int iColumn=conflict[i];3492 if (fabs(sort[i])!=fabs(farkas[iColumn])&&originalUpper[iColumn]==1.0)3493 printf("odd %d %g %d %g\n",i,sort[i],iColumn,farkas[iColumn]);3494 3495 bSum+=relax;3496 3497 3498 double totalChange=0;3499 3500 double last = sort[nConflict1];3501 int kConflict=nConflict;3502 3503 double change = sort[kConflict1];3504 if (change>last+1.0e5)3505 3506 3507 3508 3509 if (bSum+totalChange>1.0e4)3510 3419 printf("All variables relaxed and still infeasible  what does this mean?\n"); 3420 #endif 3421 int nR = 0; 3422 for (int i = 0; i < numberRows; i++) { 3423 if (fabs(ray[i]) > 1.0e10) 3424 nR++; 3425 else 3426 ray[i] = 0.0; 3427 } 3428 int nC = 0; 3429 for (int i = 0; i < numberColumns; i++) { 3430 if (fabs(farkas[i]) > 1.0e10) 3431 nC++; 3432 else 3433 farkas[i] = 0.0; 3434 } 3435 if (nR < 3 && nC < 5) { 3436 printf("BAD %d nonzero rows, %d nonzero columns\n", nR, nC); 3437 } 3438 } 3439 } else if (nConflict < 1000) { 3440 #if PRINT_CONFLICT > 1 //ndef NDEBUG 3441 if (nConflict < 5) 3442 printf("BOUNDS violation bSum %g (relaxed %g)  %d at original bounds, %d fixed  %d in conflict\n", bSum, 3443 relax + bSum, nOriginal, nFixed, nConflict); 3444 #endif 3445 CoinSort_2(sort, sort + nConflict, conflict); 3446 if ((debugMode & 4) != 0) { 3447 double *temp = new double[numberColumns]; 3448 int *tempC = new int[numberColumns]; 3449 int n = 0; 3450 for (int j = 0; j < nConflict; j++) { 3451 int i = conflict[j]; 3452 if (fabs(farkas[i]) > 1.0e12) { 3453 temp[n] = farkas[i]; 3454 tempC[n++] = i; 3455 } 3456 } 3457 debugModel.addRow(n, tempC, temp, bSum, bSum); 3458 delete[] tempC; 3459 delete[] temp; 3460 } 3461 int nC = nConflict; 3462 for (int i = 0; i < nConflict; i++) { 3463 int iColumn = conflict[i]; 3464 if (fabs(sort[i]) != fabs(farkas[iColumn]) && originalUpper[iColumn] == 1.0) 3465 printf("odd %d %g %d %g\n", i, sort[i], iColumn, farkas[iColumn]); 3466 } 3467 bSum += relax; 3468 double saveBsum = bSum; 3469 // we can't use same values 3470 double totalChange = 0; 3471 while (nConflict) { 3472 double last = sort[nConflict  1]; 3473 int kConflict = nConflict; 3474 while (kConflict) { 3475 double change = sort[kConflict  1]; 3476 if (change > last + 1.0e5) 3477 break; 3478 totalChange += change; 3479 kConflict; 3480 } 3481 if (bSum + totalChange > 1.0e4) 3482 break; 3511 3483 #if 0 3512 3484 //int iColumn=conflict[nConflict1]; … … 3517 3489 bSum += change; 3518 3490 #else 3519 nConflict=kConflict;3520 3521 #endif 3522 3523 3524 int nR=0;3525 for (int i=0;i<numberRows;i++) {3526 if (fabs(ray[i])>1.0e10)3527 3528 3529 ray[i]=0.0;3530 3531 int nC=0;3532 for (int i=0;i<numberColumns;i++) {3533 if (fabs(farkas[i])>1.0e10)3534 3535 3536 farkas[i]=0.0;3537 3491 nConflict = kConflict; 3492 bSum += totalChange; 3493 #endif 3494 } 3495 if (!nConflict) { 3496 int nR = 0; 3497 for (int i = 0; i < numberRows; i++) { 3498 if (fabs(ray[i]) > 1.0e10) 3499 nR++; 3500 else 3501 ray[i] = 0.0; 3502 } 3503 int nC = 0; 3504 for (int i = 0; i < numberColumns; i++) { 3505 if (fabs(farkas[i]) > 1.0e10) 3506 nC++; 3507 else 3508 farkas[i] = 0.0; 3509 } 3538 3510 #if 1 //PRINT_CONFLICT>1 //ndef NDEBUG 3539 3540 printf("BAD2  zero nConflict %d nonzero rows, %d nonzero columns\n",nR,nC);3541 3542 #endif 3543 3544 3545 if (nConflict<nC+1&&nConflict<100&&nConflict) {3546 cut=new OsiRowCut();3547 3548 3549 double lo=1.0;3550 for (int i=0;i<nConflict;i++) {3551 3552 if (originalLower[iColumn]==columnLower[iColumn]) {3553 3554 sort[i]=1.0;3555 3556 3557 3558 sort[i]=1.0;3559 3560 3561 3562 3563 cut>setRow(nConflict,conflict,sort);3511 { 3512 printf("BAD2  zero nConflict %d nonzero rows, %d nonzero columns\n", nR, nC); 3513 } 3514 #endif 3515 } 3516 // no point doing if no reduction (or big?) ? 3517 if (nConflict < nC + 1 && nConflict < 100 && nConflict) { 3518 cut = new OsiRowCut(); 3519 cut>setUb(COIN_DBL_MAX); 3520 if (!typeCut) { 3521 double lo = 1.0; 3522 for (int i = 0; i < nConflict; i++) { 3523 int iColumn = conflict[i]; 3524 if (originalLower[iColumn] == columnLower[iColumn]) { 3525 // must be at least one higher 3526 sort[i] = 1.0; 3527 lo += originalLower[iColumn]; 3528 } else { 3529 // must be at least one lower 3530 sort[i] = 1.0; 3531 lo = originalUpper[iColumn]; 3532 } 3533 } 3534 cut>setLb(lo); 3535 cut>setRow(nConflict, conflict, sort); 3564 3536 #if PRINT_CONFLICT 3565 printf("CUT has %d (started at %d)  final bSum %g\n",nConflict,nC,bSum);3566 #endif 3567 if ((debugMode&4)!=0) {3568 debugModel.addRow(nConflict,conflict,sort,lo,COIN_DBL_MAX);3569 3570 3571 3572 3573 3574 int nC2=nC;3575 3576 3577 double change=sort[nC21];3578 <