Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPOP and BIPOP restart mechanisms #403

Merged
merged 56 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
bdbdc01
IPOP and IPOP restart mechanisms
beny-bee Jul 7, 2024
6bb6af4
Update include/ensmallen_bits/cmaes/bipop_cmaes.hpp
beny-bee Jul 8, 2024
4d880bb
add ipop and bipop documentation
beny-bee Jul 8, 2024
8a257b5
update docs
beny-bee Jul 29, 2024
942bc37
Updates ipop bipop
beny-bee Jul 29, 2024
762fab9
bipop update
beny-bee Jul 29, 2024
2508bb1
Refactor IPOP and BIPOP to one
beny-bee Aug 13, 2024
aba89da
add POP in ensmallen.hpp
beny-bee Aug 13, 2024
1103561
correct typo
beny-bee Aug 13, 2024
3316077
Documentation and useBIPOP parameter template
beny-bee Aug 17, 2024
66d9f19
Delete include/ensmallen_bits/cmaes/bipop_cmaes.hpp
beny-bee Aug 17, 2024
6d58cfd
Delete include/ensmallen_bits/cmaes/bipop_cmaes_impl.hpp
beny-bee Aug 17, 2024
2c14b7d
Delete include/ensmallen_bits/cmaes/ipop_cmaes.hpp
beny-bee Aug 17, 2024
541c6be
Delete include/ensmallen_bits/cmaes/ipop_cmaes_impl.hpp
beny-bee Aug 17, 2024
1d2dd1e
Delete tests/bipop_cmaes_test.cpp
beny-bee Aug 17, 2024
4622470
Delete tests/ipop_cmaes_test.cpp
beny-bee Aug 17, 2024
6d369f3
Update CMakeLists.txt
beny-bee Aug 17, 2024
3dfe373
add more tests for pop-cma-es
beny-bee Aug 17, 2024
16b0be1
fixed bug in pop-cma-es
beny-bee Aug 17, 2024
a6fd0ff
Update test for pop-cma-es
beny-bee Aug 17, 2024
8f5ce22
init overallSBC to sbc
beny-bee Aug 20, 2024
723b623
Update include/ensmallen_bits/cmaes/pop_cmaes.hpp
beny-bee Aug 20, 2024
4abc15d
update doc and tests
beny-bee Aug 20, 2024
2e3f7db
update tests
beny-bee Aug 20, 2024
0a5d061
Merge branch 'mlpack:master' into restart-ipop-bipop
beny-bee Aug 27, 2024
6b674f3
Update doc/optimizers.md per suggestion
conradsnicta Nov 28, 2024
b876f45
Update doc/optimizers.md per suggestion
conradsnicta Nov 28, 2024
0b5ecbd
Update doc/optimizers.md per suggestion
conradsnicta Nov 28, 2024
0980684
Update doc/optimizers.md per suggestion
conradsnicta Nov 28, 2024
a985816
Update doc/function_types.md per suggestion
conradsnicta Nov 28, 2024
6e674f9
Update doc/optimizers.md per suggestion
conradsnicta Nov 28, 2024
71fc310
Update doc/optimizers.md per suggestion
conradsnicta Nov 28, 2024
1a222d3
Update doc/optimizers.md per suggestion
conradsnicta Nov 28, 2024
b07b339
Update doc/optimizers.md per suggestion
conradsnicta Nov 28, 2024
f377c79
Update doc/optimizers.md per suggestion
conradsnicta Nov 28, 2024
d271cda
Update doc/optimizers.md per suggestion
conradsnicta Nov 28, 2024
befd7d5
Update include/ensmallen_bits/cmaes/pop_cmaes.hpp per suggestion
conradsnicta Nov 28, 2024
b98991b
Update include/ensmallen_bits/cmaes/pop_cmaes_impl.hpp per suggestion
conradsnicta Nov 28, 2024
33b5452
Update doc/optimizers.md per suggestion
conradsnicta Nov 28, 2024
42e01ee
Update doc/optimizers.md per suggestion
conradsnicta Nov 28, 2024
765af85
Update doc/optimizers.md per suggestion
conradsnicta Nov 28, 2024
27ec68d
Update include/ensmallen_bits/cmaes/cmaes.hpp per suggestion
conradsnicta Nov 28, 2024
b8671a4
Update include/ensmallen_bits/cmaes/cmaes.hpp per suggestion
conradsnicta Nov 28, 2024
5a69d3d
Update tests/pop_cmaes_test.cpp per suggestion
conradsnicta Nov 28, 2024
32443c7
Update include/ensmallen_bits/cmaes/pop_cmaes_impl.hpp per suggestion
conradsnicta Nov 28, 2024
0b735a7
Update include/ensmallen_bits/cmaes/pop_cmaes_impl.hpp per suggestion
conradsnicta Nov 28, 2024
552a690
Update include/ensmallen_bits/cmaes/pop_cmaes_impl.hpp per suggestion
conradsnicta Nov 28, 2024
cc39308
Update include/ensmallen_bits/cmaes/pop_cmaes_impl.hpp per suggestion
conradsnicta Nov 28, 2024
7b95aa0
Update include/ensmallen_bits/cmaes/pop_cmaes_impl.hpp per suggestion
conradsnicta Nov 28, 2024
70f2064
Update include/ensmallen_bits/cmaes/pop_cmaes_impl.hpp per suggestion
conradsnicta Nov 28, 2024
8749c95
Update include/ensmallen_bits/cmaes/pop_cmaes_impl.hpp per suggestion
conradsnicta Nov 28, 2024
2456a4b
Update include/ensmallen_bits/cmaes/pop_cmaes_impl.hpp per suggestion
conradsnicta Nov 28, 2024
61d0a73
Update include/ensmallen_bits/cmaes/pop_cmaes_impl.hpp per suggestion
conradsnicta Nov 28, 2024
13fc2be
Merge branch 'mlpack:master' into restart-ipop-bipop
beny-bee Nov 28, 2024
e0ceb9e
Update HISTORY.md
beny-bee Nov 28, 2024
57da5eb
Change CMAES to CMA-ES in other places too.
rcurtin Nov 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 138 additions & 0 deletions doc/optimizers.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ approxOptimizer.Optimize(f, coordinates);

