Dynamic systems -------------------------------------------- - - PDF document

dynamic systems differential approaches
SMART_READER_LITE
LIVE PREVIEW

Dynamic systems -------------------------------------------- - - PDF document

Lesson 2 University of Bergamo Engineering and Management for Health FOR CHRONIC DISEASES MEDICAL SUPPORT SYSTEMS LESSON 2 Overview of the main methods we will adopt during the course: differential methods; stochastic methods; optimization


slide-1
SLIDE 1

Lesson 2 Overview of the main methods we will adopt during the course: differential methods; stochastic methods; optimization methods.

Ettore Lanzarone March 11, 2019

MEDICAL SUPPORT SYSTEMS FOR CHRONIC DISEASES

Engineering and Management for Health University of Bergamo

LESSON 2

Differential approaches

Dynamic systems

  • Differential approaches
slide-2
SLIDE 2

Lesson 2

Differential approaches

ORDINARY DIFFERENTIAL EQUATION Let us consider a function y(t). A ordinary differential equation (ODE) is: The goal is to find the solution y(t) that respect the equation tI. The solution is also called “integral” of the equation (as it is usually computed through integrals). The highest order of derivative included in the equation is the order of the differential equation.

Differential approaches

PARTIAL DIFFERENTIAL EQUATION Let us consider a function y(t,x1,…,xm). A partial differential equation (PDE) is: (limited to the second order) are the partial derivatives with respect to one of the independent variables (computed fixing the values of the other variables and considering them as constant values)

slide-3
SLIDE 3

Lesson 2

Differential approaches

are the second partial derivatives with respect to one of the independent variables Second partial derivatives can computed with respect to two variables (first time derivative with respect to one variable, second time derivative with respect to the other variable): MIXED PARTIAL DERIVATIVES. Schwarz's theorem: mixed partial derivatives are the same while changing the order of the derivatives, e.g.;

Differential approaches

Let us consider a simple ODE: where f(t) is a known function. The solution is: There are infinite solutions that depend on the value of coefficient k. General validity: an ODE of order n has infinite solutions that depend on n coefficients. The set these solutions is named GENERAL INTEGRAL of the ODE.

slide-4
SLIDE 4

Lesson 2

Differential approaches

In practical application, we are interested in choosing one of the solutions. How? Usually, initial condition:

  • If we observe the system at time t0, we know exactly y(t0).
  • We choose the solution that respects this condition.

The single solution that respects the condition is named PARTICULAR INTEGRAL. In general, for an ODE of order n we need n initial conditions: y(t0), y’(t0), y’’(t0), …, y(n-1)(t0)

Differential approaches

Other alternatives are also possible, e.g., to impose that the solution passes through several points. As for PDEs, the idea is similar. We have to include BOUNDARY CONDITIONS. See the example for y(t,x)

slide-5
SLIDE 5

Lesson 2

Differential approaches

Possible approaches to solve a differential equation:

  • ANALYTICAL SOLUTION

Most powerful approach: it allows to get the analytical expression of the solution. Limitation: analytical solutions are available only for a limited number of equation classes

  • QUALITATIVE SOLUTION

The idea is to draw a qualitative trend of the solution using the information that can be qualitatively extracted from the solution (e.g., the signum of the derivative to get local minima and maxima)

  • NUMERICAL SOLUTION

Flexible approach: it can be always applied. Limitations: computational time to get the solution, solution given in terms of points without getting the analytical expression; convergence of the numerical approach to be verified

Differential approaches

EXAMPLE OF ANALYTICAL SOLUTION SEPARABLE VARIABLES 1. Constant solutions:

slide-6
SLIDE 6

Lesson 2

Differential approaches

EXAMPLE OF ANALYTICAL SOLUTION SEPARABLE VARIABLES 2. Other solutions:

Differential approaches

EXAMPLE OF ANALYTICAL SOLUTION SEPARABLE VARIABLES 2. Other solutions:

slide-7
SLIDE 7

Lesson 2

Differential approaches

EXAMPLE OF ANALYTICAL SOLUTION SEPARABLE VARIABLES Constant solutions: Other solutions:

Differential approaches

EXAMPLE OF ANALYTICAL SOLUTION LINEAR FIRST ORDER EQUATION a(t) and f(t) are known continuous functions. The solution is:

slide-8
SLIDE 8

Lesson 2

Differential approaches

These are just examples to show analytical solutions. Probably none of the problems in medicine and health care can be solved in this way. We will focus on the numerical approaches.

Differential approaches

Possible approaches to solve a differential equation:

  • ANALYTICAL SOLUTION

Most powerful approach: it allows to get the analytical expression of the solution. Limitation: analytical solutions are available only for a limited number of equation classes

  • QUALITATIVE SOLUTION

The idea is to draw a qualitative trend of the solution using the information that can be qualitatively extracted from the solution (e.g., the signum of the derivative to get local minima and maxima)

  • NUMERICAL SOLUTION

Flexible approach: it can be always applied. Limitations: computational time to get the solution, solution given in terms of points without getting the analytical expression; convergence of the numerical approach to be verified

slide-9
SLIDE 9

