Skip to content
Snippets Groups Projects
Commit 44319031 authored by tuhe's avatar tuhe
Browse files

Fixed documentation

parent fe32d099
No related branches found
No related tags found
No related merge requests found
...@@ -31,23 +31,16 @@ class ControlModel: ...@@ -31,23 +31,16 @@ class ControlModel:
c_F(t_0, t_F, x(t_0), x(t_F)) + \int_{t_0}^{t_F} c(t, x, u) dt c_F(t_0, t_F, x(t_0), x(t_F)) + \int_{t_0}^{t_F} c(t, x, u) dt
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.
"""
if self.state_labels is None: if self.state_labels is None:
self.state_labels = [f'x{i}' for i in range(self.state_size)] self.state_labels = [f'x{i}' for i in range(self.state_size)]
if self.action_labels is None: if self.action_labels is None:
...@@ -117,17 +110,17 @@ class ControlModel: ...@@ -117,17 +110,17 @@ class ControlModel:
def get_cost(self) -> SymbolicQRCost: def get_cost(self) -> SymbolicQRCost:
"""Return the cost. """Return the cost.
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.
""" """
raise NotImplementedError("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))") raise NotImplementedError("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))")
def sym_f(self, x, u, t=None): def sym_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`
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment