Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Error with Fmicon objective function

1 vue (au cours des 30 derniers jours)
Nikolas Spiliopoulos
Nikolas Spiliopoulos le 6 Fév 2018
Clôturé : MATLAB Answer Bot le 20 Août 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 commentaire
Torsten
Torsten le 6 Fév 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.

Réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by