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

matt at myxo.css.msu.edu matt at myxo.css.msu.edu
Wed Jul 25 15:27:44 PDT 2007


Author: matt
Date: 2007-07-25 18:27:44 -0400 (Wed, 25 Jul 2007)
New Revision: 1851

Modified:
   development/Avida.xcodeproj/project.pbxproj
   development/source/cpu/cTestCPU.h
   development/source/cpu/cTestCPUInterface.cc
   development/source/cpu/cTestCPUInterface.h
   development/source/main/cAvidaConfig.h
   development/source/main/cOrgInterface.h
   development/source/main/cPhenotype.h
   development/source/main/cPopulation.cc
   development/source/main/cPopulationCell.h
   development/source/main/cPopulationInterface.cc
   development/source/main/cPopulationInterface.h
Log:
CClade fitness histogram printing was corrected; added organism interface accessor to retrieve a cell's environment inputs; changed PRECALC_MERIT setting to PRECALC_PHENOTYPE to provide greater granularity over the behavior of pre-calculation behavior. (Some files didn't get TX'd last time)

Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj	2007-07-25 22:18:40 UTC (rev 1850)
+++ development/Avida.xcodeproj/project.pbxproj	2007-07-25 22:27:44 UTC (rev 1851)
@@ -209,23 +209,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;
@@ -848,7 +831,7 @@
 		DCC315CE076253A5008F7A48 /* environment.rotate */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = environment.rotate; sourceTree = "<group>"; };
 		DCC315D0076253A5008F7A48 /* task_event_gen.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = task_event_gen.cc; sourceTree = "<group>"; };
 		DCC315D1076253A5008F7A48 /* task_event_gen.old.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = task_event_gen.old.cc; sourceTree = "<group>"; };
-		DCC3164D07626CF3008F7A48 /* avida */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = avida; sourceTree = BUILT_PRODUCTS_DIR; };
+		DCC3164D07626CF3008F7A48 /* avida */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = avida; sourceTree = BUILT_PRODUCTS_DIR; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -1778,12 +1761,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/cTestCPU.h
===================================================================
--- development/source/cpu/cTestCPU.h	2007-07-25 22:18:40 UTC (rev 1850)
+++ development/source/cpu/cTestCPU.h	2007-07-25 22:27:44 UTC (rev 1851)
@@ -99,6 +99,7 @@
 
   inline int GetInput();
   inline int GetInputAt(int & input_pointer);
+  tArray<int> GetInputs() {return input_array;}
   void ResetInputs(cAvidaContext& ctx);
 
   inline int GetReceiveValue();

Modified: development/source/cpu/cTestCPUInterface.cc
===================================================================
--- development/source/cpu/cTestCPUInterface.cc	2007-07-25 22:18:40 UTC (rev 1850)
+++ development/source/cpu/cTestCPUInterface.cc	2007-07-25 22:27:44 UTC (rev 1851)
@@ -60,6 +60,11 @@
   m_testcpu->ResetInputs(ctx); 
 }
 
