Info

此问题已关闭。 请重新打开它进行编辑或回答。

Error with Fmicon objective function

2 次查看(过去 30 天)
Nikolas Spiliopoulos
关闭: MATLAB Answer Bot 2021-8-20
Hi all,
I am trying to run a non linear optimization with fmincon, I have set the equality and inequality constraints but I am struggling with the objective function. The constraints (for example Aeq)is a matrix of 5 X 5397. So I wanna have an objective function for each row, something like:
F(x)=x(1:2700,1)+x(2701:5397,1)
I tried this:
f=@(x) x(1:2700,1)+x(2701:5397,1);
x0=0.001;
x = fmincon(f,x0,A(:,1),b,Aeq(:,1),beq,lb,ub);
However I am getting errors like:
"initVals.f = feval(funfcn{3},X,varargin{:});"
AND
"Failure in initial objective function evaluation. FMINCON cannot continue"
Does anybody have any idea how to overcome this?
thanks in advance
Nikolas
  1 个评论
Torsten
Torsten 2018-2-6
1. The objective function must return a scalar value, not a vector.
2. You give an initial value of 0.001 to x0. Thus you only have one scalar variable to optimize. In this case, your A and Aeq have to be matrices of size n x 1, not n x 5397.
You should again write down your optimization problem and study how fmincon can be used to solve it.
Best wishes
Torsten.

回答(0 个)

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by