필터 지우기
필터 지우기

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

채택된 답변

Riccardo Scorretti
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])
Local minimum possible. Constraints satisfied. fgoalattain stopped because the size of the current search direction is less than twice the value of the step size tolerance and constraints are satisfied to within the value of the constraint tolerance.
x = 1×3
1.0000 1.1000 1.0000
fval = 3×1
0.0220 0.5663 453.1104
attainfactor = 453.1104
exitflag = 4

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multiobjective Optimization에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by