Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example...

62
Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference point (2D) Calculation BVP formulation BVP Implementation Approximate solution Initialization Indifference-Attractor Bifurcation (1D) Calculation BVP formulation Indifference-Attractor Bifurcation (2D) Calculation BVP Implementation Approximate solution Initialization References OCMat functions 4.129 Lecture 4 : Multiple solutions and heteroclinic bifurcations History counts! OCMat: A MATLAB package for the analysis of optimal control problems Dieter Graß: [email protected] Operations Research and Control Systems (ORCOS)

Transcript of Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example...

Page 1: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.129

Lecture 4:

Multiple solutions and heteroclinic

bifurcationsHistory counts!

OCMat: A MATLAB package for the analysis ofoptimal control problems

Dieter Graß: [email protected] Research and Control Systems (ORCOS)

Page 2: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.130

The coral reef model revisited

Model formulation (coral reef model)

maxh(·)

∫ ∞

0

e−rt(

ph(t)F (t)− h(t)2)

dt

s.t. F (t) = F (t)

(

1−F (t)

A

)

−1

τ + C

F (t)2

1 + F (t)2− h(t)F (t)

εA(t) = 1− dA(t)− A(t)F (t)

with F (0) = F0 ≥ 0, A(0) = A0 ≥ 0

h(t) ≥ 0, for all t

• fish (F (·))

• algae (A(·))

• coral (C )

• fishing effort (h(·))

Page 3: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.130

The coral reef model revisited

Initialization file (coralreef1D.m)

% An Opt ima l l y Managed Co ra l Ree fs t a t ed ynam i c s=sym( ’ [ ( s igma∗x1∗(1−x1/x2 )−gamma/(C+tau )∗x1ˆ t h e t a

/(1+x1ˆ th e t a )−e t a∗u1∗x1 ) / e p s i l o n ; n−d∗x2−e∗x2∗x1 ] ’ ) ;o b j e c t i v e f u n c t i o n=sym( ’ p∗u1∗x1−ph i∗u1ˆ2 ’ ) ;c o n t r o l c o n s t r a i n t=sym( ’ u1−ulow ’ ) ;

% Gene ra ln=1;d=0.05 ;e=1;p=1;mu=93;r =0.02 ;ulow=0;t h e t a =2;tau =0.25 ;s igma =0.825;gamma=1;ph i =1;e t a =1;C=0;e p s i l o n =1;

Page 4: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.131

From the Threshold to the Indifference Case ε = 0

Page 5: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.132

Definitions I

Definition (Solution sets)

Let x∗(·) be the optimal state trajectory, starting at x0 then

S(x0) = {x∗(·) : x∗(0) = x0},

is called the solution set, and

S∞(x0) = {x(x0,∞) : x(·) ∈ S(x0)},

where x(x0,∞) is the limit set, is called the asymptotic solution set.

Definition (Indifference point)

Let S(x0) be the solution set of an optimal control problem. If thereexist x∗

1 (·), x∗

2 (·) ∈ S(x0) and t ∈ [0, T ] satisfying

x∗

1 (t) 6= x∗

2 (t),

then x0 is called an indifference point. If the solution set S(x0) hascardinality k < ∞, then x0 is called of order k; otherwise it is of infiniteorder.

Page 6: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.133

Definitions II

Definition (Threshold point)

Let us consider an infinite time horizon problem with x(0) = x0.Then x0 is called a threshold point if for every neighborhood U ofx0 there exist x10, x20 ∈ U, satisfying

S∞(x10) ∩ S∞(x20) = ∅, S∞(xi0) 6= ∅, i = 1, 2.

Definition (Asymptotic indifference point)

Let us consider an infinite time horizon problem with x(0) = x0.Then x0 is called an asymptotic indifference point if it is both anindifference point and a threshold point.

Remark

At the moment there exists no canonical nomenclature of thesepoints. However what I introduced here as asymptotic indifferencepoint (AIP) is also known as Skiba or DNSS point.

Page 7: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.134

AIP in a one state model

b

b

F

λ

Page 8: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.134

AIP in a one state model

b

b

F

λ

Page 9: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.134

AIP in a one state model

b

b

F

λ

Page 10: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.134

AIP in a one state model

b

b

F

λ

Page 11: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.135

Recipe of finding an (approximated) AIP

1 Calculate the stable path of the first equilibrium.

2 Calculate the stable path of the second equilibrium.

3 Intersect Hamiltonian of the two stable paths.

4 Calculate the stable paths starting at the intersection point.

0.5 1 1.5 2 2.5 30.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

2Finding an AIP

F

λ

Page 12: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.135

Recipe of finding an (approximated) AIP

1 Calculate the stable path of the first equilibrium.

2 Calculate the stable path of the second equilibrium.

3 Intersect Hamiltonian of the two stable paths.

4 Calculate the stable paths starting at the intersection point.

0.5 1 1.5 2 2.5 30.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

2Finding an AIP

F

λ

Page 13: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.135

Recipe of finding an (approximated) AIP

1 Calculate the stable path of the first equilibrium.

2 Calculate the stable path of the second equilibrium.

3 Intersect Hamiltonian of the two stable paths.

4 Calculate the stable paths starting at the intersection point.

0.5 1 1.5 2 2.5 30.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

2Finding an AIP

F

λ

Page 14: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.135

Recipe of finding an (approximated) AIP

1 Calculate the stable path of the first equilibrium.

2 Calculate the stable path of the second equilibrium.

3 Intersect Hamiltonian of the two stable paths.

4 Calculate the stable paths starting at the intersection point.

0.5 1 1.5 2 2.5 30.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

2Finding an AIP

F

λ

Page 15: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.135

Recipe of finding an (approximated) AIP

1 Calculate the stable path of the first equilibrium.

2 Calculate the stable path of the second equilibrium.

3 Intersect Hamiltonian of the two stable paths.

4 Calculate the stable paths starting at the intersection point.

0.5 1 1.5 2 2.5 30.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

2Finding an AIP

F

λ

Page 16: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.136

Recipe of finding an AIP: Remarks

1 If one of the continuation processes of point 1 or 2 issuccessful, the corresponding path is superior and no AIPexists.

2 One or both stable paths may exhibit different arcs.

3 If the continuation process gets “stuck”, interrupt it withCtrl+C and store the last solution with m=store(m).

4 If the stable paths have no region of intersection in the statespace an unstable node may exist as a separator.

Remark

Remind that in the one dimensional case the slice manifoldcoincides with the stable path. Therefore the intersectioncommand could have been invoked using the slice manifoldsinstead of the stable paths.

Page 17: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.137

Realization of the recipe with OCMat

>> m=ocmodel ( ’ c o r a l r e e f 1D ’ ) ;>> m=changeparameter (m, ’A,C ’ , [ 7 . 4 2 6 0 . 3 7 5 ] ) ;>> ocEP=ca l c e p (m) ; b=i s a dm i s s i b l e (m, ocEP) ; ocEP(˜ b ) = [ ] ; b=i s n e g a t i v e s t a t e (m, ocEP) ; ocEP (b

==1)= [ ] ;>> i s s a d d l e ( ocEP{:})ans =

