Getting error while plotting best fitness, so how do I solve this issue or is there any alternative way to plot it (I am using Genetic Algorithm from Optimization Toolbox)?
1 view (last 30 days)
Show older comments
I have used Genetic Algorithm for finding gains of PI controllers. For that purpose Optimization toolbox is used and GA is used as solver.
The optimization and everything seems to run well, but when I try to plot Best Fitness Function while running iterations, it throws following error :
-----------------------------------------------------------------------------------------------
Optimization Running.
Warning: Imaginary parts of complex X and/or Y arguments ignored
Errorrunning optimization.
Complex values are not supported.
-----------------------------------------------------------------------------------------------
And when Best Fitness function plot is not selected, the algorithm runs smoothly without any problem.
For my project I need Best Fitness function plot ? So how do I resolve this error or plot them alternatively.
Screenshot for both the cases is attached...
Any Help is Appreciated...
Thanks & Regards
Sanjeev Gupta
0 Comments
Answers (1)
Star Strider
on 8 Mar 2021
That plots the output of your fitness function, and I find it interesting that complex results even work in that context.
I have no idea what your fitness function does, however if it is calculating the square root of a negative number or taking the logarithm of a negative number, or something similar, it would likely be best to constrain the parameters (or do whatever else may be necessary) to avoid those, to be certain that it is not generating complex results.
The algorithm may run smoothly, however it may not be doing what you want it to do.
0 Comments
See Also
Categories
Find more on Genetic Algorithm 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!