Пример #1
0
/**
 * While the chromosome contains all necessary information to describe a trajectory, mission analysits
 * often require a different set of data to understand a trajectory. This method outputs a stream with
 * information on the trajectory that is otherwise 'hidden' in the chromosome
 *
 * \param[in] x chromosome representing the trajectory in the optimization process
 * \returns an std::string with launch dates, DV magnitues and other information on the trajectory
 */
std::string tandem::pretty(const std::vector<double> &x) const
{
	double obj=0;
	std::vector<double> printablex;
	if (tof!=-1) { //constrained problem
		//Here we copy the chromosome into a new vector and we transform its time percentages into days
		copy_of_x = x;
		copy_of_x[4] = x[4]*365.25*tof;
		copy_of_x[5] = x[5]*(365.25*tof-copy_of_x[4]);
		copy_of_x[6] = x[6]*(365.25*tof-copy_of_x[4]-copy_of_x[5]);
		copy_of_x[7] = x[7]*(365.25*tof-copy_of_x[4]-copy_of_x[5]-copy_of_x[6]);
		MGA_DSM(copy_of_x, problem, obj);
		printablex=copy_of_x;
	} else {	//unconstrained problem
		MGA_DSM(x, problem, obj);
		printablex=x;
	}
	std::ostringstream s;
	s.precision(15);
	s << std::scientific;
	const size_t seq_size = (x.size() + 2) / 4;
	pagmo_assert((x.size() + 2) % 4 == 0 && seq_size >= 2);
	pagmo_assert(problem.sequence.size() == seq_size);
	s << "Flyby sequence:\t\t\t";
	for (size_t i = 0; i < seq_size; ++i) {
		s << problem.sequence[i];
	}
	s << '\n';
	s << "Departure epoch (mjd2000):\t" << printablex[0] << '\n';
	s << "Departure epoch:\t\t" << ::kep_toolbox::epoch(printablex[0],::kep_toolbox::epoch::MJD2000) << '\n';
	s << "Vinf polar components:\t\t";
	for (size_t i = 0; i < 3; ++i) {
		s << printablex[i + 1] << ' ';
	}
	s << '\n';
	double totaltime = 0;
	for (size_t i = 0; i < seq_size - 1; ++i) {
		s << "Leg time of flight:\t\t" << printablex[i + 4] << '\n';
		totaltime += printablex[i + 4];
	}
	s << "Total time of flight:\t\t" << totaltime << '\n';
	for (size_t i = 0; i < seq_size - 2; ++i) {
		s << "Flyby radius:\t\t\t" << printablex[i + 2 * (seq_size + 1)] << '\n';
	}
	totaltime=printablex[0];
	for (size_t i = 0; i < seq_size - 2; ++i) {
	totaltime += printablex[i + 4];
		s << "Flyby date:\t\t\t" << ::kep_toolbox::epoch(totaltime,::kep_toolbox::epoch::MJD2000) << '\n';
	}
	for (size_t i = 0; i < seq_size - 2; ++i) {
		s << "Vinf at flyby:\t\t\t" << std::sqrt(problem.vrelin_vec[i]) << '\n';
	}
	for (size_t i = 0; i < seq_size - 1; ++i) {
		s << "dsm" << i+1 << ":\t\t\t\t" << problem.DV[i+1] << '\n';
	}
	s << "Final DV:\t\t\t" << problem.DV.back() << '\n';
	return s.str();
}
Пример #2
0
/// Implementation of the objective function.
void sample_return::objfun_impl(fitness_vector &f, const decision_vector &x) const
{
	//We split the decision vector in the two legs
	std::copy(x.begin(),x.begin()+6,x_leg1.begin());
	std::copy(x.begin()+6,x.begin()+12,x_leg2.begin());

	x_leg1[4] = x_leg1[4] * m_Tmax;
	x_leg2[4] = (m_Tmax - x_leg1[4] - x_leg2[0]) * x_leg2[4];

	//We account for the waiting time
	x_leg2[0] += x_leg1[0] + x_leg1[4];
	double dummy = 0;
	MGA_DSM(x_leg1, m_leg1, dummy);
	MGA_DSM(x_leg2, m_leg2, dummy);
	f[0] = m_leg1.DV[0] + m_leg1.DV[1] + m_leg1.DV[2] +
		m_leg2.DV[0] + m_leg2.DV[1] + std::max(0.0,m_leg2.DV[2] - 5.5);

}
Пример #3
0
/// Computes the Delta-Vs
std::vector<double> sample_return::get_delta_v(const std::vector<double> &x) const {
	//We split the decision vector in the two legs
	std::copy(x.begin(),x.begin()+6,x_leg1.begin());
	std::copy(x.begin()+6,x.begin()+12,x_leg2.begin());

	x_leg1[4] = x_leg1[4] * m_Tmax;
	x_leg2[4] = (m_Tmax - x_leg1[4] - x_leg2[0]) * x_leg2[4];

	//We account for the waiting time
	x_leg2[0] += x_leg1[0] + x_leg1[4];
	double dummy = 0;
	MGA_DSM(x_leg1, m_leg1, dummy);
	MGA_DSM(x_leg2, m_leg2, dummy);
	std::vector<double> retval;
	for (int i=0;i<3;++i) retval.push_back(m_leg1.DV[i]);
	for (int i=0;i<3;++i) retval.push_back(m_leg2.DV[i]);
	return retval;
}
Пример #4
0
std::string sample_return::pretty(const std::vector<double> &x) const
{
	std::ostringstream s;
	s.precision(15);
	s << std::scientific;
	//We split the decision vector in the two legs
	std::copy(x.begin(),x.begin()+6,x_leg1.begin());
	std::copy(x.begin()+6,x.begin()+12,x_leg2.begin());

	x_leg1[4] = x_leg1[4] * m_Tmax;
	x_leg2[4] = (m_Tmax - x_leg1[4] - x_leg2[0]) * x_leg2[4];

	//We account for the waiting time
	x_leg2[0] += x_leg1[0] + x_leg1[4];
	double dummy = 0;
	MGA_DSM(x_leg1, m_leg1, dummy);
	MGA_DSM(x_leg2, m_leg2, dummy);

	s << "Departure epoch (mjd2000):\t" << x[0] << '\n';
	s << "Departure epoch:\t\t" << ::kep_toolbox::epoch(x[0],::kep_toolbox::epoch::MJD2000) << '\n';
	s << "Escape velocity:\t\t" << m_leg1.DV[0] << '\n';
	s << "dsm1 epoch:\t\t\t" << ::kep_toolbox::epoch(x[0] + x[5]*x[4],::kep_toolbox::epoch::MJD2000) << '\n';
	s << "dsm1 magnitude\t\t\t" << m_leg1.DV[1] << " \n";
	s << "Asteroid arrival epoch: \t" << ::kep_toolbox::epoch(x[0] + x[4],::kep_toolbox::epoch::MJD2000) << '\n';
	s << "Breaking manouvre:\t\t" << m_leg1.DV[2] << '\n' << std::endl;

	s << "Departure epoch (mjd2000):\t" << x[0] + x[4] + x[6] << '\n';
	s << "Departure epoch:\t\t" << ::kep_toolbox::epoch(x[0] + x[4] + x[6],::kep_toolbox::epoch::MJD2000) << '\n';
	s << "Escape velocity:\t\t" << m_leg2.DV[0] << '\n';
	s << "dsm2 epoch:\t\t\t" << ::kep_toolbox::epoch(x[0]+x[4]+x[6]+x[11]*x[10],::kep_toolbox::epoch::MJD2000) << '\n';
	s << "dsm2 magnitude\t\t\t" << m_leg2.DV[1] << " \n";
	s << "Earth arrival epoch: \t\t" << ::kep_toolbox::epoch(x[0]+x[4]+x[6]+x[10],::kep_toolbox::epoch::MJD2000) << '\n';
	s << "Arrival Vinf:\t\t\t" << m_leg2.DV[2] << '\n';
	s << "Total time of flight:\t\t" << x[4]+x[6]+x[10] << '\n' << std::endl;

	s << "Earth-ephemerides at departure:\t\t" << m_leg1.r[0][0] << " " << m_leg1.r[0][1] << " " << m_leg1.r[0][2] << std::endl;
	s << "Asteroid-ephemerides at arrival:\t" << m_leg1.r[1][0] << " " << m_leg1.r[1][1] << " " << m_leg1.r[1][2] << std::endl;
	s << "Asteroid-ephemerides at departure:\t" << m_leg2.r[0][0] << " " << m_leg2.r[0][1] << " " << m_leg2.r[0][2] << std::endl;
	s << "Earth-ephemerides at arrival:\t\t" << m_leg2.r[1][0] << " " << m_leg2.r[1][1] << " " << m_leg2.r[1][2] << std::endl;



	return s.str();
}
Пример #5
0
/**
 * While the chromosome contains all necessary information to describe a trajectory, mission analysits
 * often require a different set of data to evaluate its use. This method outputs a stream with
 * information on the trajectory that is otherwise 'hidden' in the chromosome
 *
 * \param[in] x chromosome representing the trajectory in the optimization process
 * \returns an std::string with launch dates, DV magnitues and other information on the trajectory
 */
