Genetic Algorithm (Plot Function)
6 views (last 30 days)
Show older comments
Hi,
I set up an genetic algorithm for running a curve fitting process in order to identify the parameters (a,b,c) of a model equation. The model equation should later predict the experimental data depending on variables (x,y,z).
I used the sum of squares as my objective function:
sse = sum(power(ExperimentalData - ModelOutput,2));
Now I like to observe the actual function (ModelOutput) whiles the algorithm runs using the parameters (design variables) which the algorithm finds at each iteration.
Can someone help me to create such a Plot function which I could include in the GA options (gaoptimset)? I don`t really know which values are availible during the iterations and how I can access them. My initial idea was just to create a function file which includes my model function. This function file gets the parameters plus a range for the variables x,y,z (eg. x =[0:0.001:5]; y =[0:0.001:2]; z =[0:0.001:7])
and the experimental data as an input in order to visualize how the model prediction would look like compared to the experimental data.
How could a solution look like?
I´m looking forward to somebody helping me out with this problem.
Best regards Joe
Answers (1)
Cam Salzberger
on 1 Mar 2016
Hello Joe,
I understand that you are looking to plot the current output of the model as the genetic algorithm is running. I believe that you will find the 'PlotFcns' property, that can be set with "gaoptimset", to be the most useful. There are a variety of built-in plotting functions. Of them, I believe that the "Best individual" function (@gaplotbestindiv) is what you would like to see. You can also create a custom function, and pass its handle to that property. Custom functions should match the format shown here.
I hope this helps!
-Cam
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!