%Longin Jan Latecki, latecki@temple.edu, Oct 2012

function [z_UU]=ssl(PLL, PLU, PUL, PUU, True_LL)
% Initialize
%Y_L(row_i) = delta(yi), a Kronecker row.
% where i=1:l(=70) and yi=1:c(=70)
YL = [];
for i=1:length(True_LL)
    ind = find(ismember(True_LL, i, 'rows'));
    YL(ind,ind) = 1;     
end

% Initialize fu(ij) = 0.5[PUL*YL(ij)+1]
fu = 0.5*(PUL*YL + ones(1330,70));

% Iterating until f convergence when error < tolerance
tolerance = 0.2;
error = 10;
while (error >= tolerance)
    fu_temp = fu;
    fu = PUL*YL + PUU*fu;
    error = norm((fu - fu_temp), inf);
end

% z_UU(i)= argmax[fu(ij)] where i=t+1:t+u; j=1:c(=70)
[~, z_UU] = max(fu');
z_UU = z_UU';
