Error return from fmincon with Matlab 2019a
Show older comments
I am using the example in matlab documentation for fmincon. When I run this example I get the following error return. I also get this on my own problems.
fun = @(x)100*(x(2)-x(1)^2)^2 + (1-x(1))^2;
x0 = [-1,2];
A = [1,2];
b = 1;
x = fmincon(fun,x0,A,b)
Warning: Large-scale (trust region) method does not currently solve this type of problem,
switching to medium-scale (line search).
> In fmincon (line 213)
Reference to non-existent field 'OutputFcn'.
Error in optimget>optimgetfast (line 120)
if (isstring(defaultopt.(name)))
Error in optimget (line 31)
o = optimgetfast(options,name,default);
Error in nlconst (line 17)
outputfcn = optimget(OPTIONS,'OutputFcn',defaultopt,'fast');
Error in fmincon (line 459)
nlconst(funfcn,X,l,u,full(A),B,full(Aeq),Beq,confcn,options,defaultopt, ...
5 Comments
Walter Roberson
on 6 Oct 2019
You could probably work around the problem by providing an options structure, but I do not know at the moment why the problem is happening.
Thomas Harris
on 6 Oct 2019
Walter Roberson
on 6 Oct 2019
opts = optimset('fmincon', 'OutputFcn', {});
Aeq = []; beq = []; lb = []; ub = []; nlincon = [];
x = fmincon(fun, x0, A, b, Aeq, beq, lb, ub, nlincon, opts);
Sulaymon Eshkabilov
on 7 Oct 2019
Your code works in MATLAB 2017a and 2018b without any hassle. Maybe you'd need to restart your matlab. Good luck.
Matt J
on 7 Oct 2019
I've tested it in R2019a and also found that it runs without hassle.
I vaguely suspect that your are not running the code that you think you are. The error messages show that a nonlinear constraint function is being called, but your posted code does not pass a nonlinear constraint handle to fmincon.
Answers (0)
Categories
Find more on Problem-Based Optimization Setup 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!