1 1 0 1 1>> i n i t S t r u c t=i n i t o c c o n t ( ’ e x t r ema l ’ ,m, ’ i n i t p o i n t ’ , 1 , ocEP{4}. dynVar (1 , 1 ) , ocEP{2}, ’

I n t e g r a t i o nT ime ’ , 500) ;>> [ s o l s o l n ]= occon t (m, i n i t S t r u c t , opt ) ;>> m=s t o r e (m) ;>> i n i t S t r u c t=i n i t o c c o n t ( ’ e x t r ema l ’ ,m, ’ i n i t p o i n t ’ , 1 , ocEP{4}. dynVar (1 , 1 ) , ocEP{2}, ’

I n t e g r a t i o nT ime ’ , 500)>> [ s o l s o l n ]= occon t (m, i n i t S t r u c t , opt ) ;>> s o l ns o l n =

oca s ymp to t i c o b j e c t :l i m i t s e t : [ d y n p r im i t i v e o b j e c t ]dynVar : [ 2 x23 doub l e ]t : [ 1 x23 doub l e ]a r c i d : 1t i m e i n t e r v a l s : 500v i o l a t i o n : [ 2 x23 doub l e ]

>> i n i t S t r u c t=i n i t o c c o n t ( ’ e x t r ema l ’ ,m, ’ i n i t p o i n t ’ , 1 , ocEP{2}. dynVar (1 , 1 ) , so ln , ’I n t e g r a t i o nT ime ’ , 500) ;

>> [ s o l s o l n ]= occon t (m, i n i t S t r u c t , opt ) ;>> m=s t o r e (m) ;>> dns s=f i n d d n s s (m, 1 , 3 ) ;dn s s =

1.2704>> ocEx=e x t r ema l s o l (m) ;>> i n i t S t r u c t=i n i t o c c o n t ( ’ e x t r ema l ’ ,m, ’ i n i t p o i n t ’ , 1 , dnss , ocEx{1}) ;>> [ s o l s o l n ]= occon t (m, i n i t S t r u c t , opt ) ;m=s t o r e (m) ;>> i n i t S t r u c t=i n i t o c c o n t ( ’ e x t r ema l ’ ,m, ’ i n i t p o i n t ’ , 1 , dnss , ocEx{3})>> [ s o l s o l n ]= occon t (m, i n i t S t r u c t , opt ) ;m=s t o r e (m) ;

Page 18: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.138

Formulation as a BVP

y1(t) = T1f1(y1(t)), t ∈ [0, 1] (6a)

y2(t) = T2f2(y2(t)), t ∈ [0, 1] (6b)

y11 (0) = y1

2 (0) (6c)

H(y1(0)) = H(y2(0)) (6d)

Π′1(y1(1)− y1) = 0 (6e)

Π′2(y2(1)− y2) = 0. (6f)

• (6a) and (6b) denote the two different solutions.

• (6c) states that both solutions have to start from the sameinitial state

• (6d) property for equally optimal solutions.

• (6e) and (6f) are the usual asymptotic transversalityconditions

Page 19: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.139

Realization of the BVP formulation with OCMat

>> ocEx=e x t r ema l s o l (m) ;>> ocDNSS=[ocEx{4} ocEx {5} ]ocDNSS =1x2 ocasympto t i c o b j e c t w i th f i e l d s :

l i m i t s e to c t r a j e c t o r y

>> i n i t S t r u c t=i n i t o c c o n t ( ’ dnss ’ ,m, ’ i n i t p o i n t ’ , [ ] , [ ] , ocDNSS)>> [ s o l d so l dn ]= o c c a l c (m, i n i t S t r u c t , opt ) ;m=s t o r e (m) ;>> m. o cRe su l t s . DNSSCurveans =

[1 x1 occu rve ]>> p l o t p h a s e o c r e s u l t (m, ’ c o s t a t e ’ , 1 , 1 , ’ o n l y ’ ,{ ’ DNSSCurve ’ } , ’

a s s o c i a t e d s o l ’ , ’ on ’ )

0.5 1 1.5 2 2.5 3

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

F

λ

Multiple solutions

Page 20: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.140

AIPs in two and more state models

b

b

F

A

Page 21: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.140

AIPs in two and more state models

b

b

F

A

Page 22: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.140

AIPs in two and more state models

b

b

F

A

Page 23: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.141

Finding an (approximated) AIP: step 1

Determine equilibria and calculate stable paths

>> m=ocmodel ( ’ c o r a l r e e f 2D ’ ) ;>> m=changeparameter (m, ’ r ,C , e , n , s igma ’ , [ 0 . 1 0 .38237 2 30 1 ] ) ;>> ocEP=ca l c e p (m) ; b=i s a dm i s s i b l e (m, ocEP) ; ocEP(˜ b ) = [ ] ; b=i s n e g a t i v e s t a t e (m, ocEP) ; ocEP (b

==1)= [ ] ;>> ocEP ( [ 1 5 ] ) = [ ] ; [ b dim]= i s s a d d l e ( ocEP{:})b =

1 1 1dim =

2 1 2>> i n i t S t r u c t=i n i t o c c o n t ( ’ e x t r ema l ’ ,m, ’ i n i t p o i n t ’ , [ 1 2 ] , ocEP{3}. dynVar ( 1 : 2 , 1 ) , ocEP{1}, ’

I n t e g r a t i o nT ime ’ , 500) ;>> opt=s e t o c o p t i o n s ( ’OCCONT ’ , ’ I n i t S t epWid th ’ , 0 . 05/5ˆ2 , ’ MaxStepWidth ’ , 0 . 05 , ’OC ’ , ’

BVPSolver ’ , ’ bvp5c ’ ) ;>> [ s o l s o l n ]= occon t (m, i n i t S t r u c t , opt ) ;>> m=s t o r e (m) ;>> i n i t S t r u c t=i n i t o c c o n t ( ’ e x t r ema l ’ ,m, ’ i n i t p o i n t ’ , [ 1 2 ] , ocEP{1}. dynVar ( 1 : 2 , 1 ) , ocEP{3}, ’

I n t e g r a t i o nT ime ’ , 500) ;>> [ s o l s o l n ]= occon t (m, i n i t S t r u c t , opt ) ;>> m=s t o r e (m) ;

Page 24: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.142

Finding an (approximated) AIP: step 2

Checking that Hamiltonians intersect

>> p l o t p h a s e o c r e s u l t (m, ’ s t a t e ’ , 2 , 1 , ’ on l y ’ ,{ ’ E x t r ema l S o l u t i o n ’} , ’ o n l y i n d e x ’ ,{ [ ]} , . . .’ l i m i t s e t ’ , ’ on ’ , ’ l i m i t s e tMa r k e r ’ , ’ . ’ , ’ l i m i t s e tMa r k e r S i z e ’ , 16) , ho ld on

