コード例 #1
0
    def __init__(self, epoch_bounds=[0, 1000], A1=gtoc7(1), A2=gtoc7(2), single_objective=False, Tmax = 0.3, Isp = 3000, ms = 1500):
        """
PyKEP.phasing.lambert_metric(epoch_bounds,A1, A2, max_acc, multi_objective)

- epoch_bounds: a list containing the lower and upper bounds in mjd2000 for the launch and arrival epochs
- A1: a planet
- A2: a planet
- Tmax: maximum spacecraft thrust [N]
- Isp: specific impulse of the spacecarft propulsion system [s]
- ms: spacecraft mass at dparture [kg]
- single_objective: if True defines a single objectiove problem (only DV)

Example::

  lm = planet(epoch_bounds=[0, 1000], A1=gtoc7(1), A2=gtoc7(2), single_objective=False, Tmax = 0.3, Isp = 3000, ms = 1500)
        """

        # First we call the constructor of the base class telling
        # essentially to PyGMO what kind of problem to expect (2 objective, 0
        # contraints etc.)
        super(lambert_metric, self).__init__(2, 0, 1 + (not single_objective), 0, 0, 0)

        # then we set the problem bounds (in this case equal for all
        # components)
        self.set_bounds(epoch_bounds[0], epoch_bounds[1])
        self._ast1 = A1
        self._ast2 = A2
        self._Tmax = Tmax
        self._Isp = Isp
        self._ms = ms
        self._UNFEASIBLE = 1e+20
コード例 #2
0
ファイル: _lambert.py プロジェクト: JonathanWillitts/pykep
    def __init__(self, epoch_bounds=[0, 1000], A1=gtoc7(1), A2=gtoc7(2), single_objective=False, max_acc=1e-4):
        """
PyKEP.phasing.lambert_metric(epoch_bounds,A1, A2, max_acc, multi_objective)

- epoch_bounds: a list containing the lower and upper bounds in mjd2000 for the launch and arrival epochs
- A1: a planet
- A2: a planet
- max_acc: maximum acceleration from the thrust [m/s^2]
- single_objective: if True defines a single objectiove problem (only DV)

Example::

  lm = planet(epoch_bounds=[0, 1000], A1=gtoc7(1), A2=gtoc7(2), single_objective=False, max_acc=1e-4)
        """

        # First we call the constructor of the base class telling
        # essentially to PyGMO what kind of problem to expect (1 objective, 0
        # contraints etc.)
        super(lambert_metric, self).__init__(2, 0, 1 + (not single_objective), 0, 0, 0)

        # then we set the problem bounds (in this case equal for all
        # components)
        self.set_bounds(epoch_bounds[0], epoch_bounds[1])
        self._ast1 = A1
        self._ast2 = A2
        self._max_acc = max_acc
        self._UNFEASIBLE = 1e+20
コード例 #3
0
ファイル: _ex6.py プロジェクト: astroHaoPeng/TSX
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
コード例 #4
0
ファイル: _gtop.py プロジェクト: ingmar-getzner/pagmo
def _pl2pl_fixed_time_ctor(self, ast0=gtoc7(7422), ast1=gtoc7(14254), t0=epoch(9818),
    t1=epoch(10118), sc=spacecraft(2000, 0.3, 3000), n_seg=5, obj="fin_m"):
    """
    Constructs a Planet 2 Planet problem with fixed time.
    Chromosome is defined as:

    x = [m_f, Th_0_x, Th_0_y, Th_0_z, .., Th_n_x, Th_n_y, Th_n_z]
    , where 'm_f' is the final mass, while 'Th_i_j' is the throttle component in direction 'j' (x,y,z) for the 'i'-th segment.

    USAGE: problem.pl2pl_fixed_time(ast0=gtoc7(7422), ast1=gtoc7(14254), t0=epoch(9818),
               t1=epoch(10118), sc=spacecraft(2000, 0.3, 3000), n_seg = 5)

    * ast0: first planet
    * ast0: second planet
    * t0: departure epoch (from planet ast0)
    * t1: arrival epoch (to planet ast1)
    * sc: spacecraft object
    * n_seg: number of segments

    """

    # We construct the arg list for the original constructor exposed by
    # boost_python
    from PyGMO.problem._problem import _pl2pl2_fixed_time_objective
    def objective(x):
        return {
            "fin_m": _pl2pl2_fixed_time_objective.FIN_M,
            "crit_m": _pl2pl2_fixed_time_objective.FIN_INI_M
        }[x]

    arg_list = []
    arg_list.append(ast0)
    arg_list.append(ast1)
    arg_list.append(t0)
    arg_list.append(t1)
    arg_list.append(sc)
    arg_list.append(n_seg)
    arg_list.append(objective(obj))
    self._orig_init(*arg_list)
