[Avida-SVN] r3376 - branches/goings/source/main
goingssh at myxo.css.msu.edu
goingssh at myxo.css.msu.edu
Sun Aug 23 20:17:43 PDT 2009
Author: goingssh
Date: 2009-08-23 23:17:42 -0400 (Sun, 23 Aug 2009)
New Revision: 3376
Modified:
branches/goings/source/main/cPopulation.cc
Log:
updated distance calculations in fitness sharing to use more of the information about the parent organism to highly increase the speed at which runs can be done with fitness sharing
Modified: branches/goings/source/main/cPopulation.cc
===================================================================
--- branches/goings/source/main/cPopulation.cc 2009-08-22 15:50:04 UTC (rev 3375)
+++ branches/goings/source/main/cPopulation.cc 2009-08-24 03:17:42 UTC (rev 3376)
@@ -433,8 +433,7 @@
// Place all of the offspring...
for (int i = 0; i < child_array.GetSize(); i++)
{
- int parent_cell = (child_array[i]->GetGenotype() == parent_genotype) ? parent_id : -1;
- ActivateOrganism(ctx, child_array[i], GetCell(target_cells[i]), parent_cell);
+ ActivateOrganism(ctx, child_array[i], GetCell(target_cells[i]), parent_id);
//@JEB - we may want to pass along some state information from parent to child
if ( (m_world->GetConfig().EPIGENETIC_METHOD.Get() == EPIGENETIC_METHOD_OFFSPRING)
@@ -935,15 +934,30 @@
// cell_id is cell we're about to place a new org, gen is its genotype
void cPopulation::UpdateHDists(int cell_id, int par_id, cGenotype* gen)
{
+ int par_dist=-1;
+ if (par_id>=0)
+ {
+ const cGenome& par_gen = cell_array[par_id].GetOrganism()->GetGenome();
+ if ( par_gen == gen->GetGenome() )
+ par_dist = 0;
+ else
+ par_dist = cGenomeUtil::FindEditDistance(par_gen, gen->GetGenome());
+ }
for (int i=0; i<cell_array.GetSize(); i++)
{
int dist = m_world->GetConfig().NICHE_RADIUS.Get();
if (cell_array[i].GetOrganism())
{
- if (par_id==-1)
+ if ( par_dist != -1 && (par_dist==0 || hdists[i][par_id]-par_dist >= dist) )
+ {
+ dist = hdists[i][par_id]-par_dist;
+ //cout << dist << " ";
+ }
+ else
+ {
dist = cGenomeUtil::FindEditDistance(cell_array[i].GetOrganism()->GetGenome(), gen->GetGenome());
- else
- dist = hdists[i][par_id];
+ cout << dist << " ";
+ }
}
hdists[i][cell_id] = dist;
hdists[cell_id][i] = dist;
More information about the Avida-cvs
mailing list