>> p l o t p h a s e o c r e s u l t (m, ’ s t a t e ’ , 2 , 1 , ’ on l y ’ ,{ ’ S l i c eMan i f o l d ’} , ’ Co lo r ’ , [ 0 0 . 5 0 ] )>> t i t l e ( ’ S t a b l e path s and s l i c e manfo lds ’ )>> x l a b e l ( ’ $F$ ’ , ’ I n t e r p r e t e r ’ , ’ l a t e x ’ ) , y l a b e l ( ’ $A$ ’ , ’ I n t e r p r e t e r ’ , ’ l a t e x ’ )

9 10 11 12 13 14 15 16 17 18 190.7

0.8

0.9

1

1.1

1.2

1.3

1.4

1.5

1.6

1.7Stable paths and slice manfolds

F

A

Page 25: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.142

Finding an (approximated) AIP: step 2

Checking that Hamiltonians intersect

>> p l o t 3 p h a s e o c r e s u l t (m, ’ h am i l t o n i a n ’ , 1 , 2 , 1 , ’ on l y ’ ,{ ’ E x t r ema l S o l u t i o n ’} , . . .’ o n l y i n d e x ’ ,{ [ ]} , ’ l i m i t s e t ’ , ’ on ’ , ’ l i m i t s e tMa r k e r ’ , ’ . ’ , ’ l i m i t s e tM a r k e r S i z e ’ , 16)

>> ho ld on>> p l o t 3 p h a s e o c r e s u l t (m, ’ h am i l t o n i a n ’ , 1 , 2 , 1 , ’ on l y ’ ,{ ’ S l i c eMa n i f o l d ’} , ’ Co lo r ’ , [ 0 0 . 5 0 ] )>> t i t l e ( ’ Hami l ton ian ’ )>> x l a b e l ( ’ $F$ ’ , ’ I n t e r p r e t e r ’ , ’ l a t e x ’ ) , y l a b e l ( ’ $A$ ’ , ’ I n t e r p r e t e r ’ , ’ l a t e x ’ )>> z l a b e l ( ’ $\c a l H$ ’ , ’ I n t e r p r e t e r ’ , ’ l a t e x ’ )

0.81

1.21.4

1.61.8

2

8

10

12

14

16

18

200.11

0.12

0.13

0.14

0.15

0.16

0.17

0.18

F

Hamiltonian

A

H

Page 26: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.142

Finding an (approximated) AIP: step 2

Checking that Hamiltonians intersect

>> p l o t p h a s e o c r e s u l t (m, ’ h am i l t o n i a n ’ , 1 , 1 , ’ on l y ’ ,{ ’ S l i c eMan i f o l d ’} , ’ Co lo r ’ , [ 0 0 . 5 0 ] )>> t i t l e ( ’ Hami l ton ian e v a l u a t e d f o r s l i c e man i f o l d ’ )>> x l a b e l ( ’ $F$ ’ , ’ I n t e r p r e t e r ’ , ’ l a t e x ’ ) , y l a b e l ( ’ $\c a l H$ ’ , ’ I n t e r p r e t e r ’ , ’ l a t e x ’ )

0.7 0.8 0.9 1 1.1 1.2 1.3 1.4 1.5 1.6 1.70.11

0.12

0.13

0.14

0.15

0.16

0.17

0.18Hamiltonian evaluated for slice manifold

F

H

Page 27: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.142

Finding an (approximated) AIP: step 2

Checking that Hamiltonians intersect

>> p l o t p h a s e o c r e s u l t (m, ’ h am i l t o n i a n ’ , 2 , 1 , ’ on l y ’ ,{ ’ S l i c eMan i f o l d ’} , ’ Co lo r ’ , [ 0 0 . 5 0 ] )>> t i t l e ( ’ Hami l ton ian e v a l u a t e d f o r s l i c e man i f o l d ’ )>> x l a b e l ( ’ $A$ ’ , ’ I n t e r p r e t e r ’ , ’ l a t e x ’ ) , y l a b e l ( ’ $\c a l H$ ’ , ’ I n t e r p r e t e r ’ , ’ l a t e x ’ )

9 10 11 12 13 14 15 16 17 18 190.11

0.12

0.13

0.14

0.15

0.16

0.17

0.18Hamiltonian evaluated for slice manifold

A

H

Page 28: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.143

Finding an (approximated) AIP: step 3

Index Argument

>> dns s=f i n d d n s s (m, 1 , 2 ) ; dn s s ( : ) . ’ans =

1.1508 14.4256

Slicemanifold Argument

>> slMF=s l i c em a n i f o l d (m) ;>> dns s=f i n d d n s s (m, slMF{1}, slMF{2}) ;

>> ocEx=e x t r ema l s o l (m) ;>> i n i t S t r u c t=i n i t o c c o n t ( ’ e x t r ema l ’ ,m, ’ i n i t p o i n t ’ , 1 : 2 , dnss , ocEx{1}) ;>> [ s o l s o l n ]= occon t (m, i n i t S t r u c t , opt ) ;m=s t o r e (m) ;>> i n i t S t r u c t=i n i t o c c o n t ( ’ e x t r ema l ’ ,m, ’ i n i t p o i n t ’ , 1 : 2 , dnss , ocEx{3})>> [ s o l s o l n ]= occon t (m, i n i t S t r u c t , opt ) ;m=s t o r e (m) ;>> ocEx=e x t r ema l s o l (m) ;>> ocD=[ocEx{3} ocEx{4} ] ;>> p l o t p h a s e (m, ocD , ’ s t a t e ’ , 1 , 2 ’ , ’ l i m i t s e t ’ , ’ on ’ , ’ l i m i t s e tMa r k e r ’ , ’ . ’ , . . .

’ L im i t s e tMa r k e r S i z e ’ , 16)

0.7 0.8 0.9 1 1.1 1.2 1.3 1.4 1.5 1.6 1.79

10

11

12

13

14

15

16

17

18

19

F

A

Multiple solutions

Page 29: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.144

Formulation as a BVP

y1(t) = T1f1(y1(t)), t ∈ [0, 1] (7a)

y2(t) = T2f2(y2(t)), t ∈ [0, 1] (7b)

y1,21 (0) = y1,2

2 (0) (7c)

y i1(0) = y i

0, i ∈ {1, 2} (7d)

H(y1(0)) = H(y2(0)) (7e)

Π′1(y1(1)− y1) = 0 (7f)

Π′2(y2(1)− y2) = 0. (7g)

• (7a) and (7b) denote the two different solutions.

• (7c) states that both solutions have to start from the sameinitial state

• (7e) restricts one state-value and lets one free, thus (7d) canbe used to continue the single point to a curve.

• (7e) property for equally optimal solutions.

• (7f) and (7g) are the usual asymptotic transversalityconditions

Page 30: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.145

Realization of the BVP formulation

>> opt=s e t o c o p t i o n s ( opt , ’OCCONT ’ , ’ I n i t S t epWid th ’ , 0 . 01 , ’ MaxStepWidth ’ , 0 . 01 , ’Mean I t e r a t i on ’ , 75) ;

