Failure in initial objective function evaluation. in fgoalattain
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Li Xu
le 13 Avr 2022
Réponse apportée : Riccardo Scorretti
le 13 Avr 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 commentaires
Réponse acceptée
Riccardo Scorretti
le 13 Avr 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Get Started with Optimization Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!