Ejemplo n.º 1
0
def run(n_restarts=5):
    from PyGMO import algorithm, island, population
    prob = earthToMars()
    algo = algorithm.scipy_slsqp(max_iter=500, acc=1e-5)
    # algo.screen_output = True
    algo2 = algorithm.mbh(algo, n_restarts, 0.005)
    algo2.screen_output = True

    pop = population(prob)

    pop.push_back((-3.810404036178629e-05, 8.036667366434322e-05, 0, -0.00011631957922519811, -0.0003960700040113729, 0, 0.00014343900668268246, -0.00039460589468829016, 0, 0.0004133243825183847, -0.0002676479632615287, 0, -6.353773946676955e-05, -0.0004027302771161609, 0, -0.00019483461157664088, -0.0003938299142410649, 0, 0.0003740376551173652, -0.00045439735580127933, 0, 0.00026271994456226056, -4.17413726080276e-05, 0, 0.0004025294016016401, 9.22186764465555e-05, 0, 0.0004379362102351141, -8.202101747983173e-05, 0, 2.0842990495214604e-05, -1.927554372930426e-05, 0, -2.392388475139966e-05, -6.3420840462436174e-06, 0))
    pop.push_back((0.00018354551497353738, 0.0002897005581203533, 0, 9.385407683672441e-05, -0.0004375546286935724, 0, -0.00017406053466786356, -0.0004055793819144533, 0, 7.811816626063441e-05, -0.00028869842254392053, 0, 0.000280132941671916, -0.00045467528344872834, 0, 0.00031161406626870487, -0.0004418005074233615, 0, 0.00016912620000403375, -0.00045156036938030775, 0, 0.00043500734938167605, -4.4611940286304056e-05, 0, 0.00023373694896547512, 4.622353180355802e-06, 0, 0.00043504614537196785, -0.00042017445674379463, 0, 0.00016822207354911628, 0.00010574669088542543, 0, 2.1129649656070842e-05, 0.00020199652091584146, 0))
    # pop.push_back((301.93091863294785, 0.0016076262089444425, 0.0015896115913838728, 0.0))
    # pop.push_back((420.2372419060117, 0.010494326408284994, 0.0044382506954818565, 0.0))
    # pop.push_back((411.21323621411335, 0.008748839048462907, 0.0033290148214346503, 0.0))
    # pop.push_back((395.8283718212657, 0.006450877568564355, 0.002069880891910152, 0.0))
    # pop.push_back((319.95400029222867, 0.0016702166037494744, 0.0013676901851197968, 0.0))
    # pop.push_back((319.5113399461457, 0.00166499548529299, 0.0013736935829129556, 0.0))
    # pop.push_back((320.0969905134936, 0.001671977113629641, 0.001365741362825864, 0.0))
    # pop.push_back((324.8947207784664, 0.0017420256877963634, 0.0013024051696600683, 0.0))

    isl = island(algo2,pop)
    print("Running Monotonic Basin Hopping .... this will take a while.")
    isl.evolve(1)
    isl.join()
    print("Is the solution found a feasible trajectory? " +
          str(prob.feasibility_x(isl.population.champion.x)))
    return isl.population.champion.x
