[Avida-SVN] r1495 - in development/source: actions main

jclune at myxo.css.msu.edu jclune at myxo.css.msu.edu
Sat Apr 21 04:37:49 PDT 2007


Author: jclune
Date: 2007-04-21 07:37:49 -0400 (Sat, 21 Apr 2007)
New Revision: 1495

Modified:
   development/source/actions/PopulationActions.cc
   development/source/main/cAvidaConfig.h
   development/source/main/cPhenotype.cc
Log:
Added FITNESS_VALLEY, FITNESS_VALLEY_START, and FITNESS_VALLEY_STOP, as well as an event ToggleFitnessValley, to enable me to have fitness valleys in my counting one environment. See the new avida.cfg file for more info (or the comment above the event). 




Modified: development/source/actions/PopulationActions.cc
===================================================================
--- development/source/actions/PopulationActions.cc	2007-04-20 11:35:13 UTC (rev 1494)
+++ development/source/actions/PopulationActions.cc	2007-04-21 11:37:49 UTC (rev 1495)
@@ -492,12 +492,11 @@
 class cActionToggleRewardInstruction : public cAction
 {
 private:
-  double m_killprob;
 public:
-  cActionToggleRewardInstruction(cWorld* world, const cString& args) : cAction(world, args), m_killprob(0.9)
+  cActionToggleRewardInstruction(cWorld* world, const cString& args) : cAction(world, args) 
   {
     //pass
-    //@JMC: m_killprob is meme that hitchiked when I used gabe's event as an example. need to clean it up. 
+    //@JMC: m_killprob (and other code) is a meme that hitchiked when I used gabe's event as an example. need to clean it up. 
   }
   
   static const cString GetDescription() { return "Arguments: [double probability=0.9]"; }
@@ -508,7 +507,37 @@
   }
 };
 
+/*
+ In avida.cfg, when BASE_MERIT_METHOD is set to 6 (Merit prop. to num times MERIT_BONUS_INST is in genome), 
+ the merit is incremented by MERIT_BONUS_EFFECT if MERIT_BONUS_EFFECT is positive and decremented by
+ MERIT_BONUS_EFFECT if it is negative. For positive values the counting starts at 1, for negative values it starts
+ at genome length. This event addes fitness valleys to this extremely simple counting-ones type of dynamic environment.
+ Orgs that have #_merit_bonus_inst_in_genome >=FITNESS_VALLEY_START && <= FITNESS_VALLEY_STOP will have a fitness of one (the lowest).
+ Example.   FITNESS_VALLEY_START = 5, FITNESS_VALLEY_STOP = 7. orgs with 5, 6, or 7 MERIT_BONUS_INST in their genome have fitness = 1.
+ Specifically, this event creates these valleys or takes them away. 
+*/
 
+class cActionToggleFitnessValley : public cAction
+{
+private:
+public:
+  cActionToggleFitnessValley(cWorld* world, const cString& args) : cAction(world, args) 
+  {
+    //pass
+    //@JMC: m_killprob (and other code) is a meme that hitchiked when I used gabe's event as an example. need to clean it up. 
+  }
+  
+  static const cString GetDescription() { return "Arguments: [double probability=0.9]"; }
+  
+  void Process(cAvidaContext& ctx)
+  {
+    if(m_world->GetConfig().FITNESS_VALLEY.Get()) {m_world->GetConfig().FITNESS_VALLEY.Set(0);}
+    else{m_world->GetConfig().FITNESS_VALLEY.Set(1);}
+//    m_world->GetConfig().FITNESS_VALLEY.Set(-1* m_world->GetConfig().FITNESS_VALLEY.Get());
+  }
+};
+
+
 /*
  Randomly removes a certain proportion of the population.
  In principle, this event does the same thing as the KillProb action.
@@ -1378,6 +1407,7 @@
 
   action_lib->Register<cActionKillProb>("KillProb");
   action_lib->Register<cActionToggleRewardInstruction>("ToggleRewardInstruction");
+  action_lib->Register<cActionToggleFitnessValley>("ToggleFitnessValley");
   action_lib->Register<cActionKillProb>("KillRate");
   action_lib->Register<cActionKillRectangle>("KillRectangle");
   action_lib->Register<cActionSerialTransfer>("SerialTransfer");

Modified: development/source/main/cAvidaConfig.h
===================================================================
--- development/source/main/cAvidaConfig.h	2007-04-20 11:35:13 UTC (rev 1494)
+++ development/source/main/cAvidaConfig.h	2007-04-21 11:37:49 UTC (rev 1495)
@@ -277,6 +277,9 @@
   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(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");

Modified: development/source/main/cPhenotype.cc
===================================================================
--- development/source/main/cPhenotype.cc	2007-04-20 11:35:13 UTC (rev 1494)
+++ development/source/main/cPhenotype.cc	2007-04-21 11:37:49 UTC (rev 1495)
@@ -847,10 +847,18 @@
     out_size = (int) sqrt((double) out_size);
     break;
   case BASE_MERIT_NUM_BONUS_INST:
+    if(m_world->GetConfig().FITNESS_VALLEY.Get()){
+      if (bonus_instruction_count >= m_world->GetConfig().FITNESS_VALLEY_START.Get() && 
+          bonus_instruction_count <= m_world->GetConfig().FITNESS_VALLEY_START.Get()){
+         out_size = 1;
+         break;
+           }
+            
+    }
     if (m_world->GetConfig().MERIT_BONUS_EFFECT.Get()>0) {out_size = 1 + bonus_instruction_count;}
     else if (m_world->GetConfig().MERIT_BONUS_EFFECT.Get()<0) {out_size = genome_length - (bonus_instruction_count -1);}
-    else {out_size = 1;}  //the extra 1 point in all these case is so the orgs are not jilted by the scheduler
-    break;   
+    else {out_size = 1;}  //the extra 1 point in all these case is so the orgs are not jilted by the scheduler        
+    break;
   case BASE_MERIT_CONST:
   default:
     out_size = m_world->GetConfig().BASE_CONST_MERIT.Get();




More information about the Avida-cvs mailing list