示例#1
0
    def __check_all_system_parts_are_casadi_symbolics(self):

        for arg in self.__init__.__code__.co_varnames[1:]:

            if not isinstance(getattr(self, arg), type(ci.mx_sym("a"))):

                raise TypeError('''
Missing input argument for system definition or wrong variable type for an
input argument. Input arguments must be CasADi symbolic types.''')
示例#2
0
    def __check_all_system_parts_are_casadi_symbolics(self):

        for arg in self.__init__.__code__.co_varnames[1:]:

                if not isinstance(getattr(self, arg), type(ci.mx_sym("a"))):

                    raise TypeError('''
Missing input argument for system definition or wrong variable type for an
input argument. Input arguments must be CasADi symbolic types.''')
示例#3
0
    def __generate_scaled_dae(self):

        # ODE time scaling according to:
        # https://groups.google.com/forum/#!topic/casadi-users/AeXzJmBH0-Y

        t_scale = ci.mx_sym("t_scale", 1)

        self.__dae_scaled = {"x": self.__system.x, \
            "p": ci.vertcat([t_scale, self.__system.u]), \
            "ode": t_scale * self.__ode_parameters_applied}
示例#4
0
    def __generate_scaled_dae(self):

        # ODE time scaling according to:
        # https://groups.google.com/forum/#!topic/casadi-users/AeXzJmBH0-Y

        t_scale = ci.mx_sym("t_scale", 1)

        dae_scaled = ci.mx_function(
            "dae_scaled",
            ci.daeIn(x=self.__system.x, p=ci.vertcat([t_scale, self.__system.u])),
            ci.daeOut(ode=t_scale * self.__ode_parameters_applied),
        )

        self.__dae_scaled = dae_scaled.expand()
示例#5
0
    def __init__(self, \
             u = ci.mx_sym("u", 0), \
             q = ci.mx_sym("q", 0), \
             p = None, \
             x = ci.mx_sym("x", 0), \
             eps_u = ci.mx_sym("eps_u", 0), \
             phi = None, \
             f = ci.mx_sym("f", 0), \
             g = ci.mx_sym("g", 0)):
        r'''
        :raises: TypeError, NotImplementedError

        :param u: time-varying controls :math:`u \in \mathbb{R}^{\text{n}_\text{u}}` that are applied piece-wise-constant for each control intervals, and therefor can change from on interval to another, e. g. motor dutycycles, temperatures, massflows (optional)
        :type u: casadi.casadi.MX

        :param q: time-constant controls :math:`q \in \mathbb{R}^{\text{n}_\text{q}}` that are constant over time, e. g. initial mass concentrations of reactants, elevation angles (optional)
        :type q: casadi.casadi.MX

        :param p: unknown parameters :math:`p \in \mathbb{R}^{\text{n}_\text{p}}`
        :type p: casadi.casadi.MX

        :param x: differential states :math:`x \in \mathbb{R}^{\text{n}_\text{x}}` (optional)
        :type x: casadi.casadi.MX

        :param eps_u: input errors :math:`\epsilon_{u} \in \mathbb{R}^{\text{n}_{\epsilon_\text{u}}}` (optional)
        :type eps_u: casadi.casadi.MX

        :param phi: output function :math:`\phi(u, q, x, p) = y \in \mathbb{R}^{\text{n}_\text{y}}`
        :type phi: casadi.casadi.MX

        :param f: explicit system of ODEs :math:`f(u, q, x, p, \epsilon_\text{u}) = \dot{x} \in \mathbb{R}^{\text{n}_\text{x}}` (optional)
        :type f: casadi.casadi.MX

        :param g: equality constraints :math:`g(u, q, p) = 0 \in \mathbb{R}^{\text{n}_\text{g}}` (optional)
        :type g: casadi.casadi.MX


        Depending on the inputs the user provides, the :class:`System`
        is interpreted as follows:


        **Non-dynamic system** (x = None):

        .. math::

            y = \phi(u, q, p)

            0 = g(u, q, p).


        **Explicit ODE system** (x != None):

        .. math::

            y & = & \phi(u, q, x, p) \\

            \dot{x}  & = & f(u, q, x, p, \epsilon_\text{u}).


        '''

        intro()

        print('\n' + '# ' + 23 * '-' + \
            ' casiopeia system definition ' + 22 * '-' + ' #')
        print('\nStarting system definition ...')

        self.u = u
        self.q = q
        self.p = p

        self.x = x

        self.eps_u = eps_u

        self.phi = phi
        self.f = f
        self.g = g

        self.__system_validation()
示例#6
0
    def __init__(self, \
             u = ci.mx_sym("u", 0), \
             q = ci.mx_sym("q", 0), \
             p = None, \
             x = ci.mx_sym("x", 0), \
             eps_u = ci.mx_sym("eps_u", 0), \
             phi = None, \
             f = ci.mx_sym("f", 0), \
             g = ci.mx_sym("g", 0)):


        r'''
        :raises: TypeError, NotImplementedError

        :param u: time-varying controls :math:`u \in \mathbb{R}^{\text{n}_\text{u}}` that are applied piece-wise-constant for each control intervals, and therefor can change from on interval to another, e. g. motor dutycycles, temperatures, massflows (optional)
        :type u: casadi.casadi.MX

        :param q: time-constant controls :math:`q \in \mathbb{R}^{\text{n}_\text{q}}` that are constant over time, e. g. initial mass concentrations of reactants, elevation angles (optional)
        :type q: casadi.casadi.MX

        :param p: unknown parameters :math:`p \in \mathbb{R}^{\text{n}_\text{p}}`
        :type p: casadi.casadi.MX

        :param x: differential states :math:`x \in \mathbb{R}^{\text{n}_\text{x}}` (optional)
        :type x: casadi.casadi.MX

        :param eps_u: input errors :math:`\epsilon_{u} \in \mathbb{R}^{\text{n}_{\epsilon_\text{u}}}` (optional)
        :type eps_u: casadi.casadi.MX

        :param phi: output function :math:`\phi(u, q, x, p) = y \in \mathbb{R}^{\text{n}_\text{y}}`
        :type phi: casadi.casadi.MX

        :param f: explicit system of ODEs :math:`f(u, q, x, p, \epsilon_\text{u}) = \dot{x} \in \mathbb{R}^{\text{n}_\text{x}}` (optional)
        :type f: casadi.casadi.MX

        :param g: equality constraints :math:`g(u, q, p) = 0 \in \mathbb{R}^{\text{n}_\text{g}}` (optional)
        :type g: casadi.casadi.MX


        Depending on the inputs the user provides, the :class:`System`
        is interpreted as follows:


        **Non-dynamic system** (x = None):

        .. math::

            y = \phi(u, q, p)

            0 = g(u, q, p).


        **Explicit ODE system** (x != None):

        .. math::

            y & = & \phi(u, q, x, p) \\

            \dot{x}  & = & f(u, q, x, p, \epsilon_\text{u}).


        '''


        intro()
        
        print('\n' + '# ' + 23 * '-' + \
            ' casiopeia system definition ' + 22 * '-' + ' #')
        print('\nStarting system definition ...')

        self.u = u
        self.q = q
        self.p = p

        self.x = x

        self.eps_u = eps_u

        self.phi = phi
        self.f = f
        self.g = g

        self.__system_validation()