function [H,u, loss]=ce(regulator_parameters,system,apriori)
eps=1;

horizont=regulator_parameters.horizont;

H=zeros(horizont+1,system.dim); % stavy na ridicim horizontu - kazdy bod ma souradnice (y, b, P)
u=zeros(1,horizont+1);    %u(0)nema smysl
loss=0;

H(1,1)=apriori.y0;
H(1,2)=apriori.b0;
H(1,3)=apriori.P0;

for i=2:horizont
    if (H(i-1,2)==0)
        u(i)=(system.yr(i)-H(i-1,1))/eps;
    else
        u(i)=(system.yr(i)-H(i-1,1))/H(i-1,2);
    end
    H(i,:)=get_next(H(i-1,:),u(i),system);
    loss=loss+(H(i,1)-system.yr(i))^2;
end

end

