26 #include <boost/math/constants/constants.hpp>
30 #include <boost/lexical_cast.hpp>
31 #include <keplerian_toolbox/core_functions/propagate_lagrangian.h>
32 #include <keplerian_toolbox/astro_constants.h>
33 #include <keplerian_toolbox/lambert_problem.h>
34 #include <keplerian_toolbox/core_functions/array3D_operations.h>
36 #include "mga_target_event.h"
39 namespace pagmo {
namespace problem {
41 mga_target_event::mga_target_event(
42 const kep_toolbox::plantes::planet_ptr start,
43 const kep_toolbox::planet::planet_ptr end,
44 const kep_toolbox::epoch t_end,
46 bool discount_launcher
47 ):base(6), m_start(start), m_end(end), m_t_end(t_end), m_T_max(T_max), m_discount_launcher(discount_launcher)
50 if (start->get_mu_central_body() != end->get_mu_central_body()) {
51 pagmo_throw(value_error,
"The planets do not all have the same mu_central_body");
56 pagmo_throw(value_error,
"T_max must be larger than zero");
61 lb[0] = 1.; lb[5] = 1e-5;
62 ub[0] = T_max; ub[2] = 12000.0; ub[5] = 1-1e-5;
68 mga_target_event::mga_target_event(
const mga_target_event &p) :
base(p.get_dimension()), m_t_end(p.m_t_end), m_T_max(p.m_T_max), m_discount_launcher(p.m_discount_launcher)
71 m_start = p.m_start->clone();
72 m_end = p.m_end->clone();
85 double tw = x[0]*x[1];
88 kep_toolbox::epoch t0 = kep_toolbox::epoch(m_t_end.mjd2000() - x[0]);
89 double tof = (x[0] - tw);
91 kep_toolbox::epoch t1 = kep_toolbox::epoch(t0.mjd2000() + tof);
93 kep_toolbox::array3D r0,v0,r1,v1,v_inf_vett,v0_sc;
94 m_start->eph(t0,r0,v0);
102 double theta = 2*M_PI*x[3];
103 double phi = acos(2. * x[4]-1.) - M_PI / 2.;
104 v_inf_vett[0] = x[2]*cos(phi)*cos(theta);
105 v_inf_vett[1] = x[2]*cos(phi)*sin(theta);
106 v_inf_vett[2] = x[2]*sin(phi);
107 kep_toolbox::sum(v0_sc,v0,v_inf_vett);
116 kep_toolbox::propagate_lagrangian(r0,v0_sc,tof*x[5]*ASTRO_DAY2SEC, ASTRO_MU_SUN);
117 kep_toolbox::lambert_problem l(r0,r1,tof*(1-x[5])*ASTRO_DAY2SEC,ASTRO_MU_SUN,
false,0);
123 kep_toolbox::array3D dv2,dv3;
124 kep_toolbox::diff(dv2,v0_sc,l.get_v1()[0]);
125 double DV2 = kep_toolbox::norm(dv2);
126 kep_toolbox::diff (dv3,v1,l.get_v2()[0]);
127 double DV3 = kep_toolbox::norm(dv3);
128 if (m_discount_launcher) {
129 DV1 = std::max(0.,DV1-6000.);
139 return "MGA-Target-Event";
150 std::ostringstream oss;
151 oss <<
"\n\tStart: " << m_start->get_name();
152 oss <<
"\n\tEnd: " + m_end->get_name();
153 oss <<
"\n\tFinal epoch: " << boost::lexical_cast<std::string>(m_t_end.mjd2000());
154 oss <<
"\n\tDiscount launcher dv?: " << (m_discount_launcher ?
"True" :
"False");
boost::shared_ptr< base > base_ptr
Alias for shared pointer to base problem.
std::vector< double > decision_vector
Decision vector type.
void objfun_impl(fitness_vector &, const decision_vector &) const
Implementation of the objective function.
base_ptr clone() const
Clone method.
std::vector< double > fitness_vector
Fitness vector type.
const decision_vector & get_ub() const
Upper bounds getter.
std::string get_name() const
Get problem's name.
const decision_vector & get_lb() const
Lower bounds getter.
void set_bounds(const decision_vector &, const decision_vector &)
Bounds setter from pagmo::decision_vector.
std::string human_readable_extra() const
Extra human readable info for the problem.