%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% FILE: esim_rryyr.m
%%
%% Luvun 2 Reijan ja Yrjon yhteisratkaisu eri w:n arvoilla kaytten funktiota
%% pmatriisi.
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Reijan ongelma ja skaalattu ratkaisu
c = 0.8;
RR = [  1    0    0;
        c    c    0;              
      1-c  1-c  1-c];
poR.psaanto = "kk";
poR.pmat = RR;
prR = pmatriisi(poR);
VR = prR.parvot;
VR = -VR;
VR = (VR-min(VR))/(max(VR)-min(VR));
      
%% Yrjon ongelma ja skaalattu ratkaisu
RY = [ 1   1   0   0;
       0   0   1   0;
       0   1   0   1];
p = [0.05  0.45  0.25  0.25]';
poY.psaanto = "oa";
poY.pmat = RY;
poY.tn = p;
prY = pmatriisi(poY);
VY = prY.parvot;
VY = (VY-min(VY))/(max(VY)-min(VY));

%% Yhteispaatos painoilla w = 1...0 (valityksella 0.1)
w = 1:-0.1:0';
for i=1:length(w)
   V(:,i) = w(i)*VR + (1-w(i))*VY; 
   [roskaa, yhtopt(i)] = max(V(:,i)'); 
end

%% Tiedoston ajo ja tuloste
%%>> esim_rryyr
%%>> yhtopt
%%yhtopt =
%%
%%   2   2   2   2   2   2   3   3   3   3   3