MATLAB Answers

optim/barrier.p "Matrix dimensions must agree" error

4 views (last 30 days)
Il on 20 Sep 2012
I'm using `fmincon', and getting a weird error. My function is defined on [0,inf) x [0,1), and I return inf outside of the range. I have also imposed inequality constraints to enforce it. Here's my optimization parameter:
options = optimset('Algorithm', 'interior-point', 'Display', 'off', 'GradObj', 'off', 'TolX', 1e-10, 'TolFun', 1e-10);
The optimization works for most cases, but very rarely, it would give a mysterious error. In MATLAB 2011b, it gives,
Error using -
Matrix dimensions must agree.
Error in /Applications/>barrier
(line 636)
Error in fmincon (line 841)
barrier(funfcn,X,A,B,Aeq,Beq,l,u,confcn,options.HessFcn, ...
In MATLAB 2011a, it gives,
??? Error using ==> minus
Matrix dimensions must agree.
Error in ==> /Applications/>barrier at 624
Error in ==> fmincon at 822
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = barrier(funfcn,X,A,B,Aeq,Beq,l,u,confcn,options_ip.HessFcn, ...
Since the error is within a precompiled function, I cannot figure out what is going on. I searched the internet for similar situation, but I couldn't find anything relevant.
Any hints?
In the mean while, I'm trying to isolate the objective function for ease of replication.

Answers (1)

Walter Roberson
Walter Roberson on 20 Sep 2012
It is not at all well documented, but what is there implies that you cannot return inf as a function value.
Look way down in the documentation at the FunValCheck option description:
Check whether objective function and constraints values are valid. 'on' displays an error when the objective function or constraints return a value that is complex, Inf, or NaN. The default, 'off', displays no error.

Community Treasure Hunt

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

Start Hunting!