Computer Systems Modelling: feedback control lab

Two small control systems to play with. Each simulation runs live; change the inputs and watch the response.

How it works and what to try

How it works: In two tabs. (1) Thermostat: set the setpoint, the proportional gain Kp, the noise on the room temperature, the outside temperature and the heater’s maximum power, and watch the room temperature, heater power and disturbance evolve live. Cards compare the measured offset and fluctuations with the predicted steady-state error and closed-loop time constant. (2) Router buffer: you are the controller. Drag a lever to set the sending rate, with a propagation delay D between you and the router, and try to avoid both overflow (drops) and underflow (idle capacity) in timed 60-second rounds. Switch between FCFS and fair sharing, or hand over to a proportional autopilot.

Try this: Turn the noise off and see a proportional controller settle below the setpoint; then raise Kp and watch the offset shrink and the response speed up. Open the window for a step disturbance, or limit the heater until it saturates. In the router, hold the queue steady with D = 0, then try again with D = 2 s. Raise the cross-traffic variability and compare FCFS with fair sharing.

Inputs

Model

dT/dt = −a(T − T_out) + b·u + w(t) e = T_ref − T u = sat[0, u_max]( K_p · e ) a = 0.1 per min (heat loss) b = 0.5 °C per kW·min (heater) w(t): i.i.d. N(0, σ²) °C/min, held for h = 0.1 min

The heater can only add heat, so u is clipped to the range [0, umax]. Time is in simulated minutes.

Setpoint T_ref 20.0 °C Σ + − e Controller K_p = 1.0 K_p·e Heater 0 to 5 kW u Disturbance w(t): Gaussian white noise w Room 5.0 °C loses heat to outside at 5 °C T feedback: measured room temperature
Room temperature T
Error e = T_ref − T
Heater power u
Predicted steady-state error
Closed-loop time constant
τ = 1/(a + b·K_p)
Mean error, last 20 min
Std. dev. of T, last 20 min
includes any start-up transient
room temperature T setpoint T_ref heater power u disturbance w

Things to try

  1. Set σ = 0 and Kp = 1, then press Reset. The room warms up but settles below the setpoint. Compare the measured offset with the predicted steady-state error ess = a(Tref − Tout) / (a + b·Kp). Why does a proportional controller need a nonzero error to keep the heater on?
  2. Raise Kp from 1 to 5. What happens to the offset? What happens to the speed of the response, as measured by τ?
  3. Now set σ = 2 and vary Kp. How does the size of the temperature fluctuations change? Compare the measured standard deviation with the approximation σ·√(h / 2(a + b·Kp)).
  4. Open the window. This is a step disturbance rather than zero-mean noise. How does the steady-state error change, and how long does the controller take to recover?
  5. Set umax = 2 kW and Tref = 28 °C. The heater saturates. Can any value of Kp reach the setpoint?
  6. Drop Tref well below the current room temperature. The heater switches off and the room cools at its natural rate a. What does this tell you about one-sided actuators?

Your control: sending rate λ

250200150100500
60packets per second

Drag the lever, or click it and use the arrow keys for fine control.

Parameters

One shared queue, served in arrival order.
Mean cross-traffic rate as a fraction of C.
Coefficient of variation of the cross-traffic rate.

Autopilot (optional)

Replaces you with a proportional controller λ = max(0, R + K(q* − q)), where R = C − x is the capacity left over by cross traffic. The sender sees q and R instantly, but its packets still take D seconds to arrive.

Model

Sender: Poisson packets, rate λ(t) Arrival at router: sent at t − D Buffer: one FCFS queue shared with cross traffic, q ≤ B; any arrival to a full buffer is dropped Link: capacity C = 100 pkt/s, serves the head of the queue Cross traffic: n(t) flows active, each sending Poisson packets at rate r; x(t) = r·n(t) flows start at rate M/τ and last Exp(τ), τ = 5 s, so n(t) ~ Poisson(M) M = 1/c_v², r = ρC/M ⇒ E[x] = ρC, CV[x] = c_v (c_v = 0: constant rate ρC) Rate available to you, R(t): FCFS: C − x(t) Fair: max(C − x, C/(n+1)), your max-min fair share; you and the cross traffic have separate virtual queues, each of size B

Changing D affects packets sent from then on; packets already in flight keep their original arrival times.

Score (lower is better)
0
=
Overflow
packets dropped
0
+
Underflow
idle capacity (packets)
0
Score = packets dropped + packets the link could have carried for you but did not, because your queue was empty. Under FCFS, cross-traffic drops count too, since you share their buffer. Under fair sharing, only your own drops count.
Free play: the score counts from the last Reset.
buffer occupancy q (all packets) your packets in buffer buffer size B λ sent your arrival rate at router (smoothed) cross-traffic rate x capacity available to you R
Elapsed time
Packets in flight
Overflow: your packets dropped
Underflow: your capacity unused
Your throughput

Things to try

  1. Set ρ = 0 (no cross traffic) and D = 0. Find a λ that keeps the queue roughly steady. Then set D = 2 s and try again. Why is it harder? Every adjustment you make takes D seconds to reach the router.
  2. Set ρ = 0.4 and cv = 0, so cross traffic is a steady Poisson stream at 40% of the link and the leftover capacity is a constant 0.6C. Can you hold the queue steady? Now raise cv to 0.5 and then 1. What changes?
  3. Because the link is FCFS, cross-traffic packets sit in the same queue as yours and take up buffer space. When a burst of cross traffic arrives, what happens to your drop rate even if you do not change λ?
  4. Set B = 20 and D = 3 s. Suppose the leftover capacity halves just as you react. Roughly how many packets pile up before your correction reaches the router? What does this suggest about sizing a buffer relative to the product of rate and delay?
  5. Switch from FCFS to fair sharing with cv = 1.5. Under fair sharing your packets and the cross traffic have separate virtual queues, and you are guaranteed at least C/(n+1), where n is the number of cross-traffic flows active at that moment. How do your drops and the swings in your queue compare with FCFS? Who benefits from fair sharing, and who pays for it?
  6. Play a few 60-second rounds with the default settings and try to lower your score. Is it better to keep the buffer nearly full or nearly empty? How does your answer change as you raise cv or D?