Changeset 1831 for trunk/Clp/src/ClpSimplexOther.cpp
 Timestamp:
 Dec 5, 2011 9:42:00 AM (9 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Clp/src/ClpSimplexOther.cpp
r1826 r1831 2866 2866 assert (ratio==1ratio==2); 2867 2867 // allow for unscaled  even if not needed 2868 int lengthArrays = 4*numberTotal+( 2*numberTotal+2)*ratio;2868 int lengthArrays = 4*numberTotal+(3*numberTotal+2)*ratio+2*numberRows_+1; 2869 2869 /* 2870 2870 Save information and modify … … 2876 2876 double * lowerChange = saveLower+numberTotal; 2877 2877 double * upperChange = saveUpper+numberTotal; 2878 int * lowerList = (reinterpret_cast<int *>(saveLower+4*numberTotal))+2; 2879 int * upperList = (reinterpret_cast<int *>(saveUpper+4*numberTotal))+2; 2878 double * lowerGap = saveLower+4*numberTotal; 2879 double * lowerCoefficient = lowerGap+numberRows_; 2880 double * upperGap = saveUpper+4*numberTotal; 2881 double * upperCoefficient = upperGap+numberRows_; 2882 int * lowerList = (reinterpret_cast<int *>(saveLower+4*numberTotal+2*numberRows_))+2; 2883 int * upperList = (reinterpret_cast<int *>(saveUpper+4*numberTotal+2*numberRows_))+2; 2884 int * lowerActive = lowerList+numberTotal+1; 2885 int * upperActive = upperList+numberTotal+1; 2880 2886 // To mark as odd 2881 char * markDone = reinterpret_cast<char *>(lower List+numberTotal);2887 char * markDone = reinterpret_cast<char *>(lowerActive+numberTotal); 2882 2888 //memset(markDone,0,numberTotal); 2883 int * backwardBasic = lowerList+2*numberTotal;2889 int * backwardBasic = upperActive+numberTotal; 2884 2890 parametricsData paramData; 2885 2891 paramData.lowerChange = lowerChange; … … 2889 2895 paramData.markDone=markDone; 2890 2896 paramData.backwardBasic=backwardBasic; 2897 paramData.lowerActive = lowerActive; 2898 paramData.lowerGap = lowerGap; 2899 paramData.lowerCoefficient = lowerCoefficient; 2900 paramData.upperActive = upperActive; 2901 paramData.upperGap = upperGap; 2902 paramData.upperCoefficient = upperCoefficient; 2891 2903 // Find theta when bounds will cross over and create arrays 2892 2904 memset(lowerChange, 0, numberTotal * sizeof(double)); … … 3559 3571 const int * lowerList = paramData.lowerList; 3560 3572 const int * upperList = paramData.upperList; 3573 //#define CLP_PARAMETRIC_DENSE_ARRAYS 2 3574 #if CLP_PARAMETRIC_DENSE_ARRAYS 3575 double * lowerGap = paramData.lowerGap; 3576 double * upperGap = paramData.upperGap; 3577 double * lowerCoefficient = paramData.lowerCoefficient; 3578 double * upperCoefficient = paramData.upperCoefficient; 3579 #endif 3561 3580 // do basic pointers 3562 3581 int * backwardBasic = paramData.backwardBasic; … … 3598 3617 for (int i=0;i<n;i++) { 3599 3618 int iSequence = lowerList[i]; 3600 double newValue = lower_[iSequence] + change * lowerChange[iSequence]; 3619 double thisChange = change * lowerChange[iSequence]; 3620 double newValue = lower_[iSequence] + thisChange; 3601 3621 lower_[iSequence] = newValue; 3622 #if CLP_PARAMETRIC_DENSE_ARRAYS 3623 if (getStatus(iSequence)==basic) { 3624 int iRow=backwardBasic[iSequence]; 3625 lowerGap[iRow] = thisChange; 3626 } else if(getStatus(iSequence)==atLowerBound) { 3627 solution_[iSequence] = newValue; 3628 } 3629 #else 3602 3630 if(getStatus(iSequence)==atLowerBound) { 3603 3631 solution_[iSequence] = newValue; 3604 3632 } 3633 #endif 3605 3634 #if 0 3606 3635 // may have to adjust other bound … … 3616 3645 for (int i=0;i<n;i++) { 3617 3646 int iSequence = upperList[i]; 3618 double newValue = upper_[iSequence] + change * upperChange[iSequence]; 3647 double thisChange = change * upperChange[iSequence]; 3648 double newValue = upper_[iSequence] + thisChange; 3619 3649 upper_[iSequence] = newValue; 3620 3650 if(getStatus(iSequence)==atUpperBound 3621 3651 getStatus(iSequence)==isFixed) { 3622 3652 solution_[iSequence] = newValue; 3653 #if CLP_PARAMETRIC_DENSE_ARRAYS 3654 } else if (getStatus(iSequence)==basic) { 3655 int iRow=backwardBasic[iSequence]; 3656 upperGap[iRow] += thisChange; 3657 #endif 3623 3658 } 3624 3659 // may have to adjust other bound … … 3772 3807 // which will change basic solution 3773 3808 if (nswapped) { 3809 abort(); //needs testing 3774 3810 factorization_>updateColumn(rowArray_[3], rowArray_[2]); 3775 3811 dualRowPivot_>updatePrimalSolution(rowArray_[2], … … 3859 3895 problemStatus_ = 2; // factorize now 3860 3896 } 3897 int * lowerActive = paramData.lowerActive; 3898 int * upperActive = paramData.upperActive; 3861 3899 // update change vector 3862 3900 { … … 3872 3910 double pivotValue = rowArray_[4]>denseVector()[pivotRow_]; 3873 3911 double multiplier = pivotValue/alpha_; 3912 double * array=rowArray_[4]>denseVector(); 3913 #if CLP_PARAMETRIC_DENSE_ARRAYS==2 3914 int lowerN=lowerActive[1]; 3915 int upperN=upperActive[1]; 3916 #endif 3874 3917 if (multiplier) { 3875 3918 for (int i = 0; i < number; i++) { 3876 3919 int iRow = which[i]; 3877 3920 #ifndef COIN_FAC_NEW 3878 rowArray_[4]>quickAddNonZero(iRow,multiplier*work[i]);3921 double alpha=multiplier*work[i]; 3879 3922 #else 3880 rowArray_[4]>quickAddNonZero(iRow,multiplier*work[iRow]); 3881 #endif 3923 double alpha=multiplier*work[iRow]; 3924 #endif 3925 #if CLP_PARAMETRIC_DENSE_ARRAYS 3926 double alpha3 = alpha+array[iRow]; 3927 int iSequence = pivotVariable_[iRow]; 3928 #if CLP_PARAMETRIC_DENSE_ARRAYS==2 3929 double oldLower = lowerCoefficient[iRow]; 3930 double oldUpper = upperCoefficient[iRow]; 3931 #endif 3932 if (lower_[iSequence]>1.0e30) { 3933 //lowerGap[iRow]=valuelower_[iSequence]; 3934 double alpha2 = alpha3 + lowerChange[iSequence]; 3935 #if CLP_PARAMETRIC_DENSE_ARRAYS==2 3936 if (alpha2>1.0e8) { 3937 lowerCoefficient[iRow]=alpha2; 3938 if (!oldLower) 3939 lowerActive[lowerN++]=iRow; 3940 } else { 3941 if (oldLower) 3942 lowerCoefficient[iRow]=COIN_DBL_MIN; 3943 } 3944 #else 3945 if (alpha2>1.0e8) 3946 lowerCoefficient[iRow]=alpha2; 3947 else 3948 lowerCoefficient[iRow]=0.0; 3949 #endif 3950 } else { 3951 #if CLP_PARAMETRIC_DENSE_ARRAYS==2 3952 if (oldLower) 3953 lowerCoefficient[iRow]=COIN_DBL_MIN; 3954 #else 3955 lowerCoefficient[iRow]=0.0; 3956 #endif 3957 } 3958 if (upper_[iSequence]<1.0e30) { 3959 //upperGap[iRow]=(valueupper_[iSequence]); 3960 double alpha2 = (alpha3+upperChange[iSequence]); 3961 #if CLP_PARAMETRIC_DENSE_ARRAYS==2 3962 if (alpha2>1.0e8) { 3963 upperCoefficient[iRow]=alpha2; 3964 if (!oldUpper) 3965 upperActive[upperN++]=iRow; 3966 } else { 3967 if (oldUpper) 3968 upperCoefficient[iRow]=COIN_DBL_MIN; 3969 } 3970 #else 3971 if (alpha2>1.0e8) 3972 upperCoefficient[iRow]=alpha2; 3973 else 3974 upperCoefficient[iRow]=0.0; 3975 #endif 3976 } else { 3977 #if CLP_PARAMETRIC_DENSE_ARRAYS==2 3978 if (oldUpper) 3979 upperCoefficient[iRow]=COIN_DBL_MIN; 3980 #else 3981 upperCoefficient[iRow]=0.0; 3982 #endif 3983 } 3984 #endif 3985 rowArray_[4]>quickAdd(iRow,alpha); 3882 3986 } 3883 3987 } 3884 pivotValue = rowArray_[4]>denseVector()[pivotRow_];3988 pivotValue = array[pivotRow_]; 3885 3989 // we want pivot to be multiplier 3886 3990 rowArray_[4]>quickAdd(pivotRow_,multiplierpivotValue); 3991 #if CLP_PARAMETRIC_DENSE_ARRAYS==2 3992 assert (lowerN>=0&&lowerN<=numberRows_); 3993 lowerActive[1]=lowerN; 3994 upperActive[1]=upperN; 3995 #endif 3887 3996 } 3888 3997 // update primal solution … … 3901 4010 reinterpret_cast<ClpSimplexDual *> ( this)>flipBounds(rowArray_[0], columnArray_[0]); 3902 4011 //rowArray_[1]>expand(); 4012 #if CLP_PARAMETRIC_DENSE_ARRAYS==0 3903 4013 dualRowPivot_>updatePrimalSolution(rowArray_[1], 3904 4014 movement, 3905 4015 objectiveChange); 4016 #else 4017 // do by hand 4018 { 4019 double * work = rowArray_[1]>denseVector(); 4020 int number = rowArray_[1]>getNumElements(); 4021 int * which = rowArray_[1]>getIndices(); 4022 int i; 4023 if (rowArray_[1]>packedMode()) { 4024 for (i = 0; i < number; i++) { 4025 int iRow = which[i]; 4026 int iSequence = pivotVariable_[iRow]; 4027 double value = solution_[iSequence]; 4028 double change = movement * work[i]; 4029 value = change; 4030 if (lower_[iSequence]>1.0e30) 4031 lowerGap[iRow]=valuelower_[iSequence]; 4032 if (upper_[iSequence]<1.0e30) 4033 upperGap[iRow]=(valueupper_[iSequence]); 4034 solution_[iSequence] = value; 4035 objectiveChange = change * cost_[iSequence]; 4036 work[i] = 0.0; 4037 } 4038 } else { 4039 for (i = 0; i < number; i++) { 4040 int iRow = which[i]; 4041 int iSequence = pivotVariable_[iRow]; 4042 double value = solution_[iSequence]; 4043 double change = movement * work[iRow]; 4044 value = change; 4045 solution_[iSequence] = value; 4046 objectiveChange = change * cost_[iSequence]; 4047 work[iRow] = 0.0; 4048 } 4049 } 4050 rowArray_[1]>setNumElements(0); 4051 } 4052 #endif 3906 4053 // modify dualout 3907 4054 dualOut_ /= alpha_; … … 3959 4106 backwardBasic[sequenceOut_]=1; 3960 4107 backwardBasic[sequenceIn_]=pivotRow_; 4108 #if CLP_PARAMETRIC_DENSE_ARRAYS 4109 double value = solution_[sequenceIn_]; 4110 double alpha = rowArray_[4]>denseVector()[pivotRow_]; 4111 #if CLP_PARAMETRIC_DENSE_ARRAYS==2 4112 double oldLower = lowerCoefficient[pivotRow_]; 4113 double oldUpper = upperCoefficient[pivotRow_]; 4114 if (lower_[sequenceIn_]>1.0e30) { 4115 lowerGap[pivotRow_]=valuelower_[sequenceIn_]; 4116 double alpha2 = alpha + lowerChange[sequenceIn_]; 4117 if (alpha2>1.0e8) { 4118 lowerCoefficient[pivotRow_]=alpha2; 4119 if (!oldLower) { 4120 int lowerN=lowerActive[1]; 4121 assert (lowerN>=0&&lowerN<numberRows_); 4122 lowerActive[lowerN]=pivotRow_; 4123 lowerActive[1]=lowerN+1; 4124 } 4125 } else { 4126 if (oldLower) 4127 lowerCoefficient[pivotRow_]=COIN_DBL_MIN; 4128 } 4129 } else { 4130 if (oldLower) 4131 lowerCoefficient[pivotRow_]=COIN_DBL_MIN; 4132 } 4133 if (upper_[sequenceIn_]<1.0e30) { 4134 upperGap[pivotRow_]=(valueupper_[sequenceIn_]); 4135 double alpha2 = (alpha+upperChange[sequenceIn_]); 4136 if (alpha2>1.0e8) { 4137 upperCoefficient[pivotRow_]=alpha2; 4138 if (!oldUpper) { 4139 int upperN=upperActive[1]; 4140 assert (upperN>=0&&upperN<numberRows_); 4141 upperActive[upperN]=pivotRow_; 4142 upperActive[1]=upperN+1; 4143 } 4144 } else { 4145 if (oldUpper) 4146 upperCoefficient[pivotRow_]=COIN_DBL_MIN; 4147 } 4148 } else { 4149 if (oldUpper) 4150 upperCoefficient[pivotRow_]=COIN_DBL_MIN; 4151 } 4152 #else 4153 if (lower_[sequenceIn_]>1.0e30) { 4154 lowerGap[pivotRow_]=valuelower_[sequenceIn_]; 4155 double alpha2 = alpha + lowerChange[sequenceIn_]; 4156 if (alpha2>1.0e8) 4157 lowerCoefficient[pivotRow_]=alpha2; 4158 else 4159 lowerCoefficient[pivotRow_]=0.0; 4160 } else { 4161 lowerCoefficient[pivotRow_]=0.0; 4162 } 4163 if (upper_[sequenceIn_]<1.0e30) { 4164 upperGap[pivotRow_]=(valueupper_[sequenceIn_]); 4165 double alpha2 = (alpha+upperChange[sequenceIn_]); 4166 if (alpha2>1.0e8) 4167 upperCoefficient[pivotRow_]=alpha2; 4168 else 4169 upperCoefficient[pivotRow_]=0.0; 4170 } else { 4171 upperCoefficient[pivotRow_]=0.0; 4172 } 4173 #endif 4174 #endif 3961 4175 { 3962 4176 char in[200],out[200]; … … 4227 4441 return returnCode; 4228 4442 } 4443 #if 0 4444 static int zzzzzz=0; 4445 int zzzzzzOther=0; 4446 #endif 4229 4447 // Finds best possible pivot 4230 4448 double … … 4283 4501 bool needFullUpdate = rowArray_[4]>getNumElements()==0; 4284 4502 double * array = rowArray_[4]>denseVector(); 4503 //rowArray_[4]>checkClean(); 4285 4504 const int * row = matrix_>getIndices(); 4286 4505 const int * columnLength = matrix_>getVectorLengths(); … … 4296 4515 } 4297 4516 #endif 4517 //#define CLP_PARAMETRIC_DENSE_ARRAYS 4518 #if CLP_PARAMETRIC_DENSE_ARRAYS 4519 double * lowerGap = paramData.lowerGap; 4520 double * upperGap = paramData.upperGap; 4521 double * lowerCoefficient = paramData.lowerCoefficient; 4522 double * upperCoefficient = paramData.upperCoefficient; 4523 #if CLP_PARAMETRIC_DENSE_ARRAYS==2 4524 int * lowerActive=paramData.lowerActive; 4525 int * upperActive=paramData.upperActive; 4526 #endif 4527 #endif 4298 4528 if (!factorization_>pivots()needFullUpdate) { 4529 //zzzzzz=0; 4299 4530 rowArray_[4]>clear(); 4300 4531 // get change … … 4310 4541 for (CoinBigIndex j = columnStart[iSequence]; 4311 4542 j < columnStart[iSequence] + columnLength[iSequence]; j++) { 4312 rowArray_[4]>quickAdd NonZero(row[j], elementByColumn[j]*value);4543 rowArray_[4]>quickAdd(row[j], elementByColumn[j]*value); 4313 4544 } 4314 4545 } … … 4321 4552 if (getRowStatus(iSequence)==atLowerBound) { 4322 4553 double value=change[iSequence]; 4323 rowArray_[4]>quickAdd NonZero(iSequence, value);4554 rowArray_[4]>quickAdd(iSequence, value); 4324 4555 } 4325 4556 } … … 4332 4563 for (CoinBigIndex j = columnStart[iSequence]; 4333 4564 j < columnStart[iSequence] + columnLength[iSequence]; j++) { 4334 rowArray_[4]>quickAdd NonZero(row[j], elementByColumn[j]*value);4565 rowArray_[4]>quickAdd(row[j], elementByColumn[j]*value); 4335 4566 } 4336 4567 } … … 4343 4574 if (getRowStatus(iSequence)==atUpperBound) { 4344 4575 double value=change[iSequence]; 4345 rowArray_[4]>quickAdd NonZero(iSequence, value);4576 rowArray_[4]>quickAdd(iSequence, value); 4346 4577 } 4347 4578 } … … 4360 4591 j < columnStart[iSequence] + columnLength[iSequence]; j++) { 4361 4592 int iRow = row[j]; 4362 rowArray_[4]>quickAdd NonZero(iRow, elementByColumn[j]*scale * rowScale_[iRow]*value);4593 rowArray_[4]>quickAdd(iRow, elementByColumn[j]*scale * rowScale_[iRow]*value); 4363 4594 } 4364 4595 } … … 4371 4602 if (getRowStatus(iSequence)==atLowerBound) { 4372 4603 double value=change[iSequence]; 4373 rowArray_[4]>quickAdd NonZero(iSequence, value);4604 rowArray_[4]>quickAdd(iSequence, value); 4374 4605 } 4375 4606 } … … 4385 4616 j < columnStart[iSequence] + columnLength[iSequence]; j++) { 4386 4617 int iRow = row[j]; 4387 rowArray_[4]>quickAdd NonZero(iRow, elementByColumn[j]*scale * rowScale_[iRow]*value);4618 rowArray_[4]>quickAdd(iRow, elementByColumn[j]*scale * rowScale_[iRow]*value); 4388 4619 } 4389 4620 } … … 4396 4627 if (getRowStatus(iSequence)==atUpperBound) { 4397 4628 double value=change[iSequence]; 4398 rowArray_[4]>quickAdd NonZero(iSequence, value);4629 rowArray_[4]>quickAdd(iSequence, value); 4399 4630 } 4400 4631 } … … 4408 4639 } 4409 4640 } 4641 #endif 4642 #if CLP_PARAMETRIC_DENSE_ARRAYS 4643 /* later for sparse  keep like CoinIndexedvector 4644 and just redo here */ 4645 #if CLP_PARAMETRIC_DENSE_ARRAYS==2 4646 int lowerN=0; 4647 int upperN=0; 4648 #endif 4649 memset(lowerCoefficient,0,numberRows_*sizeof(double)); 4650 memset(upperCoefficient,0,numberRows_*sizeof(double)); 4651 for (int iRow=0;iRow<numberRows_;iRow++) { 4652 iSequence = pivotVariable_[iRow]; 4653 double currentSolution = solution_[iSequence]; 4654 double alpha = array[iRow]; 4655 double thetaCoefficientLower = lowerChange[iSequence] + alpha; 4656 double thetaCoefficientUpper = upperChange[iSequence] + alpha; 4657 if (thetaCoefficientLower > 1.0e8&&lower_[iSequence]>1.0e30) { 4658 double currentLower = lower_[iSequence]; 4659 ClpTraceDebug (currentSolution >= currentLower  100.0*primalTolerance_); 4660 double gap=currentSolutioncurrentLower; 4661 lowerGap[iRow]=gap; 4662 lowerCoefficient[iRow]=thetaCoefficientLower; 4663 #if CLP_PARAMETRIC_DENSE_ARRAYS==2 4664 lowerActive[lowerN++]=iRow; 4665 #endif 4666 //} else { 4667 //lowerCoefficient[iRow]=0.0; 4668 } 4669 if (thetaCoefficientUpper < 1.0e8&&upper_[iSequence]<1.0e30) { 4670 double currentUpper = upper_[iSequence]; 4671 ClpTraceDebug (currentSolution <= currentUpper + 100.0*primalTolerance_); 4672 double gap2=(currentSolutioncurrentUpper); //positive 4673 upperGap[iRow]=gap2; 4674 upperCoefficient[iRow]=thetaCoefficientUpper; 4675 #if CLP_PARAMETRIC_DENSE_ARRAYS==2 4676 upperActive[upperN++]=iRow; 4677 #endif 4678 //} else { 4679 //upperCoefficient[iRow]=0.0; 4680 } 4681 } 4682 #endif 4683 #if CLP_PARAMETRIC_DENSE_ARRAYS==2 4684 assert (lowerN>=0&&lowerN<=numberRows_); 4685 lowerActive[1]=lowerN; 4686 upperActive[1]=upperN; 4410 4687 #endif 4411 4688 } else if (sequenceIn_>=0) { … … 4421 4698 for (CoinBigIndex i = columnStart[sequenceIn_]; 4422 4699 i < columnStart[sequenceIn_] + columnLength[sequenceIn_]; i++) { 4423 rowArray_[5]>quickAdd NonZero(row[i], elementByColumn[i]*change);4700 rowArray_[5]>quickAdd(row[i], elementByColumn[i]*change); 4424 4701 } 4425 4702 } else { … … 4429 4706 i < columnStart[sequenceIn_] + columnLength[sequenceIn_]; i++) { 4430 4707 int iRow = row[i]; 4431 rowArray_[5]>quickAdd NonZero(iRow, elementByColumn[i]*scale * rowScale_[iRow]*change);4708 rowArray_[5]>quickAdd(iRow, elementByColumn[i]*scale * rowScale_[iRow]*change); 4432 4709 } 4433 4710 } … … 4446 4723 for (CoinBigIndex i = columnStart[sequenceOut_]; 4447 4724 i < columnStart[sequenceOut_] + columnLength[sequenceOut_]; i++) { 4448 rowArray_[5]>quickAdd NonZero(row[i], elementByColumn[i]*change);4725 rowArray_[5]>quickAdd(row[i], elementByColumn[i]*change); 4449 4726 } 4450 4727 } else { … … 4454 4731 i < columnStart[sequenceOut_] + columnLength[sequenceOut_]; i++) { 4455 4732 int iRow = row[i]; 4456 rowArray_[5]>quickAdd NonZero(iRow, elementByColumn[i]*scale * rowScale_[iRow]*change);4733 rowArray_[5]>quickAdd(iRow, elementByColumn[i]*scale * rowScale_[iRow]*change); 4457 4734 } 4458 4735 } 4459 4736 } else { 4460 rowArray_[5]>quickAdd NonZero(sequenceOut_numberColumns_,change);4737 rowArray_[5]>quickAdd(sequenceOut_numberColumns_,change); 4461 4738 } 4462 4739 needed++; … … 4471 4748 int * index5 = rowArray_[5]>getIndices(); 4472 4749 int number5 = rowArray_[5]>getNumElements(); 4750 #if CLP_PARAMETRIC_DENSE_ARRAYS==2 4751 int lowerN=lowerActive[1]; 4752 int upperN=upperActive[1]; 4753 int nIn4=rowArray_[4]>getNumElements(); 4754 int * index4 = rowArray_[4]>getIndices(); 4755 #endif 4473 4756 for (int i = 0; i < number5; i++) { 4474 4757 int iPivot = index5[i]; 4475 rowArray_[4]>quickAddNonZero(iPivot,array5[iPivot]); 4758 #if CLP_PARAMETRIC_DENSE_ARRAYS==0 4759 rowArray_[4]>quickAdd(iPivot,array5[iPivot]); 4760 #else 4761 /* later for sparse  modify here */ 4762 int iSequence = pivotVariable_[iPivot]; 4763 double currentSolution = solution_[iSequence]; 4764 double currentAlpha = array[iPivot]; 4765 double alpha5 = array5[iPivot]; 4766 double alpha = currentAlpha+alpha5; 4767 #if CLP_PARAMETRIC_DENSE_ARRAYS==2 4768 if (currentAlpha) { 4769 if (alpha) { 4770 array[iPivot] = alpha; 4771 } else { 4772 array[iPivot] = COIN_DBL_MIN; 4773 } 4774 } else { 4775 index4[nIn4++] = iPivot; 4776 array[iPivot] = alpha; 4777 } 4778 #else 4779 rowArray_[4]>quickAdd(iPivot,alpha5); 4780 #endif 4781 //#undef CLP_PARAMETRIC_DENSE_ARRAYS 4782 //#define CLP_PARAMETRIC_DENSE_ARRAYS 1 4783 double thetaCoefficientLower = lowerChange[iSequence] + alpha; 4784 double thetaCoefficientUpper = upperChange[iSequence] + alpha; 4785 #if CLP_PARAMETRIC_DENSE_ARRAYS==2 4786 double oldLower = lowerCoefficient[iPivot]; 4787 double oldUpper = upperCoefficient[iPivot]; 4788 #endif 4789 if (thetaCoefficientLower > 1.0e8&&lower_[iSequence]>1.0e30) { 4790 double currentLower = lower_[iSequence]; 4791 ClpTraceDebug (currentSolution >= currentLower  100.0*primalTolerance_); 4792 double gap=currentSolutioncurrentLower; 4793 lowerGap[iPivot]=gap; 4794 lowerCoefficient[iPivot]=thetaCoefficientLower; 4795 #if CLP_PARAMETRIC_DENSE_ARRAYS==2 4796 if (!oldLower) 4797 lowerActive[lowerN++]=iPivot; 4798 #endif 4799 } else { 4800 #if CLP_PARAMETRIC_DENSE_ARRAYS==2 4801 if (oldLower) 4802 lowerCoefficient[iPivot]=COIN_DBL_MIN; 4803 #else 4804 lowerCoefficient[iPivot]=0.0; 4805 #endif 4806 } 4807 if (thetaCoefficientUpper < 1.0e8&&upper_[iSequence]<1.0e30) { 4808 double currentUpper = upper_[iSequence]; 4809 ClpTraceDebug (currentSolution <= currentUpper + 100.0*primalTolerance_); 4810 double gap2=(currentSolutioncurrentUpper); //positive 4811 upperGap[iPivot]=gap2; 4812 upperCoefficient[iPivot]=thetaCoefficientUpper; 4813 #if CLP_PARAMETRIC_DENSE_ARRAYS==2 4814 if (!oldUpper) 4815 upperActive[upperN++]=iPivot; 4816 #endif 4817 } else { 4818 #if CLP_PARAMETRIC_DENSE_ARRAYS==2 4819 if (oldUpper) 4820 upperCoefficient[iPivot]=COIN_DBL_MIN; 4821 #else 4822 upperCoefficient[iPivot]=0.0; 4823 #endif 4824 } 4825 #endif 4476 4826 array5[iPivot]=0.0; 4477 4827 } 4478 4828 rowArray_[5]>setNumElements(0); 4829 #if CLP_PARAMETRIC_DENSE_ARRAYS==2 4830 rowArray_[4]>setNumElements(nIn4); 4831 assert (lowerN>=0&&lowerN<=numberRows_); 4832 lowerActive[1]=lowerN; 4833 upperActive[1]=upperN; 4834 #endif 4479 4835 } 4480 4836 } 4481 4837 const int * index = rowArray_[4]>getIndices(); 4482 4838 int number = rowArray_[4]>getNumElements(); 4839 #define TESTXX 0 4840 #if CLP_PARAMETRIC_DENSE_ARRAYS==0 //TESTXX 4483 4841 int * markDone = reinterpret_cast<int *>(paramData.markDone); 4484 4842 int nToZero=(numberRows_+numberColumns_+COIN_ANY_BITS_PER_INT1)>>COIN_ANY_SHIFT_PER_INT; 4485 4843 memset(markDone,0,nToZero*sizeof(int)); 4486 4844 const int * backwardBasic = paramData.backwardBasic; 4845 #endif 4487 4846 // first ones with alpha 4488 4847 double theta1=maxTheta; 4848 int pivotRow1=1; 4849 #if CLP_PARAMETRIC_DENSE_ARRAYS<2 //TESTXX 4850 int pivotRow2=1; 4489 4851 double theta2=maxTheta; 4490 //bool toLower2=true; 4491 int pivotRow1=1; 4492 int pivotRow2=1; 4493 cilk_for (int i=0;i<number;i++) { 4852 #endif 4853 #if CLP_PARAMETRIC_DENSE_ARRAYS==0 //TESTXX 4854 for (int i=0;i<number;i++) { 4494 4855 int iPivot=index[i]; 4495 4856 iSequence = pivotVariable_[iPivot]; … … 4498 4859 int bit = iSequence & COIN_ANY_MASK_PER_INT; 4499 4860 markDone[word] = ( 1 << bit ); 4500 //markDone[iSequence]=1;4501 4861 // solution value will be sol  theta*alpha 4502 4862 // bounds will be bounds + change *theta … … 4511 4871 double currentLower = lower_[iSequence]; 4512 4872 ClpTraceDebug (currentSolution >= currentLower  100.0*primalTolerance_); 4873 assert (currentSolution >= currentLower  100.0*primalTolerance_); 4513 4874 double gap=currentSolutioncurrentLower; 4514 4875 if (thetaCoefficientLower*theta1>gap) { … … 4523 4884 double currentUpper = upper_[iSequence]; 4524 4885 ClpTraceDebug (currentSolution <= currentUpper + 100.0*primalTolerance_); 4886 assert (currentSolution <= currentUpper + 100.0*primalTolerance_); 4525 4887 double gap2=currentSolutioncurrentUpper; //negative 4526 4888 if (thetaCoefficientUpper*theta2<gap2) { … … 4583 4945 pivotRow_=pivotRow1; 4584 4946 } 4947 #if 0 //TESTXX 4948 #if CLP_PARAMETRIC_DENSE_ARRAYS==2 4949 { 4950 double * checkArray = new double[numberRows_]; 4951 memcpy(checkArray,lowerCoefficient,numberRows_*sizeof(double)); 4952 int lowerN=lowerActive[1]; 4953 for (int i=0;i<lowerN;i++) { 4954 int iRow=lowerActive[i]; 4955 int iSequence = pivotVariable_[iRow]; 4956 double alpha = array[iRow]; 4957 double thetaCoefficient = lowerChange[iSequence] + alpha; 4958 if (thetaCoefficient > 1.0e8&&lower_[iSequence]>1.0e30) { 4959 assert(fabs(checkArray[iRow]thetaCoefficient)<1.0e5); 4960 if(fabs(checkArray[iRow]thetaCoefficient)>1.0e5) { 4961 abort(); 4962 } 4963 } else { 4964 assert (fabs(checkArray[iRow])<1.0e12); 4965 if (fabs(checkArray[iRow])>1.0e12) { 4966 abort(); 4967 } 4968 } 4969 checkArray[iRow]=0.0; 4970 } 4971 for (int i=0;i<numberRows_;i++) { 4972 assert (!checkArray[i]); 4973 if (checkArray[i]) 4974 abort(); 4975 } 4976 memcpy(checkArray,upperCoefficient,numberRows_*sizeof(double)); 4977 int upperN=upperActive[1]; 4978 for (int i=0;i<upperN;i++) { 4979 int iRow=upperActive[i]; 4980 int iSequence = pivotVariable_[iRow]; 4981 double alpha = array[iRow]; 4982 double thetaCoefficient = (upperChange[iSequence] + alpha); 4983 if (thetaCoefficient > 1.0e8&&upper_[iSequence]<1.0e30) { 4984 assert(fabs(checkArray[iRow]thetaCoefficient)<1.0e5); 4985 if(fabs(checkArray[iRow]thetaCoefficient)>1.0e5) { 4986 abort(); 4987 } 4988 } else { 4989 assert (fabs(checkArray[iRow])<1.0e12); 4990 if (fabs(checkArray[iRow])>1.0e12) { 4991 abort(); 4992 } 4993 } 4994 checkArray[iRow]=0.0; 4995 } 4996 for (int i=0;i<numberRows_;i++) { 4997 assert (!checkArray[i]); 4998 if (checkArray[i]) 4999 abort(); 5000 } 5001 delete [] checkArray; 5002 } 5003 #endif 5004 #if CLP_PARAMETRIC_DENSE_ARRAYS==2 5005 double theta3=maxTheta; 5006 int pivotRow3=1; 5007 int lowerN=lowerActive[1]; 5008 for (int i=0;i<lowerN;i++) { 5009 int iRow=lowerActive[i]; 5010 double lowerC = lowerCoefficient[iRow]; 5011 double gap=lowerGap[iRow]; 5012 if (toLower&&iRow==pivotRow_) { 5013 assert (lowerC*theta3>gap1.0e8); 5014 if (lowerC*theta3<gap1.0e8) 5015 abort(); 5016 } 5017 if (lowerC*theta3>gap&&lowerC!=COIN_DBL_MIN) { 5018 theta3 = gap/lowerC; 5019 pivotRow3=iRow; 5020 } 5021 } 5022 int pivotRow4=pivotRow3; 5023 double theta4=theta3; 5024 int upperN=upperActive[1]; 5025 for (int i=0;i<upperN;i++) { 5026 int iRow=upperActive[i]; 5027 double upperC = upperCoefficient[iRow]; 5028 double gap=upperGap[iRow]; 5029 if (!toLower&&iRow==pivotRow_) { 5030 assert (upperC*theta3>gap1.0e8); 5031 if (upperC*theta3<gap1.0e8) 5032 abort(); 5033 } 5034 if (upperC*theta4>gap&&upperC!=COIN_DBL_MIN) { 5035 theta4 = gap/upperC; 5036 pivotRow4=iRow; 5037 } 5038 } 5039 bool toLower3; 5040 if (theta4<theta3) { 5041 theta3=theta4; 5042 toLower3=false; 5043 pivotRow3=pivotRow4; 5044 } else { 5045 toLower3=true; 5046 } 5047 if (fabs(theta3theta_)>1.0e8) 5048 abort(); 5049 if (toLower!=toLower3pivotRow_!=pivotRow3) { 5050 printf("bad piv  good %d %g %s, bad %d %g %s\n",pivotRow_,theta_,toLower ? "toLower" : "toUpper", 5051 pivotRow3,theta3,toLower3 ? "toLower" : "toUpper"); 5052 //zzzzzz++; 5053 if (true/*zzzzzz>zzzzzzOther*/) { 5054 printf("Swapping\n"); 5055 pivotRow_=pivotRow3; 5056 theta_=theta3; 5057 toLower=toLower3; 5058 } 5059 } 5060 #endif 5061 #endif 5062 #else 5063 #if 0 //CLP_PARAMETRIC_DENSE_ARRAYS==2 5064 { 5065 double * checkArray = new double[numberRows_]; 5066 memcpy(checkArray,lowerCoefficient,numberRows_*sizeof(double)); 5067 int lowerN=lowerActive[1]; 5068 for (int i=0;i<lowerN;i++) { 5069 int iRow=lowerActive[i]; 5070 checkArray[iRow]=0.0; 5071 } 5072 for (int i=0;i<numberRows_;i++) { 5073 assert (!checkArray[i]); 5074 if (checkArray[i]) 5075 abort(); 5076 } 5077 memcpy(checkArray,upperCoefficient,numberRows_*sizeof(double)); 5078 int upperN=upperActive[1]; 5079 for (int i=0;i<upperN;i++) { 5080 int iRow=upperActive[i]; 5081 checkArray[iRow]=0.0; 5082 } 5083 for (int i=0;i<numberRows_;i++) { 5084 assert (!checkArray[i]); 5085 if (checkArray[i]) 5086 abort(); 5087 } 5088 delete [] checkArray; 5089 } 5090 #endif 5091 #if CLP_PARAMETRIC_DENSE_ARRAYS==2 5092 int lowerN=lowerActive[1]; 5093 for (int i=0;i<lowerN;i++) { 5094 int iRow=lowerActive[i]; 5095 double lowerC = lowerCoefficient[iRow]; 5096 double gap=lowerGap[iRow]; 5097 if (lowerC*theta1>gap&&lowerC!=COIN_DBL_MIN) { 5098 theta1 = gap/lowerC; 5099 pivotRow1=iRow; 5100 } 5101 } 5102 pivotRow_=pivotRow1; 5103 theta_=theta1; 5104 int upperN=upperActive[1]; 5105 for (int i=0;i<upperN;i++) { 5106 int iRow=upperActive[i]; 5107 double upperC = upperCoefficient[iRow]; 5108 double gap=upperGap[iRow]; 5109 if (upperC*theta1>gap&&upperC!=COIN_DBL_MIN) { 5110 theta1 = gap/upperC; 5111 pivotRow1=iRow; 5112 } 5113 } 5114 if (theta1<theta_) { 5115 theta_=theta1; 5116 toLower=false; 5117 pivotRow_=pivotRow1; 5118 } else { 5119 toLower=true; 5120 } 5121 #else 5122 for (int iRow=0;iRow<numberRows_;iRow++) { 5123 double lowerC = lowerCoefficient[iRow]; 5124 if (lowerC) { 5125 double gap=lowerGap[iRow]; 5126 if (lowerC*theta1>gap&&lowerC!=COIN_DBL_MIN) { 5127 theta1 = gap/lowerC; 5128 pivotRow1=iRow; 5129 } 5130 } 5131 double upperC = upperCoefficient[iRow]; 5132 if (upperC) { 5133 double gap=upperGap[iRow]; 5134 if (upperC*theta2>gap&&upperC!=COIN_DBL_MIN) { 5135 theta2 = gap/upperC; 5136 pivotRow2=iRow; 5137 } 5138 } 5139 } 5140 if (theta2<theta1) { 5141 theta_=theta2; 5142 toLower=false; 5143 pivotRow_=pivotRow2; 5144 } else { 5145 theta_=theta1; 5146 toLower=true; 5147 pivotRow_=pivotRow1; 5148 } 5149 #endif 5150 #endif 4585 5151 theta_ = CoinMax(theta_,0.0); 4586 5152 if (theta_>1.0e15) { … … 4589 5155 int iPivot = index[iRow]; 4590 5156 iSequence = pivotVariable_[iPivot]; 4591 //markDone[iSequence]=0;4592 5157 // solution value will be sol  theta*alpha 4593 5158 double alpha = array[iPivot]; 4594 solution_[iSequence] = theta_ * alpha; 4595 } 4596 #if 0 4597 } else { 4598 for (int iRow = 0; iRow < number; iRow++) { 4599 int iPivot = index[iRow]; 4600 iSequence = pivotVariable_[iPivot]; 4601 markDone[iSequence]=0; 4602 } 4603 #endif 4604 } 5159 double currentSolution = solution_[iSequence]  theta_ * alpha; 5160 solution_[iSequence] =currentSolution; 5161 #if CLP_PARAMETRIC_DENSE_ARRAYS 5162 if (lower_[iSequence]>1.0e30) 5163 lowerGap[iPivot]=currentSolutionlower_[iSequence]; 5164 if (upper_[iSequence]<1.0e30) 5165 upperGap[iPivot]=(currentSolutionupper_[iSequence]); 5166 #endif 5167 } 5168 } 5169 #if CLP_PARAMETRIC_DENSE_ARRAYS 5170 if (pivotRow_>=0&&false) { 5171 double oldValue = upperCoefficient[pivotRow_]; 5172 double value = array[pivotRow_]; 5173 if (value) { 5174 if (!oldValue) { 5175 int upperN=upperActive[1]; 5176 assert (upperN>=0&&upperN<numberRows_); 5177 upperActive[upperN]=pivotRow_; 5178 upperActive[1]=upperN+1; 5179 } 5180 } else { 5181 if (oldValue) 5182 upperCoefficient[pivotRow_]=COIN_DBL_MIN; 5183 } 5184 } 5185 #endif 4605 5186 #if 0 4606 5187 for (int i=0;i<numberTotal;i++) … … 6930 7511 return returnCode; 6931 7512 } 7513 #ifdef COIN_SHORT_SORT 7514 #define USE_HASH 1 7515 #else 7516 #define USE_HASH 0 7517 #endif 7518 #if USE_HASH==2 7519 static const unsigned int mmult[] = { 7520 262139, 259459, 256889, 254291, 251701, 249133, 246709, 244247}; 7521 // Returns a hash value 7522 inline unsigned int 7523 hashValue(double value, unsigned int maxHash) 7524 { 7525 const char * name = reinterpret_cast<char *>(&value); 7526 unsigned int n = 0; 7527 for (int j = 0; j < 8; ++j ) { 7528 n += mmult[j] * name[j]; 7529 } 7530 return ( n % maxHash ); 7531 } 7532 /* 7533 */ 7534 static int sameTogether(unsigned int nin,int * which, double * weights, 7535 int * which2, double * weights2, unsigned int * hash) 7536 { 7537 if (nin<=1) 7538 return nin; 7539 // move up and fill hash 7540 unsigned int maxHash=4*nin; 7541 memset(hash,0xf0,maxHash*sizeof(int)); 7542 int * spare=which2+maxHash; 7543 int n2=0; 7544 unsigned int iNext = hashValue (weights[0],maxHash); 7545 unsigned int endMarker=0x80000000+maxHash; 7546 hash[iNext]=endMarker; 7547 unsigned int iLast=iNext; 7548 weights2[iNext]=weights[0]; 7549 which2[iNext]=which[0]; 7550 for (unsigned int i=1;i<nin;i++) { 7551 double value = weights[i]; 7552 unsigned int ipos = hashValue (value,maxHash); 7553 if ( hash[ipos] == 0xf0f0f0f0 ) { 7554 hash[iLast] = ipos+0x80000000; 7555 hash[ipos]=endMarker; 7556 weights2[ipos]=value; 7557 which2[ipos]=which[i]; 7558 iLast=ipos; 7559 } else { 7560 spare[n2++]=i; 7561 } 7562 } 7563 unsigned int lastSlot = 0; 7564 for (int j = 0; j < n2; ++j ) { 7565 int i = spare[j]; 7566 double value=weights[i]; 7567 unsigned int ipos = hashValue ( value , maxHash); 7568 iLast=ipos; 7569 while ( hash[ipos] <= 0x80000000) { 7570 iLast=ipos; 7571 ipos=hash[ipos]; 7572 } 7573 while (hash[lastSlot]!=0xf0f0f0f0) 7574 lastSlot++; 7575 assert (lastSlot<maxHash); 7576 hash[lastSlot] = hash[ipos]; 7577 hash[iLast] = lastSlot; 7578 weights2[lastSlot]=value; 7579 which2[lastSlot]=which[i]; 7580 } 7581 int put=0; 7582 //unsigned int iNext=0; 7583 int savePut=0; 7584 while (iNext!=maxHash) { 7585 weights[put]=weights2[iNext]; 7586 assert (iNext<maxHash); 7587 which[put++]=which2[iNext]; 7588 iNext = hash[iNext]; 7589 if (iNext>0x7fffffff) { 7590 // end 7591 if (put>savePut+1) { 7592 CoinShortSort_2(weights+savePut,weights+put,which+savePut); 7593 // keep 7594 #if 0 7595 printf("DUP2 value %g ",weights[savePut]); 7596 for (int i=savePut;i<put;i++) 7597 printf("%d (%g) ",which[i],weights[i]); 7598 printf("\n"); 7599 #endif 7600 savePut=put; 7601 } else { 7602 // no 7603 put=savePut; 7604 } 7605 iNext = 0x80000000; 7606 } 7607 } 7608 return savePut; 7609 } 7610 #endif 6932 7611 #include "CoinPresolveMatrix.hpp" 6933 7612 /* Take out duplicate rows (includes scaled rows and intersections). … … 6940 7619 */ 6941 7620 int 6942 ClpSimplex::outDuplicateRows(int numberLook,int * whichRows, double tolerance,6943 double cleanUp)7621 ClpSimplex::outDuplicateRows(int numberLook,int * whichRows, bool noOverlaps, 7622 double tolerance,double cleanUp) 6944 7623 { 7624 #if USE_HASH<2 6945 7625 double * weights = new double [numberLook+numberColumns_]; 7626 #else 7627 int numberAlloc=5*numberLook+numberColumns_+((9*numberLook+1)/(sizeof(double)/sizeof(int))); 7628 double * weights = new double [numberAlloc]; 7629 double * weights2=weights+numberLook+numberColumns_; 7630 #endif 6946 7631 double * columnWeights = weights+numberLook; 6947 7632 #ifndef COIN_REUSE_RANDOM … … 6950 7635 for (int i=0;i<numberColumns_;i++) 6951 7636 columnWeights[i]=CoinDrand48(); 7637 #endif 7638 #if USE_HASH==1 7639 typedef struct { 7640 #define INTEL // need way to find out at compile time 7641 #ifdef INTEL 7642 int which; 7643 float value; 7644 #else 7645 float value; 7646 int which; 7647 #endif 7648 } hash_1; 7649 typedef struct { 7650 union { 7651 double d; 7652 hash_1 hash; 7653 } item; 7654 } hash; 7655 assert (sizeof(double) == 8); 7656 hash * hashWeights = reinterpret_cast<hash *>(weights); 7657 #endif 7658 #if 0 7659 int counts[5]={0,0,0,0,0}; 7660 int countsEq[5]={0,0,0,0,0}; 6952 7661 #endif 6953 7662 // get row copy … … 6958 7667 int * rowLength = rowCopy.getMutableVectorLengths(); 6959 7668 double * element = rowCopy.getMutableElements(); 7669 //double wwww[200]; 7670 //assert (numberLook<=200); 7671 //int iiii[200]; 6960 7672 for (int i=0;i<numberLook;i++) { 6961 7673 int iRow=whichRows[i]; … … 6964 7676 CoinBigIndex end = start+rowLength[iRow]; 6965 7677 // sort (probably in order anyway) 7678 #ifdef COIN_SHORT_SORT 7679 CoinShortSort_2(column+start,column+end,element+start); 7680 #else 6966 7681 CoinSort_2(column+start,column+end,element+start); 7682 #endif 6967 7683 for (CoinBigIndex j=start;j<end;j++) { 6968 7684 int iColumn = column[j]; 6969 7685 value += columnWeights[iColumn]; 6970 7686 } 7687 #if USE_HASH ==1 7688 //printf("iLook %d weight %g (before)\n",i,value); 7689 hash temp; 7690 temp.item.d=value; 7691 temp.item.hash.which=iRow; 7692 hashWeights[i]=temp; 7693 //wwww[i]=value; 7694 //iiii[i]=iRow; 7695 #else 6971 7696 weights[i]=value; 7697 #endif 7698 } 7699 //#define PRINT_DUP 7700 #if USE_HASH == 0 7701 if (false) { 7702 double * w =CoinCopyOfArray(weights,numberLook); 7703 int * ind = CoinCopyOfArray(whichRows,numberLook); 7704 double * weights2=new double[50000]; 7705 int * which2 = reinterpret_cast<int *>(weights2+4*numberLook); 7706 unsigned int * hash = reinterpret_cast<unsigned int *>(which2+5*numberLook); 7707 int n=sameTogether(numberLook,ind,w,which2,weights2,hash); 7708 printf("Reduced length of %d\n",n); 7709 delete [] weights2; 7710 delete [] w; 7711 delete [] ind; 6972 7712 } 6973 7713 CoinSort_2(weights,weights+numberLook,whichRows); 7714 #if 0 7715 { 7716 double value = weights[0]; 7717 int firstSame=1; 7718 int lastSame=1; 7719 for (int iLook = 1; iLook < numberLook; iLook++) { 7720 if (weights[iLook]==value) { 7721 if (firstSame<0) { 7722 /* see how many same  if >2 but < ? may be 7723 worth looking at all combinations 7724 */ 7725 firstSame=iLook1; 7726 printf("DUPS weight %g first row %d ",value,whichRows[firstSame]); 7727 for (lastSame=iLook;lastSame<numberLook;lastSame++) { 7728 if (weights[lastSame]!=value) 7729 break; 7730 else 7731 printf(", %d ",whichRows[lastSame]); 7732 } 7733 printf("\n"); 7734 //printf("dupsame %d rows have same weight",lastSamefirstSame); 7735 } 7736 } else { 7737 firstSame=1; 7738 value=weights[iLook]; 7739 } 7740 } 7741 } 7742 #endif 7743 #elif USE_HASH==1 7744 std::sort(weights,weights+numberLook); 7745 #ifdef PRINT_DUP 7746 //CoinSort_2(wwww,wwww+numberLook,iiii); 7747 for (int i=0;i<numberLook;i++) { 7748 hash * temp = reinterpret_cast<hash *>(weights+i); 7749 whichRows[i]=temp>item.hash.which; 7750 weights[i]=temp>item.hash.value; 7751 //printf("iLook %d weight %g (after)  true %d %g\n", 7752 // whichRows[i],weights[i],iiii[i],wwww[i]); 7753 } 7754 #undef USE_HASH 7755 #define USE_HASH 0 7756 #endif 7757 #else 7758 int * which2 = reinterpret_cast<int *>(weights2+4*numberLook); 7759 unsigned int * hash = reinterpret_cast<unsigned int *>(which2+5*numberLook); 7760 numberLook=sameTogether(numberLook,whichRows,weights,which2,weights2,hash); 7761 printf("Reduced length of %d\n",numberLook); 7762 #endif 6974 7763 if (tolerance<0.0) 6975 7764 tolerance = primalTolerance_; 6976 7765 int nPossible=0; 6977 7766 int nDelete=0; 7767 #if USE_HASH==1 7768 hash * temp = reinterpret_cast<hash *>(weights); 7769 int iLast=temp>item.hash.which; 7770 float value=temp>item.hash.value; 7771 #else 6978 7772 double value = weights[0]; 7773 int iLast = whichRows[0]; 7774 #endif 6979 7775 double inverseCleanup = (cleanUp>0.0) ? 1.0/cleanUp : 0.0; 7776 //#define PRINT_DUP 7777 #ifdef PRINT_DUP 6980 7778 int firstSame=1; 6981 7779 int lastSame=1; 7780 #endif 6982 7781 for (int iLook = 1; iLook < numberLook; iLook++) { 6983 if (weights[iLook]==value) { 6984 int iLast=whichRows[iLook1]; 7782 #if USE_HASH==1 7783 hash * temp = reinterpret_cast<hash *>(weights+iLook); 7784 int iThis=temp>item.hash.which; 7785 float valueThis=temp>item.hash.value; 7786 #else 7787 int iThis=whichRows[iLook]; 7788 double valueThis=weights[iLook]; 7789 #endif 7790 if (valueThis==value) { 7791 #ifdef PRINT_DUP 6985 7792 if (firstSame<0) { 6986 7793 /* see how many same  if >2 but < ? may be … … 6988 7795 */ 6989 7796 firstSame=iLook1; 6990 for (lastSame=iLook+1;lastSame<numberLook;lastSame++) { 7797 printf("DUPS weight %g first row %d ",value,whichRows[firstSame]); 7798 for (lastSame=iLook;lastSame<numberLook;lastSame++) { 6991 7799 if (weights[lastSame]!=value) 6992 7800 break; 6993 } 6994 //#define PRINT_DUP 6995 #ifdef PRINT_DUP 6996 if (lastSamefirstSame>2) 6997 printf("dupsame %d rows have same weight\n",lastSamefirstSame); 6998 #endif 6999 } 7000 int iThis=whichRows[iLook]; 7801 else 7802 printf(", %d ",whichRows[lastSame]); 7803 } 7804 printf("\n"); 7805 #endif 7001 7806 CoinBigIndex start = rowStart[iThis]; 7002 7807 CoinBigIndex end = start + rowLength[iThis]; … … 7063 7868 rlo1,rup1,rlo2,rup2); 7064 7869 #endif 7065 /* we always keep this and delete last 7066 later maybe keep better formed one */ 7067 rlo2 = CoinMax(rlo1,rlo2); 7068 if (rlo2<1.0e30) 7069 rlo2=COIN_DBL_MAX; 7070 rup2 = CoinMin(rup1,rup2); 7071 if (rup2>1.0e30) 7072 rup2=COIN_DBL_MAX; 7870 if (!noOverlaps) { 7871 /* we always keep this and delete last 7872 later maybe keep better formed one */ 7873 rlo2 = CoinMax(rlo1,rlo2); 7874 if (rlo2<1.0e30) 7875 rlo2=COIN_DBL_MAX; 7876 rup2 = CoinMin(rup1,rup2); 7877 if (rup2>1.0e30) 7878 rup2=COIN_DBL_MAX; 7879 } else { 7880 /* keep better formed one */ 7881 if (rlo2>=rlo11.0e8&&rup2<=rup1+1.0e8) { 7882 // ok 7883 rlo2 = CoinMax(rlo1,rlo2); 7884 if (rlo2<1.0e30) 7885 rlo2=COIN_DBL_MAX; 7886 rup2 = CoinMin(rup1,rup2); 7887 if (rup2>1.0e30) 7888 rup2=COIN_DBL_MAX; 7889 } else if (rlo1>=rlo21.0e8&&rup1<=rup2+1.0e8) { 7890 rlo2 = CoinMax(rlo1,rlo2); 7891 if (rlo2<1.0e30) 7892 rlo2=COIN_DBL_MAX; 7893 rup2 = CoinMin(rup1,rup2); 7894 if (rup2>1.0e30) 7895 rup2=COIN_DBL_MAX; 7896 // swap 7897 int temp=iLast; 7898 iLast=iThis; 7899 iThis=temp; 7900 } else { 7901 // leave (for now) 7902 #if DEBUG_SOME>0 7903 printf("row %d %g %g row %d %g %g\n",iLast,rlo1,rup1,iThis,rlo2,rup2); 7904 #endif 7905 iLast=iThis; 7906 continue; 7907 } 7908 } 7073 7909 #ifdef PRINT_DUP 7074 7910 printf("pre_duprow %dR %dR keep this\n",iLast,iThis); 7911 #endif 7912 #if 0 7913 if (rowLength[iThis]<4) 7914 counts[rowLength[iThis]]++; 7915 else 7916 counts[4]++; 7075 7917 #endif 7076 7918 if (rup2<rlo2tolerance) { … … 7084 7926 else 7085 7927 rup2=rlo2; 7928 #if 0 7929 if (rowLength[iThis]<4) 7930 countsEq[rowLength[iThis]]++; 7931 else 7932 countsEq[4]++; 7933 #endif 7086 7934 #ifdef PRINT_DUP 7087 7935 printf("Row %d has %d elements == %g\n", … … 7134 7982 } 7135 7983 } else { 7984 #ifdef PRINT_DUP 7136 7985 // say no match 7137 7986 firstSame=1; 7138 value=weights[iLook]; 7139 } 7987 #endif 7988 value=valueThis; 7989 } 7990 iLast=iThis; 7140 7991 } 7141 7992 #ifdef PRINT_DUP 7142 7993 printf("%d possible duplicate rows  deleting %d\n", 7143 7994 nPossible,nDelete); 7995 #endif 7996 #if 0 7997 for (int i=0;i<5;i++) { 7998 if (counts[i]) 7999 printf("CC counts %d %d times of which %d were equalities\n",i,counts[i],countsEq[i]); 8000 } 7144 8001 #endif 7145 8002 delete [] weights; … … 7854 8711 int nChanged = 1; 7855 8712 bool feasible=true; 8713 //#define CLP_NO_SUBS 7856 8714 for (int iRow=0;iRow<numberRows_;iRow++) { 7857 8715 #if DEBUG_SOME>0 … … 7874 8732 if (rowLength[iRow]<=1) { 7875 8733 if (rowLength[iRow]==1) { 8734 #ifndef CLP_NO_SUBS 7876 8735 whichRows[numberRowsLook++]=iRow; 8736 #endif 7877 8737 } else { 7878 8738 #if DEBUG_SOME > 0 … … 7903 8763 #ifdef TWOFER 7904 8764 } else if (rowLower[iRow]==rowUpper[iRow]) { 8765 #ifndef CLP_NO_SUBS 7905 8766 whichRows[numberRowsLook++]=iRow; 8767 #endif 7906 8768 CoinBigIndex start = rowStart[iRow]; 7907 8769 int iColumn1 = column[start]; … … 8109 8971 } 8110 8972 int rowLength2=putRstartR; 8973 #ifndef CLP_NO_SUBS 8111 8974 if (rowLength2<=1&&rowLength[jRow]>1&&jRow<iRow) { 8112 8975 // may be interesting 8113 8976 whichRows[numberRowsLook++]=jRow; 8114 8977 } 8978 #endif 8115 8979 rowLength[jRow]=rowLength2; 8116 8980 } … … 8119 8983 #endif 8120 8984 } 8985 } else if (true&&rowLower[iRow]==COIN_DBL_MAX&&rowUpper[iRow]==COIN_DBL_MAX) { 8986 #if DEBUG_SOME > 0 8987 printf("Dropping null free row %d (status %d)  nActions %d\n", 8988 iRow,getRowStatus(iRow),nActions); 8989 #endif 8990 rowType[iRow]=1; 8991 clpPresolveInfo1_4_8 thisInfo; 8992 thisInfo.oldRowLower=(rowLower_[iRow]>1.0e30) ? rowLower_[iRow]rowLower[iRow] : rowLower[iRow]; 8993 thisInfo.oldRowUpper=(rowUpper_[iRow]<1.0e30) ? rowUpper_[iRow]rowUpper[iRow] : rowUpper[iRow]; 8994 thisInfo.row=iRow; 8995 int n=rowLength[iRow]; 8996 CoinBigIndex start=rowStart[iRow]; 8997 thisInfo.lengthRow=n; 8998 //thisInfo.column=1; 8999 infoA[nActions].infoOffset=stuff.putStuffstartStuff; 9000 infoA[nActions].type=1; 9001 nActions++; 9002 ClpCopyToMiniSave(stuff,reinterpret_cast<char *>(&thisInfo),sizeof(clpPresolveInfo1_4_8), 9003 n,column+start,elementByRow+start); 8121 9004 } 8122 9005 } … … 8492 9375 } 8493 9376 } 8494 if ( nActions&&feasible) {9377 if (feasible) { 8495 9378 clpPresolveMore moreInfo; 8496 9379 moreInfo.model=newModel; … … 9197 10080 } 9198 10081 if (hasToBeBasic) { 9199 abort();10082 //abort(); 9200 10083 //setRowStatus(iRow,superBasic); 9201 10084 setColumnStatus(iColumn,basic);
Note: See TracChangeset
for help on using the changeset viewer.