An error due to output function
Mostrar comentarios más antiguos
Hellow,
I am getting an error message which I did not expect (I explain why). I am solving an optimization problem. When I use fmincon no error appears. But, when I use patternsearch I get an error message, so this is really unexpected. The following are relevant parts of my code:
This works and I get no error message:
options=optimoptions('fmincon','OutputFcn',@(x,A,state)myoutput_Spline(x,A,state,dt,M),'StepTolerance',10^(-12),'FunctionTolerance',10^(-12),'MaxFunEvals',10^8,'MaxIter',10^8);
fmincon(cost,par0,[],[],[],[],lb,ub,[],options);
But this does not work and I get an error message:
options=optimoptions('patternsearch','UseParallel',UseParallel,'Display','iter','OutputFcn',@(x,A,state)myoutput_Spline(x,A,state,dt,M));
patternsearch(cost,par0,[],[],[],[],lb,ub,[],options)
Error using myoutput_Spline
Too many output arguments.
My output function is:
function stop = myoutput_Spline(x,A,state,dt,M)
stop = false;
if isequal(state,'iter')
par=x;
par(1:M)=x(1:M)./dt;
par(M+1:end)=x(M+1:end)./sqrt(dt);
disp('Estimated parameters : ');
disp(num2str(par));
disp(['Approximate value of objective function (negative of sum of log-likelihoods) : ' num2str(A.fval)]);
end
end
I have no idea what the hell is this!!!
Thanks for your help
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Solver Outputs and Iterative Display en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!