Principles of Modeling for Cyber-Physical Systems · •~4 worksheets (posted on UVACollab/Website)...

Post on 09-Mar-2020

1 views 0 download

Transcript of Principles of Modeling for Cyber-Physical Systems · •~4 worksheets (posted on UVACollab/Website)...

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 - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu

• Course logistics (5-7 mins)• Course introduction ( the interesting stuff !)

This lecture

Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 5

Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu 6

Teaching Assistants

Siavash Yousefi Jordehi Jiechao Gao

sy3fw@virginia.edu jg5ycn@virginia.edu

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 - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 12

Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu 13

Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 15

Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 19

Application domains: … and many more

Agriculture Manufacturing Industrial Control

Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 21

Closing the loop

Plant/System

Controller

ActuationSensingCyber

Physical

Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu 22

Human in the loop

Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 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 [duncan@eng.sun.com]

* @author James Todd [gonzo@eng.sun.com]*/

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 - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 29

Modeling types: Physical modeling

Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu 30

Modeling types: Functional/compositional modeling

Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu 31

Do you know of any tools for functional modeling ?

Modeling types: Mathematical modeling

Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu 32

Modeling types: Computational modeling

Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 35

This course: Three CPS domains

Energy CPS Medical CPS Automotive CPS

Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 37

Energy CPS Medical CPS Automotive CPS

EnergyPlus

Matlab

UPPAAL

Simulink

TensorFlow

PythonPrinciples of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu 38

Energy CPS ModulePrinciples of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu 39

40Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu

Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu

43

“All kilowatts are not created equally”

Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu

Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu

Price volatility is the new normalPJM (ISO) Locational Marginal Prices (LMPs) example

46Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu

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 - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu

The control problem in buildings

51

Integrated control of:

• Heating• Cooling• Ventilation• Lighting• Blinds

Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu

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 - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 54

Predictive control

Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu 55

Medical CPS ModulePrinciples of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu 56

Software related vehicle recalls

Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 60

• Two leads in heart chambers

Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu 61

• Two leads in heart chambers

• Deliver electrical signals when heart rate is low

Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 64

Pacemaker

Scenario 1

Scenario 2

Scenario 3

65Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu

Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu

68Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu

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 - madhur.behl@virginia.edu

70

Cellular Level

Node Automaton

Madhur Behl - madhur.behl@virginia.edu

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 - madhur.behl@virginia.edu

Automotive CPS ModulePrinciples of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 77

Machine intelligence is largely about training data.

Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 86

Autonomous Driving: End-to-End

Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu 87

Autonomous Driving: End-to-End

Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu 88

Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu 89

Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 92

This course: Learning objectives

Principles of modeling for CPS – Fall 2019 Madhur Behl - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu

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 - madhur.behl@virginia.edu 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 - madhur.behl@virginia.edu 96