2 // Various datastructures and functions used by the global optimizer
17 const int FALSE=(1==0); // boolean FALSE
20 const int TRUE=(1==1); // boolean TRUE
23 typedef const class Trial CTrial;
24 typedef CTrial& RCTrial;
25 typedef CTrial* PCTrial;
34 Trial(RCTrial); // Copy constructor
35 RCTrial operator=(RCTrial) ; // assignment operator
36 friend ostream & operator << (ostream &, RCTrial) ;
39 class TrialGT : public unary_function<Trial, bool>
40 // Predicate for Trial (needed for remove_if)
43 explicit TrialGT(double val) : _val(val) {}
44 bool operator()(Trial& foo) {
45 return foo.objval > _val;
51 typedef class VBox& RVBox;
52 typedef const class VBox CVBox;
53 typedef CVBox* PCVBox;
54 typedef CVBox& RCVBox;
60 VBox(); // Construct a box
62 VBox(RCVBox); // Copy constructor
63 RCVBox operator=(RCVBox); // assignment operator
65 int GetDim(); // Returns the dimension of the box
66 double Width(int) ; // Returns the width of the i-th interval
67 void Midpoint(RCRVector); // Returns the midpoint
69 friend ostream & operator << (ostream &, const VBox &);
72 typedef class TBox& RTBox;
73 typedef const class TBox CTBox;
74 typedef CTBox* PCTBox;
75 typedef CTBox& RCTBox;
77 class TBox: public VBox {
79 double minf; // Smallest function value found so far
80 list<Trial> TList; // List of trials
82 TBox(); // Construct a box
84 TBox(RCTBox); // Copy constructor
86 RCTBox operator=(RCTBox); // assignment operator
88 double GetMin(); // Returns 'minf'
89 bool EmptyBox(); // Returns TRUE if Box contains no trials
90 void AddTrial(RCTrial); // Add a trial to the (back of) box
91 void RemoveTrial(Trial &); // Remove a trial from the (back of) box
92 void GetLastTrial(Trial &); // Return a trial from the back of the box
94 list<Trial>::const_iterator FirstTrial();
95 list<Trial>::const_iterator LastTrial();
97 void GetTrial(list<Trial>::const_iterator, Trial&);
99 bool CloseToMin(RVector&, double*, double);
101 unsigned int NStationary(); // Returns the number of stationary points
103 void split(RTBox, RTBox); // Split a box
106 bool InsideBox(RCRVector);
107 int OutsideBox(RCRVector, RCTBox);
108 double ShortestSide(int*); // Returns the shortest side
109 double LongestSide(int*); // Returns the longest side
110 double ClosestSide(RCRVector x);
111 double FarthestSide(RCRVector x);
112 bool Intersection(RCRVector, RCRVector, RCRVector);
113 double LowerBound(double);
115 bool operator<(const TBox & x) const {return (minf>x.minf);}
116 friend ostream & operator << (ostream &, const TBox &);