[Avida-cvs] [avida-svn] r776 - in development: Avida.xcodeproj source/actions source/event source/main

brysonda@myxo.css.msu.edu brysonda at myxo.css.msu.edu
Mon Jun 26 05:53:49 PDT 2006


Author: brysonda
Date: 2006-06-26 08:53:49 -0400 (Mon, 26 Jun 2006)
New Revision: 776

Added:
   development/source/actions/PopulationActions.cc
   development/source/actions/PopulationActions.h
Modified:
   development/Avida.xcodeproj/project.pbxproj
   development/source/actions/CMakeLists.txt
   development/source/actions/PrintActions.cc
   development/source/actions/SConscript
   development/source/actions/cActionLibrary.cc
   development/source/event/cEventManager.cc
   development/source/main/cPopulation.cc
   development/source/main/cPopulation.h
Log:
Add in Population Actions, transitioning several inject commands.  Lay basic framework for new parasite inject.

Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj	2006-06-25 22:30:42 UTC (rev 775)
+++ development/Avida.xcodeproj/project.pbxproj	2006-06-26 12:53:49 UTC (rev 776)
@@ -202,6 +202,10 @@
 		70B08B9308FB2E6B00FC65FE /* cWeightedIndex.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B08B9108FB2E6B00FC65FE /* cWeightedIndex.cc */; };
 		70B08B9408FB2E6B00FC65FE /* cTools.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B08B9008FB2E6B00FC65FE /* cTools.cc */; };
 		70B08B9508FB2E6B00FC65FE /* cWeightedIndex.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B08B9108FB2E6B00FC65FE /* cWeightedIndex.cc */; };
+		70C054ED0A4F6FD2002703C1 /* PopulationActions.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C054C90A4F6E19002703C1 /* PopulationActions.cc */; };
+		70C054F80A4F704D002703C1 /* PopulationActions.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C054C90A4F6E19002703C1 /* PopulationActions.cc */; };
+		70C054F90A4F704E002703C1 /* SaveLoadActions.cc in Sources */ = {isa = PBXBuildFile; fileRef = 708051A80A1F65FE00CBB8B6 /* SaveLoadActions.cc */; };
+		70C054FA0A4F7053002703C1 /* PopulationActions.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C054C90A4F6E19002703C1 /* PopulationActions.cc */; };
 		70C1EF4808C393BA00F50912 /* cCodeLabel.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1EF4608C393BA00F50912 /* cCodeLabel.cc */; };
 		70C1EF4A08C393BA00F50912 /* cCodeLabel.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1EF4608C393BA00F50912 /* cCodeLabel.cc */; };
 		70C1EF5908C3948C00F50912 /* cCPUMemory.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1EF5808C3948C00F50912 /* cCPUMemory.cc */; };
