Failure in initial objective function evaluation. in fgoalattain
3 views (last 30 days)
Show older comments
Li Xu
on 13 Apr 2022
Answered: Riccardo Scorretti
on 13 Apr 2022
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 Comments
Accepted Answer
Riccardo Scorretti
on 13 Apr 2022
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 Comments
More Answers (0)
See Also
Categories
Find more on Multiobjective Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!