26 #include <boost/math/constants/constants.hpp>
28 #include "../exceptions.h"
30 #include "../population.h"
33 static int __check__(
int N)
36 pagmo_throw(value_error,
"the problem id needs to be one of [1..7]");
41 namespace pagmo {
namespace problem {
43 static const double PI_HALF = boost::math::constants::pi<double>() / 2.0;
56 m_problem_number(__check__(id)),
73 switch(m_problem_number)
87 pagmo_throw(value_error,
"Error: There are only 7 test functions in this test suite!");
99 switch(m_problem_number)
106 f23_objfun_impl(f,x);
113 f56_objfun_impl(f,x);
119 pagmo_throw(value_error,
"Error: There are only 7 test functions in this test suite!");
128 for(decision_vector::size_type i = 0; i < x.size(); ++i) {
129 y += pow(x[i] - 0.5, 2) - cos(20 * boost::math::constants::pi<double>() * (x[i] - 0.5));
131 return 100.0 * (y + x.size());
137 for(decision_vector::size_type i = 0; i < x.size(); ++i) {
138 y += pow(x[i] - 0.5, 2);
146 for(decision_vector::size_type i = 0; i < x.size(); ++i) {
158 for(decision_vector::size_type i = 0; i < x.size(); ++i) {
161 return (9.0 / x.size()) * y;
165 double dtlz::h7_func(
const fitness_vector &f,
const double g)
const
171 for(decision_vector::size_type i = 0; i < f.size() - 1; ++i) {
172 y += (f[i] / (1.0 + g)) * (1.0 + sin(3 * boost::math::constants::pi<double>() * f[i]) );
194 f[0] = 0.5 * (1.0 + g);
201 f[i] = 0.5 * (1.0 + g);
205 f[i] *= 1 - x[f.size() - (i+1)];
208 f[f.size()-1] = 0.5 * (1 - x[0]) * (1.0 + g);
226 f[0] *= cos(x[i] * PI_HALF);
232 f[i] *= cos(x[j] * PI_HALF);
234 f[i] *= sin(x[f.size() - (i+1)] * PI_HALF);
237 f[f.size()-1] = (1.0 + g) * sin(x[0] * PI_HALF);
256 f[0] *= cos(pow(x[i],m_alpha) * PI_HALF);
262 f[i] *= cos(pow(x[j], m_alpha) * PI_HALF);
264 f[i] *= sin(pow(x[f.size() - (i+1)], m_alpha) * PI_HALF);
267 f[f.size()-1] = (1.0 + g) * sin(pow(x[0],m_alpha) * PI_HALF);
288 t = 1.0 / (2.0 * (1.0 + g));
291 theta[i] = t + ((g * x[i]) / (1.0 + g));
297 f[0] *= cos(theta[i] * PI_HALF);
303 f[i] *= cos(theta[j] * PI_HALF);
305 f[i] *= sin(theta[f.size() - (i+1)] * PI_HALF);
308 f[f.size()-1] = (1.0 + g) * sin(theta[0] * PI_HALF);
322 g = 1.0 + g_func(x_M);
329 f[f.size()-1] = (1.0 + g) * h7_func(f, g);
335 std::string retval(
"DTLZ");
336 retval.append(boost::lexical_cast<std::string>(m_problem_number));
boost::shared_ptr< base > base_ptr
Alias for shared pointer to base problem.
std::vector< double > decision_vector
Decision vector type.
std::string get_name() const
Get problem's name.
Base DTLZ Multi-objective optimization problem.
dtlz(size_type id=1, size_type k=5, fitness_vector::size_type fdim=3, const size_t alpha=100)
base_ptr clone() const
Clone method.
size_type get_dimension() const
Return global dimension.
void set_lb(const decision_vector &)
Set lower bounds from pagmo::decision_vector.
void set_ub(const decision_vector &)
Set upper bounds from pagmo::decision_vector.
std::vector< double > fitness_vector
Fitness vector type.
void objfun_impl(fitness_vector &, const decision_vector &) const
Implementation of the objective function.
f_size_type get_f_dimension() const
Return fitness dimension.
decision_vector::size_type size_type
Problem's size type: the same as pagmo::decision_vector's size type.