25 #include <boost/integer_traits.hpp>
26 #include <boost/numeric/conversion/cast.hpp>
31 #include "../exceptions.h"
34 #include "luksan_vlcek_2.h"
36 static int __check__(
int N){
37 if (N - 5 >= boost::integer_traits<int>::const_max / 2) {
38 pagmo_throw(std::overflow_error,
"overflow error");
42 pagmo_throw(value_error,
"problem dimension needs to be at least 16 and even");
47 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>(2*(N-9)),clb);
72 m_cub =
decision_vector(boost::numeric_cast<decision_vector::size_type>(2*(N-9)),cub);
85 for (decision_vector::size_type i=0; i < (x.size()-2)/2; i++)
87 double a1 = x[2*i]*x[2*i] - x[2*i+1];
88 double a2 = x[2*i] - 1.;
89 double a3 = x[2*i+2]*x[2*i+2] - x[2*i+3];
90 double a4 = x[2*i+2] - 1.;
91 double a5 = x[2*i+1] + x[2*i+3] - 2.;
92 double a6 = x[2*i+1] - x[2*i+3];
93 f[0] += 100.*a1*a1 + a2*a2 + 90.*a3*a3 + a4*a4 + 10.*a5*a5 + .1*a6*a6;
100 for (decision_vector::size_type i=0; i < x.size()-9; i++)
102 c[2*i] = (2.+5.*x[i+5]*x[i+5])*x[i+5] + 1.;
103 for (decision_vector::size_type k = (i <= 5) ? 0 : i - 5; k<=i+1; k++) {
104 c[2*i] += x[k]*(x[k]+1.);
106 c[2*i] = c[2*i] - m_cub[i];
107 c[2*i+1] = (2.+5.*x[i+5]*x[i+5])*x[i+5] + 1.;
108 for (decision_vector::size_type k = (i <= 5) ? 0 : i - 5; k<=i+1; k++) {
109 c[2*i+1] += x[k]*(x[k]+1.);
111 c[2*i+1] = m_clb[i] - c[2*i+1];
126 return "Luksan-Vlcek 2";
luksan_vlcek_2(int=16, const double &=0, const double &=0)
Constructor.
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_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 objfun_impl(fitness_vector &, const decision_vector &) const
Implementation of the objective function.
void set_ub(const decision_vector &)
Set upper bounds from pagmo::decision_vector.
std::vector< double > fitness_vector
Fitness vector type.
void compute_constraints_impl(constraint_vector &, const decision_vector &) const
Implementation of the constraint function.
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.
std::vector< double > constraint_vector
Constraint vector type.
Test problem from the Luksan and Vlcek book.
void set_sparsity(int &, std::vector< int > &, std::vector< int > &) const
Implementation of the sparsity structure: automated detection.