How to Change Initial Number of Random Points in Genetic Algorithm?
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
0 votes
I need to increase initial number of parameter value combinations for GA to increase likelihood to find the best solution. How to change this setting?
Accepted Answer
Star Strider
on 4 Feb 2022
Create an options structure using optimoptions, and define 'InitialPopulationMatrix' to the correct dimensions for your problem.
For example, I use this to start with —
PopSz = 500;
Parms = 10;
opts = optimoptions('ga', 'PopulationSize',PopSz, 'InitialPopulationMatrix',randi(1E+4,PopSz,Parms)*1E-3, 'MaxGenerations',2E3, 'FunctionTolerance',1E-8, 'PlotFcn',@gaplotbestf, 'PlotInterval',1);
where ‘PopSz’ are the number of individuals, and ‘Parms’ are the number of parameters. After that, create the initial poulation matrix however you like. (My code here is only an example.) If the optimisation proceeds too slowly, I reduce ‘PopSz’ to 100 and then re-start the optimisation.
.
6 Comments
Dario Miric
on 4 Feb 2022
Thank you.
So, InitialPopulationMatrix defines initial number of parameter value combinations?
In my case I am not too concerned about what values parameters have initially, so random values are okay if they are constrained to certain upper and lower bounds defined in problem structure.
My pleasure!
‘So, InitialPopulationMatrix defines initial number of parameter value combinations?’
Yes. It can be compeltely random, as in my example, or the magnitudes of the individual parameters can be scaled to provide a better initial approximation. So for example, if the first parameter needs to be defined as multiples of 100 , the second by 10, and the third by 1, it could be defined as:
IPM = randi(1E+3, 5, 3)
IPM = 5×3
43 684 395
616 810 576
605 515 295
273 1 29
612 151 775
IMPscaled = IPM .* [1.0 0.1 0.01]
IMPscaled = 5×3
43.0000 68.4000 3.9500
616.0000 81.0000 5.7600
605.0000 51.5000 2.9500
273.0000 0.1000 0.2900
612.0000 15.1000 7.7500
‘In my case I am not too concerned about what values parameters have initially, so random values are okay if they are constrained to certain upper and lower bounds defined in problem structure.’
They can be constrained easily with respect to the randi function (see the imax and imin arguments), although that could require concatenating several randi calls producing (Nx1) vectors into a single matrix, since it allows for such range constraints for the entire array it returns, and with a bit more coding for other random number generator results as well.
.
Dario Miric
on 4 Feb 2022
Shouldn't lower and upper bounds defined in problem structure constrain randi function so that it generates random parameter values only in that region?
Star Strider
on 4 Feb 2022
The bounds defined in the problem structure are not shared with randi. Looking again through the ga documentation, it does not appear that the initial values are specifically constrained with respect to the bounds in the problem structure in the initial population matrix that ga produces by default if the matrix is not specifically defined in the optimoptions structure. They likely sort themselves out quickly once the optimisation starts, since the individuals violating the constraints are not retained in the population. Using randi calls to bound them initially may enhance the efficiency of the algorithm, however random mutations and such may initially be outside the set bounds. I am not certain if ga checks those before using them.
Most of the problems I use ga for are kinetic parameter estimation problems, so all the values are positive (not a problem with the randi call I use and posted as an example) and differ only with respect to magnitude scaling. I define the lower bounds as zeros and the upper bounds as either Inf or 1 since the kinetic parameters are generally limited to be bounded on [0,1] and the other concentrations can take on any reasonable positive value (at least in my simulaitons).
Dario Miric
on 5 Feb 2022
Edited: Dario Miric
on 5 Feb 2022
Yes, thank you. Are you a chemist or chemical engineer since you mention kinetics and concentrations? If so, I am using GA for NRTL and UNIQUAC activity coefficient model parameters optimization.
Star Strider
on 5 Feb 2022
As always, my pleasure!
Guilty of the first (undergraduate major), not of the second. (My M.S. is in Biomedical Engineering.) A lot of my activities in this area are summarised in this search.
‘I am using GA for NRTL and UNIQUAC activity coefficient model parameters optimization.’
My apologies, however I do not understand those acronyms.
See for example Parameter Estimation for a System of Differential Equations for one approach to using ga to solve kinetics problems, in this instance a relatively small and straightforward one with an abundance of data. (I checked first to be sure that it has the latest version of the relevant code.) I can generally get ga to converge on a decent set of parameters. The problems arise when the differential equations do not appropriately describe (are the wrong model for) the data.
I have some experience in this area, so if you encounter problems, I might be able to provide solutions. I will at least give them my best effort.
More Answers (0)
Categories
Find more on Problem-Based Optimization Setup in Help Center and File Exchange
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)