PaGMO  1.1.5
gtoc_2.h
1 /*****************************************************************************
2 * Copyright (C) 2004-2009 The PaGMO development team, *
3 * Advanced Concepts Team (ACT), European Space Agency (ESA) *
4 * http://apps.sourceforge.net/mediawiki/pagmo *
5 * http://apps.sourceforge.net/mediawiki/pagmo/index.php?title=Developers *
6 * http://apps.sourceforge.net/mediawiki/pagmo/index.php?title=Credits *
7 * act@esa.int *
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 * This program is distributed in the hope that it will be useful, *
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17 * GNU General Public License for more details. *
18 * *
19 * You should have received a copy of the GNU General Public License *
20 * along with this program; if not, write to the *
21 * Free Software Foundation, Inc., *
22 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
23 *****************************************************************************/
24 
25 #ifndef PAGMO_PROBLEM_GTOC_2_H
26 #define PAGMO_PROBLEM_GTOC_2_H
27 
28 #include <vector>
29 #include <string>
30 #include <keplerian_toolbox/epoch.h>
31 #include <keplerian_toolbox/planet/gtoc2.h>
32 #include <keplerian_toolbox/sims_flanagan/leg.h>
33 #include <keplerian_toolbox/sims_flanagan/spacecraft.h>
34 #include <keplerian_toolbox/sims_flanagan/throttle.h>
35 
36 #include "../config.h"
37 #include "../serialization.h"
38 #include "../types.h"
39 #include "base.h"
40 
41 
42 namespace pagmo { namespace problem {
43 
44 
46 
53 class __PAGMO_VISIBLE gtoc_2: public base
54 {
55  public:
57  enum objective {MASS,TIME,MASS_TIME};
59  gtoc_2(int = 815, int = 300, int = 110, int = 47, int = 10, objective = MASS_TIME);
60  base_ptr clone() const;
61  //void set_sparsity(int &, std::vector<int> &, std::vector<int> &) const;
62  std::string get_name() const;
63  std::string pretty(const std::vector<double> &x) const;
64  protected:
65  void objfun_impl(fitness_vector &, const decision_vector &) const;
66  void compute_constraints_impl(constraint_vector &, const decision_vector &) const;
67  std::string human_readable_extra() const;
68  private:
69  template <class Iterator>
70  kep_toolbox::sims_flanagan::throttle get_nth_throttle(int n, Iterator it, const kep_toolbox::epoch &start, const kep_toolbox::epoch &end) const
71  {
72  Iterator n_it = it + 3 * n;
73  kep_toolbox::array3D tmp = {{ *n_it, *(n_it + 1), *(n_it + 2)}};
74  const double seg_duration = (end.mjd() - start.mjd()) / m_n_seg;
75  return kep_toolbox::sims_flanagan::throttle( kep_toolbox::epoch(start.mjd() + seg_duration * n,kep_toolbox::epoch::MJD),
76  kep_toolbox::epoch(start.mjd() + seg_duration * (n + 1),kep_toolbox::epoch::MJD),
77  tmp);
78  }
79  private:
80  friend class boost::serialization::access;
81  template <class Archive>
82  void serialize(Archive &ar, const unsigned int)
83  {
84  ar & boost::serialization::base_object<base>(*this);
85  ar & const_cast<int &>(m_n_seg);
86  ar & m_asteroids;
87  ar & m_legs;
88  ar & const_cast< kep_toolbox::sims_flanagan::spacecraft &>(m_spacecraft);
89  ar & m_obj;
90  }
91  const int m_n_seg;
92  std::vector<kep_toolbox::planet::gtoc2> m_asteroids;
93  mutable std::vector< kep_toolbox::sims_flanagan::leg> m_legs;
94  const kep_toolbox::sims_flanagan::spacecraft m_spacecraft;
95  objective m_obj;
96 };
97 
98 } } // namespaces
99 
100 BOOST_CLASS_EXPORT_KEY(pagmo::problem::gtoc_2)
101 
102 #endif
103 
Root PaGMO namespace.
boost::shared_ptr< base > base_ptr
Alias for shared pointer to base problem.
Definition: problem/base.h:62
std::vector< double > decision_vector
Decision vector type.
Definition: types.h:40
Base problem class.
Definition: problem/base.h:148
GTOC_2 Low-Thrust Multiple Asteroid Randezvous Problem.
Definition: gtoc_2.h:53
objective
The objective function can be defined as final mass, final time or mass/time.
Definition: gtoc_2.h:57
std::vector< double > fitness_vector
Fitness vector type.
Definition: types.h:42
std::vector< double > constraint_vector
Constraint vector type.
Definition: types.h:44