>> i n i t S t r u c t=i n i t o c c o n t ( ’ dn s s ’ ,m, ’ i n i t p o i n t ’ , 2 , 0 . 5 , ocD ) ;>> [ s o l d s o l dn ]= occon t (m, i n i t S t r u c t , opt ) ;m=s t o r e (m) ;>> opt=s e t o c o p t i o n s ( opt , ’OCCONT ’ , ’ I n i t S t epWid th ’ , 0 . 02 , ’ MaxStepWidth ’ , 0 . 0 2 ) ;>> i n i t S t r u c t=i n i t o c c o n t ( ’ dn s s ’ ,m, ’ i n i t p o i n t ’ , 2 , 20 , s o l d ) ;>> [ s o l d s o l dn ]= occon t (m, i n i t S t r u c t , opt ) ;m=s t o r e (m) ;>> p l o t p h a s e o c r e s u l t (m, ’ s t a t e ’ , 1 , 2 , ’ on l y ’ ,{ ’ DNSSCurve ’} , ’ a s s o c i a t e d s o l ’ , ’ on ’ , . . .

a s s o c i a t e d s o l l i m i t s e t ’ , ’ on ’ , ’ a s s o c i a t e d s o l c o n t i n u o u s ’ , ’ o f f ’ , . . .’ a s s o c i a t e d s o l l i m i t s e tM a r k e r ’ , ’ . ’ , ’ a s s o c i a t e d s o l l i m i t s e tM a r k e r S i z e ’ , 16 , . . .

’ Co lo r ’ , [ 1 0 0 ] )

Page 31: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.146

Intersecting the Hamiltonians

• It is assumed that a continuation process along the same linefor two equilibria has been done and that an overlappingregion on this line exists, where both solutions exist.

• The i1 and i2 slice manifolds contain the initial points ofsolutions during continuation.

• The Hamiltonian evaluated along the slice manifold returnsthe objective value of the corresponding solution (up to thefactor 1/r).

dnss=finddnss(m,i 1 , i 2 ) ;

• The indices correspond to the continuation processes i1 and i2where an overlap exist.

• Instead of the indices the slice manifolds itself can be used:

>> slMF=s l i c em a n i f o l d (m) ;>> dnss=f i n d d n s s (m, slMF{ i 1 } , slMF{ i 2 }) ;

• Calculate solutions starting at the intersection point dnss.

Page 32: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.147

Solution object

Remark

The solutions of an IP of order k are represented as anocasymptotic vector of length k, e.g., ocAsym with ocAsym(1)and ocAsym(2).

Generating an ocasymptotic vector

>> ocAsym=[ocEx1 ocEx2 ]ocAsym =1x2 ocasympto t i c o b j e c t w i th f i e l d s :

l i m i t s e to c t r a j e c t o r y

Remark

The components of an ocasymptotic vector are evaluated at thesame (normalized) time grid, i.e.,

ocAsym(1).t=ocAsym(2).t

Page 33: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.148

Initialization of AIP calculation

Remark

We assume that some (approximated) is known from a previousHamiltonian intersection procedure.

i n i t S t r u c t=i n i t o c c o n t ( ’ dnss ’ ,m, ’ i n i t p o i n t ’ ,COOR,VAL , INITSOL ) ;

• the signal word for AIP calculation is ’dnss’.

• COOR determines the coordinate(s) to be fixed.

• VAL is the value of the fixed coordinate(s).

• INITSOL is an initial function given by an ocasymptoticvector.

• the number of fixed coordinates is n − 1, where n is thenumber of states.

Page 34: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.149

Initialization structure

>> i n i t S t r u c t=i n i t o c c o n t ( ’ dnss ’ ,m, ’ i n i t p o i n t ’ , 2 , 20 , ocD)i n i t S t r u c t=

Asymptot icBCMatr ix : { [2 x4 doub le ] [ 2 x4 doub le ]}BVPFunction : [ 1 x1 s t r u c t ]

Cont inuat ionArgument : ’ dnss ’C o n t i n u a t i o nVa r i a b l e : ’ i n i t p o i n t ’

Coo rd ina t e : { [1 2 3 4 ] [ 5 6 7 8]}I d e n t i f i e r : ’ i 2 e p s i 2 e p s ’

I n t e g r a t i o nT ime : [500 500 ]Sadd l ePo in t : { [4 x1 doub le ] [ 4 x1 doub le ]}

>> i n i t S t r u c t . BVPFunctionans =

Con t i nua t i o n : ’ co ra l r e e f 2DBVP4Cont inua t i on ’Weie rst rassErdmannCond : ’ coralreef2DBVP4WEC ’

Asymp to t i cT ran s v e r s a l i t yCond : ’ coralreef2DBVP4AsymTransCond ’DNSS: ’ coralreef2DBVP4DNSS ’

Gene ra l : ’ bc4dnss ’>> i n i t S t r u c t . ODEFunctionans =

Dynamics : ’ c o r a l r e e f 2D4Con t ’Gene ra l : ’ dyn4dnss ’

Page 35: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.150

Heteroclinic connection

Definition

Let x1 and x2 be equilibria of the ODE x(t) = f (x(t)). Atrajectory x(·) starting at a point x0 ∈ R

n is called a heteroclinicconnection of x1 and x2 if limt→∞ x(t) = x1 andlimt→−∞ x(t) = x2.

bb

×x0

x1 x2

Ws(x1)Wu(x2)

Page 36: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.151

Heteroclinic connection in a one-state model

b

b

F

λ

Page 37: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.151

Heteroclinic connection in a one-state model

b

b

F

λ

Page 38: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.151

Heteroclinic connection in a one-state model

b

b

F

λ

Page 39: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.151

Heteroclinic connection in a one-state model

b

b

F

λ

Page 40: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.152

Find heteroclinic connection

>> opt=s e t o c o p t i o n s ( ’OCCONT ’ , ’ I n i t S t epWid th ’ , 0 . 05/5ˆ2 , ’ MaxStepWidth ’ , 0 . 05 , . . .’OC ’ , ’ BVPSolver ’ , ’ bvp5c ’ , ’BVP ’ , ’ AbsTol ’ ,1 e−8, ’ Re lTo l ’ ,1 e−8) ;

>> m=ocmodel ( ’ c o r a l r e e f 1D ’ ) ;m=changeparameter (m, ’A,C ’ , [ 5 . 8 0 . 5 ] ) ;>> ocEP=ca l c e p (m) ; b=i s a dm i s s i b l e (m, ocEP) ; ocEP(˜ b ) = [ ] ; b=i s n e g a t i v e s t a t e (m, ocEP) ; . . .>> ocEP ( [ 1 5 ] ) = [ ] ;m=s t o r e (m, ocEP) ;>> i n i t S t r u c t=i n i t o c c o n t ( ’ e x t r ema l ’ ,m, ’ i n i t p o i n t ’ , 1 , 1 . 5 , ocEP{3}, ’ I n t e g r a t i o nT ime ’ ,1000 ,

’ PathType ’ , ’ s ’ ) ;>> [ s o l s o l n ]= occon t (m, i n i t S t r u c t , opt ) ;m=s t o r e (m) ;>> i n i t S t r u c t=i n i t o c c o n t ( ’ e x t r ema l ’ ,m, ’ i n i t p o i n t ’ , 1 , 1 . 5 , ocEP{1}, ’ I n t e g r a t i o nT ime ’ ,1000 ,

’ PathType ’ , ’ u ’ ) ;>> [ s o l s o l n ]= occon t (m, i n i t S t r u c t , opt ) ;m=s t o r e (m) ;

