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_self_flyby.h"
40 #include <keplerian_toolbox/astro_constants.h>
41 #include <keplerian_toolbox/planet/gtoc5.h>
46 namespace pagmo {
namespace problem {
49 gtoc5_self_flyby::gtoc5_self_flyby(
int segments,
int ast_id,
const double &mjd,
const double &initial_mass,
const double &ctol):
50 base(segments * 3 + 5, 0, 1, 7 + segments + 1, segments + 1,ctol),
51 m_n_segments(segments),m_ast(ast_id),m_mjd(mjd),m_initial_mass(initial_mass)
62 ub_v[1] = m_initial_mass;
65 for (
int i = 2; i < 5; ++i) {
71 for (
int i = 5; i < segments * 3 + 5; ++i)
80 m_leg.set_spacecraft(kep_toolbox::sims_flanagan::spacecraft(m_initial_mass,0.3,3000));
100 const epoch epoch_source(m_mjd,epoch::MJD), epoch_target(m_mjd + x[0],epoch::MJD);
101 array3D v_source, r_source, v_target, r_target;
102 m_ast.eph(epoch_source,r_source,v_source);
103 m_ast.eph(epoch_target,r_target,v_target);
107 m_leg.set_leg(epoch_source,sc_state(r_source,v_source,m_leg.get_spacecraft().get_mass()),x.begin() + 5, x.begin() + 5 + m_n_segments * 3,
108 epoch_target,sc_state(r_target,v_target,x[1]),ASTRO_MU_SUN);
112 m_leg.get_mismatch_con(c.begin(), c.begin() + 7);
113 for (
int i=0; i<3; ++i) c[i]/=ASTRO_AU;
114 for (
int i=3; i<6; ++i) c[i]/=ASTRO_EARTH_VELOCITY;
115 c[6] /= m_leg.get_spacecraft().get_mass();
118 m_leg.get_throttles_con(c.begin() + 7, c.begin() + 7 + m_n_segments);
121 c[7 + m_n_segments] = (160000. - (x[2] * x[2] + x[3] * x[3] + x[4] * x[4]));
129 for (pagmo::decision_vector::size_type i = 0; i<x0.size(); ++i)
139 return "GTOC5 Flyby phase";
146 const epoch epoch_source(m_mjd,epoch::MJD), epoch_target(m_mjd + x[0],epoch::MJD);
147 array3D v_source, r_source, v_target, r_target;
148 m_ast.eph(epoch_source,r_source,v_source);
149 m_ast.eph(epoch_target,r_target,v_target);
153 m_leg.set_leg(epoch_source,sc_state(r_source,v_source,m_leg.get_spacecraft().get_mass()),x.begin() + 5, x.begin() + 5 + m_n_segments * 3,
154 epoch_target,sc_state(r_target,v_target,x[1]),ASTRO_MU_SUN);
156 std::ostringstream oss;
157 oss << m_leg <<
'\n' << m_ast <<
'\n';
boost::shared_ptr< base > base_ptr
Alias for shared pointer to base problem.
std::vector< double > decision_vector
Decision vector type.
std::string pretty(const decision_vector &) const
A nice string representation of a chromosome.
size_type get_dimension() const
Return global dimension.
std::string get_name() const
Get problem's name.
void objfun_impl(fitness_vector &, const decision_vector &) const
Implementation of the objective function.
std::vector< double > fitness_vector
Fitness vector type.
void set_sparsity(int &, std::vector< int > &, std::vector< int > &) const
Implementation of the sparsity structure: automated detection.
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.
void compute_constraints_impl(constraint_vector &, const decision_vector &) const
Implementation of the constraint function.
const decision_vector & get_lb() const
Lower bounds getter.
base_ptr clone() const
Clone method.
void set_bounds(const decision_vector &, const decision_vector &)
Bounds setter from pagmo::decision_vector.
gtoc5_self_flyby(int=5, int=1, const double &=57023, const double &mass=4000, const double &=1E-5)
Constructor.