Loading in 5 sec....

CS416 - Mathematical Modelling & Prediction Lecturers – Douglas Leith, Robert ShortenPowerPoint Presentation

CS416 - Mathematical Modelling & Prediction Lecturers – Douglas Leith, Robert Shorten

- 54 Views
- Uploaded on

Download Presentation
## PowerPoint Slideshow about ' CS416 - Mathematical Modelling & Prediction Lecturers – Douglas Leith, Robert Shorten' - hyatt-harrington

**An Image/Link below is provided (as is) to download presentation**

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

When is real valued, system is overdamped (with special case called critically damped when a12+4a2=0) solution to system is the sum of pure exponentials When is complex valued, system is underdamped -solution to system is oscillatory, with envelope that decays exponentially for stable systems, grows exponentially for unstable systems.

CS416 - Mathematical Modelling & Prediction

Lecturers – Douglas Leith, Robert Shorten

Assessment – By final exam. No marked lab or tutorial work.

Tutorials – dates and times to be announced. Tutorials will be organised to run as each section of the course is completed.

Web – www.hamilton.ie/cs416/

What is mathematical modelling ?

- The development and solution of a set of mathematicalequations that describe a real situation to an acceptablelevel of accuracy.
- Used in order to predict what would happen in a real situation
- Note: We are interested here in quantitative rather than purely qualitative/descriptive models.

Topic of this course: modelling for decision support

- Predictive models almost always underly decision making in high performance systems

We seek models for decision support. In this course we are not seeking “true” models, but models which are “good enough” for the task at hand.

Example. Consider modelling an ideal gas

Volume, V

Pressure, P

Temperature, T

Related by model, PV=T

Each molecule has position (x,y,z) and velocity (u,v,w)

Increasing level of detail. What level of detail should we use in our model ?

Each molecule consists of atoms. Each atom consist of other particles …

Selecting the appropriate level of abstraction/detail is a key part of modelling.

Strongly application dependent and something of an “art”. Not dealt with in detail in this course, but we do note that it is linked to what we are able to observe/measure as well as to the purpose for which the model is intended.

- because when assessing a model against the real system we cannot decide between models which generate the same predicted observations

Example – A simple population model (the “logistic map”)

Let Ni be the population in year i

A crude model for population growth is that

Ni=aNi-1

When a>1, the population increases (unboundedly) each year. When a<1, the population decreases each year until it reaches zero (extinction).

This is obviously an oversimplification. We need to account for overcrowding and limited resources i.e. we expect the value of parameter a to vary with the population N.

Now have

Ni=a(Ni-1)Ni-1

Lets assume that a(N)= (1-N) for N in the interval [0,1]

See www.hamilton.ie/cs416/logisticmap.htm for arguments in support of this choice.

Example – A simple population model (the “logistic map”)

- Ni= (1-Ni-1)Ni-1 “Logistic Map”
- Note that this is a very much simplified model. Are these simplifications justified ? That is, how “good” is this model.
- depends on what we want to use it for.
- can compare predictions of model with observed behaviour to validate model/establish accuracy. Availability of observations places fundamental limit on quality of model.
- What can we use the model for ?
- The structure of the model reflects our understanding of the structure of the system
- a model organises our experiences and observations
- We can solve the model equations to make predictions
- - decision support

Example – A simple population model (the “logistic map”)

We can solve the model equations to make predictions …

Graphical Solution

Ni=Ni-1

Ni

Ni= (1-Ni-1)Ni-1 with =2

Ni-1

Example – A simple population model (the “logistic map”)

With =2, a stationary point exists to which all solutions in interval [0,1] are eventually attracted.

NB: “stationary point” = “equilibrium point” = “steady-state solution”

This is not always the case. For example, consider when =3.75

The population never settles down to a constant value

Ni

Ni-1

Example: Server with buffer/queue map”)

Queue length, q. Service rate, B packets/s.

Packets arrive at times t0,t1,t2,…

Ignoring servicing of packets just now, when a packet arrives we have

q(tn)=min(q(tn-1)+1, qmax)

