[Avida-SVN] r3541 - in branches/biounit/source: . classification main
brysonda at myxo.css.msu.edu
brysonda at myxo.css.msu.edu
Fri Nov 20 13:04:38 PST 2009
Author: brysonda
Date: 2009-11-20 16:04:38 -0500 (Fri, 20 Nov 2009)
New Revision: 3541
Modified:
branches/biounit/source/classification/cBGGenotypeManager.cc
branches/biounit/source/classification/cBGGenotypeManager.h
branches/biounit/source/classification/cBioGroupManager.h
branches/biounit/source/classification/cClassificationManager.cc
branches/biounit/source/defs.h
branches/biounit/source/main/cPopulation.cc
branches/biounit/source/main/cPopulation.h
Log:
More deme source handling.
Modified: branches/biounit/source/classification/cBGGenotypeManager.cc
===================================================================
--- branches/biounit/source/classification/cBGGenotypeManager.cc 2009-11-20 18:34:41 UTC (rev 3540)
+++ branches/biounit/source/classification/cBGGenotypeManager.cc 2009-11-20 21:04:38 UTC (rev 3541)
@@ -74,7 +74,12 @@
}
+void cBGGenotypeManager::UpdateReset()
+{
+ // @TODO
+}
+
unsigned int cBGGenotypeManager::hashGenome(const cGenome& genome) const
{
unsigned int total = 0;
Modified: branches/biounit/source/classification/cBGGenotypeManager.h
===================================================================
--- branches/biounit/source/classification/cBGGenotypeManager.h 2009-11-20 18:34:41 UTC (rev 3540)
+++ branches/biounit/source/classification/cBGGenotypeManager.h 2009-11-20 21:04:38 UTC (rev 3541)
@@ -67,6 +67,7 @@
// cBioGroupManager Interface Methods
cBioGroup* ClassifyNewBioUnit(cBioUnit* bu);
+ void UpdateReset();
// Genotype Manager Methods
cBGGenotype* ClassifyNewBioUnit(cBioUnit* bu, tArray<cBioGroup*>* parents);
Modified: branches/biounit/source/classification/cBioGroupManager.h
===================================================================
--- branches/biounit/source/classification/cBioGroupManager.h 2009-11-20 18:34:41 UTC (rev 3540)
+++ branches/biounit/source/classification/cBioGroupManager.h 2009-11-20 21:04:38 UTC (rev 3541)
@@ -46,6 +46,8 @@
virtual ~cBioGroupManager() = 0;
virtual cBioGroup* ClassifyNewBioUnit(cBioUnit* bu) = 0;
+
+ virtual void UpdateReset() = 0;
inline int GetRoleID() const { return m_role_id; }
inline const cString& GetRole() const { return m_role; }
Modified: branches/biounit/source/classification/cClassificationManager.cc
===================================================================
--- branches/biounit/source/classification/cClassificationManager.cc 2009-11-20 18:34:41 UTC (rev 3540)
+++ branches/biounit/source/classification/cClassificationManager.cc 2009-11-20 21:04:38 UTC (rev 3541)
@@ -95,6 +95,9 @@
void cClassificationManager::UpdateReset()
{
+ // Notify all bio group managers of the update reset
+ for (int i = 0; i < m_bgms.GetSize(); i++) m_bgms[i]->UpdateReset();
+
cGenotype* best_genotype = GetBestGenotype();
cTestCPU* testcpu = m_world->GetHardwareManager().CreateTestCPU();
Modified: branches/biounit/source/defs.h
===================================================================
--- branches/biounit/source/defs.h 2009-11-20 18:34:41 UTC (rev 3540)
+++ branches/biounit/source/defs.h 2009-11-20 21:04:38 UTC (rev 3541)
@@ -197,8 +197,11 @@
enum eBioUnitSource {
+ SRC_DEME_COMPETE,
+ SRC_DEME_COPY,
SRC_DEME_GERMLINE,
SRC_DEME_REPLICATE,
+ SRC_DEME_SPAWN,
SRC_ORGANISM_COMPETE,
SRC_ORGANISM_DIVIDE,
SRC_ORGANISM_FILE_LOAD,
Modified: branches/biounit/source/main/cPopulation.cc
===================================================================
--- branches/biounit/source/main/cPopulation.cc 2009-11-20 18:34:41 UTC (rev 3540)
+++ branches/biounit/source/main/cPopulation.cc 2009-11-20 21:04:38 UTC (rev 3541)
@@ -1216,7 +1216,7 @@
int from_cell_id = from_deme.GetCellID(i);
int to_cell_id = to_deme.GetCellID(i);
if (cell_array[from_cell_id].IsOccupied() == true) {
- InjectClone( to_cell_id, *(cell_array[from_cell_id].GetOrganism()) );
+ InjectClone(to_cell_id, *(cell_array[from_cell_id].GetOrganism()), SRC_DEME_COMPETE);
}
}
is_init[to_deme_id] = true;
@@ -1230,7 +1230,7 @@
for (int i = 0; i < cur_deme.GetSize(); i++) {
int cur_cell_id = cur_deme.GetCellID(i);
if (cell_array[cur_cell_id].IsOccupied() == false) continue;
- InjectClone( cur_cell_id, *(cell_array[cur_cell_id].GetOrganism()) );
+ InjectClone(cur_cell_id, *(cell_array[cur_cell_id].GetOrganism()), cell_array[cur_cell_id].GetOrganism()->GetUnitSource());
}
}
@@ -2533,7 +2533,7 @@
}
// Inject a copy of the odd organisms into the even cells.
- InjectClone( cell2_id, *org1 );
+ InjectClone(cell2_id, *org1, SRC_DEME_REPLICATE);
// Kill the organisms in the odd cells.
KillOrganism( cell_array[cell1_id] );
@@ -2565,7 +2565,7 @@
for (int i = 0; i < deme_array[deme_id].GetSize(); i++) {
int cur_cell_id = deme_array[deme_id].GetCellID(i);
if (cell_array[cur_cell_id].IsOccupied() == false) continue;
- InjectClone( cur_cell_id, *(cell_array[cur_cell_id].GetOrganism()) );
+ InjectClone(cur_cell_id, *(cell_array[cur_cell_id].GetOrganism()), cell_array[cur_cell_id].GetOrganism()->GetUnitSource());
}
}
}
@@ -2585,7 +2585,7 @@
KillOrganism(cell_array[to_cell]);
continue;
}
- InjectClone( to_cell, *(cell_array[from_cell].GetOrganism()) );
+ InjectClone(to_cell, *(cell_array[from_cell].GetOrganism()), SRC_DEME_COPY);
}
}
@@ -2733,7 +2733,7 @@
// And do the spawning.
int cell2_id = deme2.GetCellID( random.GetUInt(deme2.GetSize()) );
- InjectClone( cell2_id, *(cell_array[cell1_id].GetOrganism()) );
+ InjectClone( cell2_id, *(cell_array[cell1_id].GetOrganism()), SRC_DEME_SPAWN);
}
void cPopulation::AddDemePred(cString type, int times) {
@@ -5100,6 +5100,9 @@
cMetaGenome tmp_genome(m_world->GetConfig().HARDWARE_TYPE.Get(), 1, new_genotype->GetGenome()); // @TODO - genotypes need metagenomes
cOrganism* new_organism = new cOrganism(m_world, ctx, tmp_genome, src);
+ // Classify this new organism
+ m_world->GetClassificationManager().ClassifyNewBioUnit(new_organism);
+
//Coalescense Clade Setup
new_organism->SetCCladeLabel(-1);
@@ -5160,13 +5163,16 @@
// This function injects a new organism into the population at cell_id that
// is an exact clone of the organism passed in.
-void cPopulation::InjectClone(int cell_id, cOrganism& orig_org)
+void cPopulation::InjectClone(int cell_id, cOrganism& orig_org, eBioUnitSource src)
{
assert(cell_id >= 0 && cell_id < cell_array.GetSize());
cAvidaContext& ctx = m_world->GetDefaultContext();
- cOrganism* new_organism = new cOrganism(m_world, ctx, orig_org.GetMetaGenome(), SRC_ORGANISM_FILE_LOAD);
+ cOrganism* new_organism = new cOrganism(m_world, ctx, orig_org.GetMetaGenome(), src);
+
+ // Classify the new organism
+ m_world->GetClassificationManager().ClassifyNewBioUnit(new_organism);
// Set the genotype...
new_organism->SetGenotype(orig_org.GetGenotype());
@@ -5211,6 +5217,11 @@
parent.OffspringGenome() = save_child;
cOrganism* new_organism = new cOrganism(m_world, ctx, child_genome, SRC_ORGANISM_COMPETE);
+ // Classify the offspring
+ tArray<const tArray<cBioGroup*>*> pgrps(1);
+ pgrps[0] = &parent.GetBioGroups();
+ new_organism->SelfClassify(pgrps);
+
// Set the genotype...
assert(parent.GetGenotype());
cGenotype* new_genotype = m_world->GetClassificationManager().GetGenotype(child_genome.GetGenome(), parent.GetGenotype(), NULL);
Modified: branches/biounit/source/main/cPopulation.h
===================================================================
--- branches/biounit/source/main/cPopulation.h 2009-11-20 18:34:41 UTC (rev 3540)
+++ branches/biounit/source/main/cPopulation.h 2009-11-20 21:04:38 UTC (rev 3541)
@@ -342,7 +342,7 @@
**/
void InjectGenotype(int cell_id, cGenotype* genotype, eBioUnitSource src);
- void InjectClone(int cell_id, cOrganism& orig_org);
+ void InjectClone(int cell_id, cOrganism& orig_org, eBioUnitSource src);
void CompeteOrganisms_ConstructOffspring(int cell_id, cOrganism& parent);
//! Helper method that adds a founder organism to a deme, and sets up its phenotype
More information about the Avida-cvs
mailing list