function diff = calc_pi(pi,target,C_simul,L1_simul,L2_simul,T1_simul,T2_simul,E2_simul,kt_simul,U_simul_new,parameters,discfact,pre,kids,post)

U_simul_pi = calcU(C_simul*pi,L1_simul,L2_simul,T1_simul,T2_simul,E2_simul,kt_simul,parameters);
[U_simul_pi_disc,~,~,~,~,~]=calc_dc(U_simul_pi,U_simul_new,discfact,pre,kids,post);
diff = mean(U_simul_pi_disc(:))-target;

end