Now, interval between two packets is tn-tn-1. During this interval B(tn-tn-1) packets are serviced i.e. removed from the queue. The queue size cannot fall below zero. So, we have as our model

Q=min(q(tn-1)+1-B(tn-tn-1), qmax)

q(tn)=max(Q,0)

Example: Server with buffer/queue and acknowledgement map”)

Now let’s model the behaviour of the source. Suppose we have one source and that it sends a new packet in response to the server signalling that it has finished servicing a packet. Also suppose that its time T for the packet to travel from the source to the queue.

- Send first packet at time t0.
- Packet arrives at queue at time to+T
- Service rate is B packets/s, so at time to+T+1/B server signals that packet has been serviced.
- Send second packet – time is now t1=t0+T+1/B
- Packet arrives at queue at time to+2T+1/B

Queue now doesn’t overflow, but server is idle for time T between packets arriving. Can we do better ?

Example: Server with buffer/queue and congestion control map”)

- Additive increase/multiplicative decrease congestion control (AIMD). Define a new variable W, the number of packets sent at each acknowledgement. Suppose also that the queue signals when it’s length exceeds a threshold, qmax.
- while q<qmax, let W=W+1 when a packet is acknowledged/seviced.
- when q=q,ax, W is reset to W/2.
- Our model becomes:
- tn-1+1/B when q(tn-1)>0
- tn =
- tn-1+T+1/B when q(tn-1)=0
- Q=min(q(tn-1)+ W(tn-1) -B(tn-tn-1) , qmax)
- q(tn)=max(Q,0)
- W(tn-1)+1 when q(tn)<qmax
- W(tn)=
- W(tn-1)/2 when q(tn)=qmax

Example: Server with buffer/queue and congestion control map”)

Sending rate adapts to maintain full queue (server never idle), with almost no dropped packets

queue size, q(t)

sending rate, w(t)

packets dropped

time, t

Example: Server with buffer/queue and congestion control map”)

What if now have a second source ?

Source 1

Source 2

Would like first source to reduce its sending rate so as to allow second source to successfully send packets – dynamic resource allocation.

Fair sharing source 1 should roughly halve its sending rate and source 2 take up the slack …

Example: Server with buffer/queue and congestion control map”)

Two sources, both using AIMD. Source 2 becomes inactive after 100s.

queue size, q(t)

sending rate, w1(t)

sending rate, w2(t)

time, t

Example: Vehicle transmission map”)

Engine torque, TH

Shaft torque, TL

Force, F

TL=NTH, N is gearbox ratio

Force exerted by wheel is TLR, with friction coeff, R radius of wheel

Air creates drag force -v, with v the velocity of vehicle

Newton’s Law: Force = mass*acceleration

F=NTHR- v=m a

Noting that a=dv/dt, we have the following model for the speed of the vehicle.

m dv/dt= NTHR - v

Example: Vehicle transmission map”)

Suppose the vehicle has two gears, N1 and N2. The gear used is selected by an automatic transmission. The model is then

N1THR - v in gear 1

m dv/dt=

N2THR - v in gear 2

+ a model of the the decision making process used by the automatic transmission.

Introduce map”)taxonomy of models. It turns out that most systems can be modelled using a fairly small set of model structures.

Study solutions, esp. numerical solutions/simulations

Can derive models from first principles or learn model from observations (or more usually by a combination of both approaches). We will not cover first principles modelling as very application specific. But will introduce machine learning approaches (including probabilistic reasoning ideas).

- Course Outline
- How do we derive a model for a system ?
- How do we extract information from it (esp. how do we obtain quantitative solutions and analyse their properties) ?
- this course is structured around these questions.

A taxonomy of mathematical models map”)

- Difference Equations
- Differential Equations
- Hybrid
- Linear
- Nonlinear
- Time-invariant
- Time-varying
- Other aspects of models can also be usefully classified, but not pursued here.
- Especially deterministic/stochastic models – stochastic models not covered in this course.

Can combine these two classifications e.g. linear differential equations

A taxonomy of mathematical models map”)

- Difference Equations
- Differential Equations
- Hybrid

Simple Example of a Difference Equation:

y(k) = a y(k-1), k=1,2,…