Ejemplo n.º 2
0
def run(n_restarts=5):
    from PyGMO import algorithm, island, population
    prob = earthToMars()
    algo = algorithm.scipy_slsqp(max_iter=500, acc=1e-5)
    # algo.screen_output = True
    algo2 = algorithm.mbh(algo, n_restarts, 0.005)
    algo2.screen_output = True
    pop = population(prob)

    pop.push_back((320.33563525584435, 0.0016748335274261476, 0.0013627675495311467, 0.0))
    pop.push_back((301.93091863294785, 0.0016076262089444425, 0.0015896115913838728, 0.0))
    pop.push_back((301.93091863294785, 0.0016076262089444425, 0.0015896115913838728, 0.0))
    pop.push_back((420.2372419060117, 0.010494326408284994, 0.0044382506954818565, 0.0))
    pop.push_back((411.21323621411335, 0.008748839048462907, 0.0033290148214346503, 0.0))
    pop.push_back((395.8283718212657, 0.006450877568564355, 0.002069880891910152, 0.0))
    pop.push_back((319.95400029222867, 0.0016702166037494744, 0.0013676901851197968, 0.0))
    pop.push_back((319.5113399461457, 0.00166499548529299, 0.0013736935829129556, 0.0))
    pop.push_back((320.0969905134936, 0.001671977113629641, 0.001365741362825864, 0.0))
    pop.push_back((324.8947207784664, 0.0017420256877963634, 0.0013024051696600683, 0.0))

    isl = island(algo2,pop)
    print("Running Monotonic Basin Hopping .... this will take a while.")
    isl.evolve(1)
    isl.join()
    print("Is the solution found a feasible trajectory? " +
          str(prob.feasibility_x(isl.population.champion.x)))
    return isl.population.champion.x
Ejemplo n.º 3
0
	def run_example3():
		from PyGMO import algorithm, island
		prob = mga_lt_EVMe()
		algo = algorithm.scipy_slsqp(max_iter = 500, acc =1e-5)
		#algo = algorithm.snopt(major_iter=2000, opt_tol=1e-3, feas_tol=1e-9)
		algo2 = algorithm.mbh(algo,5,0.05)
		algo2.screen_output = True
		isl = island(algo2,prob,1)
		print "Running Monotonic Basin Hopping ...."
		isl.evolve(1); isl.join()
		print "Is the solution found a feasible trajectory? " + str(prob.feasibility_x(isl.population.champion.x))
		prob.plot(isl.population.champion.x)
Ejemplo n.º 4
0
	def run_example1():
		from PyGMO import algorithm, island
		prob = mga_lt_earth_mars(nseg=15)
		prob.high_fidelity(True)
		algo = algorithm.scipy_slsqp(max_iter = 500, acc=1e-5)
		#algo = algorithm.snopt(major_iter=1000, opt_tol=1e-6, feas_tol=1e-11)
		algo2 = algorithm.mbh(algo,5,0.05)
		algo2.screen_output = True
		isl = island(algo2,prob,1)
		print "Running Monotonic Basin Hopping .... this will take a while"
		isl.evolve(1); isl.join()
		print "Is the solution found a feasible trajectory? " + str(prob.feasibility_x(isl.population.champion.x))
		prob.plot(isl.population.champion.x)
Ejemplo n.º 5
0
def run_example1(n_restarts=5):
    from PyGMO import algorithm, island
    prob = earthToMars()
    algo = algorithm.scipy_slsqp(max_iter=500, acc=1e-5)
    algo2 = algorithm.mbh(algo, 5, 0.05)
    algo2.screen_output = True
    isl = island(algo2, prob, 1)
    print("Running Monotonic Basin Hopping .... this will take a while.")
    isl.evolve(1)
    isl.join()
    print("Is the solution found a feasible trajectory? " +
          str(prob.feasibility_x(isl.population.champion.x)))
    return isl.population.champion.x
Ejemplo n.º 6
0
	def run_example4():
		from PyGMO import algorithm, island,population
		N=20
		prob = mga_lt_earth_mars_sundmann(nseg=N)
		algo = algorithm.scipy_slsqp(max_iter = 500, acc=1e-5)
		#algo = algorithm.snopt(major_iter=1000, opt_tol=1e-6, feas_tol=1e-11)
		algo2 = algorithm.mbh(algo,5,0.05)
		algo2.screen_output = True
		isl = island(algo2,prob,1)
		print "Running Monotonic Basin Hopping ...."
		isl.evolve(1); isl.join()
		print "Is the solution found a feasible trajectory? " + str(prob.feasibility_x(isl.population.champion.x))
		print isl.population.champion.x
		prob.plot(isl.population.champion.x)
