/home/coin/Bcp-1.0.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_error.hpp"
00011 #include "BCP_enum.hpp"
00012 #include "BCP_vector.hpp"
00013 #include "BCP_obj_change.hpp"
00014 
00015 //#############################################################################
00016 
00017 // Generic cut definition
00018 
00027 class BCP_cut{
00028 private:
00032     BCP_cut();
00034     BCP_cut(const BCP_cut&);
00036     BCP_cut& operator=(const BCP_cut&);
00039 private:
00044     int  _bcpind;
00046     BCP_obj_status _status;
00048     int            _eff_cnt;
00051 protected:
00054     double         _lb;
00056     double         _ub;
00059 public:
00066     BCP_cut(const double lb, const double ub) :
00067        _bcpind(0), _status(BCP_ObjNoInfo), _eff_cnt(0), _lb(lb), _ub(ub) {}
00070     virtual ~BCP_cut() {}
00076     virtual BCP_object_t obj_type() const = 0;
00078     inline int effective_count() const   { return _eff_cnt; }
00080     inline double lb() const             { return _lb; }
00082     inline double ub() const             { return _ub; }
00084     inline int bcpind() const  { return _bcpind; }
00085 
00086     /* *@name Query methods about the status of the variable */
00087     /* @{*/
00089       inline BCP_obj_status status() const { return _status; }
00093       inline bool dont_send_to_pool() const {
00094          return _status & BCP_ObjDoNotSendToPool ? true : false;
00095       }
00098       inline bool is_non_removable() const {
00099          return (_status & BCP_ObjNotRemovable) ? true : false;
00100       }
00104       inline bool is_to_be_removed() const {
00105          return (_status & BCP_ObjToBeRemoved) != 0;
00106       }
00107     /* @}*/
00113     inline void set_effective_count(const int cnt) { _eff_cnt = cnt; }
00116     inline int increase_effective_count() {
00117        _eff_cnt = _eff_cnt <= 0 ? 1 : _eff_cnt + 1;
00118        return _eff_cnt;
00119     }
00122     inline int decrease_effective_count() {
00123        _eff_cnt = _eff_cnt >= 0 ? -1 : _eff_cnt - 1;
00124        return _eff_cnt;
00125     }
00127     inline void set_lb(const double lb) { _lb = lb; }
00129     inline void set_ub(const double ub) { _ub = ub; }
00132     inline void change_lb_ub_st(const BCP_obj_change& change) {
00133        _lb = change.lb;
00134        _ub = change.ub;
00135        _status = change.stat;
00136        if (_lb < -1e30 && _ub > 1e30)
00137          _status = static_cast<BCP_obj_status>(_status | BCP_ObjInactive);
00138     }
00140     inline void change_bounds(const double lb, const double ub) {
00141        _lb = lb;
00142        _ub = ub;
00143        if (lb < -1e30 && ub > 1e30)
00144          _status = static_cast<BCP_obj_status>(_status | BCP_ObjInactive);
00145     }
00147     inline void set_bcpind(const int bcpind)  { _bcpind = bcpind; }
00148 
00149     /* *@name Status modifying methods */
00150     /* @{*/
00152       inline void set_status(const BCP_obj_status stat) { _status = stat; }
00155       inline void dont_send_to_pool(bool flag) {
00156          _status = static_cast<BCP_obj_status>(flag ?
00157                                             _status | BCP_ObjDoNotSendToPool :
00158                                             _status & ~BCP_ObjDoNotSendToPool);
00159       }
00163       inline void make_active() {
00164          _status = static_cast<BCP_obj_status>(_status & ~BCP_ObjInactive);
00165       }
00167       inline void make_non_removable() {
00168          _status =
00169            static_cast<BCP_obj_status> ((_status & ~BCP_ObjToBeRemoved) |
00170                                         BCP_ObjNotRemovable);
00171       }
00174       inline void make_to_be_removed() {
00175          _status = BCP_ObjToBeRemoved;
00176       }
00177     /* @}*/
00179 };
00180 
00181 //#############################################################################
00182 //#############################################################################
00183 
00191 class BCP_cut_core : public BCP_cut {
00192 
00193 private:
00197    BCP_cut_core();
00199    BCP_cut_core& operator=(const BCP_cut_core&);
00202 public:
00206    BCP_cut_core(const BCP_cut_core& x) : BCP_cut(x._lb, x._ub) {
00207       set_bcpind(x.bcpind());
00208       set_status(x.status());
00209       set_effective_count(x.effective_count());
00210    }
00213    BCP_cut_core(const double lb, const double ub) : BCP_cut(lb, ub) {}
00215    ~BCP_cut_core() {}
00222    inline BCP_object_t obj_type() const  { return BCP_CoreObj; }
00224 };
00225 
00226 //#############################################################################
00227 
00233 class BCP_cut_indexed : public BCP_cut {
00234 private:
00238    BCP_cut_indexed();
00240    BCP_cut_indexed(const BCP_cut_indexed&);
00242    BCP_cut_indexed& operator=(const BCP_cut_indexed&);
00245 private:
00250    int _index;
00253 public:
00258    BCP_cut_indexed(const int index, const double lb, const double ub) :
00259       BCP_cut(lb, ub), _index(index) {}
00261    ~BCP_cut_indexed() {}
00267    inline int index() const             { return _index; }
00269    inline BCP_object_t obj_type() const { return BCP_IndexedObj; }
00271 };
00272 
00273 //#############################################################################
00274 
00275 // This is the class the user should derive his/her own algorithmic cuts
00276 
00285 class BCP_cut_algo : public BCP_cut {
00286 private:
00290    BCP_cut_algo();
00292    BCP_cut_algo(const BCP_cut_algo&);
00294    BCP_cut_algo& operator=(const BCP_cut_algo&);
00297 public:
00302    BCP_cut_algo(const double lb, const double ub) : BCP_cut(lb, ub) {}
00304    virtual ~BCP_cut_algo() = 0;
00311    inline BCP_object_t obj_type() const   { return BCP_AlgoObj; }
00313 };
00314 
00315 //#############################################################################
00316 //#############################################################################
00317 
00322 class BCP_cut_set : public BCP_vec<BCP_cut*> {
00323 private:
00327    BCP_cut_set(const BCP_cut_set&);
00329    BCP_cut_set& operator=(const BCP_cut_set&);
00332 public:
00336     BCP_cut_set() {}
00339    ~BCP_cut_set() {}
00347    inline void append(const BCP_vec<BCP_cut*>& x) {
00348       BCP_vec<BCP_cut*>::append(x);
00349    }
00352    inline void append(BCP_cut_set::const_iterator first,
00353                       BCP_cut_set::const_iterator last){
00354       BCP_vec<BCP_cut*>::append(first, last);
00355    }
00356 
00360    void set_lb_ub(const BCP_vec<int>& pos,
00361                   BCP_vec<double>::const_iterator bounds);
00368    void set_lb_ub_st(const BCP_vec<BCP_obj_change>& cc);
00372    void set_lb_ub_st(BCP_vec<int>::const_iterator pos,
00373                      const BCP_vec<BCP_obj_change>& cc);
00375 #if 0
00376    //--------------------------------------------------------------------------
00394    void nonzero_slack(int first_to_check, const double * slacks,
00395                       const double etol, const int ineff_limit,
00396                       BCP_vec<int>& coll);
00399    void zero_dual(int first_to_check, const double * duals,
00400                   const double etol, const int ineff_limit,
00401                   BCP_vec<int>& coll);
00403 #endif
00404 
00406 #if 0
00407 
00410    void deletable(const int bcutnum, BCP_vec<int>& collection) const;
00411 #endif
00412 
00416    void move_deletable_to_pool(const BCP_vec<int>& deletable_cuts,
00417                                BCP_vec<BCP_cut*>& pool);
00419    //-----------------------------------------------------------------------
00420 };
00421 
00422 #endif

Generated on Wed Aug 22 03:00:53 2007 for coin-Bcp by  doxygen 1.4.7