当前位置:   article > 正文

Hamilton雅可比矩阵判别系统稳定性(学了个寂寞)_雅可比矩阵判断生态系统稳定性

雅可比矩阵判断生态系统稳定性

参考文章内容:https://github.com/Santosh-Gudlavalleti/PH3500-Classical-Physics

最近在研究端口-Hamilton系统想做个控制方面的东西所以学习了一下相关内容上述网站上的内容说它采用了哈密尔顿、拉格朗日等方法对系统的稳定性进行了一个分析,这是一个国外物理课程的实验课里面还有它的PDF介绍。虽然我觉得这个文章和Hamilton控制没什么大关系但毕竟学都学了还是记录一下。

背景介绍

目的

了解由一节非线性微分方程链接的两个状态之间的关系、稳定性和其它参数

背景

整个系统是模拟观测兔子和狼数量的场景、假设场景内只有兔子和狼两个物种,他们的数量是随时间变化的,植物的数量非常大也就是说兔子的食物是无限的。文章中说她参考了Lotka-volterra模型但是对其做了简化

系统方程

原始系统

狼和兔的系统方程如下:

r\dot =dr/dt=(a\ast r)-(b\ast w\ast r)

w\ \dot=dw/dt=(c\ast w\ast r)-(d\ast w)

a-兔子的出生速率

b-兔子被吃掉和死亡的速率

c-狼的生长速度(因为狼的食物是兔子,所以狼的生长依赖兔子)、

d-狼的死亡速率(由于年龄和相互竞争关系)

r-兔子当前的种群规模

w-狼当前的数量规模

p-植物的数量,假设数量巨大,数量变化忽略不计。

下一时刻的系统

由于上述系统对时间没有明确的依赖,所以他是一个自洽/自治系统

得出雅可比矩阵

r_1w_1我们看作是系统经历了一个时间 t 后的新的状态,用原本的规模加上一个 变化率和时间的乘积,或者可以看作是一个泰勒展开,那么我们可以得到:

同样的:

这样就能得到雅可比矩阵:

计算上述雅可比矩阵的行列式

系统分析

对于整个系统的初始条件设置为: r = 100 ; w = 60 ; a = 0.18 ; b = 0.004 ; c = 0.001 ; d = 0.01

我认为在这里abcd应该可以看做是系统本身的参数是无法进行更改的

随后可以将狼和羊的数量表示出来,这个图中表示狼和羊的数量是一只发生变化并有一个对应的关系:

对于实时变化而言,我们可以看出两个钟群的数量变化关系是稳定的

如果此时我们将羊的初始值设置为500,即将r=500

那么此时

再来看看这个图可以发现这个系统的稳定性就大大下降了,兔子和狼一度都 有灭绝的风险

如果我们将兔子的初始数量设置为 r=1000,我们会发现此时狼和羊都会灭绝

通过我们最初的系统方程

我们可以计算出狼和羊数量变化同时为0的时刻所对应的点(w,r)的值应该是(0,0)(a/b,d/c)

当取(0,0)时,文中说计算雅可比矩阵的特征值为a和-d,但是我算的并不是,我觉得原文中此时所指的雅可比矩阵应该是这个矩阵

因为只有这个矩阵我算着特征值才是和原文相同的。

当取(0,0)点时

可以算出特征值分别为\lambda _1=a,\lambda_2=-d通过分析Jacobi矩阵的特征值。由于符号总是相反的,我们可以断定它是鞍点。同样可以用以下逻辑推理来解释:如果狼的数量变为0,兔子的数量指数地达到无穷大,而如果兔子的数量为0,狼的数量指数地下降到0。图的性质在两个方向上是不同的,因此可以得出它是一个鞍点。

在点(a/b,d/c)我们可以得到特征值为\lambda_1 = i\sqrt{ad}; \quad \lambda_2 = -i\sqrt{ad}很明显,解是纯虚的(解的实部为零)和彼此的复共轭。因此系统是椭圆型的,解是周期的。系统绕这一点在椭圆上振荡。振荡的频率就是特征值的几何平均值。因此振荡的频率\omega =\sqrt{ad}(这块我不懂)

我们可以观察到:当兔子的数量或狼的数量达到特定值(即r = d/c或w = a/b)时,切线斜率的符号发生变化。这些是驱动系统走向稳定的点。椭圆轨迹解释了振荡的相位差,而相位差与椭圆的偏心率有关。

