Here is my function, in order to shorten the expression here I add A and B, but in my original function they are inside F(1) and F(2) (i.e. that is not the problem), this is the error I get: Objective function is returning undefined values at initial point.
function F = myfun(x)N=32;K=5;s=1;b=0.1;P=5;A=-2*s^4*x(1)*N+2*s^4*x(1)*K+3*s^2*x(2)*log(2);B=sqrt(8)*x(2)*s^2*log(2);g=exprnd(1,1,N-K); F(1) = sum((g.*(1-b*x(1))/(x(2)*log(2)))-1./g)+(N-K)*((A+sqrt(A^2-B^2))/((4*s^2/sqrt(8))*B))-N*P;F(2) = b*(sum(log2((g*(1-b*x(1)/x(2)*log(2))))))-(N-K)*log2(1+(2*A^2+2*A*sqrt(A^2-B^2)-B^2)/((4/sqrt(8))*B*(A+(4/sqrt(8))*B+sqrt(A^2-B^2))));end
Best Answer