/home/coin/SVN-release/Bcp-1.2.1/Bcp/src/include/BCP_cut.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_CUT_H
00004 #define _BCP_CUT_H
00005 
00006 // This file is fully docified.
00007 
00008 //#############################################################################
00009 
00010 #include "CoinSmartPtr.hpp"
00011 #include "BCP_math.hpp"
00012 #include "BCP_error.hpp"
00013 #include "BCP_enum.hpp"
00014 #include "BCP_vector.hpp"
00015 #include "BCP_obj_change.hpp"
00016 
00017 //#############################################################################
00018 
00019 // Generic cut definition
00020 
00029 class BCP_cut : public Coin::ReferencedObject {
00030 private:
00034     BCP_cut();
00036     BCP_cut(const BCP_cut&);
00038     BCP_cut& operator=(const BCP_cut&);
00041 private:
00046     int  _bcpind;
00048     BCP_obj_status _status;
00050     int            _eff_cnt;
00053 protected:
00056     double         _lb;
00058     double         _ub;
00061 public:
00068     BCP_cut(const double lb, const double ub) :
00069        _bcpind(0), _status(BCP_ObjNoInfo), _eff_cnt(0), _lb(lb), _ub(ub) {}
00072     virtual ~BCP_cut() {}
00078     virtual BCP_object_t obj_type() const = 0;
00080     inline int effective_count() const   { return _eff_cnt; }
00082     inline double lb() const             { return _lb; }
00084     inline double ub() const             { return _ub; }
00086     inline int bcpind() const  { return _bcpind; }
00087 
00088     /* *@name Query methods about the status of the variable */
00089     /* @{*/
00091       inline BCP_obj_status status() const { return _status; }
00095       inline bool dont_send_to_pool() const {
00096          return _status & BCP_ObjDoNotSendToPool ? true : false;
00097       }
00100       inline bool is_non_removable() const {
00101          return (_status & BCP_ObjNotRemovable) ? true : false;
00102       }
00106       inline bool is_to_be_removed() const {
00107          return (_status & BCP_ObjToBeRemoved) != 0;
00108       }
00109     /* @}*/
00115     inline void set_effective_count(const int cnt) { _eff_cnt = cnt; }
00118     inline int increase_effective_count() {
00119        _eff_cnt = _eff_cnt <= 0 ? 1 : _eff_cnt + 1;
00120        return _eff_cnt;
00121     }
00124     inline int decrease_effective_count() {
00125        _eff_cnt = _eff_cnt >= 0 ? -1 : _eff_cnt - 1;
00126        return _eff_cnt;
00127     }
00129     inline void set_lb(const double lb) { _lb = lb; }
00131     inline void set_ub(const double ub) { _ub = ub; }
00134     inline void change_lb_ub_st(const BCP_obj_change& change) {
00135        _lb = change.lb;
00136        _ub = change.ub;
00137        _status = change.stat;
00138        if (_lb < -BCP_DBL_MAX/10 && _ub > BCP_DBL_MAX/10)
00139          _status = static_cast<BCP_obj_status>(_status | BCP_ObjInactive);
00140     }
00142     inline void change_bounds(const double lb, const double ub) {
00143        _lb = lb;
00144        _ub = ub;
00145        if (lb < BCP_DBL_MAX/10 && ub > BCP_DBL_MAX/10)
00146          _status = static_cast<BCP_obj_status>(_status | BCP_ObjInactive);
00147     }
00149     inline void set_bcpind(const int bcpind)  { _bcpind = bcpind; }
00151     inline void set_bcpind_flip()  { _bcpind = -_bcpind; }
00152 
00153     /* *@name Status modifying methods */
00154     /* @{*/
00156       inline void set_status(const BCP_obj_status stat) { _status = stat; }
00159       inline void dont_send_to_pool(bool flag) {
00160          _status = static_cast<BCP_obj_status>(flag ?
00161                                             _status | BCP_ObjDoNotSendToPool :
00162                                             _status & ~BCP_ObjDoNotSendToPool);
00163       }
00167       inline void make_active() {
00168          _status = static_cast<BCP_obj_status>(_status & ~BCP_ObjInactive);
00169       }
00171       inline void make_non_removable() {
00172          _status =
00173            static_cast<BCP_obj_status> ((_status & ~BCP_ObjToBeRemoved) |
00174                                         BCP_ObjNotRemovable);
00175       }
00178       inline void make_to_be_removed() {
00179          _status = BCP_ObjToBeRemoved;
00180       }
00181     /* @}*/
00183 };
00184 
00185 //#############################################################################
00186 //#############################################################################
00187 
00195 class BCP_cut_core : public BCP_cut {
00196 
00197 private:
00201    BCP_cut_core();
00203    BCP_cut_core& operator=(const BCP_cut_core&);
00206 public:
00210    BCP_cut_core(const BCP_cut_core& x) : BCP_cut(x._lb, x._ub) {
00211       set_bcpind(x.bcpind());
00212       set_status(x.status());
00213       set_effective_count(x.effective_count());
00214    }
00217    BCP_cut_core(const double lb, const double ub) : BCP_cut(lb, ub) {}
00219    ~BCP_cut_core() {}
00226    inline BCP_object_t obj_type() const  { return BCP_CoreObj; }
00228 };
00229 
00230 //#############################################################################
00231 
00232 // This is the class the user should derive his/her own algorithmic cuts
00233 
00242 class BCP_cut_algo : public BCP_cut {
00243 private:
00247    BCP_cut_algo();
00249    BCP_cut_algo(const BCP_cut_algo&);
00251    BCP_cut_algo& operator=(const BCP_cut_algo&);
00254 public:
00259    BCP_cut_algo(const double lb, const double ub) : BCP_cut(lb, ub) {}
00261    virtual ~BCP_cut_algo() = 0;
00268    inline BCP_object_t obj_type() const   { return BCP_AlgoObj; }
00270 };
00271 
00272 //#############################################################################
00273 //#############################################################################
00274 
00279 class BCP_cut_set : public BCP_vec<BCP_cut*> {
00280 private:
00284    BCP_cut_set(const BCP_cut_set&);
00286    BCP_cut_set& operator=(const BCP_cut_set&);
00289 public:
00293     BCP_cut_set() {}
00296    ~BCP_cut_set() {}
00304    inline void append(const BCP_vec<BCP_cut*>& x) {
00305       BCP_vec<BCP_cut*>::append(x);
00306    }
00309    inline void append(BCP_cut_set::const_iterator first,
00310                       BCP_cut_set::const_iterator last){
00311       BCP_vec<BCP_cut*>::append(first, last);
00312    }
00313 
00317    void set_lb_ub(const BCP_vec<int>& pos,
00318                   BCP_vec<double>::const_iterator bounds);
00325    void set_lb_ub_st(const BCP_vec<BCP_obj_change>& cc);
00329    void set_lb_ub_st(BCP_vec<int>::const_iterator pos,
00330                      const BCP_vec<BCP_obj_change>& cc);
00332 #if 0
00333    //--------------------------------------------------------------------------
00351    void nonzero_slack(int first_to_check, const double * slacks,
00352                       const double etol, const int ineff_limit,
00353                       BCP_vec<int>& coll);
00356    void zero_dual(int first_to_check, const double * duals,
00357                   const double etol, const int ineff_limit,
00358                   BCP_vec<int>& coll);
00360 #endif
00361 
00363 #if 0
00364 
00367    void deletable(const int bcutnum, BCP_vec<int>& collection) const;
00368 #endif
00369 
00373    void move_deletable_to_pool(const BCP_vec<int>& deletable_cuts,
00374                                BCP_vec<BCP_cut*>& pool);
00376    //-----------------------------------------------------------------------
00377 };
00378 
00379 #endif

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