Dieter Graß Lecture5: LimitcyclesandaMATCONT …5.182 Limit cycle stability Definition (Hyperbolic...
Transcript of Dieter Graß Lecture5: LimitcyclesandaMATCONT …5.182 Limit cycle stability Definition (Hyperbolic...
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.171
Lecture 5:
Limit cycles and a MATCONT
interfaceGo in circles or evolve!
OCMat: A MATLAB package for the analysis ofoptimal control problems
Dieter Graß: [email protected] Research and Control Systems (ORCOS)
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.172
Optimal Control of Terrorism and Global Reputation
Model formulation (terrorism and global reputation)
minh(·)
∫
∞
0
e−rt
(
cx(t) +u2
2
)
dt
s.t. x(t) = τ + kx(t)α − µx(t)− ηux(t)βy(t)γ
y(t) = δx(t)− ρu2 + κ (b − y(t))
with x(0) = x0 > 0, y(0) = y0 > 0
u(t) ≥ 0, for all t
• size of the terrorist organization (x(·))
• public opinion (y(·))
• level of counter-terror operations (u(·))
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.172
Optimal Control of Terrorism and Global Reputation
Initialization file (terrnpubop.m)
% Two Sta t e t e r r o r model : t e r r o r and p ub l i c o p i n i o ns t a t ed ynam i c s=sym( ’ [ tau+k∗x1ˆ a lpha−mu∗x1−e ta∗u1∗x1ˆ beta∗x2ˆgamma ; d e l t a∗x1− . . .
rho∗u1ˆ2+kappa∗(b−x2 ) ] ’ ) ;o b j e c t i v e f u n c t i o n=sym( ’ c∗x1+u1ˆ2/2 ’ ) ;c o n t r o l c o n s t r a i n t=sym( ’ u1−l b ’ ) ;o p t im i z a t i o n t y p e=’min ’ ;
% Gene r a lr = 0 . 0 1 ;gamma = 1 ;a lpha = 0 . 8 ;b = 1 ;be ta = 0 . 5 ;c = 1 ;d e l t a = 0 . 2 5 ;e ta = 0 . 0 85 ;k = 0 . 0 5 ;kappa = 0 . 0 5 ;mu = 0 . 0 5 ;tau = 1e−5;rho=1;l b =0;
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.173
Specificities of the model
Remark
The initialization file contains the line
optimizationtype=’min’;
specifying the model as a minimization problem, which is e.g.necessary to consider the correct sign property of the Lagrangianmultiplier.
Remark (Manual adaptation of the canonical system file)
Due to approximation errors near T = 0 the values for T can bebecome “slightly” negative, yielding imaginary results for theoccurring power functions. To overcome this problem we add theline
dynVar(1,:)=max(dynVar(1,:),0);
into the m-file terrnpubopCanonicalSystem. This guaranteesthe non-negativity of the terror strength T .
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.174
Matcont: Introductory remarks
• MATCONT and CL MATCONT are MATLAB numerical continuationpackages for the interactive bifurcation analysis of dynamicalsystems.
• CL MATCONT forms the computational core of MATCONT, but canalso be used independently as a general-purpose non-interactivecontinuation toolbox in MATLAB.
• MATCONT provides a GUI to CL MATCONT.
• Important websites:
• Main website: http://matcont.sourceforge.net/• Actual command line version: http://sourceforge.net/projects/matcont/files/cl_matcont/cl_matcont2.5.1/
• An in-depth manual: http://www.matcont.ugent.be/manual.pdf
• General description: http://www.scholarpedia.org/article/MATCONT
• For our purposes some of the commands of CL MATCONT have beenoverloaded to allow an immediate usage within OCMat, like e.g.,equilibrium continuation, detection of Hopf bifurcations and limitcycle continuation.
• To use CL MATCONT download actual version, unzip the file and addthe folder to the MATLAB path.
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.175
Using Matcont to determine equilibria
>> m=ocmodel ( ’ t e r rnpubop ’ ) ;>> hatx=rand (4 , 10 ) ; hatx ( 4 , : )=−hatx ( 4 , : ) ; ocEP=ca l c e p (m, hatx , [ ] , 1 ) ; ocEP=un iqueoc ( ocEP ) ;>> b=i s a dm i s s i b l e (m, ocEP) ; ocEP(˜ b ) = [ ] ; bb =
1 0 0 0>> opt=s e t o c o p t i o n s ( ’MATCONT’ , ’ MaxSteps ize ’ ,5 e−2, ’MaxNumPoints ’ ,2500 , ’ Backward ’ , 1 ) ;>> s i d x=ge tpa r ame t e r i n d ex (m, ’ e ta ’ ) ; [ x1 v1 s1 ]=contep (m, ocEP{1}, s i d x , opt ) ;f i r s t p o i n t foundtangen t v e c t o r to f i r s t p o i n t foundl a b e l = H , x = ( 0.005161 0.082883 16.679637 −2.468099 2.221977 )F i r s t Lyapunov c o e f f i c i e n t = 6.418437 e−005l a b e l = H , x = ( 0.000263 0.009388 20.277943 −3.512307 33.376116 )F i r s t Lyapunov c o e f f i c i e n t = −7.273909e−004l a b e l = H , x = ( 0.000122 0.007642 20.662849 −2.753707 42.533869 )Neu t r a l s a d d l el a b e l = LP , x = ( 0.000012 0.603177 2.841201 −0.001766 1.123745 )a=−3.850922e−005
e l a p s e d t ime = 8 . 3 s e c sn p o i n t s cu r v e = 2500
The command contep
• contep calls the MATCONT command cont(@equilibrium ,...) .
• Each column of x0 contains the continued equilibrium and inthe last row the corresponding parameter value.
• The structure s0 contains information about the first and lastelement and singularities detected during continuation.
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.176
Using Matcont to determine equilibria (2)
>> i d x=con t2 i d x ( x1 ( end , : ) , 1 . 7 5 ) ; ocEP=ca l c e p (m, x1 ( 1 : 4 , i d x ) , [ ] , 1 ) ; b=i s a dm i s s i b l e (m, ocEP)b =
1 1 1>> [ b dim]= i s s a d d l e ( ocEP{:}) ; dimdim =
2 1 2>> [m0, ocEPH ] = matcont2ocmodel (m, s1 (2 ) . index , ’ e q u i l i b r i um ’ , x1 , s i d x ) ;>> e i g (ocEPH)ans =
0.0000 + 0.0480 i0 .0000 − 0.0480 i0 .0400 + 0.0480 i0 .0400 − 0.0480 i
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.177
Periodic solution and limit cycle: Definition
Definition (Cycle and Periodic Solution)
Let x(·) satisfy the (autonomous) ODE
x(t) = f (x(t)),
such that there exists a τ > 0 with x(0) = x(τ ) then
Γ := {x(t) : t ∈ [0, τ ]} ⊂ Rn
is called a cycle. Let τ be the minimal value satisfying the propertyx(0) = x(τ ). Then x(·) is called a periodic solution with period τ .
Definition (Limit Cycle)
An isolated cycle Γ is called a limit cycle.
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.178
Limit cycle: Occurrence
Theorem (Poincare–Andronov–Hopf in R2)
Suppose the ODE
x = f (x , µ), with x ∈ R2, µ ∈ R,
has for small |µ| an equilibrium at the origin with eigenvalues
ξ1,2(µ) = η(µ)± iω(µ),
satisfying η(0) = 0, ω(0) > 0.If the following conditions are satisfied,
1 l1(0) 6= 0, (for an explicit formula of l1 see next slide),
2 η′(0) 6= 0,
then the system is locally topologically equivalent near the origin to oneof the following normal forms:
(
y1y2
)
=
(
β −11 β
)(
y1y2
)
± (y 21 + y 2
2 )
(
y1y2
)
, (9)
where β(µ) = η(µ)/ω(µ) and the sign of the cubic term is determinedby sgn l1(0).
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.179
Lyapunov coefficient
A lengthy calculation [see, e.g., Guckenheimer and Holmes, 1983,Kuznetsov, 1998] shows that the Lyapunov coefficient l1(µ) canexplicitly be written as
Formula
l1 =1
16
(
∂3f1∂x31
+∂3f1
∂x1∂x22+
∂3f2∂x21∂x2
+∂3f2∂x31
)
+1
16ω(0)
(
∂2f1∂x1∂x2
(
∂2f1∂x21
+∂2f1∂x22
)
−∂2f2
∂x1∂x2
(
∂2f2∂x21
+∂2f2∂x22
))
−1
16ω(0)
(
∂2f1∂x21
∂2f2∂x21
−∂2f1∂x22
∂2f2∂x22
)
,
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.180
Linear system
Definition (Fundamental Matrix Solution)
The time-dependent matrix X (t, t0) is called a fundamental matrixsolution of
x(t) = J(t)x(t), t ∈ R
s.t. x(t0) = x0, x0 ∈ Rn
if it satisfiesX (t, t0) = J(t)X (t, t0)
with detX (t0, t0) 6= 0, i.e., X (t0, t0) is invertible.
Remark
Every fundamental matrix solution X (t, t0) can be transformedinto a so-called principal matrix solution Y (t, t0) satisfyingY (t0, t0) = Idn, by defining
Y (t, t0) = X (t, t0)X−1(t0, t0).
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.181
Monodromy matrix
Definition
Let Γ(·) be a periodic solution of the ODE
x(t) = f (x(t)), x(t) ∈ Rn, t ∈ [0, ∞), (10)
with period τ , and let X (·) be a principal matrix solution of thevariational equation
y(t) = fx(Γ(t))y(t),
then the matrixM = X (τ ),
is called the monodromy matrix M of the periodic solution Γ(·).Let ξi , i = 1, . . . , n be the eigenvalues of the monodromy matrixM then
n+ := {i :, |ξi | > 1},
n− := {i :, |ξi | < 1},
n0 := {i :, |ξi | = 1}.
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.182
Limit cycle stability
Definition (Hyperbolic limit cycle)
Let Γ be a limit cycle of the ODE (10); then the limit cycle Γ is calledhyperbolic if a monodromy matrix M of Γ exhibits only one eigenvalue ξwith ξ = 1.If n+n− > 0, then the limit cycle Γ(·) is called of hyperbolic saddle-type.
Definition (Manifolds of a limit cycle)
Let Γ be a limit cycle of the ODE (10) then the set
Ws(Γ) = {x ∈ Rn : lim
t→∞
x(t) ∈ Γ, and x(0) = x}
is called the stable manifold of the limit cycle Γ.
Theorem (Stability of a limit cycle)
Let Γ be a limit cycle of the ODE (10) and let M be a monodromymatrix of the limit cycle. If n+ = n − 1 then the limit cycle is unstable,while if n− = n − 1 the limit cycle is stable.
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.183
Poincare map I
Considering a point xΓ ∈ Γ, we take the n − 1-dimensional hyperplane
Σ = {x : f (xΓ) (x − xΓ) = 0}, (11)
which is the plane crossing the limit cycle orthogonally at xΓ.
bb bΣ
Γ
xΓx0 P(x0)
We can define a (unique) function P : U → Σ, which is called thePoincare map, by
P(x) = x(σ),
where σ is the first time such that the trajectory starting at x crosses
the plane Σ.
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.184
Poincare map II
Owing to this construction xΓ is a fixed point of the Poincare map, sinceP(xΓ) = x(τ) = xΓ. Moreover, the Poincare map can (locally) bewritten as a discrete dynamical system in R
n−1. Hence the stability ofxΓ is described by the eigenvalues ξi , i = 1, . . . , n − 1 of the Jacobian
dP
d x(xΓ)
of the Poincare map P at xΓ.
Theorem
Let x be a fixed point of the dynamical system
x(t + 1) = f (x(t), t) , t ∈ Z,
i.e., f (x) = 0. If for every eigenvalue ξ of the Jacobian matrixJ(x) = fx(x)
|ξ| < 1
holds, then x is stable. If there exist some eigenvalues ξ with
|ξ| > 1,
then x is unstable.
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.185
Calculation of a limit cycle as a BVP
Let us consider the following autonomous system:
x(t) = f (x(t)), x ∈ Rn, n ≥ 2,
exhibiting a periodic solution, with τ unknown
x(t + τ) = x(t), for all t.
By a time scaling t → t/τ the problem becomes a BVP:
x(t) = τ f (x(t)), t ∈ [0, 1] (12a)
s.t. x(0) = x(1). (12b)
Since (12b) only provides n boundary conditions, we specify anadditional condition for identifying τ , e.g.
ψ (x(·)) := f (p) (x(0)− p) . (12c)
Remark
Equation (12c) fixes the initial point of the limit cycle lying on the lineorthogonal to the direction f (p). Usually p comes from a previous limitcycle calculation.
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.186
Initializing a limit cycle calculation
The limit cycle near an Hopf-bifurcation exhibiting two purelyimaginary eigenvalues ± iω0 with ω0 > 0 and two correspondingeigenvectors, v and its complex conjugate v can be approximatedby [see Kuznetsov, 1998, pp. 489]
Γε(t) = 2ε (vR cosω0t − vI sinω0t) ,
where ε > 0 is some arbitrary constant, vR = Re v , and vI = Im v ,where v has to satisfy
〈v , v〉 = 1, 〈vR , vI 〉 = 0
or, separated into the real and imaginary parts, these conditionsbecome:
〈vR , vR〉+ 〈vI , vI 〉 = 1, 〈vR , vI 〉 = 0. (13)
Remark
The conditions (13) are necessary to determine the eigenvector vuniquely. Since for any complex number c = c1 + i c2 ∈ C, cv isalso an eigenvector for iω0.
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.187
Implementation: General Files
f u n c t i o n newdynPrimLC=c a l c l c ( ocObj , dynPrimLC , v a r a r g i n )%// g l o b a l v a r i a b l e d e f i n i t i o n s (OcLCVar )// s e t t i n g r e f e r e n c e p o i n t and v e c t o r from a p r e v i o u s c a l c u l a t i o nOcLCVar . Re f e r en cePo i n t=dynPrimLC . dynVar ( : , 1 ) ;c a n on i c a l s y s t em ( ocObj , dynPrimLC ) ;OcLCVar . Re f e r en ceVec t o r=ans ( : , 1 ) ;// l i m i t c y c l e c a l c u l a t i o nb v s o l p r e d i c t=t r j 2 o d e ( dynPrimLC ) ;b v s o l a c t u a l=b vp s o l v e ( @dyn4lc , @bc4lc , b v s o l p r e d i c t , opt ) ;// c a l c u l a t e monodromy mat r i x
md=calcmonodromy ( ocObj , b v s o l a c t u a l , v a r a r g i n {:}) ;// t r an s f o rm s o l u t i o n i n t o oca s ymp to t i cnewdynPrimLC=od e 2 t r j ( dynPrimLC , b v s o l a c t u a l , ocObj , [ ] , md) ;
f u n c t i o n out = dyn4 l c ( t , dynVar , v a r a r g i n )%// get g l o b a l v a r i a b l e from oc c a l cg l o b a l OcLCVar// OcLCVar . ODEFunction . Dynamics=’ ter rnpubop4Cont ’out=f e v a l (OcLCVar . ODEFunction . Dynamics , t , dynVar ( 1 : OcLCVar . CanSysDim , : ) , . . .
OcLCVar . ModelParameterValue , OcLCVar . A r c I d e n t i f i e r , OcLCVar . Sw i t c h I d e n t i f i e r , . . .OcLCVar . Sw i t chCoord inate , i n t e r n a l p a r a r g ) ;
f u n c t i o n out = b c4 l c ( dynVara , dynVarb , p e r i o d )%g l o b a l OcLCVar// boundary c o n d i t i o n x (0 )=x (1 ) and phase s h i f t c o n d i t i o nout=[dynVarb ( 1 : OcLCVar . CanSysDim )−dynVara ( 1 : OcLCVar . CanSysDim ) ; . . .
sum(OcLCVar . Re f e r en ceVec t o r .∗(OcLCVar . Re f e r en cePo i n t−dynVara ( 1 : OcLCVar . CanSysDim ) ) )] ;
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.188
Implementation: Specific File
Normalized dynamics
f u n c t i o n out = te r rnpubop4Cont ( t , dynVar , pararg , a r ca rg , sw i t c h i d , sw i t chcoord , t r un c t , . . .i n t e r n a l p a r a r g )
%% the dynamics f i l e f o r model t e r rnpubop f o r the BVP
% Dynamical sys tem
// ’ sw i t c h i d ’ denotes the o c c u r r i n g sw i t c h e s between a c t i v e i n a c t i v e c o n s t r a i n t ssw i t ch l e n g t h ( sw i t c h i d )
case 0// v a r i a b l e ’ t runc ’ i s the unknown p e r i o d
out ( 1 : 4 , : )=t r u n c t∗t e r rnpubopCanon i ca lSy s t em ( t , dynVar ( 1 : 4 , : ) , pararg , a r c a r g (1 ) ) ;// new ca s e s a r e a u t oma t i c a l l y added du r i n g i n i t i a l i z a t i o n i n case o f o c c u r r i n g// v i o l a t i o n s .// ’ADDCASE’ i s the s i g n a l word f o r the au tomat i c f i l e adap t a t i on .%ADDCASE
o t h e rw i s ee r r o r ( [ num2str ( l e n g t h ( sw i t c h i d ) ) ’ %s not d e f i n e d ’ ] , s w i t c h i d )
end
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.189
Limit cycle: Detection
Starting from an Hopf bifurcation
>> l 0=1e−7; n t s t =20; n co l =4;>> opt=s e t o c o p t i o n s ( opt , ’MATCONT’ , ’ MaxSteps ize ’ ,1 e0 , ’MaxNumPoints ’ ,1500 , ’ Backward ’ , 0 ) ;>> [ x l c v l c s l c h l c f l c ]= c o n t l c (m0, ocEPH , s i d x , l0 , n t s t , nco l , opt ) ;L im i t p o i n t c y c l e ( p e r i o d = 1.644364 e+002 , paramete r = 1.262755 e+000)Normal form c o e f f i c i e n t = −2.135969e−001L im i t p o i n t c y c l e ( p e r i o d = 1.380961 e+002 , paramete r = 3.337564 e+001)Normal form c o e f f i c i e n t = −1.952996e−002np o i n t s cu r v e = 954
>> i d x=con t2 i d x ( x l c ( end , : ) , 1 . 7 5 )i d x =
116 498
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.190
Limit cycle: Calculation
Two limit cycles at η = 1.75
>> [ mlc , ocLC1 ] = matcont2ocmodel (m, i d x (1 ) , ’ l i m i t c y c l e ’ , x l c , s i d x , [ ] , f l c , n t s t , n co l ) ;opt=s e t o c o p t i o n s ( opt , ’BVP ’ , ’ AbsTol ’ ,1 e−8, ’ Re lTo l ’ ,1 e−8, ’ODE ’ , ’ AbsTol ’ ,1 e−10, . . .
’ Re lTo l ’ ,1 e−10, ’OC ’ , ’ BVPSolver ’ , ’ bvp5c ’ ) ;>> ocLC2=c a l c l c (m, ocLC1 , opt , ’ i v p ’ ) ;m=s t o r e (m, ocLC2 ) ;>> [ mlc , ocLC1 ] = matcont2ocmodel (m, i d x (2 ) , ’ l i m i t c y c l e ’ , x l c , s i d x , [ ] , f l c , n t s t , n co l ) ;>> ocLC2=c a l c l c (m, ocLC1 , opt , ’ i v p ’ ) ;m=s t o r e (m, ocLC2 ) ;>> ocLC=l i m i t c y c l e (m)ocLC =
[1 x1 d y n p r im i t i v e ] [ 1 x1 d y n p r im i t i v e ]>> opt=s e t o c o p t i o n s ( opt , ’OC ’ , ’ Z e r oE i g enVa l u eTo l e r an ce ’ ,1 e−5) ;>> [ b dim]= i s s a d d l e ( ocLC{:} , opt ) ; dimdim =
0 1
0 0.002 0.004 0.006 0.008 0.01 0.012 0.014 0.016 0.0180
0.05
0.1
0.15
0.2
0.25
T
R
Phase space: equilibria and limit cycles
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.191
Asymptotic boundary condition at a limit cycle
Proposition
Let Γ(·, ϕ0) be a periodic solution for a fixed phase-shift ϕ0 andxΓ = Γ(0, ϕ). The corresponding limit cycle Γ is hyperbolic withn− > 0 stable eigenvectors. Then (x − xΓ) ∈ Es(Γ) at xΓ iff
X (0) (x − xΓ) = 0, (14)
where X (0) ∈ R(n++1)×n is a solution of the adjoint variationalmatrix equation
X (t) = −X (t)τ fx (Γ(t, ϕ))′,
s.t. X (1) = ΛX (0),(15)
where Λ is a matrix with eigenvalues ξ satisfying |Re ξ| > 1.
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.192
The BVP for a stable path calculation
Remark
In case of a limit cycle Γ(·) the solution path converges to thewhole set {Γ(t)}. Thus it would be necessary to recalculate themonodromy matrix, which depends on the actual point of the limitcycle. To overcome this problem we let the end time T free anddemand that x(T ) lies on the n − 1 dimensional manifold spannedby the eigenvector with |ξ| < 1.
Then the general problem can be specified as a BVP on the timeinterval [0, 1]
x = Tf (x)
s.t. x (N)(0) = xs ∈ Rn, N = {1, 2, . . . , n}
F (xΓ − x(1)) = 0,
withxΓ = Γ(0), and F ∈ R
(n+1)×2n.
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.193
Initializing a stable path calculation
Remark
A “trivial” solution of the previous BVP is the limit cycle itself
(provided xs = x(N)Γ ). Thus we choose as the initial time T = kτ a
multiple of the period and set
x0(t) := Γ(t), t ∈ [0,T ].
Then we use a continuation technique to find the solution startingon some arbitrary state xs .
BVP for a (simple) stable path continuation
xm(t) = Tmf (xm(t)), m ≥ 1
s.t. x (N)m (0) = µmxs + (1− µm)xΓ ∈ R
n, N = {1, 2, . . . , n}
F (xΓ − xm(1)) = 0
µm = mµ
M, m = 0, . . . ,M
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.194
Stable path of the limit cycle
>> opt=s e t o c o p t i o n s ( ’OCCONT ’ , ’MaxStepWidth ’ , 0 . 05/5ˆ0 , ’ Mean I t e r a t i on ’ , 25 , . . .’ I n i t S t epWid th ’ , 0 . 05/5ˆ3 , ’ MaxGr idPoints ’ ,1000)
>> opt=s e t o c o p t i o n s ( opt , ’BVP ’ , ’ AbsTol ’ ,1 e−5, ’ Re lTo l ’ ,1 e−4, ’OC ’ , ’ BVPSolver ’ , ’ bvp4c ’ ) ;>> 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 , [ 0 . 1 0 . 0 5 ] , ocLC{2}, . . .
’ Con t inuat i onType ’ , ’ f ’ , ’ I n t e g r a t i o nT ime ’ , 5 ) ;>> s o l=occon t (m, i n i t S t r u c t , opt ) ;m=s t o r e (m) ; t ype=’ s t a t e ’ ; c o o r d i n a t e =2; s t a t e c o o r d i n a t e =1;>> p l o t p h a s e o c r e s u l t (m, type , s t a t e c o o r d i n a t e , coo rd i n a t e , ’ on l y ’ ,{ ’ L im i tCy c l e ’}) , ho ld on>> p l o t p h a s e o c r e s u l t (m, type , s t a t e c o o r d i n a t e , coo rd i n a t e , ’ on l y ’ ,{ ’ E q u i l i b r i um ’} , . . .
’ Marker ’ , ’ . ’ , ’ Marke rS i ze ’ , 16 , ’ Co lo r ’ , [ 0 0 1 ] ) ,>> p l o t p h a s e o c r e s u l t (m, type , s t a t e c o o r d i n a t e , coo rd i n a t e , ’ 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 ’ ,{ [1 ]})
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.195
Implementation: General Files
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 )
%// r e t u r n s s t r u c t u r e c o n t a i n i n g n e c e s s a r y i n f o rma t i o n f o r the c a l c u l a t i o n / c o n t i n u a t i o n// o f the BVPsw i t ch l owe r ( con t a r g )
case ’ e x t r ema l ’i n i t t r j=b v p i n i t ( ocObj , i n i t t r j , v a r a r g i n {:}) ;
// i n v o k e s ’ p r i v a t e f un c t i on ’ i n i t s o l u t i o ni n i t S t r u c t=i n i t s o l u t i o n ( ocObj , ’ Asymptot i cEx t r ema l ’ , i n i t t r j , v a r t ype , . . .
i n i t S t r u c t , v i o l a t i o nma t , path type ) ;endf u n c t i o n i n i t S t r u c t=i n i t s o l u t i o n ( ocObj , i n i t t y p e , ocTr j , va r t ype , i n i t S t r u c t , v a r a r g i n )%
// d e f i n i t i o n o f BVP f u n c t i o n names depend ing on the modeli n i t S t r u c t . BVPFunction . Con t i n ua t i on =[ocObj . optdyn . o c I n f o s . Name ’ BVP4Cont inuat ion ’ ] ;// d e f i n i t i o n o f ODE f u n c t i o n names depend ing on the modeli n i t S t r u c t . ODEFunction . Dynamics=[ocObj . optdyn . o c I n f o s .Name ’ 4Cont ’ ] ;// c a l l s p e c i f i c i n i t i l a i z a t i o n pa r t f o r ex t r ema l , boundary , e t c . c a l c u l a t i o ni n i t S t r u c t=e v a l ( [ ’ i n i t ’ i n i t t y p e ’ ( ocObj , ocTr j , i n i t S t r u c t , va r t ype , v a r a r g i n {:}) ’ ] ) ;
f o r i i =1: l e n g t h ( sw i t c h i d )// adapt boundary c o n d i t i o n and dynamics f i l e s i f new case o f a c t i v e / i n a c t i v e// c o n s t r a i n t s occu r
b c s t r=c r e a t e b c ( ocObj . optdyn . o c I n f o s .Name , sw i t c h i d{ i i } , i n i t S t r u c t . I d e n t i f i e r , . . .ocObj . optdyn . ocProblem . S t a t e .Num) ;
add sw i t ch ca s e ( [ i n i t S t r u c t . BVPFunction . Weiers t rassErdmannCond ’ .m’ ] , b c s t r ) ;endend// s p e c i f i c i n i t i a l i z a t i o n pa r t f o r s t a b l e path c a l c u l a t i o nf u n c t i o n i n i t S t r u c t=i n i tA s ymp t o t i cE x t r ema l ( ocObj , ocAsym , i n i t S t r u c t , va r t ype , . . .
v i o l a t i o nma t , path type )// add ing n e c e s s a r y e n t r i e s to ’ i n i t S t r u c t ’ s t r u c t u r eend
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.196
Implementation: General Files (2)
Boundary condition file
f u n c t i o n out = b c 4 i 2 l c ( dynVara , dynVarb , v a r a r g i n )%% BC4I2LC boundary c o n d i t i o n s f o r s o l u t i o n conv e r g i n g to a l i m i t c y c l e
// ’ i n t e r n a l p a r a r g ’ c o n t a i n s f r e e parameters , e . g . , the unknown p e r i o d o f the// l i m i t c y c l ei n t e r n a l p a r a r g = [ ] ;i f n a r g i n==3
i n t e r n a l p a r a r g=v a r a r g i n {1};end// g l o b a l v a r i a b l e c o n t a i n i n g s t r u c t u r e from ’ i n i t S t r u c t ’ and s e t i n ’ occont ’% g l o b a l v a r i a b l eg l o b a l OcBVPVar// BC f i l e f o r the c o n t i n u a t i o n p r o c e s s// OcBVPVar . BVPFunction . Con t i n ua t i on =’ ter rnpubopBVP4Cont inuat ion ’
// BC f i l e f o r the sw i t c h i n g c o n d i t i o n s between d i f f e r e n t a r c s// OcBVPVar . BVPFunction . Weiers t rassErdmannCond=’terrnpubopBVP4WEC ’
// BC f i l e f o r the a s ymp to t i c t r a n s v e r s a l i t y c o n d i t i o n// OcBVPVar . BVPFunction . A s ymp to t i cT ran s v e r s a l i t yCond =’terrnpubopBVP4AsymTransCond ’
out=[ f e v a l (OcBVPVar . BVPFunction . Cont inuat i on , dynVara , OcBVPVar . Con t i n u a t i o nVa r i a b l e , . . .OcBVPVar . ActCont inuat ionType , OcBVPVar . Targe tCoord inate , OcBVPVar . Prev iousBVSol ,
. . .OcBVPVar . Con t i n ua t i onVec t o r , OcBVPVar . StepWidth , OcBVPVar . S ta r tVa lue , . . .OcBVPVar . I n i t i a l V a l u e , i n t e r n a l p a r a r g ) ; . . .f e v a l (OcBVPVar . BVPFunction . WeierstrassErdmannCond , dynVara , dynVarb , . . .
OcBVPVar . ModelParameterValue , OcBVPVar . A r c I d e n t i f i e r , . . .OcBVPVar . Sw i t c h I d e n t i f i e r , OcBVPVar . Sw i t chCoo rd i n a t e ) ; . . .
f e v a l (OcBVPVar . BVPFunction . A s ymp to t i cT ran s v e r s a l i t yCond , . . .dynVarb ( end−OcBVPVar . CanSysDim+1: end ) , ’EP ’ , . . .OcBVPVar . Asymptot icBCMatr ix , OcBVPVar . Sadd l ePo i n t ) ] ;
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.197
Multiplicity: Unique equilibrium
>> m=ocmodel ( ’ t e r rnpubop ’ ) ;m=changeparameter (m, ’ r , gamma , eta , kappa ’ , . . .[ 0 . 0 3 5 0 .95 0 .035 0 . 0 1 25 ] ) ;
>> opt=s e t o c o p t i o n s ( opt , ’BVP ’ , ’ AbsTol ’ ,1 e−5, ’ Re lTo l ’ ,1 e−4, ’ BVPSolver ’ , ’ bvp5c ’ ) ;>> 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 , [ 0 . 1 2 5 ] , ocEP{1}, . . .
’ Con t inuat i onType ’ , ’ a l ’ , ’ I n t e g r a t i o nT ime ’ ,5000) ;>>opt=s e t o c o p t i o n s ( opt , ’OCCONT ’ , ’MaxStepWidth ’ , 0 . 01 , ’ Mean I t e r a t i on ’ , 75 , . . .
’ I n i t S t epWid th ’ , 0 . 0004 , ’ StepWidth ’ , 0 . 0004 , ’ MaxGr idPoints ’ ,1000) ;>> s o l=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 ’ , ’ MaxCont inuat i onStep s ’ ,445 , ’MaxStepWidth ’ , 0 . 05/5ˆ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 , [ 0 . 1 2 5 ] , s o l , . . .
’ Con t inuat i onType ’ , ’ f ’ ) ;>> s o l=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 ’ , ’ MaxCont inuat i onStep s ’ ,238 , ’MaxStepWidth ’ , 0 . 05/5ˆ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 , [ 0 . 1 2 5 ] , s o l , . . .
’ Con t inuat i onType ’ , ’ f ’ ) ;>> s o l=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, ’ c o s t a t e ’ , 1 , 1 , ’ on l y ’ ,{ ’ S l i c eMan i f o l d ’})
0.12 0.122 0.124 0.126 0.128 0.13 0.132 0.134 0.13611
12
13
14
15
16
17
18
19
20
21
T
λ1
Slice manifolds,
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.198
Different paths converging to the same equilibrium
>> 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 , [ 0 . 5 5 ] , ocEx{1}) ;>> opt=s e t o c o p t i o n s ( opt , ’OCCONT ’ , ’ MaxCont inuat i onStep s ’ , i n f , ’ MaxStepWidth ’ , 0 . 0 5 ) ;>> s o l=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 , [ 0 . 5 5 ] , ocEx{3}) ;>> s o l=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) ;>> opt=s e t o c o p t i o n s ( opt , ’OCCONT ’ , ’MaxStepWidth ’ , 0 . 0 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 : 2 , ocEx{5}. dynVar ( 1 : 2 , 1 ) , ocEx{4}) ;>> s o l=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 ’ , ’ MaxCont inuat i onStep s ’ , 89) ;>> 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 , ocEx{4}. dynVar ( 1 : 2 , 1 ) , ocEx{5}) ;>> s o l=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) ;>> dns s=f i n d d n s s (m, 6 , 7 )dns s =
0.50006.2560
6.245 6.25 6.255 6.26 6.2650.1583
0.1584
0.1585
0.1586
0.1587
0.1588
0.1589
0.159
0.1591
R
H
Crossing Hamiltonians
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.199
Multiplicity: Calculating the indifference curve
>> opt=s e t o c o p t i o n s ( opt , ’OCCONT ’ , ’ MaxCont inuat i onStep s ’ , i n f , ’ MaxStepWidth ’ , 0 . 0 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 : 2 , dnss , ocEx{6}) ;>> s o l=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 ’ , ’ MaxCont inuat i onStep s ’ , 98) ;>> 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{7}) ;>> s o l=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) ;>> ocDNSS=[ocEx{8} ocEx{9} ] ;>> opt=s e t o c o p t i o n s ( opt , ’OCCONT ’ , ’ MaxCont inuat i onStep s ’ , i n f , . . .
’ MaxStepWidth ’ , 0 . 05/5ˆ0 , ’ Mean I t e r a t i on ’ , 90 , ’ I n i t S t epWid th ’ , 0 . 05/5ˆ2 , . . .’ StepWidth ’ , 0 . 05/5ˆ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 ’ , 1 , 2 , ocDNSS , ’ Con t inuat i onType ’ , ’ a l ’ )>> s o l d=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 ( ’ dn s s ’ ,m, ’ i n i t p o i n t ’ , 2 , 0 , so ld , ’ Con t inuat i onType ’ , ’ a l ’ ) ;>> s o l d=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 ’} , ’ o n l y i n d e x ’ ,{ [ ]} , . . .
’ Co lo r ’ , [ 1 0 0 ] )
0 0.5 1 1.5 2 2.5 30
1
2
3
4
5
6
7
T
R
”Strange” curve
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.200
Plotting the result
Adapt user function
f u n c t i o n out = te r r npubopUse rFunc t i on ( t , dynVar , pararg , a r c a r g )%% r e t u r n s the v a l u e s f o r a u s e r d e f i n e d f u n c t i o n o f t e r rnpubop model// s e t t i n g paramete r v a l u e sr=pa ra r g (1 ) ;// c a l c u l a t i n g c on t r o l , s t a t e , c o s t a t e v a l u e sx=te r r npubopS ta t eVa l u e ( t , dynVar , pararg , a r c a r g ) ;u=te r r npubopOp t ima lCon t r o l ( t , dynVar , pararg , a r c a r g ) ;% Funct ion v a l u e s// he r e the u s e r can s p e c i f y h i s / he r own f u n c t i o n sout=[ l og ( dynVar ( 1 : 2 , : ) ) ] ;
>> p l o t p h a s e o c r e s u l t (m, ’ u s e r f u n c ’ , 2 , 1 , ’ on l y ’ ,{ ’ DNSSCurve ’} , ’ o n l y i n d e x ’ ,{ [2 ]} , . . .’ a s s o c i a t e d s o l ’ , ’ on ’ , ’ Co lo r ’ , [ 1 0 0 ] )
0 1 2 3 4 5 6 7 8−10
−8
−6
−4
−2
0
2
R
log(T
)
Dieter Graß
Introduction
Terrorism
Minimization
Matcont: Part 1
Equilibriumcontinuation
Limit cycle: Part 1
Hopf bifurcation
Stability
Poincare map
BVP
Initialization
Implementation
Matcont: Part 2
Limit cyclecontinuation
Limit cycle: Part 2
Calculation
Stable path
Initialization
Implementation
Multiplicity: Revisited
Unique equilibrium
Indifference curve
References
OCMat functions
5.201
References
J.P. Caulkins, G. Feichtinger, D. Grass, and G. Tragler. Optimal control ofterrorism and global reputation: A case study with novel threshold behavior.Operations Research Letters, 37(6):387–391, 2009
K. Lust. Improved numerical floquet multipliers. International Journal ofBifurcation and Chaos, 11(9):2389–2410, 2001
Y.A. Kuznetsov. Elements of Applied Bifurcation Theory. Springer Verlag,New York, 2nd edition, 1998
P. Deuflhard and F. Bornemann. Numerische Mathematik 2: GewohnlicheDifferentialgleichungen. de Gruyter, Berlin, New York, 3. edition, 2008
W. Govaerts, Yu.A. Kuznetsov, A. Dhooge, H.G.E. Meijer, W. Mestrom, A.M.Riet, and B. Sautois. MATCONT and CL MATCONT: Continuation toolboxesin MATLAB, 2006
R. Seydel. Practical Bifurcation and Stability Analysis. Springer Verlag, Berlin,3rd edition, 2009
A. Dhooge, W. Govaerts, and Yu.A. Kuznetsov. Numerical continuation of
fold bifurcations of limit cycles in MATCONT. In J. Hartmanis G. Goos and
J. van Leeuwen, editors, Computational Science—ICCS 2003, volume
2657/2003 of Lecture Notes in Computer Science, pages 701–711, 2003
Dieter Graß
MATCONT Interface
contep
contlc
matcont2ocmodel
calclc, store
General
getparameterindex,limitcycle
cont2idx
issaddle
5.202
f u n c t i o n [ v a r a r g ou t ]= contep ( ocObj , dynPrim , ap , v a r a r g i n )%% CONTEP con t i n u e s an e q u i l i b r i um u s i n g MATCONT%% CONTEP(OCOBJ,OCEP,AP) the e q u i l i b r i um s t o r e d as a d y n p r im i t v e ob j e c t OCEP% i s con t i n u ed by chang ing the paramete r v a l u e w i th i nd ex AP, s t a r t i n g at% the a c t u a l pa ramete r v a l u e o f OCOBJ . The n e c e s s a r y MATCONT f i l e ( s e e% MATCONT manual ) i s g en e r a t ed a u t oma t i c a l l y as ”model4matcont .m” , where% model i s the name o f OCOBJ .%% X = CONTEP(OCOBJ,OCEP,AP) the r e t u r n e d argument X i s a matr ix , where each% column con t a i n s the v a l u e s o f the e q u i l i b r i um a long the c o n t i n u a t i o n% cu r v e . I n the l a s t row the a c t u a l v a l u e o f the con t i n u ed paramete r i s% w r i t t e n .%% [X V S ] = CONTEP(OCOBJ,OCEP,AP) the mat r i x V con t a i n s the tangen t v e c t o r s% a long the c o n t i n u a t i o n cu r v e and S i s a s t r u c t u r e w i th f i e l d s :% s . i n d ex . . . i n d ex o f the s i n g u l a r i t y p o i n t i n x , so s (1 ) . i n d ex i s% a lways equa l to 1 and s ( end ) . i n d ex i s the number o f computed% p o i n t s .% s . l a b e l . . . l a b e l o f the s i n g u l a r i t y ; by conv en t i on s (1 ) . l a b e l i s 0 0% and s ( end ) . l a b e l i s 9 9 .% s . msg . . . a s t r i n g th a t may con t a i n any i n f o rma t i o n which i s u s e f u l% f o r the u se r , f o r example the f u l l name o f the d e t e c t ed s p e c i a l% po i n t .% For f u r t h e r i n f o rma t i o n about the r e t u r n e d arguments the r e ad e r i s% r e f e r r e d to the MATCONT manual .%% [X V S ] = CONTEP(OCOBJ,OCEP,AP,OPT) OPT i s an occon t op t i on s t r u c t u r e ,% where the f i e l d OPT.MATCONT p r o v i d e s s p e c i f i c o p t i o n s f o r MATCONT. To% change MATCONT s p e c i f i c o p t i o n s use the command :%% opt=s e t o c o p t i o n s ( opt , ’MATCONT’ ,OPTIONNAME,OPTIONVALUE)%% The most impor tan t f i e l d s f p r u s u a l a p p l i c a t i o n s a r e :% MaxSteps ize . . . t h e maximum s t e p s i z e ( 0 . 1 )% MaxNumPoints . . . maximum number o f p o i n t s on the cu r v e (300)% Backward . . . i n d i c a t i n g the d i r e c t i o n o f the c o n t i n u a t i o n (0 )% S i n g u l a r i t y . . . i n d i c a t i n g the p r e s en ce o f a s i n g u l a r i t y (1 )%% f o r a complete l i s t o f o p t i o n s the r e ad e r i s r e f e r r e d to the MATCONT% manual
Dieter Graß
MATCONT Interface
contep
contlc
matcont2ocmodel
calclc, store
General
getparameterindex,limitcycle
cont2idx
issaddle
5.203
f u n c t i o n [ v a r a r g ou t ]= c o n t l c ( ocObj , dynPrim , ap , v a r a r g i n )%% CONTLC con t i n u e s a l i m i t c y c l e u s i n g MATCONT%% CONTLC(OCOBJ,OCH,AP) u s u a l l y the c o n t i n u a t i o n o f a l i m i t c y c l e s t a r t s% from an e q u i l i b r i um at a Hopf b i f u r c a t i o n , d e t e c t ed by a p r e v i o u s MATCONT% e q u i l i b r i um c o n t i n u a t i o n . Then OCH i s the c o r r e s p on d i n g e q u i l i b r i um% s t o r e d as a d y n p r im i t i v e o b j e c t and AP the a c t i v e paramete r i n d ex .%% CONTLC(OCOBJ,OCH,AP, L0 ,NTST,NCOL) then L0 con t a i n s the v a l u e o f the% i n i t i a l amp l i tude and NTST and NCOL ar e the number o f mesh and% c o l l o c a t i o n p o i n t s to be used f o r the d i s c r e t i z a t i o n .%% CONTLC(OCOBJ,X,AP,V, S) to s t a r t a c o n t i n u a t i o n from a p r e v i o u s l i m i t% c y c l e c o n t i n u a t i o n the data X, thangen t data V and i n f o rma t i o n s t r u c t u r e% S has to be p rov i d ed .%% CONTLC(OCOBJ,X,AP,V, S , L0 ,NTST,NCOL)%% CONTLC(OCOBJ,X,AP , . . . , OPT) i f the l a s t argument i s an ocmat op t i on% s t r u c t u r e the op t i o n s f o r MATCONT f o r the MATCONT co n t i n u a t i o n .%% [X V S H F ] = CONTLC ( . . . ) the arguments X, V, S a r e the same as f o r the% e q u i l i b r i um c o n t i n u a t i o n (CONTEP)% F con t a i n s d i f f e r e n t i n f o rmat i on , depend ing on the c o n t i n u a t i o n run . For% noncyc l e−r e l a t e d c on t i n u a t i o n s , the f−v e c t o r j u s t c o n t a i n s the% e i g e n v a l u e s , i f asked f o r . For l i m i t c y c l e c o n t i n u a t i o n s , i t b e g i n s w i th% the mesh p o i n t s o f the time− d i s c r e t i z a t i o n , f o l l owed by , i f th ey were% asked f o r , the PRC− and dPRC−v a l u e s i n a l l p o i n t s o f the p e r i o d i c o r b i t% ( c f . MATCONT manual ) . Then , i f r e q u i r e d , f o l l ow the m u l t i p l i e r s and% monodromy matr ix , i f i n s t e a d o f the o r i g i n a l ” l i m i t c y c l e .m” f i l e the% ocmat v e r s i o n i s used ( t h i s i s the d e f a u l t b e h a v i o r ) .
Dieter Graß
MATCONT Interface
contep
contlc
matcont2ocmodel
calclc, store
General
getparameterindex,limitcycle
cont2idx
issaddle
5.204
f u n c t i o n [ newocObj , ocElement ] = matcont2ocmodel ( ocObj , idx , v a r a r g i n )%% MATCONT2OCMODEL gen e r a t e s a new i n s t a n t o f an ocmodel u s i n g the r e s u l t s% o f a MATCONT co n t i n u a t i o n%% MATCONT2OCMODEL(OCOBJ, IDX) u s e s the IDXth column o f the r e s u l t s o f an% p r e v i o u s MATCONT con t i n u a t i o n , w r i t t e n to the mat−f i l e% ”mode lMatContCont inuat ionData . mat” and s t o r e d the d e f a u l t data f o l d e r o f% the ocmodel OCOBJ to gen e r a t e a new i n s t a n t o f OCOBJ wi th the new% paramete r v a l u e s and the ob j e c t , e i t h e r an e q u i l i b r i um o f a l i m i t c y c l e .%% MATCONT2OCMODEL(OCOBJ, IDX , ’ EQUILIBRIUM ’ ,X,AP) the IDXth column from an% e q u i l i b r i um c o n t i n u a t i o n s t o r e d i n X, w i th a c t i v e paramete r AP i s used to% gene r a t e a new i n s t a n t o f an OCOBJ .%% MATCONT2OCMODEL(OCOBJ, IDX , ’ EQUILIBRIUM ’ ,X,AP, ARCID) f o r the c a l c u a l t i o n% o f the new e q u i l i b r i um the a r c i d e n t i f i e r ARCID i s used . The d e f u a l t% v a l u e i s 1 .%% [NOCOBJ OCEP] = MATCONT2OCMODEL(OCOBJ, IDX , ’ EQUILIBRIUM ’ ,X,AP,ARCID) the% argument NOCOBJ i s an ocmodel based on OCOBJ but chagnged paramete r v a l u e% o f i n d ex AP and v a l u e X(END, IDX) . The argument OCEP i s the a c t u a l% e q u i l i b r i um s t o r e d as a d y n p r im i t i v e .%% MATCONT2OCMODEL(OCOBJ, IDX , ’ LIMITCYCLE ’ ,X,AP,ARCID , F ,NTST,NCOL) a f t e r a% l i m i t c y c l e c o n t i n u a t i o n (CONTLC) the data X can be used to gen e r a t e a% new i n s t a n t o f an ocmodel c o n t a i n i g the c o r r e s p on d i n g l i m i t c y c l e as% r e t u r n e d by MATCONT. The arguments F ,NTST,NCOL ar e e x p l a i n e d i n more% d e t a i l i n CONTLC or the MATCONT manual .%% [NOCOBJ OCLC] = MATCONT2OCMODEL(OCOBJ, IDX , ’ LIMITCYCLE ’ ,X,AP,ARCID , . . . )% the same as f o r the ’ e q u i l i b r i um ’ case w i th OCLC a d y np r im i t v e o f t ype% l i m i t c y c l e .
Dieter Graß
MATCONT Interface
contep
contlc
matcont2ocmodel
calclc, store
General
getparameterindex,limitcycle
cont2idx
issaddle
5.205
f u n c t i o n newdynPrimLC=c a l c l c ( ocObj , dynPrimLC , v a r a r g i n )%% CALCLC ( r e ) c a l c u l a t e s a l i m i t c y c l e%% CALCLC(OCOBJ,OCLC) c a l c u l a t e s a l i m i t c y c l e u s i n g the paramete r v l a u e s o f% OCBJ and the l i m i t c y c l e OCLC as an i n i t i a l s o l u t i o n .%% CALCLC(OCOBJ,OCLC,OPT) wi th OPT op t i o n s f o r the boundary v a l u e s o l v e r can% be p rov i d ed . These op t i o n s a r e w r i t t e n i n the f i e l d OPT.BVP and can be% changed by :%% opt=s e t o c o p t i o n s ( ’BVP’ ,OPTIONNAME,OPTIONVALUE)%% f o r a l l p o s s i b l e o p t i o n s s e e the documentat ion o f the MATLAB command% ’ bvpset ’%% to change the used BV s o l v e r s e t :%% opt=s e t o c o p t i o n s ( ’OC’ , ’ BVPSolver ’ ,SOLVERNAME) , where SOLVERNAME i s% ’ bvp4c ’ ( d e f a u l t ) o r ’ bvp5c .%% NOCLC = CALCLC(OCOBJ,OCLC,OPT) NOCLC i s the ( r e ) c a l c u l a t e d l i m i t c y c l e% a f t e r a s u c c e s s f u l l computat ion .
The command
>> store(m,ocLC)
stores a limit cycle ocLC in the ocResults.LimitCycle field ofthe ocmodel m.
Dieter Graß
MATCONT Interface
contep
contlc
matcont2ocmodel
calclc, store
General
getparameterindex,limitcycle
cont2idx
issaddle
5.206
f u n c t i o n i d x=ge tpa r ame t e r i n d ex ( ocObj , name )%% GETPARARAMETERINDEX r e t u r n s the i nd ex o f a s p e c i f i c pa ramete r name%% IDX = GETPARARAMETERINDEX(OCOBJ,NAME) r e t u r n s the i nd ex IDX o f the% paramete r denoted by NAME.
f u n c t i o n ocLC = l i m i t c y c l e ( ocObj , v a r a r g i n )%% LIMITCYCLE r e t u r n s the l i m i t c y c l e ( s ) s t o r e d i n OCOBJ%% OCLC=LIMITCYCLE(OCOBJ) r e t u r n s a c e l l a r r y o f l i m i t c y c l e s s t o r e d i n the% ’ ocRe su l t s ’ f i e l d ’ L im i tCy c l e ’ o f OCOBJ .
Dieter Graß
MATCONT Interface
contep
contlc
matcont2ocmodel
calclc, store
General
getparameterindex,limitcycle
cont2idx
issaddle
5.207
f u n c t i o n i d x=con t2 i d x ( contpar , p a r v a l )%% CONT2IDX r e t u r n s i n d i c e s where a cu r v e c r o s s e s a s p e c i f i c pa ramete r v a l u e%% IDX=CONT2IDX(CONTPAR,PARVAL) r e t u r n s the i nd ex / i n d i c e s where the% cu r v e s t o r e d as a v e c t o r o f d i s c r e t e numbers CONTPAR, u s u a l l y coming from% a c o n t i n u a t i o n p roce s s , c r o s s e s the paramete r v a l u e PARVAL .
Dieter Graß
MATCONT Interface
contep
contlc
matcont2ocmodel
calclc, store
General
getparameterindex,limitcycle
cont2idx
issaddle
5.208
f u n c t i o n [ b , dim]= i s s a d d l e ( v a r a r g i n )%% ISSADDLE t r u e i f l i m i t s e t i s o f s a d d l e t ype%% B = ISSADDLE(DYNPRIM) the i n p u t argument DYNPRIM i s a d y n p r im i t v e ob j e c t ,% ’ e q u i l i b r i um ’ o r ’ l i m i t c y c l e ’ . B i s 1 i f DYNPRIM i s o f s a d d l e type , f o r% an e q u i l i b r i um at l e a s t one e i g e n v a l u e has to be n e g a t i v e . For a l i m i t% c y c l e the ab s o l u t e v a l u e at l e a s t o f one e i g e n v a l u e has to be sma l l e r% than one .%% [B DIM] = ISSADDLE(DYNPRIM) DIM r e t u r n s the number o f o f ” s t a b l e ”% e i g e n v a l u e s%% [B DIM] = ISSADDLE(DYNPRIM,OPT) wi th OPT the t o l e r a n c e f o r a z e r o% e i g e n v a l u e can be p rov i d ed :% opt=s e t o c o p t i o n s ( ’OC’ , ’ Ze roE igenVa lueTo l e rance ’ , t o l ) ;%% [B DIM] = ISSADDLE(DYNPRIM1 , . . . , DYNPRIMN) B i s a v e c t o r o f 0 and 1% depend ing i f the d y n p r im i t v e o b j e c t s DYNPRIM1 , . . . , DYNPRIMN are o f s a d d l e% type . DIM i s a v e c t o r c o n t a i n i n g the number o f ” s t a b l e ” e i g e n v l a u e s f o r% each o f the d y n p r im i t v e o b j e c t s .%% [B DIM] = ISSADDLE(DYNPRIM1 , . . . , DYNPRIMN,OPT)