std::string cassini_2::pretty(const std::vector<double> &x) const
{
	double obj = 0;
	MGA_DSM(x, problem, obj);
	std::ostringstream s;
	s.precision(15);
	s << std::scientific;
	const size_t seq_size = (x.size() + 2) / 4;
	pagmo_assert((x.size() + 2) % 4 == 0 && seq_size >= 2);
	pagmo_assert(problem.sequence.size() == seq_size);
	s << "Flyby sequence:\t\t\t";
	for (size_t i = 0; i < seq_size; ++i) {
		s << problem.sequence[i];
	}
	s << '\n';
	s << "Departure epoch (mjd2000):\t" << x[0] << '\n';
	s << "Departure epoch:\t\t" << ::kep_toolbox::epoch(x[0],::kep_toolbox::epoch::MJD2000) << '\n';
	s << "Vinf polar components:\t\t";
	for (size_t i = 0; i < 3; ++i) {
		s << x[i + 1] << ' ';
	}
	s << '\n';
	double totaltime = 0;
	for (size_t i = 0; i < seq_size - 1; ++i) {
		s << "Leg time of flight:\t\t" << x[i + 4] << '\n';
		totaltime += x[i + 4];
	}
	s << "Total time of flight:\t\t" << totaltime << '\n';
	for (size_t i = 0; i < seq_size - 2; ++i) {
		s << "Flyby radius:\t\t\t" << x[i + 2 * (seq_size + 1)] << '\n';
	}
	totaltime=x[0];
	for (size_t i = 0; i < seq_size - 2; ++i) {
	totaltime += x[i + 4];
		s << "Flyby date:\t\t\t" << ::kep_toolbox::epoch(totaltime,::kep_toolbox::epoch::MJD2000) << '\n';
	}
	for (size_t i = 0; i < seq_size - 2; ++i) {
		s << "Vinf at flyby:\t\t\t" << std::sqrt(problem.vrelin_vec[i]) << '\n';
	}
	for (size_t i = 0; i < seq_size - 1; ++i) {
		s << "dsm" << i+1 << ":\t\t\t\t" << problem.DV[i+1] << '\n';
	}
	s << "Final DV:\t\t\t" << problem.DV.back() << '\n';
	return s.str();
}
Пример #6
0
/// Implementation of the objective function.
void sagas::objfun_impl(fitness_vector &f, const decision_vector &x) const
{
	MGA_DSM(x, problem,f[0]);
}
Пример #7
0
/// Implementation of the objective function.
void tandem::objfun_impl(fitness_vector &f, const decision_vector &x) const
{
	if (tof!=-1) { //constrained problem
		//Here we copy the chromosome into a new vector and we transform its time percentages into days
		copy_of_x = x;
		copy_of_x[4] = x[4]*365.25*tof;
		copy_of_x[5] = x[5]*(365.25*tof-copy_of_x[4]);
		copy_of_x[6] = x[6]*(365.25*tof-copy_of_x[4]-copy_of_x[5]);
		copy_of_x[7] = x[7]*(365.25*tof-copy_of_x[4]-copy_of_x[5]-copy_of_x[6]);
		MGA_DSM(copy_of_x, problem, f[0]);
	} else {	//unconstrained problem
		MGA_DSM(x, problem, f[0]);
	}
	//evaluating the mass from the dvs
	double rE[3];
	double vE[3];
	Planet_Ephemerides_Analytical (x[0],3,rE,vE);
	double VINFE = x[1];
	double udir = x[2];
	double vdir = x[3];
	double vtemp[3];
	vtemp[0]= rE[1]*vE[2]-rE[2]*vE[1];
	vtemp[1]= rE[2]*vE[0]-rE[0]*vE[2];
	vtemp[2]= rE[0]*vE[1]-rE[1]*vE[0];
	double iP1[3];
	double normvE=sqrt(vE[0]*vE[0]+vE[1]*vE[1]+vE[2]*vE[2]);
	iP1[0]=	vE[0]/normvE;
	iP1[1]=	vE[1]/normvE;
	iP1[2]=	vE[2]/normvE;
	double zP1[3];
	double normvtemp=sqrt(vtemp[0]*vtemp[0]+vtemp[1]*vtemp[1]+vtemp[2]*vtemp[2]);
	zP1[0]= vtemp[0]/normvtemp;
	zP1[1]= vtemp[1]/normvtemp;
	zP1[2]= vtemp[2]/normvtemp;
	double jP1[3];
	jP1[0]= zP1[1]*iP1[2]-zP1[2]*iP1[1];
	jP1[1]= zP1[2]*iP1[0]-zP1[0]*iP1[2];
	jP1[2]= zP1[0]*iP1[1]-zP1[1]*iP1[0];
	double theta=2*M_PI*udir; 		//See Picking a Point on a Sphere
	double phi=acos(2*vdir-1)-M_PI/2; //In this way: -pi/2<phi<pi/2 so phi can be used as out-of-plane rotation
	double vinf[3];
	vinf[0]=VINFE*(cos(theta)*cos(phi)*iP1[0]+sin(theta)*cos(phi)*jP1[0]+sin(phi)*zP1[0]);
	vinf[1]=VINFE*(cos(theta)*cos(phi)*iP1[1]+sin(theta)*cos(phi)*jP1[1]+sin(phi)*zP1[1]);
	vinf[2]=VINFE*(cos(theta)*cos(phi)*iP1[2]+sin(theta)*cos(phi)*jP1[2]+sin(phi)*zP1[2]);
	//We rotate it to the equatorial plane
	ecl2equ(vinf,vinf);
	//And we find the declination in degrees
	double normvinf=sqrt(vinf[0]*vinf[0]+vinf[1]*vinf[1]+vinf[2]*vinf[2]);
	double sindelta = vinf[2] / normvinf;
	double declination = asin(sindelta)/M_PI*180;

	//double m_initial = SoyuzFregat(VINFE,declination);
	double m_initial = Atlas501(VINFE,declination);

	//We evaluate the final mass
	double Isp = 312;
	double g0 = 9.80665;
	double sumDVvec=0;

	for(unsigned int i=1;i<=5;i++) {
		sumDVvec=sumDVvec+problem.DV[i];
	}
	double m_final;
	sumDVvec=sumDVvec+0.165; //losses for 3 swgbys + insertion
	m_final = m_initial * exp(-sumDVvec/Isp/g0*1000);
	f[0] = -log(m_final);
}