Madhur Behl
Computer Science
Systems and Information Engineering
Principles of Modeling for Cyber-Physical SystemsFall 2018
CS 6501-003 / SYS 6581-004/600
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 1
Meet your instructor
Madhur Behl
Assistant ProfessorComputer Science, Systems and Information Engineering.
Physicist at
Cyber-Physicist by profession
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 2
PhD, University of Pennsylvania (2015)Co-Founder @ Flexergy AI
What do I do..Modeling, simulation, control, optimization, and implementation of Cyber-Physical System
Cyber-Physical Energy Systems
Internet of things Critical Infrastructures & Smart Cities
Safety of Autonomous Vehicles
Data Predictive Control: Interfacing machine learning suitable for predictive control.
DeepExplainations:Answering open-ended queries using procedural generation and interpretable models.
DeepRacing AI:Algorithms for operating autonomous cars at the limits of their control
Madhur Behl - [email protected]
• Course logistics (5-7 mins)• Course introduction ( the interesting stuff !)
This lecture
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 4
• Timings: Tue & Thu 2:00pm – 3:15pm,
• Location: Olsson Hall 018
• Course website: https://linklab-uva.github.io/modeling_cps/
• All lectures notes/slides/assignments/videos will be posted on this website.
• Piazza: https://piazza.com/virginia/fall2019/modelingcpsfall2019/home
• Prerequisites (must have):
• Some familiarity with Matlab / Simulink.
• Some programming experience, Python is a plus.
• Mathematical maturity (differential equations, matrix operations, some calculus, probability
distributions)
•Prerequisites (good to have):
• Machine learning
• Temporal logic
• Model predictive control
Course Logistics
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 5
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 6
Teaching Assistants
Siavash Yousefi Jordehi Jiechao Gao
[email protected] [email protected]
Systems Engineering, PhD Computer Science, PhD
Office Hours: TBA
• No midterm, No final exam.
• The course has three modules (more on this later). Each module is equally weighted. • Energy CPS, Medical CPS, and Automotive CPS
• ~4 worksheets (posted on UVACollab/Website) in each module, comprising of:• Problem sets• Coding/implementation assignments
• 2 late homework submissions permitted – No questions asked.• Should not be more than 1 day late. 25% grade lost for each additional late day.
• Abide by the UVA honor system. Absolutely no code/solution sharing !
Grading
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 7
• Timings: Monday 2-3pm, or by appointment.
• Location: Link Lab Room 265 [Olsson Hall 2nd floor]
• Available by appointment outside of the listed hours:• To discuss course assignments or lectures.• Research opportunities.
• Live streamed office hours will be held for online CGEP students.
Office Hours
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 8
• Attend the lectures (in-person for on-grounds students)
• Check Piazza and the Course website for announcements, and assignments.
• Ask questions !• Ask, disagree, debate..
Your responsibilities.
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 9
what is this course about ?
Principles of Modeling for Cyber-Physical Systems
Lets break it down..
1. What are Cyber-Physical Systems ?2. What do you really mean by modeling ?3. What principles am I going to learn about ?
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 10
Cyber-Physical Systems
Deeply integrating computation, communication, and control
into physical systems
� Physical = some tangible, physical device or system + environment� Cyber = computational + communicational
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 11
Application domains: Transportation
Faster, safer, more energy-efficient air
travel
Improved use of airspace
Autonomous unmanned drones
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 12
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 13
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 14
Application domains: Transportation
Safety, security, and control of autonomous cars
• Connected vehicles.• Autonomous
fleets/ride sharing.• Traffic management
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 15
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 16
Application domains: Energy
• Smart buildings.• Energy-efficient
operation.
• Smart homes.• EV charging/solar
rooftops
• Reliable and resilient electricity grid.
• Micro grids.
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 17
Application domains: Healthcare + Biomedical
• Electronic patient record management.
• In home healthcare delivery.
Health and well being monitoring devices.
Safety, and security of medical devices and heath management systems.
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 18
Application domains: Critical Infrastructure
• Water & waste management.• Storm-water/flood control.
Structural health monitoring
Utility infrastructure- Gas, Electricity, Steam.
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 19
Application domains: … and many more
Agriculture Manufacturing Industrial Control
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 20
Characteristics of CPS
• Pervasive computation, sensing and control• Networked at multi- and extreme scales• Dynamically reorganizing/ reconfiguring• High degrees of automation
• Dependable operation with potential requirements for high assurance of reliability, safety, security and usability
•With / without human in-the-loop• Conventional and unconventional substrates / platforms
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 21
Closing the loop
Plant/System
Controller
ActuationSensingCyber
Physical
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 22
Human in the loop
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 23
Cyber-Physical Systems
Deeply integrating computation, communication, control, and humans
into physical systems
� Physical = some tangible, physical device or system + environment� Cyber = computational + communicational
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 24
Cyber-Physical Systems - Goals
Transform how we interact with the physical world
Fusion of physical and computational sciences
Produce significant impact on society
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 25
Why is CPS hard ?
package org.apache.tomcat.session;
import org.apache.tomcat.core.*;import org.apache.tomcat.util.StringManager;
import java.io.*;import java.net.*;import java.util.*;
import javax.servlet.*;import javax.servlet.http.*;
/*** Core implementation of a server session
** @author James Duncan Davidson [[email protected]]
* @author James Todd [[email protected]]*/
public class ServerSession {
private StringManager sm =StringManager.getManager("org.apache.tomcat.session");
private Hashtable values = new Hashtable();private Hashtable appSessions = new Hashtable();
private String id;
private long creationTime = System.currentTimeMillis();;private long thisAccessTime = creationTime;private long lastAccessed = creationTime;
private int inactiveInterval = -1;
ServerSession(String id) {this.id = id;
}
public String getId() {
return id;}
public long getCreationTime() {return creationTime;
}
public long getLastAccessedTime() {return lastAccessed;
}
public ApplicationSession getApplicationSession(Context context,boolean create) {
ApplicationSession appSession =(ApplicationSession)appSessions.get(context);
if (appSession == null && create) {
// XXX// sync to ensure valid?
appSession = new ApplicationSession(id, this, context);appSessions.put(context, appSession);
}
// XXX// make sure that we haven't gone over the end of our// inactive interval -- if so, invalidate and create
// a new appSession
return appSession;}
void removeApplicationSession(Context context) {appSessions.remove(context);
}
/*** Called by context when request comes in so that accesses and
* inactivities can be dealt with accordingly.
*/
void accessed() {// set last accessed to thisAccessTime as it will be left over
// from the previous access
lastAccessed = thisAccessTime;thisAccessTime = System.currentTimeMillis();
}
void validate()
Computing Control Systems
Crosses Interdisciplinary Boundaries
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 26
Why is CPS hard ?
• Disciplinary boundaries need to be realigned• New fundamentals need to be created• New technologies and tools need to be developed• Education need to be restructured
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 27
Why is CPS hard ?
• Disciplinary boundaries need to be realigned• New fundamentals need to be created• New technologies and tools need to be developed• Education needs to be restructured
Hmmm, I wonder if there is a course which is trying to achieve this?
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 28
what is this course about ?
Principles of Modeling for Cyber-Physical Systems
Lets break it down..
1. What are Cyber-Physical Systems ?2. What do you really mean by modeling ?3. What principles am I going to learn about ?
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 29
Modeling types: Physical modeling
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 30
Modeling types: Functional/compositional modeling
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 31
Do you know of any tools for functional modeling ?
Modeling types: Mathematical modeling
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 32
Modeling types: Computational modeling
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 33
Verification
Validation
A word about mathematical models
Physical
System
Reality
ObservationsMathematical
models
Observational
errorsModeling
errors
Computational/
Simulation
models
Discretization
errors
Control &
implementation
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 34
“Essentially all models are wrong, but some are useful”
- George E.P. Box (statistician)
….this course is about building useful models.
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 35
This course: Three CPS domains
Energy CPS Medical CPS Automotive CPS
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 36
Energy CPS Medical CPS Automotive CPS
1/Ugw
1/Ugi
1/Ugo
Cgo
Cgi
Tgo
Tg
Tgi
Tz
Q.rad,e
1/Uei1/Uew1/Ueo
Ceo Cei
Ta
Teo Tei
Q.sol,e
Q.solt/2
1/Uci
1/Ucw
1/UcoCci
Cci
Ta
Q.sol,c
Q.rad,c
Ta
Q.conv + Q.
sens
1/Uii 1/Uiw 1/Uio
Cii Cio
Tci
Tco
1/Uwin Tii Tio
Q.solt/2
Q.rad,g
[ExternalWalls]
Ti
[Ceiling]
[Floor]
[InternalWalls]
[Windows] White-boxState-space
TimedAutomata Data-driven
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 37
Energy CPS Medical CPS Automotive CPS
EnergyPlus
Matlab
UPPAAL
Simulink
TensorFlow
PythonPrinciples of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 38
Energy CPS ModulePrinciples of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 39
40Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected]
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 41
Price Volatility: Summer peak
20th, July 2015
Nominal price: $25/MWh Peak Price: $800/MWh
32x!
42Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected]
43
“All kilowatts are not created equally”
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected]
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 44
Price Volatility: Winter peak
24th, January 2014
Nominal price: $31.21/MWh Peak Price: $2,680.21/MWh
86x!
45Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected]
Price volatility is the new normalPJM (ISO) Locational Marginal Prices (LMPs) example
46Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected]
At large scales: University Campus
72 MWPeak (UCAP)
187 Buildings
300,000SCADA Tags
4 MillionGallons of chilled water (@42F)
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 47
~$28MAnnual Electricity Bill
In 2011
Peak > UCAP
30 min
$720,000Penalty for 30 minutes
Economic incentives for model based control
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 48
Why focus on Buildings ?
Portion of global energy use
Portion of electricity consumption in the United States
Portion of global total CO2 emissions
40%70%1/3
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 49
Model-Based control for buildings
Traditional rule-based building control
• Sequence of operations or planned steps.
• Pre-defined rules set by building
engineers.
• Purely reactive.
• Equipment-level controllers (PID) ensure
reference tracking.
Start Chiller #3 at 4:00
am
Start Chiller #1
Chiller #3
at 90%
load
Took 23 min yesterday
Took 42 min today
(but price increased !)
Model-based building control
• Model how the building will response to
disturbances (weather, occupants etc.)
• Predictive
• Control design:
• Energy-efficiency
• Demand flexibility
• Fault handling
• Okay to use equipment level PID control
Model Predictive Control (MPC)50Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected]
The control problem in buildings
51
Integrated control of:
• Heating• Cooling• Ventilation• Lighting• Blinds
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected]
State-space ‘RC’ thermal modeling
1/Ugw
1/Ugi
1/Ugo
Cgo
Cgi
Tgo
Tg
Tgi
Tz
Q.rad,e
1/Uei1/Uew1/Ueo
Ceo Cei
Ta
Teo Tei
Q.sol,e
Q.solt/2
1/Uci
1/Ucw
1/UcoCci
Cci
Ta
Q.sol,c
Q.rad,c
Ta
Q.conv + Q.
sens
1/Uii 1/Uiw 1/Uio
Cii Cio
Tci
Tco
1/Uwin Tii Tio
Q.solt/2
Q.rad,g
[ExternalWalls]
Ti
[Ceiling]
[Floor]
[InternalWalls]
[Windows]
Wall Dynamics
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 52
Whole building energy simulation
Using EnergyPlus.
Generating input-output data
Modeling a building in MATLAB
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 53
Non-linear parameter estimation and model validation
Model Accuracy for Training data
RMSE: 0.062 °CR2: 0.983
Model Accuracy for Test Data
RMSE: 0.091 °CR2: 0.948
Baseline
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 54
Predictive control
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 55
Medical CPS ModulePrinciples of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 56
Software related vehicle recalls
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 57
• Over 600,000 cardiac medical devices recalled from 1990-2000 – 40% of which were due to software issues
• 2008-12: 15% of all the medical device recalls due to software
Implantable Pacemaker Implantable Cardioverter-Defibrillator (ICD)58
• Muscle contraction triggered by electrical signals
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 59
• Slow generation and conduction of electrical signals
• Slow heart rate
• Symptom: fainting, dizziness
• Could lead to heart attack
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 60
• Two leads in heart chambers
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 61
• Two leads in heart chambers
• Deliver electrical signals when heart rate is low
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 62
• Two leads in heart chambers
• Deliver electrical signals when heart rate is low
• Device malfunction may result in injury or death
• Flawed devices are recalled
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 63
Pacemaker Autonomous device with minimum human interactionLimited diagnostic/therapy capabilityIts safety must be evaluated within its environment
The physical plant:Complex dynamics of the heartInteraction between the heart and the bodyDomain knowledge
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 64
Pacemaker
Scenario 1
Scenario 2
Scenario 3
65Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected]
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 66
Refractory
Time
V out
Rest ERP RRP Rest
Refractory
TimeV out
Rest ERP RRP Rest
node
pathnode
Principles of modeling for CPS – Fall 2019 67Madhur Behl - [email protected]
68Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected]
69
Cellular Level
Node Automaton• Divide refractory period into time periods
• Model refractory properties as timers using timed automata.
• These time periods can be measured during EP study
Madhur Behl - [email protected]
71
The UPPAAL model of the closed-loop system
72
Model checking – Counter example guided.
Safety property
Ventricular rate should not be equal or above the upper rate limit for more than 30 beats
![]$%& '%$(&%). +))
Heart Pacemaker
Aget!
Vget!
AP!
VP!
monitorMadhur Behl - [email protected]
Automotive CPS ModulePrinciples of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 73
Localization and Mapping
Scene Understanding
Trajectory Planning and Control
Human Interaction
Where am I ?
Where/who/what/why of
everyone/everything else ?
Where should I go next ?
How do I steer and accelerate ?
How do I convey my intent to the
passenger and everyone else ?Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 74
Localization and Mapping
Scene Understanding
Trajectory Planning and Control
Human Interaction
Where am I ?
Where/who/what/why of everyone/everything else ?
Where should I go next ? How do I steer and accelerate ?
How do I convey my intent to the passenger and everyone else ?
Deep
Lea
rnin
g
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 75
Localization and Mapping
Scene Understanding
Trajectory Planning and Control
Human Interaction
Where am I ?
Where/who/what/why of everyone/everything else ?
Where should I go next ? How do I steer and accelerate ?
How do I convey my intent to the passenger and everyone else ?
End-
to-e
nd le
arna
ble
Deep
Neu
ral N
etw
orks
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 76
Center camera CNN
Steeringcommand
Drive-by-wire interface
End-to-End Deep Learning for Self Driving Cars - NVIDIA
Video credit:DeepTesla
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 77
Machine intelligence is largely about training data.
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 78
Image courtesy: Cognata
When’s a pedestrian not a pedestrian? When it’s a decal.
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 79
One car ? or Multiple cars ?
There is a bus right next to you!!
Autonomous Driving: End-to-End
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 86
Autonomous Driving: End-to-End
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 87
Autonomous Driving: End-to-End
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 88
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 89
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 90
what is this course about ?
Principles of Modeling for Cyber-Physical Systems
Lets break it down..
1. What are Cyber-Physical Systems ?2. What do you really mean by modeling ?3. What principles am I going to learn about ?
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 91
•Modeling for predictive control.• Parameter estimation. • Linear and non-linear
•Model checking•Model validation•Model selection• Model abstraction/reduced order modeling
• End-to-end learning
This course: Modeling principles
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 92
This course: Learning objectives
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 93
DomainExpert
(Physical System)
Modelingprinciples
Tools &implementation
This course: Learning objectives
Principles of modeling for CPS – Fall 2019 94
The future belongs to those who learn more skills and combine them in creative ways.
Madhur Behl - [email protected]
This course: Becoming a Cyber-Physicist
Parameter estimation
Med CPS
Automotive CPS
First principles modeling
Model checking
Timed automataData-driven modeling
State-SpaceModeling
Energy CPS
EnergyPlusUPPAAL
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 95
Cyber-Physicist
Next lecture:
• How to predict the future..
• State-space modeling using first principles.• Mechanical, electrical, thermal systems• ODEs and elements of white box modeling
Principles of modeling for CPS – Fall 2019 Madhur Behl - [email protected] 96