Lesson 2

Differential approaches

Numerical methods are based on the discretization of the continuous independent variable x or t in y(x) or y(t), respectively. Instead of considering the entire function y(x) we consider samples at values xi.

Differential approaches

We consider a first order ODE: We get estimates of the solution at different base points:

0)

( ); , ( ) ( y x y y x f dx x dy  

.... ), 3 ( ), 2 ( ), ( h x y h x y h x y   

slide-10
SLIDE 10

Lesson 2

Differential approaches

The solution at the next point is written in terms of the Taylor polynomial: Polynomial centered in x0 and evaluated in x=x0+h

   

n n x x n n x x x x n k n k x x k k

h

  • h

dx y d n h dx y d h dx dy x y h

  • h

dx y d k h x y          

    

! 1 ... ! 2 1 ) ( ! 1 ) (

2 2 2

Differential approaches

The simpler approximation is to cut at the first order: We may express the derivative based on the ODE: Thus:

 

h

  • h

dx dy x y h x y

x x

   

 0

) ( ) ( ) , ( y x f dx dy

x x

 

h

  • h

y x f x y h x y      ) , ( ) ( ) (

slide-11
SLIDE 11

Lesson 2

Differential approaches

The approach is iterative: where y(x0+h) is known from the previous step where y(x0+2h) is known from the previous step

h y x f y h x y     ) , ( ) ( h h x y h x f h x y h x y        )) ( , ( ) ( ) 2 ( h h x y h x f h x y h x y        )) 2 ( , 2 ( ) 2 ( ) 3 (

Differential approaches

In a compact way: with:

) ( ,... 2 , 1 ) , (

1

ih x y y i for h y x f y y

i i i i i

     

slide-12
SLIDE 12

Lesson 2

Differential approaches

GEOMETRICAL INTERPETATION

x0 x y0

INITIAL POINT (x0,y0)

Differential approaches

GEOMETRICAL INTERPETATION

h x0 x1 x y0

y1=y0+f(x0,y0)h

Slope=f(x0,y0)

f(x0,y0)h

y1

slide-13
SLIDE 13

Lesson 2

Differential approaches

GEOMETRICAL INTERPETATION

x0 x1 x2 x y0

y1=y0+f(x0,y0)h

y1 h

y2=y1+f(x1,y1)h

New slope=f(x1,y1) y2

hf(x1,y1)

Differential approaches

Example with h=0.01

4 ) 1 ( ; 1

2

    y x dx dy

     

9394 . 3 01 . 02 . 1 1 9598 . 3 ) , ( : 3 9598 . 3 01 . 01 . 1 1 98 . 3 ) , ( : 2 98 . 3 01 . 1 1 4 ) , ( : 1 ) , (

2 2 2 2 3 2 1 1 1 2 2 1 1

                                

h y x f y y Step h y x f y y Step h y x f y y Step h y x f y y

i i i i

slide-14
SLIDE 14

Lesson 2

Differential approaches

Example True value is known because for this example also the analytical solution exists (separable variables)

Differential approaches

Example The solution is given by the coordinates of the discrete points and can be easily plotted.

slide-15
SLIDE 15

Lesson 2

Differential approaches

The problem is to determine an integration step h that is small enough to get convergence. Suggestion:

  • try some values of h;
  • you may observe that decreasing the value of h the solutions are stable (they do not change);
  • any value of h for which the solution does not change is suitable;
  • the highest among them is the most efficient from the computational viewpoint.

In some cases where the slopes of the function y(x) are high the step h can be really small or the convergence is never guaranteed.

Differential approaches

In some cases where the slopes of the function y(x) are high the step h can be really small

  • r the convergence is never guaranteed.

Use something else with respect to the Euler method: 1. Higher order methods: do not limit to the first order in the Taylor polynomial that approximates f(x,t) 2. Add additional points between xi and xi+1=xi+h  RUNGE-KUTTA METHODS

slide-16
SLIDE 16

Lesson 2

Differential approaches

Runge-Kutta denotes a family of method. Among them, the RK4 is widely adopted. with Instead of using only one slope k=k1, a set of four slopes are considered to better approximate the solution.

Differential approaches

Graphical representation of the slopes The considered slope is then a wighted average of them.

slide-17
SLIDE 17

Lesson 2

Differential approaches

Numerical approaches can be extended to study systems of differential equations:

Differential approaches

An ODE with order n larger than one can be rewritten as a system of n ODE equations with order 1. Example for second order: We define two new variables: So the equation becomes:

slide-18
SLIDE 18

Lesson 2

Differential approaches

SOFTWARE TOOLS:

  • Matlab
  • Simnon

Differential approaches

MATLAB

slide-19
SLIDE 19

Lesson 2

Differential approaches

SIMNON Software tool to easily solve ODEs and systems of ODEs. You can find a free version within the course material. Let’s use the program! 1. Write the system in a text file *.t

Differential approaches

SIMNON Software tool to easily solve ODEs and systems of ODEs. You can find a free version within the course material. Let’s use the program! 1. Write the system in a text file *.t 1. Run the model using the command line

slide-20
SLIDE 20

Lesson 2

Differential approaches Differential approaches

EXPORT store < store Results are stored in a file store.d This command generates a text file with the discrete points of the solution, named store.t

slide-21
SLIDE 21

Lesson 2

Differential approaches

OPEN THE PROGRAM AND PLAY WITH …

Differential approaches

Note:

  • The integration step h has been not defined
  • Time instants are not equally spaced

The integration step h can be optimized by the solver in

  • rder to reduce it only when necessary, to improve the

computational performance while keeping the convergence of the solution.

slide-22
SLIDE 22

Lesson 2

Differential approaches

It is possible to decide the parameters of the simulation. In SIMNON, instead of the simple command line “SIMU 0 ***” it is possible to configure the parameters with a dedicated window. CHOOSE AUTO OR A FIXED STEP

Differential approaches

It is also possible to choose the integration algorithm

slide-23
SLIDE 23

Lesson 2

Differential approaches

PLAY WITH THE PROGRAM …

Optimization approaches

Decision

  • Optimization approaches
slide-24
SLIDE 24

Lesson 2

Optimization approaches

Optimization means to find the maximum and minimum of a function over a given set (entire domain of the function or a subdomain). If the set coincides with the domain it is UNCONSTRAINED OPTIMIZATION;

  • therwise it is CONSTRAINED OPTIMIZATION.

Function y(x) - unconstrained

  • In the derivable points: Fermat’s Theorem.

Maximum and minimum points are searched among those with y’(x)=0

  • In the non derivable points: local study.

For example: y=|x| has a minimum in x=0, which is not determined with y’(x)=0

Optimization approaches

Function y(x) - constrained

  • Study the unconstrained optimal points within the domain
  • Study the border of the domain

The maximum is on the border of the interval if the set is close [a,b] If the set is open (a,b) there is no maximum but only an upper extreme

slide-25
SLIDE 25

Lesson 2

Optimization approaches

Function y(x) - constrained

  • If the function is linear, maximum and minimum points are on the border

Easy to see but important. It will be at the basis of the simplex method for linear programming models. Maximum and minimum on the border of the interval if the set is close [a,b] If the set is open (a,b) only upper and lower extremes

Optimization approaches

Function z=f(x,y) – unconstrained

  • In the derivable points: extension of the Fermat’s Theorem.

Maximum and minimum points are searched among those with null gradient.

  • Then consider the Hessian matrix of the second derivatives

in these points:

Hessian is a symmetric matrix (Schwarz's theorem: mixed partial derivatives are equal)

slide-26
SLIDE 26

Lesson 2

Optimization approaches

Hessian cases: 1. Positive determinant and positive first element MINIMUM 2. Positive determinant and negative first element MAXIMUM 3. Negative determinant SADDLE POINT 4. Null determinant NO INFORMATION Similar to y’’(0)=0 for functions of 1 variable

SADDLE POINT

Optimization approaches

Function z=f(x,y) - constrained

  • Study the unconstrained optimal points within the domain
  • Study the border of the domain

The border is a close line expressed as a function g(x,y)=0 Two possible approaches: 1. Parametrization of the border 2. Lagrange multipliers

slide-27
SLIDE 27

Lesson 2

Optimization approaches

Parametrization of the border The border g(x,y)=0 can be rewritten as: The problem is to find maximum and minimum for a function of only one variable.

Optimization approaches

Lagrange multipliers method The following function is built based on z=f(x,t) and g(x,y)=0 The candidate maxima and minima are those with a null gradient of (x,y,)

Then, computing the value of z in these points, maxima and minima are identified.

slide-28
SLIDE 28

Lesson 2

Optimization approaches

In case the function is linear and the border is piecewise composed by linear equations (see for example the figure), the minimum and the maximum of the function in the domain are

  • n the border of the domain (if domain is close).

Optimization approaches

In this case, the problem can be rewritten as a so-called linear programming model. Or alternatively with maximize All inequality are with “=“ to include the border (maximum and minimum are on the border)

slide-29
SLIDE 29

Lesson 2

Optimization approaches

This problem can be solved via a set of algorithms, e.g., the SIMPLEX ALGORITHM. Commercial solvers for this type of problems. For example, CPLEX couples simplex and some branch and bound / branch and cut algorithms.

Differential approaches

OPEN THE PROGRAM AND PLAY WITH …

Free version for students and researchers available: www.ibm.com/it-it/products/ilog-cplex-optimization-studio

slide-30
SLIDE 30

Lesson 2

Optimization approaches

For problems with long computational times, CPLEX provides intermediate solutions associated with an optimality gap. When gap is 0, the optimal solution is found. It is possible to stop the execution after a given computational time or when a solution associated with a given gap is obtained. What is the gap? Estimation of the difference between the objective function of the current solution and that of the best possible one.

Optimization approaches

GAP = estimation of the difference between the objective function of the current solution and that of the best possible one. For example, in case of problems with integer variables, a relaxed problem is solved using continuous variables with respect to integer ones. Then the gap is based on this relaxed solution. Obviously that solution is not admissible for the original problem. The gap is updated because:

  • a better solution is found
  • estimation of the bound is updated with something more realistic