25 #include <boost/integer_traits.hpp>
26 #include <boost/numeric/conversion/cast.hpp>
32 #include "../exceptions.h"
35 #include "luksan_vlcek_1.h"
37 static int __check__(
int N){
38 if (N - 2 >= boost::integer_traits<int>::const_max / 2) {
39 pagmo_throw(std::overflow_error,
"overflow error");
43 pagmo_throw(value_error,
"problem dimension needs to be at least 3");
48 namespace pagmo {
namespace problem {
67 pagmo_throw(value_error,
"constraints lower bound is higher than the upper bound");
71 m_clb =
decision_vector(boost::numeric_cast<decision_vector::size_type>(N-2),clb);
72 m_cub =
decision_vector(boost::numeric_cast<decision_vector::size_type>(N-2),cub);
85 for (pagmo::decision_vector::size_type i=0; i<x.size()-1; i++)
87 double a1 = x[i]*x[i]-x[i+1];
88 double a2 = x[i] - 1.;
89 f[0] += 100.*a1*a1 + a2*a2;
96 for (pagmo::decision_vector::size_type i=0; i<x.size()-2; i++)
98 c[2 * i] = (3.*std::pow(x[i+1],3.) + 2.*x[i+2] - 5.
99 + std::sin(x[i+1]-x[i+2])*std::sin(x[i+1]+x[i+2]) + 4.*x[i+1]
100 - x[i]*std::exp(x[i]-x[i+1]) - 3.) - m_cub[i];
101 c[2 * i + 1] = - (3.*std::pow(x[i+1],3.) + 2.*x[i+2] - 5.
102 + std::sin(x[i+1]-x[i+2])*std::sin(x[i+1]+x[i+2]) + 4.*x[i+1]
103 - x[i]*std::exp(x[i]-x[i+1]) - 3.) + m_clb[i];
118 return "Luksan-Vlcek 1";
boost::shared_ptr< base > base_ptr
Alias for shared pointer to base problem.
std::vector< double > decision_vector
Decision vector type.
void compute_constraints_impl(constraint_vector &, const decision_vector &) const
Implementation of the constraint function.
std::string get_name() const
Get problem's name.
void set_sparsity(int &, std::vector< int > &, std::vector< int > &) const
Implementation of the sparsity structure: automated detection.
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 estimate_sparsity(const decision_vector &, int &lenG, std::vector< int > &iGfun, std::vector< int > &jGvar) const
Heuristics to estimate the sparsity pattern of the problem.
luksan_vlcek_1(int=3, const double &=-10, const double &=10)
Constructor.
std::vector< double > constraint_vector
Constraint vector type.
void objfun_impl(fitness_vector &, const decision_vector &) const
Implementation of the objective function.
base_ptr clone() const
Clone method.
Test problem from the Luksan and Vlcek book.