Lecture #4 Simulation of hybrid systems João P. Hespanha University of California at Santa Barbara Hybrid Control and Switched Systems.

Slides:



Advertisements
Similar presentations
Formal Computational Skills
Advertisements

MATLAB and SimulinkLecture 71 To days Outline  Callbacks  MATLAB And Simulink  S-functions  Project suggestions.
UPPAAL Introduction Chien-Liang Chen.
Hybrid System Verification Synchronous Workshop 2003 A New Verification Algorithm for Planar Differential Inclusions Gordon Pace University of Malta December.
Hybrid Systems Presented by: Arnab De Anand S. An Intuitive Introduction to Hybrid Systems Discrete program with an analog environment. What does it mean?
CS 367: Model-Based Reasoning Lecture 2 (01/15/2002)
Logic Synthesis – 3 Optimization Ahmed Hemani Sources: Synopsys Documentation.
Timed Automata.
Zonotopes Techniques for Reachability Analysis Antoine Girard Workshop “Topics in Computation and Control” March 27 th 2006, Santa Barbara, CA, USA
Semantic Translation of Simulink/Stateflow Models to Hybrid Automata using Graph Transformations A. Agarwal, Gy. Simon, G. Karsai ISIS, Vanderbilt University.
Lecture #13 Stability under slow switching & state-dependent switching João P. Hespanha University of California at Santa Barbara Hybrid Control and Switched.
Lecture #1 Hybrid systems are everywhere: Examples João P. Hespanha University of California at Santa Barbara Hybrid Control and Switched Systems.
Chess Review November 21, 2005 Berkeley, CA Edited and presented by Interchange Format for Hybrid Systems Alessandro Pinto UC Berkeley.
EECE Hybrid and Embedded Systems: Computation T. John Koo, Ph.D. Institute for Software Integrated Systems Department of Electrical Engineering and.
Simulation Where real stuff starts. ToC 1.What, transience, stationarity 2.How, discrete event, recurrence 3.Accuracy of output 4.Monte Carlo 5.Random.
Simulation with Arena, 3 rd ed.Chapter 11 – Continuous & Combined Discrete/Continuous ModelsSlide 1 of 11 Continuous and Combined Discrete/ Continuous.
Simulation with Arena, 4 th ed.Chapter 11 – Continuous & Combined Discrete/Continuous ModelsSlide 1 of 11 Continuous and Combined Discrete/ Continuous.
IBM WebSphere survey Kristian Bisgaard Lassen. University of AarhusIBM WebSphere survey2 Tools  WebSphere Application Server Portal Studio Business Integration.
1 A Tool for System Simulation: SIMULINK Can be used for simulation of various systems: – Linear, nonlinear; Input signals can be arbitrarily generated:
6th Biennial Ptolemy Miniconference Berkeley, CA May 12, 2005 Operational Semantics of Hybrid Systems Haiyang Zheng and Edward A. Lee With contributions.
Chess Review May 11, 2005 Berkeley, CA Operational Semantics of Hybrid Systems Haiyang Zheng and Edward A. Lee With contributions from the Ptolemy group.
Motivations In a deterministic setting: Difficult to assess global properties (stability, reachability) Model glitches: Zenoness De-abstaction is the solution?
SIMULINK Dr. Samir Al-Amer. SIMULINK SIMULINK is a power simulation program that comes with MATLAB Used to simulate wide range of dynamical systems To.
HossamTalaat - MATLAB Course - KSU - 21/1/24 1 IEEE Student Branch - College of Engineering - KSU Getting started with Simulink By Prof. Hossam Talaat.
NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Program Review May 10,
Ordinary Differential Equations (ODEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / Explicit ODE Solvers Daniel Baur ETH Zurich, Institut.
A Hybrid Systems Modeling Framework for Fast and Accurate Simulation of Data Communication Networks João P. Hespanha University of Calif. Santa Barbara.
Professor Walter W. Olson Department of Mechanical, Industrial and Manufacturing Engineering University of Toledo Solving ODE.
1 DISTRIBUTION A. Approved for public release; Distribution unlimited. (Approval AFRL PA # 88ABW , 09 April 2014) Reducing the Wrapping Effect.
Designing a Discrete Event Simulation Tool Peter L. Jackson School of Operations Research and Industrial Engineering March 15, 2003 Cornell University.
Lecture #9 Analysis tools for hybrid systems: Impact maps João P. Hespanha University of California at Santa Barbara Hybrid Control and Switched Systems.
Transformation of Timed Automata into Mixed Integer Linear Programs Sebastian Panek.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
MathCore Engineering AB Experts in Modeling & Simulation WTC.
Department of Mechanical Engineering The University of Strathclyde, Glasgow Hybrid Systems: Modelling, Analysis and Control Yan Pang Department of Mechanical.
MCTS Guide to Microsoft Windows Vista Chapter 4 Managing Disks.
Lecture #8 Stability and convergence of hybrid systems João P. Hespanha University of California at Santa Barbara Hybrid Control and Switched Systems.
Lecture #5 Properties of hybrid systems João P. Hespanha University of California at Santa Barbara Hybrid Control and Switched Systems.
Universidade do Minho Escola de Engenharia Techniques for Modeling Discrete Controllers for the Optimization of Hybrid Plants: a Case Study Universidade.
OUTLINE Overview Numbers, variables and similar in Matlab
Fall 2004EE 3563 Digital Systems Design EE 3563 VHSIC Hardware Description Language  Required Reading: –These Slides –VHDL Tutorial  Very High Speed.
Communicating Real-Time State Machines (CRSM) State machines that communicate synchronously Unique unidirectional channels are used for the communication.
Large Timestep Issues Lecture 12 Alessandra Nardi Thanks to Prof. Sangiovanni, Prof. Newton, Prof. White, Deepak Ramaswamy, Michal Rewienski, and Karen.
Lecture #3 What can go wrong? Trajectories of hybrid systems João P. Hespanha University of California at Santa Barbara Hybrid Control and Switched Systems.
Hybrid Modeling of TCP Congestion Control João P. Hespanha, Stephan Bohacek, Katia Obraczka, Junsoo Lee University of Southern California.
SIMULINK-Tutorial 1 Class ECES-304 Presented by : Shubham Bhat.
Lecture #14 Computational methods to construct multiple Lyapunov functions & Applications João P. Hespanha University of California at Santa Barbara Hybrid.
Lecture 6: Time Response 1.Time response determination Review of differential equation approach Introduce transfer function approach 2.MATLAB commands.
Transfer Functions Convenient representation of a linear, dynamic model. A transfer function (TF) relates one input and one output: The following terminology.
Intro to Simulink April 15, Copyright , Andy Packard. This work is licensed under the Creative Commons.
INTRODUCTION TO SIMULINK by Yasmin Hanum Md Thayoob & Aidil Azwin Zainul Abidin.
Lecture #2 How to describe a hybrid system? Formal models for hybrid system João P. Hespanha University of California at Santa Barbara Hybrid Control and.
TISC Suite Connects Simulation Tools. User Engine = … Refrigeration Cycle Passengers Compartment Redesign of models in one suitable program A BCoupling.
Graphical Design Environment for a Reconfigurable Processor IAmE Abstract The Field Programmable Processor Array (FPPA) is a new reconfigurable architecture.
Application model integration in the Virtual Test Bed Roger A. Dougal Dept of Electrical Engineering University of South Carolina Columbia, SC 29208
Simulink  ? 1 Simulink  ( Simu lation and Link ) is an extension of Matlab Offers modeling, simulation, and analysis of dynamical systems; i.e., a system.
Intro to Simulink Modified by Gary Balas 20 Feb 2011 Copyright , Andy Packard. This work is licensed under.
Lecture 2: Mathematical Modeling Copyright © Thomas Marlin 2013 The copyright holder provides a royalty-free license for use of this material at non-profit.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 6 - Chapters 22 and 23.
An Introduction to Computational Fluids Dynamics Prapared by: Chudasama Gulambhai H ( ) Azhar Damani ( ) Dave Aman ( )
More Vensim and “Stuff” Fall /14/20162 TODAY Recitation Lecture Hands-on.
Math for CS Fourier Transforms
João P. Hespanha University of California at Santa Barbara
First simulation results
CSCI1600: Embedded and Real Time Software
Class Notes 18: Numerical Methods (1/2)
CSE 245: Computer Aided Circuit Simulation and Verification
Lecture #10 Switched systems
CSCI1600: Embedded and Real Time Software
Multichannel Link Path Analysis
Presentation transcript:

Lecture #4 Simulation of hybrid systems João P. Hespanha University of California at Santa Barbara Hybrid Control and Switched Systems

Summary 1.Numerical simulation of hybrid automata simulations of ODEs zero-crossing detection 2.Simulators Simulink Stateflow SHIFT Modelica

Numerical simulation of ODEs Initial value problem (IVP) ´ Definition: A signal x : [0,T] ! R n is a solution to the IVP if Euler method (first order method): 1st partition interval into N subintervals of length h › T/N 2nd assume derivative of x constant on each subinterval t 0T x0x0 x(t)x(t) on each subinterval x is assumed linear

Numerical simulation of ODEs Initial value problem (IVP) ´ Definition: A signal x : [0,T] ! R n is a solution to the IVP if Runge-Kutta methods (m-order method): 1st partition interval into N subintervals of length h › T/N t 0T x0x0 x(t)x(t)  i,  i computed assuming a m- order polynomial approximation on each subinterval (truncated Taylor series) 2nd assume derivative of x constant on each subinterval

Numerical simulation of ODEs Initial value problem (IVP) ´ Definition: A signal x : [0,T] ! R n is a solution to the IVP if Variable-step methods (e.g., Euler): Pick tolerance  and define t 0 › 0 choose t k +1 sufficiently close to t k so that Simulation can be both fast and accurate: 1.when f is “flat” one can advance time fast, 2.when f is “steep” one advances time slowly (to retain accuracy)

Example #1: Bouncing ball t Free fall ´ Collision ´ g y g y c 2 [0,1) ´ energy absorbed at impact x 1 · 0 & x 2 < 0 ? x 2 › – c x 2 – linear/polynomial approximations are bad when transitions occur

Example #1: Bouncing ball x 1 · 0 & x 2 < 0 ? x 2 › – c x 2 – ball_nozerocross.mdl t

Example #1: Bouncing ball t before the transition the linear approximation seems very good so the integration algorithm is fooled into choosing a large integration step

Zero-crossing detection x 1 · 0 & x 2 < 0 ? x 2 › – c x 2 – ball_withzerocross.mdl After a transition is detected, the integration algorithm “goes back in time” to determine where the transition occurred and starts a new integration step at that point.

Zero-crossing detection t After a transition is detected, the integration algorithm “goes back in time” to determine where the transition occurred and starts a new integration step at that point.

Summary 1.Numerical simulation of hybrid automata simulations of ODEs zero-crossing detection 2.Simulators Simulink Stateflow SHIFT Modelica suitable for a small number of discrete modes difficult to recover hybrid automaton from Simulink file good for large numbers of discrete modes and complex transitions poor integration between continuous and discrete very good semantics (easily understandable) poor numerical algorithms very good numerical algorithms very convenient for large models with interconnected components difficult to recover hybrid automaton from simulink file

MATLAB’s Simulink 1. What you see: graphical user interface to build models of dynamical systems 2. What’s behind: numerical solver of ODEs with zero-crossing detection A little history… Commercial product developed by MathWorks (founded 1984, flag product is MATLAB/Simulink) MATLAB’s Simulink was inspired by MATRIXx’s SystemBuild (in 2001 MathWorks bought MATRIXx),

Simulation of ODEs simple_ode.mdl

Simulation of ODEs simple_odex0.mdl

ODEs with resets (or impulse systems) Q´ set of discrete states R n ´ continuous state-space f : R n ! R n ´ vector field  ½ R n ´ transition set  : R n ! R n ´ reset map x – 2  ? x›(q1,x–)x›(q1,x–) x 1 · 0 & x 2 < 0 ? x 2 › – c x 2 – E.g., bouncing ball

Simulation of ODEs with resets Q´ set of discrete states R n ´ continuous state-space f : R n ! R n ´ vector field  ½ R n ´ transition set  : R n ! R n ´ reset map x – 2  ? integrator with reset (by default does zero-crossing detection on reset input) x›(q1,x–)x›(q1,x–)

Example #1: Bouncing ball Q´ set of discrete states R n ´ continuous state-space f : R n ! R n ´ vector field  ½ R n ´ transition set  : R n ! R n ´ reset map x 1 · 0 & x 2 < 0 ? x 2 › – c x 2 – integrator with reset (by default does zero-crossing detection on reset input)

Example #1: Bouncing ball ball_withzerocross.mdl

Simulation of ODEs with resets Q´ set of discrete states R n ´ continuous state-space f : R n ! R n ´ vector field  ½ R n ´ transition set  : R n ! R n ´ reset map x 1 · 0 & x 2 < 0 ? x 2 › – c x 2 – x(tk)x(tk) x ( t k -1 ) The “reset” pulse is not really instantaneous (may lead to problems for “Zeno” systems)

Example #1: Bouncing ball ball_withzerocross.mdl fails to catch the “rising edge” of the reset trigger and the ball falls

Simulation of hybrid automaton (no resets) Q´ set of discrete states R n ´ continuous state-space f : Q £ R n ! R n ´ vector field  : Q £ R n ! Q´ discrete transition mode q 1 mode q 3  (q 1, x – ) = q 3 ? mode q 2  (q 1, x – ) = q 2 ? x · 73 ? x ¸ 77 ? q = 1 q = 2 E.g., thermostat heater room x ´ mean temperature

Simulation of hybrid automaton (no resets) Q´ set of discrete states R n ´ continuous state-space f : Q £ R n ! R n ´ vector field  : Q £ R n ! Q´ discrete transition mode q 1 mode q 2  (q 1, x – ) = q 2 ? Q ½ RQ ½ R

Example #2: Thermostat x · 73 ? x ¸ 77 ? q = 1 q = 2 heater room x ´ mean temperature

Example #2: Thermostat thermostat.mdl

Simulation of hybrid automaton Q´ set of discrete states R n ´ continuous state-space f : Q £ R n ! R n ´ vector field  : Q £ R n ! Q´ discrete transition  : Q £ R n ! R n ´ reset map mode q 1 mode q 3  (q 1, x – ) = q 3 ? mode q 2  (q 1, x – ) = q 2 ? x›(q1,x–)x›(q1,x–) x›(q1,x–)x›(q1,x–)

Simulation of hybrid automaton Q´ set of discrete states R n ´ continuous state-space f : Q £ R n ! R n ´ vector field  : Q £ R n ! Q´ discrete transition  : Q £ R n ! R n ´ reset map x›(q1,x–)x›(q1,x–) mode q 1 mode q 2  (q 1, x – ) = q 2 ?

Example #5: Tank system y pump goal ´ prevent the tank from emptying or filling up constant outflow ´  = 1 pump-on inflow ´ = 3  =.5 ´ delay between command is sent to pump and the time it is executed pump off (q = 1) wait to on (q = 2) pump on (q = 3 ) wait to off (q = 4) y · 1 ? y ¸ 2 ?  › 0  ¸  ?  › 0

Example #5: Tank system tank.mdl

Stateflow Q´ set of discrete states R n ´ continuous state-space f : Q £ R n ! R n ´ vector field  : Q £ R n ! Q´ discrete transition mode q 1 mode q 2  (q 1, x – ) = q 2 ? Simulink (continuous dynamics): generates continuous state Stateflow (discrete dyn.): generates discrete state & events (e.g., resets) signals & events

Simulation of hybrid automaton Q´ set of discrete states R n ´ continuous state-space f : Q £ R n ! R n ´ vector field  : Q £ R n ! Q´ discrete transition  : Q £ R n ! R n ´ reset map x›(q1,x–)x›(q1,x–) mode q 1 mode q 2  (q 1, x – ) = q 2 ? replaced by StateFlow “chart”

Simulation of hybrid automaton Q´ set of discrete states R n ´ continuous state-space f : Q £ R n ! R n ´ vector field  : Q £ R n ! Q´ discrete transition  : Q £ R n ! R n ´ reset map x›(q1,x–)x›(q1,x–) mode q 1 mode q 2  (q 1, x – ) = q 2 ? pump off wait to onpump on wait to off

Example #5: Tank system tank_sf_withzerocross.mdl Stateflow does not automatically does zero crossing detection, which must be done “manually”

Example #5: Tank system tank_sf_nozerocross.mdl Stateflow does not automatically does zero crossing detection, which must be done “manually”

SHIFT (Hybrid System Tool Interchange Format) 1.Simulation Language for Hybrid Automaton 2.Developed at UC Berkeley under the PATH (Partners for Advance Transit and Highways) project to simulate Automated Highway Systems 3.PATH provides freeware to compile SHIFT into a C-based simulator ( ) Advantages: 1.Syntax matches very closely the hybrid automata formalism 2.Object-oriented and scalable (multiple copies of a automata can be created, connected, disconnected, and destroyed as the simulation runs) Problems: 1.Currently the simulation engine is poor (limited integration algorithms, no zero-crossing detection) 2.Still in the development stages

A SHIFT program type AutomataType {// declaration of automata types input …// declaration of input signals state …// declaration of internal states output …// declaration of output signals export …// declaration of events for synchronization discrete …// declaration of discrete modes // & corresponding continuous dynamics transition …// definition of transition rules setup …// initializations } global …// declaration of global Automata setup …// creation and initialization of global Automata

Example #2: Thermostat x · 73 ? x ¸ 77 ? q = 1 q = 2 heater room x ´ mean temperature type ThermostatType { state continuous number x := 50; discrete heater_off { x’ = -x + 50; }, heater_on { x’ = -x + 100; }; transition heater_off -> heater_on {} when { x<= 73}, heater_on -> heater_off {} when { x>= 77}; } global ThermostatType thermostat; setup define { thermostat := create(ThermostatType, x:= 60); } declaration of the ThermostatType type declaration of a variable called “thermostat” of type “ThermostatType” creation (and initialization) of the hybrid automaton first declared is the initial mode thermostat.hs

Example #7: Server system with congestion control r server B rate of service (bandwidth) incoming rate q q max Additive increase/multiplicative decrease congestion control (AIMD): while q < q max increase r linearly when q reaches q max instantaneously multiply r by m  2 (0,1) q ¸ q max ? r › m  r – q(t)q(t) t queue dynamics congestion controller

Example #7: Server system with congestion control r server B rate of service (bandwidth) incoming rate q q max q ¸ q max ? r › m r – queue-full queue dynamics congestion controller synchronized transitions (all guards must hold for transition to occur) event queue-full variable r r > 1

Example #7: Server system with congestion control type CongestionControllerType { output continuous number r := 0; state number m := 0.5;// multiplicative decrease (parameter) export queue_full; discrete additive_increase { r’ = 1; } transition additive_increase -> additive_increase { queue_full } when { r > 1 } do { r := m * r; } } r › m r – queue-full congestion controller r > 1 resetsynchronization event jump condition congestion.hs

Example #7: Server system with congestion control q ¸ q max, r > B ? queue-full queue dynamics type QueueType { input continuous number r := 0; state continuous number q := 0; state CongestionControllerType controller;// controller to synchronize with state number B := 1;// Bandwidth (parameter) state number qmax := 10;// Maximum queue size (parameter) discrete empty_queue { q’ = 0; } full_queue { q’ = 0; } normal { q’ = r - B; } transition empty_queue -> normal {} when { r > B }, full_queue -> normal {} when { r < B }; normal -> empty_queue {} when { q <= 0 and r <= B ) do { q = 0; }, normal -> full_queue { controller:queue_full } when { q >= Qmax and r>B ) do { q = qmax; }, } normal empty full q · 0, r < B ? r > B ? r < B ? congestion.hs

Example #7: Server system with congestion control congestion controller queue dynamics variable r event queue_full global QueueType queue; global CongestionControllerType contr; setup define { contr := create(CongestionControllerType); queue := create(QueueType, controller := contr); } connect { r(queue) <- r(contr); } declaration of global variables creation (and initialization) of the hybrid automata inputs à output connections congestion.hs

Example #10: Server with multiple congestion controllers r1r1 server B rate of service (bandwidth) incoming rates q q max r2r2 congestion controller 2 queue dynamics congestion controller 1 r1r1 r2r2 queue_full

Example #10: Server with multiple congestion controllers type QueueType { input continuous number r1 := 0; input continuous number r2 := 0; state continuous number r := 0; state continuous number q := 0; state set(CongestionControllerType) controllers; state number B := 1;// Bandwidth (parameter) state number qmax := 10;// Maximum queue size (parameter) discrete empty_queue { q’ = 0; r = r1 + r2; } full_queue { q’ = 0; r = r1 + r2; } normal { q’ = r - B; r = r1 + r2; } transition empty_queue -> normal {} when { r > B }, full_queue -> normal {} when { r < B }; normal -> empty_queue {} when { q <= 0 and r <= B ) do { q = 0; }, normal -> full_queue { controllers:queue_full(all) } when { q >= Qmax and r>B ) do { q = qmax; }, } congestion controller 2 queue dynamics congestion controller 1 r1r1 r2r2 queue_full congestion2.hs

Example #10: Server with multiple congestion controllers congestion controller 2 queue dynamics congestion controller 1 r1r1 r2r2 queue_full global QueueType queue; global CongestionControllerType contr1; global CongestionControllerType contr2; setup define { contr1 := create(CongestionControllerType, r := 1.5); contr2 := create(CongestionControllerType, r := 2.0); queue := create(QueueType, controllers := {contr1,contr2} ); } connect { r1(queue) <- r(contr1); r2(queue) <- r(contr2); } declaration of global variables creation (and initialization) of the hybrid automata inputs à output connections congestion2.hs

Modelica 1.Object-oriented language for modeling physical systems 2.Developed and promoted by the Modelica Association (international non-profit, non-governmental organization based in Sweden) Dynasim AB sells Dymola, currently the best Modelica simulator (interfaces with MATLAB and Simulink) Advantages: 1.Object-oriented and scalable 2.Large number of component libraries available (electric circuits, mechanical system, thermo-hydraulics, power systems, robotics, petri-nets, etc.) 3.Numerically stable simulation engine (allows differential algebraic equations, automatic zero-crossing detection) 4.Heavily used in industry, especially in Europe 5.UCSB has a site license! Problems: 1.Not as widely known as MATLAB/Simulink

Modelica object model ModelName // declarations of public variables (inputs and outputs) that // can be accessed using “ModelName.Variable name” TypeName VariableName; … protected // declarations of internal (hidden) variables (state) TypeName VariableName; … equation // algebraic and differential equations Expression = Expression; … end ModelName

Modelica 101 Predefined types Real x,// x is a real number y (start = 1.1, unit = “inches” ) “height”; // y is a “height,” initialized with 1.1 “inches” Integern;// n is an integer Booleanp;// p can be either true or false Type modifiers parameterReal B;// B does not change during the simulation but // can be initialized with different values constantReal PI;// PI is a fixed constant discrete Real q;// q is a piecewise constant variable (discrete state) flow Real r;// r is a “flow” variable // (connection of flows follow conservation law, // by convention positive means flow enters component)

Modelica 101 Predefined functions/variables for use in equation der(x) // derivative of Real signal x pre(x)// left-limit of discrete signal x edge(x)// true when discrete variable x is discontinuous time// simulation time Commands for use in equation x = y// equate two variable x + z = y// (should be interpreted as equation and not assignment) reinit(x, 2.1);// reset variable x to to 2.1 connect(x,y);// connects variables: connect(x,z);// x = y = z (or x + y + z = 0 in case of flows) when p then// execute command when p becomes true command; end when;

Example #2: Thermostat x · 73 ? x ¸ 77 ? q = falseq = true heater room x ´ mean temperature model thermostat Real x "Average temperature"; Boolean q(start = false)"Heater state"; parameter Real xon = 73"Turn-on temperature"; parameter Real xoff = 77"Turn-off temperature"; equation q =if not pre(q) and x <= xon then true// turn on else if pre(q) and x >= xoff then false// turn off else pre(q);// no change der(x) = if q then 100-x else 50-x; end thermostat; thermostat.mo

Example #2: Thermostat To get started (bradbury.ece.ucsb.edu): setenv PATH /usr/local/dymola/bin:$PATH dymola5 thermostat.mo [documentation online & in refs in the course’s web page]

Example #7: Server system with congestion control r server B rate of service (bandwidth) incoming rate q q max q ¸ q max ? r › m r – queue-full queue-full ? queue dynamics congestion controller event queue-full variable r NOT synchronized transitions

Example #7: Server system with congestion control r › m r – queue-full congestion controller model Controller Real r(start=0)"out-flow"; discrete Boolean queue_full"Queue full"; parameter Real a=.1"Additive constant"; parameter Real m=.5"Multiplicative constant"; equation der(r) = a; when pre(queue_full) then reinit(r, r*m); end when; end Controller congestion.mo

Example #7: Server system with congestion control q ¸ q max, r > B ? queue-full queue dynamics normal empty full q · 0, r < B ? r > B ? r < B ? model Queue Real r "In-flow"; discrete Boolean queue_full(start=false)"Queue full"; parameter Real B=1"Bandwidth"; parameter Real Qmax=1"Max queue size"; protected discrete Integer status(start=0)"Queue status";// 0 empty, 1 normal, 2 full Real q(start=0)"Queue size"; equation status =if pre(status) == 0 and r > B then 1// no longer empty else if pre(status) == 2 and r < B then 1// no longer full else if pre(status) == 1 and q <= 0 and r < B then 0// became empty else if pre(status) == 1 and q >= Qmax and r > B then 2// became full else pre(status);// no change queue_full = pre(status) == 1 and status == 2; der(q) = if status == 1 then r - B else 0; end Queue congestion.mo

Example #7: Server system with congestion control congestion controller queue dynamics r queue_full model System Queue queue; Controller contr; equation queue.r = contr.r; queue.queue_full = contr.queue_full; end System congestion.mo

Example #7: Server system with congestion control congestion.mo

Example #10: Server with multiple congestion controllers r1r1 server B rate of service (bandwidth) incoming rates q q max r2r2 congestion controller 2 queue dynamics congestion controller 1 r1r1 r2r2 queue_full congestion2.mo

Example #10: Server with multiple congestion controllers congestion controller 2 queue dynamics congestion controller 1 r1r1 r2r2 queue_full model System Queue queue; Controller contr1; Controller contr2; equation queue.r = contr1.r + contr2.r; queue.queue_full = contr1.queue_full; queue.queue_full = contr2.queue_full; end System congestion2.mo

Example #10: Server with multiple congestion controllers congestion2.mo

Example #10: Server with multiple congestion controllers see congestion3.mo for the use of the connect command congestion3.mo

Interfacing Dymola & MATLAB/Simulink Sharing data Each time you simulate a Dymola model, a file “xxxx.mat” is created with all the data. You can get this data into MATLAB with load xxxx.mat Using Dymola models in Simulink Add dymola to the MATLAB path: path('/usr/local/dymola/mfiles',path) path('/usr/local/dymola/mfiles/traj',path) The Simulink block /usr/local/dymola/mfiles/DymolaBlockMaster.mdl can be used to insert a Dymola system into a Simulink diagram Not sure if its working?

Next class… Properties of hybrid systems Safety (reachability) Liveness Asymptotic properties (stability)