Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

bound_delta.h

Go to the documentation of this file.
00001 // Bound Delta implementation -*- C++ -*-
00002 
00003 // Copyright (C) 2001-2003 Hermann Schichl
00004 //
00005 // This file is part of the COCONUT API.  This library
00006 // is free software; you can redistribute it and/or modify it under the
00007 // terms of the Library GNU General Public License as published by the
00008 // Free Software Foundation; either version 2, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // Library GNU General Public License for more details.
00015 
00016 // As a special exception, you may use this file as part of a free software
00017 // library without restriction.  Specifically, if other files instantiate
00018 // templates or use macros or inline functions from this file, or you compile
00019 // this file and link it with other files to produce an executable, this
00020 // file does not by itself cause the resulting executable to be covered by
00021 // the Library GNU General Public License.  This exception does not however
00022 // invalidate any other reasons why the executable file might be covered by
00023 // the Library GNU General Public License.
00024 
00027 #ifndef _BOUND_DELTA_H_
00028 #define _BOUND_DELTA_H_
00029 
00030 #include <api_delta.h>
00031 
00032 class bound_undelta : public undelta_base
00033 {
00034 public:
00035   std::vector<unsigned int> indices;    // if all variables are being
00036                                         // updated this vector is empty
00037   std::vector<interval> old_f_bounds;   // original bounds are stored here
00038                                         // in order to restore the values
00039                                         // easily during backtracking
00040   double old_gain, old_log_vol;
00041 public:
00042   bound_undelta(const std::vector<unsigned int>& __i,
00043                 const std::vector<interval>& __b,
00044                 double _og, double _olv) : undelta_base(), indices(__i),
00045                                            old_f_bounds(__b), old_gain(_og),
00046                                            old_log_vol(_olv)           {}
00047   
00048   bound_undelta(const std::vector<unsigned int>& __i, double _og,
00049                 double _olv) : undelta_base(), indices(__i),
00050                                old_f_bounds(), old_gain(_og),
00051                                old_log_vol(_olv) {}
00052   
00053   bound_undelta(const bound_undelta& __d) : undelta_base(__d),
00054                                             indices(__d.indices),
00055                                             old_f_bounds(__d.old_f_bounds),
00056                                             old_gain(__d.old_gain),
00057                                             old_log_vol(__d.old_log_vol)
00058       {
00059 #if DEBUG_DELTA
00060         std::cerr << "Called bound_undelta copy constructor" << std::endl;
00061 #endif
00062       }
00063 
00064   bound_undelta* new_copy() const { return new bound_undelta(*this); }
00065   void destroy_copy(bound_undelta* __d) { delete __d; }
00066 
00067   bool unapply(work_node& _x) const;
00068 
00069   friend class bound_delta;
00070 };
00071 
00072 class bound_delta : public delta_base
00073 {
00074 public:
00075   std::vector<unsigned int> indices;         // if all variables are being
00076                                              // updated this vector is empty
00077   std::vector<interval> new_f_bounds;        // new bounds
00078 public:
00079   bound_delta(const std::vector<unsigned int>& __i,
00080               const std::vector<interval>& __b)
00081                     : delta_base("change bounds"), indices(__i),
00082                       new_f_bounds(__b) {}
00083   
00084   bound_delta(unsigned int __i, interval __b)
00085                     : delta_base("change bounds"), indices(1,__i),
00086                       new_f_bounds(1,__b) {}
00087   
00088   bound_delta(const bound_delta& __d) : delta_base(__d), indices(__d.indices),
00089                                         new_f_bounds(__d.new_f_bounds)
00090     {
00091 #if DEBUG_DELTA
00092         std::cerr << "Called bound_delta copy constructor" << std::endl;
00093 #endif
00094     }
00095 
00096   bound_delta* new_copy() const { return new bound_delta(*this); }
00097   void destroy_copy(bound_delta* __d) { delete __d; }
00098 
00099   bool apply(work_node& _x, undelta_base*& _u) const;
00100 };
00101 
00102 #endif /* _BOUND_DELTA_H_ */

Generated on Tue Nov 4 01:57:56 2003 for COCONUT API by doxygen1.2.18