Run 1
Run 1
The perturbed objective function is stochastic and not smooth. fmincon is a general constrained
optimization solver which finds a local minimum using derivatives of the objective function. If
you do not provide the first derivatives of the objective function, fmincon uses finite differences
to approximate the derivatives. In this example, the objective function is random, so finite
difference estimates derivatives hence can be unreliable. fmincon can potentially stop at a point
that is not a minimum. This may happen because the optimal conditions seems to be satisfied at
the final point because of noise, or fmincon could not make further progress.
Get
[Xop,Fop] = fmincon(Objfcn,X0,[],[],[],[],LB,UB,[],options)
First-order Norm of
Iter F-count f(x) Feasibility optimality step
0 3 -1.925772e+01 0.000e+00 2.126e+08
1 6 -7.107849e+01 0.000e+00 2.623e+08 8.873e+00
2 11 -8.055890e+01 0.000e+00 2.401e+08 6.715e-01
3 20 -8.325315e+01 0.000e+00 7.348e+07 3.047e-01
4 48 -8.366302e+01 0.000e+00 1.762e+08 1.593e-07
5 64 -8.591081e+01 0.000e+00 1.569e+08 3.111e-10
fmincon stopped because the size of the current step is less than
the value of the step size tolerance and constraints are
satisfied to within the value of the constraint tolerance.
Xop = 1×2
-4.9628 2.6673
Fop =
-85.9108
Get
figure(fig);
hold on;
ph = [];
ph(1) = plot3(X0(1),X0(2),Objfcn(X0)+30,'or','MarkerSize',10,'MarkerFaceColor','r');
ph(2) = plot3(Xop(1),Xop(2),Fop,'dm','MarkerSize',10,'MarkerFaceColor','m');
% Add legend to plot
legendLabels = {'Start point','|fmincon| solution'};
lh = legend(ph,legendLabels,'Location','SouthEast');
lp = lh.Position;
lh.Position = [1-lp(3)-0.005 0.005 lp(3) lp(4)];
hold off;