Info
This question is closed. Reopen it to edit or answer.
Error with Fmicon objective function
2 views (last 30 days)
Show older comments
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 Comment
Torsten
on 6 Feb 2018
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.
Answers (0)
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!