0.8 1 1.2 1.4 1.6 1.8 2 2.20.55

0.6

0.65

0.7

0.75

0.8

0.85

0.9

0.95

1

F

λ

Heteroclinic connection: approximation

Page 41: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.153

Find heteroclinic connection (2)

>> ocEx=e x t r ema l s o l (m) ; ocH=[ocEx{1} ocEx{2} ] ;>> i n i t S t r u c t=i n i t o c c o n t ( ’ h e t e r o c l i n i c ’ ,m, ’ i n i t p o i n t ’ , [ ] , [ ] , ocH , ’ Con t inuat i onType ’ , ’ f ’ ,

’ F reeParamete r ’ , 2 ) ;>> [ s o l h s o l hn ]= oc c a l c (m, i n i t S t r u c t , opt ) ;m=s t o r e (m) ;

0.8 1 1.2 1.4 1.6 1.8 2 2.20.55

0.6

0.65

0.7

0.75

0.8

0.85

0.9

0.95

1

F

λ

Heteroclinic connection

Page 42: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.154

Formulation as a BVP

y1(t, µ) = T1f1(y1(t), µ), t ∈ [0, 1] (8a)

y2(t, µ) = −T2f2(y2(t), µ), t ∈ [0, 1] (8b)

y1(0, µ) = y2(0, µ) (8c)

y1(0) = y1,0 (8d)

Π1(µ)′(y1(1)− y1) = 0 (8e)

Π2(µ)′(y2(1)− y2) = 0. (8f)

• The terms explicitly depend on the free parameter µ.

• (8a) denotes the stable, (8b) the unstable path.

• (8c) states that both solutions start from the same point.

• (8d) can be replaced by any “phase-condition” allowing todetermine a specific point of the connecting path.

• (8e) is the asymptotic transversality condition for a stablepath, (8f) for an unstable path.

Page 43: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.155

Heteroclinic connection in a two-state model

b

b

F

A

Page 44: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.155

Heteroclinic connection in a two-state model

b

b

F

A

Page 45: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.155

Heteroclinic connection in a two-state model

b

b

F

A

Page 46: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.155

Heteroclinic connection in a two-state model

b

b

F

A

Page 47: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.155

Heteroclinic connection in a two-state model

b

b

F

A

Page 48: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.156

Finding a heteroclinic connection

Page 49: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.157

Procedure out of practice

Page 50: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.158

Practical remarks

• Usually the computation of a heteroclinic connection is done afteran AIP (curve) has been found, e.g. for µI .

• Therefore a relevant parameter for the AIP has to be changed. Ifthe AIP vanishes for some parameter value, say µ0, a heteroclinicconnection can be searched in the parameter interval (µI , µ0).

• It is assumed that multiple equilibria exist, even if only one is thelong run optimal solution. Then the the unstable path iscalculated for the equilibrium which did become suboptimal.

• In a first attempt some initial point lying on the connection linebetween the two equilibria can be chosen. Plotting the paths onecan see that the paths concentrate around one curve.

Page 51: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.159

Initializing a heteroclinic connection computation

Remark

We assume that some (approximated) is known from a previousHamiltonian intersection procedure.

i n i t S t r u c t= . . .i n i t o c c o n t ( ’ h e t e r o c l i n i c ’ ,m, ’ paramete r ’ ,FIXPARIDX , FIXPARVAL

, INITSOL , ’ F reeParamete r ’ ,FREEIDX) ;

• The signal word for a detection of a heteroclinic connection is’ heteroclinic ’.

• FIXPARIDX is empty for calculation or determines theparameter to be varied in case of continuation.

• FIXPARVAL is empty for calculation or determines theparameter value for the continuation.

• INITSOL provides an initial approximation given by anocasymptotic vecotr.

• FREEIDX determines the index of the free parameter.

Page 52: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.160

Initialization structure

>> i n i t S t r u c t=i n i t o c c o n t ( ’ h e t e r o c l i n i c ’ ,m, ’ paramete r ’, [ 1 ] , [ 0 . 1 ] , . . .ocH , ’ Cont inuat ionType ’ , ’ f ’ , ’ F reeParamete r ’ , 2 )

i n i t S t r u c t =Asymptot icBCMatr ix : { [2 x4 doub le ] [ 2 x4 doub le ]}

BCPathType : { ’ s ’ ’ u ’}BVPFunction : [ 1 x1 s t r u c t ]

Cont inuat ionArgument : ’ h e t e r o c l i n i c ’Cont inuat ionType : ’ f ’

C o n t i n u a t i o nVa r i a b l e : ’ pa ramete r ’I d e n t i f i e r : ’ i 2 e p s i 2 e p u ’

ODEFunction : [ 1 x1 s t r u c t ]Sadd l ePo in t : { [4 x1 doub le ] [ 4 x1 doub le ]}

>> i n i t S t r u c t . BVPFunctionans =

Con t i nua t i o n : ’ co ra l r e e f 2DBVP4Cont inua t i on ’Weie rst rassErdmannCond : ’ coralreef2DBVP4WEC ’

Asymp to t i cT ran s v e r s a l i t yCond : ’ coralreef2DBVP4AsymTransCond’

Gene ra l : ’ b c 4 h e t e r o c l i n i c ’>> i n i t S t r u c t . ODEFunctionans =

Dynamics : ’ c o r a l r e e f 2D4Con t ’Gene ra l : ’ d y n 4 h e t e r o c l i n i c ’

Page 53: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Introduction

Example

Definitions

Indifference point (1D)

Recipe

Calculation

BVP formulation

Indifference point (2D)

Calculation

BVP formulation

BVP Implementation

Approximate solution

Initialization

Indifference-AttractorBifurcation (1D)

Calculation

BVP formulation

Indifference-AttractorBifurcation (2D)

Calculation

BVP Implementation

Approximate solution

Initialization

References

OCMat functions

4.161

References

F.O.O. Wagener. Skiba points and heteroclinic bifurcations, withapplications to the shallow lake system. Journal of Economic Dynamics

and Control, 27(9):1533–1561, July 2003

F.O.O. Wagener. Skiba points for small discount rates. Journal ofOptimization Theory and Applications, 128(2):261–277, February 2006

T. Kiseleva and F.O.O. Wagener. Bifurcations of optimal vector fields inthe shallow lake system. Journal of Economic Dynamics and Control, 34(5):825–843, 2010

