00001
00002
00003
00004
00005
00006
00007 #include "CoinPragma.hpp"
00008
00009 #include <math.h>
00010
00011 #include "CoinHelperFunctions.hpp"
00012 #include "ClpInterior.hpp"
00013 #include "ClpMatrixBase.hpp"
00014 #ifdef PDCO
00015 #include "ClpLsqr.hpp"
00016 #include "ClpPdcoBase.hpp"
00017 #endif
00018 #include "CoinDenseVector.hpp"
00019 #include "ClpMessage.hpp"
00020 #include "ClpHelperFunctions.hpp"
00021 #include "ClpCholeskyDense.hpp"
00022 #include "ClpLinearObjective.hpp"
00023 #include <cfloat>
00024
00025 #include <string>
00026 #include <stdio.h>
00027 #include <iostream>
00028
00029
00030 ClpInterior::ClpInterior () :
00031
00032 ClpModel(),
00033 largestPrimalError_(0.0),
00034 largestDualError_(0.0),
00035 sumDualInfeasibilities_(0.0),
00036 sumPrimalInfeasibilities_(0.0),
00037 worstComplementarity_(0.0),
00038 xsize_(0.0),
00039 zsize_(0.0),
00040 lower_(NULL),
00041 rowLowerWork_(NULL),
00042 columnLowerWork_(NULL),
00043 upper_(NULL),
00044 rowUpperWork_(NULL),
00045 columnUpperWork_(NULL),
00046 cost_(NULL),
00047 rhs_(NULL),
00048 x_(NULL),
00049 y_(NULL),
00050 dj_(NULL),
00051 lsqrObject_(NULL),
00052 pdcoStuff_(NULL),
00053 mu_(0.0),
00054 objectiveNorm_(1.0e-12),
00055 rhsNorm_(1.0e-12),
00056 solutionNorm_(1.0e-12),
00057 dualObjective_(0.0),
00058 primalObjective_(0.0),
00059 diagonalNorm_(1.0e-12),
00060 stepLength_(0.99995),
00061 linearPerturbation_(1.0e-12),
00062 diagonalPerturbation_(1.0e-15),
00063 targetGap_(1.0e-12),
00064 projectionTolerance_(1.0e-7),
00065 maximumRHSError_(0.0),
00066 maximumBoundInfeasibility_(0.0),
00067 maximumDualError_(0.0),
00068 diagonalScaleFactor_(0.0),
00069 scaleFactor_(1.0),
00070 actualPrimalStep_(0.0),
00071 actualDualStep_(0.0),
00072 smallestInfeasibility_(0.0),
00073 complementarityGap_(0.0),
00074 baseObjectiveNorm_(0.0),
00075 worstDirectionAccuracy_(0.0),
00076 maximumRHSChange_(0.0),
00077 errorRegion_(NULL),
00078 rhsFixRegion_(NULL),
00079 updateRegion_(NULL),
00080 upperSlack_(NULL),
00081 lowerSlack_(NULL),
00082 diagonal_(NULL),
00083 weights_(NULL),
00084 solution_(NULL),
00085 deltaZ_(NULL),
00086 deltaW_(NULL),
00087 deltaS_(NULL),
00088 deltaT_(NULL),
00089 zVec_(NULL),
00090 wVec_(NULL),
00091 cholesky_(NULL),
00092 numberComplementarityPairs_(0),
00093 maximumBarrierIterations_(200),
00094 gonePrimalFeasible_(false),
00095 goneDualFeasible_(false),
00096 algorithm_(-1)
00097 {
00098 memset(historyInfeasibility_,0,LENGTH_HISTORY*sizeof(double));
00099 solveType_=2;
00100 cholesky_ = new ClpCholeskyDense();
00101 }
00102
00103
00104 ClpInterior::ClpInterior ( const ClpModel * rhs,
00105 int numberRows, const int * whichRow,
00106 int numberColumns, const int * whichColumn,
00107 bool dropNames, bool dropIntegers)
00108 : ClpModel(rhs, numberRows, whichRow,
00109 numberColumns,whichColumn,dropNames,dropIntegers),
00110 largestPrimalError_(0.0),
00111 largestDualError_(0.0),
00112 sumDualInfeasibilities_(0.0),
00113 sumPrimalInfeasibilities_(0.0),
00114 worstComplementarity_(0.0),
00115 xsize_(0.0),
00116 zsize_(0.0),
00117 lower_(NULL),
00118 rowLowerWork_(NULL),
00119 columnLowerWork_(NULL),
00120 upper_(NULL),
00121 rowUpperWork_(NULL),
00122 columnUpperWork_(NULL),
00123 cost_(NULL),
00124 rhs_(NULL),
00125 x_(NULL),
00126 y_(NULL),
00127 dj_(NULL),
00128 lsqrObject_(NULL),
00129 pdcoStuff_(NULL),
00130 mu_(0.0),
00131 objectiveNorm_(1.0e-12),
00132 rhsNorm_(1.0e-12),
00133 solutionNorm_(1.0e-12),
00134 dualObjective_(0.0),
00135 primalObjective_(0.0),
00136 diagonalNorm_(1.0e-12),
00137 stepLength_(0.99995),
00138 linearPerturbation_(1.0e-12),
00139 diagonalPerturbation_(1.0e-15),
00140 targetGap_(1.0e-12),
00141 projectionTolerance_(1.0e-7),
00142 maximumRHSError_(0.0),
00143 maximumBoundInfeasibility_(0.0),
00144 maximumDualError_(0.0),
00145 diagonalScaleFactor_(0.0),
00146 scaleFactor_(0.0),
00147 actualPrimalStep_(0.0),
00148 actualDualStep_(0.0),
00149 smallestInfeasibility_(0.0),
00150 complementarityGap_(0.0),
00151 baseObjectiveNorm_(0.0),
00152 worstDirectionAccuracy_(0.0),
00153 maximumRHSChange_(0.0),
00154 errorRegion_(NULL),
00155 rhsFixRegion_(NULL),
00156 updateRegion_(NULL),
00157 upperSlack_(NULL),
00158 lowerSlack_(NULL),
00159 diagonal_(NULL),
00160 weights_(NULL),
00161 solution_(NULL),
00162 deltaZ_(NULL),
00163 deltaW_(NULL),
00164 deltaS_(NULL),
00165 deltaT_(NULL),
00166 zVec_(NULL),
00167 wVec_(NULL),
00168 cholesky_(NULL),
00169 numberComplementarityPairs_(0),
00170 maximumBarrierIterations_(200),
00171 gonePrimalFeasible_(false),
00172 goneDualFeasible_(false),
00173 algorithm_(-1)
00174 {
00175 memset(historyInfeasibility_,0,LENGTH_HISTORY*sizeof(double));
00176 solveType_=2;
00177 cholesky_= new ClpCholeskyDense();
00178 }
00179
00180
00181
00182 ClpInterior::~ClpInterior ()
00183 {
00184 gutsOfDelete();
00185 }
00186
00187
00188
00189
00190 int
00191 ClpInterior::housekeeping()
00192 {
00193 numberIterations_++;
00194 return 0;
00195 }
00196
00197 ClpInterior::ClpInterior(const ClpInterior &rhs) :
00198 ClpModel(rhs),
00199 largestPrimalError_(0.0),
00200 largestDualError_(0.0),
00201 sumDualInfeasibilities_(0.0),
00202 sumPrimalInfeasibilities_(0.0),
00203 worstComplementarity_(0.0),
00204 xsize_(0.0),
00205 zsize_(0.0),
00206 lower_(NULL),
00207 rowLowerWork_(NULL),
00208 columnLowerWork_(NULL),
00209 upper_(NULL),
00210 rowUpperWork_(NULL),
00211 columnUpperWork_(NULL),
00212 cost_(NULL),
00213 rhs_(NULL),
00214 x_(NULL),
00215 y_(NULL),
00216 dj_(NULL),
00217 lsqrObject_(NULL),
00218 pdcoStuff_(NULL),
00219 errorRegion_(NULL),
00220 rhsFixRegion_(NULL),
00221 updateRegion_(NULL),
00222 upperSlack_(NULL),
00223 lowerSlack_(NULL),
00224 diagonal_(NULL),
00225 weights_(NULL),
00226 solution_(NULL),
00227 deltaZ_(NULL),
00228 deltaW_(NULL),
00229 deltaS_(NULL),
00230 deltaT_(NULL),
00231 zVec_(NULL),
00232 wVec_(NULL),
00233 cholesky_(NULL)
00234 {
00235 gutsOfDelete();
00236 gutsOfCopy(rhs);
00237 solveType_=2;
00238 }
00239
00240 ClpInterior::ClpInterior(const ClpModel &rhs) :
00241 ClpModel(rhs),
00242 largestPrimalError_(0.0),
00243 largestDualError_(0.0),
00244 sumDualInfeasibilities_(0.0),
00245 sumPrimalInfeasibilities_(0.0),
00246 worstComplementarity_(0.0),
00247 xsize_(0.0),
00248 zsize_(0.0),
00249 lower_(NULL),
00250 rowLowerWork_(NULL),
00251 columnLowerWork_(NULL),
00252 upper_(NULL),
00253 rowUpperWork_(NULL),
00254 columnUpperWork_(NULL),
00255 cost_(NULL),
00256 rhs_(NULL),
00257 x_(NULL),
00258 y_(NULL),
00259 dj_(NULL),
00260 lsqrObject_(NULL),
00261 pdcoStuff_(NULL),
00262 mu_(0.0),
00263 objectiveNorm_(1.0e-12),
00264 rhsNorm_(1.0e-12),
00265 solutionNorm_(1.0e-12),
00266 dualObjective_(0.0),
00267 primalObjective_(0.0),
00268 diagonalNorm_(1.0e-12),
00269 stepLength_(0.99995),
00270 linearPerturbation_(1.0e-12),
00271 diagonalPerturbation_(1.0e-15),
00272 targetGap_(1.0e-12),
00273 projectionTolerance_(1.0e-7),
00274 maximumRHSError_(0.0),
00275 maximumBoundInfeasibility_(0.0),
00276 maximumDualError_(0.0),
00277 diagonalScaleFactor_(0.0),
00278 scaleFactor_(0.0),
00279 actualPrimalStep_(0.0),
00280 actualDualStep_(0.0),
00281 smallestInfeasibility_(0.0),
00282 complementarityGap_(0.0),
00283 baseObjectiveNorm_(0.0),
00284 worstDirectionAccuracy_(0.0),
00285 maximumRHSChange_(0.0),
00286 errorRegion_(NULL),
00287 rhsFixRegion_(NULL),
00288 updateRegion_(NULL),
00289 upperSlack_(NULL),
00290 lowerSlack_(NULL),
00291 diagonal_(NULL),
00292 weights_(NULL),
00293 solution_(NULL),
00294 deltaZ_(NULL),
00295 deltaW_(NULL),
00296 deltaS_(NULL),
00297 deltaT_(NULL),
00298 zVec_(NULL),
00299 wVec_(NULL),
00300 cholesky_(NULL),
00301 numberComplementarityPairs_(0),
00302 maximumBarrierIterations_(200),
00303 gonePrimalFeasible_(false),
00304 goneDualFeasible_(false),
00305 algorithm_(-1)
00306 {
00307 memset(historyInfeasibility_,0,LENGTH_HISTORY*sizeof(double));
00308 solveType_=2;
00309 cholesky_= new ClpCholeskyDense();
00310 }
00311
00312 ClpInterior &
00313 ClpInterior::operator=(const ClpInterior & rhs)
00314 {
00315 if (this != &rhs) {
00316 gutsOfDelete();
00317 ClpModel::operator=(rhs);
00318 gutsOfCopy(rhs);
00319 }
00320 return *this;
00321 }
00322 void
00323 ClpInterior::gutsOfCopy(const ClpInterior & rhs)
00324 {
00325 lower_ = ClpCopyOfArray(rhs.lower_,numberColumns_+numberRows_);
00326 rowLowerWork_ = lower_+numberColumns_;
00327 columnLowerWork_ = lower_;
00328 upper_ = ClpCopyOfArray(rhs.upper_,numberColumns_+numberRows_);
00329 rowUpperWork_ = upper_+numberColumns_;
00330 columnUpperWork_ = upper_;
00331
00332 cost_ = ClpCopyOfArray(rhs.cost_,numberColumns_);
00333 rhs_ = ClpCopyOfArray(rhs.rhs_,numberRows_);
00334 x_ = ClpCopyOfArray(rhs.x_,numberColumns_);
00335 y_ = ClpCopyOfArray(rhs.y_,numberRows_);
00336 dj_ = ClpCopyOfArray(rhs.dj_,numberColumns_+numberRows_);
00337 #ifdef PDCO
00338 lsqrObject_= new ClpLsqr(*rhs.lsqrObject_);
00339 pdcoStuff_ = rhs.pdcoStuff_->clone();
00340 #endif
00341 largestPrimalError_ = rhs.largestPrimalError_;
00342 largestDualError_ = rhs.largestDualError_;
00343 sumDualInfeasibilities_ = rhs.sumDualInfeasibilities_;
00344 sumPrimalInfeasibilities_ = rhs.sumPrimalInfeasibilities_;
00345 worstComplementarity_ = rhs.worstComplementarity_;
00346 xsize_ = rhs.xsize_;
00347 zsize_ = rhs.zsize_;
00348 solveType_=rhs.solveType_;
00349 mu_ = rhs.mu_;
00350 objectiveNorm_ = rhs.objectiveNorm_;
00351 rhsNorm_ = rhs.rhsNorm_;
00352 solutionNorm_ = rhs.solutionNorm_;
00353 dualObjective_ = rhs.dualObjective_;
00354 primalObjective_ = rhs.primalObjective_;
00355 diagonalNorm_ = rhs.diagonalNorm_;
00356 stepLength_ = rhs.stepLength_;
00357 linearPerturbation_ = rhs.linearPerturbation_;
00358 diagonalPerturbation_ = rhs.diagonalPerturbation_;
00359 targetGap_ = rhs.targetGap_;
00360 projectionTolerance_ = rhs.projectionTolerance_;
00361 maximumRHSError_ = rhs.maximumRHSError_;
00362 maximumBoundInfeasibility_ = rhs.maximumBoundInfeasibility_;
00363 maximumDualError_ = rhs.maximumDualError_;
00364 diagonalScaleFactor_ = rhs.diagonalScaleFactor_;
00365 scaleFactor_ = rhs.scaleFactor_;
00366 actualPrimalStep_ = rhs.actualPrimalStep_;
00367 actualDualStep_ = rhs.actualDualStep_;
00368 smallestInfeasibility_ = rhs.smallestInfeasibility_;
00369 complementarityGap_ = rhs.complementarityGap_;
00370 baseObjectiveNorm_ = rhs.baseObjectiveNorm_;
00371 worstDirectionAccuracy_ = rhs.worstDirectionAccuracy_;
00372 maximumRHSChange_ = rhs.maximumRHSChange_;
00373 errorRegion_ = ClpCopyOfArray(rhs.errorRegion_,numberRows_);
00374 rhsFixRegion_ = ClpCopyOfArray(rhs.rhsFixRegion_,numberRows_);
00375 updateRegion_ = ClpCopyOfArray(rhs.updateRegion_,numberRows_);
00376 upperSlack_ = ClpCopyOfArray(rhs.upperSlack_,numberRows_+numberColumns_);
00377 lowerSlack_ = ClpCopyOfArray(rhs.lowerSlack_,numberRows_+numberColumns_);
00378 diagonal_ = ClpCopyOfArray(rhs.diagonal_,numberRows_+numberColumns_);
00379 weights_ = ClpCopyOfArray(rhs.weights_,numberRows_+numberColumns_);
00380 solution_ = ClpCopyOfArray(rhs.solution_,numberRows_+numberColumns_);
00381 deltaZ_ = ClpCopyOfArray(rhs.deltaZ_,numberRows_+numberColumns_);
00382 deltaW_ = ClpCopyOfArray(rhs.deltaW_,numberRows_+numberColumns_);
00383 deltaS_ = ClpCopyOfArray(rhs.deltaS_,numberRows_+numberColumns_);
00384 deltaT_ = ClpCopyOfArray(rhs.deltaT_,numberRows_+numberColumns_);
00385 zVec_ = ClpCopyOfArray(rhs.zVec_,numberRows_+numberColumns_);
00386 wVec_ = ClpCopyOfArray(rhs.wVec_,numberRows_+numberColumns_);
00387 cholesky_ = rhs.cholesky_->clone();
00388 numberComplementarityPairs_ = rhs.numberComplementarityPairs_;
00389 maximumBarrierIterations_ = rhs.maximumBarrierIterations_;
00390 gonePrimalFeasible_ = rhs.gonePrimalFeasible_;
00391 goneDualFeasible_ = rhs.goneDualFeasible_;
00392 algorithm_ = rhs.algorithm_;
00393 }
00394
00395 void
00396 ClpInterior::gutsOfDelete()
00397 {
00398 delete [] lower_;
00399 lower_=NULL;
00400 rowLowerWork_=NULL;
00401 columnLowerWork_=NULL;
00402 delete [] upper_;
00403 upper_=NULL;
00404 rowUpperWork_=NULL;
00405 columnUpperWork_=NULL;
00406 delete [] cost_;
00407 cost_=NULL;
00408 delete [] rhs_;
00409 rhs_ = NULL;
00410 delete [] x_;
00411 x_ = NULL;
00412 delete [] y_;
00413 y_ = NULL;
00414 delete [] dj_;
00415 dj_ = NULL;
00416 #ifdef PDCO
00417 delete lsqrObject_;
00418 lsqrObject_ = NULL;
00419
00420 pdcoStuff_=NULL;
00421 #endif
00422 delete [] errorRegion_;
00423 errorRegion_ = NULL;
00424 delete [] rhsFixRegion_;
00425 rhsFixRegion_ = NULL;
00426 delete [] updateRegion_;
00427 updateRegion_ = NULL;
00428 delete [] upperSlack_;
00429 upperSlack_ = NULL;
00430 delete [] lowerSlack_;
00431 lowerSlack_ = NULL;
00432 delete [] diagonal_;
00433 diagonal_ = NULL;
00434 delete [] weights_;
00435 weights_ = NULL;
00436 delete [] solution_;
00437 solution_ = NULL;
00438 delete [] deltaZ_;
00439 deltaZ_ = NULL;
00440 delete [] deltaW_;
00441 deltaW_ = NULL;
00442 delete [] deltaS_;
00443 deltaS_ = NULL;
00444 delete [] deltaT_;
00445 deltaT_ = NULL;
00446 delete [] zVec_;
00447 zVec_ = NULL;
00448 delete [] wVec_;
00449 wVec_ = NULL;
00450 delete cholesky_;
00451 }
00452 bool
00453 ClpInterior::createWorkingData()
00454 {
00455 bool goodMatrix=true;
00456
00457 if (!matrix_->allElementsInRange(this,1.0e-12,1.0e20)) {
00458 problemStatus_=4;
00459 goodMatrix= false;
00460 }
00461 int nTotal = numberRows_+numberColumns_;
00462 delete [] solution_;
00463 solution_ = new double[nTotal];
00464 memcpy(solution_,columnActivity_,
00465 numberColumns_*sizeof(double));
00466 memcpy(solution_+numberColumns_,rowActivity_,
00467 numberRows_*sizeof(double));
00468 delete [] cost_;
00469 cost_ = new double[nTotal];
00470 int i;
00471 double direction = optimizationDirection_;
00472
00473 if (direction)
00474 direction = 1.0/direction;
00475 const double * obj = objective();
00476 for (i=0;i<numberColumns_;i++)
00477 cost_[i] = direction*obj[i];
00478 memset(cost_+numberColumns_,0,numberRows_*sizeof(double));
00479 delete [] lower_;
00480 delete [] upper_;
00481 lower_ = new double[nTotal];
00482 upper_ = new double[nTotal];
00483 rowLowerWork_ = lower_+numberColumns_;
00484 columnLowerWork_ = lower_;
00485 rowUpperWork_ = upper_+numberColumns_;
00486 columnUpperWork_ = upper_;
00487 memcpy(rowLowerWork_,rowLower_,numberRows_*sizeof(double));
00488 memcpy(rowUpperWork_,rowUpper_,numberRows_*sizeof(double));
00489 memcpy(columnLowerWork_,columnLower_,numberColumns_*sizeof(double));
00490 memcpy(columnUpperWork_,columnUpper_,numberColumns_*sizeof(double));
00491
00492 for (i=0;i<numberColumns_;i++) {
00493 if (columnLowerWork_[i]<-1.0e30)
00494 columnLowerWork_[i] = -COIN_DBL_MAX;
00495 if (columnUpperWork_[i]>1.0e30)
00496 columnUpperWork_[i] = COIN_DBL_MAX;
00497 }
00498
00499 for (i=0;i<numberRows_;i++) {
00500 if (rowLowerWork_[i]<-1.0e30)
00501 rowLowerWork_[i] = -COIN_DBL_MAX;
00502 if (rowUpperWork_[i]>1.0e30)
00503 rowUpperWork_[i] = COIN_DBL_MAX;
00504 }
00505
00506 if (!sanityCheck())
00507 goodMatrix=false;
00508 assert (!errorRegion_);
00509 errorRegion_ = new double [numberRows_];
00510 assert (!rhsFixRegion_);
00511 rhsFixRegion_ = new double [numberRows_];
00512 assert (!updateRegion_);
00513 updateRegion_ = new double [numberRows_];
00514 assert (!upperSlack_);
00515 upperSlack_ = new double [nTotal];
00516 assert (!lowerSlack_);
00517 lowerSlack_ = new double [nTotal];
00518 assert (!diagonal_);
00519 diagonal_ = new double [nTotal];
00520 assert (!weights_);
00521 weights_ = new double [nTotal];
00522 assert (!deltaZ_);
00523 deltaZ_ = new double [nTotal];
00524 assert (!deltaW_);
00525 deltaW_ = new double [nTotal];
00526 assert (!deltaS_);
00527 deltaS_ = new double [nTotal];
00528 assert (!deltaT_);
00529 deltaT_ = new double [nTotal];
00530 assert (!zVec_);
00531 zVec_ = new double [nTotal];
00532 assert (!wVec_);
00533 wVec_ = new double [nTotal];
00534 assert (!dj_);
00535 dj_ = new double [nTotal];
00536 delete [] status_;
00537 status_ = new unsigned char [numberRows_+numberColumns_];
00538 memset(status_,0,numberRows_+numberColumns_);
00539 return goodMatrix;
00540 }
00541 void
00542 ClpInterior::deleteWorkingData()
00543 {
00544 int i;
00545 if (optimizationDirection_!=1.0) {
00546
00547 for (i=0;i<numberColumns_;i++)
00548 reducedCost_[i] = optimizationDirection_*dj_[i];
00549 for (i=0;i<numberRows_;i++)
00550 dual_[i] *= optimizationDirection_;
00551 }
00552 delete [] cost_;
00553 cost_ = NULL;
00554 delete [] solution_;
00555 solution_ = NULL;
00556 delete [] lower_;
00557 lower_ = NULL;
00558 delete [] upper_;
00559 upper_ = NULL;
00560 delete [] errorRegion_;
00561 errorRegion_ = NULL;
00562 delete [] rhsFixRegion_;
00563 rhsFixRegion_ = NULL;
00564 delete [] updateRegion_;
00565 updateRegion_ = NULL;
00566 delete [] upperSlack_;
00567 upperSlack_ = NULL;
00568 delete [] lowerSlack_;
00569 lowerSlack_ = NULL;
00570 delete [] diagonal_;
00571 diagonal_ = NULL;
00572 delete [] weights_;
00573 weights_ = NULL;
00574 delete [] deltaZ_;
00575 deltaZ_ = NULL;
00576 delete [] deltaW_;
00577 deltaW_ = NULL;
00578 delete [] deltaS_;
00579 deltaS_ = NULL;
00580 delete [] deltaT_;
00581 deltaT_ = NULL;
00582 delete [] zVec_;
00583 zVec_ = NULL;
00584 delete [] wVec_;
00585 wVec_ = NULL;
00586 delete [] dj_;
00587 dj_ = NULL;
00588 }
00589
00590 bool
00591 ClpInterior::sanityCheck()
00592 {
00593
00594 if (!numberRows_||!numberColumns_||!matrix_->getNumElements()) {
00595 handler_->message(CLP_EMPTY_PROBLEM,messages_)
00596 <<numberRows_
00597 <<numberColumns_
00598 <<matrix_->getNumElements()
00599 <<CoinMessageEol;
00600 problemStatus_=4;
00601 return false;
00602 }
00603 int numberBad ;
00604 double largestBound, smallestBound, minimumGap;
00605 double smallestObj, largestObj;
00606 int firstBad;
00607 int modifiedBounds=0;
00608 int i;
00609 numberBad=0;
00610 firstBad=-1;
00611 minimumGap=1.0e100;
00612 smallestBound=1.0e100;
00613 largestBound=0.0;
00614 smallestObj=1.0e100;
00615 largestObj=0.0;
00616
00617 double fixTolerance = 1.1*primalTolerance();
00618 for (i=numberColumns_;i<numberColumns_+numberRows_;i++) {
00619 double value;
00620 value = fabs(cost_[i]);
00621 if (value>1.0e50) {
00622 numberBad++;
00623 if (firstBad<0)
00624 firstBad=i;
00625 } else if (value) {
00626 if (value>largestObj)
00627 largestObj=value;
00628 if (value<smallestObj)
00629 smallestObj=value;
00630 }
00631 value=upper_[i]-lower_[i];
00632 if (value<-primalTolerance()) {
00633 numberBad++;
00634 if (firstBad<0)
00635 firstBad=i;
00636 } else if (value<=fixTolerance) {
00637 if (value) {
00638
00639 upper_[i] = lower_[i];
00640 modifiedBounds++;
00641 }
00642 } else {
00643 if (value<minimumGap)
00644 minimumGap=value;
00645 }
00646 if (lower_[i]>-1.0e100&&lower_[i]) {
00647 value = fabs(lower_[i]);
00648 if (value>largestBound)
00649 largestBound=value;
00650 if (value<smallestBound)
00651 smallestBound=value;
00652 }
00653 if (upper_[i]<1.0e100&&upper_[i]) {
00654 value = fabs(upper_[i]);
00655 if (value>largestBound)
00656 largestBound=value;
00657 if (value<smallestBound)
00658 smallestBound=value;
00659 }
00660 }
00661 if (largestBound)
00662 handler_->message(CLP_RIMSTATISTICS3,messages_)
00663 <<smallestBound
00664 <<largestBound
00665 <<minimumGap
00666 <<CoinMessageEol;
00667 minimumGap=1.0e100;
00668 smallestBound=1.0e100;
00669 largestBound=0.0;
00670 for (i=0;i<numberColumns_;i++) {
00671 double value;
00672 value = fabs(cost_[i]);
00673 if (value>1.0e50) {
00674 numberBad++;
00675 if (firstBad<0)
00676 firstBad=i;
00677 } else if (value) {
00678 if (value>largestObj)
00679 largestObj=value;
00680 if (value<smallestObj)
00681 smallestObj=value;
00682 }
00683 value=upper_[i]-lower_[i];
00684 if (value<-primalTolerance()) {
00685 numberBad++;
00686 if (firstBad<0)
00687 firstBad=i;
00688 } else if (value<=fixTolerance) {
00689 if (value) {
00690
00691 upper_[i] = lower_[i];
00692 modifiedBounds++;
00693 }
00694 } else {
00695 if (value<minimumGap)
00696 minimumGap=value;
00697 }
00698 if (lower_[i]>-1.0e100&&lower_[i]) {
00699 value = fabs(lower_[i]);
00700 if (value>largestBound)
00701 largestBound=value;
00702 if (value<smallestBound)
00703 smallestBound=value;
00704 }
00705 if (upper_[i]<1.0e100&&upper_[i]) {
00706 value = fabs(upper_[i]);
00707 if (value>largestBound)
00708 largestBound=value;
00709 if (value<smallestBound)
00710 smallestBound=value;
00711 }
00712 }
00713 char rowcol[]={'R','C'};
00714 if (numberBad) {
00715 handler_->message(CLP_BAD_BOUNDS,messages_)
00716 <<numberBad
00717 <<rowcol[isColumn(firstBad)]<<sequenceWithin(firstBad)
00718 <<CoinMessageEol;
00719 problemStatus_=4;
00720 return false;
00721 }
00722 if (modifiedBounds)
00723 handler_->message(CLP_MODIFIEDBOUNDS,messages_)
00724 <<modifiedBounds
00725 <<CoinMessageEol;
00726 handler_->message(CLP_RIMSTATISTICS1,messages_)
00727 <<smallestObj
00728 <<largestObj
00729 <<CoinMessageEol; if (largestBound)
00730 handler_->message(CLP_RIMSTATISTICS2,messages_)
00731 <<smallestBound
00732 <<largestBound
00733 <<minimumGap
00734 <<CoinMessageEol;
00735 return true;
00736 }
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748 void
00749 ClpInterior::loadProblem ( const ClpMatrixBase& matrix,
00750 const double* collb, const double* colub,
00751 const double* obj,
00752 const double* rowlb, const double* rowub,
00753 const double * rowObjective)
00754 {
00755 ClpModel::loadProblem(matrix, collb, colub, obj, rowlb, rowub,
00756 rowObjective);
00757 }
00758 void
00759 ClpInterior::loadProblem ( const CoinPackedMatrix& matrix,
00760 const double* collb, const double* colub,
00761 const double* obj,
00762 const double* rowlb, const double* rowub,
00763 const double * rowObjective)
00764 {
00765 ClpModel::loadProblem(matrix, collb, colub, obj, rowlb, rowub,
00766 rowObjective);
00767 }
00768
00769
00770
00771 void
00772 ClpInterior::loadProblem ( const int numcols, const int numrows,
00773 const CoinBigIndex* start, const int* index,
00774 const double* value,
00775 const double* collb, const double* colub,
00776 const double* obj,
00777 const double* rowlb, const double* rowub,
00778 const double * rowObjective)
00779 {
00780 ClpModel::loadProblem(numcols, numrows, start, index, value,
00781 collb, colub, obj, rowlb, rowub,
00782 rowObjective);
00783 }
00784 void
00785 ClpInterior::loadProblem ( const int numcols, const int numrows,
00786 const CoinBigIndex* start, const int* index,
00787 const double* value,const int * length,
00788 const double* collb, const double* colub,
00789 const double* obj,
00790 const double* rowlb, const double* rowub,
00791 const double * rowObjective)
00792 {
00793 ClpModel::loadProblem(numcols, numrows, start, index, value, length,
00794 collb, colub, obj, rowlb, rowub,
00795 rowObjective);
00796 }
00797
00798 int
00799 ClpInterior::readMps(const char *filename,
00800 bool keepNames,
00801 bool ignoreErrors)
00802 {
00803 int status = ClpModel::readMps(filename,keepNames,ignoreErrors);
00804 return status;
00805 }
00806 #ifdef PDCO
00807 #include "ClpPdco.hpp"
00808
00809 int
00810 ClpInterior::pdco()
00811 {
00812 return ((ClpPdco *) this)->pdco();
00813 }
00814
00815 int
00816 ClpInterior::pdco( ClpPdcoBase * stuff, Options &options, Info &info, Outfo &outfo)
00817 {
00818 return ((ClpPdco *) this)->pdco(stuff,options,info,outfo);
00819 }
00820 #endif
00821 #include "ClpPredictorCorrector.hpp"
00822
00823 int
00824 ClpInterior::primalDual()
00825 {
00826 return ((ClpPredictorCorrector *) this)->solve();
00827 }
00828
00829 void
00830 ClpInterior::checkSolution()
00831 {
00832 int iRow,iColumn;
00833
00834 objectiveValue_ = 0.0;
00835
00836 sumPrimalInfeasibilities_=0.0;
00837 sumDualInfeasibilities_=0.0;
00838 double dualTolerance = dblParam_[ClpDualTolerance];
00839 double primalTolerance = dblParam_[ClpPrimalTolerance];
00840 worstComplementarity_=0.0;
00841 complementarityGap_=0.0;
00842
00843 for (iRow=0;iRow<numberRows_;iRow++) {
00844 double infeasibility=0.0;
00845 double distanceUp = min(rowUpper_[iRow]-
00846 rowActivity_[iRow],1.0e10);
00847 double distanceDown = min(rowActivity_[iRow] -
00848 rowLower_[iRow],1.0e10);
00849 if (distanceUp>primalTolerance) {
00850 double value = dual_[iRow];
00851
00852 if (value<-dualTolerance) {
00853 value = - value*distanceUp;
00854 if (value>worstComplementarity_)
00855 worstComplementarity_=value;
00856 complementarityGap_ += value;
00857 }
00858 }
00859 if (distanceDown>primalTolerance) {
00860 double value = dual_[iRow];
00861
00862 if (value>dualTolerance) {
00863 value = value*distanceDown;
00864 if (value>worstComplementarity_)
00865 worstComplementarity_=value;
00866 complementarityGap_ += value;
00867 }
00868 }
00869 if (rowActivity_[iRow]>rowUpper_[iRow]) {
00870 infeasibility=rowActivity_[iRow]-rowUpper_[iRow];
00871 } else if (rowActivity_[iRow]<rowLower_[iRow]) {
00872 infeasibility=rowLower_[iRow]-rowActivity_[iRow];
00873 }
00874 if (infeasibility>primalTolerance) {
00875 sumPrimalInfeasibilities_ += infeasibility-primalTolerance;
00876 }
00877 }
00878 for (iColumn=0;iColumn<numberColumns_;iColumn++) {
00879 double infeasibility=0.0;
00880 objectiveValue_ += cost_[iColumn]*columnActivity_[iColumn];
00881 double distanceUp = min(columnUpper_[iColumn]-
00882 columnActivity_[iColumn],1.0e10);
00883 double distanceDown = min(columnActivity_[iColumn] -
00884 columnLower_[iColumn],1.0e10);
00885 if (distanceUp>primalTolerance) {
00886 double value = reducedCost_[iColumn];
00887
00888 if (value<-dualTolerance) {
00889 value = - value*distanceUp;
00890 if (value>worstComplementarity_)
00891 worstComplementarity_=value;
00892 complementarityGap_ += value;
00893 }
00894 }
00895 if (distanceDown>primalTolerance) {
00896 double value = reducedCost_[iColumn];
00897
00898 if (value>dualTolerance) {
00899 value = value*distanceDown;
00900 if (value>worstComplementarity_)
00901 worstComplementarity_=value;
00902 complementarityGap_ += value;
00903 }
00904 }
00905 if (columnActivity_[iColumn]>columnUpper_[iColumn]) {
00906 infeasibility=columnActivity_[iColumn]-columnUpper_[iColumn];
00907 } else if (columnActivity_[iColumn]<columnLower_[iColumn]) {
00908 infeasibility=columnLower_[iColumn]-columnActivity_[iColumn];
00909 }
00910 if (infeasibility>primalTolerance) {
00911 sumPrimalInfeasibilities_ += infeasibility-primalTolerance;
00912 }
00913 }
00914 }