This is equivalent to the (infinite) set of equations:

y(1)=ay(0)

y(2)=ay(1)

y(3)=ay(2)

etc.

If have observations of y(0), y(1), etc, then this defines a relation between these observations. If y(1), y(2) etc are unknown, the equations can be solved to find them.

Difference Equations map”)

Logistic Map is another example of a difference equation

y(k)=(1-y(k-1))y(k-1), k=1,2,…

Can also include an external input u in the difference equation, e.g.

y(k) = a y(k-1)+bu(k-1), k=1,2,…

This is equivalent to the (infinite) set of equations:

y(1)=ay(0)+bu(0)

y(2)=ay(1)+bu(1)

y(3)=ay(2)+bu(2)

etc.

Difference Equations map”)

Definition:

Suppose there is a defined sequence of values y(k), k=0,1,2,… (e.g. representing values observed at equally-spaced time points). A difference equation is an equation relating the value y(k) to other values y(i), ik.

A difference equation is said to be causal wheny(k) is related to values y(i) with i<k.

i.e. y(k)=f(y(k-1),y(k-2),…,y(k-n), u(k-1),u(k-2),…,u(k-m))

where m,n are some constants.

NB: We write y(k)=f(y(k-1),y(k-2),…) but could equally well write this as y(k+1)=f(y(k),y(k-1),…), and this is often done.

u is an external input

Difference Equations map”)

A difference equation is said to be linear when the function f on the RHS is a linear function

i.e y(k)=a1(k)y(k-1) + a2 (k)y(k-2)+…+an (k)y(k-n)

+b1 (k)u(k-1)+b2 (k)u(k-2)+…+bm (k)u(k-m))

where a1(k), a2(k), …,an (k)and b1 (k),b2 (k), …, bm (k) are time-varying parameters. When these parameters are constants (do not vary with time), the model is said to be linear time-invariant.

- Difference Equations
- Differential Equations
- Hybrid
- Linear
- Nonlinear
- Time-invariant
- Time-varying

+

Linear Time-Invariant Difference Equations

Difference Equations map”)

A solution to a difference equation is a function y(k) that satisfies the equation. Solutions are readily derived by recursion.

e.g. for y(k)=ay(k-1) we have that

y(1)=ay(0)

y(2)=ay(1)=a2y(0)

y(3)=ay(2)=a3y(0)

etc.

i.e. a solution is y(k)=aky(0)

NB: We need to specify y(0) in order to solve this equation. This is called the initial condition for the equation. We need to specify both the equation and its initial condition in order to define a solution.

Difference Equations – Initial Conditions map”)

More generally,

y(k)=f(y(k-1),y(k-2),…,y(k-n), u(k-1),u(k-2),…,u(k-m))

We assume that the input values u(k) are defined beforehand. We must also specify y(0), y(1), …, y(n-1) in order to define a solution – in general the initial condition must specify n values.

Difference Equations – Existence & Uniqueness of Solutions map”)

- Note that a difference equation need not have any solution.
- e.g. y(k)2=-(1+y(k-1)2)
- has no solution since y(k)2 can never be negative.
- Also, even when a solution exists, it need not be unique i.e. there may exist many solutions.
- e.g. sin y(k) = y(k-1)
- Generally, however, a model of a physical system can be expected to possess a solution which is unique.

Difference Equations – Solutions to Linear Time-Invariant Models

- Recall that linear time-invariant difference equations have the form
- y(k)=a1y(k-1) + a2y(k-2)+…+any(k-n)
- +b1u(k-1)+b2u(k-2)+…+bmu(k-m))
- Consider the simplest system y(k)=ay(k-1) “first-order system”
- We have that y(1)=ay(0)
- y(2)=ay(1)=a2y(0)
- y(3)=ay(2)=a3y(0)
- etc
- So the solution is y(k)=aky(0). Note that the solution behaves as anexponential – we can rewrite it as y(k)=exp(k loga)y(0)
- For a<1, y(k)0 as k - system is said to be stable
- For a>1, y(k) as k - system is said to be unstable
- For a=1, solution neither grows of decays
- - system is said to be critically stable

