You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+53-49Lines changed: 53 additions & 49 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,19 +11,19 @@ A very simple explanation of DMC is included in [this file](docs/DMC.pdf).
11
11
12
12
The functions and scripts are as follows:
13
13
### DMC functions
14
-
-`simulate_linear_system` and `simulate_nonlinear_system` simulate the systems by running the whole simulation, calling the MPC controller at each timestep to get the control input, applying the control input to the systems and moving the dynamics forward.
15
-
-`dmc_linear` determines the control input for the linear system using the DMC logic
16
-
-`dmc_nonlinear` is the same as `dmc_linear` with the difference that it moves the nonlinear system's dynamics forward to calculate `Ypast`.
17
-
-`update_linear_state` moves the linear system's dynamics forward one step. You can insert your linear system dynamics here.
18
-
-`update_nonlinear_state` moves the nonlinear system's dynamics forward one step. You can insert your nonlinear system dynamics here.
14
+
-[simulate_linear_system](DMC/simulate_linear_system.m) and [simulate_nonlinear_system(DMC/simulate_nonlinear_system) simulate the systems by running the whole simulation, calling the MPC controller at each timestep to get the control input, applying the control input to the systems and moving the dynamics forward.
15
+
-[dmc_linear](DMC/dmc_linear.m) determines the control input for the linear system using the DMC logic
16
+
-[dmc_nonlinear](DMC/dmc_nonlinear.m) is the same as [dmc_linear](DMC/dmc_linear.m) with the difference that it moves the nonlinear system's dynamics forward to calculate `Ypast`.
17
+
-[update_linear_state](DMC/update_linear_state.m) moves the linear system's dynamics forward one step. You can insert your linear system dynamics here.
18
+
-[update_nonlinear_state](DMC/update_nonlinear_state.m) moves the nonlinear system's dynamics forward one step. You can insert your nonlinear system dynamics here.
19
19
A considerably smaller step size (compared to control sample time) should be considered when simulating the nonlinear system itself. The `substeps` parameter can be tuned for that (keep it at least at 10 for a realistic simulation).
20
-
-`plot_simulation_results`, `plot_comparison_results`, `plot_comparison_results_for_Q` and `plot_comparison_results_for_alpha` are used for plotting the results.
21
-
-`plot_static_gain` is used for analyzing the nonlinear system's static gain at a given point
20
+
-[plot_simulation_results](DMC/plot_simulation_results.m), [plot_comparison_results](DMC/plot_comparison_results.m), [plot_comparison_results_for_Q](DMC/plot_comparison_results_for_Q.m) and [plot_comparison_results_for_alpha](DMC/plot_comparison_results_for_alpha.m) are used for plotting the results.
21
+
-[plot_static_gain](DMC/plot_static_gain.m) is used for analyzing the nonlinear system's static gain at a given point
22
22
23
23
### DMC scripts
24
24
25
-
-`plot_step_response` is used to analyzing the linearized system's step response to obtain a reliable model horizon N
26
-
-`general` runs the simulation with the set parameters and saves the results. Parameters include:
25
+
-[plot_step_response](DMC/plot_step_response.m) is used to analyzing the linearized system's step response to obtain a reliable model horizon N
26
+
-[general](DMC/general.m) runs the simulation with the set parameters and saves the results. Parameters include:
27
27
-`Ts` sampling time
28
28
-`tf` final simulation time
29
29
-`N` model horizon
@@ -42,14 +42,14 @@ A considerably smaller step size (compared to control sample time) should be con
42
42
-`noise_power` power of white noise on the output (in dB)
43
43
-`dist_amp` the amplitude of disturbance on the output. The disturbance is considered to be a pulse signal.
44
44
-`dist_start_time` the time when the disturbance is applied
45
-
-`compare_Ms` compares different values of M.
46
-
-`compare_Ns` compares different values of N.
47
-
-`compare_Ps` compares different values of P.
48
-
-`compare_Qs` compares different values of Q.
49
-
-`compare_Rs` compares different values of R.
50
-
-`compare_Rs` compares different values of alpha.
51
-
-`pulse` pulse reference signal
52
-
-`sinusoid` sinusoid reference signal
45
+
-[compare_Ms](DMC/compare_Ms.m) compares different values of M.
46
+
-[compare_Ns](DMC/compare_Ns.m) compares different values of N.
47
+
-[compare_Ps](DMC/compare_Ps.m) compares different values of P.
48
+
-[compare_Qs](DMC/compare_Qs.m) compares different values of Q.
49
+
-[compare_Rs](DMC/compare_Rs.m) compares different values of R.
50
+
-[compare_alphas](DMC/compare_alphas.m) compares different values of alpha.
51
+
-[pulse](DMC/pulse0 pulse reference signal
52
+
-[sinusoid](DMC/sinusoid.m) sinusoid reference signal
53
53
54
54
55
55
## EPFC
@@ -58,17 +58,21 @@ An extended PFC controller is implemented to control a nonlinear system. The exe
The system state space representation is as follows:
61
-
```
62
-
x1_dot = x2
63
-
x2_dot = -0.33 * exp(-x1) * x1 - 1.1 * x2 + u
64
-
y = x1
65
-
```
61
+
62
+
$$
63
+
\begin{align}
64
+
\dot{x}_1 = x_2 \\
65
+
\dot{x}_2 = -0.33 e^{-x_1} x_1 - 1.1 x_2 + u
66
+
y = x_1
67
+
\end{align}
68
+
$$
66
69
67
70
Any other system can be used instead. It's simply a matter of system definition in one function, which will be shown later.
68
71
A change of variables is considered as:
69
-
```
70
-
v = u + x1
71
-
```
72
+
73
+
$$
74
+
v = u + x_1
75
+
$$
72
76
73
77
This change of variables allows the new system to have a one-to-one relationship between `v` and `y`. If a system does not need a change of variables, line 162 of `run_simulation` can simply be changed to:
74
78
```matlab
@@ -78,18 +82,18 @@ A very simple explanation of EPFC is included in [this file](docs/EPFC.pdf).
78
82
79
83
The functions and scripts are as follows:
80
84
### EPFC functions
81
-
`run_simulation` runs the simulation given
82
-
-linearization method: set to 'perturbation' or 'jacobian'. Jacobian uses the provided Jacobian of the system (which should be provided in `linearize_dynamics`). The perturbation method uses the predictive model and applies two inputs. One where the input is kept unchanged as it is at this sample time, and one with a small change in the control input value. By dividing the change of the output in the two cases by the change of the input, a linearized model is achieved.
83
-
-`linearize_dynamics` provides the jacobian for the 'jacobian' lineariztion method. You should set this function according to your system's dynamics.
84
-
-`get_step_response_nonlinear` provides the outputs for a given constant input. It is used in 'perturbation' linearization technique.
85
-
-`update_nonlinear_state` moves the nonlinear system's dynamics forward one step. You can insert your system dynamics here.
85
+
-[run_simulation](EPFC/run_simulation.m) runs the simulation given
86
+
linearization method: set to 'perturbation' or 'jacobian'. Jacobian uses the provided Jacobian of the system (which should be provided in [linearize_dynamics](EPFC/linearize_dynamics.m)). The perturbation method uses the predictive model and applies two inputs. One where the input is kept unchanged as it is at this sample time, and one with a small change in the control input value. By dividing the change of the output in the two cases by the change of the input, a linearized model is achieved.
87
+
-[linearize_dynamics](EPFC/linearize_dynamics.m) provides the jacobian for the 'jacobian' lineariztion method. You should set this function according to your system's dynamics.
88
+
-[get_step_response_nonlinear](EPFC/get_step_response_nonlinear.m) provides the outputs for a given constant input. It is used in 'perturbation' linearization technique.
89
+
-[update_nonlinear_state](EPFC/update_nonlinear_state.m) moves the nonlinear system's dynamics forward one step. You can insert your system dynamics here.
86
90
A considerably smaller step size (compared to control sample time) should be considered when simulating the nonlinear system itself. The `substeps` parameter can be tuned for that (keep it at least at 10 for a realistic simulation).
87
-
-`update_nonlinear_state_actual` is used when model mismatch is considered. You can skip setting up this function if your model is exact. If not, use the model at hand in `update_nonlinear_state` and in `update_nonlinear_state_actual` write the actual system model (unknown).
88
-
-`plot_simulation_results` and `plot_comparison_results` are used for plotting and saving the outputs. The outputs are saved in a folder called `simulation_results` in `downloads`. If no such folder exists, one will be created.
91
+
-[update_nonlinear_state_actual](EPFC/update_nonlinear_state_actual.m) is used when model mismatch is considered. You can skip setting up this function if your model is exact. If not, use the model at hand in [update_nonlinear_state](EPFC/update_nonlinear_state.m) and in [update_nonlinear_state_actual](EPFC/update_nonlinear_state_actual.m) write the actual system model (unknown).
92
+
-[plot_simulation_results](EPFC/plot_simulation_results.m) and [plot_comparison_results](EPFC/plot_comparison_results.m) are used for plotting and saving the outputs. The outputs are saved in a folder called `simulation_results` in `downloads`. If no such folder exists, one will be created.
89
93
90
94
### EPFC scripts
91
-
-`plot_static_gain` is used for analyzing the nonlinear system static gain and consider a change of variables if necessary
92
-
-`main` runs the simulation with the set parameters and saves the results. Parameters include:
95
+
-[plot_static_gain](EPFC/plot_static_gain.m) is used for analyzing the nonlinear system static gain and consider a change of variables if necessary
96
+
-[main](EPFC/main.m) runs the simulation with the set parameters and saves the results. Parameters include:
93
97
-`Ts` sampling time
94
98
-`tf` final simulation time
95
99
-`N-model` not actually used in PFC, but set it to something larger than all the `mu`s
@@ -108,21 +112,21 @@ A considerably smaller step size (compared to control sample time) should be con
108
112
-`dist_amp` the amplitude of disturbance on the output. The disturbance is considered to be a pulse signal.
109
113
-`dist_time` the time when the disturbance is applied
110
114
-`dist_duration` the duration of the disturbance
111
-
-`one_input_one_output` simulates the system for one input and one output coincidence points.
112
-
-`one_input_three_outputs` simulates the system for one input and three output coincidence points.
113
-
-`one_input_three_outputs` simulates the system for three input and three output coincidence points.
114
-
-`compare_coincidence_points` compares the three cases above.
115
-
-`compare_input_coincidence_points` compare different sets of input coincidence points.
116
-
-`compare_output_coincidence_points` compare different sets of output coincidence points.
117
-
-`compare_constrained_vs_unconstrained` compares the controller performance in presence and absence of input constraints
118
-
-`compare_linearization_method` compares 'perturbation' and 'jacobian' linearization methods.
119
-
-`compare_q_values` compares different values of q.
120
-
-`compare_r_values` compares different values of r.
121
-
-`compare-psi_values` compares different values of psi.
122
-
-`compare_nominal_vs-uncertainty` compares the controller performance in presence and absence of uncertainty in the model.
123
-
-`compare_programmed` compares programmed vs unprogrammed reference signal.
124
-
-`noise_and_disturbance` is just `main` with more noise and disturbance to see their effects.
125
-
-`initial_condition` is just `main` with different initial conditions to see their effects.
115
+
-[one_input_one_output](EPFC/one_input_one_output.m) simulates the system for one input and one output coincidence points.
116
+
-[one_input_three_outputs](EPFC/one_input_three_outputs.m) simulates the system for one input and three output coincidence points.
117
+
-[one_input_three_outputs](EPFC/one_input_three_outputs.m) simulates the system for three input and three output coincidence points.
118
+
-[compare_coincidence_points](EPFC/compare_coincidence_points.m) compares the three cases above.
119
+
-[compare_input_coincidence_points](EPFC/compare_input_coincidence_points.m) compare different sets of input coincidence points.
120
+
-[compare_output_coincidence_points](EPFC/compare_output_coincidence_points.m) compare different sets of output coincidence points.
121
+
-[compare_constrained_vs_unconstrained](EPFC/compare_constrained_vs_unconstrained.m) compares the controller performance in presence and absence of input constraints
122
+
-[compare_linearization_methods](EPFC/compare_linearization_methods.m) compares 'perturbation' and 'jacobian' linearization methods.
123
+
-[compare_q_values](EPFC/compare_q_values.m) compares different values of q.
124
+
-[compare_r_values](EPFC/compare_r_values.m) compares different values of r.
125
+
-[compare_psi_values](EPFC/compare_psi_values.m) compares different values of psi.
126
+
-[compare_nominal_vs_uncertainty](EPFC/compare_nominal_vs_uncertainty.m) compares the controller performance in presence and absence of uncertainty in the model.
127
+
-[compare_programmed](EPFC/compare_programmed.m) compares programmed vs unprogrammed reference signal.
128
+
-[noise_and_disturbance](EPFC/noise_and_disturbance.m) is just [main](EPFC/main.m) with more noise and disturbance to see their effects.
129
+
-[initial_condition](EPFC/initial_condition.m) is just [main](EPFC/main.m) with different initial conditions to see their effects.
0 commit comments