|
33 | 33 | }, |
34 | 34 | { |
35 | 35 | "cell_type": "code", |
36 | | - "execution_count": 11, |
| 36 | + "execution_count": 17, |
37 | 37 | "metadata": {}, |
38 | 38 | "outputs": [], |
39 | 39 | "source": [ |
|
42 | 42 | }, |
43 | 43 | { |
44 | 44 | "cell_type": "code", |
45 | | - "execution_count": 12, |
| 45 | + "execution_count": 18, |
46 | 46 | "metadata": {}, |
47 | 47 | "outputs": [], |
48 | 48 | "source": [ |
|
66 | 66 | }, |
67 | 67 | { |
68 | 68 | "cell_type": "code", |
69 | | - "execution_count": 3, |
| 69 | + "execution_count": 20, |
70 | 70 | "metadata": {}, |
71 | 71 | "outputs": [], |
72 | 72 | "source": [ |
|
94 | 94 | }, |
95 | 95 | { |
96 | 96 | "cell_type": "code", |
97 | | - "execution_count": 13, |
| 97 | + "execution_count": 22, |
98 | 98 | "metadata": {}, |
99 | 99 | "outputs": [], |
100 | 100 | "source": [ |
|
124 | 124 | " self.p = environment.get_wrapper_attr('physical_system').electrical_motor.motor_parameter['p']\n", |
125 | 125 | " self.abc_to_dq = environment.get_wrapper_attr('physical_system').abc_to_dq_space\n", |
126 | 126 | " self.prediction_horizon = prediction_horizon # Prediction horizon (typically 1 for FCS-MPC)\n", |
| 127 | + "\n", |
| 128 | + " # limit values for the normalization\n", |
| 129 | + " self.u_lim = environment.get_wrapper_attr('physical_system').limits[env.get_wrapper_attr('state_names').index('u_sd')]\n", |
127 | 130 | " \n", |
128 | 131 | " # Get the finite set of voltage vectors from the environment\n", |
129 | 132 | " self.subactions = -np.power(-1, environment.get_wrapper_attr('physical_system')._converter._subactions)\n", |
| 133 | + " self.u_abc_k1 = self.u_lim * self.subactions\n", |
130 | 134 | " \n", |
131 | 135 | " def _simulate_sequence(self, i_d, i_q, epsilon_el, omega, ref_i_d, ref_i_q, depth):\n", |
132 | 136 | " min_cost = float('inf')\n", |
133 | 137 | " best_sequence = []\n", |
134 | 138 | "\n", |
135 | | - " for idx, (v_a, v_b, v_c) in enumerate(self.subactions):\n", |
| 139 | + " for idx, (v_a, v_b, v_c) in enumerate(self.u_abc_k1):\n", |
136 | 140 | " # Convert to dq \n", |
137 | 141 | " v_dq = np.transpose(np.array([self.abc_to_dq(np.array([v_a, v_b, v_c]), epsilon_el + 0.5*omega*self.tau)]))\n", |
138 | 142 | " v_d, v_q = v_dq[0], v_dq[1]\n", |
|
199 | 203 | }, |
200 | 204 | { |
201 | 205 | "cell_type": "code", |
202 | | - "execution_count": 14, |
| 206 | + "execution_count": 23, |
203 | 207 | "metadata": {}, |
204 | 208 | "outputs": [], |
205 | 209 | "source": [ |
|
217 | 221 | }, |
218 | 222 | { |
219 | 223 | "cell_type": "code", |
220 | | - "execution_count": 16, |
| 224 | + "execution_count": 24, |
221 | 225 | "metadata": {}, |
222 | 226 | "outputs": [], |
223 | 227 | "source": [ |
|
254 | 258 | }, |
255 | 259 | { |
256 | 260 | "cell_type": "code", |
257 | | - "execution_count": 17, |
| 261 | + "execution_count": 25, |
258 | 262 | "metadata": {}, |
259 | 263 | "outputs": [ |
260 | 264 | { |
261 | 265 | "data": { |
262 | 266 | "application/vnd.jupyter.widget-view+json": { |
263 | | - "model_id": "47799e64eeb84ba88aaee9f1d299e191", |
| 267 | + "model_id": "793190cb48db401cb57950c71587cbe5", |
264 | 268 | "version_major": 2, |
265 | 269 | "version_minor": 0 |
266 | 270 | }, |
|
317 | 321 | }, |
318 | 322 | { |
319 | 323 | "cell_type": "code", |
320 | | - "execution_count": 18, |
| 324 | + "execution_count": 26, |
321 | 325 | "metadata": {}, |
322 | 326 | "outputs": [ |
323 | 327 | { |
324 | 328 | "name": "stdout", |
325 | 329 | "output_type": "stream", |
326 | 330 | "text": [ |
327 | | - "Reward = -1430.5877421997113\n" |
| 331 | + "Reward = -1041.746469033069\n" |
328 | 332 | ] |
329 | 333 | } |
330 | 334 | ], |
|
0 commit comments