[Avida-SVN] r3216 - development/source/main

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Tue Apr 21 19:08:16 PDT 2009


Author: brysonda
Date: 2009-04-21 22:08:16 -0400 (Tue, 21 Apr 2009)
New Revision: 3216

Modified:
   development/source/main/cAvidaConfig.h
   development/source/main/cOrganism.cc
   development/source/main/cPhenotype.cc
   development/source/main/cPhenotype.h
Log:
Implement support for applying organism merit increases during gestation (i.e. adjust current scheduler merit when the current bonus * base_merit is greater than it).  For backward compatibility this is off by default, but can be enabled by setting MERIT_INC_APPLY_IMMEDIATE to 1.

Modified: development/source/main/cAvidaConfig.h
===================================================================
--- development/source/main/cAvidaConfig.h	2009-04-20 19:45:47 UTC (rev 3215)
+++ development/source/main/cAvidaConfig.h	2009-04-22 02:08:16 UTC (rev 3216)
@@ -437,6 +437,7 @@
   CONFIG_ADD_VAR(MERIT_DEFAULT_BONUS, int, 0, "Scale the merit of an offspring by this default bonus\nrather than the accumulated bonus of the parent? 0 = off"); 
   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(MERIT_INC_APPLY_IMMEDIATE, bool, 0, "Should merit increases (above current) be applied immediately, or delayed until divide?");
   CONFIG_ADD_VAR(FITNESS_METHOD, int, 0, "0 = default, >=1 = experimental"); 
   CONFIG_ADD_VAR(FITNESS_COEFF_1, double, 1.0, "1st FITNESS_METHOD parameter");  
   CONFIG_ADD_VAR(FITNESS_COEFF_2, double, 1.0, "2nd FITNESS_METHOD parameter");  

Modified: development/source/main/cOrganism.cc
===================================================================
--- development/source/main/cOrganism.cc	2009-04-20 19:45:47 UTC (rev 3215)
+++ development/source/main/cOrganism.cc	2009-04-22 02:08:16 UTC (rev 3216)
@@ -383,6 +383,12 @@
   bool task_completed = m_phenotype.TestOutput(ctx, taskctx, globalAndDeme_resource_count, 
                                                m_phenotype.GetCurRBinsAvail(), globalAndDeme_res_change, 
                                                insts_triggered);
+  
+  // Handle merit increases that take the organism above it's current population merit
+  if (m_world->GetConfig().MERIT_INC_APPLY_IMMEDIATE.Get()) {
+    double cur_merit = m_phenotype.CalcCurrentMerit();
+    if (m_phenotype.GetMerit().GetDouble() < cur_merit) m_interface->UpdateMerit(cur_merit);
+  }
  
   //disassemble global and deme resource counts
   global_res_change = globalAndDeme_res_change.Subset(0, global_res_change.GetSize());

Modified: development/source/main/cPhenotype.cc
===================================================================
--- development/source/main/cPhenotype.cc	2009-04-20 19:45:47 UTC (rev 3215)
+++ development/source/main/cPhenotype.cc	2009-04-22 02:08:16 UTC (rev 3216)
@@ -1291,7 +1291,17 @@
   return out_size;
 } 
 
+double cPhenotype::CalcCurrentMerit() const
+{
+  int merit_base = CalcSizeMerit();
+  
+  const int merit_default_bonus = m_world->GetConfig().MERIT_DEFAULT_BONUS.Get();
+  double bonus = (merit_default_bonus) ? merit_default_bonus : cur_bonus;
+  
+  return merit_base * bonus;  
+}
 
+
 double cPhenotype::CalcFitness(double _merit_base, double _bonus, int _gestation_time, int _cpu_cycles) const
 {
   double out_fitness = 0;

Modified: development/source/main/cPhenotype.h
===================================================================
--- development/source/main/cPhenotype.h	2009-04-20 19:45:47 UTC (rev 3215)
+++ development/source/main/cPhenotype.h	2009-04-22 02:08:16 UTC (rev 3216)
@@ -288,6 +288,7 @@
 
   // Some useful methods...
   int CalcSizeMerit() const;
+  double CalcCurrentMerit() const;
   double CalcFitness(double _merit_base, double _bonus, int _gestation_time, int _cpu_cycles) const;
 
   double CalcFitnessRatio() {




More information about the Avida-cvs mailing list