Feedback Control For programmers and other strangers

28
Feedback Control For programmers and other strangers Philipp K. Janert Principal Value, LLC

description

Feedback Control For programmers and other strangers. Philipp K. Janert Principal Value, LLC. Feedback Control. What is feedback control? Why should I care?. Definition. Feedback Control: An automated method to choose a system’s configuration parameters - PowerPoint PPT Presentation

Transcript of Feedback Control For programmers and other strangers

Page 1: Feedback Control For programmers and other strangers

Feedback ControlFor programmers

and other strangers

Philipp K. JanertPrincipal Value, LLC

Page 2: Feedback Control For programmers and other strangers

Feedback Control

•What is feedback control?

•Why should I care?

Page 3: Feedback Control For programmers and other strangers

Definition

Feedback Control:

An automated method

to choose a system’s configuration parameters

in order to achieve a desired behavior

in the presence of uncertainty and change.

Page 4: Feedback Control For programmers and other strangers

Examples

Example 1: Cache

Configuration Variable (Input):

Size (Max number of items)

Monitored Metric (Output):

Hit rate (Success Rate)

Page 5: Feedback Control For programmers and other strangers

Examples

Example 2: Sever Farm

Configuration Variable (Input):

Number of Instances Online

Monitored Metric (Output):

Average Response Time

Page 6: Feedback Control For programmers and other strangers

Examples

Example 3: Waiting Queue

Configuration Variable (Input):

Number of Consumer Instances

Monitored Metric (Output):

Average Holding Time (or: Queue Length)

Page 7: Feedback Control For programmers and other strangers

Examples

Example 4: Workflow

Configuration Variable (Input):

Release Rate or Flow Rate (Number of items released per period)

Monitored Metric (Output):

Length of Downstream Queue (Number of items pending)

Page 8: Feedback Control For programmers and other strangers

Examples

Example 5: Graphics Engine

Configuration Variable (Input):

Graphics Resolution (Pixels per Game Object)

Monitored Metric (Output):

Memory Consumption

Page 9: Feedback Control For programmers and other strangers

In Common…

Cache SizeServer Instances

Queue ConsumersFlow Rate

Graphics Resolution

Hit RateResponse TimeWaiting TimeQueue LengthMemory Consumption

1. System transforming Input to Output2. Desired Outcome3. Uncertainty4. Change

Page 10: Feedback Control For programmers and other strangers

Feedforward

1.Figure it out (Algorithmic-Deterministic)

2.Trial and Error (Heuristic)

3.Change on Demand (Firedrill…)

Difficulty: How to control in the face of uncertainty and change?

Schedule

System

Page 11: Feedback Control For programmers and other strangers

Feedback

Poor-Man’s Solution:

1. Pick some value

2. Check the output

3. Apply a correction

4. Repeat!

Trial and Error: It’s no longer a bug, now it’s a feature!

Page 12: Feedback Control For programmers and other strangers

Feedback Loop Architecture

r : Reference Value (“Setpoint”)

e : Tracking Error

u : Input (Configuration Parameter)

y : Output (Tracked Metric)

Controller Plant u r ye = r - y

Page 13: Feedback Control For programmers and other strangers

Feedback Loop Architecture - Cache

What does the Controller Do?

•Apply a correction in the correct direction…

•… and of approximately the right size.

Controller Cache SizeSetpoint Hit Rate Error

Page 14: Feedback Control For programmers and other strangers

Feedback Loop Architecture - Cache

Challenge:

Correction must be approximately the right size

•Too large: instability and oscillation

•Too small: slow and insufficient response

Controller Cache (1000)Sizer = 0.8 Hit Rate y = 0.7 e = r - y

Page 15: Feedback Control For programmers and other strangers

Review, Part 1

What is Feedback and Why should I care?

An automated method

to choose a system’s configuration parameters

in order to achieve a desired behavior

in the presence of uncertainty and change.

Page 16: Feedback Control For programmers and other strangers

Review, Part 2

How does feedback work?

Feedback works by repeatedly comparing the output to the setpoint,

and applying a corrective action in the correct direction.

What are the challenges?

Corrections must be approximately the right size:

•Small enough to avoid instability and oscillation

•Large enough to provide sufficiently quick response and compensation

Page 17: Feedback Control For programmers and other strangers

Controller Implementation

Feedback controllers can be simple,

because of the self-correcting nature of the loop architecture.

(Feedforward controllers tend to be complex, by contrast.)

Controller Plant InputSetpoint Output Error

Page 18: Feedback Control For programmers and other strangers

Controller Implementation

Typical Choice: Cumulative Error (“Integral Control”)

cumul += error

action = gain * cumul

Controller Plant InputSetpoint Output Error

Page 19: Feedback Control For programmers and other strangers

Controller ImplementationIntegral Controller

Controller gain k = 1000

Time Step Setpoint r

Error e = r –y Cumulative c Size k*c Hit Rate y

0 0.8 0 0

1 0.8 0.8 0.8 800 0.6

2 0.8 0.2 1.0 1000 0.7

3 0.8 0.1 1.1 1100 0.8

4 0.8 0.0 1.1 1100 0.8

n 0.8 1.2 1200 0.9

n+1 0.8 -0.1 1.1 1100 0.8

Page 20: Feedback Control For programmers and other strangers

Controller Implementation

PI Controller (Proportional-Integral Controller)

cumul += error

action = kp * error + ki * cumul

With two gain parameters: kp and ki (proportional and integral)

95% of all installed controllers are PI Controllers!

Page 21: Feedback Control For programmers and other strangers

Controller Tuning

How does one find values for the gain parameters?

•Theoretical Description (if available)

•Inspection

•Experiments and Formulas (Heuristics)

Why is this better than finding the system parameters directly?

•Controller gains need only be known approximately.

•Feedback architecture gives robustness to change.

Page 22: Feedback Control For programmers and other strangers

Results - Cache

Page 23: Feedback Control For programmers and other strangers

Results - Cache

Page 24: Feedback Control For programmers and other strangers

Results - Cache

Page 25: Feedback Control For programmers and other strangers

Summary

Feedback Control is an automated method

to choose a system’s configuration parameters

in order to achieve a desired behavior

in the presence of uncertainty and change.

Feedback works by repeatedly comparing the output to the setpoint,

and applying a corrective action in the correct direction.

Page 26: Feedback Control For programmers and other strangers

Summary

Stable systems rely on feedback everywhere…• Electrical Engineering• Aeronautics• Process Control• Biological Processes• Economy• Relationships• …

… isn’t it time we programmers give it a try?

Page 27: Feedback Control For programmers and other strangers

Philipp K. JanertPrincipal Value, LLC

[email protected]

Page 28: Feedback Control For programmers and other strangers