PaGMO  1.1.5
messenger_full.cpp
1 /*****************************************************************************
2  * Copyright (C) 2004-2015 The PaGMO development team, *
3  * Advanced Concepts Team (ACT), European Space Agency (ESA) *
4  * *
5  * https://github.com/esa/pagmo *
6  * *
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 #include <string>
26 #include <keplerian_toolbox/epoch.h>
27 
28 #include "messenger_full.h"
29 #include "../AstroToolbox/mga_dsm.h"
30 
31 namespace pagmo { namespace problem {
32 
33 const int messenger_full::sequence[7] = {3, 2, 2, 1, 1, 1, 1};
34 
36 
39 messenger_full::messenger_full():base(26),problem(orbit_insertion,sequence,7,0,0,0,0.704,2440 + 200)
40 {
41  // Set bounds.
42  const double lb[26] = {1900, 3, 0, 0, 100, 100, 100, 100, 100, 100, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 1.1, 1.1, 1.05, 1.05, 1.05, -M_PI, -M_PI, -M_PI, -M_PI, -M_PI};
43  const double ub[26] = {2200, 4.05, 1, 1, 500, 500, 500, 500, 500, 550, 0.99, 0.99, 0.99, 0.99, 0.99, 0.99, 6, 6, 6, 6, 6, M_PI, M_PI, M_PI, M_PI, M_PI};
44  set_bounds(lb,lb+26,ub,ub+26);
45 
46  // Set sequence
47 
48 }
49 
52 {
53  return base_ptr(new messenger_full(*this));
54 }
55 
58 {
59  MGA_DSM(x, problem,f[0]);
60 }
61 
63 
72 std::string messenger_full::pretty(const std::vector<double> &x) const
73 {
74  double obj = 0;
75  MGA_DSM(x, problem, obj);
76  std::ostringstream s;
77  s.precision(15);
78  s << std::scientific;
79  const size_t seq_size = (x.size() + 2) / 4;
80  pagmo_assert((x.size() + 2) % 4 == 0 && seq_size >= 2);
81  pagmo_assert(problem.sequence.size() == seq_size);
82  s << "Flyby sequence:\t\t\t";
83  for (size_t i = 0; i < seq_size; ++i) {
84  s << problem.sequence[i];
85  }
86  s << '\n';
87  s << "Departure epoch (mjd2000):\t" << x[0] << '\n';
88  s << "Departure epoch:\t\t" << ::kep_toolbox::epoch(x[0],::kep_toolbox::epoch::MJD2000) << '\n';
89  s << "Vinf polar components:\t\t";
90  for (size_t i = 0; i < 3; ++i) {
91  s << x[i + 1] << ' ';
92  }
93  s << '\n';
94  double totaltime = 0;
95  for (size_t i = 0; i < seq_size - 1; ++i) {
96  s << "Leg time of flight:\t\t" << x[i + 4] << '\n';
97  totaltime += x[i + 4];
98  }
99  s << "Total time of flight:\t\t" << totaltime << '\n';
100  for (size_t i = 0; i < seq_size - 2; ++i) {
101  s << "Flyby radius:\t\t\t" << x[i + 2 * (seq_size + 1)] << '\n';
102  }
103  totaltime=x[0];
104  for (size_t i = 0; i < seq_size - 2; ++i) {
105  totaltime += x[i + 4];
106  s << "Flyby date:\t\t\t" << ::kep_toolbox::epoch(totaltime,::kep_toolbox::epoch::MJD2000) << '\n';
107  }
108  for (size_t i = 0; i < seq_size - 2; ++i) {
109  s << "Vinf at flyby:\t\t\t" << std::sqrt(problem.vrelin_vec[i]) << '\n';
110  }
111  for (size_t i = 0; i < seq_size - 1; ++i) {
112  s << "dsm" << i+1 << ":\t\t\t\t" << problem.DV[i+1] << '\n';
113  }
114  s << "Final DV:\t\t\t" << problem.DV.back() << '\n';
115  return s.str();
116 }
117 
119 void messenger_full::set_sparsity(int &lenG, std::vector<int> &iGfun, std::vector<int> &jGvar) const
120 {
121  lenG=26;
122  iGfun.resize(26);
123  jGvar.resize(26);
124  for (int i = 0; i<lenG; ++i)
125  {
126  iGfun[i] = 0;
127  jGvar[i] = i;
128  }
129 }
130 
131 std::string messenger_full::get_name() const
132 {
133  return "Messenger full";
134 }
135 
136 }}
137 
138 BOOST_CLASS_EXPORT_IMPLEMENT(pagmo::problem::messenger_full)
Root PaGMO namespace.
Messenger MGA-DSM Problem (full version)
boost::shared_ptr< base > base_ptr
Alias for shared pointer to base problem.
Definition: problem/base.h:62
void objfun_impl(fitness_vector &, const decision_vector &) const
Implementation of the objective function.
std::vector< double > decision_vector
Decision vector type.
Definition: types.h:40
Base problem class.
Definition: problem/base.h:148
messenger_full()
Problem Constructor.
void set_sparsity(int &, std::vector< int > &, std::vector< int > &) const
Implementation of the sparsity structure.
std::string pretty(const std::vector< double > &x) const
Outputs a stream with the trajectory data.
base_ptr clone() const
Clone method.
std::vector< double > fitness_vector
Fitness vector type.
Definition: types.h:42
std::string get_name() const
Get problem's name.
void set_bounds(const decision_vector &, const decision_vector &)
Bounds setter from pagmo::decision_vector.