Skip to content

Commit ab1ce7e

Browse files
Fix typos in docstrings, error messages, and verbose output (#33)
* Fix wrong step printed in closed-loop simulations The previous step variable printed as a verbose output was the n-mpc step, which remained constant for n-mpc steps when n-mpc was greater than 1. Now, the step variable printed is the actual control step. * Fix docstring typo and remove comment in LTI controller - Rename `y_r_param` to `y_s_param` in the docstring of the `set_input_output_setpoints` method, as it was a typo. - Remove leftover comment. * Fix wrong error message in nonlinear controller Replace `self.y_s.shape` with `self.y_r.shape` in the `ValueError` message of the `set_output_setpoint` method, as it was a typo.
1 parent e28e76b commit ab1ce7e

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

direct_data_driven_mpc/lti_data_driven_mpc_controller.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,15 +1097,15 @@ def set_input_output_setpoints(
10971097
Note:
10981098
This method sets the values of the `u_s` and `y_s` attributes with
10991099
the provided new setpoints and updates the values of `u_s_param`
1100-
and `y_r_param` to update the data-driven MPC controller setpoint.
1100+
and `y_s_param` to update the data-driven MPC controller setpoint.
11011101
"""
11021102
# Validate input types and dimensions
11031103
if u_s.shape != self.u_s.shape:
11041104
raise ValueError(
11051105
"Incorrect dimensions. `u_s` must have shape "
11061106
f"{self.u_s.shape}, but got {u_s.shape} instead."
11071107
)
1108-
if y_s.shape != self.y_s.shape: # Replace with actual expected shape
1108+
if y_s.shape != self.y_s.shape:
11091109
raise ValueError(
11101110
"Incorrect dimensions. `y_s` must have shape "
11111111
f"{self.y_s.shape}, but got {y_s.shape} instead."

direct_data_driven_mpc/nonlinear_data_driven_mpc_controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1385,7 +1385,7 @@ def set_output_setpoint(self, y_r: np.ndarray) -> None:
13851385
if y_r.shape != self.y_r.shape:
13861386
raise ValueError(
13871387
"Incorrect dimensions. `y_r` must have shape "
1388-
f"{self.y_s.shape}, but got {y_r.shape} instead."
1388+
f"{self.y_r.shape}, but got {y_r.shape} instead."
13891389
)
13901390

13911391
# Update output setpoint and its parameter value

direct_data_driven_mpc/utilities/controller/data_driven_mpc_sim.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def simulate_lti_data_driven_mpc_control_loop(
134134
mpc_cost_val = data_driven_mpc_controller.get_optimal_cost_value()
135135
print_mpc_step_info(
136136
verbose=verbose,
137-
step=t,
137+
step=k,
138138
mpc_cost_val=mpc_cost_val,
139139
u_sys_k=u_sys[k, :].flatten(),
140140
u_s=u_s.flatten(),
@@ -305,7 +305,7 @@ def simulate_nonlinear_data_driven_mpc_control_loop(
305305
mpc_cost_val = data_driven_mpc_controller.get_optimal_cost_value()
306306
print_mpc_step_info(
307307
verbose=verbose,
308-
step=t,
308+
step=k,
309309
mpc_cost_val=mpc_cost_val,
310310
y_sys_k=y_sys[k, :].flatten(),
311311
y_s=y_r.flatten(),

0 commit comments

Comments
 (0)