📄 nashequilibria.m
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Example to illustrate computation of Nash equilibria of% finite two player nonzero sum "bimatrix" games. If you run% the program multiple times, with the J1 and J2 definition lines % appropriately commented out below, you can see cases where there are% zero, one, or more than one Nash equilibrium. Now, the program% provides one example where there are two Nash solutions.%% Author: K. Passino% Version: 2/2/02%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%clear all% Set the number of different possible values of the decision variablesm=5; % If change will need to modify specific J1, J2 value chosen belown=3; % Set the payoff matrices J1(i,j) and J2(i,j):%J1=round(10*rand(m,n)-5*ones(m,n)) % Make it random integers between -5 and +5%J2=round(10*rand(m,n)-5*ones(m,n)) % Make it random integers between -5 and +5% One set of payoff matrices that gives two Nash equilibria:J1 =[-1 5 -3; -2 5 1; 4 3 -2; -5 -1 5; 3 0 2]J2 =[-1 2 -3; 2 -3 1; -2 3 1; -1 1 -1; 4 -4 1]% Compute the Nash equilibria:flag=0; % Flag for saying if there is no Nash equilibriafor i=1:m for j=1:n if J1(i,j)<=min(J1(:,j)) & J2(i,j)<=min(J2(i,:)), % Conduct two inequality tests display('Nash equilibrium and outcome:') % If satisfied, then diplay solution i j J1(i,j) J2(i,j) flag=1; % Indicates that there was one Nash equilibrium (or more) end endendif flag==0 display('There were no Nash equilibria')end%-------------------------------------% End of program%-------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -