/home/coin/SVN-release/Bcp-1.2.1/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     void print() const;
00098 };
00099 
00100 #if 0
00101 //#############################################################################
00102 
00103 class BCP_var_set_change {
00104     // _storage tells how the var_set is stored.
00105     // -- If wrt parent then _deleted_num tells how many are deleted from the
00106     // parent, and their indices are listed on the first _deleted_num slots of
00107     // _del_change_pos. The rest of _del_change_pos shows the indices of
00108     // the vars that have some param changed. _change contains these changes
00109     // and finally _new_vars has the vars to be added, that is, their bcpind,
00110     // which might be the negative of the real bcpind in case a var has not
00111     // yet been sent to the TM.
00112     // -- If explicite list then _new_vars has the complete list.
00113 private:
00114     // disable default copy constructor and assignment operator
00115     BCP_var_set_change(const BCP_var_set_change&);
00116     BCP_var_set_change& operator=(const BCP_var_set_change&);
00117 public:
00118     BCP_storage_t           _storage;
00119     int                     _deleted_num;
00120     BCP_vec<int>            _del_change_pos;
00121     BCP_vec<BCP_obj_change> _change;
00122     BCP_vec<int>            _new_vars;
00123 public:
00124     BCP_var_set_change() :
00125         _storage(BCP_Storage_Explicit), _deleted_num(0),
00126         _del_change_pos(), _change(), _new_vars() {}
00127 #if 0
00128     BCP_var_set_change(BCP_vec<BCP_var*>::const_iterator firstvar,
00129                        BCP_vec<BCP_var*>::const_iterator lastvar);
00130     BCP_var_set_change(BCP_vec<BCP_var*>::const_iterator firstvar,
00131                        BCP_vec<BCP_var*>::const_iterator lastvar,
00132                        const BCP_vec<int>& added_index,
00133                        const BCP_vec<BCP_obj_change>& added_desc);
00134 #endif
00135     ~BCP_var_set_change() {}
00136     
00137     void swap(BCP_var_set_change& x);    // *INLINE ?*
00138 
00139     inline BCP_storage_t storage() const { return _storage; }
00140 
00141     inline int deleted_num() const { return _deleted_num; }
00142     inline int changed_num() const { return _change.size(); }
00143     inline int added_num() const { return _new_vars.size(); }
00144 
00145     int pack_size() const;
00146 
00147     void update(const BCP_var_set_change& vars_change);
00148 };
00149 
00150 //#############################################################################
00151 
00152 class BCP_cut_set_change {
00153     // _storage tells how the cut_set is stored.
00154     // -- If wrt parent then _deleted_num tells how many are deleted from the
00155     // parent, and their indices are listed on the first _deleted_num slots of
00156     // _del_change_pos. The rest of _del_change_pos shows the indices of
00157     // the cuts that have some param changed. _change contains these changes
00158     // and finally _new_cuts has the cuts to be added, that is, their bcpind,
00159     // which might be the negative of the real bcpind in case a var has not
00160     // yet been sent to the TM.
00161     // -- If explicite list then _new_cuts has the complete list.
00162 private:
00163     // disable default copy constructor and assignment operator
00164     BCP_cut_set_change(const BCP_cut_set_change&);
00165     BCP_cut_set_change& operator=(const BCP_cut_set_change&);
00166 public:
00167     BCP_storage_t           _storage;
00168     int                     _deleted_num;
00169     BCP_vec<int>            _del_change_pos;
00170     BCP_vec<BCP_obj_change> _change;
00171     BCP_vec<int>            _new_cuts;
00172 public:
00173     BCP_cut_set_change() :
00174         _storage(BCP_Storage_Explicit), _deleted_num(0),
00175         _del_change_pos(), _change(), _new_cuts() {}
00176 #if 0
00177     BCP_cut_set_change(BCP_vec<BCP_cut*>::const_iterator firstcut,
00178                        BCP_vec<BCP_cut*>::const_iterator lastcut);
00179     BCP_cut_set_change(BCP_vec<BCP_cut*>::const_iterator firstcut,
00180                        BCP_vec<BCP_cut*>::const_iterator lastcut,
00181                        const BCP_vec<int>& added_index,
00182                        const BCP_vec<BCP_obj_change>& added_desc);
00183 #endif
00184     ~BCP_cut_set_change() {}
00185 
00186     void swap(BCP_cut_set_change& x);    // *INLINE ?*
00187 
00188     inline BCP_storage_t storage() const { return _storage; }
00189 
00190     inline int deleted_num() const { return _deleted_num; }
00191     inline int changed_num() const { return _change.size(); }
00192     inline int added_num() const { return _new_cuts.size(); }
00193 
00194     int pack_size() const;
00195 
00196     void update(const BCP_cut_set_change& cuts_change);
00197 };
00198 
00199 //#############################################################################
00200 #endif
00201 
00202 #endif

Generated on Thu Jan 15 03:00:58 2009 for coin-Bcp by  doxygen 1.4.7