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_launch.h"
40 #include <keplerian_toolbox/sims_flanagan/codings.h>
41 #include <keplerian_toolbox/astro_constants.h>
42 #include <keplerian_toolbox/planet/gtoc5.h>
47 namespace pagmo {
namespace problem {
50 gtoc5_launch::gtoc5_launch(
int segments,
int target,
objective obj,
const double &ctol) :
51 base(segments * 3 + 6, 0, 1, 7 + segments + 1, segments + 1,ctol),
52 m_n_segments(segments),m_earth(),m_target(target),m_obj(obj)
78 for (
int i = 6; i < segments * 3 + 6; ++i)
88 m_leg.set_spacecraft(kep_toolbox::sims_flanagan::spacecraft(4000,0.3,3000));
101 f[0] = -x[2] / m_leg.get_spacecraft().get_mass();
103 f[0] = x[1] / 365.25;
112 const epoch epoch_i(x[0],epoch::MJD), epoch_f(x[1] + x[0],epoch::MJD);
113 array3D v0, r0, vf, rf;
114 m_earth.eph(epoch_i,r0,v0);
115 m_target.eph(epoch_f,rf,vf);
120 m_leg.set_leg(epoch_i,sc_state(r0,v0,m_leg.get_spacecraft().get_mass()),x.begin() + 6, x.end(),epoch_f,sc_state(rf,vf,x[2]),ASTRO_MU_SUN);
123 m_leg.get_mismatch_con(c.begin(), c.begin() + 7);
124 for (
int i=0; i<3; ++i) c[i]/=ASTRO_AU;
125 for (
int i=3; i<6; ++i) c[i]/=ASTRO_EARTH_VELOCITY;
126 c[6] /= m_leg.get_spacecraft().get_mass();
128 m_leg.get_throttles_con(c.begin() + 7, c.begin() + 7 + m_n_segments);
129 c[7 + m_n_segments] = (x[3]*x[3] + x[4]*x[4] + x[5]*x[5] - 25000000) / ASTRO_EARTH_VELOCITY / ASTRO_EARTH_VELOCITY;
137 for (pagmo::decision_vector::size_type i = 0; i<x0.size(); ++i)
147 return "GTOC5 Launch phase";
154 const epoch epoch_i(x[0],epoch::MJD), epoch_f(x[1] + x[0],epoch::MJD);
155 array3D v0, r0, vf, rf;
156 m_earth.eph(epoch_i,r0,v0);
157 m_target.eph(epoch_f,rf,vf);
162 m_leg.set_leg(epoch_i,sc_state(r0,v0,m_leg.get_spacecraft().get_mass()),x.begin() + 6, x.end(),epoch_f,sc_state(rf,vf,x[5]),ASTRO_MU_SUN);
164 std::ostringstream oss;
165 oss << m_leg <<
'\n' << m_earth <<
'\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.
void set_sparsity(int &, std::vector< int > &, std::vector< int > &) const
Implementation of the sparsity structure: automated detection.
Launch phase of the GTOC5 roblem.
std::string pretty(const decision_vector &) const
A nice string representation of a chromosome.
size_type get_dimension() const
Return global dimension.
gtoc5_launch(int=10, int=1, objective=MASS, const double &=1E-5)
Constructor.
base_ptr clone() const
Clone method.
std::string get_name() const
Get problem's name.
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.
void compute_constraints_impl(constraint_vector &, const decision_vector &) const
Implementation of the constraint function.
std::vector< double > constraint_vector
Constraint vector type.
const decision_vector & get_ub() const
Upper bounds getter.
objective
Objective function to be minimized.
const decision_vector & get_lb() const
Lower bounds getter.
void set_bounds(const decision_vector &, const decision_vector &)
Bounds setter from pagmo::decision_vector.
void objfun_impl(fitness_vector &, const decision_vector &) const
Implementation of the objective function.