⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 securitystratexample.m

📁 一个用MATLAB编写的优化控制工具箱
💻 M
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Example to illustrate security strategies%% Author: K. Passino% Version: 1/22/02%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%clear all% Set the number of different possible values of the decision variablesm=5; % If change will need to modify specific J1 value chosen belown=3; % Set the payoff matrix J1(i,j):%J1=round(10*rand(m,n)-5*ones(m,n)); % Make it random integers between -5 and +5J1 =[-3     4     4; % Just saved this from the screen for one case to get consistent values     0    -5     2;  % (comment this J1 out to get random payoff matrices, or to change n, m)     -2    1    -4;     2     3    -4;     2    -2    -5]% Compute the security strategy and value for each player, P1 then P2[maxvals,indexmax]=max(J1'); % This is the max value for each row (note transpose)maxvals' % Display the max values of each row[secvalP1,secstratP1]=min(maxvals) % Display the security value of P1 and its security strategy[minvals,indexmin]=min(J1); % This is the min value for each column (note no transpose)minvals % Display the min values of each column[secvalP2,secstratP2]=max(minvals) % Display the security value of P2 and its security strategy% The outcome of the game will begameoutcome=J1(secstratP1,secstratP2)% Plot the payoff values (clearly can just read the security value and strategy directly off % this plot by inspection)figure(1)clfsubplot(211)bar(1:m,J1)gridxlabel('Decision of player 1, i')title('(a) J^1(i,j), groups are payoffs for j=1,2,...,n')subplot(212)bar(1:n,J1')gridxlabel('Decision of player 2, j')title('(b) J^1(i,j), groups are payoffs for i=1,2,...,m')%-------------------------------------% End of program%-------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -