I'm trying to optimize a problem of engine performance using a external function 'finter' (external deck - executable). That function works properly as I have checked it many times.
My objective function is as follows:
ys1 = [-1.60742937984057;-1.75941194993574;-1.52016066840023;-1.38821355190586;-1.26737524545974;-1.11748814435432;-0.968998107063983;-1.31351767471495;-1.48990020304618;-1.29056672044894];
ys2 = [-0.218867980285718;-0.146046874197578;-0.0918019106772645;-0.0117144187008822;0.101770383589507;0.238687435338204;0.389060531152024;0.0547756208261101;-0.0687671839852227;0.0390575624990874];
m = sqrt(((norm(y1-ys1))^2)+((norm(y2-ys2))^2));
I have only as constraints the following conditions:
a) The solution must count with all the components (the solution X counts with 10 components) in between 0 and 2. That's whay my UB and LB are as follows:
LB = [0;0;0;0;0;0;0;0;0;0]
UB = [2;2;2;2;2;2;2;2;2;2]
b) The components must be positive always. That's why my non-linear constraint function is as follows:
function [c,ceq] = nonlcon(x)
The initial point I use for the iterations is the following:
X0 = [0.0650000000000000; 1.12240000000000; 1.76370000000000; 1.33840000000000; 0.380900000000000; 0.737800000000000; 1.96330000000000; 1.96330000000000; 0.312800000000000; 1.71100000000000]
It is interesting that, when I select the option "approximate by solver" in the derivatives, the tool starts the optimization. Finally it says that the initial point given is a good solution:
Objective function value: 1.6591997092884727
Initial point is a local minimum that satisfies the constraints.
Optimization completed because at the initial point, the objective function is non-decreasing
in feasible directions to within the value of the optimality tolerance, and
constraints are satisfied to within the value of the constraint tolerance.
Obviously, that is not a valid answer because I know the solution of the problem is as follows:
Xsolv = [0.602900000000000; 1.40220000000000; 1.33270000000000; 1.07830000000000; 1.39620000000000; 1.33310000000000; 0.356300000000000; 0.256000000000000; 1.99820000000000; 0.342200000000000]
But, at least, the progam starts doing something.
With the "gradient" option in the derivatives the tool finds this problem:
Error running optimization.
Too many output arguments.
Any idea on where the issue may be?
My problem is quite dependant on the function. I know that some colleague has used the gradient succesfully in this very same problem and, frankly speaking, it seems the SQP-gradient seems to be the right approach here, but 'm not capable to make it work so far.