CMAIndividual.h
Go to the documentation of this file.
1 /*!
2  *
3  *
4  * \brief TypedIndividual
5 
6  *
7  *
8  * \author T.Voss, T. Glasmachers, O.Krause
9  * \date 2010-2011
10  *
11  *
12  * \par Copyright 1995-2017 Shark Development Team
13  *
14  * <BR><HR>
15  * This file is part of Shark.
16  * <http://shark-ml.org/>
17  *
18  * Shark is free software: you can redistribute it and/or modify
19  * it under the terms of the GNU Lesser General Public License as published
20  * by the Free Software Foundation, either version 3 of the License, or
21  * (at your option) any later version.
22  *
23  * Shark is distributed in the hope that it will be useful,
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26  * GNU Lesser General Public License for more details.
27  *
28  * You should have received a copy of the GNU Lesser General Public License
29  * along with Shark. If not, see <http://www.gnu.org/licenses/>.
30  *
31  */
32 #ifndef SHARK_ALGORITHMS_DIRECT_SEARCH_CMA_INDIVIDUAL_H
33 #define SHARK_ALGORITHMS_DIRECT_SEARCH_CMA_INDIVIDUAL_H
34 
37 
38 #include <shark/LinAlg/Base.h>
39 #include <vector>
40 
41 namespace shark {
42 
43 template<class FitnessType>
44 class CMAIndividual : public Individual<RealVector,FitnessType, CMAChromosome>{
45 public:
48  /**
49  * \brief Default constructor that initializes the individual's attributes to default values.
50  */
51  CMAIndividual():m_parent(0){}
53  std::size_t searchSpaceDimension,
54  double successThreshold = 0.44,
55  double initialStepSize = 1.0
56  ):m_parent(0){
57  chromosome() = CMAChromosome(searchSpaceDimension, successThreshold, initialStepSize);
58  searchPoint().resize(searchSpaceDimension);
59  }
60 
62  chromosome().updateAsParent(offspringSuccess);
63  }
66  }
67  template<class randomType>
68  void mutate(randomType& rng){
70  rng, chromosome().m_lastStep,chromosome().m_lastZ
71  );
73  }
74 
76  return chromosome().m_noSuccessfulOffspring;
77  }
78 
79  double noSuccessfulOffspring()const{
80  return chromosome().m_noSuccessfulOffspring;
81  }
82 
83  std::size_t parent()const{
84  return m_parent;
85  }
86  std::size_t& parent(){
87  return m_parent;
88  }
89 private:
90  std::size_t m_parent;
91 };
92 
93 }
94 #endif