W.J. Beyn, T. Pampel, and W. Semmler. Dynamic optimization andSkiba sets in economic examples. Optimal Control Applications and

Methods, 22(5–6):251–280, 2001

A.K. Skiba. Optimal growth with a convex-concave production function.Econometrica, 46(3):527–539, 1978

W.D. Dechert and K. Nishimura. A complete characterization of

optimal growth paths in an aggregated model with a non-concave

production function. Journal of Economic Theory, 31(2):332–354, 1983

Page 54: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Multiple solutions

horzcat

occalc

finddnss

initoccont

Heteroclinic connection

initoccont

General commands

subsparval, deval

Graphic commands

gettag, savefigure

Plotting 3D

Phase space

4.162

Multidimensional trajectories

Remark

The object representing a multiple solution is a multidimensionaloctrajectory , these consist of two or more octrajectory objects,which are evaluated on the same time grid. They are generated bythe overloaded horzcat command.

f u n c t i o n ocTr j=ho r z ca t ( v a r a r g i n )%% HORZCAT conca t ena t e s o c t r a j e c t o r i e s to an o c t r a j e c t o r y a r r a y .%% OCTRJ=HORZCAT(OCTRJ1 ,OCTRJ2 , . . . , OCTRJN) conca t ena t e s the o c t r a j e c t o r i e s% OCTRJ1 , . . . , OCTRJN, i n t e r p o l a t e d on a j o i n t t ime g r i d . The r e t u r n e d ob j e c t% OCTRJ i s a mu l t i d imen s i o n a l t r a j e c t o r y , where each t r a j c t o r y can be% add r e s s ed by ocTRJ (1 ) , OCTRJ(2 ) , . . . OCTRJ(N) .%% The command HORZCAT can be r e p l a c e d by the command% OCTRJ=[OCTRJ1 ,OCTRJ2 , . . . , OCTRJN]%% These o b j e c t s a r e used to r e p r e s e n t mu l t i p l e s o l u t i o n s o r h e t e r o c l i n i c% conn e c t i o n s .

f u n c t i o n ocAsym=ho r z ca t ( v a r a r g i n )%% HORZCAT conca t ena t e s o ca s ymp to t i c s to an oca s ymp to t i c a r r a y .%% OCASYM=HORZCAT(OCASYM1,OCASYM2, . . . ,OCASYMN) conca t ena t e s the . . .

Page 55: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Multiple solutions

horzcat

occalc

finddnss

initoccont

Heteroclinic connection

initoccont

General commands

subsparval, deval

Graphic commands

gettag, savefigure

Plotting 3D

Phase space

4.163

Solving a BVP

Remark

Whereas the command occont is used to solve a BVP usingcontinuation the command occalc tries to solve the BVP withinone step.

f u n c t i o n v a r a r g ou t=oc c a l c ( ocObj , I n i tBVSt ru c t , v a r a r g i n )%% OCCALC s o l v e s a BVP%% OCXP=OCCALC(OCOBJ, INITSTRUCT) t r i e s to f i n d a s o l u t i o n s p e c i f i e d i n% INITSTRUCT o f the oc model OCOBJ . OCXP i s the r e t u r n e d s o l u t i o n o f the% c a l c u l a t i o n and INITSTRUCT i s a s t r u c t u r r e t u r n e d by INITOCCONT ( . . . ) .

Page 56: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Multiple solutions

horzcat

occalc

finddnss

initoccont

Heteroclinic connection

initoccont

General commands

subsparval, deval

Graphic commands

gettag, savefigure

Plotting 3D

Phase space

4.164

Find an initial solution

f u n c t i o n dns s=f i n d d n s s ( ocObj , v a r a r g i n )%% FINDDNSS f i n d p o i n t s o f o v e r l a p i n g s c l i c e man i f o l d s w i th the same% Hami l ton ian v a l u e .%% DNSS=f i n d d n s s (OCOBJ, IDX1 , IDX2 ) i n t e r s e c t s the c u r v e s g i v en by the s t a t e% v a l u e s and Hami l ton ian e v a l u a t e d a long the s l i c e man i f o l d s s t o r e d i n the% IDX1 and IDX2 c e l l s o f the f i e l d ’ S l i c eMan i f o l d ’ i n the o cRe s u l t s . The% r e s u l t i s empty i f the s l i c e man i f o l d s do not o v e r l a p i n the s t a t e space% or i f the c a l c u l a t e d cu r v e s do not i n t e r s e c t . DNSS i s a p o i n t i n the% s t a t e space%% DNSS=f i n d d n s s (OCOBJ, SLMF1 , SLMF2) the s l i c e man i f o l d s can d i r e c t l y be% p rov i d ed by SLMF1 and SLMF2 .%% DNSS=f i n d d n s s (OCOBJ,OCASYM1,OCASYM2) s i n c e f o r one s t a t e models the s l i c e% man i f o l d s c o i n c i d e w i th the s t a b l e path s OCASYM1 and OCASYM2, the path s% i n s t e a d o f the s l i c e man i f o l d s can be p rov i d ed .

Remark

The returned point DNSS can be used to find an initial solutionfor an AIP, by continuing the (two) solutions to the initial stateDNSS. The such calculated solutions can then be transformedinto an ocasymptotic array.

Page 57: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Multiple solutions

horzcat

occalc

finddnss

initoccont

Heteroclinic connection

initoccont

General commands

subsparval, deval

Graphic commands

gettag, savefigure

Plotting 3D

Phase space

4.165

Initialization file for the BVP ansatz: ’dnss’

f u n c t i o n i n i t S t r u c t=i n i t o c c o n t ( contarg , ocObj , va r t ype , t a r g e t c o o r d i n a t e , t a r g e t v a l u e ,i n i t t r j , v a r a r g i n )

%% INITOCCONT r e t u r n s the i n i t i a l i z i n g s t r u c t u r e f o r the c o n t i n u a t i o n% p r o c e s s%% INITSTRUCT=INITOCCONT( ’ dnss ’ ,OCOBJ,VARTYPE,TCOORD,TVAL, INITTRJ , . . . )% r e t u r n s the i n i t i a l i z i n g s t r u c t u r e INITSTRUCT f o r the c o n t i n u a t i o n type% ’ dnss ’ .%% INITTRJ i s an i n i t i a l s o l u t i o n f o r the ana l y z ed BVP and i s o f c l a s s% ’ ocasymptot i c ’ .%% INITSTRUCT=INITOCCONT(CONTARG,OCOBJ, ’ INITPOINT ’ , INITPTIDX , INITPTVAL , . . . )% INITPTIDX denotes the c o o r d i n a t e ( s ) o f the i n i t i a l s t a t e s to which the% s o l u t i o n i s con t i n u ed and INITPTVAL s p e c i f i e s i t s a c t u a l v a l u e .%% INITSTRUCT=INITOCCONT ( . . . , ’ Cont inuat ionType ’ ,CT) p o s s i b l e v a l u e s f o r CT% are% ’ f ’ . . . f i x s t ep method% ’ a l ’ . . . a d ap t i v e s t ep method wi th l i n e a r e x t r a p o l a t i o n% ’ aq ’ . . . a d ap t i v e s t ep method wi th q u ad r a t i c e x t r a p o l a t i o n%

