BTPerfIndicatorConstr.cpp
Go to the documentation of this file.
1 /* $Id: BTPerfIndicatorConstr.cpp 1146 2015-05-04 13:57:47Z stefan $
2  *
3  * Name: CouenneBTPerfIndicatorConstr.cpp
4  * Author: Pietro Belotti
5  * Purpose: Measures performance of BT in terms of shrunken bounds -- constructors
6  *
7  * (C) Pietro Belotti, 2011.
8  * This file is licensed under the Eclipse Public License (EPL)
9  */
10 
12 #include "CouenneProblem.hpp"
13 #include "IpSmartPtr.hpp"
14 
15 
16 using namespace Couenne;
17 
20 
21  name_ (name),
22  nFixed_ (0.),
23  boundRatio_ (0.),
24  shrunkInf_ (0.),
25  shrunkDoubleInf_ (0.),
26  nProvedInfeas_ (0.),
27  weightSum_ (0.),
28  oldLB_ (NULL),
29  oldUB_ (NULL),
30  totalTime_ (0.),
31  nRuns_ (0),
32  problem_ (p),
33  stats_ ((p != NULL) &&
34  (GetRawPtr (p -> Jnlst ()) != NULL) &&
35  (p -> Jnlst () -> ProduceOutput (Ipopt::J_ERROR, J_COUENNE))) {}
36 
37 
40 
41  if (totalTime_ > 0. &&
42  nRuns_ &&
43  problem_)
44 
45  if (stats_)
46  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",
47  name_.c_str (),
48  totalTime_,
49  nRuns_,
51 
52  //weightSum_ * nFixed_, weightSum_ * boundRatio_, weightSum_ * shrunkInf_, weightSum_ * shrunkDoubleInf_, weightSum_ * nProvedInfeas_);
53 
54  if (oldLB_) delete [] oldLB_;
55  if (oldUB_) delete [] oldUB_;
56 }
57 
58 
61 
62  name_ (rhs.name_),
63  nFixed_ (rhs.nFixed_),
64  boundRatio_ (rhs.boundRatio_),
65  shrunkInf_ (rhs.shrunkInf_),
66  shrunkDoubleInf_ (rhs.shrunkDoubleInf_),
67  nProvedInfeas_ (rhs.nProvedInfeas_),
68  weightSum_ (rhs.weightSum_),
69  oldLB_ (!rhs.problem_ || rhs.oldLB_ ? NULL : CoinCopyOfArray (rhs.oldLB_, rhs.problem_ -> nVars ())),
70  oldUB_ (!rhs.problem_ || rhs.oldUB_ ? NULL : CoinCopyOfArray (rhs.oldUB_, rhs.problem_ -> nVars ())),
71  totalTime_ (rhs.totalTime_),
72  nRuns_ (rhs.nRuns_),
73  problem_ (rhs.problem_),
74  stats_ (rhs.stats_) {}
75 
76 
79 
80  name_ = rhs.name_;
81  nFixed_ = rhs.nFixed_;
83  shrunkInf_ = rhs.shrunkInf_;
86  weightSum_ = rhs.weightSum_;
87  oldLB_ = !rhs.problem_ || !rhs.oldLB_ ? NULL : CoinCopyOfArray (rhs.oldLB_, rhs.problem_ -> nVars ());
88  oldUB_ = !rhs.problem_ || !rhs.oldUB_ ? NULL : CoinCopyOfArray (rhs.oldUB_, rhs.problem_ -> nVars ());
89  totalTime_ = rhs.totalTime_;
90  nRuns_ = rhs.nRuns_;
91  problem_ = rhs.problem_;
92  stats_ = rhs.stats_;
93 
94  return *this;
95 }
96 
97 
99 void CouenneBTPerfIndicator::setOldBounds (const CouNumber *lb, const CouNumber *ub) const {
100 
101  if (problem_) {
102 
103  oldLB_ = CoinCopyOfArray (lb, problem_ -> nVars ());
104  oldUB_ = CoinCopyOfArray (ub, problem_ -> nVars ());
105 
106  } else {
107 
108  printf ("CouenneBTPerfIndicator::setOldBounds(): no problem information, exiting\n");
109  exit (-1);
110  }
111 }
112 
113 
115 void CouenneBTPerfIndicator::addToTimer (double time) const
116 {totalTime_ += time;}
void addToTimer(double time) const
add to timer
double nFixed_
Whose performance is this?
double * oldLB_
total weight (used to give an average indicator at the end of Couenne)
double boundRatio_
number of fixed variables
double shrunkInf_
average bound width shrinkage
CouenneBTPerfIndicator & operator=(const CouenneBTPerfIndicator &rhs)
int nRuns_
CPU time spent on this.
ConstJnlstPtr Jnlst() const
Provide Journalist.
CouenneBTPerfIndicator(CouenneProblem *p, const std::string &name)
Should stats be printed at the end? Copied from problem_ -> Jnlst () -> ProduceOutput (ERROR...
Class for MINLP problems with symbolic information.
double nProvedInfeas_
average # bounds that went from doubly infinite to infinite
U * GetRawPtr(const OSSmartPtr< U > &smart_ptr)
Definition: OSSmartPtr.hpp:452
double * oldUB_
old lower bounds (initial, i.e. before BT)
double shrunkDoubleInf_
average # bounds that went from infinite to finite (counts twice if [-inf,inf] to [a...
double CouNumber
main number type in Couenne
void setOldBounds(const CouNumber *lb, const CouNumber *ub) const
const Ipopt::EJournalCategory J_COUENNE(Ipopt::J_USER8)
CouenneProblem * problem_
number of runs
double weightSum_
average # proofs of infeasibility