00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00028 #ifndef _BOUND_DELTA_H_
00029 #define _BOUND_DELTA_H_
00030
00031 #include <api_delta.h>
00032
00033 namespace coco {
00034
00036
00041 class bound_undelta : public undelta_base
00042 {
00043 public:
00046 std::vector<unsigned int> indices;
00047
00049 std::vector<interval> old_f_bounds;
00050
00051 double old_gain;
00052 double old_log_vol;
00053 public:
00056 bound_undelta(const std::vector<unsigned int>& __i,
00057 const std::vector<interval>& __b,
00058 double _og, double _olv) : undelta_base(), indices(__i),
00059 old_f_bounds(__b), old_gain(_og),
00060 old_log_vol(_olv) {}
00061
00064 bound_undelta(const std::vector<unsigned int>& __i, double _og,
00065 double _olv) : undelta_base(), indices(__i),
00066 old_f_bounds(), old_gain(_og),
00067 old_log_vol(_olv) {}
00068
00070 bound_undelta(const bound_undelta& __d) : undelta_base(__d),
00071 indices(__d.indices),
00072 old_f_bounds(__d.old_f_bounds),
00073 old_gain(__d.old_gain),
00074 old_log_vol(__d.old_log_vol)
00075 {
00076 #if DEBUG_DELTA
00077 std::cerr << "Called bound_undelta copy constructor" << std::endl;
00078 #endif
00079 }
00080
00082 bound_undelta* new_copy() const { return new bound_undelta(*this); }
00084 void destroy_copy(undelta_base* __d) const { delete (bound_undelta*)__d; }
00085
00087 bool unapply(work_node& _x, const delta_id& _did) const;
00088
00089 friend class bound_delta;
00090 };
00091
00093
00098 class bound_delta : public delta_base
00099 {
00100 public:
00103 std::vector<unsigned int> indices;
00105 std::vector<interval> new_f_bounds;
00106 public:
00109 bound_delta(const std::vector<unsigned int>& __i,
00110 const std::vector<interval>& __b)
00111 : delta_base("change bounds"), indices(__i),
00112 new_f_bounds(__b) {}
00113
00116 bound_delta(unsigned int __i, interval __b)
00117 : delta_base("change bounds"), indices(1,__i),
00118 new_f_bounds(1,__b) {}
00119
00121 bound_delta(const bound_delta& __d) : delta_base(__d), indices(__d.indices),
00122 new_f_bounds(__d.new_f_bounds)
00123 {
00124 #if DEBUG_DELTA
00125 std::cerr << "Called bound_delta copy constructor" << std::endl;
00126 #endif
00127 }
00128
00130 bound_delta* new_copy() const { return new bound_delta(*this); }
00132 void destroy_copy(delta_base* __d) const { delete (bound_delta*)__d; }
00133
00136 bool apply(work_node& _x, undelta_base*& _u, const delta_id& _did) const;
00137
00139 bool operator==(const delta_base& _c) const
00140 { return _c.get_action() == get_action() &&
00141 this->operator==(*(bound_delta*)&_c); }
00142 bool operator!=(const delta_base& _c) const
00143 { return _c.get_action() != get_action() ||
00144 this->operator!=(*(bound_delta*)&_c); }
00145
00147 bool operator==(const bound_delta& _c) const
00148 { return this == &_c ||
00149 (indices == _c.indices && new_f_bounds == _c.new_f_bounds); }
00150 bool operator!=(const bound_delta& _c) const
00151 { return this != &_c &&
00152 (indices != _c.indices || new_f_bounds != _c.new_f_bounds); }
00153 };
00154
00155 }
00156
00157 #endif