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..6]");
41 namespace pagmo {
namespace problem {
51 :
base_unc_mo( (__check__(id) != 5) ? param_1 : 30 + 5 * (param_1 - 1), (__check__(id) != 5) ? 0 : 30 + 5 * (param_1 - 1), 2 ),
52 m_problem_number(__check__(id))
55 pagmo_throw(value_error,
"Invalid parameter (problem dimension needs to be higher)");
59 switch(m_problem_number)
85 pagmo_throw(value_error,
"Error: There are only 6 test functions in this test suite!");
99 switch(m_problem_number)
104 return g0123_convergence_metric(x);
106 return g04_convergence_metric(x);
108 return g05_convergence_metric(x);
110 return g06_convergence_metric(x);
112 pagmo_throw(value_error,
"Error: There are only 6 test functions in this test suite!");
120 switch(m_problem_number)
123 g01_objfun_impl(f,x);
126 g02_objfun_impl(f,x);
129 g03_objfun_impl(f,x);
132 g04_objfun_impl(f,x);
135 g05_objfun_impl(f,x);
138 g06_objfun_impl(f,x);
141 pagmo_throw(value_error,
"Error: There are only 6 test functions in this test suite!");
155 c += 1 + (9 * g) / (x.size()-1);
161 pagmo_assert(f.size() == 2);
171 g = 1 + (9 * g) / (x.size()-1);
173 f[1] = g * ( 1 - sqrt(x[0]/g));
179 pagmo_assert(f.size() == 2);
189 g = 1 + (9 * g) / (x.size() - 1);
191 f[1] = g * ( 1 - (x[0]/g)*(x[0]/g));
196 pagmo_assert(f.size() == 2);
206 g = 1 + (9 * g) / (x.size()-1);
208 f[1] = g * ( 1 - sqrt(x[0]/g) - x[0]/g * sin(10 * boost::math::constants::pi<double>() * x[0]));
218 g += x[j]*x[j] - 10 * cos(4 * boost::math::constants::pi<double>() * x[j]);
220 c += 1 + 10 * (x.size()-1) + g;
227 pagmo_assert(f.size() == 2);
230 double g = 1 + 10 * (x.size() - 1);
235 g += x[i]*x[i] - 10 * cos(4 * boost::math::constants::pi<double>() * x[i]);
238 f[1] = g * ( 1 - sqrt(x[0]/g) );
250 std::vector<int> u(n_vectors,0);
251 std::vector<int> v(n_vectors);
255 for (
int j=0; j<5; j++)
282 return c - n_vectors + 1;
287 pagmo_assert(f.size() == 2);
293 std::vector<int> u(n_vectors);
294 std::vector<int> v(n_vectors);
337 f[1] = g * (1.0/f[0]);
350 c += 1 + 9 * pow((g / (x.size()-1)),0.25);
358 pagmo_assert(f.size() == 2);
363 f[0] = 1 - exp(-4*x[0])*pow(sin(6*boost::math::constants::pi<double>()*x[0]),6);
368 g = 1 + 9 * pow((g/(x.size()-1)),0.25);
370 f[1] = g * ( 1 - (f[0]/g)*(f[0]/g));
377 std::string retval(
"ZDT");
378 retval.append(boost::lexical_cast<std::string>(m_problem_number));
base_ptr clone() const
Clone method.
boost::shared_ptr< base > base_ptr
Alias for shared pointer to base problem.
std::vector< double > decision_vector
Decision vector type.
size_type get_dimension() const
Return global dimension.
void set_lb(const decision_vector &)
Set lower bounds from pagmo::decision_vector.
zdt(size_type=1, size_type=30)
Base Class for Unconstrained Multi-objective problems.
std::string get_name() const
Get problem's name.
void set_ub(const decision_vector &)
Set upper bounds from pagmo::decision_vector.
std::vector< double > fitness_vector
Fitness vector type.
double convergence_metric(const decision_vector &) const
Convergence metric for a decision_vector (0 = converged to the optimal front)
void objfun_impl(fitness_vector &, const decision_vector &) const
Implementation of the objective function.
decision_vector::size_type size_type
Problem's size type: the same as pagmo::decision_vector's size type.