How can I convert symbolic equation to fitness function which can be evaluated by genetic algorithm
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi,
I have a symbolic equation and wish to convert to a function which can be evaluated by genetic algorithm (ga). I have tried using the matlabFunction and convert the symbolic equation into a matlab file. However, this generated file can only be evaluated by fmincon or patternsearch algorithms and not genetic algorithm. I get this error using ga.
Caused by: Failure in initial user-supplied fitness function evaluation. GA cannot continue.
It seems like the matlabFunction does not generate the format required by ga, can anyone please advise what's the solution/workaround to this problem?
Thanks!
0 Commenti
Risposte (3)
Alan Weiss
il 22 Gen 2014
fmincon and patternsearch expect that the variable x is a column, though they are pretty forgiving if it is something else. ga expects that x is a row. So perhaps you should have
X = sym('x',[1 2*N]);
I could not check this because I do not know what P and price are.
Alan Weiss
MATLAB mathematical toolbox documentation
1 Commento
Ashley Thornton
il 20 Ago 2015
Thanks so much. I was having the exact same problem, your solution worked a treat.
Walter Roberson
il 21 Gen 2014
Please show symvars() of the symbolic expression, and show the call to matlabFunction that you used. Please also show the first bit of the generated function -- in particular, the part inside the @() header. Please show your call to ga()
0 Commenti
Vedere anche
Categorie
Scopri di più su Genetic Algorithm in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!