Error return from fmincon with Matlab 2019a

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

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.
Hello - I have tried this, but I couldn't get this to work - that doesn't mean that someone else couldn't. I traced through code to find specific point. It occurs when the set up for optimizer tries to find the OutputFcn in the default options. When I examine the default options, it doesn't have OutputFcn as one of the structured elements. I put this in as part of the structured array as [ ] (no space). This didn't work, so I took this out.
Thank y ou
opts = optimset('fmincon', 'OutputFcn', {});
Aeq = []; beq = []; lb = []; ub = []; nlincon = [];
x = fmincon(fun, x0, A, b, Aeq, beq, lb, ub, nlincon, opts);
Your code works in MATLAB 2017a and 2018b without any hassle. Maybe you'd need to restart your matlab. Good luck.
Matt J
Matt J 2019년 10월 7일
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.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Problem-Based Optimization Setup에 대해 자세히 알아보기

제품

릴리스

R2019a

질문:

2019년 10월 6일

댓글:

2019년 10월 7일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by