/home/coin/SVN-release/CoinAll-1.1.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 //#############################################################################
00020 
00021 class BCP_obj_change {
00022 public:
00023    double lb;
00024    double ub;
00025    BCP_obj_status stat;
00026 public:
00027    BCP_obj_change(const double lower, const double upper,
00028                   const BCP_obj_status status) :
00029       lb(lower), ub(upper), stat(status) {}
00030    BCP_obj_change() : lb(0), ub(0), stat(BCP_ObjNoInfo) {}
00031    ~BCP_obj_change() {}
00032    // default copy constructor and assignment operator are fine
00033 
00034    static inline int pack_size() {
00035       return 2 * sizeof(double) + sizeof(BCP_obj_status);
00036    }
00037 };
00038 
00039 inline bool operator==(const BCP_obj_change& ch0, const BCP_obj_change& ch1)
00040 {
00041    return ch0.lb == ch1.lb && ch0.ub == ch1.ub && ch0.stat == ch1.stat;
00042 }
00043 
00044 inline bool operator!=(const BCP_obj_change& ch0, const BCP_obj_change& ch1)
00045 {
00046    return ch0.lb != ch1.lb || ch0.ub != ch1.ub || ch0.stat != ch1.stat;
00047 }
00048 
00049 //#############################################################################
00050 //#############################################################################
00051 
00052 class BCP_var_set_change {
00053    // _storage tells how the var_set is stored.
00054    // -- If wrt parent then _deleted_num tells how many are deleted from the
00055    // parent, and their indices are listed on the first _deleted_num slots of
00056    // _del_change_pos. The rest of _del_change_pos shows the indices of
00057    // the vars that have some param changed. _change contains these changes
00058    // and finally _new_vars has the vars to be added.
00059    // -- If explicite list then _new_vars has the complete list.
00060 private:
00061    // disable default copy constructor and assignment operator
00062    BCP_var_set_change(const BCP_var_set_change&);
00063    BCP_var_set_change& operator=(const BCP_var_set_change&);
00064 public:
00065    BCP_storage_t           _storage;
00066    int                     _deleted_num;
00067    BCP_vec<int>            _del_change_pos;
00068    BCP_vec<BCP_obj_change> _change;
00069    BCP_vec<BCP_var*>       _new_vars;
00070 public:
00071    BCP_var_set_change() :
00072       _storage(BCP_Storage_Explicit), _deleted_num(0),
00073       _del_change_pos(), _change(), _new_vars() {}
00074    BCP_var_set_change(BCP_vec<BCP_var*>::const_iterator firstvar,
00075                       BCP_vec<BCP_var*>::const_iterator lastvar);
00076    BCP_var_set_change(BCP_vec<BCP_var*>::const_iterator firstvar,
00077                       BCP_vec<BCP_var*>::const_iterator lastvar,
00078                       const BCP_vec<int>& added_index,
00079                       const BCP_vec<BCP_obj_change>& added_desc);
00080    ~BCP_var_set_change() {}
00081 
00082    void swap(BCP_var_set_change& x);    // *INLINE ?*
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_vars.size(); }
00089 
00090    int pack_size() const;
00091 
00092    void update(const BCP_var_set_change& vars_change);
00093 };
00094 
00095 //#############################################################################
00096 
00097 class BCP_cut_set_change {
00098    // _storage tells how the cut_set is stored.
00099    // -- If wrt parent then _deleted_num tells how many are deleted from the
00100    // parent, and their indices are listed on the first _deleted_num slots of
00101    // _del_change_pos. The rest of _del_change_pos shows the indices of
00102    // the cuts that have some param changed. _change contains these changes
00103    // and finally _new_cuts has the cuts to be added.
00104    // -- If explicite list then _new_cuts has the complete list.
00105 private:
00106    // disable default copy constructor and assignment operator
00107    BCP_cut_set_change(const BCP_cut_set_change&);
00108    BCP_cut_set_change& operator=(const BCP_cut_set_change&);
00109 public:
00110    BCP_storage_t        _storage;
00111    int                     _deleted_num;
00112    BCP_vec<int>            _del_change_pos;
00113    BCP_vec<BCP_obj_change> _change;
00114    BCP_vec<BCP_cut*>       _new_cuts;
00115 public:
00116    BCP_cut_set_change() :
00117       _storage(BCP_Storage_Explicit), _deleted_num(0),
00118       _del_change_pos(), _change(), _new_cuts() {}
00119    BCP_cut_set_change(BCP_vec<BCP_cut*>::const_iterator firstcut,
00120                       BCP_vec<BCP_cut*>::const_iterator lastcut);
00121    BCP_cut_set_change(BCP_vec<BCP_cut*>::const_iterator firstcut,
00122                       BCP_vec<BCP_cut*>::const_iterator lastcut,
00123                       const BCP_vec<int>& added_index,
00124                       const BCP_vec<BCP_obj_change>& added_desc);
00125    ~BCP_cut_set_change() {}
00126 
00127    void swap(BCP_cut_set_change& x);    // *INLINE ?*
00128 
00129    inline BCP_storage_t storage() const { return _storage; }
00130 
00131    inline int deleted_num() const { return _deleted_num; }
00132    inline int changed_num() const { return _change.size(); }
00133    inline int added_num() const { return _new_cuts.size(); }
00134    //    inline void reserve(int cuts_size) { _new_cuts.reserve(cuts_size); }
00135 
00136    int pack_size() const;
00137 
00138    void update(const BCP_cut_set_change& cuts_change);
00139 };
00140 
00141 //#############################################################################
00142 
00143 #endif

Generated on Sun Nov 14 14:06:29 2010 for Coin-All by  doxygen 1.4.7