• INITTRJ is a multidimensional ocasymptotic.

• INITPTIDX denotes the coordinate which is changed after eachcontinuation step but kept fixed while a solution of the BVP issearched. If it is set to empty the solution is not continued andinstead of occont occalc should be used.

Page 58: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Multiple solutions

horzcat

occalc

finddnss

initoccont

Heteroclinic connection

initoccont

General commands

subsparval, deval

Graphic commands

gettag, savefigure

Plotting 3D

Phase space

4.166

Initialization file for the BVP ansatz: ’heteroclinic’

f u n c t i o n i n i t S t r u c t=i n i t o c c o n t ( contarg , ocObj , va r t ype , t a r g e t c o o r d i n a t e , t a r g e t v a l u e ,i n i t t r j , v a r a r g i n )

%% INITOCCONT r e t u r n s the i n i t i a l i z i n g s t r u c t u r e f o r the c o n t i n u a t i o n% p r o c e s s%% INITSTRUCT=INITOCCONT( ’ h e t e r o c l i n i c ’ ,OCOBJ,VARTYPE,TCOORD,TVAL, INITTRJ , . . . )% r e t u r n s the i n i t i a l i z i n g s t r u c t u r e INITSTRUCT f o r the c o n t i n u a t i o n type% ’ h e t e r o c l i n i c ’ .%% INITTRJ i s an i n i t i a l s o l u t i o n f o r the ana l y z ed BVP and i s o f c l a s s% ’ ocasymptot i c ’ .%% INITSTRUCT=INITOCCONT(CONTARG,OCOBJ, ’ INITPOINT ’ , INITPTIDX , INITPTVAL , . . . )% INITPTIDX denotes the c o o r d i n a t e ( s ) o f the i n i t i a l s t a t e s to which the% s o l u t i o n i s con t i n u ed and INITPTVAL s p e c i f i e s i t s a c t u a l v a l u e .%% INITSTRUCT=INITOCCONT ( . . . , ’ Cont inuat ionType ’ ,CT) p o s s i b l e v a l u e s f o r CT% are% ’ f ’ . . . f i x s t ep method% ’ a l ’ . . . a d ap t i v e s t ep method wi th l i n e a r e x t r a p o l a t i o n% ’ aq ’ . . . a d ap t i v e s t ep method wi th q u ad r a t i c e x t r a p o l a t i o n%

• INITTRJ is a twodimensional ocasymptotic, where one has to bea stable and the other an unstable path.

• INITPTIDX denotes the coordinate which is changed after eachcontinuation step but kept fixed while a solution of the BVP issearched. If it is set to empty the solution is not continued andinstead of occont occalc should be used.

Page 59: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Multiple solutions

horzcat

occalc

finddnss

initoccont

Heteroclinic connection

initoccont

General commands

subsparval, deval

Graphic commands

gettag, savefigure

Plotting 3D

Phase space

4.167

General commands

Symbolic expressions

f u n c t i o n s=su b s p a r v a l ( ocObj , s )% SUBSPARVAL s u b s t i t u t e s the model pa ramete r s%% S=SUBSPARVAL(OCOBJ, S) s u b s t i t u t e s the paramete r v a l u e s o f the op t ima l% c o n t r o l model OCOBJ f o r the s ymbo l i c e x p r e s s i o n S .

Solution trajectories

f u n c t i o n v a r a r g ou t=d e v a l ( ocTr j , t , v a r a r g i n )%% DEVAL ev a l u a t e an o c t r a j e c t o r y on a new t imeg r i d .%% DYNVAR = DEVAL(OCTRJ,T) e v a l u a t e s the o c t r a j e c t o r y OCTRJ at the t ime% p o i n t s T, where T has to l i e i n s i d e the t ime i n t e r v a l [ 0 1 ] . The s o l u t i o n% p o i n t s a r e r e t u r n e d i n the mat r i x DYNVAR.%% To gene r a t e an o c t r a j e c t o r y ob j e c t OCTRJN ev a l u a t e d at T one has to% d e f i n e a s t r u c t u r e OCTRJSTR :% OCTRJSTR . t=T;% OCTRJSTR . dynVar=DYNVAR;% OCTRJSTR . t i m e i n t e r v a l s=OCTRJ . t i m e i n t e r v a l s% OCTRJSTR . a r c i d=OCTRJ . a r c i d%% and can then s e t :% OCTRJN=o c t r a j e c t o r y (OCTRJSTR)%% DEVAL o v e r l o a d s the n a t i v e MATLAB command .

Page 60: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Multiple solutions

horzcat

occalc

finddnss

initoccont

Heteroclinic connection

initoccont

General commands

subsparval, deval

Graphic commands

gettag, savefigure

Plotting 3D

Phase space

4.168

General graphic commands

Retrieve information about plotted elements

f u n c t i o n out = ge t t ag ( v a r a r g i n )%% GETTAG read s out the t ag s o f p l o t l i n e s .%% OUT = GETTAG(N) r ead s out the t ag s o f N p l o t l i n e s . The p l o t l i n e s a r e% marked u s i n g the mouse . The t ag s a r e s t r i n g s p r o v i d i n g a un ique name o f% the p l o t t e d l i n e , which a r e gen e r a t ed u s i n g OCMAT p l o t t i n g commands . The% s t r i n g s a r e r e t u r n e d i n a c e l l a r r a y OUT.%% Po s s i b l e examples a r e :% ’ E x t r ema l S o l u t i o n 1 s t a t e 1 c o s t a t e 2 Num1 ’% ’ E q u i l i b r i um 1 s t a t e 1 h am i l t o n i a n 1 ’%% GETTAG main l y b a s e s on the MATLAB f u n c t i o n GINPUT .

Save plotted figures

f u n c t i o n s a v e f i g u r e ( ocObj , v a r a r g i n )%% SAVEFIGURE p r i n t s a f i g u r e to an image .%% SAVEFIGURE(H) p r i n t s a f i g u r e p l o t t e d i n f i g u r e , w i th hand l e H. I t i s the% cu r r e n t f i g u r e by d e f a u l t .%% SAVEFIGURE(H, IMGT) p o s s i b l e image t yp e s a r e ’bmp ’ , ’ eps ’ and ’ png ’ . The% d e f a u l t v a l u e i s ’ eps ’ .%% SAVEFIGURE(H, IMGT,FN, FF) w i th FN a f i l e name and wi th FF a f o l d e r can be% s p e c i f i e d . The d e f u a l t f o l d e r i s the data f o l d e r o f OCOBJ .%% SAVEFIGURE(H, IMGT,FN, FF ,RES) w i th RES the r e s o l u t i o n o f the image can be% s p e c i f i e d . By the d e f a u l t RES = 750 .

