[Avida-SVN] r3235 - in development/source: cpu main

goingssh at myxo.css.msu.edu goingssh at myxo.css.msu.edu
Thu May 14 08:11:41 PDT 2009


Author: goingssh
Date: 2009-05-14 11:11:40 -0400 (Thu, 14 May 2009)
New Revision: 3235

Modified:
   development/source/cpu/cHardwareBase.cc
   development/source/main/cAvidaConfig.h
   development/source/main/cOrganism.cc
   development/source/main/cOrganism.h
   development/source/main/cWorld.cc
Log:
Adding ability to revert and sterilize task loss (defined as a mutation that causes the loss of 1 or more tasks without the gain of any task(s) ).

Modified: development/source/cpu/cHardwareBase.cc
===================================================================
--- development/source/cpu/cHardwareBase.cc	2009-05-13 15:43:56 UTC (rev 3234)
+++ development/source/cpu/cHardwareBase.cc	2009-05-14 15:11:40 UTC (rev 3235)
@@ -498,6 +498,7 @@
   if (phenotype.CopyTrue() == true) return false;
 	
   const double parent_fitness = m_organism->GetTestFitness(ctx);
+  const tArray<int>& parenttasks = phenotype.GetCurTaskCount();
   const double neut_min = parent_fitness * (1.0 - m_organism->GetNeutralMin());
     const double neut_max = parent_fitness * (1.0 + m_organism->GetNeutralMax());
       
@@ -531,6 +532,31 @@
         if (ctx.GetRandom().P(m_organism->GetSterilizePos())) sterilize = true;
       }
       
+	  int RorS = 0;	// 0 = neither, 1 = revert, 2 = sterilize
+	  if (ctx.GetRandom().P(m_organism->GetRevertTaskLoss()))
+		  RorS = 1;
+	  else if (ctx.GetRandom().P(m_organism->GetSterilizeTaskLoss()))
+		  RorS = 2;
+	  // check if child has lost any tasks parent had AND not gained any new tasks
+	  if (RorS) {
+		  const tArray<int>& childtasks = test_info.GetTestPhenotype().GetLastTaskCount();
+		  bool del = false;
+		  bool added = false;
+		  for (int i=0; i<childtasks.GetSize(); i++)
+		  {
+			  if (childtasks[i] > parenttasks[i]) {
+				  added = true;
+				  break;
+			  }
+			  else if (childtasks[i] < parenttasks[i])
+				  del = true;
+		  }
+		  if (RorS == 1) 
+			  revert = (del & !added);
+		  else 
+			  sterilize = (del & !added);
+	  }
+      
       // Ideally, we won't have reversions and sterilizations turned on at the
       // same time, but if we do, give revert the priority.
       if (revert == true) {
@@ -565,6 +591,7 @@
   if (phenotype.CopyTrue() == true) return false;
 	
   const double parent_fitness = m_organism->GetTestFitness(ctx);
+  const tArray<int>& parenttasks = phenotype.GetCurTaskCount();
   const double neut_min = parent_fitness * (1.0 - m_organism->GetNeutralMin());
   const double neut_max = parent_fitness * (1.0 + m_organism->GetNeutralMax());
       
@@ -601,17 +628,42 @@
     if (ctx.GetRandom().P(m_organism->GetRevertPos())) revert = true;
     if (ctx.GetRandom().P(m_organism->GetSterilizePos())) sterilize = true;
   }
-  
+
+  int RorS = 0;	// 0 = neither, 1 = revert, 2 = sterilize
+  if (ctx.GetRandom().P(m_organism->GetRevertTaskLoss()))
+	  RorS = 1;
+  else if (ctx.GetRandom().P(m_organism->GetSterilizeTaskLoss()))
+	  RorS = 2;
+  // check if child has lost any tasks parent had AND not gained any new tasks
+  if (RorS) {
+	  const tArray<int>& childtasks = test_info.GetTestPhenotype().GetLastTaskCount();
+	  bool del = false;
+	  bool added = false;
+	  for (int i=0; i<childtasks.GetSize(); i++)
+	  {
+		  if (childtasks[i] > parenttasks[i]) {
+			  added = true;
+			  break;
+		  }
+		  else if (childtasks[i] < parenttasks[i])
+			  del = true;
+	  }
+	  if (RorS == 1) 
+		  revert = (del & !added);
+	  else 
+		  sterilize = (del & !added);
+  }
+
   // Ideally, we won't have reversions and sterilizations turned on at the
   // same time, but if we do, give revert the priority.
   if (revert == true) {
-    m_organism->OffspringGenome() = m_organism->GetMetaGenome();
+	  m_organism->OffspringGenome() = m_organism->GetMetaGenome();
   }
-  
+
   if (sterilize == true) {
-    m_organism->GetPhenotype().ChildFertile() = false;
+	  m_organism->GetPhenotype().ChildFertile() = false;
   }
-  
+
   return (!sterilize) && revert;
 }
 

Modified: development/source/main/cAvidaConfig.h
===================================================================
--- development/source/main/cAvidaConfig.h	2009-05-13 15:43:56 UTC (rev 3234)
+++ development/source/main/cAvidaConfig.h	2009-05-14 15:11:40 UTC (rev 3235)
@@ -419,10 +419,12 @@
   CONFIG_ADD_VAR(REVERT_DETRIMENTAL, double, 0.0, "  0.0 to 1.0; Probability of reversion.");
   CONFIG_ADD_VAR(REVERT_NEUTRAL, double, 0.0, "");
   CONFIG_ADD_VAR(REVERT_BENEFICIAL, double, 0.0, "");
