Setting options in fmincon
18 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Seems like a simple question, but I have tried all kinds of variants and nothing works. The documanetation on this stinks. All kinds of examples given that give errors.
I just want to lower the optimality tolerance, because my fmincon is not finding the minimum (which is zero) even though its getting to within the default OptimalityTolerance. I need it closer to zero than that. I will probably need to do the same with the StepTolerance.
I have tried using OptimalityTolerance instead of TolFun as well. Neither works.
If I run this as below, and then do a optimoptions('fmincon') at the command line the OptimalityTolerance stays at 1e-6 and my results are no different no matter what I use.
x0=log(1e-20)*ones(5,1)'; lb=log(1e-20)*ones(5,1)'; ub=log(1e-10)*ones(5,1)';
fun = @(x)abs(log(A)-log(cosT)+log(alp(1))+x(1)+log(sum(exp(x-x(1)+log(alp)-log(alp(1)))))-log(ro3^(-5/3)));
options = optimoptions(@fmincon,'TolFun',1e-7);
[x,fval] = fmincon(fun,x0,[],[],[],[],lb,ub,[],options)
optimoptions('fmincon')
0 comentarios
Respuestas (2)
Fabio Freschi
el 23 de Sept. de 2019
TolFun is to be used with optimset. With optimoptions use OptimalityTolerance
opts = optimoptions('fmincon','OptimalityTolerance',1e-12);
0 comentarios
Matt J
el 23 de Sept. de 2019
Editada: Matt J
el 23 de Sept. de 2019
If I run this as below, and then do a optimoptions('fmincon') at the command line the OptimalityTolerance stays at 1e-6 and my results are no different no matter what I use.
Doing optimoptions('fmincon') at the command line does not give any information about what settings were used in a previous optimization. It will just display the default fmincon settings at the command line. The real option settings seen by fmincon are those contained in the options object which you created and passed to fmincon. Those settings were correctly made:
>> options
options =
fmincon options:
Options used by current Algorithm ('interior-point'):
(Other available algorithms: 'active-set', 'sqp', 'sqp-legacy', 'trust-region-reflective')
Set properties:
OptimalityTolerance: 1.0000e-07
Default properties:
Algorithm: 'interior-point'
CheckGradients: 0
ConstraintTolerance: 1.0000e-06
Display: 'final'
FiniteDifferenceStepSize: 'sqrt(eps)'
FiniteDifferenceType: 'forward'
HessianApproximation: 'bfgs'
HessianFcn: []
HessianMultiplyFcn: []
HonorBounds: 1
MaxFunctionEvaluations: 3000
MaxIterations: 1000
ObjectiveLimit: -1.0000e+20
OutputFcn: []
PlotFcn: []
ScaleProblem: 0
SpecifyConstraintGradient: 0
SpecifyObjectiveGradient: 0
StepTolerance: 1.0000e-10
SubproblemAlgorithm: 'factorization'
TypicalX: 'ones(numberOfVariables,1)'
UseParallel: 0
As for why your results are not changing, we cannot see what is happening because you have not provided enough of the input variables to run the code. However, it may be that another stopping criterion was reached before the OptimalityTolerance criterion.
You should also be mindful that the OptimalityTolerance is not a way of specifying the distance from the minimum value that you would like the algorithm to stop. No option setting can specify that directly. The OptimalityTolerance sets a tolerance on the first order optimality measure as described here,
6 comentarios
Matt J
el 24 de Sept. de 2019
Editada: Matt J
el 24 de Sept. de 2019
Yes, fmincon will search for the 5-dimensional minimum (up to any constraints you specify, of course).
The plot of L(t) is deliberately a restriction of your 5-dimensional objective function to a 1-dimensional cross-sectional line passing through x and xtrue: one-dimensional plots are easier to visualize than 5-dimensional plots. The point was just to show that x and xtrue lie in different basins of the graph of your objective function. Because of the initial guess that you chose, fmincon is caught in the basin of x and cannot reach xtrue. Changing the optimoptions will not help with that.
Also, the plot further demonstrates that your objective has no derivative at either minima. That is likely why fmincon is having trouble converging to better than 1e-7.
Ver también
Categorías
Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!