Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
Error with Fmicon objective function
조회 수: 2 (최근 30일)
이전 댓글 표시
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
Torsten
2018년 2월 6일
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.
답변 (0개)
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!