[Avida-SVN] r2549 - in branches/jobScheduling/source: cpu main

beckma24 at myxo.css.msu.edu beckma24 at myxo.css.msu.edu
Wed Apr 23 11:46:13 PDT 2008


Author: beckma24
Date: 2008-04-23 14:46:12 -0400 (Wed, 23 Apr 2008)
New Revision: 2549

Modified:
   branches/jobScheduling/source/cpu/cHardwareBase.cc
   branches/jobScheduling/source/cpu/cHardwareBase.h
   branches/jobScheduling/source/cpu/cHardwareCPU.cc
   branches/jobScheduling/source/main/cAvidaConfig.h
   branches/jobScheduling/source/main/cDeme.cc
   branches/jobScheduling/source/main/cPhenotype.cc
   branches/jobScheduling/source/main/cPhenotype.h
   branches/jobScheduling/source/main/cPopulation.cc
Log:
Added instruction to reset exe ratio and config aption to allow energy ratio to be heritable

Modified: branches/jobScheduling/source/cpu/cHardwareBase.cc
===================================================================
--- branches/jobScheduling/source/cpu/cHardwareBase.cc	2008-04-22 19:46:36 UTC (rev 2548)
+++ branches/jobScheduling/source/cpu/cHardwareBase.cc	2008-04-23 18:46:12 UTC (rev 2549)
@@ -806,11 +806,11 @@
 }
 
 bool cHardwareBase::Inst_DoubleEnergyUsage(cAvidaContext& ctx) {
-  double energy_req = inst_energy_cost[IP().GetNextInst().GetOp()]
+/*  double energy_req = inst_energy_cost[IP().GetNextInst().GetOp()]
                         * cMerit::EnergyToMerit(organism->GetPhenotype().GetStoredEnergy() * organism->GetPhenotype().GetEnergyUsageRatio() * 2.0, m_world)
                         / 100.0; //compensate by factor of 100
-
-  organism->GetPhenotype().DoubleEnergyUsage(energy_req);
+*/
+  organism->GetPhenotype().DoubleEnergyUsage();
   double newOrgMerit = cMerit::EnergyToMerit(organism->GetPhenotype().GetStoredEnergy()  * organism->GetPhenotype().GetEnergyUsageRatio(), m_world);
   organism->UpdateMerit(newOrgMerit);
   return true;
@@ -823,6 +823,13 @@
   return true;
 }
 
+bool cHardwareBase::Inst_DefaultEnergyUsage(cAvidaContext& ctx) {
+  organism->GetPhenotype().DefaultEnergyUsage();
+  double newOrgMerit = cMerit::EnergyToMerit(organism->GetPhenotype().GetStoredEnergy()  * organism->GetPhenotype().GetEnergyUsageRatio(), m_world);
+  organism->UpdateMerit(newOrgMerit);
+  return true;
+}
+
 // This method will test to see if all costs have been paid associated
 // with executing an instruction and only return true when that instruction
 // should proceed.

Modified: branches/jobScheduling/source/cpu/cHardwareBase.h
===================================================================
--- branches/jobScheduling/source/cpu/cHardwareBase.h	2008-04-22 19:46:36 UTC (rev 2548)
+++ branches/jobScheduling/source/cpu/cHardwareBase.h	2008-04-23 18:46:12 UTC (rev 2549)
@@ -204,6 +204,7 @@
   // --------  Execution Speed Instruction --------
   bool Inst_DoubleEnergyUsage(cAvidaContext& ctx);
   bool Inst_HalfEnergyUsage(cAvidaContext& ctx);
+  bool Inst_DefaultEnergyUsage(cAvidaContext& ctx);
 };
 
 

Modified: branches/jobScheduling/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/jobScheduling/source/cpu/cHardwareCPU.cc	2008-04-22 19:46:36 UTC (rev 2548)
+++ branches/jobScheduling/source/cpu/cHardwareCPU.cc	2008-04-23 18:46:12 UTC (rev 2549)
@@ -401,12 +401,12 @@
     // Energy usage
     tInstLibEntry<tMethod>("double-energy-usage", &cHardwareCPU::Inst_DoubleEnergyUsage, nInstFlag::STALL),
     tInstLibEntry<tMethod>("half-energy-usage", &cHardwareCPU::Inst_HalfEnergyUsage, nInstFlag::STALL),
