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

blwalker at myxo.css.msu.edu blwalker at myxo.css.msu.edu
Thu Dec 11 20:10:59 PST 2008


Author: blwalker
Date: 2008-12-11 23:10:58 -0500 (Thu, 11 Dec 2008)
New Revision: 3023

Modified:
   development/source/main/cAvidaConfig.h
   development/source/main/cEnvironment.cc
   development/support/config/avida.cfg
Log:

Implemented the USE_STORED_FRACTION configuration option, and added an ENV_FRACTION_THRESHOLD option to allow further control of the circumstances under which stored resources are used.


Modified: development/source/main/cAvidaConfig.h
===================================================================
--- development/source/main/cAvidaConfig.h	2008-12-12 03:17:56 UTC (rev 3022)
+++ development/source/main/cAvidaConfig.h	2008-12-12 04:10:58 UTC (rev 3023)
@@ -491,12 +491,13 @@
   CONFIG_ADD_VAR(BUY_PRICE, int, 0, "price offered by organisms attempting to buy");
   CONFIG_ADD_VAR(SELL_PRICE, int, 0, "price offered by organisms attempting to sell");
   
-  CONFIG_ADD_GROUP(HOARD_RESOURCE_GROUP, "Resource Hoarding Parameters \nDO NOT USE with hardwares other than the \"original\".");
-  CONFIG_ADD_VAR(USE_RESOURCE_BINS, bool, 0, "Use resources stored in resource bins.");
-  CONFIG_ADD_VAR(ABSORB_RESOURCE_FRACTION, double, .0025, "Fraction of available environmental resource an organism absorbs with the collect instruction.");
-  CONFIG_ADD_VAR(MULTI_ABSORB_TYPE, int, 0, "What to do if collect is called on a range of resources.\n 0 = absorb a random resource in the range\n 1 = absorb the first resource in the range\n 2 = absorb the last resource in the range\n 3 = absorb ABSORB_RESOURCE_FRACTION / (# of resources in range) of each resource in the range");
+  CONFIG_ADD_GROUP(HOARD_RESOURCE_GROUP, "Resource Hoarding Parameters");
+  CONFIG_ADD_VAR(USE_RESOURCE_BINS, bool, 0, "Enable resource bin use.  This serves as a guard on most resource hoarding code.");
+  CONFIG_ADD_VAR(ABSORB_RESOURCE_FRACTION, double, .0025, "Fraction of available environmental resource an organism absorbs.");
+  CONFIG_ADD_VAR(MULTI_ABSORB_TYPE, int, 0, "What to do if a collect instruction is called on a range of resources.\n 0 = absorb a random resource in the range\n 1 = absorb the first resource in the range\n 2 = absorb the last resource in the range\n 3 = absorb ABSORB_RESOURCE_FRACTION / (# of resources in range) of each resource in the range");
   CONFIG_ADD_VAR(MAX_TOTAL_STORED, double, -1, "Maximum total amount of all resources an organism can store.\n <0 = no maximum");
   CONFIG_ADD_VAR(USE_STORED_FRACTION, double, 1.0, "The fraction of stored resource to use.");
+  CONFIG_ADD_VAR(ENV_FRACTION_THRESHOLD, double, 1.0, "The fraction of available environmental resource to compare available stored resource to when deciding whether to use stored resource.");
   CONFIG_ADD_VAR(RETURN_STORED_ON_DEATH, bool, 1, "Return an organism's stored resources to the world when it dies?");
   
   CONFIG_ADD_GROUP(ANALYZE_GROUP, "Analysis Settings");

Modified: development/source/main/cEnvironment.cc
===================================================================
--- development/source/main/cEnvironment.cc	2008-12-12 03:17:56 UTC (rev 3022)
+++ development/source/main/cEnvironment.cc	2008-12-12 04:10:58 UTC (rev 3023)
@@ -1157,9 +1157,17 @@
       	assert(rbins_count.GetSize() > res_id);
       }
       
-      //check to see if we do want to use this resource from a bin instead of the environment
-      if (may_use_rbins && rbins_count[res_id] > consumed && rbins_count[res_id] > 0) {
-        consumed = rbins_count[res_id];
+      /* Check to see if we do want to use this resource from a bin instead of the environment:
+       * - Can we use the resource bins?
+       * - Is there anything in the bin for this resource?
+       * - Is the usable fraction in the bin strictly greater than the threshold fraction
+       *   of what we could consume from the outside environment?
+       */
+      if (may_use_rbins && rbins_count[res_id] > 0 && 
+           (m_world->GetConfig().USE_STORED_FRACTION.Get() * rbins_count[res_id]) > 
+           (m_world->GetConfig().ENV_FRACTION_THRESHOLD.Get() * consumed)
+           ) {
+        consumed = m_world->GetConfig().USE_STORED_FRACTION.Get() * rbins_count[res_id];
         using_rbins = true;
       }
       

Modified: development/support/config/avida.cfg
===================================================================
--- development/support/config/avida.cfg	2008-12-12 03:17:56 UTC (rev 3022)
+++ development/support/config/avida.cfg	2008-12-12 04:10:58 UTC (rev 3023)
@@ -387,8 +387,7 @@
 
 ### HOARD_RESOURCE_GROUP ###
 # Resource Hoarding Parameters 
-# DO NOT USE with hardwares other than the "original".
-USE_RESOURCE_BINS 0             # Use resources stored in resource bins.
+USE_RESOURCE_BINS 0             # Enable resource bin use.  This serves as a guard on most resource hoarding code.
 ABSORB_RESOURCE_FRACTION .0025  # Fraction of available environmental resource an organism absorbs with the collect instruction.
 MULTI_ABSORB_TYPE 0             # What to do if collect is called on a range of resources.
                                 #  0 = absorb a random resource in the range
@@ -398,6 +397,7 @@
 MAX_TOTAL_STORED -1             # Maximum total amount of all resources an organism can store.
                                 #  <0 = no maximum
 USE_STORED_FRACTION 1.0         # The fraction of stored resource to use.
+ENV_FRACTION_THRESHOLD 1.0      # The fraction of available environmental resource to compare available stored resource to when deciding whether to use stored resource.
 RETURN_STORED_ON_DEATH 1        # Return an organism's stored resources to the world when it dies?
 
 ### ANALYZE_GROUP ###




More information about the Avida-cvs mailing list