[Avida-SVN] r2154 - in branches/collect: . Avida.xcodeproj documentation source/actions source/analyze source/cpu source/main source/tools support/config tests/energy_deme_level_res
blwalker at myxo.css.msu.edu
blwalker at myxo.css.msu.edu
Wed Oct 24 07:05:39 PDT 2007
Author: blwalker
Date: 2007-10-24 10:05:38 -0400 (Wed, 24 Oct 2007)
New Revision: 2154
Added:
branches/collect/documentation/energy_model.html
branches/collect/tests/energy_deme_level_res/expected/
Modified:
branches/collect/Avida.xcodeproj/project.pbxproj
branches/collect/CMakeLists.txt
branches/collect/documentation/actions.html
branches/collect/documentation/analyze.html
branches/collect/documentation/environment.html
branches/collect/documentation/index.html
branches/collect/source/actions/EnvironmentActions.cc
branches/collect/source/actions/PopulationActions.cc
branches/collect/source/analyze/cAnalyze.cc
branches/collect/source/analyze/cAnalyzeGenotype.cc
branches/collect/source/analyze/cAnalyzeGenotype.h
branches/collect/source/cpu/cHardwareBase.cc
branches/collect/source/cpu/cHardwareCPU.cc
branches/collect/source/cpu/cHardwareCPU.h
branches/collect/source/cpu/cHardwareExperimental.cc
branches/collect/source/cpu/cHardwareGX.cc
branches/collect/source/cpu/cHardwareSMT.cc
branches/collect/source/cpu/cHardwareSMT.h
branches/collect/source/cpu/cHardwareTransSMT.cc
branches/collect/source/cpu/cHardwareTransSMT.h
branches/collect/source/cpu/cHeadCPU.cc
branches/collect/source/cpu/cInstLib.h
branches/collect/source/cpu/cInstSet.cc
branches/collect/source/cpu/cInstSet.h
branches/collect/source/cpu/tInstLib.h
branches/collect/source/main/avida.cc
branches/collect/source/main/cAvidaConfig.h
branches/collect/source/main/cEnvironment.cc
branches/collect/source/main/cEnvironment.h
branches/collect/source/main/cOrganism.h
branches/collect/source/main/cPhenPlastGenotype.cc
branches/collect/source/main/cPhenotype.cc
branches/collect/source/main/cPopulation.cc
branches/collect/source/main/cPopulation.h
branches/collect/source/main/cReaction.cc
branches/collect/source/main/cReaction.h
branches/collect/source/main/cResourceCount.cc
branches/collect/source/main/cResourceCount.h
branches/collect/source/tools/cString.h
branches/collect/source/tools/cTopology.h
branches/collect/support/config/avida.cfg
Log:
Porting development 2070:2150 to collect branch; any problems in the r2152 commit are resolved by this one.
Modified: branches/collect/Avida.xcodeproj/project.pbxproj
===================================================================
--- branches/collect/Avida.xcodeproj/project.pbxproj 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/Avida.xcodeproj/project.pbxproj 2007-10-24 14:05:38 UTC (rev 2154)
@@ -212,23 +212,6 @@
};
/* End PBXBuildRule section */
-/* Begin PBXBuildStyle section */
- B516AF180C91DC7700023D53 /* Development */ = {
- isa = PBXBuildStyle;
- buildSettings = {
- COPY_PHASE_STRIP = NO;
- };
- name = Development;
- };
- B516AF190C91DC7700023D53 /* Deployment */ = {
- isa = PBXBuildStyle;
- buildSettings = {
- COPY_PHASE_STRIP = YES;
- };
- name = Deployment;
- };
-/* End PBXBuildStyle section */
-
/* Begin PBXContainerItemProxy section */
56F555DA0C3B36FC00E2E929 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
@@ -1796,12 +1779,6 @@
DCC30C4D0762532C008F7A48 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 702442D70859E0B00059BD9B /* Build configuration list for PBXProject "Avida" */;
- buildSettings = {
- };
- buildStyles = (
- B516AF180C91DC7700023D53 /* Development */,
- B516AF190C91DC7700023D53 /* Deployment */,
- );
hasScannedForEncodings = 0;
mainGroup = DCC30C490762532C008F7A48;
productRefGroup = DCC3164E07626CF3008F7A48 /* Products */;
Modified: branches/collect/CMakeLists.txt
===================================================================
--- branches/collect/CMakeLists.txt 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/CMakeLists.txt 2007-10-24 14:05:38 UTC (rev 2154)
@@ -34,13 +34,22 @@
SET(COMPILER_WARNING_FLAGS "")
SET(COMPILER_OPTIMIZATION_FLAGS "-ffast-math -fno-rtti -funroll-loops -fstrict-aliasing -OPT:Olimit=0")
ELSE (CMAKE_CXX_COMPILER MATCHES ".*pathCC.*")
- SET(COMPILER_WARNING_FLAGS "-Wextra -Wno-unknown-pragmas -Wconversion -Wno-trigraphs")
- SET(COMPILER_OPTIMIZATION_FLAGS "-ffast-math -fno-rtti -funroll-loops -fstrict-aliasing -ftree-vectorize -fvisibility-inlines-hidden")
+ IF (CMAKE_CXX_COMPILER MATCHES ".*icpc.*")
+ SET(COMPILER_WARNING_FLAGS "")
+ SET(COMPILER_OPTIMIZATION_FLAGS "")
+ ELSE (CMAKE_CXX_COMPILER MATCHES ".*icpc.*")
+ SET(COMPILER_WARNING_FLAGS "-Wextra -Wno-unknown-pragmas -Wconversion -Wno-trigraphs")
+ SET(COMPILER_OPTIMIZATION_FLAGS "-ffast-math -fno-rtti -funroll-loops -fstrict-aliasing -ftree-vectorize -fvisibility-inlines-hidden")
+ ENDIF (CMAKE_CXX_COMPILER MATCHES ".*icpc.*")
ENDIF (CMAKE_CXX_COMPILER MATCHES ".*pathCC.*")
INCLUDE(CheckCSourceCompiles)
- SET(CMAKE_REQUIRED_FLAGS "-mno-fused-madd")
- CHECK_C_SOURCE_COMPILES("int main() { return 0; }" HAVE_FUSED_MADD)
+ IF (CMAKE_CXX_COMPILER MATCHES ".*icpc.*")
+ SET(HAVE_FUSED_MADD FALSE)
+ ELSE (CMAKE_CXX_COMPILER MATCHES ".*icpc.*")
+ SET(CMAKE_REQUIRED_FLAGS "-mno-fused-madd")
+ CHECK_C_SOURCE_COMPILES("int main() { return 0; }" HAVE_FUSED_MADD)
+ ENDIF (CMAKE_CXX_COMPILER MATCHES ".*icpc.*")
SET(CMAKE_REQUIRED_FLAGS "")
IF(HAVE_FUSED_MADD)
@@ -207,6 +216,7 @@
${MAIN_DIR}/cAvidaConfig.cc
${MAIN_DIR}/cBirthChamber.cc
${MAIN_DIR}/cDeme.cc
+ ${MAIN_DIR}/cDemeCellEvent.cc
${MAIN_DIR}/cEnvironment.cc
${MAIN_DIR}/cEventList.cc
${MAIN_DIR}/cFitnessMatrix.cc
@@ -300,7 +310,11 @@
# Build Instructions for the TCMalloc library
# ------------------------------------------------------------------------------
IF(UNIX)
- SET(AVD_ENABLE_TCMALLOC TRUE)
+ IF (CMAKE_CXX_COMPILER MATCHES ".*icpc.*")
+ SET(AVD_ENABLE_TCMALLOC FALSE)
+ ELSE (CMAKE_CXX_COMPILER MATCHES ".*icpc.*")
+ SET(AVD_ENABLE_TCMALLOC TRUE)
+ ENDIF (CMAKE_CXX_COMPILER MATCHES ".*icpc.*")
ELSE(UNIX)
SET(AVD_ENABLE_TCMALLOC FALSE)
ENDIF(UNIX)
Modified: branches/collect/documentation/actions.html
===================================================================
--- branches/collect/documentation/actions.html 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/documentation/actions.html 2007-10-24 14:05:38 UTC (rev 2154)
@@ -90,11 +90,11 @@
<br /><a href="#KillRate">KillRate</a>
<br /><a href="#KillRectangle">KillRectangle</a>
<br /><a href="#LoadClone">LoadClone</a>
+ <br /><a href="#LoadPopulation">LoadPopulation</a>
+ <br /><a href="#ModMutProb">ModMutProb</a>
</td>
<td>
- <a href="#LoadPopulation">LoadPopulation</a>
- <br /><a href="#ModMutProb">ModMutProb</a>
- <br /><a href="#OutflowScaledResource">OutflowScaledResource</a>
+ <a href="#OutflowScaledResource">OutflowScaledResource</a>
<br /><a href="#PairTestLandscape">PairTestLandscape</a>
<br /><a href="#PrecalcLandscape">PrecalcLandscape</a>
<br /><a href="#PredictNuLandscape">PredictNuLandscape</a>
@@ -127,13 +127,13 @@
<br /><a href="#PrintLogFitnessHistogram">PrintLogFitnessHistogram</a>
<br /><a href="#PrintMutationRateData">PrintMutationRateData</a>
<br /><a href="#PrintPhenotypeData">PrintPhenotypeData</a>
- </td>
- <td>
- <a href="#PrintPhenotypeStatus">PrintPhenotypeStatus</a>
+ <br /><a href="#PrintPhenotypeStatus">PrintPhenotypeStatus</a>
<br /><a href="#PrintPhenotypicPlasticity">PrintPhenotypicPlasticity</a>
<br /><a href="#PrintPopulationDistanceData">PrintPopulationDistanceData</a>
<br /><a href="#PrintRelativeFitnessHistogram">PrintRelativeFitnessHistogram</a>
- <br /><a href="#PrintResourceData">PrintResourceData</a>
+ </td>
+ <td>
+ <a href="#PrintResourceData">PrintResourceData</a>
<br /><a href="#PrintSpeciesAbundanceData">PrintSpeciesAbundanceData</a>
<br /><a href="#PrintStatsData">PrintStatsData</a>
<br /><a href="#PrintTasksSnapshot">PrintTasksSnapshot</a>
@@ -154,11 +154,16 @@
<br /><a href="#SavePopulation">SavePopulation</a>
<br /><a href="#SaveSexPopulation">SaveSexPopulation</a>
<br /><a href="#SerialTransfer">SerialTransfer</a>
+ <br /><a href="#SetEnvironmentInputs">SetEnvironmentInputs</a>
<br /><a href="#SetMutProb">SetMutProb</a>
<br /><a href="#SetReactionInst">SetReactionInst</a>
+ <br /><a href="#SetReactionMinTaskCount">SetReactionMinTaskCount</a>
+ <br /><a href="#SetReactionMaxTaskCount">SetReactionMaxTaskCount</a>
<br /><a href="#SetReactionValue">SetReactionValue</a>
<br /><a href="#SetReactionValueMult">SetReactionValueMult</a>
<br /><a href="#SetResource">SetResource</a>
+ <br /><a href="#SetResourceInflow">SetResourceInflow</a>
+ <br /><a href="#SetResourceOutflow">SetResourceOutflow</a>
<br /><a href="#SetVerbose">SetVerbose</a>
<br /><a href="#SeverGridCol">SeverGridCol</a>
<br /><a href="#SeverGridRow">SeverGridRow</a>
@@ -1010,7 +1015,21 @@
<p>
</p>
</li>
+
<li>
+ <strong><a name="SetEnvironmentInputs">SetEnvironmentInputs</a></strong>
+ <<span class="cmdarg">int input.1</span>> <<span class="cmdarg">int input.2</span>>
+ <<span class="cmdarg">int input.3</span>>
+
+ <p>
+ Set the inputs that all organisms get from the environment when doing IO to these specific values. There must
+ be exactly three inputs, and they must have the usual values for the top 8 "key" bits, i.e. they must be of the form
+ 0x0F?????? 0x33?????? 0x55?????? where ? can be replaced with any hexadecimal digit.
+ </p>
+</li>
+
+
+<li>
<strong><a name="SetResource">SetResource</a></strong>
<<span class="cmdarg">string res_name</span>> <<span class="cmdarg">double res_count</span>>
@@ -1022,6 +1041,29 @@
</li>
<li>
+ <strong><a name="SetResourceInflow">SetResourceInflow</a></strong>
+ <<span class="cmdarg">string res_name</span>> <<span class="cmdarg">double inflow</span>>
+
+ <p>
+ Set the resource inflow to a specific level.
+ <span class="cmdarg">res_name</span> must already exist as
+ a resource in environment file.
+ </p>
+</li>
+
+<li>
+ <strong><a name="SetResourceOutflow">SetResourceOutflow</a></strong>
+ <<span class="cmdarg">string res_name</span>> <<span class="cmdarg">double outflow</span>>
+
+ <p>
+ Set the resource outflow to a specific level.
+ <span class="cmdarg">res_name</span> must already exist as
+ a resource in environment file.
+ </p>
+</li>
+
+
+<li>
<strong><a name="SetReactionValue">SetReactionValue</a></strong>
<<span class="cmdarg">string reaction_name</span>> <<span class="cmdarg">double value</span>>
@@ -1033,6 +1075,28 @@
</p>
</li>
<li>
+ <strong><a name="SetReactionMinTaskCount">SetReactionMinTaskCount</a></strong>
+ <<span class="cmdarg">string reaction_name</span>> <<span class="cmdarg">int task_count</span>>
+
+ <p>
+ Set the min task count required to trigger a reaction to <span class="cmdarg">task_count</span>.
+ <span class="cmdarg">reaction_name</span> must already
+ exist in the environment file.
+ </p>
+</li>
+
+<li>
+ <strong><a name="SetReactionMaxTaskCount">SetReactionMaxTaskCount</a></strong>
+ <<span class="cmdarg">string reaction_name</span>> <<span class="cmdarg">int task_count</span>>
+
+ <p>
+ Set the max task count required to trigger a reaction to <span class="cmdarg">task_count</span>.
+ <span class="cmdarg">reaction_name</span> must already
+ exist in the environment file.
+ </p>
+</li>
+
+<li>
<strong><a name="SetReactionValueMult">SetReactionValueMult</a></strong>
<<span class="cmdarg">string reaction_name</span>> <<span class="cmdarg">double value</span>>
Modified: branches/collect/documentation/analyze.html
===================================================================
--- branches/collect/documentation/analyze.html 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/documentation/analyze.html 2007-10-24 14:05:38 UTC (rev 2154)
@@ -356,6 +356,14 @@
have been loaded in, or a RECALCULATE (or RECALC) must have been run to collect
it.
</dd>
+<dt><strong>
+ PRINT_PHENOTYPES [<span class="cmdargopt">file='phenotype.dat']
+ [<span class="cmdargopt">total_task_count]
+ [<span class="cmdargopt">total_task_performance_count]
+</strong></dt>
+<dd>
+ Prints phenotypes in the current batch as determined by task-signature. Default statistics for each phenotype are number of organisms, number of genotypes, average genome length, average gestation time, viability, and tasks performed. Using the total_task_count and/or total_task_performance_count flags will add that statistic to the output. (In the case of total_task_performance_count, this will be an average over the members of the phenotype.)
+</dd>
<dt><strong>DETAIL [<span class="cmdargopt">file='detail.dat'</span>] [<span class="cmdargopt">format ...</span>]</strong></dt>
<dd>
Print out all of the stats for each genotype, one per line. The
@@ -621,6 +629,10 @@
<tr>
<td><strong>task.n</strong> (# of times task number n is done)</td>
<td><strong>task.n:binary</strong> (is task n done, 0/1)</td>
+ <td><strong>total_task_count</strong> (# of different tasks done)</td>
+</tr>
+<tr>
+ <td><strong>total_task_performance_count</strong> (total # of tasks done)</td>
<td><strong>inst.n</strong> (# of times instruction number n is done)</td>
</tr>
</table>
Copied: branches/collect/documentation/energy_model.html (from rev 2073, development/documentation/energy_model.html)
===================================================================
--- branches/collect/documentation/energy_model.html (rev 0)
+++ branches/collect/documentation/energy_model.html 2007-10-24 14:05:38 UTC (rev 2154)
@@ -0,0 +1,131 @@
+<html>
+<head>
+ <title>Avida : Energy Model</title>
+ <link rel="stylesheet" type="text/css" href="main.css" />
+</head>
+<body>
+
+<div class="revision">
+Revised 2007-07-07 BEB
+</div>
+
+<p>
+<a href="index.html">Return to the Index</a> |
+<a href="config.html">The Configuration File</a>
+</p>
+<hr />
+
+<div align="center">
+<h1>Energy Model</h1>
+</div>
+
+<a name="Overview"><h2>Overview</h2></a>
+<p>
+The energy model provides an organism with a metabolic rate, which is proportional to its stored energy (shown below).
+
+An organism with a higher metabolic rate will pay more energy to execute instructions than one with a lower rate.
+
+An organism must pay both virtual CPU cycle and energy costs to execute instructions.
+
+As instructions are executed the organism's stored energy level is reduced.
+
+Energy can be taken up by the organism when it completes a task, among others.
+</p>
+
+<center>
+Metabolic Rate = Stored Energy / <a href="#NUM_INST_EXC_BEFORE_0_ENERGY">NUM_INST_EXC_BEFORE_0_ENERGY</a>
+</center>
+
+<a name="Settings"><h2>Settings</h2></a>
+<p>
+The settings below are defults from <code>avida.cfg</code>
+<pre>
+### ENERGY_GROUP ###
+# Energy Settings
+<a href="#ENERGY_ENABLED">ENERGY_ENABLED</a> 0 # Enable Energy Model. 0/1 (off/on)
+<a href="#ENERGY_GIVEN_ON_INJECT">ENERGY_GIVEN_ON_INJECT</a> 0 # Energy given to organism upon injection.
+<a href="#ENERGY_GIVEN_AT_BIRTH">ENERGY_GIVEN_AT_BIRTH</a> 0 # Energy given to offspring upon birth.
+<a href="#FRAC_PARENT_ENERGY_GIVEN_AT_BIRTH">FRAC_PARENT_ENERGY_GIVEN_AT_BIRTH</a> 0.5 # Fraction of perent's energy given to offspring.
+<a href="#FRAC_ENERGY_DECAY_AT_BIRTH">FRAC_ENERGY_DECAY_AT_BIRTH</a> 0.0 # Fraction of energy lost due to decay during reproduction.
+<a href="#NUM_INST_EXC_BEFORE_0_ENERGY">NUM_INST_EXC_BEFORE_0_ENERGY</a> 0 # Number of instructions executed before energy is exhausted.
+<a href="#ENERGY_CAP">ENERGY_CAP</a> -1 # Maximum amount of energy that can be stored in an organism.
+ # -1 means the cap is set to Max Int
+<a href="#APPLY_ENERGY_METHOD">APPLY_ENERGY_METHOD</a> 0 # When should rewarded energy be applied to current energy?
+ # 0 = on divide
+ # 1 = on completion of task
+ # 2 = on sleep
+<a href="#FRAC_ENERGY_TRANSFER">FRAC_ENERGY_TRANSFER</a> 0.0 # Fraction of replaced organism's energy take by new resident
+<a href="#LOG_SLEEP_TIMES">LOG_SLEEP_TIMES</a> 0 # Log sleep start and end times. 0/1 (off/on)
+ # WARNING: may use lots of memory.
+</pre>
+</p>
+
+<a name="Description of Settings"><h2>Description of Settings</h2></a>
+<strong><a name="ENERGY_ENABLED">ENERGY_ENABLED</a></strong>
+<p>
+Flag that disables/enables the us of the energy model.
+
+0 = off, 1 = on
+</p>
+
+<strong><a name="ENERGY_GIVEN_ON_INJECT">ENERGY_GIVEN_ON_INJECT</a></strong>
+<p>
+How much energy is given to an injected organism.
+
+This number should be large enough to sustain the population until it can gather its own energy through tasks, etc..
+</p>
+
+<strong><a name="ENERGY_GIVEN_AT_BIRTH">ENERGY_GIVEN_AT_BIRTH</a></strong>
+<p>
+How much energy is given to an organism when it is born.
+</p>
+
+<strong><a name="FRAC_PARENT_ENERGY_GIVEN_AT_BIRTH">FRAC_PARENT_ENERGY_GIVEN_AT_BIRTH</a></strong>
+<p>
+Fraction of the parent(s) energy which is taken from the parent and given to the offspring at birth.
+</p>
+
+<strong><a name="FRAC_ENERGY_DECAY_AT_BIRTH">FRAC_ENERGY_DECAY_AT_BIRTH</a></strong>
+<p>
+Fraction of energy that decays on birth.
+</p>
+
+<strong><a name="NUM_INST_EXC_BEFORE_0_ENERGY">NUM_INST_EXC_BEFORE_0_ENERGY</a></strong>
+<p>
+Number of instructions an organism can execute before it runs out of energy assuming no new energy.
+
+Note: if instructions have energy costs > 0 then this options needs to be altered accordingly.
+</p>
+
+<strong><a name="ENERGY_CAP">ENERGY_CAP</a></strong>
+<p>
+Maximum amount of energy that can be stored in an organism.
+</p>
+
+<strong><a name="APPLY_ENERGY_METHOD">APPLY_ENERGY_METHOD</a></strong>
+<p>
+Specifies when newly received energy is applied to the organism energy store and metabolic rate.
+
+Note: the <code>sleep</code> instruction can also be used as an eat instructions if needed.
+</p>
+
+<strong><a name="FRAC_ENERGY_TRANSFER">FRAC_ENERGY_TRANSFER</a></strong>
+<p>
+Fraction of a replaced organism's energy transfered to the replacing organism.
+</p>
+
+<strong><a name="LOG_SLEEP_TIMES">LOG_SLEEP_TIMES</a></strong>
+<p>
+Logs start and end times, in updates, of all executions of the <code>sleep</code> instruction.
+
+Note: can use a lot of memory.
+</p>
+
+<hr />
+<p>
+<a href="index.html">Return to the Index</a> |
+<a href="config.html">The Configuration File</a>
+</p>
+
+</body>
+</html>
Modified: branches/collect/documentation/environment.html
===================================================================
--- branches/collect/documentation/environment.html 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/documentation/environment.html 2007-10-24 14:05:38 UTC (rev 2154)
@@ -266,8 +266,8 @@
from the top and flows towards the bottom where it exits the system,
you could use:
<pre>
- RESOURCE lactose:initial=100000:inflow=100:outflow=0.1:inflowx1=0:\
- inflowx2=100:inflowy1=0:inflowy2=0:outflowx1=0:outflowx2=100:\
+ RESOURCE lactose:geometry=grid:initial=100000:inflow=100:outflow=0.1:\
+ inflowx1=0:inflowx2=100:inflowy1=0:inflowy2=0:outflowx1=0:outflowx2=100:\
outflowy1=100:outflowy2=100:ygravity=0.5
</pre>
</p>
Modified: branches/collect/documentation/index.html
===================================================================
--- branches/collect/documentation/index.html 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/documentation/index.html 2007-10-24 14:05:38 UTC (rev 2154)
@@ -31,6 +31,7 @@
<p>
<a href="config.html">Setting up the Avida Configuration File</a>
+<br /><a href="energy_model.html">Energy model configuration</a>
<br /><a href="inst_set.html">Setting up the Instruction Set</a>
<br /><a href="events.html">Guidelines to setting up the Events File</a>
<br /><a href="environment.html">Guidelines to setting up Environments</a>
Modified: branches/collect/source/actions/EnvironmentActions.cc
===================================================================
--- branches/collect/source/actions/EnvironmentActions.cc 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/actions/EnvironmentActions.cc 2007-10-24 14:05:38 UTC (rev 2154)
@@ -266,6 +266,146 @@
}
};
+class cActionSetReactionMinTaskCount : public cAction
+{
+private:
+ cString m_name;
+ int m_min_count;
+
+public:
+ cActionSetReactionMinTaskCount(cWorld* world, const cString& args) : cAction(world, args), m_name(""), m_min_count(0)
+ {
+ cString largs(args);
+ if (largs.GetSize()) m_name = largs.PopWord();
+ if (largs.GetSize()) m_min_count = largs.PopWord().AsInt();
+ }
+
+ static const cString GetDescription() { return "Arguments: <string reaction_name> <int min_count>"; }
+
+ void Process(cAvidaContext& ctx)
+ {
+ m_world->GetEnvironment().SetReactionMinTaskCount(m_name, m_min_count);
+ }
+};
+
+class cActionSetReactionMaxTaskCount : public cAction
+{
+private:
+ cString m_name;
+ int m_max_count;
+
+public:
+ cActionSetReactionMaxTaskCount(cWorld* world, const cString& args) : cAction(world, args), m_name(""), m_max_count(0)
+ {
+ cString largs(args);
+ if (largs.GetSize()) m_name = largs.PopWord();
+ if (largs.GetSize()) m_max_count = largs.PopWord().AsInt();
+ }
+
+ static const cString GetDescription() { return "Arguments: <string reaction_name> <int max_count>"; }
+
+ void Process(cAvidaContext& ctx)
+ {
+ m_world->GetEnvironment().SetReactionMaxTaskCount(m_name, m_max_count);
+ }
+};
+
+class cActionSetResourceInflow : public cAction
+{
+private:
+ cString m_name;
+ double m_inflow;
+
+public:
+ cActionSetResourceInflow(cWorld* world, const cString& args) : cAction(world, args), m_name(""), m_inflow(0.0)
+ {
+ cString largs(args);
+ if (largs.GetSize()) m_name = largs.PopWord();
+ if (largs.GetSize()) m_inflow = largs.PopWord().AsDouble();
+ }
+
+ static const cString GetDescription() { return "Arguments: <string resource_name> <int inflow>"; }
+
+ void Process(cAvidaContext& ctx)
+ {
+ m_world->GetEnvironment().SetResourceInflow(m_name, m_inflow);
+ //This doesn't actually update the rate in the population, so...
+ m_world->GetPopulation().GetResourceCount().SetInflow(m_name, m_inflow);
+ }
+};
+
+class cActionSetResourceOutflow : public cAction
+{
+private:
+ cString m_name;
+ double m_outflow;
+
+public:
+ cActionSetResourceOutflow(cWorld* world, const cString& args) : cAction(world, args), m_name(""), m_outflow(0.0)
+ {
+ cString largs(args);
+ if (largs.GetSize()) m_name = largs.PopWord();
+ if (largs.GetSize()) m_outflow = largs.PopWord().AsDouble();
+ assert(m_outflow < 1.0);
+ assert(m_outflow > 0.0);
+ }
+
+ static const cString GetDescription() { return "Arguments: <string resource_name> <int outflow>"; }
+
+ void Process(cAvidaContext& ctx)
+ {
+ m_world->GetEnvironment().SetResourceOutflow(m_name, m_outflow);
+ //This doesn't actually update the rate in the population, so...
+ m_world->GetPopulation().GetResourceCount().SetDecay(m_name, 1-m_outflow);
+ }
+};
+
+class cActionSetEnvironmentInputs : public cAction
+{
+private:
+ tArray<int> m_inputs;
+
+public:
+ cActionSetEnvironmentInputs(cWorld* world, const cString& args) : cAction(world, args), m_inputs()
+ {
+ cString largs(args);
+ if (largs.GetSize()) m_inputs.Push(largs.PopWord().AsInt());
+ if (largs.GetSize()) m_inputs.Push(largs.PopWord().AsInt());
+ if (largs.GetSize()) m_inputs.Push(largs.PopWord().AsInt());
+
+ if ( m_inputs.GetSize() != 3 )
+ {
+ cerr << "Must have exactly 3 inputs for SetEnvironmentInputs action." << endl;
+ exit(1);
+ }
+
+ if ( (m_inputs[0] >> 24 != 15) || (m_inputs[1] >> 24 != 51) || (m_inputs[2] >> 24 != 85) )
+ {
+ cerr << "Inputs must begin 0F, 33, 55 for SetEnvironmentInputs" << endl;
+ cerr << "They are: " << m_inputs[0] << " " << m_inputs[1] << " " << m_inputs[2] << endl;
+ exit(1);
+ }
+
+ }
+
+ static const cString GetDescription() { return "Arguments: <int input_1> <int input_2> <int input_3> "; }
+
+ void Process(cAvidaContext& ctx)
+ {
+ //First change the environmental inputs
+ cEnvironment& env = m_world->GetEnvironment();
+ env.SetSpecificInputs(m_inputs);
+
+ //Now immediately change the inputs in each cell and
+ //clear the input array of each organism so changes take effect
+
+ cPopulation& pop = m_world->GetPopulation();
+ pop.ResetInputs(ctx);
+ }
+};
+
+
+
class cActionSetTaskArgInt : public cAction
{
private:
@@ -498,7 +638,14 @@
action_lib->Register<cActionSetReactionValue>("SetReactionValue");
action_lib->Register<cActionSetReactionValueMult>("SetReactionValueMult");
action_lib->Register<cActionSetReactionInst>("SetReactionInst");
+ action_lib->Register<cActionSetReactionMinTaskCount>("SetReactionMinTaskCount");
+ action_lib->Register<cActionSetReactionMaxTaskCount>("SetReactionMaxTaskCount");
+ action_lib->Register<cActionSetResourceInflow>("SetResourceInflow");
+ action_lib->Register<cActionSetResourceOutflow>("SetResourceOutflow");
+
+ action_lib->Register<cActionSetEnvironmentInputs>("SetEnvironmentInputs");
+
action_lib->Register<cActionSetPeriodicResource>("SetPeriodicResource");
action_lib->Register<cActionSetNumInstBefore0Energy>("SetNumInstBefore0Energy");
Modified: branches/collect/source/actions/PopulationActions.cc
===================================================================
--- branches/collect/source/actions/PopulationActions.cc 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/actions/PopulationActions.cc 2007-10-24 14:05:38 UTC (rev 2154)
@@ -1182,16 +1182,30 @@
m_world->GetDriver().RaiseException(err);
return;
}
+
// Loop through all of the rows and make the cut on each...
for (int row_id = m_min; row_id < m_max; row_id++) {
+ //col is always the same -- compute which row to make the cut
int idA = row_id * world_x + m_id;
int idB = GridNeighbor(idA, world_x, world_y, -1, 0);
+
int idA0 = GridNeighbor(idA, world_x, world_y, 0, -1);
int idA1 = GridNeighbor(idA, world_x, world_y, 0, 1);
+
int idB0 = GridNeighbor(idA, world_x, world_y, -1, -1);
int idB1 = GridNeighbor(idA, world_x, world_y, -1, 1);
+
cPopulationCell& cellA = m_world->GetPopulation().GetCell(idA);
cPopulationCell& cellB = m_world->GetPopulation().GetCell(idB);
+
+ #ifdef DEBUG
+ int temp_x = 0, temp_y = 0;
+ cellA.GetPosition(temp_x,temp_y);
+ cerr << "cellA: " << temp_x << " " << temp_y << endl;
+ cellB.GetPosition(temp_x,temp_y);
+ cerr << "cellB: " << temp_x << " " << temp_y << endl;
+ #endif
+
tList<cPopulationCell>& cellA_list = cellA.ConnectionList();
tList<cPopulationCell>& cellB_list = cellB.ConnectionList();
cellA_list.Remove(&m_world->GetPopulation().GetCell(idB));
@@ -1208,7 +1222,7 @@
///// sever_grid_row /////
/*
- Remove the connections between cells along a column in an avida grid.
+ Remove the connections between cells along a row in an avida grid.
Arguments:
row_id: indicates the number of rows above the cut.
@@ -1246,16 +1260,29 @@
m_world->GetDriver().RaiseException(err);
return;
}
- // Loop through all of the rows and make the cut on each...
+
+ // Loop through all of the cols and make the cut on each...
for (int col_id = m_min; col_id < m_max; col_id++) {
- int idA = col_id * world_y + m_id;
+ //row is always the same -- only the column changes -- could also do this in the loop
+ int idA = m_id * world_x + col_id;
int idB = GridNeighbor(idA, world_x, world_y, 0, -1);
+
int idA0 = GridNeighbor(idA, world_x, world_y, -1, 0);
int idA1 = GridNeighbor(idA, world_x, world_y, 1, 0);
+
int idB0 = GridNeighbor(idA, world_x, world_y, -1, -1);
int idB1 = GridNeighbor(idA, world_x, world_y, 1, -1);
cPopulationCell& cellA = m_world->GetPopulation().GetCell(idA);
cPopulationCell& cellB = m_world->GetPopulation().GetCell(idB);
+
+ #ifdef DEBUG
+ int temp_x = 0, temp_y = 0;
+ cellA.GetPosition(temp_x,temp_y);
+ cerr << "cellA: " << temp_x << " " << temp_y << endl;
+ cellB.GetPosition(temp_x,temp_y);
+ cerr << "cellB: " << temp_x << " " << temp_y << endl;
+ #endif
+
tList<cPopulationCell>& cellA_list = cellA.ConnectionList();
tList<cPopulationCell>& cellB_list = cellB.ConnectionList();
cellA_list.Remove(&m_world->GetPopulation().GetCell(idB));
@@ -1301,6 +1328,7 @@
{
const int world_x = m_world->GetPopulation().GetWorldX();
const int world_y = m_world->GetPopulation().GetWorldY();
+ const int geometry = m_world->GetConfig().WORLD_GEOMETRY.Get();
if (m_id == -1) m_id = world_x / 2;
if (m_max == -1) m_max = world_y;
if (m_id < 0 || m_id >= world_x) {
@@ -1310,22 +1338,35 @@
}
// Loop through all of the rows and make the cut on each...
for (int row_id = m_min; row_id < m_max; row_id++) {
+ //compute which cells to be joined -- grab them from the population
int idA = row_id * world_x + m_id;
int idB = GridNeighbor(idA, world_x, world_y, -1, 0);
cPopulationCell& cellA = m_world->GetPopulation().GetCell(idA);
cPopulationCell& cellB = m_world->GetPopulation().GetCell(idB);
- cPopulationCell& cellA0 = m_world->GetPopulation().GetCell(GridNeighbor(idA, world_x, world_y, 0, -1));
- cPopulationCell& cellA1 = m_world->GetPopulation().GetCell(GridNeighbor(idA, world_x, world_y, 0, 1));
- cPopulationCell& cellB0 = m_world->GetPopulation().GetCell(GridNeighbor(idA, world_x, world_y, -1, -1));
- cPopulationCell& cellB1 = m_world->GetPopulation().GetCell(GridNeighbor(idA, world_x, world_y, -1, 1));
+
+ //grab the cell lists
tList<cPopulationCell>& cellA_list = cellA.ConnectionList();
tList<cPopulationCell>& cellB_list = cellB.ConnectionList();
+
+ //these cells are always joined
if (cellA_list.FindPtr(&cellB) == NULL) cellA_list.Push(&cellB);
- if (cellA_list.FindPtr(&cellB0) == NULL) cellA_list.Push(&cellB0);
- if (cellA_list.FindPtr(&cellB1) == NULL) cellA_list.Push(&cellB1);
if (cellB_list.FindPtr(&cellA) == NULL) cellB_list.Push(&cellA);
- if (cellB_list.FindPtr(&cellA0) == NULL) cellB_list.Push(&cellA0);
- if (cellB_list.FindPtr(&cellA1) == NULL) cellB_list.Push(&cellA1);
+
+ //make sure we don't break the bounded grid at the top
+ if((nGeometry::GRID == geometry && row_id != 0) || nGeometry::GRID != geometry){
+ cPopulationCell& cellA0 = m_world->GetPopulation().GetCell(GridNeighbor(idA, world_x, world_y, 0, -1));
+ cPopulationCell& cellB0 = m_world->GetPopulation().GetCell(GridNeighbor(idA, world_x, world_y, -1, -1));
+ if (cellA_list.FindPtr(&cellB0) == NULL) cellA_list.Push(&cellB0);
+ if (cellB_list.FindPtr(&cellA0) == NULL) cellB_list.Push(&cellA0);
+ }
+
+ //make sure we don't break the bounded grid at the bottom
+ if((nGeometry::GRID == geometry && row_id != (world_y-1)) || nGeometry::GRID != geometry){
+ cPopulationCell& cellA1 = m_world->GetPopulation().GetCell(GridNeighbor(idA, world_x, world_y, 0, 1));
+ cPopulationCell& cellB1 = m_world->GetPopulation().GetCell(GridNeighbor(idA, world_x, world_y, -1, 1));
+ if (cellA_list.FindPtr(&cellB1) == NULL) cellA_list.Push(&cellB1);
+ if (cellB_list.FindPtr(&cellA1) == NULL) cellB_list.Push(&cellA1);
+ }
}
}
};
@@ -1363,6 +1404,7 @@
{
const int world_x = m_world->GetPopulation().GetWorldX();
const int world_y = m_world->GetPopulation().GetWorldY();
+ const int geometry = m_world->GetConfig().WORLD_GEOMETRY.Get();
if (m_id == -1) m_id = world_y / 2;
if (m_max == -1) m_max = world_x;
if (m_id < 0 || m_id >= world_y) {
@@ -1372,22 +1414,35 @@
}
// Loop through all of the rows and make the cut on each...
for (int col_id = m_min; col_id < m_max; col_id++) {
- int idA = col_id * world_y + m_id;
+ //compute which cells are beoing joined and grab them
+ int idA = m_id * world_x + col_id;
int idB = GridNeighbor(idA, world_x, world_y, 0, -1);
cPopulationCell& cellA = m_world->GetPopulation().GetCell(idA);
cPopulationCell& cellB = m_world->GetPopulation().GetCell(idB);
- cPopulationCell& cellA0 = m_world->GetPopulation().GetCell(GridNeighbor(idA, world_x, world_y, -1, 0));
- cPopulationCell& cellA1 = m_world->GetPopulation().GetCell(GridNeighbor(idA, world_x, world_y, 1, 0));
- cPopulationCell& cellB0 = m_world->GetPopulation().GetCell(GridNeighbor(idA, world_x, world_y, -1, -1));
- cPopulationCell& cellB1 = m_world->GetPopulation().GetCell(GridNeighbor(idA, world_x, world_y, 1, -1));
+
+ //grab the cell lists
tList<cPopulationCell>& cellA_list = cellA.ConnectionList();
tList<cPopulationCell>& cellB_list = cellB.ConnectionList();
+
+ //these cells are always joined
if (cellA_list.FindPtr(&cellB) == NULL) cellA_list.Push(&cellB);
- if (cellA_list.FindPtr(&cellB0) == NULL) cellA_list.Push(&cellB0);
- if (cellA_list.FindPtr(&cellB1) == NULL) cellA_list.Push(&cellB1);
if (cellB_list.FindPtr(&cellA) == NULL) cellB_list.Push(&cellA);
- if (cellB_list.FindPtr(&cellA0) == NULL) cellB_list.Push(&cellA0);
- if (cellB_list.FindPtr(&cellA1) == NULL) cellB_list.Push(&cellA1);
+
+ //make sure we don't break the bounded grid on the left
+ if((nGeometry::GRID == geometry && col_id != 0) || nGeometry::GRID != geometry){
+ cPopulationCell& cellA0 = m_world->GetPopulation().GetCell(GridNeighbor(idA, world_x, world_y, -1, 0));
+ cPopulationCell& cellB0 = m_world->GetPopulation().GetCell(GridNeighbor(idA, world_x, world_y, -1, -1));
+ if (cellA_list.FindPtr(&cellB0) == NULL) cellA_list.Push(&cellB0);
+ if (cellB_list.FindPtr(&cellA0) == NULL) cellB_list.Push(&cellA0);
+ }
+
+ //make cure we don't break the bounded grid on the right
+ if((nGeometry::GRID == geometry && col_id != (world_x-1)) || nGeometry::GRID != geometry){
+ cPopulationCell& cellA1 = m_world->GetPopulation().GetCell(GridNeighbor(idA, world_x, world_y, 1, 0));
+ cPopulationCell& cellB1 = m_world->GetPopulation().GetCell(GridNeighbor(idA, world_x, world_y, 1, -1));
+ if (cellA_list.FindPtr(&cellB1) == NULL) cellA_list.Push(&cellB1);
+ if (cellB_list.FindPtr(&cellA1) == NULL) cellB_list.Push(&cellA1);
+ }
}
}
};
Modified: branches/collect/source/analyze/cAnalyze.cc
===================================================================
--- branches/collect/source/analyze/cAnalyze.cc 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/analyze/cAnalyze.cc 2007-10-24 14:05:38 UTC (rev 2154)
@@ -2554,7 +2554,16 @@
// Load in the variables...
cString filename("phenotype.dat");
if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-
+
+ cString flag("");
+ bool print_ttc = false;
+ bool print_ttpc = false;
+ while (cur_string.GetSize() != 0) {
+ flag = cur_string.PopWord();
+ if (flag == "total_task_count") print_ttc = true;
+ else if (flag == "total_task_performance_count") print_ttpc = true;
+ }
+
// Make sure we have at least one genotype...
if (batch[cur_batch].List().GetSize() == 0) return;
@@ -2565,11 +2574,15 @@
tArray<int> genotype_counts(num_phenotypes);
tArray<double> total_length(num_phenotypes);
tArray<double> total_gest(num_phenotypes);
+ tArray<int> total_task_count(num_phenotypes);
+ tArray<int> total_task_performance_count(num_phenotypes);
phenotype_counts.SetAll(0);
genotype_counts.SetAll(0);
total_length.SetAll(0.0);
total_gest.SetAll(0.0);
+ total_task_count.SetAll(0);
+ total_task_performance_count.SetAll(0);
// Loop through all of the genotypes in this batch...
tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
@@ -2584,6 +2597,10 @@
genotype_counts[phen_id]++;
total_length[phen_id] += genotype->GetNumCPUs() * genotype->GetLength();
total_gest[phen_id] += genotype->GetNumCPUs() * genotype->GetGestTime();
+ for (int i = 0; i < num_tasks; i++) {
+ total_task_count[phen_id] += ((genotype->GetTaskCount(i) > 0) ? 1 : 0);
+ total_task_performance_count[phen_id] += genotype->GetTaskCount(i);
+ }
}
// Print out the results...
@@ -2594,9 +2611,22 @@
<< "# 2: Number of genotypes of this phenotye" << endl
<< "# 3: Average Genome Length" << endl
<< "# 4: Average Gestation Time" << endl
- << "# 5: Viability of Phenotype" << endl
- << "# 6+: Tasks performed in this phenotype" << endl
- << endl;
+ << "# 5: Viability of Phenotype" << endl;
+ if (print_ttc && print_ttpc) {
+ fp << "# 6: Total # of different tasks performed by this phenotype" << endl
+ << "# 7: Average # of tasks performed by this phenotype" << endl
+ << "# 8+: Tasks performed in this phenotype" << endl;
+ }
+ else if (print_ttc) {
+ fp << "# 6: Total # of different tasks performed by this phenotype" << endl
+ << "# 7+: Tasks performed in this phenotype" << endl;
+ }
+ else if (print_ttpc) {
+ fp << "# 6: Total # of tasks performed by this phenotype" << endl
+ << "# 7+: Tasks performed in this phenotype" << endl;
+ }
+ else { fp << "# 6+: Tasks performed in this phenotype" << endl; }
+ fp << endl;
// @CAO Lets do this inefficiently for the moment, but print out the
// phenotypes in order.
@@ -2619,6 +2649,10 @@
<< total_length[max_position] / phenotype_counts[max_position] << " "
<< total_gest[max_position] / phenotype_counts[max_position] << " "
<< (max_position & 1) << " ";
+ if (print_ttc) { fp << total_task_count[max_position] / genotype_counts[max_position] << " "; }
+ if (print_ttpc) {
+ fp << total_task_performance_count[max_position] / genotype_counts[max_position] << " ";
+ }
for (int i = 1; i <= num_tasks; i++) {
if ((max_position >> i) & 1 > 0) fp << "1 ";
else fp << "0 ";
@@ -8273,6 +8307,10 @@
(i_name, i_desc, &cAnalyzeGenotype::GetInstExecutedCount, i));
}
+ // coarse-grained task stats
+ ADD_GDATA(int, "total_task_count","# Different Tasks", GetTotalTaskCount, SetNULL, 1, 0, 0);
+ ADD_GDATA(int, "total_task_performance_count", "Total Tasks Performed", GetTotalTaskPerformanceCount, SetNULL, 1, 0, 0);
+
const cEnvironment& environment = m_world->GetEnvironment();
for (int i = 0; i < environment.GetNumTasks(); i++) {
cString t_name, t_desc;
Modified: branches/collect/source/analyze/cAnalyzeGenotype.cc
===================================================================
--- branches/collect/source/analyze/cAnalyzeGenotype.cc 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/analyze/cAnalyzeGenotype.cc 2007-10-24 14:05:38 UTC (rev 2154)
@@ -403,6 +403,7 @@
void cAnalyzeGenotype::Recalculate(cAvidaContext& ctx, cTestCPU* testcpu, cAnalyzeGenotype* parent_genotype, cCPUTestInfo* test_info, int num_trials)
{
+ // We are not going to use this testcpu ...
//Allocate our own test info if it wasn't provided
cCPUTestInfo* temp_test_info = NULL;
Modified: branches/collect/source/analyze/cAnalyzeGenotype.h
===================================================================
--- branches/collect/source/analyze/cAnalyzeGenotype.h 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/analyze/cAnalyzeGenotype.h 2007-10-24 14:05:38 UTC (rev 2154)
@@ -385,6 +385,31 @@
const tArray<int> & GetTaskCounts() const {
return task_counts;
}
+
+ double GetTaskQuality(int task_id) const {
+ if (task_id >= task_counts.GetSize()) return 0;
+ return task_qualities[task_id];
+ }
+ const tArray<double> & GetTaskQualities() const {
+ return task_qualities;
+ }
+
+ // number of different tasks performed
+ int GetTotalTaskCount() const {
+ int total_task_count = 0;
+ for(int i = 0; i < task_counts.GetSize(); i++)
+ { if (task_counts[i] > 0) total_task_count++; }
+ return total_task_count;
+ }
+
+ // total number of tasks performed, including multiple performances
+ int GetTotalTaskPerformanceCount() const {
+ int total_task_performance_count = 0;
+ for(int i = 0; i < task_counts.GetSize(); i++)
+ { total_task_performance_count += task_counts[i]; }
+ return total_task_performance_count;
+ }
+
int GetEnvInput(int input_id) const{
if (input_id >= m_env_inputs.GetSize()) return 0;
return m_env_inputs[input_id];
@@ -393,14 +418,6 @@
return m_env_inputs;
}
- double GetTaskQuality(int task_id) const {
- if (task_id >= task_counts.GetSize()) return 0;
- return task_qualities[task_id];
- }
- const tArray<double> & GetTaskQualities() const {
- return task_qualities;
- }
-
// Comparisons... Compares a genotype to the "previous" one, which is
// passed in, in one specified phenotype.
// Return values are:
Modified: branches/collect/source/cpu/cHardwareBase.cc
===================================================================
--- branches/collect/source/cpu/cHardwareBase.cc 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/cpu/cHardwareBase.cc 2007-10-24 14:05:38 UTC (rev 2154)
@@ -799,6 +799,9 @@
// @JEB Check implicit repro conditions -- meant to be called at the end of SingleProcess
void cHardwareBase::CheckImplicitRepro(cAvidaContext& ctx, bool exec_last_inst)
{
+ //Dividing a dead organism causes all kinds of problems
+ if (organism->IsDead()) return;
+
if( (m_world->GetConfig().IMPLICIT_REPRO_TIME.Get() && (organism->GetPhenotype().GetTimeUsed() >= m_world->GetConfig().IMPLICIT_REPRO_TIME.Get()))
|| (m_world->GetConfig().IMPLICIT_REPRO_CPU_CYCLES.Get() && (organism->GetPhenotype().GetCPUCyclesUsed() >= m_world->GetConfig().IMPLICIT_REPRO_CPU_CYCLES.Get()))
|| (m_world->GetConfig().IMPLICIT_REPRO_BONUS.Get() && (organism->GetPhenotype().GetCurBonus() >= m_world->GetConfig().IMPLICIT_REPRO_BONUS.Get()))
Modified: branches/collect/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/collect/source/cpu/cHardwareCPU.cc 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/cpu/cHardwareCPU.cc 2007-10-24 14:05:38 UTC (rev 2154)
@@ -365,8 +365,13 @@
tInstLibEntry<tMethod>("promoter", &cHardwareCPU::Inst_Promoter),
tInstLibEntry<tMethod>("terminate", &cHardwareCPU::Inst_Terminate),
tInstLibEntry<tMethod>("regulate", &cHardwareCPU::Inst_Regulate),
+ tInstLibEntry<tMethod>("regulate-sp", &cHardwareCPU::Inst_RegulateSpecificPromoters),
+ tInstLibEntry<tMethod>("s-regulate", &cHardwareCPU::Inst_SenseRegulate),
tInstLibEntry<tMethod>("numberate", &cHardwareCPU::Inst_Numberate),
-
+ tInstLibEntry<tMethod>("numberate-24", &cHardwareCPU::Inst_Numberate24),
+ tInstLibEntry<tMethod>("bit-cons", &cHardwareCPU::Inst_BitConsensus),
+ tInstLibEntry<tMethod>("bit-cons-24", &cHardwareCPU::Inst_BitConsensus24),
+
// Energy usage
tInstLibEntry<tMethod>("double-energy-usage", &cHardwareCPU::Inst_DoubleEnergyUsage),
tInstLibEntry<tMethod>("half-energy-usage", &cHardwareCPU::Inst_HalfEnergyUsage),
@@ -395,11 +400,10 @@
static tMethod functions[f_size];
for (int i = 0; i < f_size; i++) functions[i] = s_f_array[i].GetFunction();
- const cInstruction error(255);
- const cInstruction def(0);
- const cInstruction null_inst(f_size - 1);
+ const int def = 0;
+ const int null_inst = f_size - 1;
- return new tInstLib<tMethod>(f_size, s_f_array, n_names, nop_mods, functions, error, def, null_inst);
+ return new tInstLib<tMethod>(f_size, s_f_array, n_names, nop_mods, functions, def, null_inst);
}
cHardwareCPU::cHardwareCPU(cWorld* world, cOrganism* in_organism, cInstSet* in_m_inst_set)
@@ -482,13 +486,12 @@
m_promoter_index = -1; // Meaning the last promoter was nothing
m_promoter_offset = 0;
- m_promoter_regulation = 0;
m_promoters.Resize(0);
for (int i=0; i<GetMemory().GetSize(); i++)
{
if ( (GetMemory())[i] == promoter_inst)
{
- int code = Numberate(i-1, -1);
+ int code = Numberate(i-1, -1, m_world->GetConfig().PROMOTER_CODE_SIZE.Get());
m_promoters.Push( cPromoter(i,code) );
}
}
@@ -525,6 +528,7 @@
void cHardwareCPU::SingleProcess(cAvidaContext& ctx)
{
+
int last_IP_pos = IP().GetPosition();
// Mark this organism as running...
@@ -567,11 +571,15 @@
// Test if costs have been paid and it is okay to execute this now...
bool exec = SingleProcess_PayCosts(ctx, cur_inst);
+ // Constitutive regulation applied here
+ if (m_world->GetConfig().CONSTITUTIVE_REGULATION.Get() == 1) {
+ Inst_SenseRegulate(ctx);
+ }
+
// If there are no active promoters and a certain mode is set, then don't execute any further instructions
if ((m_world->GetConfig().PROMOTERS_ENABLED.Get() == 1)
&& (m_world->GetConfig().NO_ACTIVE_PROMOTER_EFFECT.Get() == 2)
- && (m_promoter_index == -1) )
- {
+ && (m_promoter_index == -1) ) {
exec = false;
}
@@ -614,7 +622,7 @@
} // if exec
} // Previous was executed once for each thread...
-
+
// Kill creatures who have reached their max num of instructions executed
const int max_executed = organism->GetMaxExecuted();
if ((max_executed > 0 && phenotype.GetTimeUsed() >= max_executed)
@@ -622,8 +630,10 @@
organism->Die();
}
+ // Note: if organism just died, this will NOT let it repro.
+ CheckImplicitRepro(ctx, last_IP_pos > IP().GetPosition());
+
organism->SetRunning(false);
- CheckImplicitRepro(ctx, last_IP_pos > IP().GetPosition());
}
// This method will handle the actual execution of an instruction
@@ -733,11 +743,10 @@
{
fp << "Promoters: index=" << m_promoter_index << " offset=" << m_promoter_offset;
fp << " exe_inst=" << m_threads[m_cur_thread].GetPromoterInstExecuted();
- fp << " regulation=0x" << setbase(16) << setfill('0') << setw(8) << m_promoter_regulation << endl;
for (int i=0; i<m_promoters.GetSize(); i++)
{
- fp << setfill(' ') << setbase(10) << i << "(" << m_promoters[i].m_pos << "):";
- fp << "Ox" << setbase(16) << setfill('0') << setw(8) << (m_promoters[i].m_bit_code ^ m_promoter_regulation) << " ";
+ fp << setfill(' ') << setbase(10) << m_promoters[i].m_pos << ":";
+ fp << "Ox" << setbase(16) << setfill('0') << setw(8) << (m_promoters[i].GetRegulatedBitCode()) << " ";
}
fp << endl;
fp << setfill(' ') << setbase(10) << endl;
@@ -2586,6 +2595,7 @@
}
}
}
+
Divide_DoMutations(ctx);
// Many tests will require us to run the offspring through a test CPU;
@@ -3076,13 +3086,18 @@
}
}
- // Take the log after adding resource amounts together!
- // Otherwise
+ // Take the log after adding resource amounts together! This way a zero can be assigned to INT_MIN
if (conversion_method == 0) // Log2
{
// You really shouldn't be using the log method if you can get to zero resources
- assert(dresource_result != 0);
- resource_result = (int)(log(dresource_result)/log(base));
+ if(dresource_result == 0.0)
+ {
+ resource_result = INT_MIN;
+ }
+ else
+ {
+ resource_result = (int)(log(dresource_result)/log(base));
+ }
}
//Dump this value into an arbitrary register: BX
@@ -4419,8 +4434,6 @@
{
// Promoters don't do anything themselves
return true;
-// std::cerr<<"x = "<<pos.first<<" y = "<<pos.second<<" ans = "<<GetRegister(reg)<<std::endl;
- return true;
}
// Move the instruction ptr to the next active promoter
@@ -4502,24 +4515,82 @@
else
{
// We found an active match, offset to just after it.
- // and put its bit code in BX for the organism to have
- // cHeadCPU will do the mod genome size for us
+ // cHeadCPU will do the mod genome size for us
IP().Set(m_promoters[m_promoter_index].m_pos + 1);
- GetRegister(reg_used) = m_promoters[m_promoter_index].m_bit_code;
+
+ // Put its bit code in BX for the organism to have if option is set
+ if ( m_world->GetConfig().PROMOTER_TO_REGISTER.Get() )
+ {
+ GetRegister(reg_used) = m_promoters[m_promoter_index].m_bit_code;
+ }
}
return true;
}
-// Get a new regulation code (which is XOR'ed with promoter codes).
+// Set a new regulation code (which is XOR'ed with ALL promoter codes).
bool cHardwareCPU::Inst_Regulate(cAvidaContext& ctx)
{
const int reg_used = FindModifiedRegister(REG_BX);
- m_promoter_regulation = GetRegister(reg_used);
+ int regulation_code = GetRegister(reg_used);
+
+ for (int i=0; i< m_promoters.GetSize();i++)
+ {
+ m_promoters[i].m_regulation = regulation_code;
+ }
return true;
}
+// Set a new regulation code, but only on a subset of promoters.
+bool cHardwareCPU::Inst_RegulateSpecificPromoters(cAvidaContext& ctx)
+{
+ const int reg_used = FindModifiedRegister(REG_BX);
+ int regulation_code = GetRegister(reg_used);
+
+ const int reg_promoter = FindModifiedRegister((reg_used+1) % NUM_REGISTERS);
+ int regulation_promoter = GetRegister(reg_promoter);
+
+ for (int i=0; i< m_promoters.GetSize();i++)
+ {
+ //Look for consensus bit matches over the length of the promoter code
+ int test_p_code = m_promoters[i].m_bit_code;
+ int test_r_code = regulation_promoter;
+ int bit_count = 0;
+ for (int j=0; j<m_world->GetConfig().PROMOTER_EXE_LENGTH.Get();j++)
+ {
+ if ((test_p_code & 1) == (test_r_code & 1)) bit_count++;
+ test_p_code >>= 1;
+ test_r_code >>= 1;
+ }
+ if (bit_count >= m_world->GetConfig().PROMOTER_EXE_LENGTH.Get() / 2)
+ {
+ m_promoters[i].m_regulation = regulation_code;
+ }
+ }
+ return true;
+}
+
+
+bool cHardwareCPU::Inst_SenseRegulate(cAvidaContext& ctx)
+{
+ unsigned int bits = 0;
+ const tArray<double> & res_count = organism->GetOrgInterface().GetResources();
+ assert (res_count.GetSize() != 0);
+ for (int i=0; i<m_world->GetConfig().PROMOTER_CODE_SIZE.Get(); i++)
+ {
+ int b = i % res_count.GetSize();
+ bits <<= 1;
+ bits += (res_count[b] != 0);
+ }
+
+ for (int i=0; i< m_promoters.GetSize();i++)
+ {
+ m_promoters[i].m_regulation = bits;
+ }
+ return true;
+}
+
// Create a number from inst bit codes
-bool cHardwareCPU::Inst_Numberate(cAvidaContext& ctx)
+bool cHardwareCPU::Do_Numberate(cAvidaContext& ctx, int num_bits)
{
const int reg_used = FindModifiedRegister(REG_BX);
@@ -4527,7 +4598,7 @@
IP().Advance();
m_advance_ip = false;
- int num = Numberate(IP().GetPosition(), +1);
+ int num = Numberate(IP().GetPosition(), +1, num_bits);
GetRegister(reg_used) = num;
return true;
}
@@ -4543,7 +4614,7 @@
// Move offset, rolling over when there are not enough bits before we would have to wrap around left
m_promoter_offset+=m_world->GetConfig().PROMOTER_EXE_LENGTH.Get();
- if (m_promoter_offset + m_world->GetConfig().PROMOTER_EXE_LENGTH.Get() >= cHardwareCPU::PROMOTER_CODE_SIZE)
+ if (m_promoter_offset + m_world->GetConfig().PROMOTER_EXE_LENGTH.Get() >= m_world->GetConfig().PROMOTER_CODE_SIZE.Get())
{
m_promoter_offset = 0;
}
@@ -4556,11 +4627,11 @@
{
assert( m_promoters.GetSize() != 0 );
int count = 0;
- unsigned int code = m_promoters[m_promoter_index].m_bit_code ^ m_promoter_regulation;
+ unsigned int code = m_promoters[m_promoter_index].GetRegulatedBitCode();
for(int i=0; i<m_world->GetConfig().PROMOTER_EXE_LENGTH.Get(); i++)
{
int offset = m_promoter_offset + i;
- offset %= cHardwareCPU::PROMOTER_CODE_SIZE;
+ offset %= m_world->GetConfig().PROMOTER_CODE_SIZE.Get();
int state = code >> offset;
count += (state & 1);
}
@@ -4569,22 +4640,26 @@
}
// Construct a promoter bit code from instruction bit codes
-int cHardwareCPU::Numberate(int _pos, int _dir)
+int cHardwareCPU::Numberate(int _pos, int _dir, int _num_bits)
{
int code_size = 0;
unsigned int code = 0;
+ unsigned int max_bits = sizeof(code) * 8;
+ assert(_num_bits <= (int)max_bits);
+ if (_num_bits == 0) _num_bits = max_bits;
+
int j = _pos;
j %= GetMemory().GetSize();
- while (code_size < cHardwareCPU::PROMOTER_CODE_SIZE)
+ while (code_size < _num_bits)
{
unsigned int inst_code = (unsigned int) GetInstSet().GetInstructionCode( (GetMemory())[j] );
- // shift bits in, one by one ... excuse the counter pun
- for (int code_on = 0; (code_size < cHardwareCPU::PROMOTER_CODE_SIZE) && (code_on < m_world->GetConfig().INST_CODE_LENGTH.Get()); code_on++)
+ // shift bits in, one by one ... excuse the counter variable pun
+ for (int code_on = 0; (code_size < _num_bits) && (code_on < m_world->GetConfig().INST_CODE_LENGTH.Get()); code_on++)
{
if (_dir < 0)
{
code >>= 1; // shift first so we don't go one too far at the end
- code += (1 << (cHardwareCPU::PROMOTER_CODE_SIZE - 1)) * (inst_code & 1);
+ code += (1 << (_num_bits - 1)) * (inst_code & 1);
inst_code >>= 1;
}
else
@@ -4601,9 +4676,44 @@
j %= GetMemory().GetSize();
}
+
return code;
}
+/*!
+ Sets BX to 1 if >=50% of the bits in the specified register places
+ are 1's and zero otherwise.
+*/
+
+bool cHardwareCPU::Inst_BitConsensus(cAvidaContext& ctx)
+{
+ return BitConsensus(ctx, sizeof(int) * 8);
+}
+
+// Looks at only the lower 24 bits
+bool cHardwareCPU::Inst_BitConsensus24(cAvidaContext& ctx)
+{
+ return BitConsensus(ctx, 24);
+}
+
+bool cHardwareCPU::BitConsensus(cAvidaContext& ctx, const unsigned int num_bits)
+{
+ assert(num_bits <= sizeof(int) * 8);
+
+ const int reg_used = FindModifiedRegister(REG_BX);
+ int reg_val = GetRegister(REG_CX);
+ unsigned int bits_on = 0;
+
+ for (unsigned int i = 0; i < num_bits; i++)
+ {
+ bits_on += (reg_val & 1);
+ reg_val >>= 1;
+ }
+
+ GetRegister(reg_used) = ( bits_on >= (sizeof(int) * 8)/2 ) ? 1 : 0;
+ return true;
+}
+
/*! Send a message to the organism that is currently faced by this cell,
where the label field of sent message is from register ?BX?, and the data field
is from register ~?BX?.
Modified: branches/collect/source/cpu/cHardwareCPU.h
===================================================================
--- branches/collect/source/cpu/cHardwareCPU.h 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/cpu/cHardwareCPU.h 2007-10-24 14:05:38 UTC (rev 2154)
@@ -89,7 +89,6 @@
static const int NUM_HEADS = nHardware::NUM_HEADS >= NUM_REGISTERS ? nHardware::NUM_HEADS : NUM_REGISTERS;
enum tRegisters { REG_AX = 0, REG_BX, REG_CX, REG_DX, REG_EX, REG_FX };
static const int NUM_NOPS = 3;
- static const int PROMOTER_CODE_SIZE = sizeof(int) * 8; // Number of bits in promoter codes
// -------- Data Structures --------
struct cLocalThread
@@ -145,15 +144,16 @@
// <-- Promoter model
int m_promoter_index; //site to begin looking for the next active promoter from
int m_promoter_offset; //bit offset when testing whether a promoter is on
- int m_promoter_regulation; //bit code that modifies current execution, via an XOR
struct cPromoter
{
public:
int m_pos; //position within genome
int m_bit_code; //bit code of promoter
+ int m_regulation; //bit code of promoter
public:
- cPromoter(int _pos = 0, int _bit_code = 0) { m_pos = _pos; m_bit_code = _bit_code; }
+ cPromoter(int _pos = 0, int _bit_code = 0, int _regulation = 0) { m_pos = _pos; m_bit_code = _bit_code; m_regulation = _regulation; }
+ int GetRegulatedBitCode() { return m_bit_code ^ m_regulation; }
~cPromoter() { ; }
};
tArray<cPromoter> m_promoters;
@@ -554,13 +554,24 @@
bool Inst_Promoter(cAvidaContext& ctx);
bool Inst_Terminate(cAvidaContext& ctx);
bool Inst_Regulate(cAvidaContext& ctx);
- bool Inst_Numberate(cAvidaContext& ctx);
+ bool Inst_RegulateSpecificPromoters(cAvidaContext& ctx);
+ bool Inst_SenseRegulate(cAvidaContext& ctx);
+ bool Inst_Numberate(cAvidaContext& ctx) { return Do_Numberate(ctx); };
+ bool Inst_Numberate24(cAvidaContext& ctx) { return Do_Numberate(ctx, 24); };
+ bool Do_Numberate(cAvidaContext& ctx, int num_bits=0);
// Helper functions //
bool IsActivePromoter();
void NextPromoter();
- int Numberate(int _pos, int _dir);
+ int Numberate(int _pos, int _dir, int _num_bits = 0);
+
+
+ //// Bit consensus functions ////
+ bool Inst_BitConsensus(cAvidaContext& ctx);
+ bool Inst_BitConsensus24(cAvidaContext& ctx);
+ bool BitConsensus(cAvidaContext& ctx, const unsigned int num_bits);
+
//// Messaging ////
bool Inst_SendMessage(cAvidaContext& ctx);
bool Inst_RetrieveMessage(cAvidaContext& ctx);
Modified: branches/collect/source/cpu/cHardwareExperimental.cc
===================================================================
--- branches/collect/source/cpu/cHardwareExperimental.cc 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/cpu/cHardwareExperimental.cc 2007-10-24 14:05:38 UTC (rev 2154)
@@ -136,11 +136,10 @@
static tMethod functions[f_size];
for (int i = 0; i < f_size; i++) functions[i] = s_f_array[i].GetFunction();
- const cInstruction error(255);
- const cInstruction def(0);
- const cInstruction null_inst(4);
+ const int def = 0;
+ const int null_inst = 4;
- return new tInstLib<tMethod>(f_size, s_f_array, n_names, nop_mods, functions, error, def, null_inst);
+ return new tInstLib<tMethod>(f_size, s_f_array, n_names, nop_mods, functions, def, null_inst);
}
cHardwareExperimental::cHardwareExperimental(cWorld* world, cOrganism* in_organism, cInstSet* in_m_inst_set)
Modified: branches/collect/source/cpu/cHardwareGX.cc
===================================================================
--- branches/collect/source/cpu/cHardwareGX.cc 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/cpu/cHardwareGX.cc 2007-10-24 14:05:38 UTC (rev 2154)
@@ -301,11 +301,10 @@
static tMethod functions[f_size];
for (int i = 0; i < f_size; i++) functions[i] = s_f_array[i].GetFunction();
- const cInstruction error(255);
- const cInstruction def(0);
- const cInstruction null_inst(f_size - 1);
+ const int def = 0;
+ const int null_inst = f_size - 1;
- return new tInstLib<tMethod>(f_size, s_f_array, n_names, nop_mods, functions, error, def, null_inst);
+ return new tInstLib<tMethod>(f_size, s_f_array, n_names, nop_mods, functions, def, null_inst);
}
Modified: branches/collect/source/cpu/cHardwareSMT.cc
===================================================================
--- branches/collect/source/cpu/cHardwareSMT.cc 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/cpu/cHardwareSMT.cc 2007-10-24 14:05:38 UTC (rev 2154)
@@ -127,11 +127,10 @@
static tMethod functions[f_size];
for (int i = 0; i < f_size; i++) functions[i] = s_f_array[i].GetFunction();
- const cInstruction error(255);
- const cInstruction def(0);
- const cInstruction null_inst(f_size - 1);
+ const int def = 0;
+ const int null_inst = f_size - 1;
- return new tInstLib<tMethod>(f_size, s_f_array, n_names, nop_mods, functions, error, def, null_inst);
+ return new tInstLib<tMethod>(f_size, s_f_array, n_names, nop_mods, functions, def, null_inst);
}
cHardwareSMT::cHardwareSMT(cWorld* world, cOrganism* in_organism, cInstSet* in_m_inst_set)
Modified: branches/collect/source/cpu/cHardwareSMT.h
===================================================================
--- branches/collect/source/cpu/cHardwareSMT.h 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/cpu/cHardwareSMT.h 2007-10-24 14:05:38 UTC (rev 2154)
@@ -358,9 +358,9 @@
inline int cHardwareSMT::GetStack(int depth, int stack_id, int in_thread) const
{
- if(stack_id<0 || stack_id > NUM_STACKS) stack_id=0;
+ if (stack_id<0 || stack_id > NUM_STACKS) stack_id=0;
- if(in_thread==-1)
+ if (in_thread==-1)
in_thread=m_cur_thread;
return Stack(stack_id, in_thread).Get(depth);
@@ -368,8 +368,8 @@
inline cCPUStack& cHardwareSMT::Stack(int stack_id)
{
- if(stack_id >= NUM_STACKS) stack_id = 0;
- if(stack_id < NUM_LOCAL_STACKS)
+ if (stack_id >= NUM_STACKS) stack_id = 0;
+ if (stack_id < NUM_LOCAL_STACKS)
return m_threads[m_cur_thread].local_stacks[stack_id];
else
return m_global_stacks[stack_id % NUM_LOCAL_STACKS];
@@ -377,8 +377,8 @@
inline const cCPUStack& cHardwareSMT::Stack(int stack_id) const
{
- if(stack_id >= NUM_STACKS) stack_id = 0;
- if(stack_id < NUM_LOCAL_STACKS)
+ if (stack_id >= NUM_STACKS) stack_id = 0;
+ if (stack_id < NUM_LOCAL_STACKS)
return m_threads[m_cur_thread].local_stacks[stack_id];
else
return m_global_stacks[stack_id % NUM_LOCAL_STACKS];
@@ -386,10 +386,10 @@
inline cCPUStack& cHardwareSMT::Stack(int stack_id, int in_thread)
{
- if(stack_id >= NUM_STACKS || stack_id < 0) stack_id = 0;
- if(in_thread >= m_threads.GetSize() || in_thread < 0) in_thread = m_cur_thread;
+ if (stack_id >= NUM_STACKS || stack_id < 0) stack_id = 0;
+ if (in_thread >= m_threads.GetSize() || in_thread < 0) in_thread = m_cur_thread;
- if(stack_id < NUM_LOCAL_STACKS)
+ if (stack_id < NUM_LOCAL_STACKS)
return m_threads[in_thread].local_stacks[stack_id];
else
return m_global_stacks[stack_id % NUM_LOCAL_STACKS];
@@ -397,10 +397,10 @@
inline const cCPUStack& cHardwareSMT::Stack(int stack_id, int in_thread) const
{
- if(stack_id >= NUM_STACKS || stack_id < 0) stack_id = 0;
- if(in_thread >= m_threads.GetSize() || in_thread < 0) in_thread = m_cur_thread;
+ if (stack_id >= NUM_STACKS || stack_id < 0) stack_id = 0;
+ if (in_thread >= m_threads.GetSize() || in_thread < 0) in_thread = m_cur_thread;
- if(stack_id < NUM_LOCAL_STACKS)
+ if (stack_id < NUM_LOCAL_STACKS)
return m_threads[in_thread].local_stacks[stack_id];
else
return m_global_stacks[stack_id % NUM_LOCAL_STACKS];
@@ -408,8 +408,8 @@
inline int cHardwareSMT::NormalizeMemSpace(int mem_space) const
{
- if(mem_space >= m_mem_array.GetSize())
- mem_space %= m_mem_array.GetSize();
+ assert(mem_space >= 0);
+ if (mem_space >= m_mem_array.GetSize()) mem_space %= m_mem_array.GetSize();
return mem_space;
}
Modified: branches/collect/source/cpu/cHardwareTransSMT.cc
===================================================================
--- branches/collect/source/cpu/cHardwareTransSMT.cc 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/cpu/cHardwareTransSMT.cc 2007-10-24 14:05:38 UTC (rev 2154)
@@ -126,11 +126,10 @@
static tMethod functions[f_size];
for (int i = 0; i < f_size; i++) functions[i] = s_f_array[i].GetFunction();
- const cInstruction error(255);
- const cInstruction def(0);
- const cInstruction null_inst(f_size - 1);
+ const int def = 0;
+ const int null_inst = f_size - 1;
- return new tInstLib<tMethod>(f_size, s_f_array, n_names, nop_mods, functions, error, def, null_inst);
+ return new tInstLib<tMethod>(f_size, s_f_array, n_names, nop_mods, functions, def, null_inst);
}
cHardwareTransSMT::cHardwareTransSMT(cWorld* world, cOrganism* in_organism, cInstSet* in_m_inst_set)
Modified: branches/collect/source/cpu/cHardwareTransSMT.h
===================================================================
--- branches/collect/source/cpu/cHardwareTransSMT.h 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/cpu/cHardwareTransSMT.h 2007-10-24 14:05:38 UTC (rev 2154)
@@ -358,9 +358,9 @@
inline int cHardwareTransSMT::GetStack(int depth, int stack_id, int in_thread) const
{
- if(stack_id<0 || stack_id > NUM_STACKS) stack_id=0;
+ if (stack_id<0 || stack_id > NUM_STACKS) stack_id=0;
- if(in_thread==-1)
+ if (in_thread==-1)
in_thread=m_cur_thread;
return Stack(stack_id, in_thread).Get(depth);
@@ -368,8 +368,8 @@
inline cCPUStack& cHardwareTransSMT::Stack(int stack_id)
{
- if(stack_id >= NUM_STACKS) stack_id = 0;
- if(stack_id < NUM_LOCAL_STACKS)
+ if (stack_id >= NUM_STACKS) stack_id = 0;
+ if (stack_id < NUM_LOCAL_STACKS)
return m_threads[m_cur_thread].local_stacks[stack_id];
else
return m_global_stacks[stack_id % NUM_LOCAL_STACKS];
@@ -377,8 +377,8 @@
inline const cCPUStack& cHardwareTransSMT::Stack(int stack_id) const
{
- if(stack_id >= NUM_STACKS) stack_id = 0;
- if(stack_id < NUM_LOCAL_STACKS)
+ if (stack_id >= NUM_STACKS) stack_id = 0;
+ if (stack_id < NUM_LOCAL_STACKS)
return m_threads[m_cur_thread].local_stacks[stack_id];
else
return m_global_stacks[stack_id % NUM_LOCAL_STACKS];
@@ -386,10 +386,10 @@
inline cCPUStack& cHardwareTransSMT::Stack(int stack_id, int in_thread)
{
- if(stack_id >= NUM_STACKS || stack_id < 0) stack_id = 0;
- if(in_thread >= m_threads.GetSize() || in_thread < 0) in_thread = m_cur_thread;
+ if (stack_id >= NUM_STACKS || stack_id < 0) stack_id = 0;
+ if (in_thread >= m_threads.GetSize() || in_thread < 0) in_thread = m_cur_thread;
- if(stack_id < NUM_LOCAL_STACKS)
+ if (stack_id < NUM_LOCAL_STACKS)
return m_threads[in_thread].local_stacks[stack_id];
else
return m_global_stacks[stack_id % NUM_LOCAL_STACKS];
@@ -397,10 +397,10 @@
inline const cCPUStack& cHardwareTransSMT::Stack(int stack_id, int in_thread) const
{
- if(stack_id >= NUM_STACKS || stack_id < 0) stack_id = 0;
- if(in_thread >= m_threads.GetSize() || in_thread < 0) in_thread = m_cur_thread;
+ if (stack_id >= NUM_STACKS || stack_id < 0) stack_id = 0;
+ if (in_thread >= m_threads.GetSize() || in_thread < 0) in_thread = m_cur_thread;
- if(stack_id < NUM_LOCAL_STACKS)
+ if (stack_id < NUM_LOCAL_STACKS)
return m_threads[in_thread].local_stacks[stack_id];
else
return m_global_stacks[stack_id % NUM_LOCAL_STACKS];
@@ -408,8 +408,8 @@
inline int cHardwareTransSMT::NormalizeMemSpace(int mem_space) const
{
- if(mem_space >= m_mem_array.GetSize())
- mem_space %= m_mem_array.GetSize();
+ assert(mem_space >= 0);
+ if (mem_space >= m_mem_array.GetSize()) mem_space %= m_mem_array.GetSize();
return mem_space;
}
Modified: branches/collect/source/cpu/cHeadCPU.cc
===================================================================
--- branches/collect/source/cpu/cHeadCPU.cc 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/cpu/cHeadCPU.cc 2007-10-24 14:05:38 UTC (rev 2154)
@@ -35,8 +35,9 @@
void cHeadCPU::Adjust()
{
+ assert(m_mem_space >= 0);
// Ensure that m_mem_space is valid
- m_mem_space %= m_hardware->GetNumMemSpaces();
+ if (m_mem_space >= m_hardware->GetNumMemSpaces()) m_mem_space %= m_hardware->GetNumMemSpaces();
const int mem_size = GetMemory().GetSize();
Modified: branches/collect/source/cpu/cInstLib.h
===================================================================
--- branches/collect/source/cpu/cInstLib.h 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/cpu/cInstLib.h 2007-10-24 14:05:38 UTC (rev 2154)
@@ -45,15 +45,14 @@
const int m_size;
tDictionary<int> m_namemap;
- const cInstruction m_inst_error;
- const cInstruction m_inst_default;
- const cInstruction m_inst_null;
+ int m_inst_default;
+ int m_inst_null;
cInstLib(); // @not_implemented
public:
- cInstLib(int size, const cInstruction inst_error, const cInstruction inst_default, const cInstruction inst_null)
- : m_size(size), m_inst_error(inst_error), m_inst_default(inst_default), m_inst_null(inst_null) { ; }
+ cInstLib(int size, int inst_default, int inst_null)
+ : m_size(size), m_inst_default(inst_default), m_inst_null(inst_null) { ; }
virtual ~cInstLib() { ; }
inline int GetSize() const { return m_size; }
@@ -69,11 +68,13 @@
virtual int GetNopMod(const unsigned int id) = 0;
virtual int GetNopMod(const cInstruction& inst) = 0;
- inline cInstruction GetInst(const cString& name);
- const cInstruction GetInstError() const { return m_inst_error; }
- const cInstruction GetInstDefault() const { return m_inst_default; }
- const cInstruction GetInstNull() const { return m_inst_null; }
+ int GetInstDefault() const { return m_inst_default; }
+ int GetInstNull() const { return m_inst_null; }
+
+private:
+ inline cInstruction GetInst(const cString& name);
+
};
@@ -88,7 +89,7 @@
{
int idx;
if (m_namemap.Find(name, idx)) return cInstruction(idx);
- return m_inst_error;
+ return cInstruction(255);
}
Modified: branches/collect/source/cpu/cInstSet.cc
===================================================================
--- branches/collect/source/cpu/cInstSet.cc 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/cpu/cInstSet.cc 2007-10-24 14:05:38 UTC (rev 2154)
@@ -38,7 +38,7 @@
bool cInstSet::OK() const
{
- assert(m_lib_name_map.GetSize() < 256);
+ assert(m_lib_name_map.GetSize() < 255);
assert(m_lib_nopmod_map.GetSize() < m_lib_name_map.GetSize());
// Make sure that all of the redundancies are represented the appropriate
@@ -67,7 +67,7 @@
cInstruction cInstSet::ActivateNullInst()
{
const int inst_id = m_lib_name_map.GetSize();
- const int null_fun_id = m_inst_lib->GetInstNull().GetOp();
+ const int null_fun_id = m_inst_lib->GetInstNull();
assert(inst_id < 255);
@@ -196,7 +196,7 @@
}
// Check to make sure we are not inserting the special NULL instruction
- if (fun_id == m_inst_lib->GetInstNull().GetOp()) {
+ if (fun_id == m_inst_lib->GetInstNull()) {
errors.PushRear(new cString("Invalid use of NULL instruction"));
success = false;
continue;
@@ -342,7 +342,7 @@
- if (fun_id == m_inst_lib->GetInstNull().GetOp())
+ if (fun_id == m_inst_lib->GetInstNull())
m_world->GetDriver().RaiseFatalException(1,"Invalid use of NULL instruction");
const int inst_id = m_lib_name_map.GetSize();
Modified: branches/collect/source/cpu/cInstSet.h
===================================================================
--- branches/collect/source/cpu/cInstSet.h 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/cpu/cInstSet.h 2007-10-24 14:05:38 UTC (rev 2154)
@@ -133,8 +133,8 @@
cString FindBestMatch(const cString& in_name) const;
bool InstInSet(const cString& in_name) const;
- cInstruction GetInstDefault() const { return m_inst_lib->GetInstDefault(); }
- cInstruction GetInstError() const { return m_inst_lib->GetInstError(); }
+ cInstruction GetInstDefault() const { return cInstruction(m_inst_lib->GetInstDefault()); }
+ cInstruction GetInstError() const { return cInstruction(255); }
void LoadFromConfig();
void LoadFromFile(const cString& filename);
@@ -183,12 +183,7 @@
// Adding default answer if nothing is found...
- /*
- FIXME: this return value is supposed to be cInstSet::GetInstError
- which should be the same as m_inst_lib->GetInstError().
- -- kgn
- */
- return cInstruction(0);
+ return cInstruction(255);
}
#endif
Modified: branches/collect/source/cpu/tInstLib.h
===================================================================
--- branches/collect/source/cpu/tInstLib.h 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/cpu/tInstLib.h 2007-10-24 14:05:38 UTC (rev 2154)
@@ -47,8 +47,8 @@
public:
tInstLib(int size, const tInstLibEntry<MethodType>* entries, cString* nopmod_names, const int* nopmods,
- const MethodType* functions, const cInstruction error, const cInstruction def, const cInstruction null_inst)
- : cInstLib(size, error, def, null_inst), m_entries(entries),
+ const MethodType* functions, int def, int null_inst)
+ : cInstLib(size, def, null_inst), m_entries(entries),
m_nopmod_names(nopmod_names),
m_nopmods(nopmods),
m_functions(functions)
Modified: branches/collect/source/main/avida.cc
===================================================================
--- branches/collect/source/main/avida.cc 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/main/avida.cc 2007-10-24 14:05:38 UTC (rev 2154)
@@ -137,7 +137,7 @@
bool flag_interactive = false;
bool flag_load = false; cString val_load;
bool flag_review = false;
- bool flag_verbosity = false; int val_verbosity;
+ bool flag_verbosity = false; int val_verbosity = 0;
bool flag_seed = false; int val_seed = 0;
// Then scan through and process the rest of the args.
Modified: branches/collect/source/main/cAvidaConfig.h
===================================================================
--- branches/collect/source/main/cAvidaConfig.h 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/main/cAvidaConfig.h 2007-10-24 14:05:38 UTC (rev 2154)
@@ -379,7 +379,7 @@
CONFIG_ADD_VAR(BASE_MERIT_METHOD, int, 4, "0 = Constant (merit independent of size)\n1 = Merit proportional to copied size\n2 = Merit prop. to executed size\n3 = Merit prop. to full size\n4 = Merit prop. to min of executed or copied size\n5 = Merit prop. to sqrt of the minimum size\n6 = Merit prop. to num times MERIT_BONUS_INST is in genome.");
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_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(FITNESS_METHOD, int, 0, "0 = default, >1 = experimental");
@@ -477,12 +477,15 @@
CONFIG_ADD_VAR(PROMOTER_INST_MAX, int, 0, "Maximum number of instructions to execute before terminating. 0 = off");
CONFIG_ADD_VAR(PROMOTER_PROCESSIVITY, double, 1.0, "Chance of not terminating after each cpu cycle.");
CONFIG_ADD_VAR(PROMOTER_PROCESSIVITY_INST, double, 1.0, "Chance of not terminating after each instruction.");
+ CONFIG_ADD_VAR(PROMOTER_TO_REGISTER, int, 0, "Place a promoter's base bit code in register BX when starting execution from it?");
CONFIG_ADD_VAR(TERMINATION_RESETS, int, 0, "Does termination reset the thread's state?");
CONFIG_ADD_VAR(NO_ACTIVE_PROMOTER_EFFECT, int, 0, "What happens when there are no active promoters?\n0 = Start execution at the beginning of the genome.\n1 = Kill the organism.\n2 = Stop the organism from executing any further instructions.");
- CONFIG_ADD_VAR(PROMOTER_EXE_LENGTH, int, 4, "Length of promoter windows used to determine execution.");
- CONFIG_ADD_VAR(PROMOTER_EXE_THRESHOLD, int, 3, "Minimum number of bits that must be set in a promoter window to allow execution.");
- CONFIG_ADD_VAR(INST_CODE_LENGTH, int, 4, "Instruction binary code length (number of bits)");
+ CONFIG_ADD_VAR(PROMOTER_CODE_SIZE, int, 24, "Size of a promoter code in bits. (Maximum value is 32)");
+ CONFIG_ADD_VAR(PROMOTER_EXE_LENGTH, int, 3, "Length of promoter windows used to determine execution.");
+ CONFIG_ADD_VAR(PROMOTER_EXE_THRESHOLD, int, 2, "Minimum number of bits that must be set in a promoter window to allow execution.");
+ CONFIG_ADD_VAR(INST_CODE_LENGTH, int, 3, "Instruction binary code length (number of bits)");
CONFIG_ADD_VAR(INST_CODE_DEFAULT_TYPE, int, 0, "Default value of instruction binary code value.\n0 = All zeros\n1 = Based off the instruction number");
+ CONFIG_ADD_VAR(CONSTITUTIVE_REGULATION, int, 0, "Sense a new regulation value before each CPU cycle?");
CONFIG_ADD_GROUP(COLORS_GROUP, "Output colors for when data files are printed in HTML mode.\nThere are two sets of these; the first are for lineages,\nand the second are for mutation tests.");
CONFIG_ADD_VAR(COLOR_DIFF, cString, "CCCCFF", "Color to flag stat that has changed since parent.");
Modified: branches/collect/source/main/cEnvironment.cc
===================================================================
--- branches/collect/source/main/cEnvironment.cc 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/main/cEnvironment.cc 2007-10-24 14:05:38 UTC (rev 2154)
@@ -789,6 +789,14 @@
{
input_array.Resize(m_input_size);
+ //Specific inputs trump everything
+ if (m_use_specific_inputs)
+ {
+ input_array = m_specific_inputs;
+ return;
+ }
+
+
if (random) {
if (m_true_rand) {
for (int i = 0; i < m_input_size; i++) {
@@ -1140,3 +1148,33 @@
return true;
}
+bool cEnvironment::SetReactionMinTaskCount(const cString& name, int min_count)
+{
+ cReaction* found_reaction = reaction_lib.GetReaction(name);
+ if (found_reaction == NULL) return false;
+ return found_reaction->SetMinTaskCount( min_count );
+}
+
+bool cEnvironment::SetReactionMaxTaskCount(const cString& name, int max_count)
+{
+ cReaction* found_reaction = reaction_lib.GetReaction(name);
+ if (found_reaction == NULL) return false;
+ return found_reaction->SetMaxTaskCount( max_count );
+}
+
+bool cEnvironment::SetResourceInflow(const cString& name, double _inflow )
+{
+ cResource* found_resource = resource_lib.GetResource(name);
+ if (found_resource == NULL) return false;
+ found_resource->SetInflow( _inflow );
+ return true;
+}
+
+bool cEnvironment::SetResourceOutflow(const cString& name, double _outflow )
+{
+ cResource* found_resource = resource_lib.GetResource(name);
+ if (found_resource == NULL) return false;
+ found_resource->SetOutflow( _outflow );
+ return true;
+}
+
Modified: branches/collect/source/main/cEnvironment.h
===================================================================
--- branches/collect/source/main/cEnvironment.h 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/main/cEnvironment.h 2007-10-24 14:05:38 UTC (rev 2154)
@@ -90,6 +90,8 @@
int m_output_size;
bool m_true_rand;
+ bool m_use_specific_inputs; // Use specific inputs, rather than generating random ones
+ tArray<int> m_specific_inputs;
static bool ParseSetting(cString entry, cString& var_name, cString& var_value, const cString& var_type);
static bool AssertInputInt(const cString& input, const cString& name, const cString& type);
@@ -126,6 +128,8 @@
// Interaction with the organisms
void SetupInputs(cAvidaContext& ctx, tArray<int>& input_array, bool random = true) const;
+ void SetSpecificInputs(const tArray<int> in_input_array)
+ { m_use_specific_inputs = true; m_specific_inputs = in_input_array; }
void SwapInputs(cAvidaContext& ctx, tArray<int>& src_input_array, tArray<int>& dest_input_array) const;
@@ -158,11 +162,17 @@
bool SetReactionValue(cAvidaContext& ctx, const cString& name, double value);
bool SetReactionValueMult(const cString& name, double value_mult);
bool SetReactionInst(const cString& name, cString inst_name);
+ bool SetReactionMinTaskCount(const cString& name, int min_count);
+ bool SetReactionMaxTaskCount(const cString& name, int max_count);
+ bool SetResourceInflow(const cString& name, double _inflow );
+ bool SetResourceOutflow(const cString& name, double _outflow );
+
};
inline cEnvironment::cEnvironment(cWorld* world) : m_world(world) , m_tasklib(world),
- m_input_size(INPUT_SIZE_DEFAULT), m_output_size(OUTPUT_SIZE_DEFAULT), m_true_rand(false)
+ m_input_size(INPUT_SIZE_DEFAULT), m_output_size(OUTPUT_SIZE_DEFAULT), m_true_rand(false),
+ m_use_specific_inputs(false), m_specific_inputs()
{
mut_rates.Setup(world);
}
Modified: branches/collect/source/main/cOrganism.h
===================================================================
--- branches/collect/source/main/cOrganism.h 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/main/cOrganism.h 2007-10-24 14:05:38 UTC (rev 2154)
@@ -234,6 +234,7 @@
//! Check tasks based on the passed-in IO buffers and value (on_divide=false).
void DoOutput(cAvidaContext& ctx, tBuffer<int>& input_buffer, tBuffer<int>& output_buffer, const int value);
+
protected:
/*! The main DoOutput function. The DoOutputs above all forward to this function. */
void DoOutput(cAvidaContext& ctx, tBuffer<int>& input_buffer,
@@ -241,6 +242,7 @@
public:
void ClearInput() { m_input_buf.Clear(); }
+ void ResetInput() {m_input_pointer = 0; m_input_buf.Clear(); };
void AddOutput(int val) { m_output_buf.Add(val); }
// -------- Divide Methods --------
Modified: branches/collect/source/main/cPhenPlastGenotype.cc
===================================================================
--- branches/collect/source/main/cPhenPlastGenotype.cc 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/main/cPhenPlastGenotype.cc 2007-10-24 14:05:38 UTC (rev 2154)
@@ -47,7 +47,7 @@
{
UniquePhenotypes::iterator it = m_unique.begin();
while (it != m_unique.end()){
- delete *it;
+ delete static_cast<cPlasticPhenotype*>(*it); // Remember to cast back
++it;
}
}
@@ -71,6 +71,7 @@
}
}
}
+
// Update statistics
UniquePhenotypes::iterator uit = m_unique.begin();
m_max_fitness = -1.0;
Modified: branches/collect/source/main/cPhenotype.cc
===================================================================
--- branches/collect/source/main/cPhenotype.cc 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/main/cPhenotype.cc 2007-10-24 14:05:38 UTC (rev 2154)
@@ -561,11 +561,9 @@
// and it will also be propagated to the child
const int merit_default_bonus = m_world->GetConfig().MERIT_DEFAULT_BONUS.Get();
if (merit_default_bonus) {
- merit = cur_merit_base * m_world->GetConfig().DEFAULT_BONUS.Get();
+ cur_bonus = merit_default_bonus;
}
- else { // Default
- merit = cur_merit_base * cur_bonus;
- }
+ merit = cur_merit_base * cur_bonus;
//BB:TODO update energy store
SetEnergy(energy_store + cur_energy_bonus);
@@ -714,7 +712,11 @@
// Update these values as needed...
int cur_merit_base = CalcSizeMerit();
- merit = cur_merit_base * cur_bonus;
+ const int merit_default_bonus = m_world->GetConfig().MERIT_DEFAULT_BONUS.Get();
+ if (merit_default_bonus) {
+ cur_bonus = merit_default_bonus;
+ }
+ merit = cur_merit_base * cur_bonus;
genome_length = _genome.GetSize();
(void) copied_size; // Unchanged
@@ -1552,11 +1554,9 @@
// and it will also be propagated to the child
int merit_default_bonus = m_world->GetConfig().MERIT_DEFAULT_BONUS.Get();
if (merit_default_bonus) {
- merit = cur_merit_base * m_world->GetConfig().DEFAULT_BONUS.Get();
+ cur_bonus = merit_default_bonus;
}
- else { // Default
- merit = cur_merit_base * cur_bonus;
- }
+ merit = cur_merit_base * cur_bonus;
// update energy store
energy_store += cur_energy_bonus;
@@ -1677,11 +1677,9 @@
// and it will also be propagated to the child
const int merit_default_bonus = m_world->GetConfig().MERIT_DEFAULT_BONUS.Get();
if (merit_default_bonus) {
- merit = cur_merit_base * m_world->GetConfig().DEFAULT_BONUS.Get();
+ cur_bonus = merit_default_bonus;
}
- else { // Defaul
- merit = cur_merit_base * cur_bonus;
- }
+ merit = cur_merit_base * cur_bonus;
//BB:TODO update energy store
SetEnergy(energy_store + cur_energy_bonus);
Modified: branches/collect/source/main/cPopulation.cc
===================================================================
--- branches/collect/source/main/cPopulation.cc 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/main/cPopulation.cc 2007-10-24 14:05:38 UTC (rev 2154)
@@ -106,16 +106,19 @@
}
}
+ // Invalid settings should be changed to one deme
+ if (num_demes <= 0) {
+ num_demes = 1; // One population == one deme.
+ }
+
// Error checking for demes vs. non-demes setup.
#ifdef DEBUG
const int birth_method = m_world->GetConfig().BIRTH_METHOD.Get();
-#endif
- if(num_demes > 0) {
+
+ if(num_demes > 1) {
assert(birth_method != POSITION_CHILD_FULL_SOUP_ELDEST);
- } else {
- assert(birth_method != POSITION_CHILD_DEME_RANDOM);
- num_demes = 1; // One population == one deme.
}
+#endif
// Allocate the cells, resources, and market.
cell_array.ResizeClear(num_cells);
@@ -2788,6 +2791,19 @@
resource_count.Set(id, new_level);
}
+void cPopulation::ResetInputs(cAvidaContext& ctx)
+{
+ for (int i=0; i<GetSize(); i++)
+ {
+ cPopulationCell& cell = GetCell(i);
+ cell.ResetInputs(ctx);
+ if (cell.IsOccupied())
+ {
+ cell.GetOrganism()->ResetInput();
+ }
+ }
+}
+
void cPopulation::BuildTimeSlicer(cChangeList * change_list)
{
switch (m_world->GetConfig().SLICING_METHOD.Get()) {
Modified: branches/collect/source/main/cPopulation.h
===================================================================
--- branches/collect/source/main/cPopulation.h 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/main/cPopulation.h 2007-10-24 14:05:38 UTC (rev 2154)
@@ -244,6 +244,8 @@
double GetResource(int id) const { return resource_count.Get(id); }
cResourceCount& GetResourceCount() { return resource_count; }
+ void ResetInputs(cAvidaContext& ctx);
+
cEnvironment& GetEnvironment() { return environment; }
int GetNumOrganisms() { return num_organisms; }
Modified: branches/collect/source/main/cReaction.cc
===================================================================
--- branches/collect/source/main/cReaction.cc 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/main/cReaction.cc 2007-10-24 14:05:38 UTC (rev 2154)
@@ -81,7 +81,21 @@
return true;
}
+bool cReaction::SetMinTaskCount(int min_count, int requisite_num)
+{
+ if (requisite_num >= requisite_list.GetSize() || requisite_num < 0) return false;
+ requisite_list.GetPos(requisite_num)->SetMinTaskCount(min_count);
+ return true;
+}
+bool cReaction::SetMaxTaskCount(int max_count, int requisite_num)
+{
+ if (requisite_num >= requisite_list.GetSize() || requisite_num < 0) return false;
+ requisite_list.GetPos(requisite_num)->SetMaxTaskCount(max_count);
+ return true;
+}
+
+
double cReaction::GetValue(int process_num)
{
if (process_num >= process_list.GetSize() || process_num < 0) return false;
Modified: branches/collect/source/main/cReaction.h
===================================================================
--- branches/collect/source/main/cReaction.h 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/main/cReaction.h 2007-10-24 14:05:38 UTC (rev 2154)
@@ -75,6 +75,10 @@
// This method will modify the instruction triggered by this process
bool ModifyInst(int inst_id, int process_num = 0);
+ // These methods will modify the min/max count of the requisite for this process
+ bool SetMinTaskCount(int min_count, int requisite_num = 0);
+ bool SetMaxTaskCount(int max_count, int requisite_num = 0);
+
double GetValue(int process_num = 0);
};
Modified: branches/collect/source/main/cResourceCount.cc
===================================================================
--- branches/collect/source/main/cResourceCount.cc 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/main/cResourceCount.cc 2007-10-24 14:05:38 UTC (rev 2154)
@@ -283,6 +283,43 @@
spatial_resource_count[id].SetOutflowY2(in_outflowY2);
}
+int cResourceCount::GetResourceCountID(const cString& res_name)
+{
+ for (int i = 0; i < resource_name.GetSize(); i++) {
+ if (resource_name[i] == res_name) return i;
+ }
+ cerr << "Error: Unknown resource '" << res_name << "'." << endl;
+ return -1;
+}
+
+void cResourceCount::SetInflow(const cString& name, const double _inflow)
+{
+ int id = GetResourceCountID(name);
+ if (id == -1) return;
+
+ inflow_rate[id] = _inflow;
+ double step_inflow = _inflow * UPDATE_STEP;
+ double step_decay = pow(decay_rate[id], UPDATE_STEP);
+
+ inflow_precalc(id, 0) = 0.0;
+ for (int i = 1; i <= PRECALC_DISTANCE; i++) {
+ inflow_precalc(id, i) = inflow_precalc(id, i-1) * step_decay + step_inflow;
+ }
+}
+
+void cResourceCount::SetDecay(const cString& name, const double _decay)
+{
+ int id = GetResourceCountID(name);
+ if (id == -1) return;
+
+ decay_rate[id] = _decay;
+ double step_decay = pow(_decay, UPDATE_STEP);
+ decay_precalc(id, 0) = 1.0;
+ for (int i = 1; i <= PRECALC_DISTANCE; i++) {
+ decay_precalc(id, i) = decay_precalc(id, i-1) * step_decay;
+ }
+}
+
void cResourceCount::Update(double in_time)
{
update_time += in_time;
Modified: branches/collect/source/main/cResourceCount.h
===================================================================
--- branches/collect/source/main/cResourceCount.h 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/main/cResourceCount.h 2007-10-24 14:05:38 UTC (rev 2154)
@@ -85,6 +85,11 @@
int in_outflowX1, int in_outflowX2, int in_outflowY1,
int in_outflowY, tArray<cCellResource> *in_cell_list_ptr,
int verbosity_level);
+
+ int GetResourceCountID(const cString& res_name);
+ void SetInflow(const cString& name, const double _inflow);
+ void SetDecay(const cString& name, const double _decay);
+
void Update(double in_time);
int GetSize(void) const { return resource_count.GetSize(); }
Modified: branches/collect/source/tools/cString.h
===================================================================
--- branches/collect/source/tools/cString.h 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/tools/cString.h 2007-10-24 14:05:38 UTC (rev 2154)
@@ -331,8 +331,8 @@
*
* @return The integer value corresponding to the string.
**/
- int AsInt() const { return static_cast<int>(strtol(*this, NULL, 10)); }
-
+ int AsInt() const { return static_cast<int>(strtol(*this, NULL, 0)); }
+
/**
* Convert string to double.
*
Modified: branches/collect/source/tools/cTopology.h
===================================================================
--- branches/collect/source/tools/cTopology.h 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/source/tools/cTopology.h 2007-10-24 14:05:38 UTC (rev 2154)
@@ -49,15 +49,15 @@
// And now remove the connections that wrap around.
for(InputIterator i=begin; i!=end; ++i) {
int id = i->GetID();
- unsigned int x = (id-offset) % y_size;
- unsigned int y = (id-offset) / y_size;
+ unsigned int x = (id-offset) % x_size;
+ unsigned int y = (id-offset) / x_size;
if(x==0) {
i->ConnectionList().Remove(&begin[GridNeighbor(i->GetID()-offset, x_size, y_size, -1, -1)]);
i->ConnectionList().Remove(&begin[GridNeighbor(i->GetID()-offset, x_size, y_size, -1, 0)]);
i->ConnectionList().Remove(&begin[GridNeighbor(i->GetID()-offset, x_size, y_size, -1, 1)]);
}
- if(x==(y_size-1)) {
+ if(x==(x_size-1)) {
i->ConnectionList().Remove(&begin[GridNeighbor(i->GetID()-offset, x_size, y_size, 1, -1)]);
i->ConnectionList().Remove(&begin[GridNeighbor(i->GetID()-offset, x_size, y_size, 1, 0)]);
i->ConnectionList().Remove(&begin[GridNeighbor(i->GetID()-offset, x_size, y_size, 1, 1)]);
@@ -67,7 +67,7 @@
i->ConnectionList().Remove(&begin[GridNeighbor(i->GetID()-offset, x_size, y_size, 0, -1)]);
i->ConnectionList().Remove(&begin[GridNeighbor(i->GetID()-offset, x_size, y_size, 1, -1)]);
}
- if(y==(x_size-1)) {
+ if(y==(y_size-1)) {
i->ConnectionList().Remove(&begin[GridNeighbor(i->GetID()-offset, x_size, y_size, -1, 1)]);
i->ConnectionList().Remove(&begin[GridNeighbor(i->GetID()-offset, x_size, y_size, 0, 1)]);
i->ConnectionList().Remove(&begin[GridNeighbor(i->GetID()-offset, x_size, y_size, 1, 1)]);
Modified: branches/collect/support/config/avida.cfg
===================================================================
--- branches/collect/support/config/avida.cfg 2007-10-24 13:30:48 UTC (rev 2153)
+++ branches/collect/support/config/avida.cfg 2007-10-24 14:05:38 UTC (rev 2154)
@@ -36,6 +36,9 @@
# Configuration Files
DATA_DIR data # Directory in which config files are found
INST_SET - # File containing instruction set
+INST_SET_FORMAT 0 # Instruction set file format.
+ # 0 = Default
+ # 1 = New Style
EVENT_FILE events.cfg # File containing list of events during run
ANALYZE_FILE analyze.cfg # File used for analysis mode
ENVIRONMENT_FILE environment.cfg # File that describes the environment
@@ -50,8 +53,11 @@
# germline replication.
GERMLINE_REPLACES_SOURCE 0 # Whether the source germline is updated
# on replication; 0=no.
-GERMLINE_RANDOM_PLACEMENT 0 # Whether the seed for a germline is placed
- # randomly within the deme; 0=no.
+GERMLINE_RANDOM_PLACEMENT 0 # Defines how the seed for a germline is placed
+ # within the deme;
+ # 0 = organisms is placed in center of deme, no orientation
+ # 1 = organisms is placed in center of deme and oriented
+ # 2 = organism is randomly placed in deme, no orientation
MAX_DEME_AGE 500 # The maximum age of a deme (in updates) to be
# used for age-based replication (default=500).
@@ -178,8 +184,8 @@
# 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_DEFAULT_BONUS 0 # Scale the merit of an offspring by this default bonus
+ # rather than the accumulated bonus of the parent? 0 = off
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
@@ -305,6 +311,7 @@
# 0 = on divide
# 1 = on completion of task
# 2 = on sleep
+FRAC_ENERGY_TRANSFER 0.0 # Fraction of replaced organism's energy take by new resident
LOG_SLEEP_TIMES 0 # Log sleep start and end times. 0/1 (off/on)
# WARNING: may use lots of memory.
@@ -326,14 +333,23 @@
# Promoters
PROMOTERS_ENABLED 0 # Use the promoter/terminator execution scheme.
# Certain instructions must also be included.
-PROMOTER_MAX_INST 20 # Maximum number of instructions to execute before terminating.
+PROMOTER_INST_MAX 0 # Maximum number of instructions to execute before terminating. 0 = off
PROMOTER_PROCESSIVITY 1.0 # Chance of not terminating after each cpu cycle.
PROMOTER_PROCESSIVITY_INST 1.0 # Chance of not terminating after each instruction.
-PROMOTER_BG_STRENGTH 0 # Probability of positions that are not promoter
- # instructions initiating execution (promoters are 1).
-REGULATION_STRENGTH 1 # Strength added or subtracted to a promoter by regulation.
-REGULATION_DECAY_FRAC 0.1 # Fraction of regulation that decays away.
- # Max regulation = 2^(REGULATION_STRENGTH/REGULATION_DECAY_FRAC)
+PROMOTER_TO_REGISTER 0 # Place a promoter's base bit code in register BX when starting execution from it?
+TERMINATION_RESETS 0 # Does termination reset the thread's state?
+NO_ACTIVE_PROMOTER_EFFECT 0 # What happens when there are no active promoters?
+ # 0 = Start execution at the beginning of the genome.
+ # 1 = Kill the organism.
+ # 2 = Stop the organism from executing any further instructions.
+PROMOTER_CODE_SIZE 24 # Size of a promoter code in bits. (Maximum value is 32)
+PROMOTER_EXE_LENGTH 3 # Length of promoter windows used to determine execution.
+PROMOTER_EXE_THRESHOLD 2 # Minimum number of bits that must be set in a promoter window to allow execution.
+INST_CODE_LENGTH 3 # Instruction binary code length (number of bits)
+INST_CODE_DEFAULT_TYPE 0 # Default value of instruction binary code value.
+ # 0 = All zeros
+ # 1 = Based off the instruction number
+CONSTITUTIVE_REGULATION 0 # Sense a new regulation value before each CPU cycle?
### COLORS_GROUP ###
# Output colors for when data files are printed in HTML mode.
Copied: branches/collect/tests/energy_deme_level_res/expected (from rev 2073, development/tests/energy_deme_level_res/expected)
More information about the Avida-cvs
mailing list