Changes from stable/2.8/Cbc/src/CbcModel.cpp at r2088 to trunk/Cbc/src/CbcModel.cpp at r2106
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Cbc/src/CbcModel.cpp
r2088 r2106 62 62 #include "CbcFathom.hpp" 63 63 #include "CbcFullNodeInfo.hpp" 64 #ifdef COIN_HAS_NTY 65 #include "CbcSymmetry.hpp" 66 #endif 64 67 // include Probing 65 68 #include "CglProbing.hpp" … … 71 74 #include "CglStored.hpp" 72 75 #include "CglClique.hpp" 76 #include "CglKnapsackCover.hpp" 73 77 74 78 #include "CoinTime.hpp" … … 444 448 if (!numberContinuousObj && numberIntegerObj <= 5 && numberIntegerWeight <= 100 && 445 449 numberIntegerObj*3 < numberObjects_ && !parentModel_ && solver_>getNumRows() > 100) 446 iType = 1 + 4 + (( moreSpecialOptions_&536870912)==0) ? 2 : 0;450 iType = 1 + 4 + (((moreSpecialOptions_&536870912)==0) ? 2 : 0); 447 451 else if (!numberContinuousObj && numberIntegerObj <= 100 && 448 452 numberIntegerObj*5 < numberObjects_ && numberIntegerWeight <= 100 && 449 453 !parentModel_ && 450 454 solver_>getNumRows() > 100 && cost != COIN_DBL_MAX) 451 iType = 4 + (( moreSpecialOptions_&536870912)==0) ? 2 : 0;455 iType = 4 + (((moreSpecialOptions_&536870912)==0) ? 2 : 0); 452 456 else if (!numberContinuousObj && numberIntegerObj <= 100 && 453 457 numberIntegerObj*5 < numberObjects_ && … … 586 590 !numberContinuousObj && 587 591 !numberGeneralIntegerObj && 588 numberIntegerObj*2 < numberColumns) {592 numberIntegerObj*2 < CoinMin(numberColumns,20)) { 589 593 // up priorities on costed 590 594 int iPriority = 1; … … 597 601 } 598 602 if (iPriority >= 100) { 599 #if def CLP_INVESTIGATE603 #if CBC_USEFUL_PRINTING>1 600 604 printf("Setting variables with obj to high priority\n"); 601 605 #endif … … 1087 1091 int numberColumns = getNumCols(); 1088 1092 if (tryNewSearch) { 1089 #if def CLP_INVESTIGATE1093 #if CBC_USEFUL_PRINTING>1 1090 1094 printf("after %d nodes, cutoff %g  looking\n", 1091 1095 numberNodes_, getCutoff()); … … 1233 1237 int numberColumns = continuousSolver_>getNumCols(); 1234 1238 int numberRows = continuousSolver_>getNumRows(); 1239 int numberOriginalIntegers = numberIntegers_; 1235 1240 int * del = new int [CoinMax(numberColumns, numberRows)]; 1236 1241 int * original = new int [numberColumns]; 1237 int numberOriginalIntegers=numberIntegers_;1238 1242 char * possibleRow = new char [numberRows]; 1239 1243 { … … 1266 1270 j < rowStart[i] + rowLength[i]; j++) { 1267 1271 int iColumn = column[j]; 1268 double value = fabs(element[j]);1269 1272 if (continuousSolver_>isInteger(iColumn)) { 1270 if ( value!= 1.0)1273 if (fabs(element[j]) != 1.0) 1271 1274 possible = false; 1272 1275 } else { 1273 1276 nLeft++; 1274 if (value>100.0)1275 allSame=1.0; // not safe1276 1277 if (!allSame) { 1277 allSame = value;1278 allSame = fabs(element[j]); 1278 1279 } else if (allSame>0.0) { 1279 if (allSame!= value)1280 if (allSame!=fabs(element[j])) 1280 1281 allSame = 1.0; 1281 1282 } … … 1470 1471 int n = clpSolver>getModelPtr()>findNetwork(rotate, 1.0); 1471 1472 delete [] rotate; 1472 #if def CLP_INVESTIGATE1473 #if CBC_USEFUL_PRINTING>1 1473 1474 printf("INTA network %d rows out of %d\n", n, numberRows); 1474 1475 #endif … … 1478 1479 if (!possibleRow[i]) { 1479 1480 couldBeNetwork = false; 1480 #if def CLP_INVESTIGATE1481 #if CBC_USEFUL_PRINTING>1 1481 1482 printf("but row %d is bad\n", i); 1482 1483 #endif … … 1558 1559 assert(solver_>isInteger(i)); 1559 1560 } 1560 #if def CLP_INVESTIGATE1561 #if CBC_USEFUL_PRINTING>1 1561 1562 if (couldBeNetwork  nExtra) 1562 1563 printf("INTA %d extra integers, %d left%s\n", nExtra, … … 1567 1568 convertToDynamic(); 1568 1569 } 1569 #if def CLP_INVESTIGATE1570 #if CBC_USEFUL_PRINTING>1 1570 1571 if (!couldBeNetwork && copy1>getNumCols() && 1571 1572 copy1>getNumRows()) { … … 1601 1602 */ 1602 1603 1604 #ifdef CONFLICT_CUTS 1605 #if PRINT_CONFLICT==1 1606 static int numberConflictCuts=0; 1607 static int lastNumberConflictCuts=0; 1608 static double lengthConflictCuts=0.0; 1609 #endif 1610 #endif 1603 1611 /* 1604 1612 The overall flow can be divided into three stages: … … 1621 1629 1622 1630 { 1623 if (!parentModel_) 1624 /* 1625 Capture a time stamp before we start (unless set). 1626 */ 1627 if (!dblParam_[CbcStartSeconds]) { 1628 if (!useElapsedTime()) 1629 dblParam_[CbcStartSeconds] = CoinCpuTime(); 1630 else 1631 dblParam_[CbcStartSeconds] = CoinGetTimeOfDay(); 1631 if (!parentModel_) { 1632 /* 1633 Capture a time stamp before we start (unless set). 1634 */ 1635 if (!dblParam_[CbcStartSeconds]) { 1636 if (!useElapsedTime()) 1637 dblParam_[CbcStartSeconds] = CoinCpuTime(); 1638 else 1639 dblParam_[CbcStartSeconds] = CoinGetTimeOfDay(); 1640 } 1632 1641 } 1633 1642 dblParam_[CbcSmallestChange] = COIN_DBL_MAX; … … 2017 2026 ClpSimplex * clpSimplex = clpSolver>getModelPtr(); 2018 2027 if ((specialOptions_&32) == 0) { 2019 // take off names 2020 clpSimplex>dropNames(); 2028 // take off names (unless going to be saving) 2029 if (numberAnalyzeIterations_>=0(numberAnalyzeIterations_&64)==0) 2030 clpSimplex>dropNames(); 2021 2031 } 2022 2032 // no crunch if mostly continuous … … 2038 2048 #endif 2039 2049 bool feasible; 2050 numberSolves_ = 0 ; 2040 2051 { 2041 2052 // check … … 2050 2061 moreSpecialOptions_ = 1073741824; 2051 2062 } 2052 numberSolves_ = 0 ;2053 2063 // If NLP then we assume already solved outside branchAndbound 2054 2064 if (!solverCharacteristics_>solverType()  solverCharacteristics_>solverType() == 4) { … … 2224 2234 } 2225 2235 if (numberOdd) { 2226 if (numberHeuristics_) {2236 if (numberHeuristics_ && (specialOptions_&1024)==0 ) { 2227 2237 int k = 0; 2228 2238 for (int i = 0; i < numberHeuristics_; i++) { … … 2241 2251 // If odd switch off AddIntegers 2242 2252 specialOptions_ &= ~65536; 2253 // switch off fast nodes for now 2254 fastNodeDepth_ = 1; 2255 moreSpecialOptions_ &= ~33554432; // no diving 2243 2256 } else if (numberSOS) { 2244 2257 specialOptions_ = 128; // say can do SOS in dynamic mode … … 2249 2262 if (numberThreads_ > 0) { 2250 2263 // switch off fast nodes for now 2251 fastNodeDepth_ = 1;2264 //fastNodeDepth_ = 1; 2252 2265 } 2253 2266 } … … 2311 2324 constraint system (aka the continuous system). 2312 2325 */ 2326 delete continuousSolver_; 2313 2327 continuousSolver_ = solver_>clone() ; 2328 #ifdef COIN_HAS_NTY 2329 // maybe allow on fix and restart later 2330 if ((moreSpecialOptions2_&(128256))!=0&&!parentModel_) { 2331 symmetryInfo_ = new CbcSymmetry(); 2332 symmetryInfo_>setupSymmetry(*continuousSolver_); 2333 int numberGenerators = symmetryInfo_>statsOrbits(this,0); 2334 if (!symmetryInfo_>numberUsefulOrbits()&&(moreSpecialOptions2_&(128256))!=(128256)) { 2335 delete symmetryInfo_; 2336 symmetryInfo_=NULL; 2337 moreSpecialOptions2_ &= ~(128256); 2338 } 2339 if ((moreSpecialOptions2_&(128256))==(128256)) { 2340 //moreSpecialOptions2_ &= ~256; 2341 } 2342 } 2343 #endif 2314 2344 2315 2345 // add cutoff as constraint if wanted … … 2539 2569 } 2540 2570 } 2571 #ifdef SWITCH_VARIABLES 2572 // see if any switching variables 2573 if (numberIntegers_<solver_>getNumCols()) 2574 findSwitching(); 2575 #endif 2541 2576 /* 2542 2577 Run heuristics at the root. This is the only opportunity to run FPump; it … … 2579 2614 } 2580 2615 CoinWarmStartBasis * basis = dynamic_cast<CoinWarmStartBasis *> (solver_>getEmptyWarmStart()); 2581 int numberIterations=0;2582 2616 for (int i=0;i<numberModels;i++) { 2583 2617 rootModels[i]=new CbcModel(*this); … … 2590 2624 rootModels[i]>setSpecialOptions(specialOptions_ (41943048388608)); 2591 2625 rootModels[i]>setMoreSpecialOptions(moreSpecialOptions_ & 2592 (~134217728)); 2626 (~(1342177284194304))); 2627 rootModels[i]>setMoreSpecialOptions2(moreSpecialOptions2_ & 2628 (~(128256))); 2593 2629 rootModels[i]>solver_>setWarmStart(basis); 2594 2630 #ifdef COIN_HAS_CLP 2595 2631 OsiClpSolverInterface * clpSolver 2596 2632 = dynamic_cast<OsiClpSolverInterface *> (rootModels[i]>solver_); 2633 #define NEW_RANDOM_BASIS 2634 #ifdef NEW_RANDOM_BASIS 2635 if (i==0) 2636 continue; 2637 #endif 2597 2638 if (clpSolver) { 2598 2639 ClpSimplex * simplex = clpSolver>getModelPtr(); … … 2605 2646 simplex>setLogLevel(0); 2606 2647 if (i!=0) { 2648 #ifdef NEW_RANDOM_BASIS 2649 int numberRows = simplex>numberRows(); 2650 int throwOut=20;//2+numberRows/100; 2651 for (int iThrow=0;iThrow<throwOut;iThrow++) { 2652 double random = simplex>randomNumberGenerator()>randomDouble(); 2653 int iStart=static_cast<int>(random*numberRows); 2654 for (int j=iStart;j<numberRows;j++) { 2655 if (simplex>getRowStatus(j)!=ClpSimplex::basic) { 2656 simplex>setRowStatus(j,ClpSimplex::basic); 2657 break; 2658 } 2659 } 2660 } 2661 clpSolver>setWarmStart(NULL); 2662 #else 2607 2663 double random = simplex>randomNumberGenerator()>randomDouble(); 2608 2664 int bias = static_cast<int>(random*(numberIterations/4)); … … 2611 2667 simplex>setMaximumIterations(COIN_INT_MAX); 2612 2668 simplex>dual(); 2669 #endif 2613 2670 } else { 2671 #ifndef NEW_RANDOM_BASIS 2614 2672 simplex>primal(); 2615 numberIterations=simplex>numberIterations(); 2673 #endif 2674 #endif 2616 2675 } 2676 #ifdef NEW_RANDOM_BASIS 2617 2677 simplex>setLogLevel(logLevel); 2618 2678 clpSolver>setWarmStart(NULL); 2679 #endif 2619 2680 } 2620 #endif2621 2681 for (int j=0;j<numberHeuristics_;j++) 2622 2682 rootModels[i]>heuristic_[j]>setSeed(rootModels[i]>heuristic_[j]>getSeed()+100000000*i); … … 2853 2913 //rowCut.addCuts(globalCuts_); 2854 2914 int nTightened=0; 2855 assert 2915 assert(feasible); 2856 2916 { 2857 2917 double tolerance=1.0e5; … … 2859 2919 const double * upper = solver_>getColUpper(); 2860 2920 for (int i=0;i<numberColumns;i++) { 2861 if (tightBounds[2*i+0]>tightBounds[2*i+1] ) {2921 if (tightBounds[2*i+0]>tightBounds[2*i+1]+1.0e9) { 2862 2922 feasible=false; 2863 2923 char general[200]; … … 3486 3546 numberFixedAtRoot_ = 0; 3487 3547 numberFixedNow_ = 0; 3548 if (!parentModel_&&(moreSpecialOptions2_&2)!=0) { 3549 #ifdef COIN_HAS_CLP 3550 OsiClpSolverInterface * clpSolver 3551 = dynamic_cast<OsiClpSolverInterface *> (solver_); 3552 if (clpSolver) { 3553 if (getCutoff()>1.0e20) { 3554 printf("Zapping costs\n"); 3555 int numberColumns=solver_>getNumCols(); 3556 double * zeroCost = new double [numberColumns]; 3557 // could make small random 3558 memset(zeroCost,0,numberColumns*sizeof(double)); 3559 solver_>setObjective(zeroCost); 3560 double objValue = solver_>getObjValue(); 3561 solver_>setDblParam(OsiObjOffset,objValue); 3562 clpSolver>getModelPtr()>setObjectiveValue(objValue); 3563 delete [] zeroCost; 3564 } else { 3565 moreSpecialOptions2_ &= ~2; 3566 } 3567 } else { 3568 #endif 3569 moreSpecialOptions2_ &= ~2; 3570 #ifdef COIN_HAS_CLP 3571 } 3572 #endif 3573 } 3488 3574 int numberIterationsAtContinuous = numberIterations_; 3489 3575 //solverCharacteristics_>setSolver(solver_); 3490 3576 if (feasible) { 3577 // mark all cuts as globally valid 3578 int numberCuts=cuts.sizeRowCuts(); 3579 for (int i=0;i<numberCuts;i++) { 3580 cuts.rowCutPtr(i)>setGloballyValid(); 3581 whichGenerator_[i]=20000+(whichGenerator_[i]%10000); 3582 } 3491 3583 #define HOTSTART 1 3492 3584 #if HOTSTART<0 … … 3587 3679 } 3588 3680 } 3589 #if def CLP_INVESTIGATE3681 #if CBC_USEFUL_PRINTING>1 3590 3682 printf("%d forced, %d naturally at lower, %d at upper  %d zero dj\n", 3591 3683 nForced, nAtLbNatural, nAtUbNatural, nZeroDj); … … 3809 3901 int numberPassesLeft = 1000; 3810 3902 // This is first crude step 3811 if (numberAnalyzeIterations_ ) {3903 if (numberAnalyzeIterations_ && !parentModel_) { 3812 3904 delete [] analyzeResults_; 3813 analyzeResults_ = new double [4*numberIntegers_]; 3905 //int numberColumns = solver_>getNumCols(); 3906 analyzeResults_ = new double [5*numberIntegers_]; 3814 3907 numberFixedAtRoot_ = newNode>analyze(this, analyzeResults_); 3815 3908 if (numberFixedAtRoot_ > 0) { … … 3826 3919 } 3827 3920 OsiSolverBranch * branches = NULL; 3828 anyAction = chooseBranch(newNode, numberPassesLeft, NULL, cuts, resolved, 3921 if (feasible) 3922 anyAction = chooseBranch(newNode, numberPassesLeft, NULL, cuts, resolved, 3829 3923 NULL, NULL, NULL, branches); 3830 3924 if (anyAction == 2  newNode>objectiveValue() >= cutoff) { … … 3832 3926 // zap parent nodeInfo 3833 3927 #ifdef COIN_DEVELOP 3834 printf("zapping CbcNodeInfo %x\n", reinterpret_cast<int>(newNode>nodeInfo()>parent()));3928 printf("zapping CbcNodeInfo %x\n", newNode>nodeInfo()>parent()); 3835 3929 #endif 3836 3930 if (newNode>nodeInfo()) … … 3850 3944 if (toZero[number01]) { 3851 3945 CglTreeProbingInfo info(*probingInfo_); 3852 #ifdef JJF_ZERO 3853 /* 3854 Marginal idea. Further exploration probably good. Build some extra 3855 cliques from probing info. Not quite worth the effort? 3856 */ 3857 OsiSolverInterface * fake = info.analyze(*solver_, 1); 3858 if (fake) { 3859 fake>writeMps("fake"); 3946 if ((moreSpecialOptions2_&64)!=0&&!parentModel_) { 3947 /* 3948 Marginal idea. Further exploration probably good. Build some extra 3949 cliques from probing info. Not quite worth the effort? 3950 */ 3951 CglProbing generator1; 3952 generator1.setUsingObjective(false); 3953 generator1.setMaxPass(1); 3954 generator1.setMaxPassRoot(1); 3955 generator1.setMaxLook(100); 3956 generator1.setRowCuts(3); 3957 generator1.setMaxElements(300); 3958 generator1.setMaxProbeRoot(solver_>getNumCols()); 3959 CoinThreadRandom randomGenerator; 3960 //CglTreeProbingInfo info(solver_); 3961 info.level = 0; 3962 info.formulation_rows = solver_>getNumRows(); 3963 info.inTree = false; 3964 info.randomNumberGenerator=&randomGenerator; 3965 info.pass=4; 3966 generator1.setMode(8); 3967 OsiCuts cs; 3968 generator1.generateCutsAndModify(*solver_,cs,&info); 3969 // very clunky 3970 OsiSolverInterface * temp = generator1.cliqueModel(solver_,2); 3971 CglPreProcess dummy; 3972 OsiSolverInterface * newSolver=dummy.cliqueIt(*temp,0.0001); 3973 delete temp; 3974 OsiSolverInterface * fake = NULL; 3975 if (newSolver) { 3976 #if 0 3977 int numberCliques = generator1.numberCliques(); 3978 cliqueEntry * entry = generator1.cliqueEntry(); 3979 cliqueType * type = new cliqueType [numberCliques]; 3980 int * start = new int [numberCliques+1]; 3981 start[numberCliques]=2*numberCliques; 3982 int n=0; 3983 for (int i=0;i<numberCliques;i++) { 3984 start[i]=2*i; 3985 setOneFixesInCliqueEntry(entry[2*i],true); 3986 setOneFixesInCliqueEntry(entry[2*i+1],true); 3987 type[i]=0; 3988 } 3989 fake = info.analyze(*solver_, 1,numberCliques,start, 3990 entry,type); 3991 delete [] type; 3992 delete [] entry; 3993 #else 3994 fake = info.analyze(*newSolver, 1,1); 3995 #endif 3996 delete newSolver; 3997 } else { 3998 fake = info.analyze(*solver_, 1); 3999 } 4000 if (fake) { 4001 //fake>writeMps("fake"); 3860 4002 CglFakeClique cliqueGen(fake); 3861 4003 cliqueGen.setStarCliqueReport(false); … … 3864 4006 addCutGenerator(&cliqueGen, 1, "Fake cliques", true, false, false, 200); 3865 4007 generator_[numberCutGenerators_1]>setTiming(true); 3866 } 3867 #endif 4008 for (int i = 0; i < numberCutGenerators_; i++) { 4009 CglKnapsackCover * cutGen = 4010 dynamic_cast<CglKnapsackCover *>(generator_[i]>generator()); 4011 if (cutGen) { 4012 cutGen>createCliques(*fake,2,200,false); 4013 } 4014 } 4015 } 4016 } 3868 4017 if (probingInfo_>packDown()) { 3869 #if def CLP_INVESTIGATE4018 #if CBC_USEFUL_PRINTING>1 3870 4019 printf("%d implications on %d 01\n", toZero[number01], number01); 3871 4020 #endif … … 3874 4023 addCutGenerator(&implication, 1, "ImplicationCuts", true, false, false, 200); 3875 4024 generator_[numberCutGenerators_1]>setGlobalCuts(true); 4025 generator_[numberCutGenerators_1]>setTiming(true); 3876 4026 } else { 3877 4027 delete probingInfo_; … … 3891 4041 assert (!newNode  newNode>objectiveValue() <= cutoff) ; 3892 4042 // Save address of root node as we don't want to delete it 3893 // initialize for print out3894 int lastDepth = 0;3895 int lastUnsatisfied = 0;3896 if (newNode)3897 lastUnsatisfied = newNode>numberUnsatisfied();3898 4043 /* 3899 4044 The common case is that the lp relaxation is feasible but doesn't satisfy … … 4113 4258 ClpSimplex * simplex = clpSolver>getModelPtr(); 4114 4259 int perturbation = simplex>perturbation(); 4115 #if def CLP_INVESTIGATE4260 #if CBC_USEFUL_PRINTING>1 4116 4261 printf("Testing its n,s %d %d solves n,s %d %d  pert %d\n", 4117 4262 numberIterations_, saveNumberIterations, … … 4122 4267 // switch off perturbation 4123 4268 simplex>setPerturbation(100); 4124 #if def CLP_INVESTIGATE4269 #if CBC_USEFUL_PRINTING>1 4125 4270 printf("Perturbation switched off\n"); 4126 4271 #endif … … 4136 4281 int numberColumns = getNumCols(); 4137 4282 if (tryNewSearch) { 4138 checkCutoffForRestart = getCutoff() ; 4139 #ifdef CLP_INVESTIGATE 4283 // adding increment back allows current best  tiny bit weaker 4284 checkCutoffForRestart = getCutoff() + getCutoffIncrement() ; 4285 #if CBC_USEFUL_PRINTING>1 4140 4286 printf("after %d nodes, cutoff %g  looking\n", 4141 4287 numberNodes_, getCutoff()); … … 4214 4360 tryNewSearch = false; 4215 4361 } 4362 #ifdef CONFLICT_CUTS 4363 // temporary 4364 if ((moreSpecialOptions_&4194304)!=0) 4365 tryNewSearch=false; 4366 #endif 4216 4367 if (tryNewSearch) { 4217 4368 // back to solver without cuts? … … 4346 4497 break; 4347 4498 } 4499 // add as global cut 4500 objLower[i]=COIN_DBL_MAX; 4501 OsiRowCut rc; 4502 rc.setLb(newLower[i]); 4503 rc.setUb(COIN_DBL_MAX); 4504 double one=1.0; 4505 rc.setRow(1,integerVariable_+i,&one,false); 4506 rc.setGloballyValidAsInteger(2); 4507 globalCuts_.addCutIfNotDuplicate(rc) ; 4348 4508 } else if (objUpper[i] > newCutoff) { 4349 4509 n++; 4510 // add as global cut 4511 objUpper[i]=COIN_DBL_MAX; 4512 OsiRowCut rc; 4513 rc.setLb(COIN_DBL_MAX); 4514 rc.setUb(newUpper[i]); 4515 double one=1.0; 4516 rc.setRow(1,integerVariable_+i,&one,false); 4517 rc.setGloballyValidAsInteger(2); 4518 globalCuts_.addCutIfNotDuplicate(rc) ; 4350 4519 } 4351 4520 } … … 4436 4605 #endif 4437 4606 unlockThread(); 4438 #if def CLP_INVESTIGATE4607 #if CBC_USEFUL_PRINTING>1 4439 4608 if (getCutoff() < 1.0e20) { 4440 4609 if (fabs(getCutoff()  (bestObjective_  getCutoffIncrement())) > 1.0e6 && … … 4454 4623 messageHandler()>message(CBC_STATUS2, messages()) 4455 4624 << numberNodes_ << nNodes << bestObjective_ << bestPossibleObjective_ 4456 << lastDepth << lastUnsatisfied << numberIterations_ 4625 << tree_>lastDepth() << tree_>lastUnsatisfied() 4626 << tree_>lastObjective() << numberIterations_ 4457 4627 << getCurrentSeconds() 4458 4628 << CoinMessageEol ; … … 4460 4630 messageHandler()>message(CBC_STATUS2, messages()) 4461 4631 << numberNodes_ << nNodes << bestObjective_ << bestPossibleObjective_ 4462 << lastDepth << lastUnsatisfied<< numberIterations_4632 << tree_>lastDepth() << tree_>lastUnsatisfied() << numberIterations_ 4463 4633 << getCurrentSeconds() 4464 4634 << CoinMessageEol ; 4465 4635 } else { 4466 4636 messageHandler()>message(CBC_STATUS3, messages()) 4467 << numberNodes_ << numberExtraNodes_ << nNodes << bestObjective_ << bestPossibleObjective_ 4468 << lastDepth << lastUnsatisfied << numberIterations_ << numberExtraIterations_ 4637 << numberNodes_ << numberFathoms_ << numberExtraNodes_ << nNodes 4638 << bestObjective_ << bestPossibleObjective_ 4639 << tree_>lastDepth() << tree_>lastUnsatisfied() << numberIterations_ << numberExtraIterations_ 4469 4640 << getCurrentSeconds() 4470 4641 << CoinMessageEol ; 4471 4642 } 4643 #ifdef COIN_HAS_NTY 4644 if (symmetryInfo_) 4645 symmetryInfo_>statsOrbits(this,1); 4646 #endif 4647 #if PRINT_CONFLICT==1 4648 if (numberConflictCuts>lastNumberConflictCuts) { 4649 double length = lengthConflictCuts/numberConflictCuts; 4650 printf("%d new conflict cuts  total %d  average length %g\n", 4651 numberConflictCutslastNumberConflictCuts, 4652 numberConflictCuts,length); 4653 lastNumberConflictCuts = numberConflictCuts; 4654 } 4655 #endif 4472 4656 if (eventHandler && !eventHandler>event(CbcEventHandler::treeStatus)) { 4473 4657 eventHappened_ = true; // exit … … 4544 4728 } else { 4545 4729 // Deterministic parallel 4546 if (tree_>size() < CoinMax(numberThreads_, 8) && !goneParallel) { 4730 if ((tree_>size() < CoinMax(numberThreads_, 8) 4731 hotstartSolution_) && !goneParallel) { 4547 4732 node = tree_>bestNode(cutoff) ; 4548 4733 // Possible one on tree worse than cutoff … … 4603 4788 master_>stopThreads(1); 4604 4789 master_>waitForThreadsInTree(2); 4605 delete master_;4606 master_ = NULL;4607 masterThread_ = NULL;4608 4790 // adjust time to allow for children on some systems 4609 4791 //dblParam_[CbcStartSeconds] = CoinCpuTimeJustChildren(); … … 4627 4809 double dummyBest; 4628 4810 tree_>cleanTree(this, COIN_DBL_MAX, dummyBest) ; 4811 #ifdef CBC_THREAD 4812 if (parallelMode() > 0 && master_) { 4813 // see if any dangling nodes 4814 int numberThreads = master_>numberThreads(); 4815 for (int i=0;i<numberThreads;i++) { 4816 CbcThread * child = master_>child(i); 4817 //if (child>createdNode()) 4818 //printf("CHILD_NODE %p\n",child>createdNode()); 4819 delete child>createdNode(); 4820 } 4821 } 4822 #endif 4629 4823 } 4630 4824 delete nextRowCut_; … … 4665 4859 } 4666 4860 } 4861 #ifdef CBC_THREAD 4862 if (master_) { 4863 delete master_; 4864 master_ = NULL; 4865 masterThread_ = NULL; 4866 } 4867 #endif 4667 4868 /* 4668 4869 That's it, we've exhausted the search tree, or broken out of the loop because … … 4695 4896 << CoinMessageEol ; 4696 4897 } 4898 if ((moreSpecialOptions_&4194304)!=0) { 4899 // Conflict cuts 4900 int numberCuts = globalCuts_.sizeRowCuts(); 4901 int nConflict=0; 4902 double sizeConflict = 0.0; 4903 for (int i=0;i<numberCuts;i++) { 4904 OsiRowCut2 * cut = globalCuts_.cut(i); 4905 if (cut>whichRow()==1) { 4906 nConflict++; 4907 sizeConflict += cut>row().getNumElements(); 4908 } 4909 } 4910 if (nConflict) { 4911 sizeConflict /= nConflict; 4912 char general[200]; 4913 sprintf(general, "%d conflict cuts generated  average length %g", 4914 nConflict,sizeConflict); 4915 messageHandler()>message(CBC_GENERAL, 4916 messages()) 4917 << general << CoinMessageEol ; 4918 } 4919 } 4697 4920 if (numberStrongIterations_) 4698 4921 handler_>message(CBC_STRONG_STATS, messages_) … … 4706 4929 handler_>message(CBC_OTHER_STATS2, messages_) 4707 4930 << maximumDepthActual_ 4708 << numberDJFixed_ << number ExtraNodes_ << numberExtraIterations_4931 << numberDJFixed_ << numberFathoms_ << numberExtraNodes_ << numberExtraIterations_ 4709 4932 << CoinMessageEol ; 4933 #ifdef COIN_HAS_NTY 4934 if (symmetryInfo_) 4935 symmetryInfo_>statsOrbits(this,1); 4936 #endif 4710 4937 if (doStatistics == 100) { 4711 4938 for (int i = 0; i < numberObjects_; i++) { … … 5201 5428 specialOptions_(0), 5202 5429 moreSpecialOptions_(0), 5430 moreSpecialOptions2_(0), 5203 5431 topOfTree_(NULL), 5204 5432 subTreeModel_(NULL), … … 5224 5452 fastNodeDepth_(1), 5225 5453 eventHandler_(NULL), 5454 #ifdef COIN_HAS_NTY 5455 symmetryInfo_(NULL), 5456 #endif 5226 5457 numberObjects_(0), 5227 5458 object_(NULL), … … 5232 5463 numberExtraIterations_(0), 5233 5464 numberExtraNodes_(0), 5465 numberFathoms_(0), 5234 5466 continuousObjective_(COIN_DBL_MAX), 5235 5467 originalContinuousObjective_(COIN_DBL_MAX), … … 5269 5501 numberThreads_(0), 5270 5502 threadMode_(0), 5503 numberGlobalCutsIn_(0), 5271 5504 master_(NULL), 5272 5505 masterThread_(NULL) … … 5365 5598 specialOptions_(0), 5366 5599 moreSpecialOptions_(0), 5600 moreSpecialOptions2_(0), 5367 5601 topOfTree_(NULL), 5368 5602 subTreeModel_(NULL), … … 5388 5622 fastNodeDepth_(1), 5389 5623 eventHandler_(NULL), 5624 #ifdef COIN_HAS_NTY 5625 symmetryInfo_(NULL), 5626 #endif 5390 5627 numberObjects_(0), 5391 5628 object_(NULL), … … 5396 5633 numberExtraIterations_(0), 5397 5634 numberExtraNodes_(0), 5635 numberFathoms_(0), 5398 5636 continuousObjective_(COIN_DBL_MAX), 5399 5637 originalContinuousObjective_(COIN_DBL_MAX), … … 5433 5671 numberThreads_(0), 5434 5672 threadMode_(0), 5673 numberGlobalCutsIn_(0), 5435 5674 master_(NULL), 5436 5675 masterThread_(NULL) … … 5493 5732 // Space for current solution 5494 5733 currentSolution_ = new double[numberColumns]; 5495 continuousSolution_ = new double[numberColumns];5734 continuousSolution_ = CoinCopyOfArray(solver_>getColSolution(),numberColumns); 5496 5735 usedInSolution_ = new int[numberColumns]; 5497 5736 CoinZeroN(usedInSolution_, numberColumns); … … 5660 5899 specialOptions_(rhs.specialOptions_), 5661 5900 moreSpecialOptions_(rhs.moreSpecialOptions_), 5901 moreSpecialOptions2_(rhs.moreSpecialOptions2_), 5662 5902 topOfTree_(NULL), 5663 5903 subTreeModel_(rhs.subTreeModel_), … … 5680 5920 numberExtraIterations_(rhs.numberExtraIterations_), 5681 5921 numberExtraNodes_(rhs.numberExtraNodes_), 5922 numberFathoms_(rhs.numberFathoms_), 5682 5923 continuousObjective_(rhs.continuousObjective_), 5683 5924 originalContinuousObjective_(rhs.originalContinuousObjective_), … … 5717 5958 numberThreads_(rhs.numberThreads_), 5718 5959 threadMode_(rhs.threadMode_), 5960 numberGlobalCutsIn_(rhs.numberGlobalCutsIn_), 5719 5961 master_(NULL), 5720 5962 masterThread_(NULL) … … 5788 6030 numberObjects_ = 0; 5789 6031 object_ = NULL; 6032 } 6033 if (rhs.continuousSolver_) { 6034 continuousSolver_ = rhs.continuousSolver_>clone() ; 6035 } else { 6036 continuousSolver_ = NULL ; 5790 6037 } 5791 6038 if (rhs.referenceSolver_) … … 5871 6118 // Space for current solution 5872 6119 currentSolution_ = new double[numberColumns]; 5873 continuousSolution_ = new double[numberColumns];6120 continuousSolution_ = CoinCopyOfArray(solver_>getColSolution(),numberColumns); 5874 6121 usedInSolution_ = new int[numberColumns]; 5875 6122 CoinZeroN(usedInSolution_, numberColumns); … … 5905 6152 lastCut_ = NULL; 5906 6153 } 6154 #ifdef COIN_HAS_NTY 6155 if (rhs.symmetryInfo_) 6156 symmetryInfo_ = new CbcSymmetry(*rhs.symmetryInfo_); 6157 else 6158 symmetryInfo_ = NULL; 6159 #endif 5907 6160 synchronizeModel(); 5908 6161 if (cloneHandler && !defaultHandler_) { … … 5983 6236 // Space for current solution 5984 6237 currentSolution_ = new double[numberColumns]; 5985 continuousSolution_ = new double[numberColumns];6238 continuousSolution_ = CoinCopyOfArray(solver_>getColSolution(),numberColumns); 5986 6239 usedInSolution_ = new int[numberColumns]; 5987 6240 CoinZeroN(usedInSolution_, numberColumns); … … 6014 6267 specialOptions_ = rhs.specialOptions_; 6015 6268 moreSpecialOptions_ = rhs.moreSpecialOptions_; 6269 moreSpecialOptions2_ = rhs.moreSpecialOptions2_; 6016 6270 subTreeModel_ = rhs.subTreeModel_; 6017 6271 heuristicModel_ = NULL; … … 6033 6287 numberExtraIterations_ = rhs.numberExtraIterations_; 6034 6288 numberExtraNodes_ = rhs.numberExtraNodes_; 6289 numberFathoms_ = rhs.numberFathoms_; 6035 6290 continuousObjective_ = rhs.continuousObjective_; 6036 6291 originalContinuousObjective_ = rhs.originalContinuousObjective_; … … 6093 6348 numberThreads_ = rhs.numberThreads_; 6094 6349 threadMode_ = rhs.threadMode_; 6350 numberGlobalCutsIn_ = rhs.numberGlobalCutsIn_; 6095 6351 delete master_; 6096 6352 master_ = NULL; … … 6238 6494 lastCut_ = NULL; 6239 6495 } 6496 #ifdef COIN_HAS_NTY 6497 if (rhs.symmetryInfo_) 6498 symmetryInfo_ = new CbcSymmetry(*rhs.symmetryInfo_); 6499 else 6500 symmetryInfo_ = NULL; 6501 #endif 6240 6502 synchronizeModel(); 6241 6503 cbcColLower_ = NULL; … … 6329 6591 topOfTree_ = NULL; 6330 6592 resetModel(); 6593 #ifdef COIN_HAS_NTY 6594 delete symmetryInfo_; 6595 symmetryInfo_ = NULL; 6596 #endif 6331 6597 } 6332 6598 // Clears out enough to reset CbcModel … … 6437 6703 numberExtraIterations_ = 0; 6438 6704 numberExtraNodes_ = 0; 6705 numberFathoms_ = 0; 6439 6706 continuousObjective_ = 0.0; 6440 6707 originalContinuousObjective_ = 0.0; … … 6470 6737 specialOptions_ = rhs.specialOptions_; 6471 6738 moreSpecialOptions_ = rhs.moreSpecialOptions_; 6739 moreSpecialOptions2_ = rhs.moreSpecialOptions2_; 6472 6740 numberStrong_ = rhs.numberStrong_; 6473 6741 numberBeforeTrust_ = rhs.numberBeforeTrust_; … … 6494 6762 numberThreads_ = rhs.numberThreads_; 6495 6763 threadMode_ = rhs.threadMode_; 6764 numberGlobalCutsIn_ = rhs.numberGlobalCutsIn_; 6496 6765 delete master_; 6497 6766 master_ = NULL; … … 6524 6793 } else { 6525 6794 generator_[i] = new CbcCutGenerator(*rhs.virginGenerator_[i]); 6526 // But copy across maximumTries 6795 // But copy across maximumTries and switches 6527 6796 generator_[i]>setMaximumTries(rhs.generator_[i]>maximumTries()); 6797 generator_[i]>setSwitches(rhs.generator_[i]>switches()); 6528 6798 } 6529 6799 virginGenerator_[i] = new CbcCutGenerator(*rhs.virginGenerator_[i]); … … 6553 6823 messageHandler()>setLogLevel(rhs.messageHandler()>logLevel()); 6554 6824 whenCuts_ = rhs.whenCuts_; 6825 #ifdef COIN_HAS_NTY 6826 if (rhs.symmetryInfo_) 6827 symmetryInfo_ = new CbcSymmetry (*rhs.symmetryInfo_); 6828 else 6829 symmetryInfo_ = NULL; 6830 #endif 6555 6831 synchronizeModel(); 6556 6832 } … … 6917 7193 easy way to pass in the size. But we take a hit for memory allocation. 6918 7194 */ 6919 lastws>setSize(numberColumns, numberRowsAtContinuous_ + currentNumberCuts); 7195 if (lastws) 7196 lastws>setSize(numberColumns, numberRowsAtContinuous_ + currentNumberCuts); 6920 7197 currentNumberCuts = 0; 6921 7198 while (nNode) { … … 6925 7202 } 6926 7203 #ifndef NDEBUG 6927 if ( !lastws>fullBasis()) {7204 if (lastws&&!lastws>fullBasis()) { 6928 7205 #ifdef COIN_DEVELOP 6929 7206 printf("******* bad basis\n"); … … 6950 7227 descendants. 6951 7228 */ 6952 int CbcModel::addCuts (CbcNode *node, CoinWarmStartBasis *&lastws , bool canFix)7229 int CbcModel::addCuts (CbcNode *node, CoinWarmStartBasis *&lastws) 6953 7230 { 6954 7231 /* … … 6967 7244 double cutoff = getCutoff() ; 6968 7245 int currentNumberCuts = currentNumberCuts_; 6969 if (canFix) {6970 bool feasible = true;6971 const double *lower = solver_>getColLower() ;6972 const double *upper = solver_>getColUpper() ;6973 double * newLower = analyzeResults_;6974 double * objLower = newLower + numberIntegers_;6975 double * newUpper = objLower + numberIntegers_;6976 double * objUpper = newUpper + numberIntegers_;6977 int n = 0;6978 for (i = 0; i < numberIntegers_; i++) {6979 int iColumn = integerVariable_[i];6980 bool changed = false;6981 double lo = 0.0;6982 double up = 0.0;6983 if (objLower[i] > cutoff) {6984 lo = lower[iColumn];6985 up = upper[iColumn];6986 if (lo < newLower[i]) {6987 lo = newLower[i];6988 solver_>setColLower(iColumn, lo);6989 changed = true;6990 n++;6991 }6992 if (objUpper[i] > cutoff) {6993 if (up > newUpper[i]) {6994 up = newUpper[i];6995 solver_>setColUpper(iColumn, up);6996 changed = true;6997 n++;6998 }6999 }7000 } else if (objUpper[i] > cutoff) {7001 lo = lower[iColumn];7002 up = upper[iColumn];7003 if (up > newUpper[i]) {7004 up = newUpper[i];7005 solver_>setColUpper(iColumn, up);7006 changed = true;7007 n++;7008 }7009 }7010 if (changed && lo > up) {7011 feasible = false;7012 break;7013 }7014 }7015 if (!feasible) {7016 COIN_DETAIL_PRINT(printf("analysis says node infeas\n"));7017 cutoff = COIN_DBL_MAX;7018 }7019 }7020 7246 /* 7021 7247 If the node can't be fathomed by bound, reinstall tight cuts in the … … 7060 7286 numberRowsAtContinuous_ + numberToAdd); 7061 7287 # endif 7288 whichGenerator_[numberToAdd] = whichGenerator_[i]; 7062 7289 addCuts[numberToAdd++] = addedCuts_[i]; 7063 7290 #if 1 … … 7187 7414 } 7188 7415 #endif 7189 //int n2=solver_>getNumRows();7190 //for (int j=0;j<numberToAdd;j++)7191 //addCuts[j]>print();7192 7416 solver_>applyRowCuts(numberToAdd, addCuts); 7193 //int n3=solver_>getNumRows();7194 //printf("NBefore %d, after del %d, now %d\n",n1,n2,n3);7195 7417 } 7196 7418 # ifdef CBC_CHECK_BASIS … … 7199 7421 lastws>print(); 7200 7422 # endif 7201 //for (i=0;i<numberToAdd;i++)7202 //delete addCuts[i];7203 7423 delete [] addCuts; 7204 7424 delete [] cutsToDrop ; … … 7368 7588 } 7369 7589 numberDJFixed_ += numberFixed  numberTightened; 7590 #ifdef SWITCH_VARIABLES 7591 if (numberFixed) 7592 fixAssociated(NULL,0); 7593 #endif 7370 7594 return numberFixed; 7371 7595 } … … 7507 7731 int returnCode = resolve(node ? node>nodeInfo() : NULL, 1); 7508 7732 moreSpecialOptions_=save; 7509 #ifdef CONFLICT_CUTS 7733 #ifdef CONFLICT_CUTS 7510 7734 #ifdef COIN_HAS_CLP 7511 7735 // if infeasible conflict analysis 7512 7736 if (solver_>isProvenPrimalInfeasible()&&!parentModel_&& 7513 7737 (moreSpecialOptions_&4194304)!=0&&clpSolver) { 7514 //printf("infeasible  do conflict analysis\n"); 7738 if (!topOfTree_ && masterThread_) 7739 topOfTree_ = masterThread_>master_>baseModel_>topOfTree_; 7515 7740 assert (topOfTree_); 7516 int iType= 1;7741 int iType=0; 7517 7742 OsiRowCut * cut = clpSolver>modelCut(topOfTree_>lower(), 7518 7743 topOfTree_>upper(), 7519 7744 numberRowsAtContinuous_,whichGenerator_,iType); 7520 7745 if (cut) { 7521 printf("XXXXXX cut\n");7522 7746 //cut>print(); 7523 7747 if (!iType) { 7524 makeGlobalCut(cut) ; 7748 int badCut = makeGlobalCut(cut) ; 7749 if (!badCut) { 7750 #if PRINT_CONFLICT==1 7751 numberConflictCuts++; 7752 lengthConflictCuts += cut>row().getNumElements(); 7753 #endif 7754 #if PRINT_CONFLICT<2 7755 if (handler_>logLevel() > 1) { 7756 #endif 7757 printf("Conflict cut at depth %d (%d elements)\n", 7758 currentDepth_,cut>row().getNumElements()); 7759 if (cut>row().getNumElements()<3) 7760 cut>print(); 7761 #if PRINT_CONFLICT<2 7762 } 7763 #endif 7764 } 7525 7765 if ((specialOptions_&1) != 0) { 7526 7766 debugger = continuousSolver_>getRowCutDebugger() ; … … 7547 7787 #endif 7548 7788 #endif 7549 #if COIN_DEVELOP>17550 //if (!solver_>getIterationCount()&&solver_>isProvenOptimal())7551 //printf("zero iterations on first solve of branch\n");7552 #endif7553 7789 double lastObjective = solver_>getObjValue() * solver_>getObjSense(); 7554 7790 cut_obj[CUT_HISTORY1] = lastObjective; … … 7710 7946 double objectiveValue = solver_>getObjValue() * solver_>getObjSense(); 7711 7947 double changeInObjective = CoinMax(0.0, objectiveValue  originalValue); 7712 int iStatus = (feasible) ? 0 : 0;7713 7948 double value = obj>value(); 7714 7949 double movement; … … 7718 7953 movement = value  floor(value); 7719 7954 branchingMethod_>chooseMethod()>updateInformation(iObject, branch, changeInObjective, 7720 movement, iStatus);7955 movement, 0 /*(feasible) ? 0 : 1; */); 7721 7956 } 7722 7957 } … … 7774 8009 if ( maximumSecondsReached() ) 7775 8010 numberTries = 0; // exit 8011 if ((moreSpecialOptions2_&(20484096))!=0 && currentDepth_>5) { 8012 // howOftenGlobalScan_ = 10; 8013 int type = (moreSpecialOptions2_&(20484096))>>11; 8014 if (type==1) { 8015 int n=0; 8016 int k=currentDepth_; 8017 while (k) { 8018 if ((k&1)!=0) 8019 n++; 8020 k = k >>1; 8021 } 8022 if (n>1) 8023 numberTries=0; 8024 } else if (type==2) { 8025 if ((currentDepth_%4)!=0) 8026 numberTries=0; 8027 } else { 8028 if ((currentDepth_%8)!=0) 8029 numberTries=0; 8030 } 8031 } 7776 8032 //if ((numberNodes_%100)==0) 7777 8033 //printf("XXa sum obj changed by %g\n",sumChangeObjective1_); … … 7925 8181 #define CHECK_DEBUGGER 7926 8182 #ifdef CHECK_DEBUGGER 7927 if ((specialOptions_&1) != 0 ) {8183 if ((specialOptions_&1) != 0 && ! parentModel_) { 7928 8184 CoinAssert (!solver_>getRowCutDebuggerAlways()>invalidCut(*thisCut)); 7929 8185 } … … 7933 8189 thisCut>violated(cbcColSolution_)) ; 7934 8190 #endif 7935 whichGenerator_[numberViolated++] = 1;8191 whichGenerator_[numberViolated++] = 20099; 7936 8192 #ifndef GLOBAL_CUTS_JUST_POINTERS 7937 8193 theseCuts.insert(*thisCut) ; … … 7984 8240 if (clpSolver) 7985 8241 clpSolver>setSpecialOptions(save); 7986 #if def CLP_INVESTIGATE8242 #if CBC_USEFUL_PRINTING>1 7987 8243 if (clpSolver>getModelPtr()>numberIterations()) 7988 8244 printf("ITS %d pass %d\n", … … 8018 8274 resizeWhichGenerator(numberViolated, numberViolated + 1); 8019 8275 // set whichgenerator (also serves as marker to say don't delete0 8020 whichGenerator_[numberViolated++] = 2;8276 whichGenerator_[numberViolated++] = 20098; 8021 8277 } 8022 8278 … … 8100 8356 incrementUsed(newSolution); 8101 8357 lastHeuristic_ = heuristic_[found]; 8102 #ifdef CLP_INVESTIGATE8358 #ifdef HEURISTIC_INFORM 8103 8359 printf("HEUR %s where %d A\n", 8104 8360 lastHeuristic_>heuristicName(), whereFrom); … … 8270 8526 if (numberToAdd > 0) { 8271 8527 int i ; 8528 int * whichGenerator = whichGenerator_  8529 numberRowsAtContinuous_+solver_>getNumRows(); 8272 8530 // Faster to add all at once 8273 8531 addCuts = new const OsiRowCut * [numberToAdd] ; 8274 8532 for (i = 0 ; i < numberToAdd ; i++) { 8275 8533 addCuts[i] = &theseCuts.rowCut(i) ; 8534 whichGenerator[i]=90; 8276 8535 } 8277 8536 if ((specialOptions_&262144) != 0 && !parentModel_) { … … 8417 8676 } 8418 8677 } 8419 #if def CLP_INVESTIGATE28678 #if CBC_USEFUL_PRINTING>12 8420 8679 if (!parentModel_ && !numberNodes_) 8421 8680 printf("badObj %s nBad %d maxBad %d goodDrop %g minDrop %g thisDrop %g obj %g\n", … … 8440 8699 if (thisObj  lastObjective > drop[currentDepth_]*minimumDrop) { 8441 8700 numberTries++; 8442 #if def CLP_INVESTIGATE8701 #if CBC_USEFUL_PRINTING>1 8443 8702 //printf("drop %g %g %d\n",thisObj,lastObjective,currentPassNumber_); 8444 8703 #endif … … 8554 8813 8555 8814 for (int i = numberGlobalBefore ; i < numberGlobalAfter ; i++) { 8556 whichGenerator_[numberNewCuts_++] = 1;8815 whichGenerator_[numberNewCuts_++] = 20099; 8557 8816 #ifndef GLOBAL_CUTS_JUST_POINTERS 8558 8817 cuts.insert(*globalCuts_.rowCutPtr(i)) ; … … 8637 8896 incrementUsed(newSolution); 8638 8897 lastHeuristic_ = heuristic_[found]; 8639 #ifdef CLP_INVESTIGATE8898 #ifdef HEURISTIC_INFORM 8640 8899 printf("HEUR %s where %d B\n", 8641 8900 lastHeuristic_>heuristicName(), whereFrom); … … 8756 9015 bool smallProblem = size <= 550; 8757 9016 smallProblem = false; 8758 #if def CLP_INVESTIGATE9017 #if CBC_USEFUL_PRINTING>1 8759 9018 int maxPass = maximumCutPasses_; 8760 9019 #endif … … 8853 9112 whenCuts_ += 100000; 8854 9113 //// end 8855 #if def CLP_INVESTIGATE9114 #if CBC_USEFUL_PRINTING>1 8856 9115 printf("changing whenCuts from %d to %d and cutPasses from %d to %d objchange %g\n", 8857 9116 whenC, whenCuts_, maxPass, maximumCutPasses_, thisObjective  startObjective); … … 8910 9169 if (numberColumns < 200) 8911 9170 value = CoinMax(minimumDrop_, 0.1 * value); 8912 #if def CLP_INVESTIGATE9171 #if CBC_USEFUL_PRINTING>1 8913 9172 printf("Minimum drop for cuts was %g, now is %g\n", minimumDrop_, value); 8914 9173 #endif … … 8920 9179 for (i = 0; i < numberNewCuts_; i++) { 8921 9180 int iGenerator = whichGenerator_[i]; 9181 //assert (iGenerator>=0); 8922 9182 if (iGenerator>=0) 8923 9183 iGenerator=iGenerator%10000; … … 9305 9565 for (i = 0; i < numberNewCuts_; i++) { 9306 9566 int iGenerator = whichGenerator_[i]; 9567 #ifdef CONFLICT_CUTS 9568 assert (iGenerator>=0); 9569 #endif 9307 9570 if (iGenerator>=0) 9308 9571 iGenerator=iGenerator%10000; 9309 if (iGenerator >= 0 )9572 if (iGenerator >= 0 && iGenerator < numberCutGenerators_) 9310 9573 generator_[iGenerator]>incrementNumberCutsActive(); 9311 9574 } … … 9469 9732 } 9470 9733 #endif 9471 if (mustResolve  (specialOptions_&1) != 0) {9734 if (mustResolve /* (specialOptions_&1) != 0*/) { 9472 9735 int returnCode = resolve(node ? node>nodeInfo() : NULL, 2); 9473 9736 if (returnCode == 0) … … 9540 9803 break; 9541 9804 } 9542 whichGenerator_[numberBefore++] = i ;9805 whichGenerator_[numberBefore++] = i+20000 ; 9543 9806 if (!numberNodes_generator_[i]>globalCuts()) 9544 9807 whichGenerator_[numberBefore1]=i+10000; … … 9565 9828 for (; j < numberRowCutsAfter; j++) { 9566 9829 const OsiRowCut * thisCut = theseCuts.rowCutPtr(j) ; 9567 whichGenerator_[numberBefore++] = i ;9830 whichGenerator_[numberBefore++] = i+20000 ; 9568 9831 if (!numberNodes_generator_[i]>globalCuts()) 9569 9832 whichGenerator_[numberBefore1]=i+10000; … … 9616 9879 printf("Old cut added  violation %g\n", 9617 9880 thisCut>violated(cbcColSolution_)) ; 9618 whichGenerator_[numberOld++] = 3;9881 whichGenerator_[numberOld++] = 20097; 9619 9882 theseCuts.insert(*thisCut) ; 9620 9883 } … … 9676 9939 int firstOldCut = numberRowsAtContinuous_ ; 9677 9940 int totalNumberCuts = numberNewCuts_ + numberOldActiveCuts_ ; 9941 assert (numberRowsAtContinuous_+totalNumberCuts== 9942 solver_>getNumRows()); 9678 9943 int *solverCutIndices = new int[totalNumberCuts] ; 9679 9944 int *newCutIndices = new int[numberNewCuts_] ; … … 9690 9955 int numberOldToDelete = 0 ; 9691 9956 int i ; 9957 int kCut=0; 9692 9958 ws = dynamic_cast<const CoinWarmStartBasis*>(solver_>getWarmStart()) ; 9693 9959 /* … … 9715 9981 if (slackCut>effectiveness() != 1.234) { 9716 9982 slackCut>setEffectiveness(1.234); 9983 slackCut>setGloballyValid(); 9717 9984 saveCuts>insert(*slackCut); 9718 9985 } … … 9723 9990 oldCutIndex++ ; 9724 9991 } else { 9725 oldCutIndex++ ; 9992 int iGenerator = addedCuts_[oldCutIndex]>whichCutGenerator(); 9993 if (iGenerator==1) 9994 iGenerator=100; 9995 whichGenerator_[kCut++] = iGenerator ; 9996 oldCutIndex++; 9726 9997 } 9727 9998 } … … 9736 10007 */ 9737 10008 int firstNewCut = firstOldCut + numberOldActiveCuts_ ; 9738 int k = 0 ;9739 10009 int nCuts = newCuts.sizeRowCuts(); 9740 10010 for (i = 0 ; i < nCuts ; i++) { … … 9745 10015 newCutIndices[numberNewToDelete++] = i ; 9746 10016 } else { // save which generator did it 9747 // 2 means branch cut! assert (whichGenerator_[i]!=2); // ?? what if it is  memory leak?9748 whichGenerator_[k ++] = whichGenerator_[i] ;10017 // 20098 means branch cut! assert (whichGenerator_[i]!=20098); // ?? what if it is  memory leak? 10018 whichGenerator_[kCut++] = whichGenerator_[i] ; 9749 10019 } 9750 10020 } … … 9777 10047 if (slackCut>effectiveness() != 1.234) { 9778 10048 slackCut>setEffectiveness(1.234); 10049 slackCut>setGloballyValid(); 9779 10050 saveCuts>insert(slackCut); 9780 10051 } else { … … 9826 10097 } 9827 10098 } 10099 9828 10100 /* 9829 10101 Clean up and return. … … 9849 10121 cbc_resolve_check(solver_); 9850 10122 #endif 10123 bool onOptimalPath = false; 10124 if ((specialOptions_&1) != 0) { 10125 const OsiRowCutDebugger *debugger = solver_>getRowCutDebugger() ; 10126 if (debugger) { 10127 onOptimalPath = true; 10128 printf("On optimal path d\n") ; 10129 } 10130 } 9851 10131 // We may have deliberately added in violated cuts  check to avoid message 9852 10132 int iRow; … … 9881 10161 */ 9882 10162 if (feasible) { 9883 bool onOptimalPath = false;9884 if ((specialOptions_&1) != 0) {9885 const OsiRowCutDebugger *debugger = solver_>getRowCutDebugger() ;9886 if (debugger) {9887 onOptimalPath = true;9888 printf("On optimal path d\n") ;9889 }9890 }9891 10163 int nTightened = 0; 9892 10164 #ifdef COIN_HAS_CLP … … 9926 10198 //double cutoff = getCutoff(); 9927 10199 if (bestObjective_  getCutoffIncrement() < testValue) { 9928 #if def CLP_INVESTIGATE10200 #if CBC_USEFUL_PRINTING>1 9929 10201 double value ; 9930 10202 solver_>getDblParam(OsiDualObjectiveLimit, value) ; … … 10174 10446 } 10175 10447 } 10448 #if 0 10449 if ((specialOptions_&1) != 0 && onOptimalPath) { 10450 const OsiRowCutDebugger *debugger = solver_>getRowCutDebugger() ; 10451 if (!debugger) { 10452 // tighten did something??? 10453 solver_>getRowCutDebuggerAlways()>printOptimalSolution(*solver_); 10454 solver_>writeMpsNative("infeas4.mps", NULL, NULL, 2); 10455 printf("Not on optimalpath aaaa\n"); 10456 //abort(); 10457 } else { 10458 printf("Still on optimal path\n"); 10459 } 10460 } 10461 #endif 10176 10462 return returnStatus ; 10177 10463 } … … 10419 10705 printf("%d cliques of average size %g found, %d P1, %d M1\n", 10420 10706 numberCliques, 10421 (static_cast<double>(totalP1 + totalM1)) / (static_cast<double> numberCliques),10707 (static_cast<double>(totalP1 + totalM1)) / (static_cast<double> (numberCliques)), 10422 10708 totalP1, totalM1); 10423 10709 else … … 11105 11391 // treat as if will cost what it says up 11106 11392 double upCost = costValue; 11393 #ifndef BRANCH_BREAKEVEN 11394 #define BRANCH_BREAKEVEN 0.3 11395 #else 11396 preferredWay=1; 11397 #endif 11107 11398 // and balance at breakeven of 0.3 11108 double downCost = ( 0.7 * upCost) / 0.3;11399 double downCost = ((1.0BRANCH_BREAKEVEN) * upCost) / BRANCH_BREAKEVEN; 11109 11400 if (obj1a) { 11110 11401 upCost = obj1a>upPseudoCost(); … … 11142 11433 branchingMethod_ = new CbcBranchDynamicDecision(); 11143 11434 } 11435 #ifdef SWITCH_VARIABLES 11436 // see if any switching variables 11437 if (numberIntegers_<solver_>getNumCols()) 11438 findSwitching(); 11439 #endif 11144 11440 synchronizeNumberBeforeTrust(); 11145 11441 } 11442 #ifdef SWITCH_VARIABLES 11443 // Convert Dynamic to Switching 11444 int 11445 CbcModel::findSwitching() 11446 { 11447 if ((moreSpecialOptions2_&1)==0) 11448 return 0; 11449 const CoinPackedMatrix * rowCopy = solver_>getMatrixByRow(); 11450 const int * column = rowCopy>getIndices(); 11451 const int * rowLength = rowCopy>getVectorLengths(); 11452 const CoinBigIndex * rowStart = rowCopy>getVectorStarts(); 11453 const double * rowLower = solver_>getRowLower(); 11454 const double * rowUpper = solver_>getRowUpper(); 11455 const double * columnLower = solver_>getColLower(); 11456 const double * columnUpper = solver_>getColUpper(); 11457 const double * element = rowCopy>getElements(); 11458 //const double * element = solver_>getMatrixByCol()>getElements(); 11459 const int * row = solver_>getMatrixByCol()>getIndices(); 11460 const CoinBigIndex * columnStart = solver_>getMatrixByCol()>getVectorStarts(); 11461 const int * columnLength = solver_>getMatrixByCol()>getVectorLengths(); 11462 int numberRows = solver_>getNumRows(); 11463 int numberColumns = solver_>getNumCols(); 11464 int * sort = new int[2*numberRows+2+numberColumns]; 11465 int * whichRow = sort+numberRows+1; 11466 int * marked = whichRow+numberRows+1; 11467 memset(marked,0,numberColumns*sizeof(int)); 11468 int nnSwitch=0; 11469 int nnSwitchTotal=0; 11470 int n2Switch=0; 11471 double largeRatio1=1000.0; 11472 double largeRatio2=100.0; 11473 for (int i=0;i<numberIntegers_;i++) { 11474 int iColumn = integerVariable_[i]; 11475 if (columnLower[iColumn]columnUpper[iColumn]!=1.0) 11476 continue; 11477 if (!dynamic_cast <CbcSimpleInteger *> (object_[i])) 11478 continue; 11479 int nAdd=0; 11480 bool takeThis=false; 11481 CoinBigIndex start = columnStart[iColumn]; 11482 CoinBigIndex end = start + columnLength[iColumn]; 11483 for (CoinBigIndex j = start; j < end; j++) { 11484 int iRow = row[j]; 11485 if (rowLength[iRow]!=2) { 11486 continue; 11487 } 11488 // for now just 0.0 in rhs 11489 if (!rowLower[iRow]) { 11490 if (rowUpper[iRow]!=COIN_DBL_MAX) 11491 continue; 11492 } else if (rowLower[iRow]!=COIN_DBL_MAX) { 11493 continue; 11494 } else if (rowUpper[iRow]) { 11495 continue; 11496 } 11497 CoinBigIndex k = rowStart[iRow]; 11498 double bValue, cValue; 11499 int cColumn; 11500 if (column[k]==iColumn) { 11501 bValue=element[k]; 11502 cValue=element[k+1]; 11503 cColumn=column[k+1]; 11504 } else { 11505 bValue=element[k+1]; 11506 cValue=element[k]; 11507 cColumn=column[k]; 11508 } 11509 if (solver_>isInteger(cColumn)) 11510 continue; 11511 if (columnLower[cColumn]<0.0) 11512 continue; 11513 if (bValue*cValue>0.0) 11514 continue; 11515 if (fabs(bValue)>largeRatio1*fabs(cValue)) 11516 takeThis=true; 11517 // add to list 11518 whichRow[nAdd]=iRow; 11519 sort[nAdd++]=cColumn; 11520 } 11521 if (nAdd) { 11522 n2Switch++; 11523 CoinSort_2(sort,sort+nAdd,whichRow); 11524 int last=sort[0]; 11525 for (int k=1;k<nAdd;k++) { 11526 if (sort[k]==last) 11527 takeThis=true; 11528 else 11529 last=sort[k]; 11530 } 11531 if (takeThis) { 11532 int last=sort[0]; 11533 marked[last]++; 11534 for (int k=1;k<nAdd;k++) { 11535 if (sort[k]!=last) { 11536 last=sort[k]; 11537 marked[last]++; 11538 } 11539 } 11540 //printf("Column %d has %d other columns\n",iColumn,nAdd); 11541 sort[nAdd]=COIN_INT_MAX; 11542 whichRow[nAdd]=COIN_INT_MAX; 11543 CbcSimpleIntegerDynamicPseudoCost * thisOne = 11544 dynamic_cast <CbcSimpleIntegerDynamicPseudoCost *> (object_[i]); 11545 if (thisOne) { 11546 assert(iColumn == thisOne>columnNumber()); 11547 object_[i]=new CbcSwitchingBinary(thisOne,nAdd,sort,whichRow); 11548 delete thisOne; 11549 } else { 11550 CbcSimpleInteger * thisOne = 11551 dynamic_cast <CbcSimpleInteger *> (object_[i]); 11552 assert (thisOne); 11553 assert(iColumn == thisOne>columnNumber()); 11554 CbcSimpleIntegerDynamicPseudoCost tempObj(this,iColumn,0.1); 11555 object_[i]=new CbcSwitchingBinary(&tempObj,nAdd,sort,whichRow); 11556 delete thisOne; 11557 } 11558 } 11559 } 11560 // see if there is an interesting row 11561 for (CoinBigIndex j = start; j < end; j++) { 11562 int iRow = row[j]; 11563 // for now just 0.0 in rhs 11564 if (!rowLower[iRow]) { 11565 if (rowUpper[iRow]!=COIN_DBL_MAX) 11566 continue; 11567 } else if (rowLower[iRow]!=COIN_DBL_MAX) { 11568 continue; 11569 } else if (rowUpper[iRow]) { 11570 continue; 11571 } 11572 int nOther=0; 11573 double bEl=0.0; 11574 double cMax=COIN_DBL_MAX; 11575 double cMin=COIN_DBL_MAX; 11576 for (CoinBigIndex k = rowStart[iRow]; 11577 k<rowStart[iRow]+rowLength[iRow];k++) { 11578 int jColumn = column[k]; 11579 if (jColumn==iColumn) { 11580 bEl=element[k]; 11581 } else { 11582 sort[nOther++]=jColumn; 11583 if (solver_>isInteger(jColumn)) { 11584 cMin=1.0; 11585 cMax=1.0; 11586 break; 11587 } else { 11588 cMax=CoinMax(cMax,element[k]); 11589 cMin=CoinMin(cMin,element[k]); 11590 if (columnLower[jColumn]<0.0) { 11591 cMin=1.0; 11592 cMax=1.0; 11593 break; 11594 } 11595 } 11596 } 11597 } 11598 double largestC = CoinMax(fabs(cMin),fabs(cMax)); 11599 if (((cMin>0.0&&bEl<0.0&&!rowUpper[iRow]) 11600 (cMin<0.0&&bEl>0.0&&!rowLower[iRow]))&&cMin*cMax>0.0&& 11601 fabs(bEl)>largeRatio2*largestC) { 11602 // forces to zero 11603 CbcSwitchingBinary * object = 11604 dynamic_cast <CbcSwitchingBinary *> (object_[i]); 11605 if (!object) { 11606 // create empty one 11607 CbcSimpleIntegerDynamicPseudoCost * thisOne = 11608 dynamic_cast <CbcSimpleIntegerDynamicPseudoCost *> (object_[i]); 11609 if (thisOne) { 11610 assert(iColumn == thisOne>columnNumber()); 11611 object=new CbcSwitchingBinary(thisOne,0,sort,whichRow); 11612 delete thisOne; 11613 } else { 11614 CbcSimpleInteger * thisOne = 11615 dynamic_cast <CbcSimpleInteger *> (object_[i]); 11616 assert (thisOne); 11617 assert(iColumn == thisOne>columnNumber()); 11618 CbcSimpleIntegerDynamicPseudoCost tempObj(this,iColumn,0.1); 11619 object=new CbcSwitchingBinary(&tempObj,0,sort,whichRow); 11620 delete thisOne; 11621 } 11622 object_[i]=object; 11623 } 11624 object>addZeroSwitches(nOther,sort); 11625 nnSwitch++; 11626 nnSwitchTotal+=nOther; 11627 } 11628 } 11629 } 11630 if (n2Switch+nnSwitch) { 11631 if (handler_>logLevel()>2) 11632 printf("%d two switch variables  %d multi (total multi %d)\n", 11633 n2Switch,nnSwitch,nnSwitchTotal); 11634 memset(whichRow,0,(numberRows+1)*sizeof(int)); 11635 for (int i=0;i<numberColumns;i++) { 11636 whichRow[marked[i]]++; 11637 } 11638 if (handler_>logLevel()>2) { 11639 for (int i=0;i<numberRows+1;i++) { 11640 if (whichRow[i]) 11641 printf("%d variables have %d switches\n",whichRow[i],i); 11642 } 11643 } 11644 } 11645 delete [] sort; 11646 // say switches exist 11647 if (n2Switch+nnSwitch) 11648 moreSpecialOptions2_=4; 11649 return n2Switch+nnSwitch; 11650 } 11651 // Fix associated variables 11652 int 11653 CbcModel::fixAssociated(OsiSolverInterface * solver,int cleanBasis) 11654 { 11655 int nChanged=0; 11656 if ((moreSpecialOptions2_&4)!=0) { 11657 int n=1; 11658 while (n) { 11659 n=0; 11660 for (int i=0;i<numberObjects_;i++) { 11661 CbcSwitchingBinary * object = dynamic_cast<CbcSwitchingBinary *> (object_[i]); 11662 if (object) { 11663 n += object>setAssociatedBounds(solver,cleanBasis); 11664 } 11665 } 11666 nChanged+=n; 11667 } 11668 } 11669 return nChanged; 11670 } 11671 /* Debug associated variables 11672 printLevel  1 summary if bad on fixed 11673 2 summary if bad on satisfied 11674 3 for individuals 11675 */ 11676 int 11677 CbcModel::checkAssociated(const OsiSolverInterface * solver, 11678 const double * solution,int printLevel) 11679 { 11680 int nBad=0; 11681 int nBadFixed=0; 11682 if ((moreSpecialOptions2_&4)!=0) { 11683 int nAt0=0; 11684 int nAt1=0; 11685 int nBetween=0; 11686 for (int i=0;i<numberObjects_;i++) { 11687 CbcSwitchingBinary * object = dynamic_cast<CbcSwitchingBinary *> (object_[i]); 11688 if (object) { 11689 int state[3]; 11690 nBad += object>checkAssociatedBounds(solver,solution,printLevel,state, 11691 nBadFixed); 11692 if (state[0]==0) 11693 nBetween++; 11694 else if (state[0]==1) 11695 nAt0++; 11696 else 11697 nAt1++; 11698 } 11699 } 11700 if (handler_>logLevel()>2) { 11701 if (printLevel>1(printLevel==1&&nBadFixed)) { 11702 printf("%d switches, %d at 0, %d at 1, %d between  %d bad values (%d when fixed)\n", 11703 nBetween+nAt0+nAt1,nAt0,nAt1,nBetween,nBad,nBadFixed); 11704 if (nBadFixed && printLevel!=3) 11705 checkAssociated(solver,solution,3); 11706 } 11707 } 11708 } 11709 return nBad; 11710 } 11711 #endif 11146 11712 // Set numberBeforeTrust in all objects 11147 11713 void … … 11464 12030 11465 12031 { 12032 int numberContinuousColumns=continuousSolver_>getNumCols(); 11466 12033 if (!solverCharacteristics_>solutionAddsCuts()) { 11467 12034 // Can trust solution 11468 12035 int numberColumns = solver_>getNumCols(); 12036 #ifdef COIN_HAS_CLP 12037 OsiClpSolverInterface * clpContinuousSolver 12038 = dynamic_cast<OsiClpSolverInterface *> (continuousSolver_); 12039 int modifiedTolerances=0; 12040 #ifndef CBC_LEAVE_PERTURBATION_ON_CHECK_SOLUTION 12041 int savePerturbation=1; 12042 #endif 12043 #ifndef CBC_LEAVE_TOLERANCE_ON_CHECK_SOLUTION 12044 double savePrimalTolerance=0.0; 12045 #endif 12046 #ifndef CBC_LEAVE_SCALING_ON_CHECK_SOLUTION 12047 int saveScaling=1; 12048 #endif 12049 if (clpContinuousSolver ) { 12050 // be more accurate if possible 12051 ClpSimplex * clp = clpContinuousSolver>getModelPtr(); 12052 #ifndef CBC_LEAVE_PERTURBATION_ON_CHECK_SOLUTION 12053 savePerturbation=clp>perturbation(); 12054 #endif 12055 #ifndef CBC_LEAVE_TOLERANCE_ON_CHECK_SOLUTION 12056 savePrimalTolerance=clp>primalTolerance(); 12057 #endif 12058 #ifndef CBC_LEAVE_SCALING_ON_CHECK_SOLUTION 12059 saveScaling=clp>scalingFlag(); 12060 #endif 12061 #ifndef CBC_LEAVE_TOLERANCE_ON_CHECK_SOLUTION 12062 if (savePrimalTolerance>0.9999999e7) { 12063 modifiedTolerances = 1; 12064 clp>setPrimalTolerance(1.0e8); 12065 } 12066 #endif 12067 #ifndef CBC_LEAVE_PERTURBATION_ON_CHECK_SOLUTION 12068 if (savePerturbation<100) { 12069 modifiedTolerances = 2; 12070 clp>setPerturbation(100); 12071 } 12072 #endif 12073 #ifndef CBC_LEAVE_SCALING_ON_CHECK_SOLUTION 12074 if (saveScaling) { 12075 modifiedTolerances = 4; 12076 clp>scaling(0); 12077 } 12078 #endif 12079 } 12080 #endif 11469 12081 11470 12082 /* … … 11501 12113 memcpy(saveUpper, getColUpper(), numberColumns*sizeof(double)); 11502 12114 memcpy(saveLower, getColLower(), numberColumns*sizeof(double)); 12115 //#define CLP_INVESTIGATE4 12116 #if CBC_USEFUL_PRINTING>14 12117 { 12118 int nBad=checkAssociated(solver_,solver_>getColSolution(),1); 12119 if (nBad) 12120 checkAssociated(solver_,solver_>getColSolution(),3); 12121 double largestInfeasibility = 0.0; 12122 double primalTolerance ; 12123 double offset; 12124 solver_>getDblParam(OsiObjOffset, offset); 12125 solver_>getDblParam(OsiPrimalTolerance, primalTolerance) ; 12126 const double *objective = getObjCoefficients() ; 12127 const double * rowLower = solver_>getRowLower() ; 12128 const double * rowUpper = solver_>getRowUpper() ; 12129 const double * columnLower = solver_>getColLower() ; 12130 const double * columnUpper = solver_>getColUpper() ; 12131 int numberRows = solver_>getNumRows() ; 12132 double *rowActivity = new double[numberRows] ; 12133 memset(rowActivity, 0, numberRows*sizeof(double)) ; 12134 double *rowSum = new double[numberRows] ; 12135 memset(rowSum, 0, numberRows*sizeof(double)) ; 12136 int * marked = new int [numberColumns]; 12137 for (int i=0;i<numberColumns;i++) 12138 marked[i]=1; 12139 for (int i=0;i<numberIntegers_;i++) 12140 marked[integerVariable_[i]]=2; 12141 if ((moreSpecialOptions2_&4)!=0) { 12142 for (int i=0;i<numberObjects_;i++) { 12143 CbcSwitchingBinary * object = dynamic_cast<CbcSwitchingBinary *> (object_[i]); 12144 if (object) { 12145 int iColumn = object>columnNumber(); 12146 const int * other = object>otherVariable(); 12147 marked[iColumn]=3other[0]; 12148 int n=object>numberOther(); 12149 for (int k=0;k<n;k++) 12150 marked[other[k]]=iColumn; 12151 } 12152 } 12153 } 12154 const double * element = solver_>getMatrixByCol()>getElements(); 12155 const int * row = solver_>getMatrixByCol()>getIndices(); 12156 const CoinBigIndex * columnStart = solver_>getMatrixByCol()>getVectorStarts(); 12157 const int * columnLength = solver_>getMatrixByCol()>getVectorLengths(); 12158 const CoinPackedMatrix * rowCopy = solver_>getMatrixByRow(); 12159 const int * column = rowCopy>getIndices(); 12160 const int * rowLength = rowCopy>getVectorLengths(); 12161 const CoinBigIndex * rowStart = rowCopy>getVectorStarts(); 12162 const double * elementByRow = rowCopy>getElements(); 12163 double objValue=offset; 12164 for (int iColumn = 0; iColumn < numberColumns; iColumn++) { 12165 double value = solution[iColumn]; 12166 objValue += value*objective[iColumn]; 12167 if (value>columnUpper[iColumn]) { 12168 if (valuecolumnUpper[iColumn]>1.0e8) 12169 printf("column %d has value %.12g above %.12g\n",iColumn,value,columnUpper[iColumn]); 12170 value=columnUpper[iColumn]; 12171 } else if (value<columnLower[iColumn]) { 12172 if (valuecolumnLower[iColumn]<1.0e8) 12173 printf("column %d has value %.12g below %.12g\n",iColumn,value,columnLower[iColumn]); 12174 value=columnLower[iColumn]; 12175 } 12176 if (value) { 12177 CoinBigIndex start = columnStart[iColumn]; 12178 CoinBigIndex end = start + columnLength[iColumn]; 12179 for (CoinBigIndex j = start; j < end; j++) { 12180 int iRow = row[j]; 12181 rowActivity[iRow] += value * element[j]; 12182 rowSum[iRow] += fabs(value * element[j]); 12183 } 12184 } 12185 } 12186 for (int i = 0 ; i < numberRows ; i++) { 12187 #if 0 //def CLP_INVESTIGATE 12188 double inf; 12189 inf = rowLower[i]  rowActivity[i]; 12190 if (inf > primalTolerance) 12191 printf("Row %d inf %g sum %g %g <= %g <= %g\n", 12192 i, inf, rowSum[i], rowLower[i], rowActivity[i], rowUpper[i]); 12193 inf = rowActivity[i]  rowUpper[i]; 12194 if (inf > primalTolerance) 12195 printf("Row %d inf %g sum %g %g <= %g <= %g\n", 12196 i, inf, rowSum[i], rowLower[i], rowActivity[i], rowUpper[i]); 12197 #endif 12198 double infeasibility = CoinMax(rowActivity[i]rowUpper[i], 12199 rowLower[i]rowActivity[i]); 12200 // but allow for errors 12201 double factor = CoinMax(1.0,rowSum[i]*1.0e3); 12202 if (infeasibility>largestInfeasibility*factor) { 12203 largestInfeasibility = infeasibility/factor; 12204 printf("Ainf of %g on row %d sum %g scaled %g\n", 12205 infeasibility,i,rowSum[i],largestInfeasibility); 12206 if (infeasibility>1.0e10) { 12207 for (CoinBigIndex j=rowStart[i]; 12208 j<rowStart[i]+rowLength[i];j++) { 12209 printf("col %d element %g marked %d\n", 12210 column[j],elementByRow[j],marked[column[j]]); 12211 } 12212 } 12213 } 12214 } 12215 delete [] rowActivity ; 12216 delete [] rowSum; 12217 delete [] marked; 12218 if (largestInfeasibility > 10.0*primalTolerance) 12219 printf("Alargest infeasibility is %g  obj %g\n", largestInfeasibility,objValue); 12220 else 12221 printf("Afeasible (%g)  obj %g\n", largestInfeasibility,objValue); 12222 } 12223 #endif 11503 12224 // point to useful information 11504 12225 OsiBranchingInformation usefulInfo = usefulInformation(); … … 11513 12234 for (i = 0; i < numberObjects_; i++) 11514 12235 object_[i]>feasibleRegion(solver_, &usefulInfo); 12236 #if CBC_USEFUL_PRINTING>14 12237 { 12238 int nBad=checkAssociated(solver_,solver_>getColSolution(),1); 12239 if (nBad) 12240 checkAssociated(solver_,solver_>getColSolution(),3); 12241 double largestInfeasibility = 0.0; 12242 double primalTolerance ; 12243 double offset; 12244 solver_>getDblParam(OsiObjOffset, offset); 12245 solver_>getDblParam(OsiPrimalTolerance, primalTolerance) ; 12246 const double *objective = getObjCoefficients() ; 12247 const double * rowLower = solver_>getRowLower() ; 12248 const double * rowUpper = solver_>getRowUpper() ; 12249 const double * columnLower = solver_>getColLower() ; 12250 const double * columnUpper = solver_>getColUpper() ; 12251 int numberRows = solver_>getNumRows() ; 12252 double *rowActivity = new double[numberRows] ; 12253 memset(rowActivity, 0, numberRows*sizeof(double)) ; 12254 double *rowSum = new double[numberRows] ; 12255 memset(rowSum, 0, numberRows*sizeof(double)) ; 12256 int * marked = new int [numberColumns]; 12257 for (int i=0;i<numberColumns;i++) 12258 marked[i]=1; 12259 for (int i=0;i<numberIntegers_;i++) 12260 marked[integerVariable_[i]]=2; 12261 if ((moreSpecialOptions2_&4)!=0) { 12262 for (int i=0;i<numberObjects_;i++) { 12263 CbcSwitchingBinary * object = dynamic_cast<CbcSwitchingBinary *> (object_[i]); 12264 if (object) { 12265 int iColumn = object>columnNumber(); 12266 const int * other = object>otherVariable(); 12267 marked[iColumn]=3other[0]; 12268 int n=object>numberOther(); 12269 for (int k=0;k<n;k++) 12270 marked[other[k]]=iColumn; 12271 } 12272 } 12273 } 12274 const double * element = solver_>getMatrixByCol()>getElements(); 12275 const int * row = solver_>getMatrixByCol()>getIndices(); 12276 const CoinBigIndex * columnStart = solver_>getMatrixByCol()>getVectorStarts(); 12277 const int * columnLength = solver_>getMatrixByCol()>getVectorLengths(); 12278 const CoinPackedMatrix * rowCopy = solver_>getMatrixByRow(); 12279 const int * column = rowCopy>getIndices(); 12280 const int * rowLength = rowCopy>getVectorLengths(); 12281 const CoinBigIndex * rowStart = rowCopy>getVectorStarts(); 12282 const double * elementByRow = rowCopy>getElements(); 12283 double objValue=offset; 12284 for (int iColumn = 0; iColumn < numberColumns; iColumn++) { 12285 double value = solution[iColumn]; 12286 objValue += value*objective[iColumn]; 12287 if (value>columnUpper[iColumn]) { 12288 if (valuecolumnUpper[iColumn]>1.0e8) 12289 printf("column %d has value %.12g above %.12g\n",iColumn,value,columnUpper[iColumn]); 12290 value=columnUpper[iColumn]; 12291 } else if (value<columnLower[iColumn]) { 12292 if (valuecolumnLower[iColumn]<1.0e8) 12293 printf("column %d has value %.12g below %.12g\n",iColumn,value,columnLower[iColumn]); 12294 value=columnLower[iColumn]; 12295 } 12296 if (value) { 12297 CoinBigIndex start = columnStart[iColumn]; 12298 CoinBigIndex end = start + columnLength[iColumn]; 12299 for (CoinBigIndex j = start; j < end; j++) { 12300 int iRow = row[j]; 12301 rowActivity[iRow] += value * element[j]; 12302 rowSum[iRow] += fabs(value * element[j]); 12303 } 12304 } 12305 } 12306 for (int i = 0 ; i < numberRows ; i++) { 12307 #if 0 //def CLP_INVESTIGATE 12308 double inf; 12309 inf = rowLower[i]  rowActivity[i]; 12310 if (inf > primalTolerance) 12311 printf("Row %d inf %g sum %g %g <= %g <= %g\n", 12312 i, inf, rowSum[i], rowLower[i], rowActivity[i], rowUpper[i]); 12313 inf = rowActivity[i]  rowUpper[i]; 12314 if (inf > primalTolerance) 12315 printf("Row %d inf %g sum %g %g <= %g <= %g\n", 12316 i, inf, rowSum[i], rowLower[i], rowActivity[i], rowUpper[i]); 12317 #endif 12318 double infeasibility = CoinMax(rowActivity[i]rowUpper[i], 12319 rowLower[i]rowActivity[i]); 12320 // but allow for errors 12321 double factor = CoinMax(1.0,rowSum[i]*1.0e3); 12322 if (infeasibility>largestInfeasibility*factor) { 12323 largestInfeasibility = infeasibility/factor; 12324 printf("inf of %g on row %d sum %g scaled %g\n", 12325 infeasibility,i,rowSum[i],largestInfeasibility); 12326 if (infeasibility>1.0e10) { 12327 for (CoinBigIndex j=rowStart[i]; 12328 j<rowStart[i]+rowLength[i];j++) { 12329 printf("col %d element %g marked %d\n", 12330 column[j],elementByRow[j],marked[column[j]]); 12331 } 12332 } 12333 } 12334 } 12335 delete [] rowActivity ; 12336 delete [] rowSum; 12337 delete [] marked; 12338 if (largestInfeasibility > 10.0*primalTolerance) 12339 printf("Largest infeasibility is %g  obj %g\n", largestInfeasibility,objValue); 12340 else 12341 printf("Feasible (%g)  obj %g\n", largestInfeasibility,objValue); 12342 } 12343 #endif 11515 12344 // If relaxed then leave bounds on basic variables 11516 12345 if (fixVariables == 1 && (specialOptions_&16) == 0) { … … 11533 12362 } 11534 12363 // We can switch off check 11535 if ((specialOptions_&4) == 0 ) {12364 if ((specialOptions_&4) == 0 && (moreSpecialOptions2_&10) != 8) { 11536 12365 if ((specialOptions_&2) == 0 && solverCharacteristics_>warmStart()) { 11537 12366 /* … … 11559 12388 solver_>setHintParam(OsiDoDualInInitial, true, OsiHintTry); 11560 12389 solver_>initialSolve(); 12390 #ifdef SWITCH_VARIABLES 12391 if (solver_>isProvenOptimal()) { 12392 int nBad=checkAssociated(solver_,solver_>getColSolution(),1); 12393 if (nBad) 12394 checkAssociated(solver_,solver_>getColSolution(),3); 12395 } 12396 #endif 11561 12397 #ifdef JJF_ZERO 11562 12398 if (solver_>isProvenOptimal()) { 11563 solver_>writeMps("feasible"); 12399 solver_>writeMpsNative("feasible.mps",NULL,NULL,2); 12400 #ifdef COIN_HAS_CLP 12401 OsiClpSolverInterface * clpSolver 12402 = dynamic_cast<OsiClpSolverInterface *> (solver_); 12403 if (clpSolver ) { 12404 clpSolver>getModelPtr()>writeBasis("feasible.bas",true); 12405 } 12406 #endif 11564 12407 printf("XXXXXXXXXXXX  saving feasible\n"); 11565 12408 } 11566 12409 #endif 11567 12410 if (!solver_>isProvenOptimal()) { 11568 #if C OIN_DEVELOP>112411 #if CBC_FEASIBILITY_INVESTIGATE 11569 12412 printf("checkSolution infeas! Retrying with primal.\n"); 11570 12413 #endif … … 11588 12431 solver_>setWarmStart(slack); 11589 12432 delete slack ; 11590 #if C OIN_DEVELOP>112433 #if CBC_FEASIBILITY_INVESTIGATE 11591 12434 printf("checkSolution infeas! Retrying wihout basis and with primal.\n"); 11592 12435 #endif 11593 12436 solver_>initialSolve(); 11594 #if COIN_DEVELOP>1 12437 //solver_>writeMps("bad"); 12438 #ifdef COIN_HAS_CLP 12439 if (!solver_>isProvenOptimal()&&modifiedTolerances) { 12440 // Restore 12441 ClpSimplex * clp = clpContinuousSolver>getModelPtr(); 12442 #ifndef CBC_LEAVE_TOLERANCE_ON_CHECK_SOLUTION 12443 clp>setPrimalTolerance(savePrimalTolerance); 12444 #endif 12445 #ifndef CBC_LEAVE_PERTURBATION_ON_CHECK_SOLUTION 12446 clp>setPerturbation(savePerturbation); 12447 #endif 12448 #ifndef CBC_LEAVE_SCALING_ON_CHECK_SOLUTION 12449 clp>scaling(saveScaling); 12450 #endif 12451 solver_>resolve(); 12452 } 12453 #endif 12454 #if CBC_FEASIBILITY_INVESTIGATE 11595 12455 if (!solver_>isProvenOptimal()) { 11596 12456 printf("checkSolution still infeas!\n"); … … 11624 12484 double integerTolerance = getIntegerTolerance() ; 11625 12485 #endif 11626 #if C OIN_DEVELOP>112486 #if CBC_FEASIBILITY_INVESTIGATE 11627 12487 const double * dj = solver_>getReducedCost(); 11628 12488 const double * colLower = saveSolver>getColLower(); … … 11638 12498 int nNotNeeded = 0; 11639 12499 #endif 11640 for (iColumn = 0 ; iColumn < numberCo lumns ; iColumn++) {12500 for (iColumn = 0 ; iColumn < numberContinuousColumns ; iColumn++) { 11641 12501 double value = solution[iColumn] ; 11642 12502 value = CoinMax(value, saveLower[iColumn]) ; … … 11644 12504 if (solver_>isInteger(iColumn)) { 11645 12505 assert(fabs(value  solution[iColumn]) <= 100.0*integerTolerance) ; 11646 #if C OIN_DEVELOP>112506 #if CBC_FEASIBILITY_INVESTIGATE 11647 12507 double value2 = floor(value + 0.5); 11648 12508 if (dj[iColumn] < 1.0e6) { … … 11695 12555 solution[iColumn] = value ; 11696 12556 } 11697 #if C OIN_DEVELOP>112557 #if CBC_FEASIBILITY_INVESTIGATE 11698 12558 printf("nAtLbNat %d,nAtUbNat %d,nAtLbNatZero %d,nAtUbNatZero %d,nAtLbFixed %d,nAtUbFixed %d,nAtOther %d,nAtOtherNat %d, useless %d\n", 11699 12559 nAtLbNatural, … … 11734 12594 const CoinBigIndex * columnStart = solver_>getMatrixByCol()>getVectorStarts(); 11735 12595 const int * columnLength = solver_>getMatrixByCol()>getVectorLengths(); 11736 for (iColumn = 0; iColumn < numberColumns; iColumn++) { 11737 double value = solution[iColumn]; 12596 double offset; 12597 solver_>getDblParam(OsiObjOffset, offset); 12598 double objValue=offset; 12599 const double *objective = getObjCoefficients() ; 12600 for (int iColumn = 0; iColumn < numberColumns; iColumn++) { 12601 double value = solution[iColumn]; 12602 objValue += value*objective[iColumn]; 11738 12603 if (value) { 11739 12604 CoinBigIndex start = columnStart[iColumn]; … … 11747 12612 } 11748 12613 for (i = 0 ; i < numberRows ; i++) { 11749 #if def CLP_INVESTIGATE12614 #if CBC_FEASIBILITY_INVESTIGATE>1 11750 12615 double inf; 11751 12616 inf = rowLower[i]  rowActivity[i]; … … 11762 12627 // but allow for errors 11763 12628 double factor = CoinMax(1.0,rowSum[i]*1.0e3); 11764 if (infeasibility>largestInfeasibility*factor) 12629 if (infeasibility>largestInfeasibility*factor) { 11765 12630 largestInfeasibility = infeasibility/factor; 12631 //printf("inf of %g on row %d sum %g scaled %g\n", 12632 // infeasibility,i,rowSum[i],largestInfeasibility); 12633 } 11766 12634 } 11767 12635 delete [] rowActivity ; 11768 12636 delete [] rowSum; 11769 #ifdef CLP_INVESTIGATE 12637 #if CBC_FEASIBILITY_INVESTIGATE==0 12638 if (handler_>logLevel()>2) { 12639 #endif 12640 if (largestInfeasibility > 10.0*primalTolerance) 12641 printf("BLargest infeasibility is %g  obj %g (%g)\n", largestInfeasibility,objValue,objectiveValue); 12642 else 12643 printf("BFeasible (%g)  obj %g %g\n", largestInfeasibility,objValue,objectiveValue); 12644 #if CBC_FEASIBILITY_INVESTIGATE==0 12645 } 12646 #endif 12647 //if (fabs(objValueobjectiveValue)>1.0e7*fabs(objectiveValue)) { 12648 //printf("Bad obj values\n"); 12649 objectiveValue = objValue; 12650 //} 12651 #if CBC_FEASIBILITY_INVESTIGATE 11770 12652 if (largestInfeasibility > 10.0*primalTolerance) 11771 printf(" largest infeasibility is %g\n", largestInfeasibility);11772 #endif 11773 if (largestInfeasibility > 1000.0*primalTolerance) {12653 printf("XX largest infeasibility is %g\n", largestInfeasibility); 12654 #endif 12655 if (largestInfeasibility > 200.0*primalTolerance) { 11774 12656 handler_>message(CBC_NOTFEAS3, messages_) 11775 12657 << largestInfeasibility << CoinMessageEol ; … … 11803 12685 solver_ = saveSolver; 11804 12686 testSolution_ = save; 12687 #ifdef COIN_HAS_CLP 12688 if (modifiedTolerances) { 12689 // Restore 12690 ClpSimplex * clp = clpContinuousSolver>getModelPtr(); 12691 #ifndef CBC_LEAVE_TOLERANCE_ON_CHECK_SOLUTION 12692 clp>setPrimalTolerance(savePrimalTolerance); 12693 #endif 12694 #ifndef CBC_LEAVE_PERTURBATION_ON_CHECK_SOLUTION 12695 clp>setPerturbation(savePerturbation); 12696 #endif 12697 #ifndef CBC_LEAVE_SCALING_ON_CHECK_SOLUTION 12698 clp>scaling(saveScaling); 12699 #endif 12700 } 12701 #endif 11805 12702 return objectiveValue; 11806 12703 } else { … … 11943 12840 11944 12841 { 12842 11945 12843 double * solution = CoinCopyOfArray(solutionIn, solver_>getNumCols()); 11946 12844 #ifdef JJF_ZERO … … 11980 12878 assert(basis != NULL); 11981 12879 objectiveValue = checkSolution(cutoff, solution, fixVariables, objectiveValue); 11982 if (saveObjectiveValue + 1.0e3 < objectiveValue) { 11983 #if COIN_DEVELOP>1 12880 if (cutoff>1.0e40&&objectiveValue<1.0e10) 12881 saveObjectiveValue = objectiveValue; // take anyway 12882 if (saveObjectiveValue + 1.0e3 +1.0e7*fabs(saveObjectiveValue) 12883 < objectiveValue) { 12884 #if CBC_FEASIBILITY_INVESTIGATE 11984 12885 printf("First try at solution had objective %.16g, rechecked as %.16g\n", 11985 12886 saveObjectiveValue, objectiveValue); … … 11995 12896 double objectiveValue2 = saveObjectiveValue; 11996 12897 objectiveValue2 = checkSolution(cutoff, solution2, 1, objectiveValue2); 11997 #if C OIN_DEVELOP>112898 #if CBC_FEASIBILITY_INVESTIGATE 11998 12899 printf("Relaxed second try had objective of %.16g\n", 11999 12900 objectiveValue2); … … 12007 12908 int iAway = 1; 12008 12909 double largestInfeasibility = tolerance; 12009 #if C OIN_DEVELOP>112910 #if CBC_FEASIBILITY_INVESTIGATE 12010 12911 int iInfeas = 1; 12011 12912 #endif … … 12016 12917 double value = solution2[i]; 12017 12918 if (value > columnUpper[i] + largestInfeasibility) { 12018 #if C OIN_DEVELOP>112919 #if CBC_FEASIBILITY_INVESTIGATE 12019 12920 iInfeas = i; 12020 12921 #endif 12021 12922 largestInfeasibility = value  columnUpper[i]; 12022 12923 } else if (value < columnLower[i]  largestInfeasibility) { 12023 #if C OIN_DEVELOP>112924 #if CBC_FEASIBILITY_INVESTIGATE 12024 12925 iInfeas = i; 12025 12926 #endif … … 12040 12941 } 12041 12942 } 12042 #if C OIN_DEVELOP>112943 #if CBC_FEASIBILITY_INVESTIGATE 12043 12944 if (iInfeas >= 0) 12044 12945 printf("Largest infeasibility of %g on column %d  tolerance %g\n", … … 12061 12962 objectiveValue = objectiveValue2; 12062 12963 } 12063 } 12964 } else if (!parentModel_) { 12965 // not good 12966 messageHandler()>message(CBC_FPUMP2, messages()) 12967 << "On closer inspection  solution discarded" 12968 << CoinMessageEol ; 12969 } 12064 12970 delete [] solution2; 12065 12971 solver_>setWarmStart(basis2); … … 12099 13005 // But allow for rounding errors 12100 13006 if (dblParam_[CbcCutoffIncrement] == 1e5) { 12101 #if C OIN_DEVELOP>513007 #if CBC_FEASIBILITY_INVESTIGATE 12102 13008 if (saveObjectiveValue + 1.0e7 < bestObjective_) 12103 13009 printf("First try at solution had objective %.16g, rechecked as %.16g\n", … … 12109 13015 cutoff = 2.0e5; 12110 13016 } 13017 if (!parentModel_&&(moreSpecialOptions2_&2)!=0) { 13018 // put back objective 13019 solver_>setObjective(continuousSolver_>getObjCoefficients()); 13020 double offset; 13021 continuousSolver_>getDblParam(OsiObjOffset,offset); 13022 solver_>setDblParam(OsiObjOffset,offset); 13023 moreSpecialOptions2_ &= ~2; 13024 } 12111 13025 // This is not correct  that way cutoff can go up if maximization 12112 13026 //double direction = solver_>getObjSense(); … … 12657 13571 } else { 12658 13572 // relax a bit 12659 value = CoinMin(saveUpper, value + 1.0e 5* (fabs(saveUpper) + 1));13573 value = CoinMin(saveUpper, value + 1.0e8 * (fabs(saveUpper) + 1)); 12660 13574 } 12661 13575 if (value  saveLower < 1.0e7) … … 12671 13585 } else { 12672 13586 // relax a bit 12673 value = CoinMax(saveLower, value  1.0e 5* (fabs(saveLower) + 1));13587 value = CoinMax(saveLower, value  1.0e8 * (fabs(saveLower) + 1)); 12674 13588 } 12675 13589 if (saveUpper  value < 1.0e7) … … 12719 13633 newLower = CoinMax(lower[jColumn], 12720 13634 newLower 12721  1.0e 5* (fabs(lower[jColumn]) + 1));13635  1.0e8 * (fabs(lower[jColumn]) + 1)); 12722 13636 newUpper = CoinMin(upper[jColumn], 12723 13637 newUpper 12724 + 1.0e 5* (fabs(upper[jColumn]) + 1));13638 + 1.0e8 * (fabs(upper[jColumn]) + 1)); 12725 13639 } 12726 13640 solver>setColLower(jColumn, newLower); … … 12927 13841 } 12928 13842 // Make given cut into a global cut 12929 void 13843 int 12930 13844 CbcModel::makeGlobalCut(const OsiRowCut * cut) 12931 13845 { 13846 if (cut>row().getNumElements()>11) { 12932 13847 OsiRowCut newCut(*cut); 12933 13848 newCut.setGloballyValidAsInteger(2); 12934 13849 newCut.mutableRow().setTestForDuplicateIndex(false); 12935 globalCuts_.addCutIfNotDuplicate(newCut) ; 13850 return globalCuts_.addCutIfNotDuplicate(newCut,1) ; 13851 } else { 13852 assert (cut>row().getNumElements()==1); 13853 int iColumn = cut>row().getIndices()[0]; 13854 double value = cut>row().getElements()[0]; 13855 double lb = cut>lb(); 13856 double ub = cut>ub(); 13857 if (value>0) { 13858 if (lb>COIN_DBL_MAX) 13859 lb /= value; 13860 if (ub<COIN_DBL_MAX) 13861 ub /= value; 13862 } else { 13863 double saveUb=ub; 13864 if (lb>COIN_DBL_MAX) 13865 ub = lb/value; 13866 else 13867 ub = COIN_DBL_MAX; 13868 if (saveUb<COIN_DBL_MAX) 13869 lb = saveUb/value; 13870 else 13871 lb = COIN_DBL_MAX; 13872 } 13873 #if PRINT_CONFLICT==0 13874 if (handler_>logLevel() > 1) { 13875 #endif 13876 printf("Conflict cut at depth %d (%d elements)\n", 13877 currentDepth_,cut>row().getNumElements()); 13878 cut>print(); 13879 #if PRINT_CONFLICT==0 13880 } 13881 #endif 13882 const double * lower; 13883 const double * upper; 13884 if (topOfTree_) { 13885 lower = topOfTree_>lower(); 13886 upper = topOfTree_>upper(); 13887 lb = CoinMax(lb,lower[iColumn]); 13888 topOfTree_>setColLower(iColumn,lb); 13889 ub = CoinMin(ub,upper[iColumn]); 13890 topOfTree_>setColUpper(iColumn,ub); 13891 } else { 13892 lower = solver_>getColLower(); 13893 upper = solver_>getColUpper(); 13894 lb = CoinMax(lb,lower[iColumn]); 13895 solver_>setColLower(iColumn,lb); 13896 ub = CoinMin(ub,upper[iColumn]); 13897 solver_>setColUpper(iColumn,ub); 13898 } 13899 return 1; 13900 } 12936 13901 } 12937 13902 // Make given cut into a global cut 12938 void 13903 int 12939 13904 CbcModel::makeGlobalCut(const OsiRowCut & cut) 12940 13905 { … … 12942 13907 newCut.setGloballyValid(true); 12943 13908 newCut.mutableRow().setTestForDuplicateIndex(false); 12944 globalCuts_.addCutIfNotDuplicate(newCut) ;13909 return globalCuts_.addCutIfNotDuplicate(newCut) ; 12945 13910 } 12946 13911 // Make given column cut into a global cut … … 12948 13913 CbcModel::makeGlobalCut(const OsiColCut * cut) 12949 13914 { 13915 abort(); // need to think about top of tree 12950 13916 const double * lower; 12951 13917 const double * upper; … … 13066 14032 newCut.setLb(lo); 13067 14033 newCut.setRow(nConflict,column,values); 13068 printf("CUTa has %d (started at %d)  final bSum %g \n",nConflict,nC,bSum);14034 printf("CUTa has %d (started at %d)  final bSum %g  depth %d\n",nConflict,nC,bSum,currentDepth_); 13069 14035 if (nConflict>1) { 13070 14036 if ((specialOptions_&1) != 0) { … … 13146 14112 CbcModel::incrementUsed(const double * solution) 13147 14113 { 13148 // might as well mark all including continuous 13149 int numberColumns = solver_>getNumCols(); 13150 for (int i = 0; i < numberColumns; i++) { 14114 if(usedInSolution_) { 14115 // might as well mark all including continuous 14116 int numberColumns = solver_>getNumCols(); 14117 for (int i = 0; i < numberColumns; i++) { 13151 14118 if (solution[i]) 13152 usedInSolution_[i]++; 14119 usedInSolution_[i]++; 14120 } 13153 14121 } 13154 14122 } … … 13257 14225 if (probingInfo_ && currentDepth_ > 0) { 13258 14226 int nFix = probingInfo_>fixColumns(*solver); 14227 #ifdef SWITCH_VARIABLES 14228 if (nFix>0) 14229 fixAssociated(solver_,0); 14230 #endif 13259 14231 if (nFix < 0) { 13260 14232 #ifdef COIN_HAS_CLP … … 13308 14280 clpSimplex>largestPrimalError()); 13309 14281 if (error > 1.0e2  !clpSolver>isProvenOptimal()) { 13310 #if def CLP_INVESTIGATE14282 #if CBC_USEFUL_PRINTING>1 13311 14283 printf("Problem was %s largest dual error %g largest primal %g  safer cuts\n", 13312 14284 clpSolver>isProvenOptimal() ? "optimal" : "!infeasible", … … 13342 14314 } 13343 14315 clpSolver>setSpecialOptions(save2); 13344 #if def CLP_INVESTIGATE14316 #if CBC_USEFUL_PRINTING>1 13345 14317 if (clpSimplex>numberIterations() > 1000) 13346 14318 printf("node %d took %d iterations\n", numberNodes_, clpSimplex>numberIterations()); … … 13354 14326 #else 13355 14327 solver>resolve(); 14328 #endif 14329 #ifdef SWITCH_VARIABLES 14330 if (solver_>isProvenOptimal()) { 14331 int nBad=checkAssociated(solver_,solver_>getColSolution(),0); 14332 if (nBad) 14333 checkAssociated(solver_,solver_>getColSolution(),1); 14334 } 13356 14335 #endif 13357 14336 return solver>isProvenOptimal() ? 1 : 0; … … 13372 14351 clpSimplex>largestPrimalError()); 13373 14352 if (error > 1.0e2  !clpSolver>isProvenOptimal()) { 13374 #if def CLP_INVESTIGATE14353 #if CBC_USEFUL_PRINTING>1 13375 14354 printf("Problem was %s largest dual error %g largest primal %g  safer cuts\n", 13376 14355 clpSolver>isProvenOptimal() ? "optimal" : "!infeasible", … … 13406 14385 } 13407 14386 clpSolver>setSpecialOptions(save2); 13408 #if def CLP_INVESTIGATE14387 #if CBC_USEFUL_PRINTING>1 13409 14388 if (clpSimplex>numberIterations() > 1000) 13410 14389 printf("node %d took %d iterations\n", numberNodes_, clpSimplex>numberIterations()); … … 13855 14834 } 13856 14835 #endif 14836 #ifdef COIN_HAS_NTY 14837 if (symmetryInfo_) { 14838 CbcNodeInfo * infoX = oldNode ? oldNode>nodeInfo() : NULL; 14839 bool worthTrying = false; 14840 if (infoX) { 14841 CbcNodeInfo * info = infoX; 14842 for (int i=0;i<NTY_BAD_DEPTH;i++) { 14843 if (!info>parent()) { 14844 worthTrying = true; 14845 break; 14846 } 14847 info = info>parent(); 14848 if (info>symmetryWorked()) { 14849 worthTrying = true; 14850 break; 14851 } 14852 } 14853 } else { 14854 worthTrying=true; 14855 } 14856 if ((moreSpecialOptions2_&(128256))==(128256)&¤tDepth_>5) 14857 worthTrying=false; 14858 if (worthTrying) { 14859 int n=symmetryInfo_>orbitalFixing(solver_); 14860 if (n) { 14861 #if PRINT_MORE==0 14862 if (logLevel()>1) 14863 printf("%d orbital fixes\n",n); 14864 #endif 14865 solver_>resolve(); 14866 if(!isProvenOptimal()) { 14867 if (logLevel()>1) 14868 printf("infeasible after orbital fixing\n"); 14869 } 14870 } 14871 } 14872 } 14873 #endif 13857 14874 if (numberBeforeTrust_ == 0 ) { 13858 14875 anyAction = newNode>chooseBranch(this, oldNode, numberPassesLeft) ; … … 14123 15140 // zap parent nodeInfo 14124 15141 #ifdef COIN_DEVELOP 14125 printf("zapping3 CbcNodeInfo %x\n", reinterpret_cast<int>(newNode>nodeInfo()>parent()));15142 printf("zapping3 CbcNodeInfo %x\n", newNode>nodeInfo()>parent()); 14126 15143 #endif 14127 15144 if (newNode>nodeInfo()) … … 14265 15282 solver_>getDblParam(OsiObjOffset, offset); 14266 15283 solver_>setRowUpper(cutoffRowNumber_,cutoff+offset); 15284 if (continuousSolver_&&solver_>getNumCols()>continuousSolver_>getNumCols()) { 15285 solver_>setRowUpper(cutoffRowNumber_,floor(cutoff)+offset); 15286 solver_>setRowLower(cutoffRowNumber_,floor(cutoff)+offset); 15287 } 14267 15288 } 14268 15289 } … … 14331 15352 bool exitNow = false; 14332 15353 for (i = 0; i < numberHeuristics_; i++) { 14333 heuristic_[i]>setModelOnly(this);14334 15354 if (heuristic_[i]>exitNow(bestObjective_)) 14335 15355 exitNow = true; … … 14457 15477 line << CoinMessageEol ; 14458 15478 } 15479 //#define DEBUG_BEST 15480 #ifdef DEBUG_BEST 15481 FILE * fp = fopen("solution.data","rb"); 15482 if (!fp&&ifSol>0) { 15483 int numberColumns=getNumCols(); 15484 fp = fopen("solution.data","wb"); 15485 printf("Solution data on file solution.data\n"); 15486 size_t numberWritten; 15487 numberWritten=fwrite(&numberColumns,sizeof(int),1,fp); 15488 assert (numberWritten==1); 15489 numberWritten=fwrite(&heuristicValue,sizeof(double),1,fp); 15490 assert (numberWritten==1); 15491 numberWritten=fwrite(newSolution,sizeof(double),numberColumns,fp); 15492 assert (numberWritten==numberColumns); 15493 fclose(fp); 15494 } else if (fp) { 15495 int numberColumns=getNumCols(); 15496 int numberColumnsX; 15497 size_t numberRead; 15498 numberRead=fread(&numberColumnsX,sizeof(int),1,fp); 15499 assert (numberRead==1); 15500 if (numberColumns==numberColumnsX) { 15501 numberRead=fread(&heuristicValue,sizeof(double),1,fp); 15502 assert (numberRead==1); 15503 numberRead=fread(newSolution,sizeof(double),numberColumns,fp); 15504 assert (numberRead==numberColumns); 15505 ifSol=1; 15506 } 15507 fclose(fp); 15508 } 15509 #endif 14459 15510 if (ifSol > 0) { 14460 15511 // better solution found … … 14471 15522 // numberSolutions_++; 14472 15523 numberHeuristicSolutions_++; 14473 #ifdef CLP_INVESTIGATE15524 #ifdef HEURISTIC_INFORM 14474 15525 printf("HEUR %s where %d C\n", 14475 15526 lastHeuristic_>heuristicName(), whereFrom); … … 14501 15552 } else { 14502 15553 // NOT better solution 14503 #if def CLP_INVESTIGATE15554 #if CBC_USEFUL_PRINTING>1 14504 15555 printf("HEUR %s where %d REJECTED i==%d\n", 14505 15556 heuristic_[i]>heuristicName(), whereFrom, i); … … 14854 15905 } 14855 15906 int save2 = maximumDepth_; 14856 int retCode = addCuts(node, lastws, numberFixedNow_ > numberFixedAtRoot_); 15907 int retCode = addCuts(node, lastws); 15908 #ifdef SWITCH_VARIABLES 15909 fixAssociated(solver_,0); 15910 #endif 14857 15911 //if (save1<maximumNumberCuts_) { 14858 15912 // increased … … 14979 16033 } 14980 16034 #ifdef COIN_HAS_CLP 14981 bool fathomDone = false;14982 16035 OsiClpSolverInterface * clpSolver 14983 16036 = dynamic_cast<OsiClpSolverInterface *> (solver_); … … 15108 16161 simplex>setMoreSpecialOptions(saveMoreOptions); 15109 16162 simplex>setPerturbation(perturbation); 15110 numberExtraNodes_ += info>numberNodesExplored_;15111 numberExtraIterations_ += info>numberIterations_;16163 incrementExtra(info>numberNodesExplored_, 16164 info>numberIterations_); 15112 16165 char general[200]; 15113 16166 int fathomStatus=info>nNodes_; … … 15128 16181 FATHOM_BIAS  fastNodeDepth_ << CoinMessageEol ; 15129 16182 #endif 15130 #if def CLP_INVESTIGATE16183 #if CBC_USEFUL_PRINTING>0 15131 16184 printf(">10000  depth now %d so at depth >= %d\n", 15132 16185 fastNodeDepth_, FATHOM_BIAS  fastNodeDepth_); … … 15136 16189 // we gave up 15137 16190 //abort(); 15138 fastNodeDepth_ = 3;16191 fastNodeDepth_ = (info>nNodes_==10) ? 5 : 2; 15139 16192 #ifndef NO_FATHOM_PRINT 15140 16193 if ((moreSpecialOptions_&262144) != 0) … … 15142 16195 FATHOM_BIAS  fastNodeDepth_ << CoinMessageEol ; 15143 16196 #endif 15144 #if def CLP_INVESTIGATE15145 printf(" fastNodeDepth now %d  so at depth >= %d\n",16197 #if CBC_USEFUL_PRINTING>0 16198 printf("gave up fastNodeDepth now %d  so at depth >= %d\n", 15146 16199 fastNodeDepth_, FATHOM_BIAS  fastNodeDepth_); 15147 16200 #endif … … 15154 16207 clpSolver>setWarmStart(NULL); 15155 16208 // try and do solution 15156 double value = simplex>objectiveValue() * 15157 simplex>optimizationDirection(); 16209 double value = simplex>objectiveValue(); 15158 16210 double * newSolution = 15159 16211 CoinCopyOfArray(simplex>primalColumnSolution(), … … 15172 16224 clpSolver>setWarmStart(NULL); 15173 16225 // try and do solution 15174 double value = simplex>objectiveValue() * 15175 simplex>optimizationDirection(); 16226 double value = simplex>objectiveValue(); 15176 16227 double * newSolution = 15177 16228 CoinCopyOfArray(simplex>primalColumnSolution(), 15178 16229 numberColumns); 15179 16230 setBestSolution(CBC_STRONGSOL, value, newSolution) ; 16231 // in case of inaccuracy 16232 simplex>setObjectiveValue(CoinMax(bestObjective_, 16233 simplex>objectiveValue())); 15180 16234 delete [] newSolution; 15181 16235 } … … 15207 16261 } 15208 16262 //printf("range of costs %g to %g\n",smallest,largest); 15209 // If value of objective borderline then may not be feasible15210 double value = simplex>objectiveValue() * simplex>optimizationDirection();15211 if (value  getCutoff() < 1.0e1)15212 fathomDone = true;15213 16263 } 15214 16264 simplex>setLogLevel(saveLevel); … … 15281 16331 setBestSolution(CBC_STRONGSOL, value, newSolution) ; 15282 16332 delete [] newSolution; 15283 fathomDone = true;15284 } else {15285 feasible = false;15286 16333 } 15287 16334 #endif … … 15293 16340 int numberPasses = /*doCutsNow(1) ?*/ maximumCutPasses_ /*: 0*/; 15294 16341 feasible = solveWithCuts(cuts, numberPasses, node); 15295 if (fathomDone)15296 assert (feasible);15297 16342 } 15298 16343 #else … … 15811 16856 int iHeur ; 15812 16857 int whereFrom = 3; 16858 // allow more heuristics 16859 currentPassNumber_=0; 15813 16860 for (iHeur = 0 ; iHeur < numberHeuristics_ ; iHeur++) { 15814 16861 // skip if can't run here … … 15827 16874 } else { 15828 16875 lastHeuristic_ = heuristic_[found]; 15829 #ifdef CLP_INVESTIGATE16876 #ifdef HEURISTIC_INFORM 15830 16877 printf("HEUR %s where %d D\n", 15831 16878 lastHeuristic_>heuristicName(), whereFrom); … … 15836 16883 } 15837 16884 } else if (ifSol < 0) { // just returning an estimate 15838 estValue =CoinMin(heurValue, estValue) ;16885 estValue = heurValue; //CoinMin(heurValue, estValue) ; 15839 16886 heurValue = saveValue ; 15840 16887 } … … 15842 16889 if (found >= 0 && parallelMode() > 0) { 15843 16890 lastHeuristic_ = heuristic_[found]; 15844 #if def CLP_INVESTIGATE16891 #if CBC_USEFUL_PRINTING>1 15845 16892 printf("HEUR %s where %d D\n", 15846 16893 lastHeuristic_>heuristicName(), whereFrom); … … 16001 17048 delete [] delRows ; 16002 17049 } 17050 numberNewCuts_=0; 16003 17051 } 16004 17052 #endif … … 16016 17064 usedInSolution_[i] = 0; 16017 17065 } 16018 baseModel>numberSolutions_++;16019 17066 if (bestObjective_ < baseModel>bestObjective_ && bestObjective_ < baseModel>getCutoff()) { 16020 17067 baseModel>bestObjective_ = bestObjective_ ; … … 16024 17071 CoinCopyN(bestSolution_, numberColumns, baseModel>bestSolution_); 16025 17072 baseModel>setCutoff(getCutoff()); 16026 } 17073 baseModel>handler_>message(CBC_ROUNDING, messages_) 17074 << bestObjective_ 17075 << "heuristic" 17076 << baseModel>numberIterations_ 17077 << baseModel>numberNodes_ << getCurrentSeconds() 17078 << CoinMessageEol; 17079 } 17080 baseModel>numberSolutions_++; 16027 17081 unlockThread(); 16028 17082 } … … 16140 17194 for (i = 0; i < numberIntegers_; i++) 16141 17195 back[integerVariable_[i]] = i; 16142 #if def CLP_INVESTIGATE17196 #if CBC_USEFUL_PRINTING>1 16143 17197 int numberNot = 0; 16144 17198 #endif … … 16148 17202 if (!obj) 16149 17203 continue; 16150 #if def CLP_INVESTIGATE17204 #if CBC_USEFUL_PRINTING>1 16151 17205 if (obj>numberTimesDown() < numberBeforeTrust_  16152 17206 obj>numberTimesUp() < numberBeforeTrust_) … … 16169 17223 } 16170 17224 } 16171 #if def CLP_INVESTIGATE417225 #if CBC_USEFUL_PRINTING>5 16172 17226 if (priority) 16173 17227 printf("Before fathom %d not trusted out of %d\n", … … 16272 17326 * dblParam_[CbcAllowableFractionGap]); 16273 17327 returnCode = (bestObjective_  bestPossibleObjective_ < testGap && getCutoffIncrement() >= 0.0); 16274 } 17328 } 17329 #if 0 17330 if (returnCode) { 17331 if (fabs(bestObjective_+1469650.0)<1.0) { 17332 fprintf(stderr,"BAD  cr to continue\n"); 17333 fflush(stdout); 17334 char xx; 17335 xx=getc(stdin); 17336 } 17337 } 17338 #endif 16275 17339 return returnCode; 16276 17340 } … … 16435 17499 OsiClpSolverInterface * clpSolver 16436 17500 = dynamic_cast<OsiClpSolverInterface *> (solver_); 16437 if (clpSolver && numberNodes_ >= numberNodes && numberNodes_ < 2*numberNodes ) {17501 if (clpSolver && numberNodes_ >= numberNodes && numberNodes_ < 2*numberNodes && clpSolver>getNumRows() < 10000) { 16438 17502 if (numberIterations_ < (numberSolves_ + numberNodes_)*10) { 16439 17503 //if (numberIterations_<numberNodes_*20) { … … 16739 17803 // better solution save 16740 17804 lastHeuristic_ = heuristic_[found]; 16741 #ifdef CLP_INVESTIGATE17805 #ifdef HEURISTIC_INFORM 16742 17806 printf("HEUR %s where %d oddE\n", 16743 17807 lastHeuristic_>heuristicName(), whereFrom); … … 16938 18002 bool hitMaxTime = (totalTime >= maxSeconds); 16939 18003 if (parentModel_ && !hitMaxTime) { 16940 // In a sub tree 18004 // In a sub tree 16941 18005 assert (parentModel_); 16942 18006 maxSeconds = parentModel_>getMaximumSeconds(); … … 17658 18722 char general[200]; 17659 18723 if (clpSolver) { 17660 clpSolver>getModelPtr()>dual(); // probably not needed 18724 sprintf(general,"Starting multiple root solver"); 18725 model>messageHandler()>message(CBC_GENERAL, 18726 model>messages()) 18727 << general << CoinMessageEol ; 18728 clpSolver>setHintParam(OsiDoReducePrint, true, OsiHintTry); 18729 ClpSimplex * simplex = clpSolver>getModelPtr(); 18730 int logLevel=simplex>logLevel(); 18731 if (logLevel<=1) 18732 simplex>setLogLevel(0); 18733 simplex>dual(); 18734 simplex>setLogLevel(logLevel); 17661 18735 clpSolver>setWarmStart(NULL); 17662 sprintf(general,"Starting multiple root solver");17663 18736 } else { 17664 #endif17665 #ifdef COIN_HAS_CLP17666 18737 model>initialSolve(); 17667 18738 sprintf(general,"Solver did %d iterations in initialSolve\n", 17668 18739 model>solver()>getIterationCount()); 17669 }17670 #endif 17671 model>messageHandler()>message(CBC_GENERAL, 17672 model>messages()) 17673 << general << CoinMessageEol ; 18740 model>messageHandler()>message(CBC_GENERAL, 18741 model>messages()) 18742 << general << CoinMessageEol ; 18743 } 18744 #endif 17674 18745 model>branchAndBound(); 17675 18746 sprintf(general,"Ending multiple root solver"); … … 17743 18814 for (int iRow=numberRowsAtContinuous_;iRow<numberRows;iRow++) { 17744 18815 int iType=whichGenerator[iRow]; 17745 if ((iType>=0&&iType< 10000)iType<1) {18816 if ((iType>=0&&iType<20000)) { 17746 18817 if (fabs(ray[iRow])>1.0e10) { 17747 18818 badRows++; … … 18052 19123 return cut; 18053 19124 } 18054
Note: See TracChangeset
for help on using the changeset viewer.