[Avida-SVN] r2028 - in development/source: classification cpu main
brysonda at myxo.css.msu.edu
brysonda at myxo.css.msu.edu
Thu Aug 30 09:30:25 PDT 2007
Author: brysonda
Date: 2007-08-30 12:30:25 -0400 (Thu, 30 Aug 2007)
New Revision: 2028
Modified:
development/source/classification/cGenotypeControl.cc
development/source/cpu/cHardwareCPU.cc
development/source/main/cPopulation.cc
development/source/main/cPopulationCell.cc
development/source/main/cPopulationCell.h
Log:
A few small performance tweaks.
Modified: development/source/classification/cGenotypeControl.cc
===================================================================
--- development/source/classification/cGenotypeControl.cc 2007-08-30 13:47:11 UTC (rev 2027)
+++ development/source/classification/cGenotypeControl.cc 2007-08-30 16:30:25 UTC (rev 2028)
@@ -204,29 +204,22 @@
bool cGenotypeControl::Adjust(cGenotype & in_genotype)
{
- cGenotype * cur_genotype = in_genotype.GetPrev();
+ cGenotype* cur_genotype = in_genotype.GetPrev();
// Check to see if this genotype should be removed completely.
-
- if (in_genotype.GetNumOrganisms() == 0 &&
- in_genotype.GetDeferAdjust() == false) {
+ if (in_genotype.GetNumOrganisms() == 0 && in_genotype.GetDeferAdjust() == false) {
m_world->GetClassificationManager().RemoveGenotype(in_genotype);
return false;
}
// Do not adjust the position of this genotype if it was and still is the
// best genotype, or if it is otherwise in the proper spot...
+ if (CheckPos(in_genotype)) return true;
- if (CheckPos(in_genotype)) {
- return true;
- }
-
// Otherwise, remove it from the queue (for just the moment).
-
Remove(in_genotype);
// If this genotype is the best, put it there.
-
if (in_genotype.GetNumOrganisms() > best->GetNumOrganisms()) {
Insert(in_genotype, best->GetPrev());
best = &in_genotype;
Modified: development/source/cpu/cHardwareCPU.cc
===================================================================
--- development/source/cpu/cHardwareCPU.cc 2007-08-30 13:47:11 UTC (rev 2027)
+++ development/source/cpu/cHardwareCPU.cc 2007-08-30 16:30:25 UTC (rev 2028)
@@ -519,12 +519,11 @@
// Mark this organism as running...
organism->SetRunning(true);
- cPhenotype & phenotype = organism->GetPhenotype();
+ cPhenotype& phenotype = organism->GetPhenotype();
- if (m_world->GetConfig().PROMOTERS_ENABLED.Get() == 1) {
- //First instruction - check whether we should be starting at a promoter.
- if (phenotype.GetCPUCyclesUsed() == 0) Inst_Terminate(m_world->GetDefaultContext());
- }
+ // First instruction - check whether we should be starting at a promoter, when enabled.
+ if (phenotype.GetCPUCyclesUsed() == 0 && m_world->GetConfig().PROMOTERS_ENABLED.Get() == 1)
+ Inst_Terminate(m_world->GetDefaultContext());
// Count the cpu cycles used
phenotype.IncCPUCyclesUsed();
Modified: development/source/main/cPopulation.cc
===================================================================
--- development/source/main/cPopulation.cc 2007-08-30 13:47:11 UTC (rev 2027)
+++ development/source/main/cPopulation.cc 2007-08-30 16:30:25 UTC (rev 2028)
@@ -2033,7 +2033,7 @@
cPopulationCell& cell = GetCell(cell_id);
assert(cell.IsOccupied()); // Unoccupied cell getting processor time!
cOrganism* cur_org = cell.GetOrganism();
- cur_org->GetHardware().SingleProcess(ctx);
+ cell.GetHardware()->SingleProcess(ctx);
if (cur_org->GetPhenotype().GetToDelete() == true) {
delete cur_org;
}
Modified: development/source/main/cPopulationCell.cc
===================================================================
--- development/source/main/cPopulationCell.cc 2007-08-30 13:47:11 UTC (rev 2027)
+++ development/source/main/cPopulationCell.cc 2007-08-30 16:30:25 UTC (rev 2028)
@@ -40,6 +40,7 @@
cPopulationCell::cPopulationCell(const cPopulationCell& in_cell)
: m_world(in_cell.m_world)
, m_organism(in_cell.m_organism)
+ , m_hardware(in_cell.m_hardware)
, m_inputs(in_cell.m_inputs)
, m_cell_id(in_cell.m_cell_id)
, m_deme_id(in_cell.m_deme_id)
@@ -58,6 +59,7 @@
{
m_world = in_cell.m_world;
m_organism = in_cell.m_organism;
+ m_hardware = in_cell.m_hardware;
m_inputs = in_cell.m_inputs;
m_cell_id = in_cell.m_cell_id;
m_deme_id = in_cell.m_deme_id;
@@ -164,6 +166,7 @@
// Adjust this cell's attributes to account for the new organism.
m_organism = new_org;
+ m_hardware = &new_org->GetHardware();
m_organism_count++;
// Adjust the organism's attributes to match this cell.
@@ -191,6 +194,7 @@
m_world->GetPopulation().GetDeme(m_deme_id).GiveBackCellEnergy(m_cell_id, m_organism->GetPhenotype().GetStoredEnergy() * m_world->GetConfig().FRAC_ENERGY_TRANSFER.Get());
}
m_organism = NULL;
+ m_hardware = NULL;
return out_organism;
}
Modified: development/source/main/cPopulationCell.h
===================================================================
--- development/source/main/cPopulationCell.h 2007-08-30 13:47:11 UTC (rev 2027)
+++ development/source/main/cPopulationCell.h 2007-08-30 16:30:25 UTC (rev 2028)
@@ -38,6 +38,7 @@
#include "tList.h"
#endif
+class cHardwareBase;
class cPopulation;
class cOrganism;
class cPopulationCell;
@@ -50,6 +51,7 @@
private:
cWorld* m_world;
cOrganism* m_organism; // The occupent of this cell.
+ cHardwareBase* m_hardware;
tList<cPopulationCell> m_connections; // A list of neighboring cells.
cMutationRates* m_mut_rates; // Mutation rates at this cell.
tArray<int> m_inputs; // Environmental Inputs...
@@ -68,7 +70,7 @@
public:
- cPopulationCell() : m_world(NULL), m_organism(NULL), m_mut_rates(NULL), m_organism_count(0) { ; }
+ cPopulationCell() : m_world(NULL), m_organism(NULL), m_hardware(NULL), m_mut_rates(NULL), m_organism_count(0) { ; }
cPopulationCell(const cPopulationCell& in_cell);
~cPopulationCell() { delete m_mut_rates; }
@@ -79,6 +81,7 @@
void Rotate(cPopulationCell& new_facing);
inline cOrganism* GetOrganism() const { return m_organism; }
+ inline cHardwareBase* GetHardware() const { return m_hardware; }
inline tList<cPopulationCell>& ConnectionList() { return m_connections; }
inline cPopulationCell& GetCellFaced() { return *(m_connections.GetFirst()); }
int GetFacing(); // Returns the facing of this cell.
More information about the Avida-cvs
mailing list