27 #include <boost/integer_traits.hpp>
28 #include <boost/numeric/conversion/bounds.hpp>
29 #include <boost/numeric/conversion/cast.hpp>
33 #include <keplerian_toolbox/sims_flanagan/codings.h>
34 #include <keplerian_toolbox/planet/jpl_low_precision.h>
36 #include "../exceptions.h"
39 #include "earth_planet.h"
44 namespace pagmo {
namespace problem {
47 earth_planet::earth_planet(
int segments, std::string target,
const double &ctol) :
base(base_format(1,segments,1000).size(), 0, 1, 6 + segments + 1 +1, segments+2,ctol),
48 encoding(1,segments,1000), vmax(3000),n_segments(segments)
54 lb_v[encoding.leg_start_epoch_i(0)[0]] = 0;
55 ub_v[encoding.leg_start_epoch_i(0)[0]] = 1000;
58 lb_v[encoding.leg_end_epoch_i(0)[0]] = 500;
59 ub_v[encoding.leg_end_epoch_i(0)[0]] = 1500;
62 std::vector<int> tmp = encoding.leg_start_velocity_i(0);
63 for (std::vector<int>::size_type i = 0; i < tmp.size() ; ++i)
70 tmp = encoding.leg_end_velocity_i(0);
71 for (std::vector<int>::size_type i = 0; i < tmp.size() ; ++i)
78 for (
int j = 0; j<encoding.n_segments(0); ++j)
80 tmp = encoding.segment_thrust_i(0,j);
81 for (std::vector<int>::size_type i = 0; i < tmp.size() ; ++i)
91 std::vector<planet_ptr> sequence;
92 sequence.push_back(planet_ptr(
new jpl_lp(
"earth")));
93 sequence.push_back(planet_ptr(
new jpl_lp(target)));
94 trajectory = fb_traj(sequence,segments,1000,0.05,boost::numeric::bounds<double>::highest());
106 trajectory.init_from_full_vector(x.begin(),x.end(),encoding);
107 f[0] = trajectory.get_leg(0).evaluate_dv() / 1000;
114 trajectory.init_from_full_vector(x.begin(),x.end(),encoding);
117 trajectory.evaluate_all_mismatch_con(c.begin(), c.begin() + 7);
118 for (
int i=0; i<3; ++i) c[i]/=ASTRO_AU;
119 for (
int i=3; i<6; ++i) c[i]/=ASTRO_EARTH_VELOCITY;
122 trajectory.get_leg(0).get_throttles_con(c.begin() + 6, c.begin() + 6 + n_segments);
125 c[6 + n_segments] = (trajectory.evaluate_leg_vinf2_i(0) - vmax*vmax) / ASTRO_EARTH_VELOCITY / ASTRO_EARTH_VELOCITY;
128 c[7 + n_segments] = trajectory.get_leg(0).get_t_i().mjd2000() - trajectory.get_leg(0).get_t_f().mjd2000();
136 for (pagmo::decision_vector::size_type i = 0; i<x0.size(); ++i)
146 return "Earth-Planet";
boost::shared_ptr< base > base_ptr
Alias for shared pointer to base problem.
std::vector< double > decision_vector
Decision vector type.
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 compute_constraints_impl(constraint_vector &, const decision_vector &) const
Implementation of the constraint function.
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.
std::vector< double > constraint_vector
Constraint vector type.
const decision_vector & get_ub() const
Upper bounds getter.
std::string get_name() const
Get problem's name.
void objfun_impl(fitness_vector &, const decision_vector &) const
Implementation of the objective function.
const decision_vector & get_lb() const
Lower bounds getter.
void set_bounds(const decision_vector &, const decision_vector &)
Bounds setter from pagmo::decision_vector.
base_ptr clone() const
Clone method.
earth_planet(int=10, std::string="mars", const double &=1E-9)
Constructor.