+    tInstLibEntry<tMethod>("default-energy-usage", &cHardwareCPU::Inst_DefaultEnergyUsage, nInstFlag::STALL),
 
     // Messaging
     tInstLibEntry<tMethod>("send-msg", &cHardwareCPU::Inst_SendMessage, nInstFlag::STALL),
     tInstLibEntry<tMethod>("retrieve-msg", &cHardwareCPU::Inst_RetrieveMessage, nInstFlag::STALL),
-        
-        
+
     // Alarms
     tInstLibEntry<tMethod>("send-alarm-msg", &cHardwareCPU::Inst_Alarm_MSG, nInstFlag::STALL),
     tInstLibEntry<tMethod>("send-alarm-msg-bit-cons24", &cHardwareCPU::Inst_Alarm_MSG_Bit_Cons24, nInstFlag::STALL),

Modified: branches/jobScheduling/source/main/cAvidaConfig.h
===================================================================
--- branches/jobScheduling/source/main/cAvidaConfig.h	2008-04-22 19:46:36 UTC (rev 2548)
+++ branches/jobScheduling/source/main/cAvidaConfig.h	2008-04-23 18:46:12 UTC (rev 2549)
@@ -476,7 +476,7 @@
   CONFIG_ADD_VAR(LOG_SLEEP_TIMES, bool, 0, "Log sleep start and end times. 0/1 (off/on)\nWARNING: may use lots of memory.");
   CONFIG_ADD_VAR(FRAC_ENERGY_RELINQUISH, double, 1.0, "Fraction of organisms energy to relinquish");
   CONFIG_ADD_VAR(ENERGY_PASSED_ON_DEME_REPLICATION_METHOD, int, 0, "Who get energy passed from a parent deme\n0 = Energy divided among organisms injected to offspring deme\n1 = Energy divided among cells in offspring deme");
- 
+  CONFIG_ADD_VAR(INHERIT_EXE_RATE, int, 0, "Inherit energy rate from parent? 0=no  1=yes");
 
   CONFIG_ADD_GROUP(SECOND_PASS_GROUP, "Tracking metrics known after the running experiment previously");
   CONFIG_ADD_VAR(TRACK_CCLADES, int, 0, "Enable tracking of coalescence clades");

