MATLAB 'fminunc' scenarios to converge on my optimization solution with complex constraints in R2023b
I'm stuck trying to I'm working on a personal project and I'm currently trying to optimize a function using MATLAB's `fminunc` in R2023b, but I'm working with issues with convergence when I add certain constraints... The function I'm trying to minimize is non-linear and depends on a set of parameters that should remain within specific bounds. I've set the optimization options like this: ```matlab options = optimoptions('fminunc', 'Algorithm', 'quasi-newton', 'Display', 'iter', 'TolFun', 1e-6); ``` However, when I run the optimization, I often get the following warning message: ``` Warning: Maximum number of function evaluations has been exceeded. ``` I've also tried adjusting the `MaxIter` and `MaxFunEvals` options, but increasing these values only prolongs the process without improving convergence. Hereβs a simplified version of my objective function: ```matlab function f = myObjectiveFunction(x) % Example non-linear function f = (x(1) - 2)^2 + (x(2) - 3)^2 + sin(x(1) * x(2)); end ``` And I call `fminunc` like this: ```matlab x0 = [0, 0]; % Initial guess [x_opt, fval, exitflag] = fminunc(@myObjectiveFunction, x0, options); ``` I suspect that the non-linearity of the function combined with the lack of proper constraints might be causing the optimizer to struggle. I've also considered switching to `fmincon`, but I need to maintain the structure of my current implementation. Any insights on how to approach this or potential fixes would be greatly appreciated! I'd love to hear your thoughts on this. I'm working with Matlab in a Docker container on Windows 10. Thanks for any help you can provide!