Ejemplo n.º 7
0
 def run_example3():
     from PyGMO import algorithm, island
     prob = mga_lt_EVMe()
     algo = algorithm.scipy_slsqp(max_iter=500, acc=1e-5)
     #algo = algorithm.snopt(major_iter=500, opt_tol=1e-3, feas_tol=1e-9)
     algo2 = algorithm.mbh(algo, 5, 0.05)
     algo2.screen_output = True
     isl = island(algo2, prob, 1)
     print "Running Monotonic Basin Hopping ...."
     isl.evolve(1)
     isl.join()
     print "Is the solution found a feasible trajectory? " + str(
         prob.feasibility_x(isl.population.champion.x))
     prob.plot(isl.population.champion.x)
Ejemplo n.º 8
0
def run_example1(n_restarts=5):

    prob                = mga_lt_earth_mars(nseg=15)
    prob.high_fidelity(True)
    algo                = algorithm.scipy_slsqp(max_iter=500, acc=1e-5)
    algo2               = algorithm.mbh(algo, n_restarts, 0.05)
    algo2.screen_output = True
    isl                 = island(algo2, prob, 1)
    print("Running Monotonic Basin Hopping .... this will take a while.")
    isl.evolve(1)
    isl.join()
    print("Is the solution found a feasible trajectory? " +
          str(prob.feasibility_x(isl.population.champion.x)))
    prob.plot(isl.population.champion.x)
Ejemplo n.º 9
0
def run_example4(sim,n_restarts=5):
    from PyGMO import algorithm, island
    prob = rocketMars1()
    algo = algorithm.scipy_slsqp(max_iter=500, acc=1e-5)
    # algo = algorithm.ipopt(max_iter=500, constr_viol_tol=1e-5,dual_inf_tol=1e-5,compl_inf_tol=1e-5)
    # algo.screen_output = True
    algo2 = algorithm.mbh(algo, n_restarts, 0.05)
    algo2.screen_output = True
    isl = island(algo2, prob, 1)
    print("Running Monotonic Basin Hopping .... this will take a while.")
    isl.evolve(1)
    isl.join()
    print("Is the solution found a feasible trajectory? " +
          str(prob.feasibility_x(isl.population.champion.x)))
    return isl.population.champion.x
Ejemplo n.º 10
0
 def run_example1():
     from PyGMO import algorithm, island
     prob = mga_lt_earth_mars(nseg=15)
     prob.high_fidelity(True)
     algo = algorithm.scipy_slsqp(max_iter=500, acc=1e-5)
     #algo = algorithm.snopt(major_iter=1000, opt_tol=1e-6, feas_tol=1e-11)
     algo2 = algorithm.mbh(algo, 5, 0.05)
     algo2.screen_output = True
     isl = island(algo2, prob, 1)
     print "Running Monotonic Basin Hopping .... this will take a while"
     isl.evolve(1)
     isl.join()
     print "Is the solution found a feasible trajectory? " + str(
         prob.feasibility_x(isl.population.champion.x))
     prob.plot(isl.population.champion.x)
Ejemplo n.º 11
0
 def run_example4():
     from PyGMO import algorithm, island, population
     N = 20
     prob = mga_lt_earth_mars_sundmann(nseg=N)
     algo = algorithm.scipy_slsqp(max_iter=500, acc=1e-5)
     # algo = algorithm.snopt(major_iter=1000, opt_tol=1e-6, feas_tol=1e-11)
     algo2 = algorithm.mbh(algo, 5, 0.05)
     algo2.screen_output = True
     isl = island(algo2, prob, 1)
     print("Running Monotonic Basin Hopping ....")
     isl.evolve(1)
     isl.join()
     print("Is the solution found a feasible trajectory? " +
           str(prob.feasibility_x(isl.population.champion.x)))
     print(isl.population.champion.x)
     prob.plot(isl.population.champion.x)
