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

1 次查看(过去 30 天)
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/MATLAB_R2011b.app/toolbox/optim/optim/barrier.p>barrier
(line 636)
Error in fmincon (line 841)
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] =
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/MATLAB_R2011a.app/toolbox/optim/optim/barrier.p>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.

回答(1 个)

Walter Roberson
Walter Roberson 2012-9-20
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.

类别

Help CenterFile Exchange 中查找有关 Problem-Based Optimization Setup 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by