[Avida-SVN] r1619 - in development: source source/cpu source/main support/config

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Sun May 27 12:18:50 PDT 2007


Author: brysonda
Date: 2007-05-27 15:18:50 -0400 (Sun, 27 May 2007)
New Revision: 1619

Modified:
   development/source/cpu/cHardwareTransSMT.cc
   development/source/defs.h
   development/source/main/cAvidaConfig.h
   development/source/main/cOrganism.cc
   development/source/main/cOrganism.h
   development/source/main/cPopulation.cc
   development/support/config/avida.cfg
Log:
- Add support for toggling whether the calling thread on inject is reset (i.e. the parasite).
- Cleanup TransSMT's BIRTH_METHOD handling.
- Wrap some long line in the avida.cfg
- Sync the shipped default avida.cfg with the current avida internal settings.

Modified: development/source/cpu/cHardwareTransSMT.cc
===================================================================
--- development/source/cpu/cHardwareTransSMT.cc	2007-05-27 18:14:18 UTC (rev 1618)
+++ development/source/cpu/cHardwareTransSMT.cc	2007-05-27 19:18:50 UTC (rev 1619)
@@ -181,6 +181,7 @@
   }
 #endif	
   
+  organism->ClearParasites();
   organism->NetReset();
 }
 
@@ -660,7 +661,6 @@
     return false; // (inject fails)
   }
   if (end_pos < MIN_INJECT_SIZE) {
-    m_mem_array[mem_space_used] = cGenome("a"); 
     organism->Fault(FAULT_LOC_INJECT, FAULT_TYPE_ERROR, "inject: new size too small");
     return false; // (inject fails)
   }  
@@ -676,8 +676,10 @@
   // reset the memory space that was injected
   m_mem_array[mem_space_used] = cGenome("a"); 
 	
-  for (int x = 0; x < nHardware::NUM_HEADS; x++) GetHead(x).Reset(this, IP().GetMemSpace());
-  for (int x = 0; x < NUM_LOCAL_STACKS; x++) Stack(x).Clear();
+  if (m_world->GetConfig().INJECT_METHOD.Get() == INJECT_METHOD_SPLIT) {
+    for (int x = 0; x < nHardware::NUM_HEADS; x++) GetHead(x).Reset(this, IP().GetMemSpace());
+    for (int x = 0; x < NUM_LOCAL_STACKS; x++) Stack(x).Clear();
+  }
   
   AdvanceIP() = false;
   
@@ -982,35 +984,27 @@
   //reset the memory of the memory space that has been divided off
   m_mem_array[mem_space_used] = cGenome("a"); 
 	
