Apply Fmincon with GlobalSearch to OptimProblem with anonymous function
4 views (last 30 days)
Show older comments
I am trying to create an optimization problem structure by passing a function handle (@myfun) from the parent to the createOptimProblem method.
function [new_params,gof] = parent(fnHndl,params, lb, ub, varargin)
options = optimset;
options.GradObj = 'off';
options.Hessian = 'lbfgs';
options.Display = 'off';
options.StepTolerance = 10^(-6);
problem = createOptimProblem('fmincon','objective', ...
@(x) fnHndl(x,varargin{:}), ...
'x0', params, 'lb', lb,'ub', ub,'options',options);
gs = GlobalSearch();
[new_params,gof] = run(gs, problem);
end
GlobalSearch() is then used to find lowest objective function value – however, GlobalSearch() never terminates.
On the other hand, not using the parent wrapper function and creating the problem hard-coding the functions name, GlobalSearch finds a solution.
problem = createOptimProblem('fmincon','objective',@(x) myfun(x,varagin{:}), 'x0', params, 'lb', lb,'ub', ub,'options',options);
gs = GlobalSearch();
[new_Params, optimized_GoF] = run(gs, problem);
I cannot precisly say, what is causing the problem and would be thankful for your insight or a suggestion for a workaround.
2 Comments
Answers (0)
See Also
Categories
Find more on Surrogate Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!