edoNormalAdaptive.h
00001 
00002 /*
00003 The Evolving Distribution Objects framework (EDO) is a template-based,
00004 ANSI-C++ evolutionary computation library which helps you to write your
00005 own estimation of distribution algorithms.
00006 
00007 This library is free software; you can redistribute it and/or
00008 modify it under the terms of the GNU Lesser General Public
00009 License as published by the Free Software Foundation; either
00010 version 2.1 of the License, or (at your option) any later version.
00011 
00012 This library is distributed in the hope that it will be useful,
00013 but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 Lesser General Public License for more details.
00016 
00017 You should have received a copy of the GNU Lesser General Public
00018 License along with this library; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020 
00021 Copyright (C) 2010 Thales group
00022 */
00023 /*
00024 Authors:
00025     Johann Dreo <johann.dreo@thalesgroup.com>
00026     Pierre Savéant <pierre.saveant@thalesgroup.com>
00027 */
00028 
00029 #ifndef _edoNormalAdaptive_h
00030 #define _edoNormalAdaptive_h
00031 
00032 #include "edoDistrib.h"
00033 
00034 #ifdef WITH_EIGEN
00035 
00036 #include <Eigen/Dense>
00037 
00071 template < typename EOT >
00072 class edoNormalAdaptive : public edoDistrib< EOT >
00073 {
00074 public:
00075     //typedef EOT EOType;
00076     typedef typename EOT::AtomType AtomType;
00077     typedef Eigen::Matrix< AtomType, Eigen::Dynamic, 1> Vector; // column vectors ( n lines, 1 column)
00078     typedef Eigen::Matrix< AtomType, Eigen::Dynamic, Eigen::Dynamic> Matrix;
00079 
00080     edoNormalAdaptive( unsigned int dim = 1 ) :
00081         _dim(dim),
00082         _mean( Vector::Zero(dim) ),
00083         _C( Matrix::Identity(dim,dim) ),
00084         _B( Matrix::Identity(dim,dim) ),
00085         _D( Vector::Constant( dim, 1) ),
00086         _sigma(1.0),
00087         _p_c( Vector::Zero(dim) ),
00088         _p_s( Vector::Zero(dim) )
00089     {
00090         assert( _dim > 0);
00091     }
00092 
00093     edoNormalAdaptive( unsigned int dim,
00094             Vector mean,
00095             Matrix C,
00096             Matrix B,
00097             Vector D,
00098             double sigma,
00099             Vector p_c,
00100             Vector p_s
00101         ) :
00102         _mean( mean ),
00103         _C( C ),
00104         _B( B ),
00105         _D( D ),
00106         _sigma(sigma),
00107         _p_c( p_c ),
00108         _p_s( p_s )
00109     {
00110         assert( dim > 0);
00111         assert( _mean.innerSize() == dim );
00112         assert( _C.innerSize() == dim && _C.outerSize() == dim );
00113         assert( _B.innerSize() == dim && _B.outerSize() == dim );
00114         assert( _D.innerSize() == dim );
00115         assert( _sigma != 0.0 );
00116         assert( _p_c.innerSize() == dim );
00117         assert( _p_s.innerSize() == dim );
00118     }
00119 
00120     unsigned int size()
00121     {
00122         return _mean.innerSize();
00123     }
00124 
00125     Vector mean()       const {return _mean;}
00126     Matrix covar()      const {return _C;}
00127     Matrix coord_sys()  const {return _B;}
00128     Vector scaling()    const {return _D;}
00129     double sigma()      const {return _sigma;}
00130     Vector path_covar() const {return _p_c;}
00131     Vector path_sigma() const {return _p_s;}
00132 
00133     void mean(       Vector m ) { _mean = m;  assert( m.size() == _dim ); }
00134     void covar(      Matrix c ) { _C = c;     assert( c.innerSize() == _dim && c.outerSize() == _dim ); }
00135     void coord_sys(  Matrix b ) { _B = b;     assert( b.innerSize() == _dim && b.outerSize() == _dim ); }
00136     void scaling(    Vector d ) { _D = d;     assert( d.size() == _dim ); }
00137     void sigma(      double s ) { _sigma = s; assert( s != 0.0 );}
00138     void path_covar( Vector p ) { _p_c = p;   assert( p.size() == _dim ); }
00139     void path_sigma( Vector p ) { _p_s = p;   assert( p.size() == _dim ); }
00140 
00141 private:
00142     unsigned int _dim;
00143     Vector _mean; // mean vector
00144     Matrix _C; // covariance matrix
00145     Matrix _B; // eigen vectors / coordinates system
00146     Vector _D; // eigen values / scaling
00147     double _sigma; // absolute scaling of the distribution
00148     Vector _p_c; // evolution path for C
00149     Vector _p_s; // evolution path for sigma
00150 };
00151 
00152 #else
00153 #pragma message "WARNING: there is no Boost::uBLAS implementation of edoNormalAdaptive, build WITH_EIGEN if you need it."
00154 #endif // WITH_EIGEN
00155 
00156 #endif // !_edoNormalAdaptive_h
 All Classes Functions Variables Typedefs