function [out_arg]=ObjectiveFun(PG,PG0,PGi,PD,PD0,wG,wD) t1=PG(PGi)-PG0(PGi); t2=wG.*t1.*t1; t3=wD.*((PD-PD0).*(PD-PD0)); out_arg= sum(t2)+sum(t3); end