How can I convert symbolic equation to fitness function which can be evaluated by genetic algorithm
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (3)
Alan Weiss
el 22 de En. de 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 comentario
Ashley Thornton
el 20 de Ag. de 2015
Thanks so much. I was having the exact same problem, your solution worked a treat.
Walter Roberson
el 21 de En. de 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 comentarios
Ver también
Categorías
Más información sobre Genetic Algorithm en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!