+tArray<int> cTestCPUInterface::GetInputs()
+{
+  return m_testcpu->GetInputs();
+}
+
 int cTestCPUInterface::Debug()
 {
   return -1;

Modified: development/source/cpu/cTestCPUInterface.h
===================================================================
--- development/source/cpu/cTestCPUInterface.h	2007-07-25 22:18:40 UTC (rev 1850)
+++ development/source/cpu/cTestCPUInterface.h	2007-07-25 22:27:44 UTC (rev 1851)
@@ -54,6 +54,7 @@
   void Breakpoint() { ; }
   int GetInputAt(int& input_pointer);
   void ResetInputs(cAvidaContext& ctx);
+  tArray<int> GetInputs();
   int Debug();
   const tArray<double>& GetResources();
   void UpdateResources(const tArray<double>& res_change);

Modified: development/source/main/cAvidaConfig.h
===================================================================
--- development/source/main/cAvidaConfig.h	2007-07-25 22:18:40 UTC (rev 1850)
+++ development/source/main/cAvidaConfig.h	2007-07-25 22:27:44 UTC (rev 1851)
@@ -302,7 +302,7 @@
   CONFIG_ADD_VAR(MIN_GB_DONATE_THRESHOLD, int, -1, "threshold green beard donates only to orgs above this\ndonation attempt threshold; -1=no thresh");
   CONFIG_ADD_VAR(DONATE_THRESH_QUANTA, int, 10, "The size of steps between quanta donate thresholds");
   CONFIG_ADD_VAR(MAX_DONATES, int, 1000000, "Limit on number of donates organisms are allowed.");
-  CONFIG_ADD_VAR(PRECALC_MERIT, int, 0, "Pre-calculate merit at birth (unlimited resources only).");
+  CONFIG_ADD_VAR(PRECALC_PHENOTYPE, int, 0, "0 = Disabled\n 1 = Assign precalculated merit at birth (unlimited resources only)\n 2 = Assign precalculated gestation time\n 3 = Assign precalculated merit AND gestation time.\nFitness will be evaluated for organism based on these settings.");
 
   CONFIG_ADD_GROUP(GENEOLOGY_GROUP, "Geneology");
   CONFIG_ADD_VAR(TRACK_MAIN_LINEAGE, int, 1, "Keep all ancestors of the active population?\n0=no, 1=yes, 2=yes,w/sexual population");

Modified: development/source/main/cOrgInterface.h
===================================================================
--- development/source/main/cOrgInterface.h	2007-07-25 22:18:40 UTC (rev 1850)
+++ development/source/main/cOrgInterface.h	2007-07-25 22:27:44 UTC (rev 1851)
@@ -63,6 +63,7 @@
   virtual void Breakpoint() = 0;
   virtual int GetInputAt(int& input_pointer) = 0;
   virtual void ResetInputs(cAvidaContext& ctx) = 0;
+  virtual tArray<int> GetInputs() = 0;
   virtual int Debug() = 0;
   virtual const tArray<double>& GetResources() = 0;
   virtual void UpdateResources(const tArray<double>& res_change) = 0;

Modified: development/source/main/cPhenotype.h
===================================================================
--- development/source/main/cPhenotype.h	2007-07-25 22:18:40 UTC (rev 1850)
+++ development/source/main/cPhenotype.h	2007-07-25 22:27:44 UTC (rev 1851)
@@ -379,6 +379,7 @@
 
   ////////////////////  Accessors -- Modifying  ///////////////////
   void SetMerit(const cMerit& in_merit) { merit = in_merit; }
+  void SetFitness(const double in_fit) { fitness = in_fit; }
   void ReduceEnergy(const double cost);
   void SetEnergy(const double value);
   void SetGestationTime(int in_time) { gestation_time = in_time; }

Modified: development/source/main/cPopulation.cc
===================================================================
--- development/source/main/cPopulation.cc	2007-07-25 22:18:40 UTC (rev 1850)
+++ development/source/main/cPopulation.cc	2007-07-25 22:27:44 UTC (rev 1851)
@@ -291,14 +291,19 @@
   if (parent_alive == true) {
 		
 		// Reset inputs and re-calculate merit if required
-		if (m_world->GetConfig().RESET_INPUTS_ON_DIVIDE.Get() > 0){
+    if (m_world->GetConfig().RESET_INPUTS_ON_DIVIDE.Get() > 0){
 			environment.SetupInputs(ctx, parent_cell.input_array);
-			if (m_world->GetConfig().PRECALC_MERIT.Get() > 0){
+      int pc_phenotype = m_world->GetConfig().PRECALC_PHENOTYPE.Get();
+			if (pc_phenotype){
 				cCPUTestInfo test_info;
 				cTestCPU* test_cpu = m_world->GetHardwareManager().CreateTestCPU();
 				test_info.UseManualInputs(parent_cell.input_array);                               // Test using what the environment will be
 				test_cpu->TestGenome(ctx, test_info, parent_organism.GetHardware().GetMemory()); // Use the true genome
-				parent_phenotype.SetMerit(test_info.GetTestPhenotype().GetMerit());    // Update merit
+				if (pc_phenotype & 1)  // If we must update the merit
+          parent_phenotype.SetMerit(test_info.GetTestPhenotype().GetMerit());
+        if (pc_phenotype & 2)  // If we must update the gestation time
+          parent_phenotype.SetGestationTime(test_info.GetTestPhenotype().GetGestationTime());
+        parent_phenotype.SetFitness(parent_phenotype.GetMerit().CalcFitness(parent_phenotype.GetGestationTime())); //Update fitness
 				delete test_cpu;
 			}
 		}
@@ -410,13 +415,19 @@
   environment.SetupInputs(ctx, target_cell.input_array);
   
   
-  // Precalculate the merit if requested
-  if (m_world->GetConfig().PRECALC_MERIT.Get() > 0){
+  // Precalculate the phenotype if requested
+  int pc_phenotype = m_world->GetConfig().PRECALC_PHENOTYPE.Get();
+  if (pc_phenotype){
     cCPUTestInfo test_info;
     cTestCPU* test_cpu = m_world->GetHardwareManager().CreateTestCPU();
     test_info.UseManualInputs(target_cell.input_array);                            // Test using what the environment will be
     test_cpu->TestGenome(ctx, test_info, in_organism->GetHardware().GetMemory());  // Use the true genome
-    in_organism->GetPhenotype().SetMerit(test_info.GetTestPhenotype().GetMerit()); // Update merit
+    
+    if (pc_phenotype & 1)
+      in_organism->GetPhenotype().SetMerit(test_info.GetTestPhenotype().GetMerit()); 
+    if (pc_phenotype & 2)
+      in_organism->GetPhenotype().SetGestationTime(test_info.GetTestPhenotype().GetGestationTime());
+    in_organism->GetPhenotype().SetFitness(in_organism->GetPhenotype().GetMerit().CalcFitness(in_organism->GetPhenotype().GetGestationTime()));
     delete test_cpu;
   }
   // Update the archive...

Modified: development/source/main/cPopulationCell.h
===================================================================
--- development/source/main/cPopulationCell.h	2007-07-25 22:18:40 UTC (rev 1850)
+++ development/source/main/cPopulationCell.h	2007-07-25 22:27:44 UTC (rev 1851)
@@ -83,6 +83,7 @@
   const cMutationRates & MutationRates() const { return *mutation_rates; }
   cMutationRates & MutationRates() { return *mutation_rates; }
   int GetInput(int);
+  tArray<int> GetInputs() {return input_array;}
   int GetInputAt(int & input_pointer);
   int GetInputSize() { return input_array.GetSize(); }
   void ResetInputs(cAvidaContext& ctx);

Modified: development/source/main/cPopulationInterface.cc
===================================================================
--- development/source/main/cPopulationInterface.cc	2007-07-25 22:18:40 UTC (rev 1850)
+++ development/source/main/cPopulationInterface.cc	2007-07-25 22:27:44 UTC (rev 1851)
@@ -92,6 +92,11 @@
   m_world->GetPopulation().GetCell(m_cell_id).ResetInputs(ctx); 
 }
 
+tArray<int> cPopulationInterface::GetInputs()
+{
+  return m_world->GetPopulation().GetCell(m_cell_id).GetInputs();
+}
+
 int cPopulationInterface::Debug()
 {
   cPopulationCell & cell = m_world->GetPopulation().GetCell(m_cell_id);

Modified: development/source/main/cPopulationInterface.h
===================================================================
--- development/source/main/cPopulationInterface.h	2007-07-25 22:18:40 UTC (rev 1850)
+++ development/source/main/cPopulationInterface.h	2007-07-25 22:27:44 UTC (rev 1851)
@@ -64,6 +64,7 @@
   void Breakpoint() { m_world->GetDriver().SignalBreakpoint(); }
   int GetInputAt(int& input_pointer);
   void ResetInputs(cAvidaContext& ctx);
+  tArray<int> GetInputs();
   int Debug();
   const tArray<double>& GetResources();
   void UpdateResources(const tArray<double>& res_change);




More information about the Avida-cvs mailing list