26 #include <boost/random/uniform_real.hpp>
28 #include "../exceptions.h"
30 #include "../population.h"
32 #include "decompose.h"
34 namespace pagmo {
namespace problem {
62 m_adapt_ideal(adapt_ideal)
67 pagmo_throw(value_error,
"non existing decomposition method");
71 pagmo_throw(value_error,
"decompose works only for multi-objective problems, you are trying to decompose a single objective one.");
75 if (m_weights.size() == 0) {
77 rng_double m_drng = rng_generator::get<rng_double>();
80 for(std::vector<double>::size_type i = 0; i<m_weights.size(); ++i) {
81 m_weights[i] = (1-sum) * (1 - pow(boost::uniform_real<double>(0,1)(m_drng), 1.0 / (m_weights.size() - i - 1)));
88 pagmo_throw(value_error,
"the weight vector must have length equal to the fitness size");
93 for (std::vector<double>::size_type i=0; i<m_weights.size(); ++i) {
96 if (fabs(sum-1.0) > 1E-8) {
97 pagmo_throw(value_error,
"the weight vector should sum to 1 with a tolerance of E1-8");
101 for (std::vector<double>::size_type i=0; i<m_weights.size(); ++i) {
102 if (m_weights[i] < 0) {
103 pagmo_throw(value_error,
"the weight vector should contain only positive values");
109 if (m_z.size() == 0) {
114 pagmo_throw(value_error,
"the the reference point vector must have equal length to the fitness size");
154 for (fitness_vector::size_type i=0; i<f.size(); ++i) {
155 if (f[i] < m_z[i]) m_z[i] = f[i];
182 if ( (m_weights.size() != weights.size()) || (original_fit.size() != m_weights.size()) ) {
183 pagmo_throw(value_error,
"Check the sizes of input weights and fitness vector");
188 f[0]+= weights[i]*original_fit[i];
194 (weights[i]==0) ? (weight = 1e-4) : (weight = weights[i]);
195 tmp = weight * fabs(original_fit[i] - m_z[i]);
201 const double THETA = 5.0;
203 double weight_norm = 0.0;
205 d1 += (original_fit[i] - m_z[i]) * weights[i];
206 weight_norm += pow(weights[i],2);
208 weight_norm = sqrt(weight_norm);
209 d1 = fabs(d1)/weight_norm;
213 d2 += pow(original_fit[i] - (m_z[i] + d1*weights[i]/weight_norm), 2);
217 f[0] = d1 + THETA * d2;
228 std::ostringstream oss;
230 oss <<
"\n\tDecomposition method: ";
237 oss <<
"Boundary Interception ";
241 oss <<
"Tchebycheff ";
245 oss << std::endl <<
"\tWeight vector: " << m_weights << std::endl;
246 oss <<
"\tReference point: " << m_z << std::endl;
boost::shared_ptr< base > base_ptr
Alias for shared pointer to base problem.
std::vector< double > decision_vector
Decision vector type.
decompose(const base &=zdt(1, 2), method_type=WEIGHTED, const std::vector< double > &=std::vector< double >(), const std::vector< double > &=std::vector< double >(), const bool=false)
void set_ideal_point(const fitness_vector &f)
Sets the ideal point.
const std::vector< double > & get_weights() const
fitness_vector::size_type f_size_type
Fitness' size type: the same as pagmo::fitness_vector's size type.
std::string get_name() const
Get problem's name.
fitness_vector get_ideal_point() const
Gets the ideal point.
The Boundary Intersection method is used to perform the decomposition.
void compute_original_fitness(fitness_vector &, const decision_vector &) const
Computes the original fitness.
void objfun_impl(fitness_vector &, const decision_vector &) const
Implementation of the objective function.
void compute_decomposed_fitness(fitness_vector &, const fitness_vector &) const
Computes the decomposed fitness.
std::vector< double > fitness_vector
Fitness vector type.
std::string human_readable_extra() const
Extra information in human readable format.
method_type
Mechanism used to perform the problem decomposition.
f_size_type get_f_dimension() const
Return fitness dimension.
The fitness function is the weighted sum of the multiple original fitnesses.
The Tchebycheff method is used to perform the decomposition.
base_ptr clone() const
Clone method.
This rng returns a double in the [0,1[ range.