%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Example to illustrate security strategies % % Author: K. Passino % Version: 1/22/02 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all % Set the number of different possible values of the decision variables m=5; % If change will need to modify specific J1 value chosen below n=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 +5 J1 =[-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 be gameoutcome=J1(secstratP1,secstratP2) % Plot the payoff values (clearly can just read the security value and strategy directly off % this plot by inspection) figure(1) clf subplot(211) bar(1:m,J1) grid xlabel('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') grid xlabel('Decision of player 2, j') title('(b) J^1(i,j), groups are payoffs for i=1,2,...,m') %------------------------------------- % End of program %-------------------------------------