/home/coin/SVN-release/CoinAll-1.1.0/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 "BCP_math.hpp"
00011 #include "BCP_error.hpp"
00012 #include "BCP_enum.hpp"
00013 #include "BCP_vector.hpp"
00014 #include "BCP_obj_change.hpp"
00015 
00016 //#############################################################################
00017 
00018 // Generic cut definition
00019 
00028 class BCP_cut{
00029 private:
00033     BCP_cut();
00035     BCP_cut(const BCP_cut&);
00037     BCP_cut& operator=(const BCP_cut&);
00040 private:
00045     int  _bcpind;
00047     BCP_obj_status _status;
00049     int            _eff_cnt;
00052 protected:
00055     double         _lb;
00057     double         _ub;
00060 public:
00067     BCP_cut(const double lb, const double ub) :
00068        _bcpind(0), _status(BCP_ObjNoInfo), _eff_cnt(0), _lb(lb), _ub(ub) {}
00071     virtual ~BCP_cut() {}
00077     virtual BCP_object_t obj_type() const = 0;
00079     inline int effective_count() const   { return _eff_cnt; }
00081     inline double lb() const             { return _lb; }
00083     inline double ub() const             { return _ub; }
00085     inline int bcpind() const  { return _bcpind; }
00086 
00087     /* *@name Query methods about the status of the variable */
00088     /* @{*/
00090       inline BCP_obj_status status() const { return _status; }
00094       inline bool dont_send_to_pool() const {
00095          return _status & BCP_ObjDoNotSendToPool ? true : false;
00096       }
00099       inline bool is_non_removable() const {
00100          return (_status & BCP_ObjNotRemovable) ? true : false;
00101       }
00105       inline bool is_to_be_removed() const {
00106          return (_status & BCP_ObjToBeRemoved) != 0;
00107       }
00108     /* @}*/
00114     inline void set_effective_count(const int cnt) { _eff_cnt = cnt; }
00117     inline int increase_effective_count() {
00118        _eff_cnt = _eff_cnt <= 0 ? 1 : _eff_cnt + 1;
00119        return _eff_cnt;
00120     }
00123     inline int decrease_effective_count() {
00124        _eff_cnt = _eff_cnt >= 0 ? -1 : _eff_cnt - 1;
00125        return _eff_cnt;
00126     }
00128     inline void set_lb(const double lb) { _lb = lb; }
00130     inline void set_ub(const double ub) { _ub = ub; }
00133     inline void change_lb_ub_st(const BCP_obj_change& change) {
00134        _lb = change.lb;
00135        _ub = change.ub;
00136        _status = change.stat;
00137        if (_lb < -BCP_DBL_MAX/10 && _ub > BCP_DBL_MAX/10)
00138          _status = static_cast<BCP_obj_status>(_status | BCP_ObjInactive);
00139     }
00141     inline void change_bounds(const double lb, const double ub) {
00142        _lb = lb;
00143        _ub = ub;
00144        if (lb < BCP_DBL_MAX/10 && ub > BCP_DBL_MAX/10)
00145          _status = static_cast<BCP_obj_status>(_status | BCP_ObjInactive);
00146     }
00148     inline void set_bcpind(const int bcpind)  { _bcpind = bcpind; }
00149 
00150     /* *@name Status modifying methods */
00151     /* @{*/
00153       inline void set_status(const BCP_obj_status stat) { _status = stat; }
00156       inline void dont_send_to_pool(bool flag) {
00157          _status = static_cast<BCP_obj_status>(flag ?
00158                                             _status | BCP_ObjDoNotSendToPool :
00159                                             _status & ~BCP_ObjDoNotSendToPool);
00160       }
00164       inline void make_active() {
00165          _status = static_cast<BCP_obj_status>(_status & ~BCP_ObjInactive);
00166       }
00168       inline void make_non_removable() {
00169          _status =
00170            static_cast<BCP_obj_status> ((_status & ~BCP_ObjToBeRemoved) |
00171                                         BCP_ObjNotRemovable);
00172       }
00175       inline void make_to_be_removed() {
00176          _status = BCP_ObjToBeRemoved;
00177       }
00178     /* @}*/
00180 };
00181 
00182 //#############################################################################
00183 //#############################################################################
00184 
00192 class BCP_cut_core : public BCP_cut {
00193 
00194 private:
00198    BCP_cut_core();
00200    BCP_cut_core& operator=(const BCP_cut_core&);
00203 public:
00207    BCP_cut_core(const BCP_cut_core& x) : BCP_cut(x._lb, x._ub) {
00208       set_bcpind(x.bcpind());
00209       set_status(x.status());
00210       set_effective_count(x.effective_count());
00211    }
00214    BCP_cut_core(const double lb, const double ub) : BCP_cut(lb, ub) {}
00216    ~BCP_cut_core() {}
00223    inline BCP_object_t obj_type() const  { return BCP_CoreObj; }
00225 };
00226 
00227 //#############################################################################
00228 
00234 class BCP_cut_indexed : public BCP_cut {
00235 private:
00239    BCP_cut_indexed();
00241    BCP_cut_indexed(const BCP_cut_indexed&);
00243    BCP_cut_indexed& operator=(const BCP_cut_indexed&);
00246 private:
00251    int _index;
00254 public:
00259    BCP_cut_indexed(const int index, const double lb, const double ub) :
00260       BCP_cut(lb, ub), _index(index) {}
00262    ~BCP_cut_indexed() {}
00268    inline int index() const             { return _index; }
00270    inline BCP_object_t obj_type() const { return BCP_IndexedObj; }
00272 };
00273 
00274 //#############################################################################
00275 
00276 // This is the class the user should derive his/her own algorithmic cuts
00277 
00286 class BCP_cut_algo : public BCP_cut {
00287 private:
00291    BCP_cut_algo();
00293    BCP_cut_algo(const BCP_cut_algo&);
00295    BCP_cut_algo& operator=(const BCP_cut_algo&);
00298 public:
00303    BCP_cut_algo(const double lb, const double ub) : BCP_cut(lb, ub) {}
00305    virtual ~BCP_cut_algo() = 0;
00312    inline BCP_object_t obj_type() const   { return BCP_AlgoObj; }
00314 };
00315 
00316 //#############################################################################
00317 //#############################################################################
00318 
00323 class BCP_cut_set : public BCP_vec<BCP_cut*> {
00324 private:
00328    BCP_cut_set(const BCP_cut_set&);
00330    BCP_cut_set& operator=(const BCP_cut_set&);
00333 public:
00337     BCP_cut_set() {}
00340    ~BCP_cut_set() {}
00348    inline void append(const BCP_vec<BCP_cut*>& x) {
00349       BCP_vec<BCP_cut*>::append(x);
00350    }
00353    inline void append(BCP_cut_set::const_iterator first,
00354                       BCP_cut_set::const_iterator last){
00355       BCP_vec<BCP_cut*>::append(first, last);
00356    }
00357 
00361    void set_lb_ub(const BCP_vec<int>& pos,
00362                   BCP_vec<double>::const_iterator bounds);
00369    void set_lb_ub_st(const BCP_vec<BCP_obj_change>& cc);
00373    void set_lb_ub_st(BCP_vec<int>::const_iterator pos,
00374                      const BCP_vec<BCP_obj_change>& cc);
00376 #if 0
00377    //--------------------------------------------------------------------------
00395    void nonzero_slack(int first_to_check, const double * slacks,
00396                       const double etol, const int ineff_limit,
00397                       BCP_vec<int>& coll);
00400    void zero_dual(int first_to_check, const double * duals,
00401                   const double etol, const int ineff_limit,
00402                   BCP_vec<int>& coll);
00404 #endif
00405 
00407 #if 0
00408 
00411    void deletable(const int bcutnum, BCP_vec<int>& collection) const;
00412 #endif
00413 
00417    void move_deletable_to_pool(const BCP_vec<int>& deletable_cuts,
00418                                BCP_vec<BCP_cut*>& pool);
00420    //-----------------------------------------------------------------------
00421 };
00422 
00423 #endif

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