コード例 #5
0
    def __init__(self,
                 epoch_bounds=[0, 1000],
                 A1=gtoc7(1),
                 A2=gtoc7(2),
                 single_objective=False,
                 Tmax=0.3,
                 Isp=3000,
                 ms=1500):
        """
PyKEP.phasing.lambert_metric(epoch_bounds,A1, A2, max_acc, multi_objective)

- epoch_bounds: a list containing the lower and upper bounds in mjd2000 for the launch and arrival epochs
- A1: a planet
- A2: a planet
- Tmax: maximum spacecraft thrust [N]
- Isp: specific impulse of the spacecarft propulsion system [s]
- ms: spacecraft mass at dparture [kg]
- single_objective: if True defines a single objectiove problem (only DV)

Example::

  lm = planet(epoch_bounds=[0, 1000], A1=gtoc7(1), A2=gtoc7(2), single_objective=False, Tmax = 0.3, Isp = 3000, ms = 1500)
        """

        # First we call the constructor of the base class telling
        # essentially to PyGMO what kind of problem to expect (2 objective, 0
        # contraints etc.)
        super(lambert_metric, self).__init__(2, 0, 1 + (not single_objective),
                                             0, 0, 0)

        # then we set the problem bounds (in this case equal for all
        # components)
        self.set_bounds(epoch_bounds[0], epoch_bounds[1])
        self._ast1 = A1
        self._ast2 = A2
        self._Tmax = Tmax
        self._Isp = Isp
        self._ms = ms
        self._UNFEASIBLE = 1e+20
コード例 #6
0
ファイル: _ex6.py プロジェクト: JonathanWillitts/pykep
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
コード例 #7
0
    def __init__(
            self,
            seq=[gtoc7(3413), gtoc7(234), gtoc7(11432)],
            n_seg=5,
            t0=[13000, 13200],
            leg_tof=[1, 365.25 * 3],
            rest=[30., 365.25],
            mass=[800, 2000],
            Tmax=0.3,
            Isp=3000.,
            traj_tof=365.25 * 6,
            objective='mass',
            c_tol=1e-05
    ):
        """
        prob = mr_lt_nep(seq=[PyKEP.gtoc7(3413),PyKEP.gtoc7(234), PyKEP.gtoc7(11432)], n_seg=5, t0=[13000, 13200],
                    leg_tof=[1, 365.25 * 3], rest=[30., 365.25], mass=[800, 2000], Tmax=0.3,
                    Isp=3000., traj_tof=365.25 * 6, objective='mass', c_tol=1e-05)

        * seq: list of PyKEP.planet defining the encounter sequence for the trajectoty (including the initial planet)
        * n_seg: list of integers containing the number of segments to be used for each leg (len(n_seg) = len(seq)-1)
        * t0: list of two PyKEP epochs defining the launch window
        * leg_tof: list of two floats defining the minimum and maximum time of each leg (days)
        * rest: list of two floats defining the minimum and maximum time the spacecraft can rest at one planet (days)
        * mass: list of two floats defining the minimum final spacecraft mass and the starting spacecraft mass (kg)
        * Tmax: maximum thrust (N)
        * Isp: engine specific impulse (sec)
        * traj_tof maximum total mission duration (days)
        * c_tol: tolerance on the constraints
        """
        import PyKEP
        # Number of legs
        n = len(seq) - 1
        # Problem dimension
        dim = (4 + n_seg * 3) * n + 1
        # Number of equality constraints
        dim_eq = 7 * n
        # Number of Inequality constraints
        dim_ineq = n * n_seg + n

        # We call the base problem constaructor
        super(mr_lt_nep, self).__init__(dim, 0, 1,
                                        dim_eq + dim_ineq,  # constraint dimension
                                        dim_ineq,  # inequality constraints
                                        1e-5)  # constrain tolerance

        # We define data members
        self.__seq = seq
        self.__num_legs = n
        self.__nseg = n_seg
        self.__dim_leg = 4 + n_seg * 3
        self.__start_mass = mass[1]
        self.__max_total_time = traj_tof

        # We create n distinct legs objects
        self.__legs = []
        for i in range(n):
            self.__legs.append(PyKEP.sims_flanagan.leg())
        for leg in self.__legs:
            leg.high_fidelity = True
            leg.set_mu(PyKEP.MU_SUN)

        if objective not in ['mass', 'time']:
            raise ValueError("Error in defining the objective. Was it one of mass or time?")
        self.__objective = objective

        # We set the ptoblem box-bounds
        # set leg bounds
        lb_leg = [t0[0], leg_tof[0], rest[0], mass[0]] + [-1] * n_seg * 3
        ub_leg = [t0[1] + traj_tof * n, leg_tof[1], rest[1], mass[1]] + [1] * n_seg * 3

        # set n leg bounds
        lb = lb_leg * n
        ub = [t0[1], leg_tof[1], rest[1], mass[1]] + [1] * n_seg * 3 + ub_leg * (n - 1)

        # set total time bounds
        lb += [1.]
        ub += [self.__max_total_time]

        self.set_bounds(lb, ub)