function [f,g,hh]=target_function(tuning,Q,q,constant,data,index)



if index==1
alpha=tuning(1);    
q1=q(1)*tuning(2);
q2=q(2)*tuning(3);
Sor=tuning2(1);
k=tuning2(2);
else
alpha=tuning2(1);    
q1=q(1)*tuning2(2);
q2=q(2)*tuning2(3);
Sor=tuning(1);
k=tuning(2);    
end

w=[Sor k alpha f1 f2];

[sim_t,Ca,Cb,Cc]=SolvePDE(w, Q, q, constant);

Ca_1=interp1(sim_t,Ca,data(:,1));
Cb_1=interp1(sim_t,Cb,data(:,1));
Cc_1=interp1(sim_t,Cc,data(:,1));


if index==1
 f=nansum((Ca_1-data(:,2)/CA_0).^2)+nansum((Cc_1-data(:,4)/CA_0).^2);
else
 f=nansum((Cb_1-data(:,3)/CA_0).^2);
end




end




