diff --git a/irlc/ex03/control_model.py b/irlc/ex03/control_model.py index c9426c9f238cd95f79a1d3b152fd34763710c770..d916fa2bb48bd6aa1989245bf9b2ba71405ed8e8 100644 --- a/irlc/ex03/control_model.py +++ b/irlc/ex03/control_model.py @@ -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 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 - your needs. The overall idea is that you implement the dynamics,``sym_f``, and the cost function ``get_cost``, - and optionally define bounds as needed. + 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 whichever bounds are suitable for your problem. """ state_labels = None # Labels (as lists) used for visualizations. action_labels = None # Labels (as lists) used for visualizations. 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: self.state_labels = [f'x{i}' for i in range(self.state_size)] if self.action_labels is None: @@ -117,17 +110,17 @@ class ControlModel: def get_cost(self) -> SymbolicQRCost: """Return the cost. - This function should return a :class:`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 + 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 easily specify a trivial cost 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))") 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. :param x: A list of symbolic expressions ``['x0', 'x1', ..]`` corresponding to :math:`x`