[Avida-SVN] r1834 - in development: documentation source/main tests

baerb at myxo.css.msu.edu baerb at myxo.css.msu.edu
Fri Jul 20 14:30:09 PDT 2007


Author: baerb
Date: 2007-07-20 17:30:09 -0400 (Fri, 20 Jul 2007)
New Revision: 1834

Removed:
   development/tests/default_classic_100u/
Modified:
   development/documentation/environment.html
   development/source/main/cDeme.h
   development/source/main/cEnvironment.cc
   development/source/main/cPopulation.cc
   development/source/main/cResource.cc
   development/source/main/cResource.h
   development/source/main/cResourceCount.cc
   development/source/main/cResourceCount.h
   development/source/main/nGeometry.h
Log:

Added basic infrastructure to have deme based resources



Modified: development/documentation/environment.html
===================================================================
--- development/documentation/environment.html	2007-07-20 20:27:02 UTC (rev 1833)
+++ development/documentation/environment.html	2007-07-20 21:30:09 UTC (rev 1834)
@@ -123,6 +123,16 @@
   <td>global</td>
 </tr>
 <tr>
+  <td class="resall">deme</td>
+  <td>
+    Is this resource going to be used by a deme. (<em>True</em> or 
+    <em>False</em>)
+  </td>
+  <td>
+    false
+  </td>
+</tr>
+<tr>
   <td class="resspatial">inflowx1</td>
   <td>
     Leftmost coordinate of the rectangle where resource will flow

Modified: development/source/main/cDeme.h
===================================================================
--- development/source/main/cDeme.h	2007-07-20 20:27:02 UTC (rev 1833)
+++ development/source/main/cDeme.h	2007-07-20 21:30:09 UTC (rev 1834)
@@ -26,6 +26,8 @@
 
 #include "cGermline.h"
 #include "tArray.h"
+#include "cResourceCount.h"
+#include "cStringList.h"
 
 
 /*! Demes are groups of cells in the population that are somehow bound together
@@ -44,6 +46,9 @@
   cGermline _germline; //!< The germline for this deme, if used.
 
   cDeme(const cDeme&); // @not_implemented
+  
+  cResourceCount deme_resource_count; //!< Resources available to the deme
+  cStringList deme_resource_names; //!< Name of resources used by this deme
 
   
 public:

Modified: development/source/main/cEnvironment.cc
===================================================================
--- development/source/main/cEnvironment.cc	2007-07-20 20:27:02 UTC (rev 1833)
+++ development/source/main/cEnvironment.cc	2007-07-20 21:30:09 UTC (rev 1834)
@@ -382,6 +382,13 @@
         if (!AssertInputDouble(var_value, "ygravity", var_type)) return false;
         new_resource->SetYGravity( var_value.AsDouble() );
       }
+      else if (var_name == "deme") {
+        if (!new_resource->SetDemeResource( var_value )) {
+          cerr << "Error: In " << var_type << "," << var_value <<
+          " must be true or false" << endl;
+          return false;
+        }
+      }
       else {
         cerr << "Error: Unknown variable '" << var_name
         << "' in resource '" << name << "'" << endl;
@@ -452,6 +459,7 @@
       this_resource->SetXGravity(0.0);
       this_resource->SetYDiffuse(0.0);
       this_resource->SetYGravity(0.0);
+      this_resource->SetDemeResource("false");
     } else {
       this_resource = resource_lib.GetResource(name);
     }

Modified: development/source/main/cPopulation.cc
===================================================================
--- development/source/main/cPopulation.cc	2007-07-20 20:27:02 UTC (rev 1833)
+++ development/source/main/cPopulation.cc	2007-07-20 21:30:09 UTC (rev 1834)
@@ -177,20 +177,24 @@
   
   // Setup the resources...
   const cResourceLib & resource_lib = environment.GetResourceLib();
+  int global_res_index = -1;
   for (int i = 0; i < resource_lib.GetSize(); i++) {
     cResource * res = resource_lib.GetResource(i);
-    const double decay = 1.0 - res->GetOutflow();
-    resource_count.Setup(i, res->GetName(), res->GetInitial(), 
-                         res->GetInflow(), decay,
-                         res->GetGeometry(), res->GetXDiffuse(),
-                         res->GetXGravity(), res->GetYDiffuse(), 
-                         res->GetYGravity(), res->GetInflowX1(), 
-                         res->GetInflowX2(), res->GetInflowY1(), 
-                         res->GetInflowY2(), res->GetOutflowX1(), 
-                         res->GetOutflowX2(), res->GetOutflowY1(), 
-                         res->GetOutflowY2(), res->GetCellListPtr(),
-                         world->GetVerbosity() );
-    m_world->GetStats().SetResourceName(i, res->GetName());
+    if (!res->GetDemeResource()) {
+      global_res_index++;
+      const double decay = 1.0 - res->GetOutflow();
+      resource_count.Setup(global_res_index, res->GetName(), res->GetInitial(), 
+                           res->GetInflow(), decay,
+                           res->GetGeometry(), res->GetXDiffuse(),
+                           res->GetXGravity(), res->GetYDiffuse(), 
+                           res->GetYGravity(), res->GetInflowX1(), 
+                           res->GetInflowX2(), res->GetInflowY1(), 
+                           res->GetInflowY2(), res->GetOutflowX1(), 
+                           res->GetOutflowX2(), res->GetOutflowY1(), 
+                           res->GetOutflowY2(), res->GetCellListPtr(),
+                           world->GetVerbosity() );
+      m_world->GetStats().SetResourceName(global_res_index, res->GetName());
+    }
   }
   
   // Load a clone if one is provided, otherwise setup start organism.

Modified: development/source/main/cResource.cc
===================================================================
--- development/source/main/cResource.cc	2007-07-20 20:27:02 UTC (rev 1833)
+++ development/source/main/cResource.cc	2007-07-20 21:30:09 UTC (rev 1834)
@@ -18,8 +18,8 @@
  *  GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *  along with this program; if not, write to the Free Software Foundation, 
+ *  Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  */
 