Modified: branches/jobScheduling/source/main/cDeme.cc
===================================================================
--- branches/jobScheduling/source/main/cDeme.cc	2008-04-22 19:46:36 UTC (rev 2548)
+++ branches/jobScheduling/source/main/cDeme.cc	2008-04-23 18:46:12 UTC (rev 2549)
@@ -78,17 +78,18 @@
 
 void cDeme::ProcessUpdate() {
   energyUsage.Clear();
+
+  if(IsEmpty()) {  // deme is not processed if no organisms are present
+    total_energy_testament = 0.0;
+    return;
+  }
+
   for(int i = 0; i < GetSize(); i++) {
     cPopulationCell& cell = GetCell(i);
     if(cell.IsOccupied()) {
       energyUsage.Add(cell.GetOrganism()->GetPhenotype().GetEnergyUsageRatio());
     }
-  }
-  
-  if(IsEmpty()) {  // deme is not processed if no organisms are present
-    total_energy_testament = 0.0;
-    return;
-  }
+  }  
 
   for(int i = 0; i < cell_events.GetSize(); i++) {
     cDemeCellEvent& event = cell_events[i];
@@ -115,7 +116,7 @@
   
   for(vector<pair<int, int> >::iterator iter = event_slot_end_points.begin(); iter < event_slot_end_points.end(); iter++) {
     if(_age == (*iter).first) {
-      // at end point
+      // at end point              
       if(GetEventsKilledThisSlot() >= m_world->GetConfig().DEMES_MIM_EVENTS_KILLED_RATIO.Get() * (*iter).second)
         consecutiveSuccessfulEventPeriods++;
       else

Modified: branches/jobScheduling/source/main/cPhenotype.cc
===================================================================
--- branches/jobScheduling/source/main/cPhenotype.cc	2008-04-22 19:46:36 UTC (rev 2548)
+++ branches/jobScheduling/source/main/cPhenotype.cc	2008-04-23 18:46:12 UTC (rev 2549)
@@ -257,7 +257,11 @@
 {
   // Copy divide values from parent, which should already be setup.
   merit           = parent_phenotype.merit;
-  executionRatio = 1.0;
+  if(m_world->GetConfig().INHERIT_EXE_RATE.Get() == 0)
+    executionRatio = 1.0;
+  else 
+    executionRatio = parent_phenotype.executionRatio;
+    
   energy_store    = min(energy_store, (double) m_world->GetConfig().ENERGY_CAP.Get());
   energy_tobe_applied = 0.0;
   energy_testament = 0.0;
@@ -816,9 +820,12 @@
   energy_store    = clone_phenotype.energy_store;
   energy_tobe_applied = 0.0;
   energy_testament = 0.0;
-  executionRatio = 1.0;
-  
-  executionRatio  = clone_phenotype.executionRatio;
+
+  if(m_world->GetConfig().INHERIT_EXE_RATE.Get() == 0)
+    executionRatio = 1.0;
+  else 
+    executionRatio = clone_phenotype.executionRatio;
+
   genome_length   = clone_phenotype.genome_length;
   copied_size     = clone_phenotype.copied_size;
   // copied_size     = clone_phenotype.child_copied_size;
@@ -1371,19 +1378,19 @@
   energy_store = max(0.0, min(value, (double) m_world->GetConfig().ENERGY_CAP.Get()));
 }
 
-bool cPhenotype::DoubleEnergyUsage(double energy_req) {
-  if(GetStoredEnergy() < energy_req) {
-    return false;
-  }
+void cPhenotype::DoubleEnergyUsage() {
   executionRatio *= 2.0;
-  return true;
 }
 
 void cPhenotype::HalfEnergyUsage() {
   executionRatio *= 0.5;
 }
 
+void cPhenotype::DefaultEnergyUsage() {
+  executionRatio = 1.0;
+}
 
+
 /**
 Credit organism with energy reward, but only update energy store if APPLY_ENERGY_METHOD = "on task completion" (1)
  */

Modified: branches/jobScheduling/source/main/cPhenotype.h
===================================================================
--- branches/jobScheduling/source/main/cPhenotype.h	2008-04-22 19:46:36 UTC (rev 2548)
+++ branches/jobScheduling/source/main/cPhenotype.h	2008-04-23 18:46:12 UTC (rev 2549)
@@ -454,8 +454,10 @@
   bool& ChildFertile() { assert(initialized == true); return child_fertile; }
   bool& IsMultiThread() { assert(initialized == true); return is_multi_thread; }
   
-  bool DoubleEnergyUsage(double inst_energy_cost);
+  void DoubleEnergyUsage();
   void HalfEnergyUsage();
+  void DefaultEnergyUsage();
+  
   void RefreshEnergy();
   void ApplyToEnergyStore();
   void EnergyTestament(const double value); //! external energy given to organism

Modified: branches/jobScheduling/source/main/cPopulation.cc
===================================================================
--- branches/jobScheduling/source/main/cPopulation.cc	2008-04-22 19:46:36 UTC (rev 2548)
+++ branches/jobScheduling/source/main/cPopulation.cc	2008-04-23 18:46:12 UTC (rev 2549)
@@ -1183,6 +1183,8 @@
     
     // Prevent sterile demes from replicating.
     if(m_world->GetConfig().DEMES_PREVENT_STERILE.Get() && (source_deme.GetBirthCount() == 0)) {
+      // assumes that all group level tasks cannot be solved by a single organism
+      source_deme.KillAll();
       return;
     }
 




More information about the Avida-cvs mailing list