Problem 334317 · easy · Level 03 Linear Management & Searching

Handing Over Without a Bump

PI control · bumpless transfer · integrator initialisation · manual mode

In a greenhouse the boiler's hot-water valve has been held by hand at u_man per cent open while the PI controller was being repaired. Now the grower switches back to automatic. If the controller starts with an empty integral, its first command can be far from what the valve is doing, and the valve slams to a new position: a thermal shock for the pipes and the plants. A bumpless transfer loads the integral before the switch, so the first automatic command equals the manual one and the controller takes over smoothly from there.

The controller works as in the previous problems. At the moment of the switch it reads the temperature y, and then, in this order:

e = r - y
I = I + e * dt
u = Kp * e + Ki * I

where I is whatever the integral held just before the switch.

Write bumpless_start(u_man, r, y, Kp, Ki, dt) that returns a tuple (I_load, bump):

  1. I_load: the value to put in I just before the switch so that the first command u equals u_man exactly;
  2. bump: how far the first command would jump if the integral started at 0 instead, u - u_man (percentage points; negative means the valve would slam towards shut).

Examples

Input:  u_man = 40, r = 22, y = 20.5, Kp = 8, Ki = 0.2, dt = 1
Output: (138.5, -27.7)
Explanation: e = 1.5. The P term gives 12, so the I term must give 28 after the update:
I after the update = 28 / 0.2 = 140, and before it 140 - 1.5 = 138.5.
Starting from 0 the command would be 12 + 0.2 * 1.5 = 12.3 %, a jump of -27.7 points.

Input:  u_man = 10, r = 20, y = 20, Kp = 5, Ki = 0.5, dt = 2
Output: (20.0, -10.0)

Constraints

  • Ki > 0 (without an integral there is nothing to load)
  • answers are compared with a tolerance of 1e-6; do not round

Goals

  • Work backwards from a desired command to the integral that produces it
  • Respect the controller's update order when solving for its state
  • Measure the jump a careless switch to automatic causes
Starting Python…