Changeset 1283 for trunk/Clp


Ignore:
Timestamp:
Sep 21, 2008 12:15:55 PM (11 years ago)
Author:
forrest
Message:

try and fix assert on upper_

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Clp/src/ClpSimplex.cpp

    r1282 r1283  
    1121611216  assert (!info->saveCosts_);
    1121711217  int numberTotal = numberRows_+numberColumns_;
    11218   info->saveCosts_ = CoinCopyOfArray(cost_,numberTotal);
     11218  double * save = new double [3*numberTotal];
     11219  info->saveCosts_ = save;
     11220  CoinMemcpyN(cost_,numberTotal,save);
    1121911221  return 0;
    1122011222}
     
    1122511227  assert ((info->solverOptions_&65536)!=0);
    1122611228  int numberTotal = numberRows_+numberColumns_;
    11227 #ifndef NDEBUG
    11228   if (columnScale_&&optimizationDirection_==1.0) {
    11229     //const double * obj = objective();
    11230     for (int i=0;i<numberColumns_;i++) {
    11231       //assert (fabs(cost_[i]-obj[i]*columnScale_[i])<1.0e-8);
    11232       if (lower_[i]>-1.0e30)
    11233         assert (fabs(lower_[i]-columnLower_[i]/columnScale_[i])<1.0e-8);
    11234       if (upper_[i]<1.0e30)
    11235         assert (fabs(upper_[i]-columnUpper_[i]/columnScale_[i])<1.0e-8);
    11236     }
    11237   }
    11238 #endif
    1123911229  assert (info->saveCosts_);
    11240   CoinMemcpyN(info->saveCosts_,numberTotal,cost_);
     11230  double * save = info->saveCosts_;
     11231  CoinMemcpyN(save,numberTotal,cost_);
     11232  save += numberTotal;
     11233  CoinMemcpyN(lower_,numberTotal,save);
     11234  save += numberTotal;
     11235  CoinMemcpyN(upper_,numberTotal,save);
    1124111236  numberPrimalInfeasibilities_=1;
    1124211237  sumPrimalInfeasibilities_=0.5;
     
    1127611271    // check which algorithms allowed
    1127711272    baseIteration_=numberIterations_;
    11278     // save upper and lower around primal
    11279     double * saveLower2 = CoinCopyOfArray(lower_,numberColumns_+numberRows_);
    11280     double * saveUpper2 = CoinCopyOfArray(upper_,numberColumns_+numberRows_);
    1128111273    status = ((ClpSimplexPrimal *) this)->primal(1,7);
    11282     CoinMemcpyN(saveLower2,numberColumns_+numberRows_,lower_);
    11283     delete [] saveLower2;
    11284     CoinMemcpyN(saveUpper2,numberColumns_+numberRows_,upper_);
    11285     delete [] saveUpper2;
    1128611274    baseIteration_=0;
    1128711275    if (saveObjective != objective_) {
     
    1129111279      if (!problemStatus_) {
    1129211280        // carry on
    11293         // save upper and lower around primal
    11294         double * saveLower2 = CoinCopyOfArray(lower_,numberColumns_+numberRows_);
    11295         double * saveUpper2 = CoinCopyOfArray(upper_,numberColumns_+numberRows_);
    1129611281        status = ((ClpSimplexPrimal *) this)->primal(1,7);
    11297         CoinMemcpyN(saveLower2,numberColumns_+numberRows_,lower_);
    11298         delete [] saveLower2;
    11299         CoinMemcpyN(saveUpper2,numberColumns_+numberRows_,upper_);
    11300         delete [] saveUpper2;
    1130111282      }
    1130211283    }
     
    1134711328    }
    1134811329    handler_->setLogLevel(saveLog);
    11349   } else if (problemStatus_==1) {
    11350     // bounds may be bad
    11351     int numberTotal = numberRows_+numberColumns_;
    11352     if (columnScale_) {
    11353       for (int i=0;i<numberTotal;i++) {
    11354         if (lower_[i]>-1.0e30) {
    11355           if (fabs(lower_[i]*columnScale_[i]-columnLower_[i])>1.0e-8)
    11356             lower_[i]=columnLower_[i]/columnScale_[i];
    11357         }
    11358         if (upper_[i]<1.0e30) {
    11359           if (fabs(upper_[i]*columnScale_[i]-columnUpper_[i])>1.0e-8)
    11360             upper_[i]=columnUpper_[i]/columnScale_[i];
    11361         }
    11362       }
    11363     } else {
    11364       for (int i=0;i<numberTotal;i++) {
    11365         if (lower_[i]>-1.0e30) {
    11366           if (lower_[i]!=columnLower_[i])
    11367             lower_[i]=columnLower_[i];
    11368         }
    11369         if (upper_[i]<1.0e30) {
    11370           if (upper_[i]!=columnUpper_[i])
    11371             upper_[i]=columnUpper_[i];
    11372         }
    11373       }
    11374     }
    1137511330  }
    1137611331  status=problemStatus_;
     
    1141211367    }
    1141311368  }
    11414 #ifndef NDEBUG
    11415   if (columnScale_) {
    11416     for (int i=0;i<numberColumns_;i++) {
    11417       if (lower_[i]>-1.0e30)
    11418         assert (fabs(lower_[i]-columnLower_[i]/columnScale_[i])<1.0e-8);
    11419       if (upper_[i]<1.0e30)
    11420         assert (fabs(upper_[i]-columnUpper_[i]/columnScale_[i])<1.0e-8);
    11421     }
    11422   } else {
    11423     for (int i=0;i<numberColumns_;i++) {
    11424       if (lower_[i]>-1.0e30)
    11425         assert (fabs(lower_[i]-columnLower_[i])<1.0e-8);
    11426       if (upper_[i]<1.0e30)
    11427         assert (fabs(upper_[i]-columnUpper_[i])<1.0e-8);
    11428     }
    11429   }
    11430 #endif
     11369  save = info->saveCosts_;
     11370  CoinMemcpyN(save,numberTotal,cost_);
     11371  save += numberTotal;
     11372  CoinMemcpyN(save,numberTotal,lower_);
     11373  save += numberTotal;
     11374  CoinMemcpyN(save,numberTotal,upper_);
    1143111375  return status;
    1143211376}
Note: See TracChangeset for help on using the changeset viewer.