#include <ClpSimplex.hpp>
Public Member Functions | |
Constructors and destructor and copy | |
ClpSimplexProgress () | |
Default constructor. | |
ClpSimplexProgress (ClpSimplex *model) | |
Constructor from model. | |
ClpSimplexProgress (const ClpSimplexProgress &) | |
Copy constructor. | |
ClpSimplexProgress & | operator= (const ClpSimplexProgress &rhs) |
Assignment operator. This copies the data. | |
~ClpSimplexProgress () | |
Destructor. | |
Check progress | |
int | looping () |
void | startCheck () |
Start check at beginning of whileIterating. | |
int | cycle (int in, int out, int wayIn, int wayOut) |
Returns cycle length in whileIterating. | |
double | lastObjective (int back=1) const |
Returns previous objective (if -1) - current if (0). | |
void | modifyObjective (double value) |
Modify objective e.g. if dual infeasible in dual. | |
int | lastIterationNumber (int back=1) const |
Returns previous iteration number (if -1) - current if (0). | |
void | newOddState () |
Odd state. | |
void | endOddState () |
void | clearOddState () |
int | oddState () const |
int | badTimes () const |
number of bad times | |
void | clearBadTimes () |
Public Attributes | |
Data | |
double | objective_ [CLP_PROGRESS] |
Objective values. | |
double | infeasibility_ [CLP_PROGRESS] |
Sum of infeasibilities for algorithm. | |
double | obj_ [CLP_CYCLE] |
For cycle checking. | |
int | in_ [CLP_CYCLE] |
int | out_ [CLP_CYCLE] |
char | way_ [CLP_CYCLE] |
ClpSimplex * | model_ |
Pointer back to model so we can get information. | |
int | numberInfeasibilities_ [CLP_PROGRESS] |
Number of infeasibilities. | |
int | iterationNumber_ [CLP_PROGRESS] |
Iteration number at which occurred. | |
int | numberTimes_ |
Number of times checked (so won't stop too early). | |
int | numberBadTimes_ |
Number of times it looked like loop. | |
int | oddState_ |
If things are in an odd state. |
Definition at line 968 of file ClpSimplex.hpp.
|
Returns -1 if okay, -n+1 (n number of times bad) if bad but action taken, >=0 if give up and use as problem status Definition at line 4731 of file ClpSimplex.cpp. References ClpSimplex::algorithm(), ClpSimplex::currentDualTolerance(), ClpSimplex::currentPrimalTolerance(), ClpSimplex::dualBound(), ClpSimplex::forceFactorization(), infeasibility_, ClpSimplex::infeasibilityCost(), iterationNumber_, CoinMessageHandler::logLevel(), CoinMessageHandler::message(), ClpModel::messageHandler(), ClpModel::messages(), model_, ClpSimplex::nonLinearCost(), numberBadTimes_, ClpSimplex::numberDualInfeasibilities(), ClpNonLinearCost::numberInfeasibilities(), numberInfeasibilities_, ClpModel::numberIterations(), ClpSimplex::numberPrimalInfeasibilities(), numberTimes_, objective_, ClpSimplex::progressFlag(), ClpSimplex::rawObjectiveValue(), ClpSimplex::setCurrentDualTolerance(), ClpSimplex::setCurrentPrimalTolerance(), ClpSimplex::setDualBound(), ClpSimplex::setInfeasibilityCost(), ClpSimplex::sumDualInfeasibilities(), and ClpSimplex::sumPrimalInfeasibilities(). Referenced by ClpSimplexDual::statusOfProblemInDual(), ClpSimplexPrimalQuadratic::statusOfProblemInPrimal(), and ClpSimplexPrimal::statusOfProblemInPrimal().
04732 { 04733 if (!model_) 04734 return -1; 04735 double objective = model_->rawObjectiveValue(); 04736 double infeasibility; 04737 int numberInfeasibilities; 04738 int iterationNumber = model_->numberIterations(); 04739 if (model_->algorithm()<0) { 04740 // dual 04741 infeasibility = model_->sumPrimalInfeasibilities(); 04742 numberInfeasibilities = model_->numberPrimalInfeasibilities(); 04743 } else { 04744 //primal 04745 infeasibility = model_->sumDualInfeasibilities(); 04746 numberInfeasibilities = model_->numberDualInfeasibilities(); 04747 } 04748 int i; 04749 int numberMatched=0; 04750 int matched=0; 04751 int nsame=0; 04752 for (i=0;i<CLP_PROGRESS;i++) { 04753 bool matchedOnObjective = equalDouble(objective,objective_[i]); 04754 bool matchedOnInfeasibility = equalDouble(infeasibility,infeasibility_[i]); 04755 bool matchedOnInfeasibilities = 04756 (numberInfeasibilities==numberInfeasibilities_[i]); 04757 04758 if (matchedOnObjective&&matchedOnInfeasibility&&matchedOnInfeasibilities) { 04759 matched |= (1<<i); 04760 // Check not same iteration 04761 if (iterationNumber!=iterationNumber_[i]) { 04762 numberMatched++; 04763 // here mainly to get over compiler bug? 04764 if (model_->messageHandler()->logLevel()>10) 04765 printf("%d %d %d %d %d loop check\n",i,numberMatched, 04766 matchedOnObjective, matchedOnInfeasibility, 04767 matchedOnInfeasibilities); 04768 } else { 04769 // stuck but code should notice 04770 nsame++; 04771 } 04772 } 04773 if (i) { 04774 objective_[i-1] = objective_[i]; 04775 infeasibility_[i-1] = infeasibility_[i]; 04776 numberInfeasibilities_[i-1]=numberInfeasibilities_[i]; 04777 iterationNumber_[i-1]=iterationNumber_[i]; 04778 } 04779 } 04780 objective_[CLP_PROGRESS-1] = objective; 04781 infeasibility_[CLP_PROGRESS-1] = infeasibility; 04782 numberInfeasibilities_[CLP_PROGRESS-1]=numberInfeasibilities; 04783 iterationNumber_[CLP_PROGRESS-1]=iterationNumber; 04784 if (nsame==CLP_PROGRESS) 04785 numberMatched=CLP_PROGRESS; // really stuck 04786 if (model_->progressFlag()) 04787 numberMatched=0; 04788 numberTimes_++; 04789 if (numberTimes_<10) 04790 numberMatched=0; 04791 // skip if just last time as may be checking something 04792 if (matched==(1<<(CLP_PROGRESS-1))) 04793 numberMatched=0; 04794 if (numberMatched) { 04795 model_->messageHandler()->message(CLP_POSSIBLELOOP,model_->messages()) 04796 <<numberMatched 04797 <<matched 04798 <<numberTimes_ 04799 <<CoinMessageEol; 04800 numberBadTimes_++; 04801 if (numberBadTimes_<10) { 04802 // make factorize every iteration 04803 model_->forceFactorization(1); 04804 if (model_->algorithm()<0) { 04805 // dual - change tolerance 04806 model_->setCurrentDualTolerance(model_->currentDualTolerance()*1.05); 04807 // if infeasible increase dual bound 04808 if (model_->dualBound()<1.0e17) { 04809 model_->setDualBound(model_->dualBound()*1.1); 04810 } 04811 } else { 04812 // primal - change tolerance 04813 if (numberBadTimes_>3) 04814 model_->setCurrentPrimalTolerance(model_->currentPrimalTolerance()*1.05); 04815 // if infeasible increase infeasibility cost 04816 if (model_->nonLinearCost()->numberInfeasibilities()&& 04817 model_->infeasibilityCost()<1.0e17) { 04818 model_->setInfeasibilityCost(model_->infeasibilityCost()*1.1); 04819 } 04820 } 04821 return -2; 04822 } else { 04823 // look at solution and maybe declare victory 04824 if (infeasibility<1.0e-4) { 04825 return 0; 04826 } else { 04827 model_->messageHandler()->message(CLP_LOOP,model_->messages()) 04828 <<CoinMessageEol; 04829 #ifndef NDEBUG 04830 abort(); 04831 #endif 04832 return 3; 04833 } 04834 } 04835 } 04836 return -1; 04837 } |