[Avida-SVN] r1089 - in development/source: cpu main utils/task_events
baerb at myxo.css.msu.edu
baerb at myxo.css.msu.edu
Mon Nov 20 12:24:34 PST 2006
Author: baerb
Date: 2006-11-20 15:24:34 -0500 (Mon, 20 Nov 2006)
New Revision: 1089
Modified:
development/source/cpu/cTestCPU.cc
development/source/main/cPopulation.cc
development/source/main/cResourceCount.cc
development/source/main/cResourceCount.h
development/source/main/cSpatialResCount.cc
development/source/utils/task_events/Makefile
Log:
Fixed problem where spatial resource can go negative.
Added comments.
Changed program to print out resource inputs when verbosity is
set to be above normal.
Modified: development/source/cpu/cTestCPU.cc
===================================================================
--- development/source/cpu/cTestCPU.cc 2006-11-20 16:04:12 UTC (rev 1088)
+++ development/source/cpu/cTestCPU.cc 2006-11-20 20:24:34 UTC (rev 1089)
@@ -61,7 +61,7 @@
res->GetInflowX2(), res->GetInflowY1(),
res->GetInflowY2(), res->GetOutflowX1(),
res->GetOutflowX2(), res->GetOutflowY1(),
- res->GetOutflowY2() );
+ res->GetOutflowY2(), world->GetVerbosity() );
}
}
Modified: development/source/main/cPopulation.cc
===================================================================
--- development/source/main/cPopulation.cc 2006-11-20 16:04:12 UTC (rev 1088)
+++ development/source/main/cPopulation.cc 2006-11-20 20:24:34 UTC (rev 1089)
@@ -152,7 +152,7 @@
res->GetInflowX2(), res->GetInflowY1(),
res->GetInflowY2(), res->GetOutflowX1(),
res->GetOutflowX2(), res->GetOutflowY1(),
- res->GetOutflowY2() );
+ res->GetOutflowY2(), world->GetVerbosity() );
m_world->GetStats().SetResourceName(i, res->GetName());
}
Modified: development/source/main/cResourceCount.cc
===================================================================
--- development/source/main/cResourceCount.cc 2006-11-20 16:04:12 UTC (rev 1088)
+++ development/source/main/cResourceCount.cc 2006-11-20 20:24:34 UTC (rev 1089)
@@ -150,7 +150,7 @@
int in_inflowX2, int in_inflowY1,
int in_inflowY2, int in_outflowX1,
int in_outflowX2, int in_outflowY1,
- int in_outflowY2)
+ int in_outflowY2, int verbosity_level)
{
assert(id >= 0 && id < resource_count.GetSize());
assert(initial >= 0.0);
@@ -166,31 +166,34 @@
} else if (in_geometry == nGeometry::TORUS) {
geo_name = "TORUS";
}
-#if 0
- cerr << "Setting up resource " << name
- << "(" << geo_name
- << ") with initial quatity=" << initial
- << ", decay=" << decay
- << ", inflow=" << inflow
- << endl;
- if ((in_geometry == nGeometry::GRID) || (in_geometry == nGeometry::TORUS)) {
- cerr << " Inflow rectangle (" << in_inflowX1
- << "," << in_inflowY1
- << ") to (" << in_inflowX2
- << "," << in_inflowY2
- << ")" << endl;
- cerr << " Outflow rectangle (" << in_outflowX1
- << "," << in_outflowY1
- << ") to (" << in_outflowX2
- << "," << in_outflowY2
- << ")" << endl;
- cerr << " xdiffuse=" << in_xdiffuse
- << ", xgravity=" << in_xgravity
- << ", ydiffuse=" << in_ydiffuse
- << ", ygravity=" << in_ygravity
+
+ /* If the verbose flag is set print out information about resources */
+
+ if (verbosity_level > VERBOSE_NORMAL) {
+ cout << "Setting up resource " << name
+ << "(" << geo_name
+ << ") with initial quatity=" << initial
+ << ", decay=" << decay
+ << ", inflow=" << inflow
<< endl;
- }
-#endif
+ if ((in_geometry == nGeometry::GRID) || (in_geometry == nGeometry::TORUS)) {
+ cout << " Inflow rectangle (" << in_inflowX1
+ << "," << in_inflowY1
+ << ") to (" << in_inflowX2
+ << "," << in_inflowY2
+ << ")" << endl;
+ cout << " Outflow rectangle (" << in_outflowX1
+ << "," << in_outflowY1
+ << ") to (" << in_outflowX2
+ << "," << in_outflowY2
+ << ")" << endl;
+ cout << " xdiffuse=" << in_xdiffuse
+ << ", xgravity=" << in_xgravity
+ << ", ydiffuse=" << in_ydiffuse
+ << ", ygravity=" << in_ygravity
+ << endl;
+ }
+ }
resource_count[id] = initial;
spatial_resource_count[id].RateAll
@@ -308,6 +311,14 @@
assert(resource_count[i] >= 0.0);
} else {
spatial_resource_count[i].Rate(cell_id, res_change[i]);
+
+ /* Ideally the state of the cell's resource should not be set till
+ the end of the update so that all processes (inflow, outflow,
+ diffision, gravity and organism demand) have the same weight. However
+ waiting can cause problems with negative resources so we allow
+ the organism demand work immediately on the state of the resource */
+
+ spatial_resource_count[i].State(cell_id);
}
}
}
Modified: development/source/main/cResourceCount.h
===================================================================
--- development/source/main/cResourceCount.h 2006-11-20 16:04:12 UTC (rev 1088)
+++ development/source/main/cResourceCount.h 2006-11-20 20:24:34 UTC (rev 1089)
@@ -23,6 +23,9 @@
#ifndef tMatrix_h
#include "tMatrix.h"
#endif
+#ifndef defs_h
+#include "defs.h"
+#endif
class cResourceCount
{
@@ -56,10 +59,12 @@
void SetSize(int num_resources);
- void Setup(int id, cString name, double initial, double inflow, double decay, int in_geometry,
- double in_xdiffuse, double in_xgravity, double in_ydiffuse, double in_ygravity,
+ void Setup(int id, cString name, double initial, double inflow, double decay,
+ int in_geometry, double in_xdiffuse, double in_xgravity,
+ double in_ydiffuse, double in_ygravity,
int in_inflowX1, int in_inflowX2, int in_inflowY1, int in_inflowY2,
- int in_outflowX1, int in_outflowX2, int in_outflowY1, int in_outflowY);
+ int in_outflowX1, int in_outflowX2, int in_outflowY1,
+ int in_outflowY, int verbosity_level);
void Update(double in_time);
int GetSize(void) const { return resource_count.GetSize(); }
Modified: development/source/main/cSpatialResCount.cc
===================================================================
--- development/source/main/cSpatialResCount.cc 2006-11-20 16:04:12 UTC (rev 1088)
+++ development/source/main/cSpatialResCount.cc 2006-11-20 20:24:34 UTC (rev 1089)
@@ -14,6 +14,8 @@
#include "nGeometry.h"
+/* Setup a single spatial resource with known flows */
+
cSpatialResCount::cSpatialResCount(int inworld_x, int inworld_y,
int ingeometry,
double inxdiffuse, double inydiffuse, double inxgravity,
@@ -37,6 +39,8 @@
SetPointers();
}
+/* Setup a single spatial resource using default flow amounts */
+
cSpatialResCount::cSpatialResCount(int inworld_x, int inworld_y, int ingeometry)
: grid(inworld_x * inworld_y) {
int i;
@@ -136,7 +140,9 @@
// Check that the x, y ranges of the inflow and outflow rectangles
// are valid
+
/* check range of inputs */
+
if (inflowX1 < 0) {
inflowX1 = 0;
} else if (inflowX1 > world_x) {
@@ -159,6 +165,7 @@
}
/* allow for rectangles that cross over the zero X or zero Y boundry */
+
if (inflowX2 < inflowX1) { inflowX2 += world_x; }
if (inflowY2 < inflowY1) { inflowY2 += world_y; }
if (outflowX1 < 0) {
@@ -183,6 +190,7 @@
}
/* allow for rectangles that cross over the zero X or zero Y boundry */
+
if (outflowX2 < outflowX1) { outflowX2 += world_x; }
if (outflowY2 < outflowY1) { outflowY2 += world_y; }
@@ -197,6 +205,9 @@
}
}
+/* For each cell in the grid add the changes stored in the rate variable
+ with the total of the resource */
+
void cSpatialResCount::StateAll() {
int i;
@@ -229,6 +240,8 @@
}
}
+/* Total up all the resources in each cell */
+
const double cSpatialResCount::SumAll() const{
int i;
@@ -245,7 +258,6 @@
int i, j, elem;
double totalcells;
-
totalcells = (inflowY2 - inflowY1 + 1) * (inflowX2 - inflowX1 + 1) * 1.0;
amount /= totalcells;
Modified: development/source/utils/task_events/Makefile
===================================================================
--- development/source/utils/task_events/Makefile 2006-11-20 16:04:12 UTC (rev 1088)
+++ development/source/utils/task_events/Makefile 2006-11-20 20:24:34 UTC (rev 1089)
@@ -20,10 +20,10 @@
CMAKE_EDIT_COMMAND = /usr/local/bin/ccmake
# The top-level source directory on which CMake was run.
-CMAKE_SOURCE_DIR = /home/covertar/source/development_72806/development
+CMAKE_SOURCE_DIR = /home/baer/avida_official/development
# The top-level build directory on which CMake was run.
-CMAKE_BINARY_DIR = /home/covertar/source/development_72806/development
+CMAKE_BINARY_DIR = /home/baer/avida_official/development
# Default target executed when no arguments are given to make.
default_target: all
@@ -31,7 +31,7 @@
# Special rule for the target edit_cache
edit_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..."
- cd /home/covertar/source/development_72806/development/source/utils/task_events && /usr/local/bin/ccmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
+ cd /home/baer/avida_official/development/source/utils/task_events && /usr/local/bin/ccmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
# Special rule for the target edit_cache
edit_cache/fast: edit_cache
@@ -39,17 +39,17 @@
# Special rule for the target install
install: preinstall
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..."
- cd /home/covertar/source/development_72806/development/source/utils/task_events && /usr/local/bin/cmake -P cmake_install.cmake
+ cd /home/baer/avida_official/development/source/utils/task_events && /usr/local/bin/cmake -P cmake_install.cmake
# Special rule for the target install
install/fast: preinstall/fast
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..."
- cd /home/covertar/source/development_72806/development/source/utils/task_events && /usr/local/bin/cmake -P cmake_install.cmake
+ cd /home/baer/avida_official/development/source/utils/task_events && /usr/local/bin/cmake -P cmake_install.cmake
# Special rule for the target rebuild_cache
rebuild_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
- cd /home/covertar/source/development_72806/development/source/utils/task_events && /usr/local/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
+ cd /home/baer/avida_official/development/source/utils/task_events && /usr/local/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
# Special rule for the target rebuild_cache
rebuild_cache/fast: rebuild_cache
@@ -57,7 +57,7 @@
# Special rule for the target test
test:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running tests..."
- cd /home/covertar/source/development_72806/development/source/utils/task_events && /usr/local/bin/ctest --force-new-ctest-process
+ cd /home/baer/avida_official/development/source/utils/task_events && /usr/local/bin/ctest --force-new-ctest-process
# Special rule for the target test
test/fast: test
@@ -65,9 +65,6 @@
#=============================================================================
# Special targets provided by cmake.
-# Produce verbose output by default.
-VERBOSE = 1
-
# Suppress display of executed commands.
$(VERBOSE).SILENT:
@@ -78,24 +75,24 @@
# The main all target
all: cmake_check_build_system
- cd /home/covertar/source/development_72806/development && $(CMAKE_COMMAND) -E cmake_progress_start /home/covertar/source/development_72806/development/CMakeFiles $(CMAKE_ALL_PROGRESS)
- cd /home/covertar/source/development_72806/development && $(MAKE) -f CMakeFiles/Makefile2 source/utils/task_events/all
- $(CMAKE_COMMAND) -E cmake_progress_start /home/covertar/source/development_72806/development/CMakeFiles 0
+ cd /home/baer/avida_official/development && $(CMAKE_COMMAND) -E cmake_progress_start /home/baer/avida_official/development/CMakeFiles $(CMAKE_ALL_PROGRESS)
+ cd /home/baer/avida_official/development && $(MAKE) -f CMakeFiles/Makefile2 source/utils/task_events/all
+ $(CMAKE_COMMAND) -E cmake_progress_start /home/baer/avida_official/development/CMakeFiles 0
# The main clean target
clean:
- cd /home/covertar/source/development_72806/development && $(MAKE) -f CMakeFiles/Makefile2 source/utils/task_events/clean
+ cd /home/baer/avida_official/development && $(MAKE) -f CMakeFiles/Makefile2 source/utils/task_events/clean
# The main clean target
clean/fast: clean
# Prepare targets for installation.
preinstall: all
- cd /home/covertar/source/development_72806/development && $(MAKE) -f CMakeFiles/Makefile2 source/utils/task_events/preinstall
+ cd /home/baer/avida_official/development && $(MAKE) -f CMakeFiles/Makefile2 source/utils/task_events/preinstall
# Prepare targets for installation.
preinstall/fast:
- cd /home/covertar/source/development_72806/development && $(MAKE) -f CMakeFiles/Makefile2 source/utils/task_events/preinstall
+ cd /home/baer/avida_official/development && $(MAKE) -f CMakeFiles/Makefile2 source/utils/task_events/preinstall
# clear depends
depend:
@@ -121,5 +118,5 @@
# No rule that depends on this can have commands that come from listfiles
# because they might be regenerated.
cmake_check_build_system:
- cd /home/covertar/source/development_72806/development && $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
+ cd /home/baer/avida_official/development && $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
More information about the Avida-cvs
mailing list