Failure in initial objective function evaluation. FMINCON cannot continue

1 view (last 30 days)
Hi!
Im trying to solve a optimization problem with non linear constraints using fmincon.
This is my function that I want to minimize:
F1 = @(x)L1'.*(x);
L1 is a previously defined vector.
This is how I use fmincon:
options = optimset('GradObj','off','GradConstr','off','Display','iter','Diagnostics','on');
A = [];
B = [];
Aeq = [];
Beq = [];
LB = [];
UB = [];
x = fmincon(@(x) F1(x,L1),X0,A,B,Aeq,Beq,LB,UB,@(x) mynonlcon(x,a,b,epsilon),options)
Where mynonlcon is a function file containing my non linear constraints c and ceq.
I get the error:
Error in fmincon (line 546)
initVals.f = feval(funfcn{3},X,varargin{:});
Error in HA3_test_2 (line 102)
x = fmincon(@(x) F1(x,L1),X0,A,B,Aeq,Beq,LB,UB,@(x) mynonlcon(x,a,b,epsilon),options)
Caused by:
Failure in initial objective function evaluation. FMINCON cannot continue.
So my question is, what am I doing wrong? I cant seem to get past this problem.
I've never used fmincon before so I basically have no idea what I need to do to figure this out.

Answers (1)

Matt J
Matt J on 21 May 2019
Test F1 on X0 before you give it to fmincon.
  2 Comments
Ni Ho
Ni Ho on 21 May 2019
I've tried it and it seems to be fine, it returns a vector like I want it to.
Matt J
Matt J on 21 May 2019
Edited: Matt J on 21 May 2019
fmincon expects the objective function to return a scalar. Is this supposed to be a least squares minimization? If so, then you must sum the squares yourself explicitly.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!