+  CONFIG_ADD_VAR(REVERT_TASKLOSS, double, 0.0, "should org be reverted if loses task(s) without gaining other(s)?");
   CONFIG_ADD_VAR(STERILIZE_FATAL, double, 0.0, "Should any mutations clear (kill) the organism?");
   CONFIG_ADD_VAR(STERILIZE_DETRIMENTAL, double, 0.0, "");
   CONFIG_ADD_VAR(STERILIZE_NEUTRAL, double, 0.0, "");
   CONFIG_ADD_VAR(STERILIZE_BENEFICIAL, double, 0.0, "");
+  CONFIG_ADD_VAR(STERILIZE_TASKLOSS, 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\nto be considered neutral.");
   CONFIG_ADD_VAR(NEUTRAL_MIN,double, 0.0, "The percent deleterious change from parent fitness\nto be considered neutral.");

Modified: development/source/main/cOrganism.cc
===================================================================
--- development/source/main/cOrganism.cc	2009-05-13 15:43:56 UTC (rev 3234)
+++ development/source/main/cOrganism.cc	2009-05-14 15:11:40 UTC (rev 3235)
@@ -640,11 +640,13 @@
 bool cOrganism::GetRevertNeg() const { return m_world->GetConfig().REVERT_DETRIMENTAL.Get(); }
 bool cOrganism::GetRevertNeut() const { return m_world->GetConfig().REVERT_NEUTRAL.Get(); }
 bool cOrganism::GetRevertPos() const { return m_world->GetConfig().REVERT_BENEFICIAL.Get(); }
+bool cOrganism::GetRevertTaskLoss() const { return m_world->GetConfig().REVERT_TASKLOSS.Get(); }
 
 bool cOrganism::GetSterilizeFatal() const { return m_world->GetConfig().STERILIZE_FATAL.Get(); }
 bool cOrganism::GetSterilizeNeg() const { return m_world->GetConfig().STERILIZE_DETRIMENTAL.Get(); }
 bool cOrganism::GetSterilizeNeut() const { return m_world->GetConfig().STERILIZE_NEUTRAL.Get(); }
 bool cOrganism::GetSterilizePos() const { return m_world->GetConfig().STERILIZE_BENEFICIAL.Get(); }
+bool cOrganism::GetSterilizeTaskLoss() const { return m_world->GetConfig().STERILIZE_TASKLOSS.Get(); }
 double cOrganism::GetNeutralMin() const { return m_world->GetConfig().NEUTRAL_MIN.Get(); }
 double cOrganism::GetNeutralMax() const { return m_world->GetConfig().NEUTRAL_MAX.Get(); }
 

Modified: development/source/main/cOrganism.h
===================================================================
--- development/source/main/cOrganism.h	2009-05-13 15:43:56 UTC (rev 3234)
+++ development/source/main/cOrganism.h	2009-05-14 15:11:40 UTC (rev 3235)
@@ -366,11 +366,13 @@
   bool GetRevertNeg() const;
   bool GetRevertNeut() const;
   bool GetRevertPos() const;
+  bool GetRevertTaskLoss() const;
 
   bool GetSterilizeFatal() const;
   bool GetSterilizeNeg() const;
   bool GetSterilizeNeut() const;
   bool GetSterilizePos() const;
+  bool GetSterilizeTaskLoss() const;
   double GetNeutralMin() const;
   double GetNeutralMax() const;
 

Modified: development/source/main/cWorld.cc
===================================================================
--- development/source/main/cWorld.cc	2009-05-13 15:43:56 UTC (rev 3234)
+++ development/source/main/cWorld.cc	2009-05-14 15:11:40 UTC (rev 3235)
@@ -120,14 +120,16 @@
   const bool revert_neg = m_conf->REVERT_DETRIMENTAL.Get() > 0.0;
   const bool revert_neut = m_conf->REVERT_NEUTRAL.Get() > 0.0;
   const bool revert_pos = m_conf->REVERT_BENEFICIAL.Get() > 0.0;
+  const bool revert_taskloss = m_conf->REVERT_TASKLOSS.Get() > 0.0;
   const bool fail_implicit = m_conf->FAIL_IMPLICIT.Get() > 0;
-  m_test_on_div = (revert_fatal || revert_neg || revert_neut || revert_pos || fail_implicit);
+  m_test_on_div = (revert_fatal || revert_neg || revert_neut || revert_pos || revert_taskloss || fail_implicit);
   
   const bool sterilize_fatal = m_conf->STERILIZE_FATAL.Get() > 0.0;
   const bool sterilize_neg = m_conf->STERILIZE_DETRIMENTAL.Get() > 0.0;
   const bool sterilize_neut = m_conf->STERILIZE_NEUTRAL.Get() > 0.0;
   const bool sterilize_pos = m_conf->STERILIZE_BENEFICIAL.Get() > 0.0;
-  m_test_sterilize = (sterilize_fatal || sterilize_neg || sterilize_neut || sterilize_pos);
+  const bool sterilize_taskloss = m_conf->STERILIZE_TASKLOSS.Get() > 0.0;
+  m_test_sterilize = (sterilize_fatal || sterilize_neg || sterilize_neut || sterilize_pos || sterilize_taskloss);
 }
 
 cAnalyze& cWorld::GetAnalyze()




More information about the Avida-cvs mailing list