00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "CouenneBTPerfIndicator.hpp"
00012 #include "CouenneProblem.hpp"
00013 #include "IpSmartPtr.hpp"
00014
00015
00016 using namespace Couenne;
00017
00019 CouenneBTPerfIndicator::CouenneBTPerfIndicator (CouenneProblem *p, const std::string &name):
00020
00021 name_ (name),
00022 nFixed_ (0.),
00023 boundRatio_ (0.),
00024 shrunkInf_ (0.),
00025 shrunkDoubleInf_ (0.),
00026 nProvedInfeas_ (0.),
00027 weightSum_ (0.),
00028 oldLB_ (NULL),
00029 oldUB_ (NULL),
00030 totalTime_ (0.),
00031 nRuns_ (0),
00032 problem_ (p),
00033 stats_ ((p != NULL) &&
00034 (GetRawPtr (p -> Jnlst ()) != NULL) &&
00035 (p -> Jnlst () -> ProduceOutput (Ipopt::J_ERROR, J_COUENNE))) {}
00036
00037
00039 CouenneBTPerfIndicator::~CouenneBTPerfIndicator () {
00040
00041 if (totalTime_ > 0. &&
00042 nRuns_ &&
00043 problem_)
00044
00045 if (stats_)
00046 problem_->Jnlst()->Printf(Ipopt::J_ERROR, J_COUENNE, "Performance of %30s:\t %10gs, %8d runs. fix: %10g shrnk: %10g ubd: %10g 2ubd: %10g infeas: %10g\n",
00047 name_.c_str (),
00048 totalTime_,
00049 nRuns_,
00050 nFixed_, boundRatio_, shrunkInf_, shrunkDoubleInf_, nProvedInfeas_);
00051
00052
00053
00054 if (oldLB_) delete [] oldLB_;
00055 if (oldUB_) delete [] oldUB_;
00056 }
00057
00058
00060 CouenneBTPerfIndicator::CouenneBTPerfIndicator (const CouenneBTPerfIndicator &rhs):
00061
00062 name_ (rhs.name_),
00063 nFixed_ (rhs.nFixed_),
00064 boundRatio_ (rhs.boundRatio_),
00065 shrunkInf_ (rhs.shrunkInf_),
00066 shrunkDoubleInf_ (rhs.shrunkDoubleInf_),
00067 nProvedInfeas_ (rhs.nProvedInfeas_),
00068 weightSum_ (rhs.weightSum_),
00069 oldLB_ (!rhs.problem_ || rhs.oldLB_ ? NULL : CoinCopyOfArray (rhs.oldLB_, rhs.problem_ -> nVars ())),
00070 oldUB_ (!rhs.problem_ || rhs.oldUB_ ? NULL : CoinCopyOfArray (rhs.oldUB_, rhs.problem_ -> nVars ())),
00071 totalTime_ (rhs.totalTime_),
00072 nRuns_ (rhs.nRuns_),
00073 problem_ (rhs.problem_),
00074 stats_ (rhs.stats_) {}
00075
00076
00078 CouenneBTPerfIndicator &CouenneBTPerfIndicator::operator= (const CouenneBTPerfIndicator &rhs) {
00079
00080 name_ = rhs.name_;
00081 nFixed_ = rhs.nFixed_;
00082 boundRatio_ = rhs.boundRatio_;
00083 shrunkInf_ = rhs.shrunkInf_;
00084 shrunkDoubleInf_ = rhs.shrunkDoubleInf_;
00085 nProvedInfeas_ = rhs.nProvedInfeas_;
00086 weightSum_ = rhs.weightSum_;
00087 oldLB_ = !rhs.problem_ || !rhs.oldLB_ ? NULL : CoinCopyOfArray (rhs.oldLB_, rhs.problem_ -> nVars ());
00088 oldUB_ = !rhs.problem_ || !rhs.oldUB_ ? NULL : CoinCopyOfArray (rhs.oldUB_, rhs.problem_ -> nVars ());
00089 totalTime_ = rhs.totalTime_;
00090 nRuns_ = rhs.nRuns_;
00091 problem_ = rhs.problem_;
00092 stats_ = rhs.stats_;
00093
00094 return *this;
00095 }
00096
00097
00099 void CouenneBTPerfIndicator::setOldBounds (const CouNumber *lb, const CouNumber *ub) const {
00100
00101 if (problem_) {
00102
00103 oldLB_ = CoinCopyOfArray (lb, problem_ -> nVars ());
00104 oldUB_ = CoinCopyOfArray (ub, problem_ -> nVars ());
00105
00106 } else {
00107
00108 printf ("CouenneBTPerfIndicator::setOldBounds(): no problem information, exiting\n");
00109 exit (-1);
00110 }
00111 }
00112
00113
00115 void CouenneBTPerfIndicator::addToTimer (double time) const
00116 {totalTime_ += time;}