[galib] Constrainted Optimization (Bruckmann, Tobias)

Anselmo Pitombeira anselmop at sc.usp.br
Mon Dec 3 12:35:50 EST 2007


he problem is that the population object is declared as "const" while
> destroy() calls remove() which is NOT const. I'm not an experienced C++
> programmer, so I'm having problems to get the point. What is the reason to
> introduce a "const" population while a function is offered to kill
> individuals (which fails because of the protection)? Or does it lead to
> problems to change the population size during run time? This idea came to my
> mind since I'm not sure if the implementation creates a new population with
> the original size also from a reduced population.
> 
> I guess there is a legal way to solve the problem (as a bad hack, I could try
> to replace the "const" population, but this shouldn't be the way...).


the 'population' method on the GA class is const because the GA does not want
you to muck about with its population.  you can read it, but you cannot modify
it.  internally there are (or may be, depending on the GA) other objects that
use the population object, and if the population object is modified without
telling them, they will not be happy.

if you want to make changes to the population, then you should do so from within
a GA class of your own.

another way is to make your own population class then feed that to a standard GA.

m


I have derived a NSGA-II Algorithm and written its step function, since I had to modify the population formation. You should though pay attention to the way the pointers to the populations are manipulated. It took me some time to understand it by looking at the code for the built-in GALib GAs.

Anselmo




More information about the galib mailing list