-  // 3 Division Methods:
-  // 1) DIVIDE_METHOD_OFFSPRING - Create a child, leave parent state untouched.
-  // 2) DIVIDE_METHOD_SPLIT - Create a child, completely reset state of parent.
-  // 3) DIVIDE_METHOD_BIRTH - Create a child, reset state of parent's current thread.
-  const int div_method = m_world->GetConfig().DIVIDE_METHOD.Get();
-  if (parent_alive && !(div_method == DIVIDE_METHOD_OFFSPRING))
-	{
-		
-		if (div_method == DIVIDE_METHOD_SPLIT)
-		{
-			//this will wipe out all parasites on a divide.
-			Reset();
-			
+  // Division Methods:
+  // 0 - DIVIDE_METHOD_OFFSPRING - Create a child, leave parent state untouched.
+  // 1 - DIVIDE_METHOD_SPLIT - Create a child, completely reset state of parent.
+  // 2 - DIVIDE_METHOD_BIRTH - Create a child, reset state of parent's current thread.
+  
+  if (parent_alive) { // If the parent is no longer alive, all of this is moot
+    switch (m_world->GetConfig().DIVIDE_METHOD.Get()) {
+      case DIVIDE_METHOD_SPLIT:
+        Reset();  // This will wipe out all parasites on a divide.
+        break;
+      
+      case DIVIDE_METHOD_BIRTH:
+        // Reset only the calling thread's state
+        for(int x = 0; x < nHardware::NUM_HEADS; x++) GetHead(x).Reset(this, 0);
+        for(int x = 0; x < NUM_LOCAL_STACKS; x++) Stack(x).Clear();
+        break;
+      
+      case DIVIDE_METHOD_OFFSPRING:
+      default:
+        break;
 		}
-		else if (div_method == DIVIDE_METHOD_BIRTH)
-		{
-			if((!organism->GetPhenotype().IsModified() && GetNumThreads() > 1) || GetNumThreads() > 2) {
-	      ThreadKill(m_cur_thread);
-	    } else {
-        //this will reset the current thread's heads and stacks.  It will 
-        //not touch any other threads or memory spaces (ie: parasites)
-	      for(int x = 0; x < nHardware::NUM_HEADS; x++) {
-					GetHead(x).Reset(this, 0);
-				}
-	      for(int x = 0; x < NUM_LOCAL_STACKS; x++) {
-					Stack(x).Clear();
-				}
-	    }
-		}
 		AdvanceIP() = false;
 	}
 	

Modified: development/source/defs.h
===================================================================
--- development/source/defs.h	2007-05-27 18:14:18 UTC (rev 1618)
+++ development/source/defs.h	2007-05-27 19:18:50 UTC (rev 1619)
@@ -76,13 +76,13 @@
 const int MARKET_SIZE = 10000;
 
 
-enum tFileType
+enum eFileType
 {
   FILE_TYPE_TEXT,
   FILE_TYPE_HTML
 };
 
-enum tHARDWARE_TYPE
+enum eHARDWARE_TYPE
 {
 	HARDWARE_TYPE_CPU_ORIGINAL = 0,
 	HARDWARE_TYPE_CPU_SMT,
@@ -91,14 +91,14 @@
 	HARDWARE_TYPE_CPU_GX
 };
 
-enum tTIMESLICE
+enum eTIMESLICE
 {
   SLICE_CONSTANT = 0,
   SLICE_PROB_MERIT,
   SLICE_INTEGRATED_MERIT
 };
 
-enum tPOSITION_CHILD
+enum ePOSITION_CHILD
 {
   POSITION_CHILD_RANDOM = 0,
   POSITION_CHILD_AGE,
@@ -114,34 +114,40 @@
 };
 const int NUM_LOCAL_POSITION_CHILD = POSITION_CHILD_FULL_SOUP_RANDOM;
 
-enum tDEATH_METHOD
+enum eDEATH_METHOD
 {
   DEATH_METHOD_OFF = 0,
   DEATH_METHOD_CONST,
   DEATH_METHOD_MULTIPLE
 };
 
-enum tALLOC_METHOD
+enum eALLOC_METHOD
 {
   ALLOC_METHOD_DEFAULT = 0,
   ALLOC_METHOD_NECRO,
   ALLOC_METHOD_RANDOM
 };
 
-enum tDIVIDE_METHOD
+enum eDIVIDE_METHOD
 {
   DIVIDE_METHOD_OFFSPRING = 0,
   DIVIDE_METHOD_SPLIT,
   DIVIDE_METHOD_BIRTH
 };
 
-enum tGENERATION_INCREMENT
+enum eINJECT_METHOD
 {
+  INJECT_METHOD_OFFSPRING = 0,
+  INJECT_METHOD_SPLIT
+};
+
+enum eGENERATION_INCREMENT
+{
   GENERATION_INC_OFFSPRING = 0,
   GENERATION_INC_BOTH
 };
 
-enum tBASE_MERIT
+enum eBASE_MERIT
 {
   BASE_MERIT_CONST = 0,
   BASE_MERIT_COPIED_SIZE,

Modified: development/source/main/cAvidaConfig.h
===================================================================
--- development/source/main/cAvidaConfig.h	2007-05-27 18:14:18 UTC (rev 1618)
+++ development/source/main/cAvidaConfig.h	2007-05-27 19:18:50 UTC (rev 1619)
@@ -227,6 +227,7 @@
   CONFIG_ADD_VAR(AGE_DEVIATION, int, 0, "Creates a distribution around AGE_LIMIT");
   CONFIG_ADD_VAR(ALLOC_METHOD, int, 0, "(Orignal CPU Only)\n0 = Allocated space is set to default instruction.\n1 = Set to section of dead genome (Necrophilia)\n2 = Allocated space is set to random instruction.");
   CONFIG_ADD_VAR(DIVIDE_METHOD, int, 1, "0 = Divide leaves state of mother untouched.\n1 = Divide resets state of mother\n    (after the divide, we have 2 children)\n2 = Divide resets state of current thread only\n    (does not touch possible parasite threads)");
+  CONFIG_ADD_VAR(INJECT_METHOD, int, 0, "0 = Leaves the parasite thread state untouched.\n1 = Resets the calling thread state on inject");
   CONFIG_ADD_VAR(GENERATION_INC_METHOD, int, 1, "0 = Only the generation of the child is\n    increased on divide.\n1 = Both the generation of the mother and child are\n    increased on divide (good with DIVIDE_METHOD 1).");
 
   CONFIG_ADD_GROUP(RECOMBINATION_GROUP, "Sexual Recombination and Modularity");
@@ -276,8 +277,8 @@
   CONFIG_ADD_VAR(STERILIZE_NEUTRAL, double, 0.0, "");
   CONFIG_ADD_VAR(STERILIZE_BENEFICIAL, double, 0.0, "");
   CONFIG_ADD_VAR(FAIL_IMPLICIT, int, 0, "Should copies that failed *not* due to mutations\nbe eliminated?");
-  CONFIG_ADD_VAR(NEUTRAL_MAX,double, 0.0, "The percent benifical change from parent fitness to be considered neutral.");
-  CONFIG_ADD_VAR(NEUTRAL_MIN,double, 0.0, "The percent deleterious change from parent fitness to be considered neutral.");
+  CONFIG_ADD_VAR(NEUTRAL_MAX,double, 0.0, "The percent benifical change from parent fitness\nto be considered neutral.");
+  CONFIG_ADD_VAR(NEUTRAL_MIN,double, 0.0, "The percent deleterious change from parent fitness\nto be considered neutral.");
   
   CONFIG_ADD_GROUP(TIME_GROUP, "Time Slicing");
   CONFIG_ADD_VAR(AVE_TIME_SLICE, int, 30, "Ave number of insts per org per update");
@@ -286,11 +287,11 @@
   CONFIG_ADD_VAR(BASE_CONST_MERIT, int, 100, "Base merit when BASE_MERIT_METHOD set to 0");
   CONFIG_ADD_VAR(DEFAULT_BONUS, double, 1.0, "Initial bonus before any tasks");
   CONFIG_ADD_VAR(MERIT_DEFAULT_BONUS, int, 0, "Scale the merit of an offspring by the default bonus\nrather than the accumulated bonus of the parent?"); 
-  CONFIG_ADD_VAR(MERIT_BONUS_INST, int, 0, "in BASE_MERIT_METHOD 6, this sets which instruction counts (-1=none, 0= 1st in INST_SET.)"); 
-  CONFIG_ADD_VAR(MERIT_BONUS_EFFECT, int, 0, "in BASE_MERIT_METHOD 6, this sets how much merit is earned per INST (-1=penalty, 0= no effect.)"); 
-  CONFIG_ADD_VAR(FITNESS_VALLEY, int, 0, "in BASE_MERIT_METHOD 6, this creates valleys from FITNESS_VALLEY_START to FITNESS_VALLEY_STOP (0= off, 1=on)"); 
-  CONFIG_ADD_VAR(FITNESS_VALLEY_START, int, 0, "if FITNESS_VALLEY =1, orgs with num_key_instructions from FITNESS_VALLEY_START to FITNESS_VALLEY_STOP get fitness 1 (lowest)"); 
-  CONFIG_ADD_VAR(FITNESS_VALLEY_STOP, int, 0, "if FITNESS_VALLEY =1, orgs with num_key_instructions from FITNESS_VALLEY_START to FITNESS_VALLEY_STOP get fitness 1 (lowest)"); 
+  CONFIG_ADD_VAR(MERIT_BONUS_INST, int, 0, "in BASE_MERIT_METHOD 6, this sets which instruction counts\n(-1 = none, 0 = First in INST_SET.)"); 
+  CONFIG_ADD_VAR(MERIT_BONUS_EFFECT, int, 0, "in BASE_MERIT_METHOD 6, this sets how much merit is earned\nper instruction (-1 = penalty, 0 = no effect.)"); 
+  CONFIG_ADD_VAR(FITNESS_VALLEY, int, 0, "in BASE_MERIT_METHOD 6, this creates valleys from\nFITNESS_VALLEY_START to FITNESS_VALLEY_STOP\n(0 = off, 1 = on)"); 
+  CONFIG_ADD_VAR(FITNESS_VALLEY_START, int, 0, "if FITNESS_VALLEY = 1, orgs with num_key_instructions\nfrom FITNESS_VALLEY_START to FITNESS_VALLEY_STOP\nget fitness 1 (lowest)"); 
+  CONFIG_ADD_VAR(FITNESS_VALLEY_STOP, int, 0, "if FITNESS_VALLEY = 1, orgs with num_key_instructions\nfrom FITNESS_VALLEY_START to FITNESS_VALLEY_STOP\nget fitness 1 (lowest)"); 
   CONFIG_ADD_VAR(MAX_CPU_THREADS, int, 1, "Number of Threads a CPU can spawn");
   CONFIG_ADD_VAR(THREAD_SLICING_METHOD, int, 0, "Formula for and organism's thread slicing\n  (num_threads-1) * THREAD_SLICING_METHOD + 1\n0 = One thread executed per time slice.\n1 = All threads executed each time slice.\n");
   CONFIG_ADD_VAR(MAX_LABEL_EXE_SIZE, int, 1, "Max nops marked as executed when labels are used");
@@ -298,7 +299,7 @@
   CONFIG_ADD_VAR(MERIT_RECEIVED, double, 0.0, "Multiplier of merit given with 'donate' command"); 
   CONFIG_ADD_VAR(MAX_DONATE_KIN_DIST, int, -1, "Limit on distance of relation for donate; -1=no max");
   CONFIG_ADD_VAR(MAX_DONATE_EDIT_DIST, int, -1, "Limit on genetic (edit) distance for donate; -1=no max");
-  CONFIG_ADD_VAR(MIN_GB_DONATE_THRESHOLD, int, -1, "threshold green beard donates only to orgs above this donation attempt threshold; -1=no thresh");
+  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.");
   

Modified: development/source/main/cOrganism.cc
===================================================================
--- development/source/main/cOrganism.cc	2007-05-27 18:14:18 UTC (rev 1618)
+++ development/source/main/cOrganism.cc	2007-05-27 19:18:50 UTC (rev 1619)
@@ -423,7 +423,13 @@
   return m_hardware->InjectHost(label, injected_code);
 }
 
+void cOrganism::ClearParasites()
+{
+  for (int i = 0; i < m_parasites.GetSize(); i++) m_parasites[i]->RemoveParasite();
+  m_parasites.Resize(0);
+}
 
+
 double cOrganism::CalcMeritRatio()
 {
   const double age = (double) m_phenotype.GetAge();

Modified: development/source/main/cOrganism.h
===================================================================
--- development/source/main/cOrganism.h	2007-05-27 18:14:18 UTC (rev 1618)
+++ development/source/main/cOrganism.h	2007-05-27 19:18:50 UTC (rev 1619)
@@ -229,7 +229,7 @@
   void AddParasite(cInjectGenotype* cur) { m_parasites.Push(cur); }
   cInjectGenotype& GetParasite(int x) { return *m_parasites[x]; }
   int GetNumParasites() const { return m_parasites.GetSize(); }
-  void ClearParasites() { m_parasites.Resize(0); }
+  void ClearParasites();
 		      
 
   // --------  Support Methods  --------

Modified: development/source/main/cPopulation.cc
===================================================================
--- development/source/main/cPopulation.cc	2007-05-27 18:14:18 UTC (rev 1618)
+++ development/source/main/cPopulation.cc	2007-05-27 19:18:50 UTC (rev 1619)
@@ -480,9 +480,7 @@
   }
   genotype->RemoveOrganism();
   
-  for (int i = 0; i < organism->GetNumParasites(); i++) {
-    organism->GetParasite(i).RemoveParasite();
-  }
+  organism->ClearParasites();
   
   // And clear it!
   in_cell.RemoveOrganism();

Modified: development/support/config/avida.cfg
===================================================================
--- development/support/config/avida.cfg	2007-05-27 18:14:18 UTC (rev 1618)
+++ development/support/config/avida.cfg	2007-05-27 19:18:50 UTC (rev 1619)
@@ -81,6 +81,8 @@
                          #     (after the divide, we have 2 children)
                          # 2 = Divide resets state of current thread only
                          #     (does not touch possible parasite threads)
+INJECT_METHOD 0          # 0 = Leaves the parasite thread state untouched.
+                         # 1 = Resets the calling thread state on inject
 GENERATION_INC_METHOD 1  # 0 = Only the generation of the child is
                          #     increased on divide.
                          # 1 = Both the generation of the mother and child are
@@ -143,42 +145,55 @@
 STERILIZE_BENEFICIAL 0.0   # 
 FAIL_IMPLICIT 0            # Should copies that failed *not* due to mutations
                            # be eliminated?
-NEUTRAL_MAX 0.0            # The percent benifical change from parent fitness to be considered neutral.
-NEUTRAL_MIN 0.0            # The percent deleterious change from parent fitness to be considered neutral.
+NEUTRAL_MAX 0.0            # The percent benifical change from parent fitness
+                           # to be considered neutral.
+NEUTRAL_MIN 0.0            # The percent deleterious change from parent fitness
+                           # to be considered neutral.
 
 ### TIME_GROUP ###
 # Time Slicing
-AVE_TIME_SLICE 30        # Ave number of insts per org per update
-SLICING_METHOD 1         # 0 = CONSTANT: all organisms get default...
-                         # 1 = PROBABILISTIC: Run _prob_ proportional to merit.
-                         # 2 = INTEGRATED: Perfectly integrated deterministic.
-BASE_MERIT_METHOD 4      # 0 = Constant (merit independent of size)
-                         # 1 = Merit proportional to copied size
-                         # 2 = Merit prop. to executed size
-                         # 3 = Merit prop. to full size
-                         # 4 = Merit prop. to min of executed or copied size
-                         # 5 = Merit prop. to sqrt of the minimum size
-                         # 6 = Merit prop. to num times MERIT_BONUS_INST is in genome.
-BASE_CONST_MERIT 100     # Base merit when BASE_MERIT_METHOD set to 0
-DEFAULT_BONUS 1.0        # Initial bonus before any tasks
-MERIT_DEFAULT_BONUS 0    # Scale the merit of an offspring by the default bonus
-                         # rather than the accumulated bonus of the parent?
-MERIT_BONUS_INST 0       # in BASE_MERIT_METHOD 6, this sets which instruction counts (-1=none, 0= 1st in INST_SET.)
-MERIT_BONUS_EFFECT 0     # in BASE_MERIT_METHOD 6, this sets how much merit is earned per INST (-1=penalty, 0= no effect.)
-FITNESS_VALLEY 0         # in BASE_MERIT_METHOD 6, this creates valleys from FITNESS_VALLEY_START to FITNESS_VALLEY_STOP (0= off, 1=on)
-FITNESS_VALLEY_START 0   # if FITNESS_VALLEY =1, orgs with num_key_instructions from FITNESS_VALLEY_START to FITNESS_VALLEY_STOP get fitness 1 (lowest)
-FITNESS_VALLEY_STOP 0    # if FITNESS_VALLEY =1, orgs with num_key_instructions from FITNESS_VALLEY_START to FITNESS_VALLEY_STOP get fitness 1 (lowest)
-MAX_CPU_THREADS 1        # Number of Threads a CPU can spawn
-THREAD_SLICING_METHOD 0  # Formula for and organism's thread slicing
-                         #   (num_threads-1) * THREAD_SLICING_METHOD + 1
-                         # 0 = One thread executed per time slice.
-                         # 1 = All threads executed each time slice.
-MAX_LABEL_EXE_SIZE 1     # Max nops marked as executed when labels are used
-DONATE_SIZE 5.0          # Amount of merit donated with 'donate' command
-DONATE_MULT 10.0         # Multiple of merit given that the target receives.
-MAX_DONATE_KIN_DIST -1   # Limit on distance of relation for donate; -1=no max
-MAX_DONATE_EDIT_DIST -1  # Limit on edit distance for donate; -1=no max
-MAX_DONATES 1000000      # Limit on number of donates organisms are allowed.
+AVE_TIME_SLICE 30           # Ave number of insts per org per update
+SLICING_METHOD 1            # 0 = CONSTANT: all organisms get default...
+                            # 1 = PROBABILISTIC: Run _prob_ proportional to merit.
+                            # 2 = INTEGRATED: Perfectly integrated deterministic.
+BASE_MERIT_METHOD 4         # 0 = Constant (merit independent of size)
+                            # 1 = Merit proportional to copied size
+                            # 2 = Merit prop. to executed size
+                            # 3 = Merit prop. to full size
+                            # 4 = Merit prop. to min of executed or copied size
+                            # 5 = Merit prop. to sqrt of the minimum size
+                            # 6 = Merit prop. to num times MERIT_BONUS_INST is in genome.
+BASE_CONST_MERIT 100        # Base merit when BASE_MERIT_METHOD set to 0
+DEFAULT_BONUS 1.0           # Initial bonus before any tasks
+MERIT_DEFAULT_BONUS 0       # Scale the merit of an offspring by the default bonus
+                            # rather than the accumulated bonus of the parent?
+MERIT_BONUS_INST 0          # in BASE_MERIT_METHOD 6, this sets which instruction counts
+                            # (-1 = none, 0 = First in INST_SET.)
+MERIT_BONUS_EFFECT 0        # in BASE_MERIT_METHOD 6, this sets how much merit is earned
+                            # per instruction (-1 = penalty, 0 = no effect.)
+FITNESS_VALLEY 0            # in BASE_MERIT_METHOD 6, this creates valleys from
+                            # FITNESS_VALLEY_START to FITNESS_VALLEY_STOP
+                            # (0 = off, 1 = on)
+FITNESS_VALLEY_START 0      # if FITNESS_VALLEY = 1, orgs with num_key_instructions
+                            # from FITNESS_VALLEY_START to FITNESS_VALLEY_STOP
+                            # get fitness 1 (lowest)
+FITNESS_VALLEY_STOP 0       # if FITNESS_VALLEY = 1, orgs with num_key_instructions
+                            # from FITNESS_VALLEY_START to FITNESS_VALLEY_STOP
+                            # get fitness 1 (lowest)
+MAX_CPU_THREADS 1           # Number of Threads a CPU can spawn
+THREAD_SLICING_METHOD 0     # Formula for and organism's thread slicing
+                            #   (num_threads-1) * THREAD_SLICING_METHOD + 1
+                            # 0 = One thread executed per time slice.
+                            # 1 = All threads executed each time slice.
+MAX_LABEL_EXE_SIZE 1        # Max nops marked as executed when labels are used
+MERIT_GIVEN 0.0             # Fraction of merit donated with 'donate' command
+MERIT_RECEIVED 0.0          # Multiplier of merit given with 'donate' command
+MAX_DONATE_KIN_DIST -1      # Limit on distance of relation for donate; -1=no max
+MAX_DONATE_EDIT_DIST -1     # Limit on genetic (edit) distance for donate; -1=no max
+MIN_GB_DONATE_THRESHOLD -1  # threshold green beard donates only to orgs above this
+                            # donation attempt threshold; -1=no thresh
+DONATE_THRESH_QUANTA 10     # The size of steps between quanta donate thresholds
+MAX_DONATES 1000000         # Limit on number of donates organisms are allowed.
 
 ### PROMOTER_GROUP ###
 # Promoters




More information about the Avida-cvs mailing list