[Avida-SVN] r2518 - in branches/jobScheduling/source: cpu main
beckma24 at myxo.css.msu.edu
beckma24 at myxo.css.msu.edu
Fri Apr 4 07:15:59 PDT 2008
Author: beckma24
Date: 2008-04-04 10:15:59 -0400 (Fri, 04 Apr 2008)
New Revision: 2518
Modified:
branches/jobScheduling/source/cpu/cHardwareCPU.cc
branches/jobScheduling/source/cpu/cHardwareCPU.h
branches/jobScheduling/source/main/cDeme.cc
branches/jobScheduling/source/main/cDeme.h
branches/jobScheduling/source/main/cPopulation.cc
Log:
Added die instruction variation which adds an organism's remaining energy to the offspring demes' energy, i.e. the organisms last will and testament.
Modified: branches/jobScheduling/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/jobScheduling/source/cpu/cHardwareCPU.cc 2008-04-03 20:02:50 UTC (rev 2517)
+++ branches/jobScheduling/source/cpu/cHardwareCPU.cc 2008-04-04 14:15:59 UTC (rev 2518)
@@ -356,6 +356,7 @@
tInstLibEntry<tMethod>("kazi", &cHardwareCPU::Inst_Kazi, nInstFlag::STALL),
tInstLibEntry<tMethod>("kazi5", &cHardwareCPU::Inst_Kazi5, nInstFlag::STALL),
tInstLibEntry<tMethod>("die", &cHardwareCPU::Inst_Die, nInstFlag::STALL),
+ tInstLibEntry<tMethod>("relinquishEnergyToFutureDeme", &cHardwareCPU::Inst_RelinquishEnergyToFutureDeme, nInstFlag::STALL),
// Sleep and time
tInstLibEntry<tMethod>("sleep", &cHardwareCPU::Inst_Sleep, nInstFlag::STALL),
@@ -2712,9 +2713,19 @@
bool cHardwareCPU::Inst_Die(cAvidaContext& ctx)
{
organism->Die();
- return true;
+ return true;
}
+bool cHardwareCPU::Inst_RelinquishEnergyToFutureDeme(cAvidaContext& ctx)
+{
+ double stored_energy = organism->GetPhenotype().GetStoredEnergy();
+ // put stored energy into testament pool for offspring deme
+ organism->GetOrgInterface().GetDeme()->IncreaseTotalEnergyTestament(stored_energy);
+ organism->Die();
+ return true;
+}
+
+
// The inject instruction can be used instead of a divide command, paired
// with an allocate. Note that for an inject to work, one needs to have a
// broad range for sizes allowed to be allocated.
Modified: branches/jobScheduling/source/cpu/cHardwareCPU.h
===================================================================
--- branches/jobScheduling/source/cpu/cHardwareCPU.h 2008-04-03 20:02:50 UTC (rev 2517)
+++ branches/jobScheduling/source/cpu/cHardwareCPU.h 2008-04-04 14:15:59 UTC (rev 2518)
@@ -434,6 +434,7 @@
bool Inst_Kazi(cAvidaContext& ctx);
bool Inst_Kazi5(cAvidaContext& ctx);
bool Inst_Die(cAvidaContext& ctx);
+ bool Inst_RelinquishEnergyToFutureDeme(cAvidaContext& ctx);
// I/O and Sensory
bool Inst_TaskGet(cAvidaContext& ctx);
Modified: branches/jobScheduling/source/main/cDeme.cc
===================================================================
--- branches/jobScheduling/source/main/cDeme.cc 2008-04-03 20:02:50 UTC (rev 2517)
+++ branches/jobScheduling/source/main/cDeme.cc 2008-04-04 14:15:59 UTC (rev 2518)
@@ -119,6 +119,8 @@
{
assert(org_count>0);
+ total_energy_testament = 0.0;
+
total_org_energy = deme_energy;
if(total_org_energy < 0.0)
total_org_energy = 0.0;
Modified: branches/jobScheduling/source/main/cDeme.h
===================================================================
--- branches/jobScheduling/source/main/cDeme.h 2008-04-03 20:02:50 UTC (rev 2517)
+++ branches/jobScheduling/source/main/cDeme.h 2008-04-04 14:15:59 UTC (rev 2518)
@@ -56,6 +56,7 @@
int _age; //!< Age of this deme, in updates.
int generation; //!< Generation of this deme
double total_org_energy; //! total amount of energy in organisms in this deme
+ double total_energy_testament; //! total amount of energy from suicide organisms for offspring deme
int time_used; //!< number of cpu cycles this deme has used
int gestation_time; // Time used during last generation
double cur_normalized_time_used; // normalized by merit and number of orgs
@@ -82,7 +83,7 @@
cMerit _next_merit; //!< Deme merit that will be inherited upon deme replication.
public:
- cDeme() : _id(0), width(0), birth_count(0), org_count(0), _age(0), generation(0), total_org_energy(0.0),
+ cDeme() : _id(0), width(0), birth_count(0), org_count(0), _age(0), generation(0), total_org_energy(0.0), total_energy_testament(0.0),
time_used(0), gestation_time(0), cur_normalized_time_used(0.0), last_normalized_time_used(0.0),
eventsKilled(0), deme_resource_count(0), m_germline_genotype_id(0) { ; }
~cDeme() { ; }
@@ -164,6 +165,8 @@
void KillCellEvent(const int eventID);
double CalculateTotalEnergy();
+ double GetTotalEnergyTestament() { return total_energy_testament; }
+ void IncreaseTotalEnergyTestament(double increment) { total_energy_testament += increment; }
void IncTimeUsed(double merit)
{ time_used++; cur_normalized_time_used += 1.0/merit/(double)org_count; }
Modified: branches/jobScheduling/source/main/cPopulation.cc
===================================================================
--- branches/jobScheduling/source/main/cPopulation.cc 2008-04-03 20:02:50 UTC (rev 2517)
+++ branches/jobScheduling/source/main/cPopulation.cc 2008-04-04 14:15:59 UTC (rev 2518)
@@ -1222,7 +1222,7 @@
// used to pass energy to offspring demes (set to zero if energy model is not enabled)
double source_deme_energy(0.0), deme_energy_decay(0.0), parent_deme_energy(0.0), offspring_deme_energy(0.0);
if(m_world->GetConfig().ENERGY_ENABLED.Get()) {
- source_deme_energy = source_deme.CalculateTotalEnergy();
+ source_deme_energy = source_deme.CalculateTotalEnergy() + source_deme.GetTotalEnergyTestament();
deme_energy_decay = 1.0 - m_world->GetConfig().FRAC_ENERGY_DECAY_AT_DEME_BIRTH.Get();
parent_deme_energy = source_deme_energy * deme_energy_decay * (1.0 - m_world->GetConfig().FRAC_PARENT_ENERGY_GIVEN_TO_DEME_AT_BIRTH.Get());
offspring_deme_energy = source_deme_energy * deme_energy_decay * m_world->GetConfig().FRAC_PARENT_ENERGY_GIVEN_TO_DEME_AT_BIRTH.Get();
More information about the Avida-cvs
mailing list