2.双方演化博弈代码

2021-05-06  本文已影响0人  谭小飞同学

论文标题:基于演化博弈视角的“乡贤” 参与乡村治理及其稳定性分析

视频可关注bilibili:谭小飞同学

% xiangxian.m
function dydt=xiangxian(t,y,a,p,c1,c2)
dydt=zeros(2,1);
dydt(1)=y(1)*(1-y(1))*(a*p*y(2)-c1);
dydt(2)=y(2)*(1-y(2))*((1-a)*p*y(1)-c2);
end
% xiangxian2.m
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%the 1st image
clc;clear;
a=0.6,p=1400,c1=500,c2=200;
figure(1)
% the 1st line
[t,y]=ode45(@(t,y) xiangxian(t,y,a,p,c1,c2),[0,0.1],[0.1,0.6]);
points=1:1:length(t);
plot(y(:,1),y(:,2),'rh-','linewidth',1,'markersize',5,'markerfacecolor','r','markerindices',points);
grid on
hold on 
set(gca,'XTick',[0:0.2:1],'YTick',[0:0.1:1])
axis([0 1 0 1])
% the 2nd line
[t,y]=ode45(@(t,y) xiangxian(t,y,a,p,c1,c2),[0,0.1],[0.3,0.5]);
points=1:1:length(t);
plot(y(:,1),y(:,2),'cx-','linewidth',1,'markersize',5,'markerindices',points);
hold on 
% the 3rd line
[t,y]=ode45(@(t,y) xiangxian(t,y,a,p,c1,c2),[0,0.1],[0.5,0.1]);
points=1:1:length(t);
plot(y(:,1),y(:,2),'bo-','linewidth',1,'markersize',5,'markerindices',points);
hold on 
% the 4th line
[t,y]=ode45(@(t,y) xiangxian(t,y,a,p,c1,c2),[0,0.1],[0.4,0.9]);
points=1:1:length(t);
plot(y(:,1),y(:,2),'gs-','linewidth',1,'markersize',6,'markerindices',points);
hold on 
% the 5th line
[t,y]=ode45(@(t,y) xiangxian(t,y,a,p,c1,c2),[0,0.1],[0.6,0.5]);
points=1:1:length(t);
plot(y(:,1),y(:,2),'md-','linewidth',1,'markersize',6,'markerindices',points);
hold on 
% the 6th line
[t,y]=ode45(@(t,y) xiangxian(t,y,a,p,c1,c2),[0,0.1],[0.9,0.3]);
points=1:1:length(t);
plot(y(:,1),y(:,2),'kp-','linewidth',1,'markersize',7,'markerfacecolor','k','markerindices',points);
hold on
xlabel('$x$','interpreter','latex','Rotation',0);
ylabel('$y$','interpreter','latex','Rotation',360);
title('动态演化过程','FontWeight','bold');
legend('初始值[0.1 0.6]','初始值[0.3 0.5]','初始值[0.5 0.1]','初始值[0.4 0.9]','初始值[0.6 0.5]','初始值[0.9 0.3]');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%the 2rd image
clc;
clear;
a=0.6,p=1450,c1=500,c2=200;
set(0,'defaultfigurecolor','w')
% the 1st X,Y
[t,y]=ode45(@(t,y) xiangxian(t,y,a,p,c1,c2),[0 0.1],[0.5 0.5]);
points=1:1:length(t);
figure(2)
plot(t,y(:,1),'ro-','linewidth',1,'markersize',4,'markerindices',points);
hold on 
plot(t,y(:,2),'g^-','linewidth',1,'markersize',5,'markerindices',points);
grid on
hold on 
set(gca,'XTick',[0:0.01:0.1],'YTick',[0.4:0.1:1.1])
axis([0 0.1 0.4 1.1])
% the 2nd X,Y
a=0.6,p=1600,c1=500,c2=200;
[t,y]=ode45(@(t,y) xiangxian(t,y,a,p,c1,c2),[0 0.1],[0.5 0.5]);
points=1:1:length(t);
plot(t,y(:,1),'c.-','linewidth',1,'markersize',10,'markerindices',points);
hold on 
plot(t,y(:,2),'b-.','linewidth',1,'markerindices',points);
hold on 
% the 3rd X,Y
a=0.6,p=1700,c1=500,c2=200;
[t,y]=ode45(@(t,y) xiangxian(t,y,a,p,c1,c2),[0 0.1],[0.5 0.5]);
points=1:1:length(t);
plot(t,y(:,1),'kx-','linewidth',1,'markersize',5,'markerindices',points);
hold on 
plot(t,y(:,2),'mp-','linewidth',1,'markersize',5,'markerfacecolor','m','markerindices',points);
hold on 
xlabel('$Time$','interpreter','latex','Rotation',0);
ylabel('$Solution$','interpreter','latex');
legend('X:P=1450','Y:P=1450','X:P=1600','Y:P=1600','X:P=1700','Y:P=1700');
上一篇下一篇

猜你喜欢

热点阅读