Changeset 648
- Timestamp:
- Jul 3, 2005 12:40:47 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ClpMessage.cpp
r618 r648 114 114 language_=language; 115 115 strcpy(source_,"Clp"); 116 class_ = 1; //solver 116 117 Clp_message * message = us_english; 117 118 -
trunk/ClpModel.cpp
r647 r648 1023 1023 } 1024 1024 numberColumns_ = newNumberColumns; 1025 // for now gets rid of names 1026 lengthNames_ = 0; 1027 rowNames_ = std::vector<std::string> (); 1028 columnNames_ = std::vector<std::string> (); 1025 if (lengthNames_) { 1026 // reduce row and column names vectors only if necessary 1027 if (rowNames_.size() < (unsigned int)numberRows_) 1028 rowNames_.resize(numberRows_); 1029 if (columnNames_.size() < (unsigned int)numberColumns_) 1030 columnNames_.resize(numberColumns_); 1031 } 1029 1032 } 1030 1033 // Deletes rows … … 1068 1071 } 1069 1072 #if 1 1073 // Now works if which out of order 1070 1074 if (lengthNames_) { 1071 int i, j, k; 1072 for (k = 0, j = 0, i = 0; j < number && i < numberRows_; ++i) { 1073 if (which[j] == i) { 1074 ++j; 1075 } else { 1075 char * mark = new char [numberRows_]; 1076 memset(mark,0,numberRows_); 1077 int i; 1078 for (i=0;i<number;i++) 1079 mark[which[i]]=1; 1080 int k=0; 1081 for ( i = 0; i < numberRows_; ++i) { 1082 if (!mark[i]) 1076 1083 rowNames_[k++] = rowNames_[i]; 1077 }1078 }1079 for ( ; i < numberRows_; ++i) {1080 rowNames_[k++] = rowNames_[i];1081 1084 } 1082 1085 rowNames_.erase(rowNames_.begin()+k, rowNames_.end()); 1086 delete [] mark; 1083 1087 } 1084 1088 #else … … 1153 1157 number, which, newSize,true); 1154 1158 #if 1 1159 // Now works if which out of order 1155 1160 if (lengthNames_) { 1156 int i, j, k; 1157 for (k = 0, j = 0, i = 0; j < number && i < numberColumns_; ++i) { 1158 if (which[j] == i) { 1159 ++j; 1160 } else { 1161 printf("size of names %d\n",columnNames_.size()); 1162 char * mark = new char [numberColumns_]; 1163 memset(mark,0,numberColumns_); 1164 int i; 1165 for (i=0;i<number;i++) 1166 mark[which[i]]=1; 1167 int k=0; 1168 for ( i = 0; i < numberColumns_; ++i) { 1169 if (!mark[i]) 1161 1170 columnNames_[k++] = columnNames_[i]; 1162 }1163 }1164 for ( ; i < numberColumns_; ++i) {1165 columnNames_[k++] = columnNames_[i];1166 1171 } 1167 1172 columnNames_.erase(columnNames_.begin()+k, columnNames_.end()); 1173 delete [] mark; 1168 1174 } 1169 1175 #else … … 1296 1302 delete [] columnScale_; 1297 1303 columnScale_ = NULL; 1304 if (lengthNames_) { 1305 rowNames_.resize(numberRows_); 1306 } 1298 1307 } 1299 1308 // Add rows from a build object … … 1301 1310 ClpModel::addRows(const CoinBuild & buildObject,bool tryPlusMinusOne,bool checkDuplicates) 1302 1311 { 1303 if (buildObject.numberElements()==0)1304 return 0;1305 1312 CoinAssertHint (buildObject.type()==0,"Looks as if both addRows and addCols being used"); // check correct 1306 1313 int number = buildObject.numberRows(); … … 1748 1755 delete [] columnScale_; 1749 1756 columnScale_ = NULL; 1757 if (lengthNames_) { 1758 columnNames_.resize(numberColumns_); 1759 } 1750 1760 } 1751 1761 // Add columns from a build object … … 1753 1763 ClpModel::addColumns(const CoinBuild & buildObject,bool tryPlusMinusOne,bool checkDuplicates) 1754 1764 { 1755 if (buildObject.numberElements()==0)1756 return 0;1757 1765 CoinAssertHint (buildObject.type()==1,"Looks as if both addRows and addCols being used"); // check correct 1758 1766 int number = buildObject.numberColumns(); -
trunk/ClpSimplexOther.cpp
r636 r648 205 205 double & costDecrease, int & sequenceDecrease, double & alphaDecrease) 206 206 { 207 double acceptablePivot = 1.0e- 7;207 double acceptablePivot = 1.0e-9; 208 208 double * work; 209 209 int number; … … 2023 2023 int returnCode = -1; 2024 2024 double saveSumDual = sumDualInfeasibilities_; // so we know to be careful 2025 //double useTheta = startingTheta;2025 double useTheta = startingTheta; 2026 2026 double * primalChange = new double[numberRows_]; 2027 2027 double * dualChange = new double[numberColumns_]; 2028 2028 int numberTotal = numberColumns_+numberRows_; 2029 2029 int iSequence; 2030 // See if bounds 2031 int type=0; 2032 for (iSequence=0;iSequence<numberTotal;iSequence++) { 2033 if (changeLower[iSequence]||changeUpper[iSequence]) { 2034 type=1; 2035 break; 2036 } 2037 } 2038 // See if objective 2039 for (iSequence=0;iSequence<numberTotal;iSequence++) { 2040 if (changeObjective[iSequence]) { 2041 type |= 2; 2042 break; 2043 } 2044 } 2045 assert (type); 2030 2046 while (problemStatus_==-1) { 2031 2047 double increaseTheta = CoinMin(endingTheta-useTheta,1.0e50); 2048 2032 2049 // Get theta for bounds - we know can't crossover 2033 // get change 2034 int iSequence; 2035 for (iSequence=0;iSequence<numberTotal;iSequence++) { 2036 primalChange[iSequence]=0.0; 2037 switch(getStatus(iSequence)) { 2038 2039 case basic: 2040 case isFree: 2041 case superBasic: 2042 break; 2043 case isFixed: 2044 case atUpperBound: 2045 primalChange[iSequence]=changeUpper[iSequence]; 2046 break; 2047 case atLowerBound: 2048 primalChange[iSequence]=changeLower[iSequence]; 2049 break; 2050 } 2051 } 2052 // use rowActivity 2053 memset(rowActivity_,0,numberRows_*sizeof(double)); 2054 times(1.0,primalChange,rowActivity_); 2055 2050 int pivotType = nextTheta(type,increaseTheta,primalChange,dualChange, 2051 changeLower,changeUpper,changeObjective); 2052 if (pivotType) 2053 abort(); 2056 2054 // choose row to go out 2057 2055 // dualRow will go to virtual row pivot choice algorithm … … 2497 2495 return returnCode; 2498 2496 } 2497 // Computes next theta and says if objective or bounds (0= bounds, 1 objective, -1 none) 2498 int 2499 ClpSimplexOther::nextTheta(int type, double maxTheta, double * primalChange, double * dualChange, 2500 const double * changeLower, const double * changeUpper, 2501 const double * changeObjective) 2502 { 2503 int numberTotal = numberColumns_+numberRows_; 2504 int iSequence; 2505 int iRow; 2506 theta_=maxTheta; 2507 bool toLower=false; 2508 if ((type&1)!=0) { 2509 // get change 2510 for (iSequence=0;iSequence<numberTotal;iSequence++) { 2511 primalChange[iSequence]=0.0; 2512 switch(getStatus(iSequence)) { 2513 2514 case basic: 2515 case isFree: 2516 case superBasic: 2517 break; 2518 case isFixed: 2519 case atUpperBound: 2520 primalChange[iSequence]=changeUpper[iSequence]; 2521 break; 2522 case atLowerBound: 2523 primalChange[iSequence]=changeLower[iSequence]; 2524 break; 2525 } 2526 } 2527 // use array 2528 double * array = rowArray_[1]->denseVector(); 2529 times(1.0,primalChange,array); 2530 int * index = rowArray_[1]->getIndices(); 2531 int number=0; 2532 for (iRow=0;iRow<numberRows_;iRow++) { 2533 double value = array[iRow]; 2534 if (value) { 2535 array[iRow]=value; 2536 index[number++]=iRow; 2537 } 2538 } 2539 // ftran it 2540 rowArray_[1]->setNumElements(number); 2541 factorization_->updateColumn(rowArray_[0],rowArray_[1]); 2542 number=rowArray_[1]->getNumElements(); 2543 pivotRow_=-1; 2544 for (iRow=0;iRow<number;iRow++) { 2545 int iPivot = index[iRow]; 2546 iSequence = pivotVariable_[iPivot]; 2547 // solution value will be sol - theta*alpha 2548 // bounds will be bounds + change *theta 2549 double currentSolution = solution_[iSequence]; 2550 double currentLower = lower_[iSequence]; 2551 double currentUpper = upper_[iSequence]; 2552 double alpha = array[iPivot]; 2553 assert (currentSolution>=currentLower-primalTolerance_); 2554 assert (currentSolution<=currentUpper+primalTolerance_); 2555 double thetaCoefficient; 2556 double hitsLower = COIN_DBL_MAX; 2557 thetaCoefficient = changeLower[iSequence]+alpha; 2558 if (fabs(thetaCoefficient)>1.0e-8) 2559 hitsLower = (currentSolution-currentLower)/thetaCoefficient; 2560 if (hitsLower<0.0) { 2561 // does not hit - but should we check further 2562 hitsLower=COIN_DBL_MAX; 2563 } 2564 double hitsUpper = COIN_DBL_MAX; 2565 thetaCoefficient = changeUpper[iSequence]+alpha; 2566 if (fabs(thetaCoefficient)>1.0e-8) 2567 hitsUpper = (currentSolution-currentUpper)/thetaCoefficient; 2568 if (hitsUpper<0.0) { 2569 // does not hit - but should we check further 2570 hitsUpper=COIN_DBL_MAX; 2571 } 2572 if (CoinMin(hitsLower,hitsUpper)<theta_) { 2573 theta_ = CoinMin(hitsLower,hitsUpper); 2574 toLower = hitsLower<hitsUpper; 2575 pivotRow_=iPivot; 2576 } 2577 } 2578 } 2579 if ((type&2)!=0) { 2580 abort(); 2581 } 2582 if (pivotRow_>=0) { 2583 sequenceOut_ = pivotVariable_[pivotRow_]; 2584 valueOut_ = solution_[sequenceOut_]; 2585 lowerOut_ = lower_[sequenceOut_]; 2586 upperOut_ = upper_[sequenceOut_]; 2587 if (!toLower) { 2588 directionOut_ = -1; 2589 dualOut_ = valueOut_ - upperOut_; 2590 } else if (valueOut_<lowerOut_) { 2591 directionOut_ = 1; 2592 dualOut_ = lowerOut_ - valueOut_; 2593 } 2594 return 0; 2595 } else { 2596 return -1; 2597 } 2598 } -
trunk/ClpSolve.cpp
r618 r648 376 376 saveSignal = signal(SIGINT,signal_handler); 377 377 } 378 // If no status array - set up basis 379 if (!status_) 380 allSlackBasis(); 378 381 ClpPresolve pinfo; 379 382 pinfo.setSubstitution(options.substitution()); -
trunk/Makefile.Clp
r599 r648 7 7 # between then specify the exact level you want, e.g., -O1 or -O2 8 8 OptLevel := -g 9 OptLevel := -O19 #OptLevel := -O1 10 10 11 11 LIBNAME := Clp -
trunk/include/ClpSimplex.hpp
r645 r648 210 210 */ 211 211 int dual(int ifValuesPass=0, int startFinishOptions=0); 212 // / For debug212 // If using Debug 213 213 int dualDebug(int ifValuesPass=0, int startFinishOptions=0); 214 214 /** Primal algorithm - see ClpSimplexPrimal.hpp for method. -
trunk/include/ClpSimplexOther.hpp
r636 r648 102 102 const double * changeLower, const double * changeUpper, 103 103 const double * changeObjective); 104 /** Computes next theta and says if objective or bounds (0= bounds, 1 objective, -1 none). 105 theta is in theta_. 106 type 1 bounds, 2 objective, 3 both. 107 */ 108 int nextTheta(int type, double maxTheta, double * primalChange, double * dualChange, 109 const double * changeLower, const double * changeUpper, 110 const double * changeObjective); 104 111 /** 105 112 Row array has row part of pivot row
Note: See TracChangeset
for help on using the changeset viewer.