Failure in initial objective function evaluation. FMINCON cannot continue

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.

답변 (1개)

Matt J
Matt J 2019년 5월 21일

0 개 추천

Test F1 on X0 before you give it to fmincon.

댓글 수: 2

I've tried it and it seems to be fine, it returns a vector like I want it to.
Matt J
Matt J 2019년 5월 21일
편집: Matt J 2019년 5월 21일
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.

댓글을 달려면 로그인하십시오.

카테고리

질문:

2019년 5월 21일

편집:

2019년 5월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by