How to Change Initial Number of Random Points in Genetic Algorithm?

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

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

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.
.
Shouldn't lower and upper bounds defined in problem structure constrain randi function so that it generates random parameter values only in that region?
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).
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.
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.

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!