-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #204 from IOHprofiler/double-funnel
Double funnel problems
- Loading branch information
Showing
16 changed files
with
357 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#pragma once | ||
|
||
#include "funnel/double_funnel.hpp" | ||
#include "funnel/double_sphere.hpp" | ||
#include "funnel/double_rastrigin.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#pragma once | ||
|
||
#include "ioh/problem/single.hpp" | ||
|
||
|
||
namespace ioh::problem::funnel | ||
{ | ||
namespace functions | ||
{ | ||
inline double shifted_sum(const std::vector<double> &x, const double u) | ||
{ | ||
return std::accumulate(x.begin(), x.end(), 0.0, | ||
[u](const double s, const double xi) { return s + pow(xi - u, 2.0); }); | ||
} | ||
|
||
inline double double_sphere(const std::vector<double> &x, const double u1, const double u2, const double s, | ||
const double d) | ||
{ | ||
return std::min(shifted_sum(x, u1), (d * static_cast<double>(x.size())) + s * shifted_sum(x, u2)); | ||
} | ||
} // namespace functions | ||
|
||
class DoubleFunnel : public RealSingleObjective | ||
{ | ||
double d_; | ||
double s_; | ||
double u1_; | ||
double u2_; | ||
|
||
public: | ||
/* | ||
* @brief Construct a new DoubleSphere object | ||
* @param n_variables the dimension of the problem | ||
* @param name the name of the problem | ||
* @param d the depth of the suboptimal basin (higher values decrease the height) | ||
* @param s the size of the suboptimal basin (smaller values increase the size of the suboptimal basin) | ||
*/ | ||
DoubleFunnel(const int n_variables, const std::string &name, const double d = 0.0, const double s = 1.0) : | ||
RealSingleObjective(MetaData(0, 1, name, n_variables), Bounds<double>(n_variables, -5, 5), {}, | ||
{std::vector<double>(n_variables, 2.5), 0.0}), | ||
d_(d), s_(s), u1_(2.5), u2_(-std::sqrt((std::pow(2.5, 2.0) - d) / s)) | ||
{ | ||
} | ||
|
||
[[nodiscard]] double d() const { return d_; } | ||
[[nodiscard]] double s() const { return s_; } | ||
[[nodiscard]] double u1() const { return u1_; } | ||
[[nodiscard]] double u2() const { return u2_; } | ||
}; | ||
|
||
} // namespace ioh::problem::funnel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
|
||
#include "double_funnel.hpp" | ||
|
||
namespace ioh::problem::funnel | ||
{ | ||
class DoubleRastrigin final : public DoubleFunnel | ||
{ | ||
protected: | ||
double evaluate(const std::vector<double> &x) override | ||
{ | ||
double f_rastrigin = 0.0; | ||
for (const double xi : x) | ||
f_rastrigin += 1 - std::cos(2.0 * IOH_PI * (xi - u1())); | ||
|
||
return functions::double_sphere(x, u1(), u2(), s(), d()) + (10 * f_rastrigin); | ||
} | ||
|
||
public: | ||
/* | ||
* @brief Construct a new DoubleSphere object | ||
* @param n_variables the dimension of the problem | ||
* @param d the depth of the suboptimal basin (higher values decrease the height) | ||
* @param s the size of the suboptimal basin (smaller values increase the size of the suboptimal basin) | ||
*/ | ||
DoubleRastrigin(const int n_variables, const double d = 0.0, const double s = 1.0) : | ||
DoubleFunnel(n_variables, "DoubleRastrigin", d, s) | ||
{ | ||
} | ||
}; | ||
} // namespace ioh::problem::funnel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include "double_funnel.hpp" | ||
|
||
|
||
namespace ioh::problem::funnel | ||
{ | ||
class DoubleSphere final : public DoubleFunnel | ||
{ | ||
protected: | ||
double evaluate(const std::vector<double> &x) override | ||
{ | ||
return functions::double_sphere(x, u1(), u2(), s(), d()); | ||
} | ||
public: | ||
/* | ||
* @brief Construct a new DoubleSphere object | ||
* @param n_variables the dimension of the problem | ||
* @param d the depth of the suboptimal basin (higher values decrease the height) | ||
* @param s the size of the suboptimal basin (smaller values increase the size of the suboptimal basin) | ||
*/ | ||
DoubleSphere(const int n_variables, const double d = 0.0, const double s = 1.0) : DoubleFunnel(n_variables, "DoubleSphere", d, s) { } | ||
}; | ||
} // namespace ioh::problem::funnel |
Oops, something went wrong.