/home/coin/SVN-release/Bcp-1.2.0/Bcp/src/include/BCP_obj_change.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2000, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 #ifndef _BCP_OBJ_CHANGE_H
00004 #define _BCP_OBJ_CHANGE_H
00005 
00006 //#############################################################################
00007 
00008 #include "BCP_enum.hpp"
00009 #include "BCP_vector.hpp"
00010 
00011 //#############################################################################
00012 
00013 class BCP_var;
00014 class BCP_cut;
00015 
00016 class BCP_cut_set;
00017 class BCP_var_set;
00018 
00019 class BCP_buffer;
00020 
00021 //#############################################################################
00022 
00023 class BCP_obj_change {
00024 public:
00025     double lb;
00026     double ub;
00027     BCP_obj_status stat;
00028 public:
00029     BCP_obj_change(const double lower, const double upper,
00030                    const BCP_obj_status status) :
00031         lb(lower), ub(upper), stat(status) {}
00032     BCP_obj_change() : lb(0), ub(0), stat(BCP_ObjNoInfo) {}
00033     ~BCP_obj_change() {}
00034     // default copy constructor and assignment operator are fine
00035 
00036     static inline int pack_size() {
00037         return 2 * sizeof(double) + sizeof(BCP_obj_status);
00038     }
00039 };
00040 
00041 inline bool operator==(const BCP_obj_change& ch0, const BCP_obj_change& ch1)
00042 {
00043     return ch0.lb == ch1.lb && ch0.ub == ch1.ub && ch0.stat == ch1.stat;
00044 }
00045 
00046 inline bool operator!=(const BCP_obj_change& ch0, const BCP_obj_change& ch1)
00047 {
00048     return ch0.lb != ch1.lb || ch0.ub != ch1.ub || ch0.stat != ch1.stat;
00049 }
00050 
00051 //#############################################################################
00052 
00057 class BCP_obj_set_change {
00058     // _storage tells how the var_set is stored.
00059     // -- If wrt parent then _deleted_num tells how many are deleted from the
00060     // parent, and their indices are listed on the first _deleted_num slots of
00061     // _del_change_pos. The rest of _del_change_pos shows the indices of
00062     // the vars that have some param changed. _change contains these changes
00063     // and finally _new_vars has the vars to be added, that is, their bcpind,
00064     // which might be the negative of the real bcpind in case a var has not
00065     // yet been sent to the TM.
00066     // -- If explicite list then _new_vars has the complete list.
00067 private:
00068     // disable default copy constructor and assignment operator
00069     // BCP_obj_set_change(const BCP_obj_set_change&);
00070     // BCP_obj_set_change& operator=(const BCP_obj_set_change&);
00071 public:
00072     BCP_storage_t           _storage;
00073     int                     _deleted_num;
00074     BCP_vec<int>            _del_change_pos;
00075     BCP_vec<BCP_obj_change> _change;
00076     BCP_vec<int>            _new_objs;
00077 public:
00078     BCP_obj_set_change() :
00079         _storage(BCP_Storage_Explicit), _deleted_num(0),
00080         _del_change_pos(), _change(), _new_objs() {}
00081     // default copy constructor and assignment op are OK (though expensive...)
00082     ~BCP_obj_set_change() {}
00083     
00084     inline BCP_storage_t storage() const { return _storage; }
00085 
00086     inline int deleted_num() const { return _deleted_num; }
00087     inline int changed_num() const { return _change.size(); }
00088     inline int added_num() const { return _new_objs.size(); }
00089 
00090     void update(const BCP_obj_set_change& objs_change);
00091     void swap(BCP_obj_set_change& x);    // *INLINE ?*
00092 
00093     int pack_size() const;
00094     void pack(BCP_buffer& buf) const;
00095     void unpack(BCP_buffer& buf);
00096 };
00097 
00098 #if 0
00099 //#############################################################################
00100 
00101 class BCP_var_set_change {
00102     // _storage tells how the var_set is stored.
00103     // -- If wrt parent then _deleted_num tells how many are deleted from the
00104     // parent, and their indices are listed on the first _deleted_num slots of
00105     // _del_change_pos. The rest of _del_change_pos shows the indices of
00106     // the vars that have some param changed. _change contains these changes
00107     // and finally _new_vars has the vars to be added, that is, their bcpind,
00108     // which might be the negative of the real bcpind in case a var has not
00109     // yet been sent to the TM.
00110     // -- If explicite list then _new_vars has the complete list.
00111 private:
00112     // disable default copy constructor and assignment operator
00113     BCP_var_set_change(const BCP_var_set_change&);
00114     BCP_var_set_change& operator=(const BCP_var_set_change&);
00115 public:
00116     BCP_storage_t           _storage;
00117     int                     _deleted_num;
00118     BCP_vec<int>            _del_change_pos;
00119     BCP_vec<BCP_obj_change> _change;
00120     BCP_vec<int>            _new_vars;
00121 public:
00122     BCP_var_set_change() :
00123         _storage(BCP_Storage_Explicit), _deleted_num(0),
00124         _del_change_pos(), _change(), _new_vars() {}
00125 #if 0
00126     BCP_var_set_change(BCP_vec<BCP_var*>::const_iterator firstvar,
00127                        BCP_vec<BCP_var*>::const_iterator lastvar);
00128     BCP_var_set_change(BCP_vec<BCP_var*>::const_iterator firstvar,
00129                        BCP_vec<BCP_var*>::const_iterator lastvar,
00130                        const BCP_vec<int>& added_index,
00131                        const BCP_vec<BCP_obj_change>& added_desc);
00132 #endif
00133     ~BCP_var_set_change() {}
00134     
00135     void swap(BCP_var_set_change& x);    // *INLINE ?*
00136 
00137     inline BCP_storage_t storage() const { return _storage; }
00138 
00139     inline int deleted_num() const { return _deleted_num; }
00140     inline int changed_num() const { return _change.size(); }
00141     inline int added_num() const { return _new_vars.size(); }
00142 
00143     int pack_size() const;
00144 
00145     void update(const BCP_var_set_change& vars_change);
00146 };
00147 
00148 //#############################################################################
00149 
00150 class BCP_cut_set_change {
00151     // _storage tells how the cut_set is stored.
00152     // -- If wrt parent then _deleted_num tells how many are deleted from the
00153     // parent, and their indices are listed on the first _deleted_num slots of
00154     // _del_change_pos. The rest of _del_change_pos shows the indices of
00155     // the cuts that have some param changed. _change contains these changes
00156     // and finally _new_cuts has the cuts to be added, that is, their bcpind,
00157     // which might be the negative of the real bcpind in case a var has not
00158     // yet been sent to the TM.
00159     // -- If explicite list then _new_cuts has the complete list.
00160 private:
00161     // disable default copy constructor and assignment operator
00162     BCP_cut_set_change(const BCP_cut_set_change&);
00163     BCP_cut_set_change& operator=(const BCP_cut_set_change&);
00164 public:
00165     BCP_storage_t           _storage;
00166     int                     _deleted_num;
00167     BCP_vec<int>            _del_change_pos;
00168     BCP_vec<BCP_obj_change> _change;
00169     BCP_vec<int>            _new_cuts;
00170 public:
00171     BCP_cut_set_change() :
00172         _storage(BCP_Storage_Explicit), _deleted_num(0),
00173         _del_change_pos(), _change(), _new_cuts() {}
00174 #if 0
00175     BCP_cut_set_change(BCP_vec<BCP_cut*>::const_iterator firstcut,
00176                        BCP_vec<BCP_cut*>::const_iterator lastcut);
00177     BCP_cut_set_change(BCP_vec<BCP_cut*>::const_iterator firstcut,
00178                        BCP_vec<BCP_cut*>::const_iterator lastcut,
00179                        const BCP_vec<int>& added_index,
00180                        const BCP_vec<BCP_obj_change>& added_desc);
00181 #endif
00182     ~BCP_cut_set_change() {}
00183 
00184     void swap(BCP_cut_set_change& x);    // *INLINE ?*
00185 
00186     inline BCP_storage_t storage() const { return _storage; }
00187 
00188     inline int deleted_num() const { return _deleted_num; }
00189     inline int changed_num() const { return _change.size(); }
00190     inline int added_num() const { return _new_cuts.size(); }
00191 
00192     int pack_size() const;
00193 
00194     void update(const BCP_cut_set_change& cuts_change);
00195 };
00196 
00197 //#############################################################################
00198 #endif
00199 
00200 #endif

Generated on Tue Sep 23 03:01:18 2008 for coin-Bcp by  doxygen 1.4.7