Page 61: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Multiple solutions

horzcat

occalc

finddnss

initoccont

Heteroclinic connection

initoccont

General commands

subsparval, deval

Graphic commands

gettag, savefigure

Plotting 3D

Phase space

4.169

Plotting in the phase space

%% PLOT3PHASE p l o t s the phase p o r t r a i t f o r a s o l u t i o n o f an ocmodel i n t h r e e d imen s i on s .%% PLOT3PHASE(OCOBJ,OCELEMENT) p l o t s the f i r s t t h r e e c o o r d i n a t e s o f the OCELEMENT, where% OCELEMENT can be e i t h e r a d y n p r im i t i v e , occurve , o c t r a j e c t o r y o r o ca s ymp to t i c .%% PLOT3PHASE(OCOBJ,OCTRJ,VARTYPE) wi th VARTYPE one can s p e c i f y the type% o f v a r i a b l e s to be p l o t t ed , p o s s i b l e v a l u e s a r e :% ’ s t a t e ’ . . . s t a t e v a l u e% ’ co s t a t e ’ . . . c o s t a t e v a l u e% ’ c on t r o l ’ . . . c o n t r o l v a l u e% ’ ham i l t on i an ’ . . . v a l u e o f the Hami l ton ian% ’ l m u l t i p l i e r ’ . . . v a l u e o f the Lagrang ian m u l t i p l i e r% ’ u s e r f un c ’ . . . v a l u e o f u s e r d e f i n e d f u n c t i o n s%% PLOT3PHASE(OCOBJ,OCTRJ,VARTYPE,XCOORD,YCOORD) XCOORD and YCOORD s p e c i f i e s the s t a t e

c o o r d i n a t e s XCOORD and YCOORD. I f i t i s empty the f i r s t two s t a t e c o o r d i n a t e s a r ep l o t t e d .

%% PLOT3PHASE(OCOBJ,OCTRJ,VARTYPE,XCOORD,YCOORD,ZCOORD) ZCOORD s p e c i f i e s the c o o r d i n a t e

o f term g i v en by VARTYPE. I f i t i s empty the f i r s t c o o r d i n a t e o f VARTYPE i sp l o t t e d .

%% PLOT3PHASE(OCOBJ,OCTRJ,VARTYPE,XCOORD,YCOORD,ZCOORD,PROPERTY,PROPERTYVAL) f o r

p o s s i b l e p r o p e r t i e s s e e MATLAB r e f e r e n c e o f p l o t .%% Add i t o n a l l y the f o l l o w i n g p r o p e r t i e s ( depend ing on the type o f OCELEMENT) can be s e t :% o c t r a j e c o t r y :% ’ con t inuous ’ . . . i f t h e o c t r a j e c t o r y c o n s i s t s o f d i f f e r e n t a r c s t h e s e can be% p l o t t e d as a cu r v e ’ c o n t i n u o s l y ’ connected at the sw i t c h i n g p o i n t s ’ on ’ . Or% each a r c i s p l o t t e d s e p a r a t e l y ( u s i n g a l s o d i f f e r e n t c o l o r s ) ’ o f f ’ .% occu r v e :% ’ a s s o c i a t e d s o l ’ . . . i f , e . g . , the occu r v e i s a boundary cu r v e c a l c a u l t e d by a% co n t i n u a t i o n p r o c e s s w i th ’ on ’ the a s s o c i a t e d ( ’ l a s t ’ ) s o l u t i o n o f t h i s% c o n t i n u a t i o n p r o c e s s i s p l o t t ed , d e f a u l t i s i s s e t to ’ o f f ’ .% oca s ymp to t i c :% ’ l i m i t s e t ’ . . . i f s e t to ’ on ’ the c o r r e s p on d i n g l i m i t s e t i s a l s o p l o t t ed , by% d e f a u l t t h i s i s s e t ’ o f f ’ .%% P r o p e r t i e s o f l i m i t s e t ( a s s i c a t e d s o l ) can be s e t u s ing , e . g . , ’ l im i t s e tMa r k e r ’ , ’ o ’

Page 62: Dieter Graß Lecture4: Multiplesolutionsandheteroclinic ... · Dieter Graß Introduction Example Definitions Indifference point (1D) Recipe Calculation BVP formulation Indifference

Dieter Graß

Multiple solutions

horzcat

occalc

finddnss

initoccont

Heteroclinic connection

initoccont

General commands

subsparval, deval

Graphic commands

gettag, savefigure

Plotting 3D

Phase space

4.170

Plotting ocResults in the phase space

f u n c t i o n v a r a r g ou t = p l o t 3 p h a s e o c r e s u l t ( v a r a r g i n )%% PLOT3PHASEOCRESULT p l o t s the o cRe s u l t s o f an oc ob j e c t i n t h r e e% d imen s i on s .%% PLOT3PHASEOCRESULT (OCOBJ,VARTYPE,XCOORD,YCOORD,ZCOORD) f o r VARTYPE,XCOORD% and YCOORD see the PLOT3PHASE command .%% PLOT3PHASEOCRESULT (OCOBJ,VARTYPE,XCOORD,YCOORD,ZCOORD) wi th AXH you can% s p e c i f y a f i g u r e / a x i s hand l e where the r e s u l t s s hou l d be p l o t t e d .%% PLOT3PHASEOCRESULT (OCOBJ,VARTYPE,XCOORD,YCOORD,ZCOORD, ’ONLY’ ,CELLNAME)% wi th CELLNAME you can p r o v i d e a c e l l a r r a y o f s t r i n g s c o n s i t i n g o f f i l e d% names o f the o cRe s u l t s . Then on l y t h e s e r e s u l t s a r e p l o t t e d . Even f o r one% f i e l d you have to s p e c i f y i t as a c e l l .%% PLOT3PHASEOCRESULT ( . . . , ’ ONLY’ ,CELLNAME, CELLIDX) CELLIDX i s a c e l l a r r a y% o f the same s i z e as CELLNAME and p r o v i e d the i nd ex o f s p e c i f i c e l ement s% o f the CELLNAME f i e l d s , e . g .% p l o t 3 p h a s e o c r e s u l t (m, ’ s t a t e ’ , 1 , 2 , 3 , ’ on ly ’ ,{ ’ E x t r ema lSo l u t i on ’} , ’ on l y i n d ex ’ ,{ [ 2 3]})% on l y p l o t s the 2 and 3 ob j e c t s t o r e d i n o cRe s u l t s . E x t r ema l S o l u t i o n . With% { [0]} no e l ement i s p l o t t e d and wi th { [ ]} a l l e l ement s a r e p l o t t e d .%% PLOT3PHASEOCRESULT ( . . . , ’ ONLY’ ,PROPERTY,PROPERTYVAL) wi th PROPERTY and% PROPERTYVAL p r o p e r t i e s can be p rov ided , s e e PLOTPHASE.%% H=PLOT3PHASEOCRESULT ( . . . ) r e t u r n s the l i n e hand l e s