Artificial Intelligence Applications in Engineering (MUH-920), week 14 of 14

Learning to Act, Respecting Physics and Engineering Responsibly

Prof. Dr. Utku Kose, Süleyman Demirel University

Learning to act

In Week 1, an engineer wrote the rule of the thermostat. Reinforcement learning lets an agent find the rule itself. At every step the agent observes a state, chooses an action and receives a reward and a new state; its goal is a policy that maximises the expected sum of discounted future rewards [1]. The formal model is a Markov decision process: The next state depends only on the current state and action. The discount factor gamma, between 0 and 1, sets how far the agent looks ahead. Unlike supervised learning, nobody tells the agent the correct action; it must explore to find out which actions pay off, and exploit what it has learned to collect reward.

The value of taking action a in state s and acting well afterwards is Q(s, a). Q-learning improves an estimate of Q after every step with Q(s, a) = Q(s, a) + alpha (r + gamma max Q(s', a') - Q(s, a)), where alpha is a learning rate and the maximum runs over the actions in the next state; Watkins and Dayan proved that it converges to the optimal values under suitable conditions [2]. An epsilon-greedy policy explores with a random action with probability epsilon and exploits the best known action otherwise. Tables work for small discrete problems; for large or continuous state spaces, a neural network approximates Q, as in the deep Q-network that learned to play Atari games from pixels [3].

Animation: Q-learning on a cliff walk

The agent starts at the lower left and must reach the lower right without stepping into the cliff, which costs heavily. Each step costs a little. Watch the arrows of the greedy policy and the colours of the state values change as episodes accumulate. Raise epsilon to explore more.

Check your understanding. Q(s, a) = 2.0, the reward is -1, gamma = 0.9, the best Q-value in the next state is 3.0 and alpha = 0.5. What is the updated Q(s, a)?

Formulas: Returns, values and the Bellman equations

A Markov decision process consists of states ss, actions aa, transition probabilities P(s′∣s,a)P(s' \mid s, a) of the next state s′s', rewards rr and a discount factor γ\gamma with 0≤γ<10 \le \gamma < 1 [1]. From the time tt on, the agent collects the rewards rt+1,rt+2,…r_{t+1}, r_{t+2}, \ldots, and its return is their discounted sum:

Gt=rt+1+γrt+2+γ2rt+3+⋯=∑k=0∞γkrt+k+1G_t = r_{t+1} + \gamma r_{t+2} + \gamma^2 r_{t+3} + \cdots = \sum_{k=0}^{\infty} \gamma^k r_{t+k+1}

The reward rt+k+1r_{t+k+1} counts with the weight γk\gamma^k. A constant reward rr in every step is worth r+γr+γ2r+⋯=r/(1−γ)r + \gamma r + \gamma^2 r + \cdots = r/(1 - \gamma), the sum of a geometric series, so with γ=0.9\gamma = 0.9 a reward of 1 per step is worth 10, and 1/(1−γ)1/(1 - \gamma) acts as the horizon of the agent.

A policy π\pi chooses the actions. The value of a state is the expected return of an agent that starts there and follows π\pi, and the action value adds a first action aa:

Vπ(s)=Eπ[Gt∣st=s],    Qπ(s,a)=Eπ[Gt∣st=s,at=a]V_\pi(s) = \text{E}_\pi[G_t \mid s_t = s], \;\; Q_\pi(s, a) = \text{E}_\pi[G_t \mid s_t = s, a_t = a]

The best possible values satisfy the Bellman optimality equations: The value of a state is the best action value, and an action value is the expected sum of the reward and the discounted value of the next state [1]:

V(s)=max⁡aQ(s,a),    Q(s,a)=∑s′P(s′∣s,a) (r(s,a,s′)+γV(s′))V(s) = \max_a Q(s, a), \;\; Q(s, a) = \sum_{s'} P(s' \mid s, a)\, \big( r(s, a, s') + \gamma V(s') \big)

Value iteration starts from V0(s)=0V_0(s) = 0 and turns these equations into an update that is repeated for all states, one sweep after another:

Vk+1(s)=max⁡a∑s′P(s′∣s,a) (r(s,a,s′)+γVk(s′))V_{k+1}(s) = \max_a \sum_{s'} P(s' \mid s, a)\, \big( r(s, a, s') + \gamma V_k(s') \big)

Each sweep shrinks the largest error of the values at least by the factor γ\gamma, so the values converge, and the greedy policy, which picks an action with the largest action value, becomes optimal.

Q-learning learns action values from experience, without knowing the transition probabilities [2]. After each transition from ss with the action aa to s′s' with the reward rr, the estimate moves by the learning rate α\alpha towards the target r+γmax⁡a′Q(s′,a′)r + \gamma \max_{a'} Q(s', a'):

