Failure in initial objective function evaluation. in fgoalattain
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi Guys
I got some problem to run this code:
funn = @(x,y,z)[(0.42305*x+0.043383*y+0.16814*z-0.78716).^2;(-0.631363873*x-0.258982921*y+0.501872413*z-0.338137333).^2;(-22.09773556*x+4.532201111*y-35.13106889*z+30.95699333).^2];
goal = [0,0,0];
weight = [1,1,1];
x0 = [1 1 1];
[x,fval,attainfactor,exitflag]= fgoalattain(funn,x0,goal,weight,[],[],[],[],[1 1 1],[1.1 1.1 1.1])
The error said that there is a failure in initial objective function evaluation.
Could anyone help me about this error? Much appreciated!
Best regards
Xu Li
댓글 수: 0
채택된 답변
Riccardo Scorretti
2022년 4월 13일
Hi Li,
the error is that funn requires three arguments, whereas fgoalattain needs a function with a single argument.
To fix the problem it is enough to rewrite x = x(1), y = x(2) and z = x(3):
% funn = @(x,y,z)[(0.42305*x+0.043383*y+0.16814*z-0.78716).^2;(-0.631363873*x-0.258982921*y+0.501872413*z-0.338137333).^2;(-22.09773556*x+4.532201111*y-35.13106889*z+30.95699333).^2];
funn = @(x)[(0.42305*x(1)+0.043383*x(2)+0.16814*x(3)-0.78716).^2;(-0.631363873*x(1)-0.258982921*x(2)+0.501872413*x(3)-0.338137333).^2;(-22.09773556*x(1)+4.532201111*x(2)-35.13106889*x(3)+30.95699333).^2];
goal = [0,0,0];
weight = [1,1,1];
x0 = [1 1 1];
[x,fval,attainfactor,exitflag]= fgoalattain(funn,x0,goal,weight,[],[],[],[],[1 1 1],[1.1 1.1 1.1])
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Multiobjective Optimization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!