Difference Equations – Solutions to Linear Time-Invariant Models

Also, rate of convergence/divergence varies with the value of a

a=0.95

y(k)

a=0.75

a=0.25

k

Difference Equations – Solutions to Linear Time-Invariant Models

Consider now y(k)=a1y(k-1) + a2y(k-2) “second-order system”

By analogy to the first-order case, try a solution of the form y(k)=ky(0) where is some (as yet unknown) constant. Then we need,

k y(0)=a1 k-1y(0)+a2 k-2y(0)

i.e. k - a1 k-1 - a2 k-2 = 0

Dividing through by k-2 gives

2 - a1 - a2 = 0

i.e. = a1/2 (a12+4a2)/2

We can work this through to derive an explicit solution. We won’t do this though. Observe that the situation where a12+4a2 < 0 (and so is complex valued) looks like its going to be different from when a12+4a2 < 0 (and so is real valued).

Difference Equations – Solutions to Linear Time-Invariant Models

Consider now y(k)=a1y(k-1) + a2y(k-2) “second-order system”

a12+4a2 < 0

“underdamped”

a12+4a2 > 0

“overdamped”

a1=1,a2=-0.2

(a12+4a2=+0.2)

y(k)

a1=1,a2=-0.5

(a12+4a2=-1)

k

Difference Equations – Solutions to Linear Time-Invariant Models

a1=1,a2=-0.75

a1=1,a2=-0.5

y(k)

y(k)

k

k

a1=1,a2=-0.95

a1=1,a2=-1

y(k)

y(k)

Difference Equations – Solutions to Linear Time-Invariant Models

- NOTE:
- = a1/2 (a12+4a2)/2
- Similarly to first-order case,
- For ||<1, y(k)0 as k - system is stable
- For ||>1, y(k) as k - system is unstable
- For ||=1, solution neither grows of decays
- – system is critically stable

Difference Equations – Equilibria of Linear Time-Invariant Models

For stable systems, the solution converges to a final value as k. This is called the equilibrium point of the system (also called stationary point or steady-state value).

Linear time-invariant difference equation:

y(k)=a1y(k-1) + a2y(k-2)+…+any(k-n)

+b1u(k-1)+b2u(k-2)+…+bmu(k-m))

When the input u is zero, at an equilibrium point y we must have: y=a1 y+a2 y+…+an y i.e. y=0

When input is non-zero, the equilibrium point will depend on the input. E.g. say u(k)=u, a constant value. Then

y=a1 y+a2 y+…+an y+b1u+b2u+…+bmu

i.e. y= u (b1+b2+…+bm)/(a1+a2+…+an)

Difference Equations – Solutions to Nonlinear Models Models

For linear difference equations, in qualitative terms only a small number of types of solution can exist (stable, unstable, overdamped, underdamped etc).

For nonlinear difference equations, the situation is much richer.

e.g. depending on the value of the parameter , the Logistic Map y(k)= (1-y(k-1))y(k-1) not onlyhas solutions which are stable and unstable but also has steady oscillatory solutions and chaotic solutions (complex oscillations) - these are both types of equilibrium solution which do not have just a single value y.

Difference Equations – y(k)= Models (1-y(k-1))y(k-1)

=3.5

“steady oscillation/limit cycle”

=1

“stable”

y(k)

y(k)

k

k

y(k)

y(k)

=3.9

“complex oscillation”

=4.1

“unstable”

k

k

So far have concentrated on difference equations. But physical systems are usually described by differential equations.

Recall Newton’s law:

F(t) = m a(t)

Force = mass x acceleration

We obtain velocity by integrating the acceleration

i.e.

Conversely, acceleration is obtained by differentiating velocity

i.e.

f(x) physical systems are usually described by differential equations.

0

xo

x

The derivative df/dx of a curve f(x) at a point xo is just the tangent to the curve at xo.

Higher-order derivatives are obtained recursively

i.e. , and more generally

f(x) physical systems are usually described by differential equations.

0

xo

x

The integral of a curve f(x) at a point xo is just the area under the curve between 0 and xo.

Differential Equations physical systems are usually described by differential equations.

