Changeset 1785
- Timestamp:
- Aug 25, 2011 6:17:49 AM (9 years ago)
- Location:
- trunk/Clp/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Clp/src/ClpSimplex.cpp
r1769 r1785 669 669 } 670 670 } 671 #if CAN_HAVE_ZERO_OBJ>1 672 if ((specialOptions_&2097152)==0) { 673 #endif 671 674 computeDuals(givenDuals); 672 675 if ((moreSpecialOptions_ & 128) != 0 && !numberIterations_) { … … 692 695 checkBothSolutions(); 693 696 objectiveValue_ += objectiveModification / (objectiveScale_ * rhsScale_); 697 #if CAN_HAVE_ZERO_OBJ>1 698 } else { 699 checkPrimalSolution( rowActivityWork_, columnActivityWork_); 700 #ifndef COIN_REUSE_RANDOM 701 memset(dj_,0,(numberRows_+numberColumns_)*sizeof(double)); 702 #else 703 for (int iSequence=0;iSequence<numberRows_+numberColumns_;iSequence++) { 704 double value; 705 switch (getStatus(iSequence)) { 706 case atLowerBound: 707 value=1.0e-9*(1.0+CoinDrand48()); 708 break; 709 case atUpperBound: 710 value=-1.0e-9*(1.0+CoinDrand48()); 711 break; 712 default: 713 value=0.0; 714 break; 715 } 716 } 717 #endif 718 objectiveValue_=0.0; 719 } 720 #endif 694 721 if (handler_->logLevel() > 3 || (largestPrimalError_ > 1.0e-2 || 695 722 largestDualError_ > 1.0e-2)) -
trunk/Clp/src/ClpSimplexDual.cpp
r1780 r1785 1223 1223 bestPossiblePivot = dualColumn(rowArray_[0], columnArray_[0], rowArray_[3], 1224 1224 columnArray_[1], acceptablePivot, dubiousWeights); 1225 #if CAN_HAVE_ZERO_OBJ>1 1226 if ((specialOptions_&2097152)!=0) 1227 theta_=0.0; 1228 #endif 1225 1229 } else { 1226 1230 // Make sure direction plausible … … 1399 1403 //columnArray_[0]->cleanAndPackSafe(1.0e-60); 1400 1404 if (candidate == -1) { 1405 #if CLP_CAN_HAVE_ZERO_OBJ>1 1406 if ((specialOptions_&2097152)==0) { 1407 #endif 1401 1408 // make sure incoming doesn't count 1402 1409 Status saveStatus = getStatus(sequenceIn_); … … 1406 1413 objectiveChange, false); 1407 1414 setStatus(sequenceIn_, saveStatus); 1415 #if CLP_CAN_HAVE_ZERO_OBJ>1 1416 } else { 1417 rowArray_[0]->clear(); 1418 rowArray_[2]->clear(); 1419 columnArray_[0]->clear(); 1420 } 1421 #endif 1408 1422 } else { 1409 1423 updateDualsInValuesPass(rowArray_[0], columnArray_[0], theta_); … … 3778 3792 if (value > dualTolerance_) { 3779 3793 thisIncrease = true; 3794 #if CLP_CAN_HAVE_ZERO_OBJ<2 3780 3795 #define MODIFYCOST 2 3796 #endif 3781 3797 #if MODIFYCOST 3782 3798 // modify cost to hit new tolerance … … 4666 4682 if (lastCleaned < numberIterations_ && numberTimesOptimal_ < 4 && 4667 4683 (numberChanged_ || (specialOptions_ & 4096) == 0)) { 4684 #if CLP_CAN_HAVE_ZERO_OBJ 4668 4685 if ((specialOptions_&2097152)==0) { 4686 #endif 4669 4687 doOriginalTolerance = 2; 4670 4688 numberTimesOptimal_++; … … 4681 4699 } 4682 4700 cleanDuals = 2; // If nothing changed optimal else primal 4701 #if CLP_CAN_HAVE_ZERO_OBJ 4683 4702 } else { 4684 4703 // no cost - skip checks 4685 4704 problemStatus_=0; 4686 4705 } 4706 #endif 4687 4707 } else { 4688 4708 problemStatus_ = 0; // optimal … … 4939 4959 if (givenDuals) 4940 4960 dualTolerance_ = 1.0e50; 4961 #if CLP_CAN_HAVE_ZERO_OBJ>1 4962 if ((specialOptions_&2097152)==0) { 4963 #endif 4941 4964 updateDualsInDual(rowArray_[0], columnArray_[0], rowArray_[1], 4942 4965 0.0, objectiveChange, true); 4966 #if CLP_CAN_HAVE_ZERO_OBJ>1 4967 } else { 4968 rowArray_[0]->clear(); 4969 rowArray_[1]->clear(); 4970 columnArray_[0]->clear(); 4971 } 4972 #endif 4943 4973 dualTolerance_ = saveTolerance; 4944 4974 #if 0 … … 4971 5001 if (givenDuals) 4972 5002 dualTolerance_ = 1.0e50; 5003 #if CLP_CAN_HAVE_ZERO_OBJ>1 5004 if ((specialOptions_&2097152)==0) { 5005 #endif 4973 5006 updateDualsInDual(rowArray_[0], columnArray_[0], rowArray_[1], 4974 5007 0.0, objectiveChange, true); 5008 #if CLP_CAN_HAVE_ZERO_OBJ>1 5009 } else { 5010 rowArray_[0]->clear(); 5011 rowArray_[1]->clear(); 5012 columnArray_[0]->clear(); 5013 } 5014 #endif 4975 5015 dualTolerance_ = saveTolerance; 4976 5016 if (!numberIterations_ && sumPrimalInfeasibilities_ > -
trunk/Clp/src/ClpSimplexOther.cpp
r1784 r1785 942 942 // Restores solution from dualized problem 943 943 int 944 ClpSimplexOther::restoreFromDual(const ClpSimplex * dualProblem) 944 ClpSimplexOther::restoreFromDual(const ClpSimplex * dualProblem, 945 bool checkAccuracy) 945 946 { 946 947 int returnCode = 0;; … … 1187 1188 // Below will go to ..DEBUG later 1188 1189 #if 1 //ndef NDEBUG 1189 // Check if correct 1190 double * columnActivity = CoinCopyOfArray(columnActivity_, numberColumns_); 1191 double * rowActivity = CoinCopyOfArray(rowActivity_, numberRows_); 1192 double * reducedCost = CoinCopyOfArray(reducedCost_, numberColumns_); 1193 double * dual = CoinCopyOfArray(dual_, numberRows_); 1194 this->dual(); //primal(); 1195 CoinRelFltEq eq(1.0e-5); 1196 for (iRow = 0; iRow < numberRows_; iRow++) { 1197 assert(eq(dual[iRow], dual_[iRow])); 1190 if (checkAccuracy) { 1191 // Check if correct 1192 double * columnActivity = CoinCopyOfArray(columnActivity_, numberColumns_); 1193 double * rowActivity = CoinCopyOfArray(rowActivity_, numberRows_); 1194 double * reducedCost = CoinCopyOfArray(reducedCost_, numberColumns_); 1195 double * dual = CoinCopyOfArray(dual_, numberRows_); 1196 this->dual(); //primal(); 1197 CoinRelFltEq eq(1.0e-5); 1198 for (iRow = 0; iRow < numberRows_; iRow++) { 1199 assert(eq(dual[iRow], dual_[iRow])); 1200 } 1201 for (iColumn = 0; iColumn < numberColumns_; iColumn++) { 1202 assert(eq(columnActivity[iColumn], columnActivity_[iColumn])); 1203 } 1204 for (iRow = 0; iRow < numberRows_; iRow++) { 1205 assert(eq(rowActivity[iRow], rowActivity_[iRow])); 1206 } 1207 for (iColumn = 0; iColumn < numberColumns_; iColumn++) { 1208 assert(eq(reducedCost[iColumn], reducedCost_[iColumn])); 1209 } 1210 delete [] columnActivity; 1211 delete [] rowActivity; 1212 delete [] reducedCost; 1213 delete [] dual; 1198 1214 } 1199 for (iColumn = 0; iColumn < numberColumns_; iColumn++) {1200 assert(eq(columnActivity[iColumn], columnActivity_[iColumn]));1201 }1202 for (iRow = 0; iRow < numberRows_; iRow++) {1203 assert(eq(rowActivity[iRow], rowActivity_[iRow]));1204 }1205 for (iColumn = 0; iColumn < numberColumns_; iColumn++) {1206 assert(eq(reducedCost[iColumn], reducedCost_[iColumn]));1207 }1208 delete [] columnActivity;1209 delete [] rowActivity;1210 delete [] reducedCost;1211 delete [] dual;1212 1215 #endif 1213 1216 return returnCode; … … 1992 1995 while (!returnCode) { 1993 1996 //assert (reportIncrement); 1994 returnCode = parametricsLoop(startingTheta, endingTheta, reportIncrement, 1997 parametricsData paramData; 1998 paramData.startingTheta=startingTheta; 1999 paramData.endingTheta=endingTheta; 2000 paramData.lowerChange = chgLower; 2001 paramData.upperChange = chgUpper; 2002 returnCode = parametricsLoop(paramData, reportIncrement, 1995 2003 chgLower, chgUpper, chgObjective, data, 1996 2004 canTryQuick); 2005 startingTheta=paramData.startingTheta; 2006 endingTheta=paramData.endingTheta; 1997 2007 if (!returnCode) { 1998 2008 //double change = endingTheta-startingTheta; … … 2656 2666 } 2657 2667 int 2658 ClpSimplexOther::parametricsLoop( double startingTheta, double & endingTheta,double reportIncrement,2668 ClpSimplexOther::parametricsLoop(parametricsData & paramData,double reportIncrement, 2659 2669 const double * lowerChange, const double * upperChange, 2660 2670 const double * changeObjective, ClpDataSave & data, 2661 2671 bool canTryQuick) 2662 2672 { 2673 double startingTheta = paramData.startingTheta; 2674 double & endingTheta = paramData.endingTheta; 2663 2675 // stuff is already at starting 2664 2676 // For this crude version just try and go to end … … 2757 2769 reinterpret_cast<ClpSimplexDual *> (this)->whileIterating(saveDuals, 0); 2758 2770 } else { 2759 whileIterating(startingTheta, endingTheta, reportIncrement, 2760 lowerChange, upperChange, 2771 whileIterating(paramData, reportIncrement, 2761 2772 changeObjective); 2762 2773 startingTheta = endingTheta; … … 2804 2815 assert (ratio==1||ratio==2); 2805 2816 // allow for unscaled - even if not needed 2806 int lengthArrays = 4*numberTotal+( numberTotal+2)*ratio;2817 int lengthArrays = 4*numberTotal+(2*numberTotal+2)*ratio; 2807 2818 /* 2808 2819 Save information and modify … … 2819 2830 char * markDone = reinterpret_cast<char *>(lowerList+numberTotal); 2820 2831 memset(markDone,0,numberTotal); 2832 int * backwardBasic = lowerList+2*numberTotal; 2833 parametricsData paramData; 2834 paramData.lowerChange = lowerChange; 2835 paramData.lowerList=lowerList; 2836 paramData.upperChange = upperChange; 2837 paramData.upperList=upperList; 2838 paramData.markDone=markDone; 2839 paramData.backwardBasic=backwardBasic; 2821 2840 // Find theta when bounds will cross over and create arrays 2822 2841 memset(lowerChange, 0, numberTotal * sizeof(double)); … … 3036 3055 bool canSkipFactorization=true; 3037 3056 while (!returnCode) { 3038 returnCode = parametricsLoop(startingTheta, endingTheta, 3057 paramData.startingTheta=startingTheta; 3058 paramData.endingTheta=endingTheta; 3059 returnCode = parametricsLoop(paramData, 3039 3060 data,canSkipFactorization); 3061 startingTheta=paramData.startingTheta; 3062 endingTheta=paramData.endingTheta; 3040 3063 canSkipFactorization=false; 3041 3064 if (!returnCode) { … … 3064 3087 ray_ = new double [numberColumns_]; 3065 3088 } 3066 reinterpret_cast<ClpSimplexDual *> (this)->finishSolve(1);3067 3089 if (swapped&&lower_) { 3068 3090 double * temp=saveLower; … … 3073 3095 upper_=temp; 3074 3096 } 3097 reinterpret_cast<ClpSimplexDual *> (this)->finishSolve(0); 3075 3098 } 3076 3099 if (!scalingFlag_) { … … 3117 3140 } 3118 3141 int 3119 ClpSimplexOther::parametricsLoop( double & startingTheta, double & endingTheta,3142 ClpSimplexOther::parametricsLoop(parametricsData & paramData, 3120 3143 ClpDataSave & data,bool canSkipFactorization) 3121 3144 { 3145 double & startingTheta = paramData.startingTheta; 3146 double & endingTheta = paramData.endingTheta; 3122 3147 int numberTotal = numberRows_+numberColumns_; 3123 const double * lowerChange = lower_+numberTotal;3124 const double * upperChange = upper_+numberTotal;3125 3148 // stuff is already at starting 3126 int * lowerList = (reinterpret_cast<int *>(lower_+4*numberTotal))+2;3127 int * upperList = (reinterpret_cast<int *>(upper_+4*numberTotal))+2;3149 const int * lowerList = paramData.lowerList; 3150 const int * upperList = paramData.upperList; 3128 3151 problemStatus_ = -1; 3129 3152 //double saveEndingTheta=endingTheta; … … 3259 3282 // Do iterations 3260 3283 problemStatus_=-1; 3261 whileIterating(startingTheta, endingTheta, 0.0, 3262 lowerChange, upperChange, 3284 whileIterating(paramData, 0.0, 3263 3285 NULL); 3264 3286 //startingTheta = endingTheta; … … 3417 3439 */ 3418 3440 int 3419 ClpSimplexOther::whileIterating(double & startingTheta, double & endingTheta, double /*reportIncrement*/, 3420 const double * lowerChange, const double * upperChange, 3441 ClpSimplexOther::whileIterating(parametricsData & paramData, double /*reportIncrement*/, 3421 3442 const double * /*changeObjective*/) 3422 3443 { 3444 double & startingTheta = paramData.startingTheta; 3445 double & endingTheta = paramData.endingTheta; 3446 const double * lowerChange = paramData.lowerChange; 3447 const double * upperChange = paramData.upperChange; 3423 3448 int numberTotal = numberColumns_ + numberRows_; 3424 const int * lowerList = (reinterpret_cast<int *>(lower_+4*numberTotal))+2; 3425 const int * upperList = (reinterpret_cast<int *>(upper_+4*numberTotal))+2; 3449 const int * lowerList = paramData.lowerList; 3450 const int * upperList = paramData.upperList; 3451 // do basic pointers 3452 int * backwardBasic = paramData.backwardBasic; 3453 for (int i=0;i<numberTotal;i++) 3454 backwardBasic[i]=-1; 3455 for (int i=0;i<numberRows_;i++) { 3456 int iPivot=pivotVariable_[i]; 3457 backwardBasic[iPivot]=i; 3458 } 3426 3459 { 3427 3460 int i; … … 3446 3479 double increaseTheta = CoinMin(endingTheta - lastTheta, 1.0e50); 3447 3480 // Get theta for bounds - we know can't crossover 3448 int pivotType = nextTheta(1, increaseTheta, 3449 lowerChange, upperChange,NULL);3481 int pivotType = nextTheta(1, increaseTheta, paramData, 3482 NULL); 3450 3483 useTheta += theta_; 3451 3484 double change = useTheta - lastTheta; … … 3591 3624 //rowArray_[0]->cleanAndPackSafe(1.0e-60); 3592 3625 //columnArray_[0]->cleanAndPackSafe(1.0e-60); 3626 #if CLP_CAN_HAVE_ZERO_OBJ 3593 3627 if ((specialOptions_&2097152)==0) { 3628 #endif 3594 3629 nswapped = reinterpret_cast<ClpSimplexDual *> ( this)->updateDualsInDual(rowArray_[0], columnArray_[0], 3595 3630 rowArray_[2], theta_, 3596 3631 objectiveChange, false); 3597 3632 assert (!nswapped); 3633 #if CLP_CAN_HAVE_ZERO_OBJ 3598 3634 } else { 3599 3635 rowArray_[0]->clear(); … … 3601 3637 columnArray_[0]->clear(); 3602 3638 } 3639 #endif 3603 3640 // which will change basic solution 3604 3641 if (nswapped) { … … 3710 3747 } 3711 3748 // update primal solution 3749 #if CLP_CAN_HAVE_ZERO_OBJ 3750 if ((specialOptions_&2097152)!=0) 3751 theta_=0.0; 3752 #endif 3712 3753 if (theta_ < 0.0) { 3713 3754 #ifdef CLP_DEBUG … … 3737 3778 } 3738 3779 objectiveChange = 0.0; 3780 #if CLP_CAN_HAVE_ZERO_OBJ 3739 3781 if ((specialOptions_&2097152)==0) { 3782 #endif 3740 3783 for (int i=0;i<numberTotal;i++) 3741 3784 objectiveChange += solution_[i]*cost_[i]; 3742 3785 objectiveChange -= objectiveValue_; 3786 #if CLP_CAN_HAVE_ZERO_OBJ 3743 3787 } 3788 #endif 3744 3789 // outgoing 3745 3790 originalBound(sequenceOut_,useTheta,lowerChange,upperChange); … … 3750 3795 valueOut_ = lowerOut_; 3751 3796 dj_[sequenceOut_] = theta_; 3797 #if CLP_CAN_HAVE_ZERO_OBJ>1 3798 #ifdef COIN_REUSE_RANDOM 3799 if ((specialOptions_&2097152)!=0) { 3800 dj_[sequenceOut_] = 1.0e-9*(1.0+CoinDrand48());; 3801 } 3802 #endif 3803 #endif 3752 3804 } else { 3753 3805 valueOut_ = upperOut_; 3754 3806 dj_[sequenceOut_] = -theta_; 3807 #if CLP_CAN_HAVE_ZERO_OBJ>1 3808 #ifdef COIN_REUSE_RANDOM 3809 if ((specialOptions_&2097152)!=0) { 3810 dj_[sequenceOut_] = -1.0e-9*(1.0+CoinDrand48());; 3811 } 3812 #endif 3813 #endif 3755 3814 } 3756 3815 solution_[sequenceOut_] = valueOut_; 3757 3816 int whatNext = housekeeping(objectiveChange); 3817 assert (backwardBasic[sequenceOut_]==pivotRow_); 3818 backwardBasic[sequenceOut_]=-1; 3819 backwardBasic[sequenceIn_]=pivotRow_; 3758 3820 { 3759 3821 char in[200],out[200]; … … 3828 3890 theta_ = 0.0; 3829 3891 //adjust [4] from handler - but 3830 rowArray_[4]->clear(); // temp3892 //rowArray_[4]->clear(); // temp 3831 3893 if (action>=0&&action<10) 3832 3894 problemStatus_=-1; // carry on … … 4063 4125 // Computes next theta and says if objective or bounds (0= bounds, 1 objective, -1 none) 4064 4126 int 4065 ClpSimplexOther::nextTheta(int type, double maxTheta, 4066 const double * lowerChange, const double * upperChange, 4127 ClpSimplexOther::nextTheta(int type, double maxTheta, parametricsData & paramData, 4067 4128 const double * /*changeObjective*/) 4068 4129 { 4069 int numberTotal = numberColumns_ + numberRows_; 4070 const int * lowerList = (reinterpret_cast<int *>(lower_+4*numberTotal))+2; 4071 const int * upperList = (reinterpret_cast<int *>(upper_+4*numberTotal))+2; 4130 const double * lowerChange = paramData.lowerChange; 4131 const double * upperChange = paramData.upperChange; 4132 const int * lowerList = paramData.lowerList; 4133 const int * upperList = paramData.upperList; 4072 4134 int iSequence; 4073 4135 theta_ = maxTheta; … … 4081 4143 const CoinBigIndex * columnStart = matrix_->getVectorStarts(); 4082 4144 const double * elementByColumn = matrix_->getElements(); 4145 #if 0 4146 double tempArray[5000]; 4147 bool checkIt=false; 4148 if (factorization_->pivots()&&!needFullUpdate&&sequenceIn_<0) { 4149 memcpy(tempArray,array,numberRows_*sizeof(double)); 4150 checkIt=true; 4151 needFullUpdate=true; 4152 } 4153 #endif 4083 4154 if (!factorization_->pivots()||needFullUpdate) { 4084 4155 rowArray_[4]->clear(); … … 4187 4258 // ftran it 4188 4259 factorization_->updateColumn(rowArray_[0], rowArray_[4]); 4189 } else { 4190 assert (sequenceIn_>=0); 4260 #if 0 4261 if (checkIt) { 4262 for (int i=0;i<numberRows_;i++) { 4263 assert (fabs(tempArray[i]-array[i])<1.0e-8); 4264 } 4265 } 4266 #endif 4267 } else if (sequenceIn_>=0) { 4268 //assert (sequenceIn_>=0); 4191 4269 assert (sequenceOut_>=0); 4192 4270 assert (sequenceIn_!=sequenceOut_); … … 4260 4338 const int * index = rowArray_[4]->getIndices(); 4261 4339 int number = rowArray_[4]->getNumElements(); 4262 int * lowerList2 = (reinterpret_cast<int *>(lower_+4*numberTotal))+2; 4263 char * markDone = reinterpret_cast<char *>(lowerList2+numberTotal); 4264 #if 0 4265 for (int iPivot = 0; iPivot < numberRows_; iPivot++) { 4266 //int iPivot = index[iRow]; 4267 iSequence = pivotVariable_[iPivot]; 4268 // solution value will be sol - theta*alpha 4269 // bounds will be bounds + change *theta 4270 double currentSolution = solution_[iSequence]; 4271 double currentLower = lower_[iSequence]; 4272 double currentUpper = upper_[iSequence]; 4273 double alpha = array[iPivot]; 4274 assert (currentSolution >= currentLower - 100.0*primalTolerance_); 4275 assert (currentSolution <= currentUpper + 100.0*primalTolerance_); 4276 double thetaCoefficient; 4277 double hitsLower = COIN_DBL_MAX; 4278 thetaCoefficient = lowerChange[iSequence] + alpha; 4279 if (thetaCoefficient > 1.0e-8) 4280 hitsLower = (currentSolution - currentLower) / thetaCoefficient; 4281 //if (hitsLower < 0.0) { 4282 // does not hit - but should we check further 4283 // hitsLower = COIN_DBL_MAX; 4284 //} 4285 double hitsUpper = COIN_DBL_MAX; 4286 thetaCoefficient = upperChange[iSequence] + alpha; 4287 if (thetaCoefficient < -1.0e-8) 4288 hitsUpper = (currentSolution - currentUpper) / thetaCoefficient; 4289 //if (hitsUpper < 0.0) { 4290 // does not hit - but should we check further 4291 // hitsUpper = COIN_DBL_MAX; 4292 //} 4293 if (CoinMin(hitsLower, hitsUpper) < theta_) { 4294 theta_ = CoinMin(hitsLower, hitsUpper); 4295 toLower = hitsLower < hitsUpper; 4296 pivotRow_ = iPivot; 4297 } 4298 } 4299 #else 4340 char * markDone = paramData.markDone; 4341 const int * backwardBasic = paramData.backwardBasic; 4300 4342 // first ones with alpha 4301 4343 for (int i=0;i<number;i++) { … … 4307 4349 // bounds will be bounds + change *theta 4308 4350 double currentSolution = solution_[iSequence]; 4309 double currentLower = lower_[iSequence];4310 double currentUpper = upper_[iSequence];4311 4351 double alpha = array[iPivot]; 4312 assert (currentSolution >= currentLower - 100.0*primalTolerance_);4313 assert (currentSolution <= currentUpper + 100.0*primalTolerance_);4314 double thetaCoefficient;4315 thetaCoefficient = lowerChange[iSequence] + alpha;4316 if (thetaCoefficient > 1.0e-8) {4352 double thetaCoefficientLower = lowerChange[iSequence] + alpha; 4353 double thetaCoefficientUpper = upperChange[iSequence] + alpha; 4354 if (thetaCoefficientLower > 1.0e-8) { 4355 double currentLower = lower_[iSequence]; 4356 assert (currentSolution >= currentLower - 100.0*primalTolerance_); 4317 4357 double gap=currentSolution-currentLower; 4318 if (thetaCoefficient *theta_>gap) {4319 theta_ = gap/thetaCoefficient ;4358 if (thetaCoefficientLower*theta_>gap) { 4359 theta_ = gap/thetaCoefficientLower; 4320 4360 toLower=true; 4321 4361 pivotRow_=iPivot; 4322 4362 } 4323 4363 } 4324 thetaCoefficient = upperChange[iSequence] + alpha; 4325 if (thetaCoefficient < -1.0e-8) { 4364 if (thetaCoefficientUpper < -1.0e-8) { 4365 double currentUpper = upper_[iSequence]; 4366 assert (currentSolution <= currentUpper + 100.0*primalTolerance_); 4326 4367 double gap=currentSolution-currentUpper; //negative 4327 if (thetaCoefficient *theta_<gap) {4328 theta_ = gap/thetaCoefficient ;4368 if (thetaCoefficientUpper*theta_<gap) { 4369 theta_ = gap/thetaCoefficientUpper; 4329 4370 toLower=false; 4330 4371 pivotRow_=iPivot; … … 4346 4387 theta_ = gap/thetaCoefficient; 4347 4388 toLower=true; 4348 pivotRow_ = -2-iSequence;4389 pivotRow_ = backwardBasic[iSequence]; 4349 4390 } 4350 4391 } … … 4364 4405 theta_ = gap/thetaCoefficient; 4365 4406 toLower=false; 4366 pivotRow_ = -2-iSequence;4407 pivotRow_ = backwardBasic[iSequence]; 4367 4408 } 4368 4409 } 4369 4410 } 4370 4411 } 4371 if (pivotRow_<-1) {4372 // find4373 int iSequence = -pivotRow_-2;4374 for (int iPivot = 0; iPivot < numberRows_; iPivot++) {4375 if (iSequence == pivotVariable_[iPivot]) {4376 pivotRow_=iPivot;4377 break;4378 }4379 }4380 assert (pivotRow_>=0);4381 }4382 #endif4383 4412 theta_ = CoinMax(theta_,0.0); 4384 4413 if (theta_>1.0e-15) { … … 6707 6736 double * weights = new double [numberLook+numberColumns_]; 6708 6737 double * columnWeights = weights+numberLook; 6738 #ifndef COIN_REUSE_RANDOM 6709 6739 coin_init_random_vec(columnWeights,numberColumns_); 6740 #else 6741 for (int i=0;i<numberColumns_;i++) 6742 columnWeights[i]=CoinDrand48(); 6743 #endif 6710 6744 // get row copy 6711 6745 CoinPackedMatrix rowCopy = *matrix(); … … 6961 6995 } 6962 6996 } 6963 if (sum==0.0||sum>=lastSum )6997 if (sum==0.0||sum>=lastSum-1.0e-8) 6964 6998 break; 6965 6999 lastSum=sum; -
trunk/Clp/src/ClpSimplexOther.hpp
r1780 r1785 103 103 /// Finds best possible pivot 104 104 double bestPivot(bool justColumns=false); 105 typedef struct { 106 double startingTheta; 107 double endingTheta; 108 double * lowerChange; // full array of lower bound changes 109 int * lowerList; // list of lower bound changes 110 double * upperChange; // full array of upper bound changes 111 int * upperList; // list of upper bound changes 112 char * markDone; // mark which ones looked at 113 int * backwardBasic; // from sequence to pivot row 114 } parametricsData; 105 115 106 116 private: … … 113 123 if event handler exists it may do more 114 124 */ 115 int parametricsLoop( double startingTheta, double & endingTheta, double reportIncrement,125 int parametricsLoop(parametricsData & paramData, double reportIncrement, 116 126 const double * changeLower, const double * changeUpper, 117 127 const double * changeObjective, ClpDataSave & data, 118 128 bool canTryQuick); 119 int parametricsLoop( double & startingTheta, double & endingTheta,129 int parametricsLoop(parametricsData & paramData, 120 130 ClpDataSave & data,bool canSkipFactorization=false); 121 131 /** Refactorizes if necessary … … 137 147 +3 max iterations 138 148 */ 139 int whileIterating(double & startingTheta, double & endingTheta, double reportIncrement, 140 const double * changeLower, const double * changeUpper, 149 int whileIterating(parametricsData & paramData, double reportIncrement, 141 150 const double * changeObjective); 142 151 /** Computes next theta and says if objective or bounds (0= bounds, 1 objective, -1 none). … … 144 153 type 1 bounds, 2 objective, 3 both. 145 154 */ 146 int nextTheta(int type, double maxTheta, 147 const double * changeLower, const double * changeUpper, 155 int nextTheta(int type, double maxTheta, parametricsData & paramData, 148 156 const double * changeObjective); 149 157 /// Restores bound to original bound … … 197 205 non-zero return code indicates minor problems 198 206 */ 199 int restoreFromDual(const ClpSimplex * dualProblem); 207 int restoreFromDual(const ClpSimplex * dualProblem, 208 bool checkAccuracy=false); 200 209 /** Does very cursory presolve. 201 210 rhs is numberRows, whichRows is 3*numberRows and whichColumns is 2*numberColumns.
Note: See TracChangeset
for help on using the changeset viewer.