随后进行推导:

上下进行除法

进行分离变量并对两侧同时进行积分:

由于 K 是常数故而:

可以得到是守恒的

通过数量模拟我们可以得到 K 关于 rw 的值的变化如下,可以看到除了边界区, 大部分区域的 K 值为稳定的在 0.64 附近

然后文章中就得出了这么一个结论:

对上述问题进行抽样,我们可以借助哈密顿动力学和其他方程在数学上预测其 行为。若雅可比矩阵行列式中 df 的系数接近于零,则称为稳定系统,(- 0.05,0.05)可为系统稳定的相当大范围。在这个范围内,与实际状态量相比不 会有脉冲变化,因此系统处于稳定区(我还是不懂)

感觉学物理专业的同学应该能明白它再讲什么,对于我这么个学通信实在是云里雾里。

一些代码如下:

  1. % Project : Dynamics of First order Nonlinear Differential Equations
  2. % Instructor : Prof. S. Kasiviswanathan
  3. % Course : Classical Physics (PH3500)
  4. % Project By : Santosh Gudlavalleti
  5. % Roll Number: EE19B055
  6. clc, clear
  7. disp('Welcome to the Display, Please choose an option');
  8. disp('Option 1: The Final Plots will be displayed with demo Inputs');
  9. disp('Option 2: The Live Phase Space Plots will be displayed with demo Inputs, (Quite Slow)');
  10. disp('Option 3: The Final Plots will be displayed with demo Inputs of population and disease factor');
  11. disp('Option 4: The Final Plots will be displayed with Custom Inputs');
  12. s = input('Option: ');
  13. if s == 1
  14. disp('The Final Plots will be displayed with Initial Rabbit Population as 100 and Wolf Population as 60');
  15. disp('Please Wait while the Graph is being Made');
  16. disp('Use Function: "main" to re-run the program');
  17. figure(1)
  18. fun_1(0,0.18,0.004,0,0.001,0.1,200);
  19. fun_3(0,0.18,0.004,0,0.001,0.1,20);
  20. fun_5(1000,0.18,0.004,60,0.001,0.1,200);
  21. end
  22. if s == 2
  23. disp ('The Live Phase Space Plots will be displayed with Initial Rabbit Population as 100 and Wolf Population as 60');
  24. disp ('Please Wait while the Graph is complete(Takes Time)');
  25. pause(2.0);
  26. fun_2(100,0.18,0.004,60,0.001,0.1,200);
  27. end
  28. if s == 3
  29. disp('The Final Plots will be displayed with Initial Rabbit Population as 100 and Wolf Population as 60');
  30. disp('The rabbits are affected by a disease after they reach 300 i.e ~85% of the max Population');
  31. disp('Please Wait while the Graph is being Made');
  32. disp('Use Function: "main" to re-run the program')
  33. fun_4(100,0.18,0.004,60,0.001,0.1,200,0.008);
  34. end
  35. if s == 4
  36. disp('Please enter the Custom Inputs')
  37. r = input('Enter Initial Rabbit Population (preferred 75-150): ');
  38. w = input('Enter Initial Wolf Population (preferred 50-75): ');
  39. t = input('Enter Time Duration (preferred >50): ');
  40. a = input('Enter growth rate of Rabbit(a) (preferred 0.15-0.20): ');
  41. b = input('Enter death rate of Rabbit(b) (preferred 0.0025-0.0075): ');
  42. c = input('Enter growth rate of Wolves(c) (preferred 0.0005-0.003): ');
  43. d = input('Enter death rate of Wolves(d) (preferred 0.05-0.25): ');
  44. fun_1(r,a,b,w,c,d,t);
  45. end
  46. if isempty(s) || s~=1 && s~=2 && s~=3 && s~=4
  47. disp ('Enter A valid Option')
  48. end
  49. function [out1] = fun_1(r,a,b,w,c,d,t) %Current Phase Plot
  50. h = 0.001;
  51. ra = (r);
  52. wo = (w);
  53. for i = 1:(t/h)
  54. ra(i+1) = ra(i)*(1 + h*(a - b*wo(i)));
  55. wo(i+1) = wo(i)*(1 + h*(c*ra(i) - d));
  56. % if ra(i) > 1 && wo(i) > 1
  57. % ra(i+1) = ra(i)*(1 + h*(a - b*wo(i)));
  58. % wo(i+1) = wo(i)*(1 + h*(c*ra(i) - d));
  59. % else
  60. % ra(i+1) = 0;
  61. % wo(i+1) = 0;
  62. % end
  63. end
  64. out1 = [ra wo];
  65. plot(ra, wo)
  66. title('Plot of population of Wolves vs population of Rabbits')
  67. xlabel('Population of Rabits')
  68. ylabel('Population of Wolves')
  69. grid on;
  70. legend({'Direction of flow: Anticlockwise'},'Location','northeast')
  71. hold on
  72. function [out2] = fun_2(r,a,b,w,c,d,t) %Live Phase plot
  73. h = 0.001;
  74. ra = (r);
  75. wo = (w);
  76. curve = animatedline
  77. for i = 1:(t/h)
  78. if ra(i) > 0 && wo(i) > 0
  79. ra(i+1) = ra(i)*(1 + h*(a - b*wo(i)));
  80. wo(i+1) = wo(i)*(1 + h*(c*ra(i) - d));
  81. else
  82. ra(i+1) = 0;
  83. wo(i+1) = 0;
  84. end
  85. title('Plot of population of Wolves vs population of Rabbits')
  86. xlabel('Population of Rabits')
  87. ylabel('Population of Wolves')
  88. set(gca,'XLim',[50 150],'YLim',[25 75]);
  89. grid on;
  90. addpoints(curve, ra(i), wo(i));
  91. drawnow limitrate
  92. end
  93. function [out3] = fun_3(r,a,b,w,c,d,t) %Variation with Time
  94. h = 0.001;
  95. ra = (r);
  96. wo = (w);
  97. for i = 1:(t/h)
  98. if ra(i) > 0 && wo(i) > 0
  99. ra(i+1) = ra(i)*(1 + h*(a - b*wo(i)));
  100. wo(i+1) = wo(i)*(1 + h*(c*ra(i) - d));
  101. else
  102. ra(i+1) = 0;
  103. wo(i+1) = 0;
  104. end
  105. end
  106. figure(3)
  107. plot(0:t/h,ra)
  108. hold on
  109. plot (0:t/h,wo)
  110. title('Plots of population of Wolves vs Time and Population of Rabbits vs Time')
  111. xlabel('Time (in days)')
  112. ylabel('Population')
  113. legend({'y = Rabbits Count', 'y = Wolves Count'},'Location','northeast')
  114. set(gca,'XTickLabel',(0:(t/10):t));
  115. hold off
  116. function [out4] = fun_4(r,a,b,w,c,d,t,s) %Diseased, Variation with time
  117. h = 0.001;
  118. ra = (r);
  119. wo = (w);
  120. for i = 1:(t/h)
  121. if ra(i) > 0 && wo(i) > 0
  122. if ra(i) > 130
  123. ra(i+1) = ra(i)*(1 + h*(a - s*wo(i)));
  124. wo(i+1) = wo(i)*(1 + h*(c*ra(i) - d));
  125. else
  126. ra(i+1) = ra(i)*(1 + h*(a - b*wo(i)));
  127. wo(i+1) = wo(i)*(1 + h*(c*ra(i) - d));
  128. end
  129. else
  130. ra(i+1) = 0;
  131. wo(i+1) = 0;
  132. end
  133. end
  134. out4 = [ra wo];
  135. figure(4)
  136. plot(0:t/h,ra)
  137. hold on
  138. plot (0:t/h,wo)
  139. title('Plots of population of Wolves vs Time and Population of Rabbits vs Time')
  140. xlabel('Time (in days)')
  141. ylabel('Population')
  142. legend({'y = Rabbits Count', 'y = Wolves Count'},'Location','northeast')
  143. set(gca,'XTickLabel',(0:(t/10):t));
  144. hold off
  145. function [out5] = fun_5(r,a,b,w,c,d,t) %Demo Phase plots
  146. figure(5)
  147. fun_1(50,0.18,0.004,30,0.001,0.1,200);
  148. hold on;
  149. fun_1(100,0.18,0.004,60,0.001,0.1,200);
  150. hold on;
  151. fun_1(150,0.18,0.004,90,0.001,0.1,200);
  152. title('Phase-Space plot of population of Wolves vs population of Rabbits')
  153. hold off;

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/78168
推荐阅读
相关标签
  

闽ICP备14008679号