- A simple example is
- dy(t)/dt = ay(t)
- Verify that the solution to this differential equation is:
- y(t)=exp(at) y(0)
- compare with the first-order difference equation y(k)=ay(k-1)
- which has solution y(k)=aky(0)=exp(k log(a)) y(0).

Differential Equations physical systems are usually described by differential equations.

Another example:

Can also include an external input u in the differential equation, e.g.

dy(t)/dt = a y(t)+bu(t)

Definition:

Suppose there is a function y(t) defined on an interval [to,t1]. A differential equation is an equation relating the value y(t) to some of its derivatives.

In general, a differential equation is of the form:

Differential Equations physical systems are usually described by differential equations.

A differential equation is said to be linear when the function f on the RHS is a linear function

i.e

where a1(t), a2(t), …,an (t)and b1 (t),b2 (t), …, bm (t) are time-varying parameters. When these parameters are constants (do not vary with time), the model is said to be linear time-invariant.

- Difference Equations
- Differential Equations
- Hybrid
- Linear
- Nonlinear
- Time-invariant
- Time-varying

Linear Time-Invariant Differential Equations

+

Differential Equations physical systems are usually described by differential equations.

A solution to a differential equation is a function y(t) that satisfies the equation.

E.g. the solution to dy(t)/dt = ay(t) is y(t)=exp(at) y(0)

Similarly to difference equations, we need to specify the initial condition y(0) in order to solve this equation i.e. we need to specify both the equation and its initial condition in order to define a solution.

E.g. the differential equation:

has general solution of the form y(t)=A+Bt where A,B are some constants. To find the values of these constants we use

y(0)=A, dy(0)/dt=B

Differential Equations physical systems are usually described by differential equations.

- Also, similarly to the difference equation y(k)=ay(k-1), the solution to dy(t)/dt = ay(t) is y(t)=exp(at) y(0)
- i.e.
- For a<0, y(t)0 as t - system is said to be stable
- For a>0, y(t) as t - system is said to be unstable
- For a=0, y(t)=y(0) - system is said to be critically stable
- Similarly to the second-order linear difference equation, the second-order linear differential equation
- exhibits overdamped, underdamped and critically damped responses depending on the values of a1 and a2.

Second-order Linear Differential Equation physical systems are usually described by differential equations.

a1=-0.7,a2=-0.75

a1=-0.29,a2=-0.93

y(t)

y(t)

time, t

time, t

a1=0,a2=-1

a1=-0.05,a2=-1

y(t)

y(t)

Compare with 2 physical systems are usually described by differential equations.nd order difference eqn y(k)=a1y(k-1) + a2y(k-2)

a1=1,a2=-0.75

a1=1,a2=-0.5

y(k)

y(k)

k

k

a1=1,a2=-0.95

a1=1,a2=-1

y(k)

y(k)

- Linear physical systems are usually described by differential equations.difference and differential equations are closely related.
- NOTE: This is generally only true for linear equations. Nonlinear equations seem to be fundamentally different,
- e.g. chaos can exist in first-order difference equations (such as the logistic map), but not in first-order differential equations (we need to go to at least third order to find a differential equation which exhibits chaos).
- Recall definition of derivative:
- This suggests that a derivative might be approximated by the finite difference:
- for small h. This is called the Euler approximation. We expect that as h is made smaller, the accuracy of the approximation improves.

Consider the first-order linear differential equation: physical systems are usually described by differential equations.

and now replace the exact derivative by its Euler approximation. We have

i.e. y(t+h)=y(t)+ha1(t)y(t)

Considering the time instants kh, k=0,1,2,… we have

y((k+1)h)=y(kh)+ha1(kh)y(kh)

which we can write as

y(k+1)=y(k)+ha1(k)y(k)

We have converted our first-order differential equation into a first-order difference equation. This conversion is only approximate, but the approximation becomes arbitrarily accurate as h is made small.

More generally, a linear differential equation: physical systems are usually described by differential equations.

can be approximated by a linear difference equation of the same order.

Example

Example – car braking (ABS) physical systems are usually described by differential equations.

