luca-scr / GA

An R package for optimization using genetic algorithms
http://luca-scr.github.io/GA/
91 stars 29 forks source link

Non-uniform distribution over Initial Population #14

Closed chuymtz closed 6 years ago

chuymtz commented 6 years ago

I have a situation where I know from context I should start my initial population close to a certain point. So using the DEoptim package I can specify a truncated normal distribution instead of uniform for my initial population. Unfortunately, the problem is a constrained opt problem. Your package can handle this better. But i cant find a clear example to specify the initial population I desire.

My function has over 200 variables and so can't afford to waste time away from my guess.

So is there a way to specify an initial population?

I tried by accessing the gaControl() but I don't understand how to modify it.

Many thanks,

luca-scr commented 6 years ago

You have two options:

1) provide to the optional argument suggestions a matrix of popSize x numVariables where each row is an initial solution 2) define your own function to initialise the population and then provide it through the argument population. If you are using the version from GitHub, you may want to look at function ga:::gareal_Population_R to see how it generates a population from a uniform distribution. Otherwise look at gareal_Population.

chuymtz commented 6 years ago

Great! I missed that. I worked really well. One more question. Is there an opcion to adapt the penalty to do constrained optimization? Or do i have to manually do this outside the function ga call?

Again many thanks luca

luca-scr commented 6 years ago

Constrains can be handled by including a penalty term in the definition of the fitness function. For an example see http://luca-scr.github.io/GA/articles/GA.html#constrained-optimisation

chuymtz commented 6 years ago

I think i was vague in my comment. I want to do something more like augmented lagrange optimization. It seems to me that the penalty is static across all generations of the algorithm. I would like to know if there's a way to update the penalty as your population evolves.