Ejemplo n.º 12
0
def check_low_thrustable(inci, verbose=False):
	""" Given a incipit_stats object, checks each leg on los_thrustabality. 
	
	It will return a list of tuple, one tuple for each leg. Each tuple 
	contains (feasibility, famous coefficient)."""
	if os.name == 'posix':
		alg = algorithm.snopt(500, feas_tol=1e-9, opt_tol=1e-2, screen_output=False)
	else:
		alg = algorithm.scipy_slsqp(screen_output=False)

	prob = one_lt_leg(t = inci.initial[0], r=inci.initial[1], v=inci.initial[2], high_fidelity=True)
	pop = population(prob, 1)
	pop = alg.evolve(pop)
	feasible = prob.feasibility_x(pop.champion.x)

	feas_list = [ feasible]
	fam_coeff_list = [ (inci.DV[0] / (inci.T[0]*DAY2SEC)) / (0.1 / 2000.0) ]
	
	if verbose:
		print '+++ Checking feasibility of: ' + inci.filename + ' +++'
		print 'Initial leg feasible? --> ' + str(prob.feasibility_x(pop.champion.x))
	
	for i in xrange(1, inci.n_legs):
		prob = one_lt_leg(t = [inci.t_P[i-1], inci.t_P[i]], r=[inci.r_P[i-1], inci.r_P[i]], 
						  v=[inci.v_sc[i-1][0], inci.v_sc[i-1][1]], high_fidelity=True)
		pop = population(prob, 1)
		pop = alg.evolve(pop)
		feasible = feasible and prob.feasibility_x(pop.champion.x)
		
		if verbose:
			print 'Leg no. ' + str(i) + ' feasible? --> ' + str(prob.feasibility_x(pop.champion.x))
		
		# compute famous coefficient
		fam_coeff_list.append( (inci.DV[i] / (inci.T[i]*DAY2SEC)) / (0.1 / 2000.0) )
		feas_list.append(prob.feasibility_x(pop.champion.x))

	if verbose:
		if feasible:
			print 'Feasible!'
		else:
			print 'infeasible...'
	
	return zip(feas_list, fam_coeff_list)
Ejemplo n.º 13
0
def run_example6(n_seg=5):
    """
    This example demonstrates the optimization of a multiple randezvous mission (low-thrust). 
    Such a mission (including more asteroids) is also called asteroid hopping

    The spacecraft performances, as well as the three asteroids visited, are taken from the GTOC7 problem description.
    """
    from PyGMO import algorithm, population
    from PyKEP.trajopt import mr_lt_nep
    from PyKEP import planet_gtoc7

    algo = algorithm.scipy_slsqp(max_iter=500, acc=1e-5, screen_output=True)

    prob = mr_lt_nep(t0=[9600., 9700.],
                     seq=[
                         planet_gtoc7(5318),
                         planet_gtoc7(14254),
                         planet_gtoc7(7422),
                         planet_gtoc7(5028)
                     ],
                     n_seg=n_seg,
                     mass=[800., 2000.],
                     leg_tof=[100., 365.25],
                     rest=[30., 365.25],
                     Tmax=0.3,
                     Isp=3000.,
                     traj_tof=365.25 * 3.,
                     objective='mass',
                     c_tol=1e-05)

    pop = population(prob, 1)
    pop = algo.evolve(pop)

    solution = pop.champion.x
    if prob.feasibility_x(solution):
        print "FEASIBILE!!!"
        ax = prob.plot(solution)
    else:
        print "INFEASIBLE :("
        ax = None

    return prob, solution, ax