@@ -65,10 +65,14 @@
   , xgravity(0.0)
   , ydiffuse(1.0)
   , ygravity(0.0)
+  , deme_resource(false)
 {
 }
 
 bool cResource::SetGeometry(cString _geometry)
+
+/* Set the geometry for the resource */
+
 {
      _geometry.ToLower();
      if (_geometry == "global") {
@@ -84,3 +88,20 @@
           return false;
      }
 }
+
+bool cResource::SetDemeResource(cString _deme_resource)
+
+/* Set if the resource is going to be accessable by demes */
+
+{
+  _deme_resource.ToLower();
+  if ((_deme_resource == "false") || (_deme_resource = "0")) {
+    deme_resource = false;
+    return(true);
+  } else if ((_deme_resource == "true") || (_deme_resource = "1")) {
+    deme_resource = true;
+    return(true);
+  } else {
+    return false;
+  }
+}

Modified: development/source/main/cResource.h
===================================================================
--- development/source/main/cResource.h	2007-07-20 20:27:02 UTC (rev 1833)
+++ development/source/main/cResource.h	2007-07-20 21:30:09 UTC (rev 1834)
@@ -78,6 +78,7 @@
   double xgravity;
   double ydiffuse;
   double ygravity;
+  bool deme_resource;
   tArray<cCellResource> cell_list;
  
   
@@ -105,6 +106,7 @@
   double GetXGravity() const { return xgravity; }
   double GetYDiffuse() const { return ydiffuse; }
   double GetYGravity() const { return ygravity; }
+  bool GetDemeResource() const { return deme_resource; }
   tArray<cCellResource> *GetCellListPtr() { return &cell_list; }
 
 
@@ -124,6 +126,7 @@
   void SetXGravity(double _xgravity) { xgravity = _xgravity; }
   void SetYDiffuse(double _ydiffuse) { ydiffuse = _ydiffuse; }
   void SetYGravity(double _ygravity) { ygravity = _ygravity; }
+  bool SetDemeResource(cString _deme_resource);
   void AddCellResource(cCellResource new_cell) { cell_list.Push(new_cell); }
 };
 

Modified: development/source/main/cResourceCount.cc
===================================================================
--- development/source/main/cResourceCount.cc	2007-07-20 20:27:02 UTC (rev 1833)
+++ development/source/main/cResourceCount.cc	2007-07-20 21:30:09 UTC (rev 1834)
@@ -18,8 +18,8 @@
  *  GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *  along with this program; if not, write to the Free Software Foundation,
+ *  Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  */
 

Modified: development/source/main/cResourceCount.h
===================================================================
--- development/source/main/cResourceCount.h	2007-07-20 20:27:02 UTC (rev 1833)
+++ development/source/main/cResourceCount.h	2007-07-20 21:30:09 UTC (rev 1834)
@@ -18,8 +18,8 @@
  *  GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *  along with this program; if not, write to the Free Software Foundation,
+ *  Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  */
 

Modified: development/source/main/nGeometry.h
===================================================================
--- development/source/main/nGeometry.h	2007-07-20 20:27:02 UTC (rev 1833)
+++ development/source/main/nGeometry.h	2007-07-20 21:30:09 UTC (rev 1834)
@@ -17,11 +17,13 @@
  *  GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *  along with this program; if not, write to the Free Software Foundation, 
+ *  Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  */
 
+/*! Namespace to hold possible values of the world grids geometry */
+
 #ifndef nGeometry_h
 #define nGeometry_h
 




More information about the Avida-cvs mailing list