Example – car braking (ABS) physical systems are usually described by differential equations.

- Inertia of car: m dv/dt = -Fx
- Inertia of wheel: J dw/dt = rFx – Tb
- m mass of car
- V velocity of car
- J rotational inertia of wheel
- w rotational velocity of wheel
- r radius of wheel
- Fx tyre friction force
- Tb braking torque
- Tyre friction force Fx model
- Fx = Fz()
- () = 1.28(1-e-24 ) – 0.52
- = (v-wr)/v “wheel slip”
Fz is vertical force (weight) of car

()

Hybrid Systems physical systems are usually described by differential equations.

- Difference Equations
- Differential Equations
- Hybrid

What are hybrid systems ? Mixture of discrete event systems and differential/difference equations.

+ =

Discrete event

systems

(automata)

Differential/

Difference

Equations

Hybrid system

Physical processes

Etc.

Logic, software, hardware, switches;

Collisions;

Communication networks;

Note: is just another way of writing dq/dt, dr/dt physical systems are usually described by differential equations.

Example: Server with congestion control

(differential equation version of scheme discussed in lecture one).

Hybrid Systems physical systems are usually described by differential equations.

Example – Bouncing ball

Consider the vertical motion of a ball in a gravitational field with uniform acceleration g. Let x1 be the height of the ball and x2 its velocity. Then when x10 we have

dx1/dt=x2

dx2/dt=-g

Note: is just another way of writing dx1/dt, dx2/dt

Bouncing ball equations

Height vs time

“Switched differential equation”

Hybrid Systems physical systems are usually described by differential equations.

- Solutions of Hybrid Equations

We obtain the solution to a switched equation by piecing together the solutions obtained in each mode. The piecing together is done such that the x1, x2 are continuous.

Hybrid Systems physical systems are usually described by differential equations.

- Solutions of Hybrid Equations

- What can go wrong ?
- 1. Problems in continuous evolution
- Existence
- Uniqueness

- 2. Problems in the hybrid execution
- Chattering
- Zeno

Hybrid Systems physical systems are usually described by differential equations.

- Solutions of Hybrid Equations:

Chattering

Hybrid Systems physical systems are usually described by differential equations.

- Solutions of Hybrid Equations:

Chattering

Note that chattering solutions do not always completely “stop”. Often, the system continues to evolve in a so-called sliding mode.

-1 w0

dw/dt=

1 w<0

dv/dt=-v

v

Solution “slides” along the surface w=0

0

w

Hybrid Systems physical systems are usually described by differential equations.

- Solutions of Hybrid Equations:

Zeno Execution

Hybrid Systems

Zeno execution = is infinite, but execution does not extend to t=+

Hybrid Systems physical systems are usually described by differential equations.

- Solutions of Hybrid Equations:

Similarly to difference and differential equations, hybrid systems can be classified as being stable, unstable etc.

Various definitions of stability are used, but all involve the solution decaying to an equilibrium solution as time .

The presence of switching in hybrid systems can sometimes lead to unexpected behaviour….

Hybrid Systems – Instability arising from switching physical systems are usually described by differential equations.

An example of decision-making and instability

a

c

b

“Car in the desert scenario”

Hybrid Systems - Instability arising from switching physical systems are usually described by differential equations.

System 1: Stable linear time-invariant differential equation:

dx1/dt=dx2/dt

dx2/dt=-2dx1/dt-0.2dx2/dt

Hybrid Systems - Instability arising from switching physical systems are usually described by differential equations.

System 2: Stable linear time-invariant differential equation:

dx1/dt=2dx2/dt

dx2/dt=-3dx1/dt-0.2dx2/dt

Hybrid Systems - Instability arising from switching physical systems are usually described by differential equations.

Switching between system 1 and system 2.

Introduce taxonomy of models. It turns out that most systems can be modelled using a fairly small set of model structures.

Study solutions, esp. numerical solutions/simulations

Can derive models from first principles or learn model from observations (or more usually by a combination of both approaches). We will not cover first principles modelling as very application specific. But will introduce machine learning approaches (including probabilistic reasoning ideas).

Course Outline

Download Presentation

Connecting to Server..