Error "Your fitness function must return a scalar value"
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello everyone,
I'm trying to use ga algorithm optimization with non linear inequality constraints by applying penalty method.
But I have the error :
??? Error using ==> makeState at 56
Your fitness function must return a scalar value.
Error in ==> gaunc at 41
state = makeState
(GenomeLength,FitnessFcn,Iterate,output.problemtype,options);
Error in ==> ga at 279
[x,fval,exitFlag,output,population,scores] = gaunc(FitnessFcn,nvars, ...
Error in ==> ga_test at 55
[x_opt,fval_opt,exitflag_opt] = ga(ObjectiveFunction,nvars,[],[],[],[],
[],[],[],options)
for the following reason:
In fact, i need to apply a constraint which depends on values coming from excel table. This excel table contains 2 columns:
rows x1 y1
1 4.5 10
2 5.5 11
3 6.5 13
etc.
The fitness function has 6 variables. 2 of them (var1 and var2) have to respect the following condition:
var1/var2 = ratio : i have to find which value of x corresponds
to the ratio value,
so if var1/var2 = 5.6, so y1(find(x1 <= var1/var2, 1)) = y1(2) = 11
and this 11 value will be use into an equation which has to be
positive as a constrained condition.
if I'm not clear enough, example of constraint :
constr = ((y1(find(x1>=L./(x(2)./2), 1 ))).*E.*(x(1)./(x(2)./2)).^2);
with x(1) = var1 and x(2) = var2, L and E constant values.
Insofar as i ask matlab to optimize a function but some of its variables have to respect a condition with the use of excel database and the use of find function, i have the error message on above.
So I think because of the excel table, the constraint cannot make the fitness function scalar but I don't know how to fix it.
I hope you 've already met this kind of problem and hope you could help me for that.
Thank you!
1 commentaire
Réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!