@@ -755,6 +759,12 @@
 		70B08B9008FB2E6B00FC65FE /* cTools.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cTools.cc; sourceTree = "<group>"; };
 		70B08B9108FB2E6B00FC65FE /* cWeightedIndex.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cWeightedIndex.cc; sourceTree = "<group>"; };
 		70B3984E0947B29D0018F09D /* tManagedPointerArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tManagedPointerArray.h; sourceTree = "<group>"; };
+		70C054C80A4F6E19002703C1 /* PopulationActions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PopulationActions.h; sourceTree = "<group>"; };
+		70C054C90A4F6E19002703C1 /* PopulationActions.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PopulationActions.cc; sourceTree = "<group>"; };
+		70C054F10A4F6FF1002703C1 /* SConscript */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SConscript; sourceTree = "<group>"; };
+		70C054F50A4F701B002703C1 /* SConscript */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SConscript; sourceTree = "<group>"; };
+		70C054F60A4F7030002703C1 /* SConscript */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SConscript; sourceTree = "<group>"; };
+		70C054F70A4F703D002703C1 /* SConscript */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SConscript; sourceTree = "<group>"; };
 		70C1EF4608C393BA00F50912 /* cCodeLabel.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cCodeLabel.cc; sourceTree = "<group>"; };
 		70C1EF4708C393BA00F50912 /* cCodeLabel.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cCodeLabel.h; sourceTree = "<group>"; };
 		70C1EF5808C3948C00F50912 /* cCPUMemory.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cCPUMemory.cc; sourceTree = "<group>"; };
@@ -1001,6 +1011,7 @@
 		70422A1B091B141000A5E67F /* analyze */ = {
 			isa = PBXGroup;
 			children = (
+				70C054F50A4F701B002703C1 /* SConscript */,
 				70F7DE76092967A8009E311D /* cGenotypeBatch.h */,
 				70422A44091B1B8500A5E67F /* CMakeLists.txt */,
 				70422A1C091B141000A5E67F /* cAnalyze.cc */,
@@ -1029,6 +1040,7 @@
 		707AEEEE09E80699001AEA89 /* actions */ = {
 			isa = PBXGroup;
 			children = (
+				70C054F10A4F6FF1002703C1 /* SConscript */,
 				707AF0F809EACC5E001AEA89 /* CMakeLists.txt */,
 				707AEEEF09E80725001AEA89 /* cAction.h */,
 				707AEEFE09E83381001AEA89 /* cActionLibrary.h */,
@@ -1039,6 +1051,8 @@
 				708051A70A1F65FE00CBB8B6 /* SaveLoadActions.h */,
 				708051A80A1F65FE00CBB8B6 /* SaveLoadActions.cc */,
 				708051BA0A1F66B400CBB8B6 /* cActionLibrary.cc */,
+				70C054C80A4F6E19002703C1 /* PopulationActions.h */,
+				70C054C90A4F6E19002703C1 /* PopulationActions.cc */,
 			);
 			path = actions;
 			sourceTree = "<group>";
@@ -1227,6 +1241,7 @@
 		70F7D8C8092546DC009E311D /* classification */ = {
 			isa = PBXGroup;
 			children = (
+				70C054F60A4F7030002703C1 /* SConscript */,
 				705333E5092A4B7C006BD186 /* cLineage.cc */,
 				705333E6092A4B7C006BD186 /* cLineage.h */,
 				70533363092A3DF4006BD186 /* cInjectGenotype_BirthData.h */,
@@ -1299,6 +1314,7 @@
 		DCC30F7C0762539D008F7A48 /* cpu */ = {
 			isa = PBXGroup;
 			children = (
+				70C054F70A4F703D002703C1 /* SConscript */,
 				70C1EF4608C393BA00F50912 /* cCodeLabel.cc */,
 				70C1EF4708C393BA00F50912 /* cCodeLabel.h */,
 				70C1EF5808C3948C00F50912 /* cCPUMemory.cc */,
@@ -1963,6 +1979,7 @@
 				705ACD630A1403A5002D5BA0 /* PrintActions.cc in Sources */,
 				708051BD0A1F66B400CBB8B6 /* cActionLibrary.cc in Sources */,
 				E626209E0A372C2A00C07685 /* SaveLoadActions.cc in Sources */,
+				70C054FA0A4F7053002703C1 /* PopulationActions.cc in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -2093,6 +2110,8 @@
 				707AF0B309EAC801001AEA89 /* LandscapeActions.cc in Sources */,
 				705ACD640A1403AA002D5BA0 /* PrintActions.cc in Sources */,
 				708051BC0A1F66B400CBB8B6 /* cActionLibrary.cc in Sources */,
+				70C054F80A4F704D002703C1 /* PopulationActions.cc in Sources */,
+				70C054F90A4F704E002703C1 /* SaveLoadActions.cc in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -2205,6 +2224,7 @@
 				705ACD4F0A13FED5002D5BA0 /* PrintActions.cc in Sources */,
 				708051B20A1F663100CBB8B6 /* SaveLoadActions.cc in Sources */,
 				708051BB0A1F66B400CBB8B6 /* cActionLibrary.cc in Sources */,
+				70C054ED0A4F6FD2002703C1 /* PopulationActions.cc in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: development/source/actions/CMakeLists.txt
===================================================================
--- development/source/actions/CMakeLists.txt	2006-06-25 22:30:42 UTC (rev 775)
+++ development/source/actions/CMakeLists.txt	2006-06-26 12:53:49 UTC (rev 776)
@@ -3,6 +3,7 @@
 SET(libactions_a_SOURCES
   cActionLibrary.cc
   LandscapeActions.cc
+  PopulationActions.cc
   PrintActions.cc
   SaveLoadActions.cc
 )

Added: development/source/actions/PopulationActions.cc
===================================================================
--- development/source/actions/PopulationActions.cc	2006-06-25 22:30:42 UTC (rev 775)
+++ development/source/actions/PopulationActions.cc	2006-06-26 12:53:49 UTC (rev 776)
@@ -0,0 +1,244 @@
+/*
+ *  PopulationActions.cc
+ *  Avida
+ *
+ *  Created by David on 6/25/06.
+ *  Copyright 2006 Michigan State University. All rights reserved.
+ *
+ */
+
+#include "PopulationActions.h"
+
+#include "cAction.h"
+#include "cActionLibrary.h"
+#include "cGenome.h"
+#include "cHardwareManager.h"
+#include "cInstUtil.h"
+#include "cPopulation.h"
+#include "cWorld.h"
+
+
+/*
+ Injects a single organism into the population.
+ 
+ Parameters:
+   filename (string)
+     The filename of the genotype to load. If this is left empty, or the keyword
+     "START_CREATURE" is given, than the genotype specified in the genesis
+     file under "START_CREATURE" is used.
+   cell ID (integer) default: 0
+     The grid-point into which the organism should be placed.
+   merit (double) default: -1
+     The initial merit of the organism. If set to -1, this is ignored.
+   lineage label (integer) default: 0
+     An integer that marks all descendants of this organism.
+   neutral metric (double) default: 0
+     A double value that randomly drifts over time.
+*/
+class cActionInject : public cAction
+{
+private:
+  cString m_filename;
+  int m_cell_id;
+  double m_merit;
+  int m_lineage_label;
+  double m_neutral_metric;
+public:
+  cActionInject(cWorld* world, const cString& args) : cAction(world, args), m_cell_id(0), m_merit(-1), m_lineage_label(0), m_neutral_metric(0)
+  {
+    cString largs(args);
+    if (!largs.GetSize()) m_filename = "START_CREATURE"; else m_filename = largs.PopWord();
+    if (largs.GetSize()) m_cell_id = largs.PopWord().AsInt();
+    if (largs.GetSize()) m_merit = largs.PopWord().AsDouble();
+    if (largs.GetSize()) m_lineage_label = largs.PopWord().AsInt();
+    if (largs.GetSize()) m_neutral_metric = largs.PopWord().AsDouble();
+
+    if (m_filename == "START_CREATURE") m_filename = m_world->GetConfig().START_CREATURE.Get();
+}
+  
+  const cString GetDescription() { return "Inject [cString fname=\"START_CREATURE\"] [int cell_id=0] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]"; }
+
+  void Process(cAvidaContext& ctx)
+  {
+    cGenome genome = cInstUtil::LoadGenome(m_filename, m_world->GetHardwareManager().GetInstSet());
+    m_world->GetPopulation().Inject(genome, m_cell_id, m_merit, m_lineage_label, m_neutral_metric);
+  }
+};
+
+
+/*
+ Injects identical organisms into all cells of the population.
+ 
+ Parameters:
+   filename (string)
+     The filename of the genotype to load. If this is left empty, or the keyword
+     "START_CREATURE" is given, than the genotype specified in the genesis
+     file under "START_CREATURE" is used.
+   cell ID (integer) default: 0
+     The grid-point into which the organism should be placed.
+   merit (double) default: -1
+     The initial merit of the organism. If set to -1, this is ignored.
+   lineage label (integer) default: 0
+     An integer that marks all descendants of this organism.
+   neutral metric (double) default: 0
+     A double value that randomly drifts over time.
+*/
+class cActionInjectAll : public cAction
+{
+private:
+  cString m_filename;
+  double m_merit;
+  int m_lineage_label;
+  double m_neutral_metric;
+public:
+  cActionInjectAll(cWorld* world, const cString& args) : cAction(world, args), m_merit(-1), m_lineage_label(0), m_neutral_metric(0)
+  {
+    cString largs(args);
+    if (!largs.GetSize()) m_filename = "START_CREATURE"; else m_filename = largs.PopWord();
+    if (largs.GetSize()) m_merit = largs.PopWord().AsDouble();
+    if (largs.GetSize()) m_lineage_label = largs.PopWord().AsInt();
+    if (largs.GetSize()) m_neutral_metric = largs.PopWord().AsDouble();
+    
+    if (m_filename == "START_CREATURE") m_filename = m_world->GetConfig().START_CREATURE.Get();
+  }
+  
+  const cString GetDescription() { return "InjectAll [cString fname=\"START_CREATURE\"] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]"; }
+  
+  void Process(cAvidaContext& ctx)
+  {
+    cGenome genome = cInstUtil::LoadGenome(m_filename, m_world->GetHardwareManager().GetInstSet());
+    for (int i = 0; i < m_world->GetPopulation().GetSize(); i++)
+      m_world->GetPopulation().Inject(genome, i, m_merit, m_lineage_label, m_neutral_metric);
+  }
+};
+
+/*
+ Injects identical organisms into a range of cells of the population.
+ 
+ Parameters:
+   filename (string)
+     The filename of the genotype to load. If this is left empty, or the keyword
+     "START_CREATURE" is given, than the genotype specified in the genesis
+     file under "START_CREATURE" is used.
+   cell_start (int)
+     First cell to inject into.
+   cell_end (int)
+     First cell *not* to inject into.
+   merit (double) default: -1
+     The initial merit of the organism. If set to -1, this is ignored.
+   lineage label (integer) default: 0
+     An integer that marks all descendants of this organism.
+   neutral metric (double) default: 0
+     A double value that randomly drifts over time.
+*/
+class cActionInjectRange : public cAction
+{
+private:
+  cString m_filename;
+  int m_cell_start;
+  int m_cell_end;
+  double m_merit;
+  int m_lineage_label;
+  double m_neutral_metric;
+public:
+  cActionInjectRange(cWorld* world, const cString& args) : cAction(world, args), m_cell_start(0), m_cell_end(-1), m_merit(-1), m_lineage_label(0), m_neutral_metric(0)
+  {
+    cString largs(args);
+    if (!largs.GetSize()) m_filename = "START_CREATURE"; else m_filename = largs.PopWord();
+    if (largs.GetSize()) m_cell_start = largs.PopWord().AsInt();
+    if (largs.GetSize()) m_cell_end = largs.PopWord().AsInt();
+    if (largs.GetSize()) m_merit = largs.PopWord().AsDouble();
+    if (largs.GetSize()) m_lineage_label = largs.PopWord().AsInt();
+    if (largs.GetSize()) m_neutral_metric = largs.PopWord().AsDouble();
+    
+    if (m_filename == "START_CREATURE") m_filename = m_world->GetConfig().START_CREATURE.Get();
+    if (m_cell_end == -1) m_cell_end = m_cell_start + 1;
+  }
+  
+  const cString GetDescription() { return "InjectRange [cString fname=\"START_CREATURE\"] [int cell_start=0] [int cell_end=-1] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]"; }
+  
+  void Process(cAvidaContext& ctx)
+  {
+    cGenome genome = cInstUtil::LoadGenome(m_filename, m_world->GetHardwareManager().GetInstSet());
+    if (m_cell_start < 0 || m_cell_end > m_world->GetPopulation().GetSize() || m_cell_start >= m_cell_end) {
+      m_world->GetDriver().NotifyWarning("InjectRange has invalid range!");
+    } else {
+      for (int i = m_cell_start; i < m_cell_end; i++) {
+        m_world->GetPopulation().Inject(genome, i, m_merit, m_lineage_label, m_neutral_metric);
+      }
+      m_world->GetPopulation().SetSyncEvents(true);
+    }
+  }
+};
+
+
+/*
+ Injects identical parasites into a range of cells of the population.
+ 
+ Parameters:
+   filename (string)
+     The filename of the genotype to load.
+   cell_start (int)
+     First cell to inject into.
+   cell_end (int)
+     First cell *not* to inject into.
+   merit (double) default: -1
+     The initial merit of the organism. If set to -1, this is ignored.
+   lineage label (integer) default: 0
+     An integer that marks all descendants of this organism.
+   neutral metric (double) default: 0
+     A double value that randomly drifts over time.
+*/
+class cActionInjectParasiteRange : public cAction
+{
+private:
+  cString m_filename;
+  int m_cell_start;
+  int m_cell_end;
+  double m_merit;
+  int m_lineage_label;
+  double m_neutral_metric;
+public:
+  cActionInjectParasiteRange(cWorld* world, const cString& args) : cAction(world, args), m_cell_start(0), m_cell_end(-1), m_merit(-1), m_lineage_label(0), m_neutral_metric(0)
+  {
+      cString largs(args);
+      if (!largs.GetSize()) m_filename = "default.para"; else m_filename = largs.PopWord();
+      if (largs.GetSize()) m_cell_start = largs.PopWord().AsInt();
+      if (largs.GetSize()) m_cell_end = largs.PopWord().AsInt();
+      if (largs.GetSize()) m_merit = largs.PopWord().AsDouble();
+      if (largs.GetSize()) m_lineage_label = largs.PopWord().AsInt();
+      if (largs.GetSize()) m_neutral_metric = largs.PopWord().AsDouble();
+      
+      if (m_cell_end == -1) m_cell_end = m_cell_start + 1;
+  }
+  
+  const cString GetDescription() { return "InjectRange <cString filename=\"START_CREATURE\"> [int cell_start=0] [int cell_end=-1] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]"; }
+  
+  void Process(cAvidaContext& ctx)
+  {
+    cGenome genome = cInstUtil::LoadGenome(m_filename, m_world->GetHardwareManager().GetInstSet());
+    if (m_cell_start < 0 || m_cell_end > m_world->GetPopulation().GetSize() || m_cell_start >= m_cell_end) {
+      m_world->GetDriver().NotifyWarning("InjectParasiteRange has invalid range!");
+    } else {
+      for (int i = m_cell_start; i < m_cell_end; i++) {
+        // @DMB 
+      }
+      m_world->GetPopulation().SetSyncEvents(true);
+    }
+  }
+};
+
+
+
+void RegisterPopulationActions(cActionLibrary* action_lib)
+{
+  action_lib->Register<cActionInject>("Inject");
+  action_lib->Register<cActionInjectAll>("InjectAll");
+  action_lib->Register<cActionInjectRange>("InjectRange");
+
+
+  // @DMB - The following actions are DEPRECATED aliases - These will be removed in 2.7.
+  action_lib->Register<cActionInject>("inject");
+  action_lib->Register<cActionInjectAll>("inject_all");
+  action_lib->Register<cActionInjectRange>("inject_range");
+}

Added: development/source/actions/PopulationActions.h
===================================================================
--- development/source/actions/PopulationActions.h	2006-06-25 22:30:42 UTC (rev 775)
+++ development/source/actions/PopulationActions.h	2006-06-26 12:53:49 UTC (rev 776)
@@ -0,0 +1,17 @@
+/*
+ *  PopulationActions.h
+ *  Avida
+ *
+ *  Created by David on 6/25/06.
+ *  Copyright 2006 Michigan State University. All rights reserved.
+ *
+ */
+
+#ifndef PopulationActions_h
+#define PopulationActions_h
+
+class cActionLibrary;
+
+void RegisterPopulationActions(cActionLibrary* action_lib);
+
+#endif

Modified: development/source/actions/PrintActions.cc
===================================================================
--- development/source/actions/PrintActions.cc	2006-06-25 22:30:42 UTC (rev 775)
+++ development/source/actions/PrintActions.cc	2006-06-26 12:53:49 UTC (rev 776)
@@ -96,7 +96,7 @@
     m_format = largs.PopWord();
   }
   
-  const cString GetDescription() { return "PringData <cString fname> <cString format>"; }
+  const cString GetDescription() { return "PrintData <cString fname> <cString format>"; }
 
   void Process(cAvidaContext& ctx)
   {

Modified: development/source/actions/SConscript
===================================================================
--- development/source/actions/SConscript	2006-06-25 22:30:42 UTC (rev 775)
+++ development/source/actions/SConscript	2006-06-26 12:53:49 UTC (rev 776)
@@ -7,6 +7,7 @@
   'cAction.h',
   'cActionLibrary.h',
   'LandscapeActions.h',
+  'PopulationActions.h',
   'PrintActions.h',
   'SaveLoadActions.h',
 ]
@@ -14,6 +15,7 @@
 srcs = [
   'cActionLibrary.cc',
   'LandscapeActions.cc',
+  'PopulationActions.cc',
   'PrintActions.cc',
   'SaveLoadActions.cc',
 ]

Modified: development/source/actions/cActionLibrary.cc
===================================================================
--- development/source/actions/cActionLibrary.cc	2006-06-25 22:30:42 UTC (rev 775)
+++ development/source/actions/cActionLibrary.cc	2006-06-26 12:53:49 UTC (rev 776)
@@ -10,6 +10,7 @@
 #include "cActionLibrary.h"
 
 #include "LandscapeActions.h"
+#include "PopulationActions.h"
 #include "PrintActions.h"
 #include "SaveLoadActions.h"
 
@@ -19,6 +20,7 @@
   cActionLibrary* actlib = new cActionLibrary();
 
   RegisterLandscapeActions(actlib);
+  RegisterPopulationActions(actlib);
   RegisterPrintActions(actlib);
   RegisterSaveLoadActions(actlib);
   

Modified: development/source/event/cEventManager.cc
===================================================================
--- development/source/event/cEventManager.cc	2006-06-25 22:30:42 UTC (rev 775)
+++ development/source/event/cEventManager.cc	2006-06-26 12:53:49 UTC (rev 776)
@@ -190,182 +190,6 @@
 
 
 
-
-///// inject /////
-
-/**
-* Injects a single organism into the population.
- *
- * Parameters:
- * filename (string)
- *   The filename of the genotype to load. If this is left empty, or the keyword
- *   "START_CREATURE" is given, than the genotype specified in the genesis
- *   file under "START_CREATURE" is used.
- * cell ID (integer) default: 0
-   *   The grid-point into which the organism should be placed.
-   * merit (double) default: -1
-     *   The initial merit of the organism. If set to -1, this is ignored.
-     * lineage label (integer) default: 0
-       *   An integer that marks all descendants of this organism.
-       * neutral metric (double) default: 0
-         *   A double value that randomly drifts over time.
-         **/
-
-
-class cEvent_inject : public cEvent {
-private:
-  cString fname;
-  int cell_id;
-  double merit;
-  int lineage_label;
-  double neutral_metric;
-public:
-    const cString GetName() const { return "inject"; }
-  const cString GetDescription() const { return "inject  [cString fname=\"START_CREATURE\"] [int cell_id=0] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]"; }
-  
-  void Configure(cWorld* world, const cString& in_args)
-  {
-    m_world = world;
-    m_args = in_args;
-    cString args(in_args);
-    if (args == "") fname="START_CREATURE"; else fname=args.PopWord();
-    if (args == "") cell_id=0; else cell_id=args.PopWord().AsInt();
-    if (args == "") merit=-1; else merit=args.PopWord().AsDouble();
-    if (args == "") lineage_label=0; else lineage_label=args.PopWord().AsInt();
-    if (args == "") neutral_metric=0; else neutral_metric=args.PopWord().AsDouble();
-  }
-  ///// inject /////
-  void Process(){
-    if (fname == "START_CREATURE") fname = m_world->GetConfig().START_CREATURE.Get();
-    cGenome genome =
-      cInstUtil::LoadGenome(fname, m_world->GetHardwareManager().GetInstSet());
-    m_world->GetPopulation().Inject(genome, cell_id, merit, lineage_label, neutral_metric);
-  }
-};
-
-///// inject_all /////
-
-/**
-* Injects identical organisms into all cells of the population.
- *
- * Parameters:
- * filename (string)
- *   The filename of the genotype to load. If this is left empty, or the keyword
- *   "START_CREATURE" is given, than the genotype specified in the genesis
- *   file under "START_CREATURE" is used.
- * merit (double) default: -1
-   *   The initial merit of the organism. If set to -1, this is ignored.
-   * lineage label (integer) default: 0
-     *   An integer that marks all descendants of this organism.
-     * neutral metric (double) default: 0
-       *   A double value that randomly drifts over time.
-       **/
-
-
-class cEvent_inject_all : public cEvent {
-private:
-  cString fname;
-  double merit;
-  int lineage_label;
-  double neutral_metric;
-public:
-    const cString GetName() const { return "inject_all"; }
-  const cString GetDescription() const { return "inject_all  [cString fname=\"START_CREATURE\"] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]"; }
-  
-  void Configure(cWorld* world, const cString& in_args)
-  {
-    m_world = world;
-    m_args = in_args;
-    cString args(in_args);
-    if (args == "") fname="START_CREATURE"; else fname=args.PopWord();
-    if (args == "") merit=-1; else merit=args.PopWord().AsDouble();
-    if (args == "") lineage_label=0; else lineage_label=args.PopWord().AsInt();
-    if (args == "") neutral_metric=0; else neutral_metric=args.PopWord().AsDouble();
-  }
-  ///// inject_all /////
-  void Process(){
-    if (fname == "START_CREATURE") fname = m_world->GetConfig().START_CREATURE.Get();
-    cGenome genome =
-      cInstUtil::LoadGenome(fname, m_world->GetHardwareManager().GetInstSet());
-    for (int i = 0; i < m_world->GetPopulation().GetSize(); i++) {
-      m_world->GetPopulation().Inject(genome, i, merit, lineage_label, neutral_metric);
-    }
-    m_world->GetPopulation().SetSyncEvents(true);
-  }
-};
-
-///// inject_range /////
-
-/**
-* Injects identical organisms into a range of cells of the population.
- *
- * Parameters:
- * filename (string)
- *   The filename of the genotype to load. If this is left empty, or the keyword
- *   "START_CREATURE" is given, than the genotype specified in the genesis
- *   file under "START_CREATURE" is used.
- * start_cell (int)
- *   First cell to inject into.
- * stop_cell (int)
- *   First cell *not* to inject into.
- * merit (double) default: -1
-   *   The initial merit of the organism. If set to -1, this is ignored.
-   * lineage label (integer) default: 0
-     *   An integer that marks all descendants of this organism.
-     * neutral metric (double) default: 0
-       *   A double value that randomly drifts over time.
-       *
-       * Example:
-       *   inject_range creature.gen 0 10
-       *
-       * Will inject 10 organisms into cells 0 through 9.
-       **/
-
-
-class cEvent_inject_range : public cEvent {
-private:
-  cString fname;
-  int start_cell;
-  int end_cell;
-  double merit;
-  int lineage_label;
-  double neutral_metric;
-public:
-    const cString GetName() const { return "inject_range"; }
-  const cString GetDescription() const { return "inject_range  [cString fname=\"START_CREATURE\"] [int start_cell=0] [int end_cell=-1] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]"; }
-  
-  void Configure(cWorld* world, const cString& in_args)
-  {
-    m_world = world;
-    m_args = in_args;
-    cString args(in_args);
-    if (args == "") fname="START_CREATURE"; else fname=args.PopWord();
-    if (args == "") start_cell=0; else start_cell=args.PopWord().AsInt();
-    if (args == "") end_cell=-1; else end_cell=args.PopWord().AsInt();
-    if (args == "") merit=-1; else merit=args.PopWord().AsDouble();
-    if (args == "") lineage_label=0; else lineage_label=args.PopWord().AsInt();
-    if (args == "") neutral_metric=0; else neutral_metric=args.PopWord().AsDouble();
-  }
-  ///// inject_range /////
-  void Process(){
-    if (fname == "START_CREATURE") fname = m_world->GetConfig().START_CREATURE.Get();
-    if (end_cell == -1) end_cell = start_cell + 1;
-    if (start_cell < 0 ||
-        end_cell > m_world->GetPopulation().GetSize() ||
-        start_cell >= end_cell) {
-      m_world->GetDriver().NotifyWarning("inject_range has invalid range!");
-    }
-    else {
-      cGenome genome =
-      cInstUtil::LoadGenome(fname, m_world->GetHardwareManager().GetInstSet());
-      for (int i = start_cell; i < end_cell; i++) {
-        m_world->GetPopulation().Inject(genome, i, merit, lineage_label, neutral_metric);
-      }
-      m_world->GetPopulation().SetSyncEvents(true);
-    }
-  }
-};
-
 ///// inject_sequence /////
 
 /**
@@ -487,80 +311,7 @@
   }
 };
 
-///// inject_range_parasite /////
 
-/**
-* Injects identical organisms into a range of cells of the population.
- *
- * Parameters:
- * filename (string)
- *   The filename of the genotype to load. If this is left empty, or the keyword
- *   "START_CREATURE" is given, than the genotype specified in the genesis
- *   file under "START_CREATURE" is used.
- * start_cell (int)
- *   First cell to inject into.
- * stop_cell (int)
- *   First cell *not* to inject into.
- * merit (double) default: -1
-   *   The initial merit of the organism. If set to -1, this is ignored.
-   * lineage label (integer) default: 0
-     *   An integer that marks all descendants of this organism.
-     * neutral metric (double) default: 0
-       *   A double value that randomly drifts over time.
-       *
-       * Example:
-       *   inject_range creature.gen 0 10
-       *
-       * Will inject 10 organisms into cells 0 through 9.
-       **/
-
-
-class cEvent_inject_range_parasite : public cEvent {
-private:
-  cString fname_parasite;
-  int start_cell;
-  int end_cell;
-  double merit;
-  int lineage_label;
-  double neutral_metric;
-  int mem_space;
-public:
-    const cString GetName() const { return "inject_range_parasite"; }
-  const cString GetDescription() const { return "inject_range_parasite  [cString fname_parasite=\"organism.parasite\"] [int start_cell=0] [int end_cell=-1] [double merit=-1] [int lineage_label=0] [double neutral_metric=0] [int mem_space=2]"; }
-  
-  void Configure(cWorld* world, const cString& in_args)
-  {
-    m_world = world;
-    m_args = in_args;
-    cString args(in_args);
-    if (args == "") fname_parasite="organism.parasite"; else fname_parasite=args.PopWord();
-    if (args == "") start_cell=0; else start_cell=args.PopWord().AsInt();
-    if (args == "") end_cell=-1; else end_cell=args.PopWord().AsInt();
-    if (args == "") merit=-1; else merit=args.PopWord().AsDouble();
-    if (args == "") lineage_label=0; else lineage_label=args.PopWord().AsInt();
-    if (args == "") neutral_metric=0; else neutral_metric=args.PopWord().AsDouble();
-    if (args == "") mem_space=2; else mem_space=args.PopWord().AsInt();
-  }
-  ///// inject_range_parasite /////
-  void Process(){
-    if (fname_parasite == "START_CREATURE") fname_parasite = m_world->GetConfig().START_CREATURE.Get();
-    if (end_cell == -1) end_cell = start_cell + 1;
-    if (start_cell < 0 ||
-        end_cell > m_world->GetPopulation().GetSize() ||
-        start_cell >= end_cell) {
-      m_world->GetDriver().NotifyWarning("inject_range has invalid range!");
-    }
-    else {
-      cGenome genome_parasite =
-      cInstUtil::LoadGenome(fname_parasite, m_world->GetHardwareManager().GetInstSet());
-      for (int i = start_cell; i < end_cell; i++) {
-        m_world->GetPopulation().Inject(genome_parasite, i, merit, lineage_label, neutral_metric, mem_space);
-      }
-      m_world->GetPopulation().SetSyncEvents(true);
-    }
-  }
-};
-
 ///// inject_range_pair /////
 
 /**
@@ -633,7 +384,7 @@
         cInstUtil::LoadGenome(fname_parasite, m_world->GetHardwareManager().GetInstSet());
       for (int i = start_cell; i < end_cell; i++) {
         m_world->GetPopulation().Inject(genome, i, merit, lineage_label, neutral_metric);
-        m_world->GetPopulation().Inject(genome_parasite, i, merit, lineage_label, neutral_metric, mem_space);
+// @DMB        m_world->GetPopulation().Inject(genome_parasite, i, merit, lineage_label, neutral_metric, mem_space);
       }
       m_world->GetPopulation().SetSyncEvents(true);
     }
@@ -2474,12 +2225,8 @@
   REGISTER(exit_if_ave_lineage_label_smaller);
   REGISTER(exit_if_ave_lineage_label_larger);
   
-  REGISTER(inject);
-  REGISTER(inject_all);
-  REGISTER(inject_range);
   REGISTER(inject_sequence);
   REGISTER(inject_random);
-  REGISTER(inject_range_parasite);
   REGISTER(inject_range_pair);
   REGISTER(zero_muts);
   REGISTER(mod_copy_mut);

Modified: development/source/main/cPopulation.cc
===================================================================
--- development/source/main/cPopulation.cc	2006-06-25 22:30:42 UTC (rev 775)
+++ development/source/main/cPopulation.cc	2006-06-26 12:53:49 UTC (rev 776)
@@ -388,23 +388,6 @@
   return true;
 }
 
-bool cPopulation::ActivateInject(const int cell_id, const cGenome& injected_code)
-{
-  cInjectGenotype* child_genotype = m_world->GetClassificationManager().GetInjectGenotype(injected_code);
-  cHardwareBase& child_cpu = cell_array[cell_id].GetOrganism()->GetHardware();
-  if(cell_array[cell_id].GetOrganism()->InjectHost(cCodeLabel(), injected_code))
-  {
-    cell_array[cell_id].GetOrganism()->AddParasite(child_genotype);
-    child_genotype->AddParasite();
-    child_cpu.ThreadSetOwner(child_genotype);
-    m_world->GetClassificationManager().AdjustInjectGenotype(*child_genotype);
-  }
-  else
-    return false;
-  
-  return true;
-}
-
 void cPopulation::ActivateOrganism(cAvidaContext& ctx, cOrganism* in_organism, cPopulationCell& target_cell)
 {
   assert(in_organism != NULL);
@@ -1612,8 +1595,7 @@
  * this organism.
  **/
 
-void cPopulation::Inject(const cGenome & genome, int cell_id, double merit, 
-                         int lineage_label, double neutral, int mem_space )
+void cPopulation::Inject(const cGenome & genome, int cell_id, double merit, int lineage_label, double neutral)
 {
   // If an invalid cell was given, choose a new ID for it.
   if (cell_id < 0) {
@@ -1625,24 +1607,37 @@
     }
   }
   
-  if(mem_space==0) {
-    InjectGenome( cell_id, genome, lineage_label );
-    cPhenotype & phenotype = GetCell(cell_id).GetOrganism()->GetPhenotype();
-    phenotype.SetNeutralMetric(neutral);
+  InjectGenome(cell_id, genome, lineage_label);
+  cPhenotype& phenotype = GetCell(cell_id).GetOrganism()->GetPhenotype();
+  phenotype.SetNeutralMetric(neutral);
+  
+  if (merit > 0) phenotype.SetMerit(cMerit(merit));
+  schedule->Adjust(cell_id, phenotype.GetMerit());
+  
+  LineageSetupOrganism(GetCell(cell_id).GetOrganism(), 0, lineage_label);
+}
+
+void cPopulation::InjectParasite(const cCodeLabel& label, const cGenome& injected_code, int cell_id)
+{
+  cOrganism* target_organism = cell_array[cell_id].GetOrganism();
+  
+  if (target_organism == NULL) return;
+  
+  cHardwareBase& child_cpu = target_organism->GetHardware();
+  if (child_cpu.GetNumThreads() == m_world->GetConfig().MAX_CPU_THREADS.Get()) return;
+  
+  if (target_organism->InjectHost(label, injected_code)) {
+    cInjectGenotype* child_genotype = m_world->GetClassificationManager().GetInjectGenotype(injected_code, NULL);
     
-    if (merit > 0) phenotype.SetMerit( cMerit(merit) );
-    schedule->Adjust(cell_id, phenotype.GetMerit());
-    
-    LineageSetupOrganism(GetCell(cell_id).GetOrganism(), 0, lineage_label);
+    target_organism->AddParasite(child_genotype);
+    child_genotype->AddParasite();
+    child_cpu.ThreadSetOwner(child_genotype);
+    m_world->GetClassificationManager().AdjustInjectGenotype(*child_genotype);
   }
-  else
-  {
-    ActivateInject(cell_id, genome);
-  }
-  
 }
 
-cPopulationCell & cPopulation::GetCell(int in_num)
+
+cPopulationCell& cPopulation::GetCell(int in_num)
 {
   return cell_array[in_num];
 }

Modified: development/source/main/cPopulation.h
===================================================================
--- development/source/main/cPopulation.h	2006-06-25 22:30:42 UTC (rev 775)
+++ development/source/main/cPopulation.h	2006-06-26 12:53:49 UTC (rev 776)
@@ -121,12 +121,11 @@
   bool ActivateOffspring(cAvidaContext& ctx, cGenome& child_genome, cOrganism& parent_organism);
   bool ActivateParasite(cOrganism& parent, const cGenome& injected_code);
   
-  bool ActivateInject(const int cell_id, const cGenome& injected_code);
-
   // Inject an organism from the outside world.
   void Inject(const cGenome& genome, int cell_id = -1, double merit = -1, int lineage_label = 0,
-              double neutral_metric = 0, int mem_space = 0);
-
+              double neutral_metric = 0);
+  void InjectParasite(const cCodeLabel& label, const cGenome& injected_code, int cell_id);
+  
   // Deactivate an organism in the population (required for deactivations)
   void KillOrganism(cPopulationCell& in_cell);
   void Kaboom(cPopulationCell& in_cell);




More information about the Avida-cvs mailing list