Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

Error with Fmicon objective function

1 visualizzazione (ultimi 30 giorni)
Nikolas Spiliopoulos
Nikolas Spiliopoulos il 6 Feb 2018
Chiuso: MATLAB Answer Bot il 20 Ago 2021
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 Commento
Torsten
Torsten il 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.

Risposte (0)

Questa domanda è chiusa.

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by