δ=r+γmax⁡a′Q(s′,a′)−Q(s,a),    Q(s,a)←Q(s,a)+α δ\delta = r + \gamma \max_{a'} Q(s', a') - Q(s, a), \;\; Q(s, a) \leftarrow Q(s, a) + \alpha\, \delta

The difference δ\delta is the temporal-difference error. An ε\varepsilon-greedy policy with mm actions chooses a random action with the probability ε\varepsilon, so the greedy action has the probability 1−ε+ε/m1 - \varepsilon + \varepsilon/m and every other action ε/m\varepsilon/m.

Worked example: The return of a maintenance history

A pump is inspected at the start of every week and is good (G), worn (W) or failed (F). The engineer can continue (c) or service (s). Continuing earns 10 units of production with a good pump, 6 with a worn pump and nothing with a failed one. Servicing costs 2, 4 or 20 units in the three states and returns the pump to G for the next week. A good pump wears within a week with the probability 0.3, and a worn pump fails with the probability 0.4.

In one history, the engineer continued three times and then serviced the worn pump, with the rewards 10, 10, 6 and −4. With γ=0.9\gamma = 0.9 the weights are 0.90=10.9^0 = 1, 0.91=0.90.9^1 = 0.9, 0.92=0.810.9^2 = 0.81 and 0.93=0.7290.9^3 = 0.729:

G0=10+0.9×10+0.81×6+0.729×(−4)=10+9+4.86−2.916=20.944G_0 = 10 + 0.9 \times 10 + 0.81 \times 6 + 0.729 \times (-4) = 10 + 9 + 4.86 - 2.916 = 20.944

The service at the end lowers the return of this history, but it restores the production of later weeks, which a return of four weeks does not see. The values of the next example weigh all future weeks.

Worked example: Value iteration for pump maintenance

Step 1. The first sweep. With V0=0V_0 = 0 in every state, every action value equals its reward, and the larger one is the new value:

V1(G)=max⁡(10,−2)=10,    V1(W)=max⁡(6,−4)=6,    V1(F)=max⁡(0,−20)=0V_1(\text{G}) = \max(10, -2) = 10, \;\; V_1(\text{W}) = \max(6, -4) = 6, \;\; V_1(\text{F}) = \max(0, -20) = 0

Step 2. The second sweep. The action values weigh the values V1V_1 of the possible next states with their probabilities:

Q2(G,c)=10+0.9×(0.7×10+0.3×6)=10+0.9×(7+1.8)Q_2(\text{G}, c) = 10 + 0.9 \times (0.7 \times 10 + 0.3 \times 6) = 10 + 0.9 \times (7 + 1.8)
Q2(G,c)=10+0.9×8.8=10+7.92=17.92Q_2(\text{G}, c) = 10 + 0.9 \times 8.8 = 10 + 7.92 = 17.92
Q2(W,c)=6+0.9×(0.6×6+0.4×0)=6+0.9×(3.6+0)Q_2(\text{W}, c) = 6 + 0.9 \times (0.6 \times 6 + 0.4 \times 0) = 6 + 0.9 \times (3.6 + 0)
Q2(W,c)=6+0.9×3.6=6+3.24=9.24Q_2(\text{W}, c) = 6 + 0.9 \times 3.6 = 6 + 3.24 = 9.24

Servicing and continuing with a failed pump lead to a single next state, and the value of a state is its larger action value:

State Continue, cc Service, ss V2V_2, the larger
G 17.92 −2+0.9×10=−2+9=7-2 + 0.9 \times 10 = -2 + 9 = 7 17.92
W 9.24 −4+0.9×10=−4+9=5-4 + 0.9 \times 10 = -4 + 9 = 5 9.24
F 0+0.9×0=0+0=00 + 0.9 \times 0 = 0 + 0 = 0 −20+0.9×10=−20+9=−11-20 + 0.9 \times 10 = -20 + 9 = -11 0

Step 3. The third sweep. With the values V2V_2:

Q3(G,c)=10+0.9×(0.7×17.92+0.3×9.24)=10+0.9×(12.544+2.772)Q_3(\text{G}, c) = 10 + 0.9 \times (0.7 \times 17.92 + 0.3 \times 9.24) = 10 + 0.9 \times (12.544 + 2.772)
Q3(G,c)=10+0.9×15.316=10+13.7844=23.7844Q_3(\text{G}, c) = 10 + 0.9 \times 15.316 = 10 + 13.7844 = 23.7844
Q3(W,c)=6+0.9×(0.6×9.24+0.4×0)=6+0.9×(5.544+0)Q_3(\text{W}, c) = 6 + 0.9 \times (0.6 \times 9.24 + 0.4 \times 0) = 6 + 0.9 \times (5.544 + 0)
Q3(W,c)=6+0.9×5.544=6+4.9896=10.9896Q_3(\text{W}, c) = 6 + 0.9 \times 5.544 = 6 + 4.9896 = 10.9896

Servicing and continuing with a failed pump lead to a single next state, and the value of a state is its larger action value:

State Continue, cc Service, ss V3V_3, the larger
G 23.7844 −2+0.9×17.92=−2+16.128=14.128-2 + 0.9 \times 17.92 = -2 + 16.128 = 14.128 23.7844
W 10.9896 −4+0.9×17.92=−4+16.128=12.128-4 + 0.9 \times 17.92 = -4 + 16.128 = 12.128 12.128
F 0+0.9×0=0+0=00 + 0.9 \times 0 = 0 + 0 = 0 −20+0.9×17.92=−20+16.128=−3.872-20 + 0.9 \times 17.92 = -20 + 16.128 = -3.872 0

Servicing a worn pump now beats continuing, because the value of a good pump, which a service restores, has grown faster than the value of continuing with a worn one.

Step 4. The exact values. Further sweeps change the values less and less, and from the fourth sweep on the greedy policy stays the same: Continue in G, service in W and service in F. The values of this policy solve its three Bellman equations, which have no maximum because the actions are fixed:

V(G)=10+0.9×(0.7 V(G)+0.3 V(W))V(\text{G}) = 10 + 0.9 \times (0.7\, V(\text{G}) + 0.3\, V(\text{W}))
V(W)=−4+0.9 V(G),    V(F)=−20+0.9 V(G)V(\text{W}) = -4 + 0.9\, V(\text{G}), \;\; V(\text{F}) = -20 + 0.9\, V(\text{G})

With 0.9×0.7=0.630.9 \times 0.7 = 0.63 and 0.9×0.3=0.270.9 \times 0.3 = 0.27, inserting the second equation into the first gives

V(G)=10+0.63 V(G)+0.27×(−4+0.9 V(G))V(\text{G}) = 10 + 0.63\, V(\text{G}) + 0.27 \times (-4 + 0.9\, V(\text{G}))
V(G)=10+0.63 V(G)−1.08+0.243 V(G)=8.92+0.873 V(G)V(\text{G}) = 10 + 0.63\, V(\text{G}) - 1.08 + 0.243\, V(\text{G}) = 8.92 + 0.873\, V(\text{G})
V(G)=8.921−0.873=8.920.127=70.2362V(\text{G}) = \frac{8.92}{1 - 0.873} = \frac{8.92}{0.127} = 70.2362
V(W)=−4+0.9×70.2362=−4+63.2126=59.2126,    V(F)=−20+63.2126=43.2126V(\text{W}) = -4 + 0.9 \times 70.2362 = -4 + 63.2126 = 59.2126, \;\; V(\text{F}) = -20 + 63.2126 = 43.2126

Step 5. The check. The policy is optimal because no other action does better with these values. Continuing with a worn pump, continuing with a failed pump and servicing a good pump give

Q(W,c)=6+0.9×(0.6×59.2126+0.4×43.2126)=6+0.9×(35.5276+17.285)Q(\text{W}, c) = 6 + 0.9 \times (0.6 \times 59.2126 + 0.4 \times 43.2126) = 6 + 0.9 \times (35.5276 + 17.285)
Q(W,c)=6+0.9×52.8126=6+47.5313=53.5313Q(\text{W}, c) = 6 + 0.9 \times 52.8126 = 6 + 47.5313 = 53.5313
Q(F,c)=0+0.9×43.2126=0+38.8913=38.8913Q(\text{F}, c) = 0 + 0.9 \times 43.2126 = 0 + 38.8913 = 38.8913
Q(G,s)=−2+0.9×70.2362=−2+63.2126=61.2126Q(\text{G}, s) = -2 + 0.9 \times 70.2362 = -2 + 63.2126 = 61.2126

which are all smaller than V(W)=59.2126V(\text{W}) = 59.2126, V(F)=43.2126V(\text{F}) = 43.2126 and V(G)=70.2362V(\text{G}) = 70.2362. The high cost of a failure makes preventive service of a worn pump worthwhile, the logic of condition-based maintenance. Part A of the interactive lab runs the sweeps for any rewards, probabilities and discount factors.

Worked example: Q-learning from five transitions

An agent that does not know the probabilities of the pump starts with Q=0Q = 0 for every state and action, uses α=0.5\alpha = 0.5 and γ=0.9\gamma = 0.9, and observes five transitions.

Update 1. In state G, the action continue gave the reward 10 and the next state G, whose larger estimate is max⁡(0,0)=0\max(0, 0) = 0:

δ=10+0.9×0−0=10+0−0=10−0=10\delta = 10 + 0.9 \times 0 - 0 = 10 + 0 - 0 = 10 - 0 = 10
Q(G,c)=0+0.5×10=0+5=5Q(\text{G}, c) = 0 + 0.5 \times 10 = 0 + 5 = 5

Update 2. In state G, the action continue gave the reward 10 and the next state W, whose larger estimate is max⁡(0,0)=0\max(0, 0) = 0:

δ=10+0.9×0−5=10+0−5=10−5=5\delta = 10 + 0.9 \times 0 - 5 = 10 + 0 - 5 = 10 - 5 = 5
Q(G,c)=5+0.5×5=5+2.5=7.5Q(\text{G}, c) = 5 + 0.5 \times 5 = 5 + 2.5 = 7.5

Update 3. In state W, the action continue gave the reward 6 and the next state F, whose larger estimate is max⁡(0,0)=0\max(0, 0) = 0:

δ=6+0.9×0−0=6+0−0=6−0=6\delta = 6 + 0.9 \times 0 - 0 = 6 + 0 - 0 = 6 - 0 = 6
Q(W,c)=0+0.5×6=0+3=3Q(\text{W}, c) = 0 + 0.5 \times 6 = 0 + 3 = 3

Update 4. In state F, the action service gave the reward −20 and the next state G, whose larger estimate is max⁡(7.5,0)=7.5\max(7.5, 0) = 7.5:

δ=−20+0.9×7.5−0=−20+6.75−0=−13.25−0=−13.25\delta = -20 + 0.9 \times 7.5 - 0 = -20 + 6.75 - 0 = -13.25 - 0 = -13.25
Q(F,s)=0+0.5×(−13.25)=0+(−6.625)=−6.625Q(\text{F}, s) = 0 + 0.5 \times (-13.25) = 0 + (-6.625) = -6.625

Update 5. In state G, the action continue gave the reward 10 and the next state G, whose larger estimate is max⁡(7.5,0)=7.5\max(7.5, 0) = 7.5:

δ=10+0.9×7.5−7.5=10+6.75−7.5=16.75−7.5=9.25\delta = 10 + 0.9 \times 7.5 - 7.5 = 10 + 6.75 - 7.5 = 16.75 - 7.5 = 9.25
Q(G,c)=7.5+0.5×9.25=7.5+4.625=12.125Q(\text{G}, c) = 7.5 + 0.5 \times 9.25 = 7.5 + 4.625 = 12.125

After five transitions, the estimate Q(G,c)=12.125Q(\text{G}, c) = 12.125 is still far below its value 70.2362 from the previous example, and Q(F,s)=−6.625Q(\text{F}, s) = −6.625 is lower than Q(F,c)=0Q(\text{F}, c) = 0, so a greedy agent would leave a failed pump idle. Exploration corrects such early errors: With ε=0.1\varepsilon = 0.1 and two actions, the greedy action is taken with the probability 1−0.1+0.1/2=0.951 - 0.1 + 0.1/2 = 0.95 and the other action with 0.1/2=0.050.1/2 = 0.05, so the agent keeps trying repairs. Part B of the lab runs Q-learning on the pump for thousands of weeks.

Reinforcement learning in engineering

Control problems were among the first testbeds of reinforcement learning: The cart-pole balancing task goes back to adaptive elements studied in the early 1980s [4], and Gymnasium now provides it with a standard interface for experiments [5]. Robotics has used reinforcement learning for manipulation and locomotion [6], and deep reinforcement learning has controlled the magnetic coils of a tokamak in a fusion experiment [7]. These successes share a feature: The agent learned mostly in simulation. Exploration on a real plant can damage equipment or endanger people, the reward may be satisfied in unintended ways, and a policy trained under one set of conditions may fail under others; Amodei and colleagues list safe exploration, reward hacking and distributional shift among the concrete problems of AI safety [8]. Simulators, constraints on actions, human oversight and gradual deployment are therefore part of any engineering use.

Check your understanding. Why do most engineering applications of reinforcement learning train the agent in simulation first?

Formulas: Rewards and the cross-entropy method

The reward is the specification of the task: The agent maximises exactly what it is rewarded for, and a missing or badly weighted term invites behaviour that the engineer did not intend [8]. The heating agent of the notebook receives, after it has chosen the heater command utu_t and the room has reached the temperature Tt+1T_{t+1}, the reward

rt+1=−∣Tt+1−21∣−ws st−we utr_{t+1} = -|T_{t+1} - 21| - w_s\, s_t - w_e\, u_t

where sts_t is 1 if the command differs from the previous one and 0 otherwise. The first term rewards comfort, the second penalises switching, which wears the relay, and the third penalises energy; the notebook uses ws=0.3w_s = 0.3 and we=0.05w_e = 0.05.

Policy search methods adjust the parameters θ\theta of a policy directly. The cross-entropy method draws NN parameter vectors from a normal distribution with the mean μ\mu and the standard deviation σ\sigma, runs an episode with each, keeps the KK vectors with the highest returns, the elite, and fits the distribution to the elite:

μnew=1K∑k=1Kθk,    σnew2=1K∑k=1K(θk−μnew)2\mu_{\text{new}} = \frac{1}{K} \sum_{k=1}^{K} \theta_k, \;\; \sigma_{\text{new}}^2 = \frac{1}{K} \sum_{k=1}^{K} (\theta_k - \mu_{\text{new}})^2

For vectors, these formulas apply to every component. The distribution narrows around good parameters within a few iterations; a small constant added to σ\sigma, 0.05 in the notebook, keeps it from collapsing too early. The method needs no gradients, like the population methods of Weeks 5 and 6, which suits simulators that are treated as black boxes.

Worked example: How the reward weights choose a behaviour

Two heater trajectories of four steps start from a heater that was off. Every reward splits into the comfort and energy part, which does not depend on wsw_s, and the switching penalty −wsst-w_s s_t, and the discount factor is γ=0.9\gamma = 0.9. Trajectory A switches in every step and stays close to 21 °C:

Step Weight γk−1\gamma^{k-1} TT (°C) uu Switch Comfort and energy
1 1 21.2 1 1 −0.2−0.05=−0.25-0.2 - 0.05 = -0.25
2 0.9 20.9 0 1 −0.1−0=−0.1-0.1 - 0 = -0.1
3 0.81 21.1 1 1 −0.1−0.05=−0.15-0.1 - 0.05 = -0.15
4 0.729 20.8 0 1 −0.2−0=−0.2-0.2 - 0 = -0.2

Trajectory B switches twice and drifts further from 21 °C:

Step Weight γk−1\gamma^{k-1} TT (°C) uu Switch Comfort and energy
1 1 21.4 1 1 −0.4−0.05=−0.45-0.4 - 0.05 = -0.45
2 0.9 21.8 1 0 −0.8−0.05=−0.85-0.8 - 0.05 = -0.85
3 0.81 21.3 0 1 −0.3−0=−0.3-0.3 - 0 = -0.3
4 0.729 20.9 0 0 −0.1−0=−0.1-0.1 - 0 = -0.1

Step 1. Discounted sums. The comfort and energy parts and the switches, each weighted by γk−1\gamma^{k-1}, add up to

CA=1×(−0.25)+0.9×(−0.1)+0.81×(−0.15)+0.729×(−0.2)C_A = 1 \times (-0.25) + 0.9 \times (-0.1) + 0.81 \times (-0.15) + 0.729 \times (-0.2)
CA=−0.25−0.09−0.1215−0.1458=−0.6073C_A = -0.25 - 0.09 - 0.1215 - 0.1458 = -0.6073
CB=1×(−0.45)+0.9×(−0.85)+0.81×(−0.3)+0.729×(−0.1)C_B = 1 \times (-0.45) + 0.9 \times (-0.85) + 0.81 \times (-0.3) + 0.729 \times (-0.1)
CB=−0.45−0.765−0.243−0.0729=−1.5309C_B = -0.45 - 0.765 - 0.243 - 0.0729 = -1.5309
SA=1+0.9+0.81+0.729=3.439,    SB=1+0.81=1.81S_A = 1 + 0.9 + 0.81 + 0.729 = 3.439, \;\; S_B = 1 + 0.81 = 1.81

so the returns are GA=−0.6073−3.439 wsG_A = -0.6073 - 3.439\, w_s and GB=−1.5309−1.81 wsG_B = -1.5309 - 1.81\, w_s.

Step 2. A light penalty. With ws=0.3w_s = 0.3:

GA=−0.6073−3.439×0.3=−0.6073−1.0317=−1.639G_A = -0.6073 - 3.439 \times 0.3 = -0.6073 - 1.0317 = -1.639
GB=−1.5309−1.81×0.3=−1.5309−0.543=−2.0739G_B = -1.5309 - 1.81 \times 0.3 = -1.5309 - 0.543 = -2.0739

Trajectory A has the higher return, so a learning agent is drawn towards frequent switching.

Step 3. A heavier penalty. With ws=2w_s = 2:

GA=−0.6073−3.439×2=−0.6073−6.878=−7.4853G_A = -0.6073 - 3.439 \times 2 = -0.6073 - 6.878 = -7.4853
GB=−1.5309−1.81×2=−1.5309−3.62=−5.1509G_B = -1.5309 - 1.81 \times 2 = -1.5309 - 3.62 = -5.1509

Now trajectory B wins. The two returns are equal where −0.6073−3.439 ws=−1.5309−1.81 ws-0.6073 - 3.439\, w_s = -1.5309 - 1.81\, w_s, that is at

ws=−0.6073−(−1.5309)3.439−1.81=0.92361.629=0.567w_s = \frac{-0.6073 - (-1.5309)}{3.439 - 1.81} = \frac{0.9236}{1.629} = 0.567

The weight is an engineering decision about relay wear against comfort, and the agent only carries it out. Part C of the interactive lab compares the two trajectories for any weights, and Part D lets a Q-learning thermostat learn with this reward and an adjustable penalty per switching.

Worked example: One iteration of the cross-entropy method

A controller gain θ\theta is tuned on a simulator whose return, unknown to the method, is J(θ)=10−(θ−2)2J(\theta) = 10 - (\theta - 2)^2. Ten draws from the normal distribution with μ=0\mu = 0 and σ=2\sigma = 2 give

Draw θ\theta θ−2\theta - 2 (θ−2)2(\theta - 2)^2 J(θ)=10−(θ−2)2J(\theta) = 10 - (\theta - 2)^2
−2.1 −4.1 16.81 −6.81
0.4 −1.6 2.56 7.44
1.8 −0.2 0.04 9.96
−0.7 −2.7 7.29 2.71
3.2 1.2 1.44 8.56
2.5 0.5 0.25 9.75
−1.5 −3.5 12.25 −2.25
0.9 −1.1 1.21 8.79
4.4 2.4 5.76 4.24
1.1 −0.9 0.81 9.19

Step 1. The elite. The best fifth of ten draws are the two draws with the highest returns, θ=1.8\theta = 1.8 with 9.96 and θ=2.5\theta = 2.5 with 9.75.

Step 2. The new distribution.

μnew=1.8+2.52=2.15\mu_{\text{new}} = \frac{1.8 + 2.5}{2} = 2.15
σnew2=(1.8−2.15)2+(2.5−2.15)22=0.1225+0.12252=0.1225,    σnew=0.1225=0.35\sigma_{\text{new}}^2 = \frac{(1.8 - 2.15)^2 + (2.5 - 2.15)^2}{2} = \frac{0.1225 + 0.1225}{2} = 0.1225, \;\; \sigma_{\text{new}} = \sqrt{0.1225} = 0.35

One iteration moved the mean from 0 to 2.15, close to the best gain 2, and narrowed the spread from 2 to 0.35, or 0.4 with the constant 0.05 of the notebook. Part E of the lab runs further iterations.

Physics-informed learning

Engineering rarely starts from zero knowledge. Conservation laws, constitutive equations and boundary conditions are known even when parameters or source terms are not. Physics-informed neural networks add the residual of the governing differential equation, evaluated at many collocation points, to the loss of a network whose input is space or time [9]. Automatic differentiation provides the derivatives of the network output exactly. The network then fits the data where they exist and obeys the physics everywhere else, which makes it far more reliable outside the measured range than a data-only network. The same framework solves inverse problems, estimating unknown coefficients of the equation from data. Karniadakis and colleagues review the broader field of physics-informed machine learning [10]; related methods discover governing equations from data by sparse regression [11, 12]. Physics-informed networks can be hard to train for stiff or multiscale problems, and classical numerical solvers remain the reference where they apply.

A damped oscillator: a network trained only on a few early measurements fails outside them, while a physics-informed network that also satisfies the differential equation follows the exact solution .
Figure 14.1. A damped oscillator: a network trained only on a few early measurements fails outside them, while a physics-informed network that also satisfies the differential equation follows the exact solution [9].

Check your understanding. What does the physics term in the loss of a physics-informed network contain?

Formulas: The damped oscillator and the physics-informed loss

A mass mm on a spring of stiffness kk with a damper of coefficient cc obeys mx′′+cx′+kx=0m x'' + c x' + k x = 0, where x′x' and x′′x'' are the first and second derivatives of the displacement xx with respect to time. Divided by mm, the equation takes the standard form

x′′+2ζω x′+ω2x=0,    ω=k/m,    ζ=c2kmx'' + 2 \zeta \omega\, x' + \omega^2 x = 0, \;\; \omega = \sqrt{k/m}, \;\; \zeta = \frac{c}{2 \sqrt{k m}}

with the natural angular frequency ω\omega and the damping ratio ζ\zeta. Inserting x=estx = e^{s t} gives the characteristic equation s2+2ζωs+ω2=0s^2 + 2 \zeta \omega s + \omega^2 = 0. For ζ<1\zeta < 1 its roots are s=−ζω±iωds = -\zeta \omega \pm i \omega_d, with the imaginary unit ii and the damped angular frequency ωd=ω2−(ζω)2=ω1−ζ2\omega_d = \sqrt{\omega^2 - (\zeta \omega)^2} = \omega \sqrt{1 - \zeta^2}. They yield the real solutions e−ζωtcos⁡ωdte^{-\zeta \omega t} \cos \omega_d t and e−ζωtsin⁡ωdte^{-\zeta \omega t} \sin \omega_d t, oscillations that decay with the envelope e−ζωte^{-\zeta \omega t}, and every combination of them solves the equation. Released from x(0)=x0x(0) = x_0 at rest, x′(0)=0x'(0) = 0, the mass follows

x(t)=x0 e−ζωt(cos⁡ωdt+ζωωdsin⁡ωdt)x(t) = x_0\, e^{-\zeta \omega t} \Big( \cos \omega_d t + \frac{\zeta \omega}{\omega_d} \sin \omega_d t \Big)

A physics-informed network x^(t)\hat{x}(t) is trained on the sum of a data loss over the NdN_d measurements (ti,xi)(t_i, x_i) and a physics loss over NcN_c collocation points tjt_j, at which no measurement is needed [9]:

L=1Nd∑i=1Nd(x^(ti)−xi)2+λ 1Nc∑j=1Nc(x^′′(tj)+2ζω x^′(tj)+ω2x^(tj))2L = \frac{1}{N_d} \sum_{i=1}^{N_d} \big( \hat{x}(t_i) - x_i \big)^2 + \lambda\, \frac{1}{N_c} \sum_{j=1}^{N_c} \big( \hat{x}''(t_j) + 2 \zeta \omega\, \hat{x}'(t_j) + \omega^2 \hat{x}(t_j) \big)^2

The bracket of the second sum is the residual of the equation, which is zero for every exact solution. Automatic differentiation gives the derivatives of the network output exactly, the weight λ\lambda balances the two terms, and the initial conditions can enter as further terms of the same kind, as in the notebook [10].

Worked example: Residuals of two candidate solutions

The oscillator of the notebook obeys x′′+0.4x′+4x=0x'' + 0.4 x' + 4 x = 0 with x(0)=1x(0) = 1 and x′(0)=0x'(0) = 0, and two measurements are x(0.25)=0.885x(0.25) = 0.885 and x(0.5)=0.567x(0.5) = 0.567.

Step 1. Frequency and damping. Comparing with the standard form gives ω2=4\omega^2 = 4, so ω=2\omega = 2, and 2ζω=0.42 \zeta \omega = 0.4, so ζ=0.4/(2×2)=0.1\zeta = 0.4/(2 \times 2) = 0.1 and ζω=0.2\zeta \omega = 0.2. Then

ωd=4−0.22=4−0.04=3.96=1.989975,    ζωωd=0.21.989975=0.100504\omega_d = \sqrt{4 - 0.2^2} = \sqrt{4 - 0.04} = \sqrt{3.96} = 1.989975, \;\; \frac{\zeta \omega}{\omega_d} = \frac{0.2}{1.989975} = 0.100504

Step 2. The exact solution at the measurement times. With x(t)=e−0.2t(cos⁡1.989975t+0.100504sin⁡1.989975t)x(t) = e^{-0.2 t} (\cos 1.989975 t + 0.100504 \sin 1.989975 t):

x(0.25)=e−0.05(cos⁡0.497494+0.100504sin⁡0.497494)x(0.25) = e^{-0.05} (\cos 0.497494 + 0.100504 \sin 0.497494)
x(0.25)=0.951229×(0.878781+0.100504×0.477225)x(0.25) = 0.951229 \times (0.878781 + 0.100504 \times 0.477225)
x(0.25)=0.951229×(0.878781+0.047963)=0.951229×0.926744=0.881546x(0.25) = 0.951229 \times (0.878781 + 0.047963) = 0.951229 \times 0.926744 = 0.881546
x(0.5)=e−0.1(cos⁡0.994988+0.100504sin⁡0.994988)x(0.5) = e^{-0.1} (\cos 0.994988 + 0.100504 \sin 0.994988)
x(0.5)=0.904837×(0.544513+0.100504×0.838752)x(0.5) = 0.904837 \times (0.544513 + 0.100504 \times 0.838752)
x(0.5)=0.904837×(0.544513+0.084298)=0.904837×0.628811=0.568971x(0.5) = 0.904837 \times (0.544513 + 0.084298) = 0.904837 \times 0.628811 = 0.568971

The exact solution combines solutions of the equation, so its residual is 0 at every point and its physics loss is 0.

Step 3. An undamped candidate. The candidate xA(t)=cos⁡2tx_A(t) = \cos 2t starts at 1 at rest, like the true motion, but ignores the damper. Its derivatives are xA′=−2sin⁡2tx_A' = -2 \sin 2t and xA′′=−4cos⁡2tx_A'' = -4 \cos 2t, so its residual is

rA=−4cos⁡2t+0.4×(−2sin⁡2t)+4cos⁡2t=−0.8sin⁡2tr_A = -4 \cos 2t + 0.4 \times (-2 \sin 2t) + 4 \cos 2t = -0.8 \sin 2t

At four collocation points:

tt sin⁡2t\sin 2t rA=−0.8sin⁡2tr_A = -0.8 \sin 2t rA2r_A^2
0.5 sin⁡1=0.841471\sin 1 = 0.841471 −0.673177 0.453167
1 sin⁡2=0.909297\sin 2 = 0.909297 −0.727438 0.529166
1.5 sin⁡3=0.14112\sin 3 = 0.14112 −0.112896 0.012746
2 sin⁡4=−0.756802\sin 4 = -0.756802 0.605442 0.36656
Lphys=0.453167+0.529166+0.012746+0.366564=1.3616394=0.34041L_{\text{phys}} = \frac{0.453167 + 0.529166 + 0.012746 + 0.36656}{4} = \frac{1.361639}{4} = 0.34041

Step 4. Data and total losses. At the measurement times, xA(0.25)=cos⁡0.5=0.877583x_A(0.25) = \cos 0.5 = 0.877583 and xA(0.5)=cos⁡1=0.540302x_A(0.5) = \cos 1 = 0.540302. The data losses are

Ldata,A=(0.877583−0.885)2+(0.540302−0.567)22=(−0.007417)2+(−0.026698)22L_{\text{data}, A} = \frac{(0.877583 - 0.885)^2 + (0.540302 - 0.567)^2}{2} = \frac{(-0.007417)^2 + (-0.026698)^2}{2}
Ldata,A=0.000055+0.0007132=0.000384L_{\text{data}, A} = \frac{0.000055 + 0.000713}{2} = 0.000384
Ldata,exact=(0.881546−0.885)2+(0.568971−0.567)22=(−0.003454)2+0.00197122L_{\text{data}, \text{exact}} = \frac{(0.881546 - 0.885)^2 + (0.568971 - 0.567)^2}{2} = \frac{(-0.003454)^2 + 0.001971^2}{2}
Ldata,exact=0.000012+0.0000042=0.000008L_{\text{data}, \text{exact}} = \frac{0.000012 + 0.000004}{2} = 0.000008

With λ=1\lambda = 1, the total loss of the undamped candidate is 0.000384+0.34041=0.3407940.000384 + 0.34041 = 0.340794, while that of the exact solution is 0.000008. The data alone separate the candidates only weakly, since both stay within 0.03 of the measurements, while the physics term exposes the undamped candidate at once; a network trained on the data alone has no reason to prefer the damped motion beyond the measured range. Part F of the interactive lab evaluates these losses for other candidates, data and weights.

Digital twins

Grieves and Vickers described a digital twin as a virtual representation of a physical product that is linked to it by data throughout its life, so that behaviour can be predicted and problems anticipated [13]. Tao and colleagues surveyed its industrial use in design, production and maintenance [14]. A twin combines a model of the asset, a data connection that keeps the model's state and parameters current, and services such as monitoring, forecasting, what-if analysis and controller testing. System identification, estimating model parameters from measured inputs and outputs, is its simplest learning component; the notebook identifies the thermal parameters of the room of Week 1 from noisy data and uses the resulting model to forecast and to test a controller. The methods of the whole course appear in twins: rules and fuzzy logic for decisions, optimisation for calibration, machine learning for components without physical models, anomaly detection for monitoring and reinforcement learning for control.

Formulas: Identifying a model by least squares

The room of Week 1 changes in a time step Δt\Delta t by heat loss to the outside and by the heater:

Tk+1=Tk+a (Tout−Tk)+b uk,    a=Δtτ,    b=r ΔtT_{k+1} = T_k + a\, (T_{\text{out}} - T_k) + b\, u_k, \;\; a = \frac{\Delta t}{\tau}, \;\; b = r\, \Delta t

where τ\tau is the time constant of the room, rr the heating rate in °C per minute and uku_k is 1 while the heater is on. With the change yk=Tk+1−Tky_k = T_{k+1} - T_k and the inputs xk1=Tout−Tkx_{k1} = T_{\text{out}} - T_k and xk2=ukx_{k2} = u_k, the model is linear in the unknown parameters, yk=a xk1+b xk2+eky_k = a\, x_{k1} + b\, x_{k2} + e_k, where eke_k collects noise and model error. Least squares chooses aa and bb that minimise ∑kek2\sum_k e_k^2 [12]. Setting the derivatives of this sum with respect to aa and bb to zero gives the normal equations

S11 a+S12 b=S1y,    S12 a+S22 b=S2yS_{11}\, a + S_{12}\, b = S_{1y}, \;\; S_{12}\, a + S_{22}\, b = S_{2y}

with the sums S11=∑kxk12S_{11} = \sum_k x_{k1}^2, S12=∑kxk1xk2S_{12} = \sum_k x_{k1} x_{k2}, S22=∑kxk22S_{22} = \sum_k x_{k2}^2, S1y=∑kxk1ykS_{1y} = \sum_k x_{k1} y_k and S2y=∑kxk2ykS_{2y} = \sum_k x_{k2} y_k. Cramer's rule solves this system of two equations:

a=S1yS22−S12S2yS11S22−S122,    b=S11S2y−S12S1yS11S22−S122a = \frac{S_{1y} S_{22} - S_{12} S_{2y}}{S_{11} S_{22} - S_{12}^2}, \;\; b = \frac{S_{11} S_{2y} - S_{12} S_{1y}}{S_{11} S_{22} - S_{12}^2}

The physical parameters follow as τ=Δt/a\tau = \Delta t / a and r=b/Δtr = b / \Delta t. With the heater on and a constant outside temperature, the room settles where the loss balances the heating, a (Tout−T)+b=0a\, (T_{\text{out}} - T) + b = 0, at Teq=Tout+b/aT_{\text{eq}} = T_{\text{out}} + b/a. The identified model is the core of a simple twin: It forecasts the room from its current state, the differences between forecasts and measurements reveal faults, and controllers can be tested on it before they touch the building [13, 14].

Worked example: Identifying the room from six measurements

A room was logged every Δt=10\Delta t = 10 minutes at the outside temperature Tout=5T_{\text{out}} = 5 °C:

kk TkT_k (°C) uku_k xk1=5−Tkx_{k1} = 5 - T_k yk=Tk+1−Tky_k = T_{k+1} - T_k
0 18.00 1 5−18.00=−135 - 18.00 = -13 18.37−18.00=0.3718.37 - 18.00 = 0.37
1 18.37 1 5−18.37=−13.375 - 18.37 = -13.37 18.66−18.37=0.2918.66 - 18.37 = 0.29
2 18.66 0 5−18.66=−13.665 - 18.66 = -13.66 18.01−18.66=−0.6518.01 - 18.66 = -0.65
3 18.01 1 5−18.01=−13.015 - 18.01 = -13.01 18.33−18.01=0.3218.33 - 18.01 = 0.32
4 18.33 0 5−18.33=−13.335 - 18.33 = -13.33 17.70−18.33=−0.6317.70 - 18.33 = -0.63
5 17.70

Step 1. The sums. The squares and products of each step are

kk xk12x_{k1}^2 xk1 ykx_{k1}\, y_k
0 (−13)2=169(-13)^2 = 169 −13×0.37=−4.81-13 \times 0.37 = -4.81
1 (−13.37)2=178.7569(-13.37)^2 = 178.7569 −13.37×0.29=−3.8773-13.37 \times 0.29 = -3.8773
2 (−13.66)2=186.5956(-13.66)^2 = 186.5956 −13.66×(−0.65)=8.879-13.66 \times (-0.65) = 8.879
3 (−13.01)2=169.2601(-13.01)^2 = 169.2601 −13.01×0.32=−4.1632-13.01 \times 0.32 = -4.1632
4 (−13.33)2=177.6889(-13.33)^2 = 177.6889 −13.33×(−0.63)=8.3979-13.33 \times (-0.63) = 8.3979
S11=169+178.7569+186.5956+169.2601+177.6889=881.3015S_{11} = 169 + 178.7569 + 186.5956 + 169.2601 + 177.6889 = 881.3015
S1y=−4.81−3.8773+8.879−4.1632+8.3979=4.4264S_{1y} = -4.81 - 3.8773 + 8.879 - 4.1632 + 8.3979 = 4.4264

The heater was on in steps 0, 1 and 3, so the sums with xk2=ukx_{k2} = u_k collect only these steps:

S12=−13−13.37−13.01=−39.38,    S22=1+1+1=3,    S2y=0.37+0.29+0.32=0.98S_{12} = -13 - 13.37 - 13.01 = -39.38, \;\; S_{22} = 1 + 1 + 1 = 3, \;\; S_{2y} = 0.37 + 0.29 + 0.32 = 0.98

Step 2. The parameters. The common denominator is

S11S22−S122=881.3015×3−(−39.38)2=2643.9045−1550.7844=1093.1201S_{11} S_{22} - S_{12}^2 = 881.3015 \times 3 - (-39.38)^2 = 2643.9045 - 1550.7844 = 1093.1201

and the two numerators give

a=4.4264×3−(−39.38)×0.981093.1201=13.2792−(−38.5924)1093.1201=51.87161093.1201=0.047453a = \frac{4.4264 \times 3 - (-39.38) \times 0.98}{1093.1201} = \frac{13.2792 - (-38.5924)}{1093.1201} = \frac{51.8716}{1093.1201} = 0.047453
b=881.3015×0.98−(−39.38)×4.42641093.1201=863.6755−(−174.3116)1093.1201=1037.98711093.1201=0.949564b = \frac{881.3015 \times 0.98 - (-39.38) \times 4.4264}{1093.1201} = \frac{863.6755 - (-174.3116)}{1093.1201} = \frac{1037.9871}{1093.1201} = 0.949564

Step 3. Physical parameters. The time constant is τ=10/0.047453=210.73\tau = 10/0.047453 = 210.73 minutes and the heating rate r=0.949564/10=0.094956r = 0.949564/10 = 0.094956 °C per minute. The data were simulated with τ=200\tau = 200 minutes and r=0.1r = 0.1 °C per minute and carry sensor errors of about 0.02 °C, so six noisy measurements recover both parameters with errors of about 5%.

Step 4. Using the twin. With the heater on in the next step, the twin forecasts

T6=17.70+0.047453×(5−17.70)+0.949564×1T_6 = 17.70 + 0.047453 \times (5 - 17.70) + 0.949564 \times 1
T6=17.70+0.047453×(−12.7)+0.949564T_6 = 17.70 + 0.047453 \times (-12.7) + 0.949564
T6=17.70+(−0.602653)+0.949564=18.046911T_6 = 17.70 + (-0.602653) + 0.949564 = 18.046911

and with the heater on for good, the room would settle at the temperature

Teq=5+0.9495640.047453=5+20.0106=25.0106T_{\text{eq}} = 5 + \frac{0.949564}{0.047453} = 5 + 20.0106 = 25.0106

in °C, close to the 25 °C of the simulated room. A measurement far from the forecast would point to an open window, a failed heater or a faulty sensor. Part G of the interactive lab repeats the identification with more data and noise and shows how the estimates improve.

Responsible engineering of AI systems

Engineering codes of ethics require practitioners to hold public safety paramount, and they apply to systems that include learned components. Earlier work on machine ethics and AI safety argued that safety must be designed in rather than added after deployment [15]. Regulation now makes parts of this explicit. The European Union's Artificial Intelligence Act, Regulation (EU) 2024/1689, follows a risk-based approach: A few practices are prohibited, such as social scoring and the inference of emotions in the workplace and in education except for medical or safety reasons; high-risk systems, which include safety components in the management of critical infrastructure such as water, gas, heating and electricity supply, and systems used in employment and education, must meet requirements on risk management, data governance, documentation, human oversight, accuracy and robustness; and systems such as chatbots and generators of synthetic content carry transparency obligations [16].

Frameworks turn principles into practice. The NIST AI Risk Management Framework organises activities into four functions: Govern establishes policies, roles and accountability; Map establishes the context and identifies risks; Measure analyses and tracks risks with appropriate metrics; and Manage prioritises and acts on them [17]. ISO/IEC 42001 specifies a management system for organisations that develop or use AI, in the style of other management system standards [18]. Türkiye's national strategy places trustworthy and responsible AI among its priorities [19]. The energy and resource costs of training and running models are part of the same responsibility [20].

Check your understanding. Under the EU AI Act, which category most likely applies to an AI system that acts as a safety component in the management of a city's water supply network?

Formulas: How many tests support a failure rate

The Measure function of the NIST framework asks for metrics whose uncertainty is known [17]. A frequent question is how many tests without failure support a claimed failure rate of a system, for example of a vision inspection that must miss fewer than 1% of the defects. If every test fails with the probability pp, independently of the others, all nn tests pass with the probability

P(no failure in n tests)=(1−p)nP(\text{no failure in } n \text{ tests}) = (1 - p)^n

The claim that pp is below p0p_0 is supported with the confidence 1−α1 - \alpha if a system whose rate is exactly p0p_0 would pass all nn tests with a probability of at most α\alpha:

(1−p0)n≤α,    that is    n≥ln⁡αln⁡(1−p0)(1 - p_0)^n \le \alpha, \;\; \text{that is} \;\; n \ge \frac{\ln \alpha}{\ln(1 - p_0)}

Dividing by ln⁡(1−p0)\ln(1 - p_0), which is negative, reverses the inequality. After nn tests without failure, the same reasoning gives the upper confidence bound pu=1−α1/np_u = 1 - \alpha^{1/n} of the failure rate. For small rates, ln⁡(1−p0)\ln(1 - p_0) is close to −p0-p_0, and with α=0.05\alpha = 0.05, ln⁡0.05\ln 0.05 is close to −3-3, which gives the rule of three: About 3/p03/p_0 tests are needed, and nn passed tests bound the rate at about 3/n3/n. The tests must represent the conditions of use, since a shift between test and operating conditions breaks the argument [8].

Worked example: Demonstrating a miss rate below 1%

Step 1. The number of tests. With p0=0.01p_0 = 0.01 and α=0.05\alpha = 0.05:

n≥ln⁡0.05ln⁡0.99=−2.995732−0.0100503=298.0739n \ge \frac{\ln 0.05}{\ln 0.99} = \frac{-2.995732}{-0.0100503} = 298.0739

so 299 defective parts must all be detected, close to the 3/0.01=3003/0.01 = 300 of the rule of three.

Step 2. A test campaign of 500 parts. If the inspection detects all 500 defective parts, the upper bound of its miss rate is

pu=1−0.051/500=1−eln⁡0.05/500=1−e−2.995732/500p_u = 1 - 0.05^{1/500} = 1 - e^{\ln 0.05 / 500} = 1 - e^{-2.995732/500}
pu=1−e−0.005991=1−0.994027=0.005973p_u = 1 - e^{-0.005991} = 1 - 0.994027 = 0.005973

about 0.6%, again close to 3/500=0.0063/500 = 0.006.

Step 3. What the campaign rules out. A system that misses 1% of the defects would pass all 500 tests with the probability

0.99500=e500ln⁡0.99=e500×(−0.0100503)=e−5.02515=0.0065710.99^{500} = e^{500 \ln 0.99} = e^{500 \times (-0.0100503)} = e^{-5.02515} = 0.006571

so such a system would almost never pass the campaign. The bound covers only the defects and conditions that the 500 parts represent: Parts from a new supplier or a different lighting need tests of their own. Part H of the interactive lab places eight engineering AI systems into the risk categories of the EU AI Act, Part I matches project activities to the four functions of the NIST AI Risk Management Framework, and Part J plans the tests that support a failure rate.

The course in retrospect

The fourteen weeks form one toolbox. Search plans routes and sequences; rules encode standards; fuzzy logic turns words into control; evolutionary and swarm algorithms optimise designs; machine learning predicts, classifies and detects anomalies; deep learning perceives images and sequences; language models work with text and code; and reinforcement learning, physics-informed learning and digital twins bring learning into operation. The engineering skill lies in choosing the simplest tool that meets the requirement, validating it honestly, and knowing its limits. The final project, described in the exams folder of the repository, asks for exactly this on a problem of the student's own field.

Python step 14: Environments, learning and organised code

The Python step of this week is part of the Colab notebook, where every explanation stands next to a cell that runs it and the step closes with a quick check and exercises with immediate feedback. The printable lecture notes contain the same step together with the outputs of its code. The Colab button below opens the notebook at the step. Run the setup cell just above the step first, since the exercises use its check function.

Open Python step 14 in Colab View the notebook on GitHub

Review cards

Select a card to turn it over.

Markov decision process
States, actions, transition probabilities, rewards and a discount factor [1].
Q-learning update
Q(s, a) += alpha (r + gamma max Q(s', a') - Q(s, a)) [2].
Reward hacking
An agent maximises the reward in an unintended way; one of the concrete problems of AI safety [8].
Physics-informed neural network
Loss = data misfit + residual of the governing equation at collocation points [9].
Digital twin
Virtual model linked by data to a physical asset throughout its life [13].
EU AI Act
Risk-based regulation: prohibited practices, high-risk requirements, transparency obligations [16].

Continue the week

The week continues with the simulation and the self-assessment of the interactive lab and with the Python step and the hands-on work of the Colab notebook. The week overview lists the discipline challenges, the weekly task and the research assignment.

Interactive lab Colab notebook Self-assessment Week overview and tasks

References

[1] Sutton, R. S., & Barto, A. G. (2018). Reinforcement Learning: An Introduction (2nd ed.). MIT Press.

[2] Watkins, C. J. C. H., & Dayan, P. (1992). Q-learning. Machine Learning, 8(3-4), 279-292. https://doi.org/10.1007/BF00992698

[3] Mnih, V., Kavukcuoglu, K., Silver, D., et al. (2015). Human-level control through deep reinforcement learning. Nature, 518(7540), 529-533. https://doi.org/10.1038/nature14236

[4] Barto, A. G., Sutton, R. S., & Anderson, C. W. (1983). Neuronlike adaptive elements that can solve difficult learning control problems. IEEE Transactions on Systems, Man, and Cybernetics, SMC-13(5), 834-846. https://doi.org/10.1109/TSMC.1983.6313077

[5] Towers, M., Kwiatkowski, A., Terry, J., et al. (2024). Gymnasium: A standard interface for reinforcement learning environments. arXiv preprint arXiv:2407.17032. https://arxiv.org/abs/2407.17032

[6] Kober, J., Bagnell, J. A., & Peters, J. (2013). Reinforcement learning in robotics: A survey. The International Journal of Robotics Research, 32(11), 1238-1274. https://doi.org/10.1177/0278364913495721

[7] Degrave, J., Felici, F., Buchli, J., et al. (2022). Magnetic control of tokamak plasmas through deep reinforcement learning. Nature, 602(7897), 414-419. https://doi.org/10.1038/s41586-021-04301-9

[8] Amodei, D., Olah, C., Steinhardt, J., Christiano, P., Schulman, J., & Mané, D. (2016). Concrete problems in AI safety. arXiv preprint arXiv:1606.06565. https://arxiv.org/abs/1606.06565

[9] Raissi, M., Perdikaris, P., & Karniadakis, G. E. (2019). Physics-informed neural networks: A deep learning framework for solving forward and inverse problems involving nonlinear partial differential equations. Journal of Computational Physics, 378, 686-707. https://doi.org/10.1016/j.jcp.2018.10.045

[10] Karniadakis, G. E., Kevrekidis, I. G., Lu, L., Perdikaris, P., Wang, S., & Yang, L. (2021). Physics-informed machine learning. Nature Reviews Physics, 3(6), 422-440. https://doi.org/10.1038/s42254-021-00314-5

[11] Brunton, S. L., Proctor, J. L., & Kutz, J. N. (2016). Discovering governing equations from data by sparse identification of nonlinear dynamical systems. Proceedings of the National Academy of Sciences, 113(15), 3932-3937. https://doi.org/10.1073/pnas.1517384113

[12] Brunton, S. L., & Kutz, J. N. (2022). Data-Driven Science and Engineering: Machine Learning, Dynamical Systems, and Control (2nd ed.). Cambridge University Press. https://doi.org/10.1017/9781009089517

[13] Grieves, M., & Vickers, J. (2017). Digital twin: Mitigating unpredictable, undesirable emergent behavior in complex systems. In Transdisciplinary Perspectives on Complex Systems (F.-J. Kahlen, S. Flumerfelt, & A. Alves, Eds.) (pp. 85-113). Springer. https://doi.org/10.1007/978-3-319-38756-7_4

[14] Tao, F., Zhang, H., Liu, A., & Nee, A. Y. C. (2019). Digital twin in industry: State-of-the-art. IEEE Transactions on Industrial Informatics, 15(4), 2405-2415. https://doi.org/10.1109/TII.2018.2873186

[15] Kose, U. (2018). Are we safe enough in the future of artificial intelligence? A discussion on machine ethics and artificial intelligence safety. BRAIN. Broad Research in Artificial Intelligence and Neuroscience, 9(2), 184-197.

[16] European Parliament and Council of the European Union (2024). Regulation (EU) 2024/1689 laying down harmonised rules on artificial intelligence (Artificial Intelligence Act). Official Journal of the European Union, L series, 12 July 2024. https://eur-lex.europa.eu/eli/reg/2024/1689/oj

[17] National Institute of Standards and Technology (2023). Artificial Intelligence Risk Management Framework (AI RMF 1.0), NIST AI 100-1. NIST. https://doi.org/10.6028/NIST.AI.100-1

[18] International Organization for Standardization (2023). ISO/IEC 42001:2023 Information technology, Artificial intelligence, Management system. ISO.

[19] Presidency of the Republic of Türkiye Digital Transformation Office, & Ministry of Industry and Technology (2021). National Artificial Intelligence Strategy 2021-2025 (Ulusal Yapay Zekâ Stratejisi 2021-2025). Ankara. Action plan updated for 2024-2025. https://www.cbddo.gov.tr/UYZS

[20] Strubell, E., Ganesh, A., & McCallum, A. (2019). Energy and policy considerations for deep learning in NLP. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics (pp. 3645-3650). https://doi.org/10.18653/v1/P19-1355