28 #include "../exceptions.h"
30 #include "../population.h"
34 namespace pagmo {
namespace problem {
54 m_Rotate(rotation), m_normalize_translation(), m_normalize_scale()
56 m_InvRotate = m_Rotate.transpose();
58 Eigen::MatrixXd check = m_InvRotate * m_Rotate;
59 if(!check.isIdentity(1e-5)){
60 pagmo_throw(value_error,
"The input matrix seems not to be orthonormal (to a tolerance of 1e-5)");
63 pagmo_throw(value_error,
"Input problem has an integer dimension. Cannot rotate it.");
65 configure_new_bounds();
77 const std::vector<std::vector<double> > &rotation):
86 m_Rotate(),m_normalize_translation(), m_normalize_scale()
89 pagmo_throw(value_error,
"The input matrix dimensions seem incorrect");
92 pagmo_throw(value_error,
"Input problem has an integer dimension. Cannot rotate it.");
94 m_Rotate.resize(rotation.size(),rotation.size());
96 if(!(rotation.size()==rotation[i].size())){
97 pagmo_throw(value_error,
"The input matrix seems not to be square");
100 m_Rotate(i,j) = rotation[i][j];
103 m_InvRotate = m_Rotate.transpose();
105 Eigen::MatrixXd check = m_InvRotate * m_Rotate;
106 if(!check.isIdentity(1e-5)){
107 pagmo_throw(value_error,
"The input matrix seems not to be orthonormal (to a tolerance of 1e-5)");
109 configure_new_bounds();
125 p.get_ic_dimension(),
127 m_normalize_translation(), m_normalize_scale()
130 m_Rotate = Eigen::MatrixXd::Random(dim, dim).householderQr().householderQ();
131 m_InvRotate = m_Rotate.transpose();
133 Eigen::MatrixXd check = m_InvRotate * m_Rotate;
134 if(!check.isIdentity(1e-5)){
135 pagmo_throw(value_error,
"The input matrix seems not to be orthonormal (to a tolerance of 1e-5)");
138 pagmo_throw(value_error,
"Input problem has an integer dimension. Cannot rotate it.");
140 configure_new_bounds();
159 void rotated::configure_new_bounds()
165 m_normalize_translation.push_back(mean_t);
166 m_normalize_scale.push_back(spread_t/2);
179 if (m_normalize_scale[i] == 0) {
183 normalized_x[i] = (x[i] - m_normalize_translation[i]) / m_normalize_scale[i];
196 denormalized_x[i] = (x_normed[i] * m_normalize_scale[i]) + m_normalize_translation[i];
198 return denormalized_x;
220 Eigen::VectorXd x_normed_vec = Eigen::VectorXd::Zero(x_normed.size());
221 Eigen::VectorXd x_derotated_vec;
223 x_normed_vec(i) = x_normed[i];
225 x_derotated_vec = m_InvRotate * x_normed_vec;
230 x_derotated[i] = x_derotated_vec(i);
260 std::ostringstream oss;
262 oss <<
"\n\tRotation matrix: " << std::endl;
263 if (m_Rotate.cols() > 5) {
264 oss << m_Rotate.block(0,0,5,5) << std::endl;
265 oss <<
"..." << std::endl;
268 oss << m_Rotate << std::endl;
std::string human_readable_extra() const
Extra human readable info for the problem.
boost::shared_ptr< base > base_ptr
Alias for shared pointer to base problem.
std::vector< double > decision_vector
Decision vector type.
decision_vector derotate(const decision_vector &) const
rotated(const base &, const Eigen::MatrixXd &)
size_type get_dimension() const
Return global dimension.
const Eigen::MatrixXd & get_rotation_matrix() const
std::string get_name() const
Get problem's name.
base_ptr clone() const
Clone method.
size_type get_i_dimension() const
Return integer dimension.
std::vector< double > fitness_vector
Fitness vector type.
std::vector< double > constraint_vector
Constraint vector type.
void compute_constraints_impl(constraint_vector &, const decision_vector &) const
void objfun_impl(fitness_vector &, const decision_vector &) const
const decision_vector & get_lb() const
Lower bounds getter.
void set_bounds(const decision_vector &, const decision_vector &)
Bounds setter from pagmo::decision_vector.
decision_vector::size_type size_type
Problem's size type: the same as pagmo::decision_vector's size type.