Reputation: 1898
I'm creating a genetic algorithm framework and I have a population class which includes a Tournament
and an EvolutionStrategy
object so that I can plug in different tournament types and evolution strategies.
Currently I have set it so that I create a new EvolutionStrategy
object by passing in the Population
object from population -
EvolutionStrategy strategy = new BasicStrategy(this);
In BasicStrategy
constructor I have
Population pop;
public BasicStrategy(Population pop)
{
this.pop = pop;
}
I have two questions regarding this
1) Does this create the proper reference variable, allowing updates to the population to be instantly accessible in the EvolutionStrategy
or should I be using some form of synchronization ?
2) Is there a better way to do this? It seems wasteful to me to have a reference variable to the strategy in the Population
and a reference variable to the population in the Strategy
.
Upvotes: 1
Views: 54
Reputation: 1262
Upvotes: 2