1def run_example5():
2    import pygmo as pg
3    from pykep import epoch
4    from pykep.planet import jpl_lp
5    from pykep.trajopt import mga_1dsm
6
7    # We define an Earth-Venus-Earth problem (single-objective)
8    seq = [jpl_lp('earth'), jpl_lp('venus'), jpl_lp('earth')]
9    udp = mga_1dsm(
10        seq=seq,
11        t0=[epoch(5844), epoch(6209)],
12        tof=[0.7 * 365.25, 3 * 365.25],
13        vinf=[0.5, 2.5],
14        add_vinf_dep=False,
15        add_vinf_arr=True,
16        multi_objective=False
17    )
18
19    pg.problem(udp)
20    # We solve it!!
21    uda = pg.sade(gen=100)
22    archi = pg.archipelago(algo=uda, prob=udp, n=8, pop_size=20)
23    print(
24        "Running a Self-Adaptive Differential Evolution Algorithm .... on 8 parallel islands")
25    archi.evolve(10)
26    archi.wait()
27    sols = archi.get_champions_f()
28    idx = sols.index(min(sols))
29    print("Done!! Solutions found are: ", archi.get_champions_f())
30    udp.pretty(archi.get_champions_x()[idx])
31    udp.plot(archi.get_champions_x()[idx])
32
33if __name__ == "__main__":
34    run_example5()
35