as well as constraints and boundary conditions on :math:`x`, :math:`u` and the initial conditions state :math:`x(t_0)`.
as well as constraints and boundary conditions on :math:`x`, :math:`u` and the initial conditions state :math:`x(t_0)`.
this course, the cost function will always be quadratic, and can be accessed as ``model.get_cost``.
this course, the cost function will always be quadratic and can be obtained using the function :func:`~irlc.ex03.control_model.ControlModel.get_cost`.
If you want to implement your own model, the best approach is to start with an existing model and modify it for
If you want to implement your own model, the best approach is to start with an existing model and modify it for
your needs. The overall idea is that you implement the dynamics,``sym_f``, and the cost function ``get_cost``,
your needs. The overall idea is that you implement the dynamics, :func:`~irlc.ex03.control_model.ControlModel.sym_f`, and the cost function :func:`~irlc.ex03.control_model.ControlModel.get_cost`,
and optionally define bounds as needed.
and (optionally) define whichever bounds are suitable for your problem.
"""
"""
state_labels=None# Labels (as lists) used for visualizations.
state_labels=None# Labels (as lists) used for visualizations.
action_labels=None# Labels (as lists) used for visualizations.
action_labels=None# Labels (as lists) used for visualizations.
def__init__(self):
def__init__(self):
"""
The cost must be an instance of :class:`irlc.ex04.cost_continuous.SymbolicQRCost`.
Bounds is a dictionary but otherwise optional; the model should give it a default value.
:param cost: A quadratic cost function
:param dict bounds: A dictionary of boundary constraints.
This function should return a :class:`SymbolicQRCost` instance. The function must be implemented
This function should return a :func:`~irlc.ex03.control_cost.SymbolicQRCost` instance. The function must be implemented
since the cost object is used to guess the number of states and actions. Note that you can specify a trivial cost
since the cost object is used to guess the number of states and actions. Note that you can easily specify a trivial cost
instance such as :python:`return SymbolicQRCost.zero(n_states, n_actions)`.
instance such as :python:`return SymbolicQRCost.zero(n_states, n_actions)`.
:return: A :class:`SymbolicQRCost` instance representing the models cost function.
:return: A :func:`~irlc.ex03.control_cost.SymbolicQRCost` instance representing the models cost function.
"""
"""
raiseNotImplementedError("When you implement the model, you must implement the get_cost() function.\nfor instance, use return SymbolicQRCost(Q=np.eye(n), R=np.eye(d))")
raiseNotImplementedError("When you implement the model, you must implement the get_cost() function.\nfor instance, use return SymbolicQRCost(Q=np.eye(n), R=np.eye(d))")
defsym_f(self,x,u,t=None):
defsym_f(self,x,u,t=None):
"""
"""
The symbolic (``sympy``) version of the dynamics :math:`f(x, u, t)`. This is the main place where you specify
The symbolic (:mod:`sympy`) version of the dynamics :math:`f(x, u, t)`. This is the main place where you specify
the dynamics when you build a new model. you should look at concrete implementations of models for specifics.
the dynamics when you build a new model. you should look at concrete implementations of models for specifics.
:param x: A list of symbolic expressions ``['x0', 'x1', ..]`` corresponding to :math:`x`
:param x: A list of symbolic expressions ``['x0', 'x1', ..]`` corresponding to :math:`x`