ElitistCMA.h
Go to the documentation of this file.
1//===========================================================================
2/*!
3 *
4 *
5 * \brief Implements the most recent version of the elitist CMA-ES.
6 *
7 * The algorithm is based on
8 *
9 * C. Igel, T. Suttorp, and N. Hansen. A Computational Efficient
10 * Covariance Matrix Update and a (1+1)-CMA for Evolution
11 * Strategies. In Proceedings of the Genetic and Evolutionary
12 * Computation Conference (GECCO 2006), pp. 453-460, ACM Press, 2006
13 *
14 * D. V. Arnold and N. Hansen: Active covariance matrix adaptation for
15 * the (1+1)-CMA-ES. In Proceedings of the Genetic and Evolutionary
16 * Computation Conference (GECCO 2010): pp 385-392, ACM Press 2010
17 *
18 *
19 * \author O. Krause T.Voss
20 * \date 2014
21 *
22 *
23 * \par Copyright 1995-2017 Shark Development Team
24 *
25 * <BR><HR>
26 * This file is part of Shark.
27 * <https://shark-ml.github.io/Shark/>
28 *
29 * Shark is free software: you can redistribute it and/or modify
30 * it under the terms of the GNU Lesser General Public License as published
31 * by the Free Software Foundation, either version 3 of the License, or
32 * (at your option) any later version.
33 *
34 * Shark is distributed in the hope that it will be useful,
35 * but WITHOUT ANY WARRANTY; without even the implied warranty of
36 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37 * GNU Lesser General Public License for more details.
38 *
39 * You should have received a copy of the GNU Lesser General Public License
40 * along with Shark. If not, see <http://www.gnu.org/licenses/>.
41 *
42 */
43//===========================================================================
44
45
46#ifndef SHARK_ALGORITHMS_DIRECTSEARCH_ELITIST_CMA_H
47#define SHARK_ALGORITHMS_DIRECTSEARCH_ELITIST_CMA_H
48
53
54namespace shark {
55
56
57/// \brief Implements the elitist CMA-ES.
58///
59/// The algorithm is based on
60///
61/// C. Igel, T. Suttorp, and N. Hansen. A Computational Efficient
62/// Covariance Matrix Update and a (1+1)-CMA for Evolution
63/// Strategies. In Proceedings of the Genetic and Evolutionary
64/// Computation Conference (GECCO 2006), pp. 453-460, ACM Press, 2006
65///
66/// D. V. Arnold and N. Hansen: Active covariance matrix adaptation for
67/// the (1+1)-CMA-ES. In Proceedings of the Genetic and Evolutionary
68/// \ingroup singledirect
69class ElitistCMA : public AbstractSingleObjectiveOptimizer<RealVector >{
70public:
71
73
74 /// \brief From INameable: return the class name.
75 std::string name() const
76 { return "ElitistCMA"; }
77
79
80 SHARK_EXPORT_SYMBOL void write( OutArchive & archive ) const;
81
83
84 /// \brief Initializes the algorithm for the supplied objective function.
86
87 ///\brief Executes one iteration of the algorithm.
89
90 /// \brief Returns true when the active update is used (default true).
91 bool activeUpdate()const{
92 return m_activeUpdate;
93 }
94 /// \brief Setter function to enable active update. Returns true when the active update is used (default true).
95 bool& activeUpdate(){
96 return m_activeUpdate;
97 }
98
99 /// \brief Returns the penalty factor for an individual that is outside the feasible area.
100 ///
101 /// The value is multiplied with the distance to the nearest feasible point.
103 return m_evaluator.m_penaltyFactor;
104 }
105
106 /// \brief Returns a reference to the penalty factor for an individual that is outside the feasible area.
107 ///
108 /// The value is multiplied with the distance to the nearest feasible point.
110 return m_evaluator.m_penaltyFactor;
111 }
112
113 /// \brief Returns the current step length
114 double sigma()const{
115 return m_individual.chromosome().m_stepSize;
116 }
117
118 /// \brief Returns the current step length
119 double& sigma(){
120 return m_individual.chromosome().m_stepSize;
121 }
122
123private:
124 CMAIndividual<double> m_individual;///< Individual holding strategy parameter. usd as parent and offspring
125 PenalizingEvaluator m_evaluator;///< evaluates the fitness of the individual and handles constraints
126 std::vector<double> m_ancestralFitness; ///< stores the last k fitness values (by default 5).
127 bool m_activeUpdate;///< Should bad individuals be actively purged from the strategy?
128
129 random::rng_type* mpe_rng;///< the internal random number generator
130};
131}
132
133#endif