[Avida-SVN] r1890 - in development: Avida.xcodeproj source/cpu

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Thu Aug 2 12:18:18 PDT 2007


Author: brysonda
Date: 2007-08-02 15:18:18 -0400 (Thu, 02 Aug 2007)
New Revision: 1890

Modified:
   development/Avida.xcodeproj/project.pbxproj
   development/source/cpu/cHardwareBase.cc
Log:
Fix performance degradation from energy model values in SingleProcess_PayCosts.  Moved the actions inside of blocks that check if the energy model is enabled.

Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj	2007-08-02 17:35:40 UTC (rev 1889)
+++ development/Avida.xcodeproj/project.pbxproj	2007-08-02 19:18:18 UTC (rev 1890)
@@ -211,23 +211,6 @@
 		};
 /* End PBXBuildRule section */
 
-/* Begin PBXBuildStyle section */
-		B512934E0C4FCA11004B0E41 /* Development */ = {
-			isa = PBXBuildStyle;
-			buildSettings = {
-				COPY_PHASE_STRIP = NO;
-			};
-			name = Development;
-		};
-		B512934F0C4FCA11004B0E41 /* Deployment */ = {
-			isa = PBXBuildStyle;
-			buildSettings = {
-				COPY_PHASE_STRIP = YES;
-			};
-			name = Deployment;
-		};
-/* End PBXBuildStyle section */
-
 /* Begin PBXContainerItemProxy section */
 		56F555DA0C3B36FC00E2E929 /* PBXContainerItemProxy */ = {
 			isa = PBXContainerItemProxy;
@@ -1788,12 +1771,6 @@
 		DCC30C4D0762532C008F7A48 /* Project object */ = {
 			isa = PBXProject;
 			buildConfigurationList = 702442D70859E0B00059BD9B /* Build configuration list for PBXProject "Avida" */;
-			buildSettings = {
-			};
-			buildStyles = (
-				B512934E0C4FCA11004B0E41 /* Development */,
-				B512934F0C4FCA11004B0E41 /* Deployment */,
-			);
 			hasScannedForEncodings = 0;
 			mainGroup = DCC30C490762532C008F7A48;
 			productRefGroup = DCC3164E07626CF3008F7A48 /* Products */;

Modified: development/source/cpu/cHardwareBase.cc
===================================================================
--- development/source/cpu/cHardwareBase.cc	2007-08-02 17:35:40 UTC (rev 1889)
+++ development/source/cpu/cHardwareBase.cc	2007-08-02 19:18:18 UTC (rev 1890)
@@ -762,30 +762,32 @@
 {
 #if INSTRUCTION_COSTS
   assert(cur_inst.GetOp() < inst_cost.GetSize());
-  
-  // TODO:  Get rid of magic number. check avaliable energy first
-  double energy_req = inst_energy_cost[cur_inst.GetOp()] * (organism->GetPhenotype().GetMerit().GetDouble() / 100.0); //compensate by factor of 100
 
-  if(m_world->GetConfig().ENERGY_ENABLED.Get() > 0 && energy_req > 0.0) {
-    if(organism->GetPhenotype().GetStoredEnergy() >= energy_req) {
-      inst_energy_cost[cur_inst.GetOp()] = 0;
-      //subtract energy used from current org energy.
-      organism->GetPhenotype().ReduceEnergy(energy_req);  
-      
-      // tracking sleeping organisms
-      cString instName = m_world->GetHardwareManager().GetInstSet().GetName(cur_inst);
-      int cellID = organism->GetCellID();
-      if( instName == cString("sleep") || instName == cString("sleep1") || instName == cString("sleep2") ||
-          instName == cString("sleep3") || instName == cString("sleep4")) {
-        cPopulation& pop = m_world->GetPopulation();
-        if(m_world->GetConfig().LOG_SLEEP_TIMES.Get() == 1) {
-          pop.AddBeginSleep(cellID,m_world->GetStats().GetUpdate());
+  if(m_world->GetConfig().ENERGY_ENABLED.Get() > 0) {
+    // TODO:  Get rid of magic number. check avaliable energy first
+    double energy_req = inst_energy_cost[cur_inst.GetOp()] * (organism->GetPhenotype().GetMerit().GetDouble() / 100.0); //compensate by factor of 100
+    
+    if (energy_req > 0.0) { 
+      if (organism->GetPhenotype().GetStoredEnergy() >= energy_req) {
+        inst_energy_cost[cur_inst.GetOp()] = 0;
+        // subtract energy used from current org energy.
+        organism->GetPhenotype().ReduceEnergy(energy_req);  
+        
+        // tracking sleeping organisms
+        cString instName = m_world->GetHardwareManager().GetInstSet().GetName(cur_inst);
+        int cellID = organism->GetCellID();
+        if( instName == cString("sleep") || instName == cString("sleep1") || instName == cString("sleep2") ||
+            instName == cString("sleep3") || instName == cString("sleep4")) {
+          cPopulation& pop = m_world->GetPopulation();
+          if(m_world->GetConfig().LOG_SLEEP_TIMES.Get() == 1) {
+            pop.AddBeginSleep(cellID,m_world->GetStats().GetUpdate());
+          }
+          pop.GetCell(cellID).GetOrganism()->SetSleeping(true);
+          m_world->GetStats().incNumAsleep(pop.GetCell(cellID).GetDemeID());
         }
-        pop.GetCell(cellID).GetOrganism()->SetSleeping(true);
-        m_world->GetStats().incNumAsleep(pop.GetCell(cellID).GetDemeID());
+      } else { // not enough energy
+        return false;
       }
-    } else { // not enough energy
-      return false;
     }
   }
 
@@ -805,7 +807,9 @@
     }
   }
   
-  inst_energy_cost[cur_inst.GetOp()] = m_inst_set->GetEnergyCost(cur_inst); //reset instruction energy cost
+  if (m_world->GetConfig().ENERGY_ENABLED.Get() > 0) {
+    inst_energy_cost[cur_inst.GetOp()] = m_inst_set->GetEnergyCost(cur_inst); // reset instruction energy cost
+  }
 #endif
   return true;
 }




More information about the Avida-cvs mailing list