mlpack  git-master
cmaes.hpp
Go to the documentation of this file.
1 
15 #ifndef MLPACK_CORE_OPTIMIZERS_CMAES_CMAES_HPP
16 #define MLPACK_CORE_OPTIMIZERS_CMAES_CMAES_HPP
17 
18 #include <mlpack/prereqs.hpp>
19 
20 #include "full_selection.hpp"
21 #include "random_selection.hpp"
22 
23 namespace mlpack {
24 namespace optimization {
25 
65 template<typename SelectionPolicyType = FullSelection>
66 class CMAES
67 {
68  public:
87  CMAES(const size_t lambda = 0,
88  const double lowerBound = -10,
89  const double upperBound = 10,
90  const size_t batchSize = 32,
91  const size_t maxIterations = 1000,
92  const double tolerance = 1e-5,
93  const SelectionPolicyType& selectionPolicy = SelectionPolicyType());
94 
105  template<typename DecomposableFunctionType>
106  double Optimize(DecomposableFunctionType& function, arma::mat& iterate);
107 
109  size_t PopulationSize() const { return lambda; }
111  size_t& PopulationSize() { return lambda; }
112 
114  double LowerBound() const { return lowerBound; }
116  double& LowerBound() { return lowerBound; }
117 
119  double UpperBound() const { return upperBound; }
121  double& UpperBound() { return upperBound; }
122 
124  size_t BatchSize() const { return batchSize; }
126  size_t& BatchSize() { return batchSize; }
127 
129  size_t MaxIterations() const { return maxIterations; }
131  size_t& MaxIterations() { return maxIterations; }
132 
134  double Tolerance() const { return tolerance; }
136  double& Tolerance() { return tolerance; }
137 
139  const SelectionPolicyType& SelectionPolicy() const { return selectionPolicy; }
141  SelectionPolicyType& SelectionPolicy() { return selectionPolicy; }
142 
143  private:
145  size_t lambda;
146 
148  double lowerBound;
149 
151  double upperBound;
152 
154  size_t batchSize;
155 
157  size_t maxIterations;
158 
160  double tolerance;
161 
163  SelectionPolicyType selectionPolicy;
164 };
165 
169 template<typename SelectionPolicyType = RandomSelection>
171 
172 } // namespace optimization
173 } // namespace mlpack
174 
175 // Include implementation.
176 #include "cmaes_impl.hpp"
177 
178 #endif
double & Tolerance()
Modify the tolerance for termination.
Definition: cmaes.hpp:136
double Optimize(DecomposableFunctionType &function, arma::mat &iterate)
Optimize the given function using CMA-ES.
double & UpperBound()
Modify the upper bound of decision variables.
Definition: cmaes.hpp:121
CMAES(const size_t lambda=0, const double lowerBound=-10, const double upperBound=10, const size_t batchSize=32, const size_t maxIterations=1000, const double tolerance=1e-5, const SelectionPolicyType &selectionPolicy=SelectionPolicyType())
Construct the CMA-ES optimizer with the given function and parameters.
.hpp
Definition: add_to_po.hpp:21
The core includes that mlpack expects; standard C++ includes and Armadillo.
size_t & BatchSize()
Modify the batch size.
Definition: cmaes.hpp:126
double Tolerance() const
Get the tolerance for termination.
Definition: cmaes.hpp:134
size_t BatchSize() const
Get the batch size.
Definition: cmaes.hpp:124
double LowerBound() const
Get the lower bound of decision variables.
Definition: cmaes.hpp:114
SelectionPolicyType & SelectionPolicy()
Modify the selection policy.
Definition: cmaes.hpp:141
const SelectionPolicyType & SelectionPolicy() const
Get the selection policy.
Definition: cmaes.hpp:139
size_t MaxIterations() const
Get the maximum number of iterations (0 indicates no limit).
Definition: cmaes.hpp:129
size_t PopulationSize() const
Get the step size.
Definition: cmaes.hpp:109
CMA-ES - Covariance Matrix Adaptation Evolution Strategy is s a stochastic search algorithm...
Definition: cmaes.hpp:66
size_t & PopulationSize()
Modify the step size.
Definition: cmaes.hpp:111
double UpperBound() const
Get the upper bound of decision variables.
Definition: cmaes.hpp:119
size_t & MaxIterations()
Modify the maximum number of iterations (0 indicates no limit).
Definition: cmaes.hpp:131
double & LowerBound()
Modify the lower bound of decision variables.
Definition: cmaes.hpp:116