#### See also:

* [BIPOP_CMAES](#bipopcmaes)
* [CMAES](#cmaes)
* [IPOP_CMAES](#ipopcmaes)
conradsnicta marked this conversation as resolved.
Show resolved Hide resolved
* [Improving Evolution Strategies through Active Covariance Matrix Adaptation](https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.114.4239&rep=rep1&type=pdfn)
* [Evolution strategy in Wikipedia](https://en.wikipedia.org/wiki/Evolution_strategy)

Expand Down Expand Up @@ -778,6 +780,72 @@ optimizer2.Optimize(f, coordinates);
* [SGD in Wikipedia](https://en.wikipedia.org/wiki/Stochastic_gradient_descent)
* [SGD](#standard-sgd)

## BIPOP_CMAES
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more documentation bit I realized; can you add BIPOP_CMAES and IPOP_CMAES to the list of optimizers for separable functions in function_types.md? Thanks 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just did that, also added ActiveCMAES which wasn't added.

Also, had to increase a bit the margin of the tests as in 2 environments it was failing

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable.

conradsnicta marked this conversation as resolved.
Show resolved Hide resolved

*An optimizer for [separable functions](#separable-functions).*
beny-bee marked this conversation as resolved.
Show resolved Hide resolved

BIPOP CMA-ES (Bi-Population CMA-ES) extends the idea of IPOP CMA-ES by using
conradsnicta marked this conversation as resolved.
Show resolved Hide resolved
two intertwined restart strategies: one with an increasing population size and
another maintaining a smaller, variable population size. This strategy allows
BIPOP CMA-ES to adaptively balance exploration and exploitation across the
fitness landscape, and can outperform IPOP. The larger population restarts aim
to explore broadly, improving global search capabilities, while the smaller
populations intensify the search in promising regions.

### Constructors

* `BIPOP_CMAES<`_`SelectionPolicyType, TransformationPolicyType`_`>()`
* `BIPOP_CMAES<`_`SelectionPolicyType, TransformationPolicyType`_`>(`_`lambda, transformationPolicy`_`)`
* `BIPOP_CMAES<`_`SelectionPolicyType, TransformationPolicyType`_`>(`_`lambda, transformationPolicy, batchSize`_`)`
* `BIPOP_CMAES<`_`SelectionPolicyType, TransformationPolicyType`_`>(`_`lambda, transformationPolicy, batchSize, maxIterations, tolerance, selectionPolicy`_`)`
* `BIPOP_CMAES<`_`SelectionPolicyType, TransformationPolicyType`_`>(`_`lambda, transformationPolicy, batchSize, maxIterations, tolerance, selectionPolicy, stepSize`_`)`
* `BIPOP_CMAES<`_`SelectionPolicyType, TransformationPolicyType`_`>(`_`lambda, transformationPolicy, batchSize, maxIterations, tolerance, selectionPolicy, stepSize, maxRestarts`_`)`
* `BIPOP_CMAES<`_`SelectionPolicyType, TransformationPolicyType`_`>(`_`lambda, transformationPolicy, batchSize, maxIterations, tolerance, selectionPolicy, stepSize, maxRestarts, populationFactor`_`)`
* `BIPOP_CMAES<`_`SelectionPolicyType, TransformationPolicyType`_`>(`_`lambda, transformationPolicy, batchSize, maxIterations, tolerance, selectionPolicy, stepSize, maxRestarts, populationFactor, maxFunctionEvaluations`_`)`
conradsnicta marked this conversation as resolved.
Show resolved Hide resolved

### Attributes

| **type** | **name** | **description** | **default** |
|----------|----------|-----------------|-------------|
| `size_t` | **`lambda`** | The population size (0 uses a default size). | `0` |
| `TransformationPolicyType` | **`transformationPolicy`** | Instantiated transformation policy used to map the coordinates to the desired domain. | `TransformationPolicyType()` |
| `size_t` | **`batchSize`** | Batch size to use for the objective calculation. | `32` |
| `size_t` | **`maxIterations`** | Maximum number of iterations. | `1000` |
| `double` | **`tolerance`** | Maximum absolute tolerance to terminate the algorithm. | `1e-5` |
| `SelectionPolicyType` | **`selectionPolicy`** | Instantiated selection policy used to calculate the objective. | `SelectionPolicyType()` |
| `double` | **`stepSize`** | Initial step size. | `0` |
| `size_t` | **`maxRestarts`** | Maximum number of restarts. | `9` |
beny-bee marked this conversation as resolved.
Show resolved Hide resolved
| `double` | **`populationFactor`** | The factor by which the population increases after each restart. | `2.0` |
| `size_t` | **`maxFunctionEvaluations`** | Maximum number of function evaluations. | `1e9` |

The _`SelectionPolicyType`_ and _`TransformationPolicyType`_ template parameters are used to control how the selection of points and the transformation of the decision variables are handled during the optimization process. For more information, check the [CMAES](#cmaes) class. The `lambda`, `transformationPolicy`, `batchSize`, `maxIterations`, `tolerance`, `selectionPolicy`, and `stepSize` are all parameters that affect the underlying CMAES process.
conradsnicta marked this conversation as resolved.
Show resolved Hide resolved

#### Examples:

<details open>
<summary>Click to collapse/expand example code.
</summary>

```c++
RosenbrockFunction f;
arma::mat coordinates = f.GetInitialPoint();

// IPOP Active CMA-ES
conradsnicta marked this conversation as resolved.
Show resolved Hide resolved
BoundaryBoxConstraint<> b(-1, 1);
BIPOP_CMAES optimizer(0, b, 32, 200, 1e-4, 5, 2, 9, 1e4);
Optimizer.Optimize(f, coordinates);
```

</details>

#### See also:

* [CMAES](#cmaes)
* [ActiveCMAES](#activecmaes)
beny-bee marked this conversation as resolved.
Show resolved Hide resolved
* [IPOP_CMAES](#ipopcmaes)
conradsnicta marked this conversation as resolved.
Show resolved Hide resolved
* [Benchmarking a BI-Population CMA-ES on the BBOB-2009 Function Testbed](https://dl.acm.org/doi/pdf/10.1145/1570256.1570333)
* [Evolution strategy in Wikipedia](https://en.wikipedia.org/wiki/Evolution_strategy)

## Coordinate Descent (CD)

*An optimizer for [partially differentiable functions](#partially-differentiable-functions).*
Expand Down Expand Up @@ -938,6 +1006,9 @@ approxOptimizer.Optimize(f, coordinates);

#### See also:

* [ActiveCMAES](#activecmaes)
* [BIPOP_CMAES](#bipopcmaes)
* [IPOP_CMAES](#ipopcmaes)
conradsnicta marked this conversation as resolved.
Show resolved Hide resolved
* [Completely Derandomized Self-Adaptation in Evolution Strategies](http://www.cmap.polytechnique.fr/~nikolaus.hansen/cmaartic.pdf)
* [CMA-ES in Wikipedia](https://en.wikipedia.org/wiki/CMA-ES)
* [Evolution strategy in Wikipedia](https://en.wikipedia.org/wiki/Evolution_strategy)
Expand Down Expand Up @@ -1484,6 +1555,73 @@ optimizer.Optimize(f, coordinates);
* [HOGWILD!: A Lock-Free Approach to Parallelizing Stochastic Gradient Descent](https://arxiv.org/abs/1106.5730)
* [Sparse differentiable separable functions](#sparse-differentiable-separable-functions)

## IPOP_CMAES
conradsnicta marked this conversation as resolved.
Show resolved Hide resolved

*An optimizer for [separable functions](#separable-functions).*

IPOP CMA-ES (Increasing Population Size CMA-ES) is an extension of the
Covariance Matrix Adaptation Evolution Strategy (CMA-ES). It introduces a
restart mechanism that progressively increases the population size. This
approach is beneficial for optimizing multi-modal functions,
characterized by numerous local optima. The restart mechanism is designed to
improve the adaptability of CMA-ES by improving the likelihood of escaping
local optima, thus increasing the chances of discovering the global optimum.

### Constructors

* `IPOP_CMAES<`_`SelectionPolicyType, TransformationPolicyType`_`>()`
* `IPOP_CMAES<`_`SelectionPolicyType, TransformationPolicyType`_`>(`_`lambda, transformationPolicy`_`)`
* `IPOP_CMAES<`_`SelectionPolicyType, TransformationPolicyType`_`>(`_`lambda, transformationPolicy, batchSize`_`)`
* `IPOP_CMAES<`_`SelectionPolicyType, TransformationPolicyType`_`>(`_`lambda, transformationPolicy, batchSize, maxIterations, tolerance, selectionPolicy`_`)`
* `IPOP_CMAES<`_`SelectionPolicyType, TransformationPolicyType`_`>(`_`lambda, transformationPolicy, batchSize, maxIterations, tolerance, selectionPolicy, stepSize`_`)`
* `IPOP_CMAES<`_`SelectionPolicyType, TransformationPolicyType`_`>(`_`lambda, transformationPolicy, batchSize, maxIterations, tolerance, selectionPolicy, stepSize, maxRestarts`_`)`
* `IPOP_CMAES<`_`SelectionPolicyType, TransformationPolicyType`_`>(`_`lambda, transformationPolicy, batchSize, maxIterations, tolerance, selectionPolicy, stepSize, maxRestarts, populationFactor`_`)`
* `IPOP_CMAES<`_`SelectionPolicyType, TransformationPolicyType`_`>(`_`lambda, transformationPolicy, batchSize, maxIterations, tolerance, selectionPolicy, stepSize, maxRestarts, populationFactor, maxFunctionEvaluations`_`)`
conradsnicta marked this conversation as resolved.
Show resolved Hide resolved

### Attributes

| **type** | **name** | **description** | **default** |
|----------|----------|-----------------|-------------|
| `size_t` | **`lambda`** | The population size (0 uses a default size). | `0` |
| `TransformationPolicyType` | **`transformationPolicy`** | Instantiated transformation policy used to map the coordinates to the desired domain. | `TransformationPolicyType()` |
| `size_t` | **`batchSize`** | Batch size to use for the objective calculation. | `32` |
| `size_t` | **`maxIterations`** | Maximum number of iterations. | `1000` |
| `double` | **`tolerance`** | Maximum absolute tolerance to terminate the algorithm. | `1e-5` |
| `SelectionPolicyType` | **`selectionPolicy`** | Instantiated selection policy used to calculate the objective. | `SelectionPolicyType()` |
| `double` | **`stepSize`** | Initial step size. | `0` |
| `size_t` | **`maxRestarts`** | Maximum number of restarts. | `9` |
| `double` | **`populationFactor`** | The factor by which the population increases after each restart. | `2.0` |
| `size_t` | **`maxFunctionEvaluations`** | Maximum number of function evaluations. | `1e9` |

The _`SelectionPolicyType`_ and _`TransformationPolicyType`_ template parameters are used to control how the selection of points and the transformation of the decision variables are handled during the optimization process. For more information, check the [CMAES](#cmaes) class. The `lambda`, `transformationPolicy`, `batchSize`, `maxIterations`, `tolerance`, `selectionPolicy`, and `stepSize` are all parameters that affect the underlying CMAES process.
conradsnicta marked this conversation as resolved.
Show resolved Hide resolved

#### Examples:

<details open>
<summary>Click to collapse/expand example code.
</summary>

```c++
RosenbrockFunction f;
arma::mat coordinates = f.GetInitialPoint();

// IPOP Active CMA-ES
conradsnicta marked this conversation as resolved.
Show resolved Hide resolved
BoundaryBoxConstraint<> b(-1, 1);
IPOP_CMAES optimizer(0, b, 32, 200, 1e-4, 5, 2, 9, 1e4);
Optimizer.Optimize(f, coordinates);
```

</details>

#### See also:

* [CMAES](#cmaes)
* [ActiveCMAES](#activecmaes)
* [BIPOP_CMAES](#bipopcmaes)
conradsnicta marked this conversation as resolved.
Show resolved Hide resolved
* [A Restart CMA Evolution Strategy With Increasing Population Size](http://www.cmap.polytechnique.fr/~nikolaus.hansen/cec2005ipopcmaes.pdf)
* [Evolution strategy in Wikipedia](https://en.wikipedia.org/wiki/Evolution_strategy)


## IQN

*An optimizer for [differentiable separable functions](#differentiable-separable-functions).*
Expand Down
1 change: 1 addition & 0 deletions include/ensmallen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
#include "ensmallen_bits/bigbatch_sgd/bigbatch_sgd.hpp"
#include "ensmallen_bits/cmaes/cmaes.hpp"
#include "ensmallen_bits/cmaes/active_cmaes.hpp"
#include "ensmallen_bits/cmaes/pop_cmaes.hpp"
#include "ensmallen_bits/cd/cd.hpp"
#include "ensmallen_bits/cne/cne.hpp"
#include "ensmallen_bits/de/de.hpp"
Expand Down
12 changes: 12 additions & 0 deletions include/ensmallen_bits/cmaes/cmaes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,15 @@ class CMAES
double& StepSize()
{ return stepSize; }

//! Get the total number of function evaluations.
size_t FunctionEvaluations() const
{ return functionEvaluations; }
conradsnicta marked this conversation as resolved.
Show resolved Hide resolved

//! Type of Selection Policy.
typedef SelectionPolicyType selectionPolicyType;
//! Type of Transformation Policy.
typedef TransformationPolicyType transformationPolicyType;

conradsnicta marked this conversation as resolved.
Show resolved Hide resolved
private:
//! Population size.
size_t lambda;
Expand All @@ -195,6 +204,9 @@ class CMAES

//! The step size.
double stepSize;

//! Counter for the number of function evaluations.
size_t functionEvaluations = 0;
};

/**
Expand Down
3 changes: 3 additions & 0 deletions include/ensmallen_bits/cmaes/cmaes_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ typename MatType::elem_type CMAES<SelectionPolicyType,
terminate |= Callback::Evaluate(*this, function, transformedIterate,
objective, callbacks...);
}
functionEvaluations += numFunctions;

ElemType overallObjective = currentObjective;
ElemType lastObjective = std::numeric_limits<ElemType>::max();
Expand Down Expand Up @@ -235,6 +236,8 @@ typename MatType::elem_type CMAES<SelectionPolicyType,
transformationPolicy.Transform(mPosition[idx1]), terminate,
callbacks...);

functionEvaluations += lambda;

// Update best parameters.
if (currentObjective < overallObjective)
{
Expand Down
175 changes: 175 additions & 0 deletions include/ensmallen_bits/cmaes/pop_cmaes.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
/**
* @file ipop_cmaes_impl.hpp
* @author Marcus Edel
* @author Benjami Parellada
*
* Definition of the IPOP Covariance Matrix Adaptation Evolution Strategy
* as proposed by A. Auger and N. Hansen in "A Restart CMA Evolution
* Strategy With Increasing Population Size" and BIPOP Covariance Matrix
* Adaptation Evolution Strategy as proposed by N. Hansen in "Benchmarking
* a BI-population CMA-ES on the BBOB-2009 function testbed".
*
* ensmallen is free software; you may redistribute it and/or modify it under
* the terms of the 3-clause BSD license. You should have received a copy of
* the 3-clause BSD license along with ensmallen. If not, see
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
*/
#ifndef ENSMALLEN_CMAES_POP_CMAES_HPP
#define ENSMALLEN_CMAES_POP_CMAES_HPP

#include "cmaes.hpp"

namespace ens {

/**
* Population-based CMA-ES (POP-CMA-ES) that can operate as either IPOP-CMA-ES
* or BIPOP-CMA-ES based on a flag.
*
* IPOP CMA-ES is a variant of the stochastic search algorithm
* CMA-ES - Covariance Matrix Adaptation Evolution Strategy.
* IPOP CMA-ES, also known as CMAES with increasing population size,
* incorporates a restart strategy that involves gradually increasing
* the population size. This approach is specifically designed to
* enhance the performance of CMA-ES on multi-modal functions.
*
* For more information, please refer to:
*
* @code
* @INPROCEEDINGS{1554902,
* author={Auger, A. and Hansen, N.},
* booktitle={2005 IEEE Congress on Evolutionary Computation},
* title={A restart CMA evolution strategy with increasing population size},
* year={2005},
* volume={2},
* number={},
* pages={1769-1776 Vol. 2},
* doi={10.1109/CEC.2005.1554902}}
* @endcode
*
* IPOP CMA-ES can optimize separable functions. For more details, see the
* documentation on function types included with this distribution or on the
* ensmallen website.
*
* BI-Population CMA-ES is a variant of the stochastic search algorithm
* CMA-ES - Covariance Matrix Adaptation Evolution Strategy.
* It implements a dual restart strategy with varying population sizes: one
* increasing and one with smaller, varied sizes. This BI-population approach
* is designed to optimize performance on multi-modal function testbeds by
* leveraging different exploration and exploitation dynamics.
*
* For more information, please refer to:
*
* @code
* @inproceedings{hansen2009benchmarking,
* title={Benchmarking a BI-population CMA-ES on the BBOB-2009 function testbed},
* author={Hansen, Nikolaus},
* booktitle={Proceedings of the 11th annual conference companion on genetic and evolutionary computation conference: late breaking papers},
* pages={2389--2396},
* year={2009}}
* @endcode
*
* BI-Population CMA-ES can efficiently handle separable, multimodal, and weak
* structure functions across various dimensions, as demonstrated in the
* comprehensive results of the BBOB-2009 function testbed. The optimizer
* utilizes an interlaced multistart strategy to balance between broad
* exploration and intensive exploitation, adjusting population sizes and
* step-sizes dynamically.
*/
template<typename SelectionPolicyType = FullSelection,
typename TransformationPolicyType = EmptyTransformation<>,
bool UseBIPOPFlag = true>
class POP_CMAES : public CMAES<SelectionPolicyType, TransformationPolicyType>
{
public:
/**
* Construct the POP-CMA-ES optimizer with the given parameters.
* Other than the same CMA-ES parameters, it also adds the maximum number of
* restarts, the increase in population factor, the maximum number of
* evaluations, as well as a flag indicating to use BIPOP or not.
* The suggested values are not necessarily good for the given problem, so it
* is suggested that the values used be tailored to the task at hand. The
* maximum number of iterations refers to the maximum number of points that
* are processed (i.e., one iteration equals one point; one iteration does not
* equal one pass over the dataset).
*
* @param lambda The initial population size (0 use the default size).
* @param transformationPolicy Instantiated transformation policy used to
* map the coordinates to the desired domain.
* @param batchSize Batch size to use for the objective calculation.
* @param maxIterations Maximum number of iterations allowed.
* @param tolerance Maximum absolute tolerance to terminate algorithm.
* @param selectionPolicy Instantiated selection policy used to calculate the
* objective.
* @param stepSize Starting sigma/step size (will be modified).
* @param populationFactor The factor by which population increases
* after each restart.
* @param maxRestarts Maximum number of restarts.
* @param maxFunctionEvaluations Maximum number of function evaluations.
*/
POP_CMAES(const size_t lambda = 0,
const TransformationPolicyType& transformationPolicy =
TransformationPolicyType(),
const size_t batchSize = 32,
const size_t maxIterations = 1000,
const double tolerance = 1e-5,
const SelectionPolicyType& selectionPolicy = SelectionPolicyType(),
double stepSize = 0,
const double populationFactor = 2,
const size_t maxRestarts = 9,
const size_t maxFunctionEvaluations = 1e9);
beny-bee marked this conversation as resolved.
Show resolved Hide resolved

/**
* Set POP-CMA-ES specific parameters.
*/
template<typename SeparableFunctionType,
typename MatType,
typename... CallbackTypes>
typename MatType::elem_type Optimize(SeparableFunctionType& function,
MatType& iterate,
CallbackTypes&&... callbacks);

//! Get the population factor.
double PopulationFactor() const { return populationFactor; }
//! Modify the population factor.
double& PopulationFactor() { return populationFactor; }

//! Get the maximum number of restarts.
size_t MaxRestarts() const { return maxRestarts; }
//! Modify the maximum number of restarts.
size_t& MaxRestarts() { return maxRestarts; }

//! Get the maximum number of function evaluations.
size_t MaxFunctionEvaluations() const { return maxFunctionEvaluations; }
//! Modify the maximum number of function evaluations.
size_t& MaxFunctionEvaluations() { return maxFunctionEvaluations; }

//! Get the BIPOP mode flag.
static constexpr bool UseBIPOP() { return UseBIPOPFlag; }

private:
//! Population factor
double populationFactor;

//! Maximum number of restarts.
size_t maxRestarts;

//! Maximum number of function evaluations.
size_t maxFunctionEvaluations;

};

// Define IPOP_CMAES and BIPOP_CMAES using the POP_CMAES template
template<typename SelectionPolicyType = FullSelection,
typename TransformationPolicyType = EmptyTransformation<>>
using IPOP_CMAES = POP_CMAES<SelectionPolicyType, TransformationPolicyType, false>;

template<typename SelectionPolicyType = FullSelection,
typename TransformationPolicyType = EmptyTransformation<>>
using BIPOP_CMAES = POP_CMAES<SelectionPolicyType, TransformationPolicyType, true>;

} // namespace ens

// Include implementation.
#include "pop_cmaes_impl.hpp"

#endif
Loading