27 #include <boost/integer_traits.hpp>
28 #include <boost/math/constants/constants.hpp>
29 #include <boost/numeric/conversion/bounds.hpp>
30 #include <boost/numeric/conversion/cast.hpp>
36 #include "../exceptions.h"
39 #include "gtoc5_flyby.h"
40 #include <keplerian_toolbox/astro_constants.h>
41 #include <keplerian_toolbox/planet/gtoc5.h>
46 namespace pagmo {
namespace problem {
49 gtoc5_flyby::gtoc5_flyby(
int segments,
int source,
int flyby,
int target,
const double &lb_epoch,
const double &initial_mass,
objective obj,
const double & tof_ub,
const double &ctol):
50 base(segments * 6 + 8, 0, 1, 14 + 2 * segments + 1, 2 * segments + 1,ctol),
51 m_n_segments(segments),m_source(source),m_flyby(flyby),m_target(target),m_lb_epoch(lb_epoch),m_initial_mass(initial_mass),m_obj(obj)
58 ub_v[0] = m_lb_epoch + 200;
66 ub_v[2] = 365.25 * tof_ub;
70 ub_v[3] = m_initial_mass;
74 ub_v[4] = m_initial_mass;
77 for (
int i = 5; i < 8; ++i) {
83 for (
int i = 8; i < segments * 6 + 8; ++i)
92 m_leg1.set_spacecraft(kep_toolbox::sims_flanagan::spacecraft(m_initial_mass,0.3,3000));
93 m_leg2.set_spacecraft(kep_toolbox::sims_flanagan::spacecraft(m_initial_mass,0.3,3000));
107 }
else if (m_obj ==
TIME) {
119 const epoch epoch_source(x[0],epoch::MJD), epoch_flyby(x[0] + x[1]*x[2],epoch::MJD), epoch_target(x[0] + x[2],epoch::MJD);
120 array3D v_source, r_source, v_flyby, r_flyby, v_target, r_target;
121 m_source.eph(epoch_source,r_source,v_source);
122 m_flyby.eph(epoch_flyby,r_flyby,v_flyby);
126 m_target.eph(epoch_target,r_target,v_target);
127 m_leg1.set_leg(epoch_source,sc_state(r_source,v_source,m_leg1.get_spacecraft().get_mass()),x.begin() + 8, x.begin() + 8 + m_n_segments * 3,
128 epoch_flyby,sc_state(r_flyby,v_flyby,x[3]),ASTRO_MU_SUN);
129 m_leg2.set_leg(epoch_flyby,sc_state(r_flyby,v_flyby,x[3] - 1),x.begin() + 8 + m_n_segments * 3, x.end(),
130 epoch_target,sc_state(r_target,v_target,x[4]),ASTRO_MU_SUN);
133 m_leg1.get_mismatch_con(c.begin(), c.begin() + 7);
134 for (
int i=0; i<3; ++i) c[i]/=ASTRO_AU;
135 for (
int i=3; i<6; ++i) c[i]/=ASTRO_EARTH_VELOCITY;
136 c[6] /= m_leg1.get_spacecraft().get_mass();
138 m_leg2.get_mismatch_con(c.begin() + 7, c.begin() + 14);
139 for (
int i=7; i<10; ++i) c[i]/=ASTRO_AU;
140 for (
int i=10; i<13; ++i) c[i]/=ASTRO_EARTH_VELOCITY;
141 c[13] /= m_leg1.get_spacecraft().get_mass();
144 m_leg1.get_throttles_con(c.begin() + 14, c.begin() + 14 + m_n_segments);
145 m_leg2.get_throttles_con(c.begin() + 14 + m_n_segments, c.begin() + 14 + 2 * m_n_segments);
148 c[14 + 2 * m_n_segments] = (160000. - (x[5] * x[5] + x[6] * x[6] + x[7] * x[7])) / 160000.;
156 for (pagmo::decision_vector::size_type i = 0; i<x0.size(); ++i)
166 return "GTOC5 Flyby phase";
173 const epoch epoch_source(x[0],epoch::MJD), epoch_flyby(x[0] + x[1],epoch::MJD), epoch_target(x[0] + x[1] + x[2],epoch::MJD);
174 array3D v_source, r_source, v_flyby, r_flyby, v_target, r_target;
175 m_source.eph(epoch_source,r_source,v_source);
176 m_flyby.eph(epoch_flyby,r_flyby,v_flyby);
180 m_target.eph(epoch_target,r_target,v_target);
181 m_leg1.set_leg(epoch_source,sc_state(r_source,v_source,m_leg1.get_spacecraft().get_mass()),x.begin() + 8, x.begin() + 8 + m_n_segments * 3,
182 epoch_flyby,sc_state(r_flyby,v_flyby,x[3]),ASTRO_MU_SUN);
183 m_leg2.set_leg(epoch_flyby,sc_state(r_flyby,v_flyby,x[3] - 1),x.begin() + 8 + m_n_segments * 3, x.end(),
184 epoch_target,sc_state(r_target,v_target,x[4]),ASTRO_MU_SUN);
186 std::ostringstream oss;
187 oss << m_leg1 <<
'\n' << m_source <<
'\n' << m_flyby <<
'\n';
188 oss << m_leg2 <<
'\n' << m_flyby <<
'\n' << m_target <<
'\n';
boost::shared_ptr< base > base_ptr
Alias for shared pointer to base problem.
std::vector< double > decision_vector
Decision vector type.
gtoc5_flyby(int=10, int=1, int=2, int=3, const double &=57023, const double &=4000, objective=MASS, const double &tof_ub=3, const double &=1E-5)
Constructor.
void compute_constraints_impl(constraint_vector &, const decision_vector &) const
Implementation of the constraint function.
size_type get_dimension() const
Return global dimension.
void objfun_impl(fitness_vector &, const decision_vector &) const
Implementation of the objective function.
std::string pretty(const decision_vector &) const
A nice string representation of a chromosome.
void set_sparsity(int &, std::vector< int > &, std::vector< int > &) const
Implementation of the sparsity structure: automated detection.
base_ptr clone() const
Clone method.
std::vector< double > fitness_vector
Fitness vector type.
std::string get_name() const
Get problem's name.
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.
const decision_vector & get_lb() const
Lower bounds getter.
void set_bounds(const decision_vector &, const decision_vector &)
Bounds setter from pagmo::decision_vector.
objective
Objective function to be minimized.