function [ztrata u y b P]=ce(regulator_parameters,system,apriori,seed)
eps=0.01;
horizont=regulator_parameters.horizont;

y=zeros(1,horizont);
b=zeros(1,horizont-1);
P=zeros(1,horizont-1);
u=zeros(1,horizont-1);
ztrata=0;

y(1)=apriori(1);
b(1)=apriori(2);
P(1)=apriori(3);

for i=1:horizont-1
    if abs(b(i))<eps
        u(i)=randn;
    else
        u(i)=-y(i)/b(i);
    end
    [y(i+1) b(i+1) P(i+1)]=get_next([y(i) b(i) P(i)],u(i),system,seed(i));
    ztrata=ztrata+y(i+1)^2;
end

end