Ejemplo n.º 14
0
def run_example6(n_seg=5):
    """
    This example demonstrates the optimization of a multiple randezvous mission (low-thrust).
    Such a mission (including more asteroids) is also called asteroid hopping

    The spacecraft performances, as well as the three asteroids visited, are taken from the GTOC7 problem description.
    """
    from PyGMO import algorithm, population
    from PyKEP.trajopt import mr_lt_nep
    from PyKEP.planet import gtoc7

    algo = algorithm.scipy_slsqp(max_iter=500, acc=1e-5, screen_output=True)

    prob = mr_lt_nep(
        t0=[9600., 9700.],
        seq=[gtoc7(5318), gtoc7(14254), gtoc7(7422), gtoc7(5028)],
        n_seg=n_seg,
        mass=[800., 2000.],
        leg_tof=[100., 365.25],
        rest=[30., 365.25],
        Tmax=0.3,
        Isp=3000.,
        traj_tof=365.25 * 3.,
        objective='mass',
        c_tol=1e-05
    )

    pop = population(prob, 1)
    pop = algo.evolve(pop)

    solution = pop.champion.x
    if prob.feasibility_x(solution):
        print("FEASIBILE!!!")
        ax = prob.plot(solution)
    else:
        print("INFEASIBLE :(")
        ax = None

    return prob, solution, ax
Ejemplo n.º 15
0
             0.35180899558417034, 1.6036558613069618)
        print(x)
        print('-' * 50)
    trajs = int(sys.argv[1])

    n_th = 1
    if len(sys.argv) > 2:
        n_th = int(sys.argv[2])

    screen_output = False
    snopt_algo = algorithm.snopt(400,
                                 opt_tol=1e-3,
                                 feas_tol=1e-6,
                                 screen_output=screen_output)
    sci_algo = algorithm.scipy_slsqp(max_iter=30,
                                     acc=1E-8,
                                     epsilon=1.49e-08,
                                     screen_output=screen_output)

    if len(sys.argv) != 4 or sys.argv[3] == 'simple':
        run_multithread(landing_problem,
                        trajs,
                        n_th,
                        initial_bounds,
                        'data/' + filedir,
                        display=True,
                        algo=sci_algo)
    elif sys.argv[3] == 'simple_qc':
        run_multithread(landing_problem,
                        trajs,
                        n_th,
                        initial_bounds,
Ejemplo n.º 16
0
        walk_bounds = [x0b, y0b, vx0b, vy0b, theta0, omega0, m0b]
        filedir = 'falcon'
        x =  (0.0004063623657985068, -0.015166893186127163, 0.00047398741968363283, -0.0815609687198395, 0.0005701909839526759, 
            0.00020132959190827737, 0.35180899558417034, 1.6036558613069618)
        print(x)
        print('-'*50)
    trajs = int(sys.argv[1])

    n_th = 1
    if len(sys.argv) > 2:
        n_th = int(sys.argv[2])

    screen_output = False
    snopt_algo = algorithm.snopt(400, opt_tol=1e-3, feas_tol=1e-6,
                                 screen_output=screen_output)
    sci_algo = algorithm.scipy_slsqp(max_iter=30, acc=1E-8, epsilon=1.49e-08,
                                     screen_output=screen_output)

    if len(sys.argv) != 4 or sys.argv[3] == 'simple':
        run_multithread(landing_problem, trajs, n_th, initial_bounds, 'data/' +
                        filedir, display=True, algo=sci_algo)
    elif sys.argv[3] == 'simple_qc':
        run_multithread(landing_problem, trajs, n_th, initial_bounds, 'data/' +
                        filedir, display=True, qc=True, algo=sci_algo, state_step=0.02)
    elif sys.argv[3] == 'rw_qc':
        
        run_multithread(landing_problem, trajs, n_th, initial_bounds, 'data/' +
                        filedir, display=True, qc=True)
    elif sys.argv[3] == 'falcon_qc':
        print(initial_bounds)
        run_multithread(landing_problem, trajs, n_th, initial_bounds, 'data/' +
                        filedir, display=True, qc=True, initial_random_walk=x,