# Genetic Algorithm starting population with integer valued variables

13 views (last 30 days)
Reed Teyber on 22 Nov 2016
Answered: Reed Teyber on 22 Nov 2016
Hello All,
I am using the genetic algorithm for a design optimization with 49 integer-valued variables which can take values from 1->6. Each function iteration calls a Comsol multiphysics simulation and takes about 2 seconds.
I know of about 10 good designs (i.e. sets of the 49 variables) and I am hoping to somehow include these in my initial population. Right now, it takes about two days before the population starts to "hone in" on good performance and another two days before the performance exceeds one of these 10 designs. It would be really fantastic if I could start from "simple designs" and iterate from here.
From what I read, its not possible to "seed" the initial population when you are using integer valued variables. Is this correct? Are there other optimization algorithms which you guys recommend for this, even looking into the python scipy packages?
Right now, the most logical solution is to use an optimization method that allows a seed or initial population definition (ga, sim. annealing, particle swarm,...) and round each variable to the nearest integer, but I fear there are some consequences with this approach.
Reed

Alan Weiss on 22 Nov 2016
I don't know why you think that you cannot put in some initial points to help start the optimization. The documentation for ga does not mention any limitation in that respect.
Alan Weiss
MATLAB mathematical toolbox documentation

Walter Roberson on 22 Nov 2016
Do not tell ga that you are using integer constraints. Instead, provide custom functions for initial population, and for crossover, and mutation. See the initial population as you see fit, and make sure the other members you generate fit the integer constraints. Adjust the crossover and mutation functions to only generate integer values.

Reed Teyber on 22 Nov 2016
Thank you both for the very prompt responses!
I had assumed that you could not do this from the quote below, but you are correct. The following worked beautifully!
opts = optimoptions('ga','InitialPopulationMatrix',x0,....
where x0 is a matrix containing my known solutions.
_"Creation function (CreationFcn) specifies the function that creates the initial population for ga. Do not specify a creation function with integer problems because ga overrides any choice you make. http://www.mathworks.com/help/gads/genetic-algorithm-options.html#f14223"_

### Community Treasure Hunt

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

Start Hunting!

Translated by