Ejemplo n.º 1
0
	def __init__(self, fpath, palantir=True):
		"""
		Constructor of the statistics object. Used to reconstruct trajectory with all its data.
		
		@param fpath relative filepath to the saved trajectory
		"""
		
		if palantir:	# trajectory format from palantir-search
			with open( fpath, 'rb') as f:
				prob, x, ms = cPickle.load(f)
		else:
			# get trajectory
			try:
				best, x = load_trajectory( fpath )
			except:
				raise Exception('ERROR: could not load trajectory')

			# reconstruct a problem instance
			try:
				prob = mga_incipit( seq=[fb.moon for fb in best.traj]+[best.next_moon.moon], tof = [ [0,300] ]*(len(x)/4) )
			except:
				raise Exception('ERROR: could not instantiate problem')
		
		params = lambertization(prob, x)
		self.seq, self.common_mu, self.n_legs, self.initial, self.T, self.t_P, self.r_P, self.v_P, self.DV, self.close_d = lambertization(prob, x)
		if palantir:
			self.best = None
		else:
			self.best = best
		self.x = x
		self.prob = prob
Ejemplo n.º 2
0
def trajectory_file_load(fpath, verbose=False):
	""" used to load a trajectory file dump from tree search module """
	# get trajectory
	try:
		best, x = load_trajectory( fpath )
	except:
		raise Exception('ERROR: could not load trajectory')

	# reconstruct a problem instance
	try:
		prob = mga_incipit( seq=[fb.moon for fb in best.traj]+[best.next_moon.moon], tof = [ [0,300] ]*(len(x)/4) )
	except:
		raise Exception('ERROR: could not instantiate problem')
	
	pop = population(prob)
	pop.push_back(x)
	
	return incipit_stats(pop.champion, fpath.split('/')[-1], 0, *lambertization(prob, x))