[galib] Constrainted Optimization (Bruckmann, Tobias)
bruckmann at mechatronik.uni-duisburg.de
Mon Dec 3 11:25:48 EST 2007
thanks for the quick answer.
So there is no way to use the destroy() function at this place? Just to remove the "const" declaration would cause the problems you wrote in your answer, right?
Von: galib-bounces at mit.edu [mailto:galib-bounces at mit.edu] Im Auftrag von matthew wall
Gesendet: Montag, 3. Dezember 2007 17:08
An: galib at mit.edu
Betreff: Re: [galib] Constrainted Optimization (Bruckmann, Tobias)
On Mon, 3 Dec 2007 at 10:37:10, Bruckmann, Tobias wrote:
> The 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.
galib mailing list
galib at mit.edu
More information about the galib