[Avida-SVN] r3517 - branches/topology-manager/source/main

pakanati at myxo.css.msu.edu pakanati at myxo.css.msu.edu
Fri Oct 30 14:34:56 PDT 2009


Author: pakanati
Date: 2009-10-30 17:34:56 -0400 (Fri, 30 Oct 2009)
New Revision: 3517

Added:
   branches/topology-manager/source/main/cTopoElement.h
   branches/topology-manager/source/main/cTopologyManagerChildInterface.h
Modified:
   branches/topology-manager/source/main/cPopulation.cc
   branches/topology-manager/source/main/cPopulation.h
   branches/topology-manager/source/main/cPopulationCell.h
   branches/topology-manager/source/main/cTopologyManager.cc
   branches/topology-manager/source/main/cTopologyManager.h
   branches/topology-manager/source/main/cWorld.cc
   branches/topology-manager/source/main/cWorld.h
Log:
Broken topology manager update...

Modified: branches/topology-manager/source/main/cPopulation.cc
===================================================================
--- branches/topology-manager/source/main/cPopulation.cc	2009-10-30 16:51:53 UTC (rev 3516)
+++ branches/topology-manager/source/main/cPopulation.cc	2009-10-30 21:34:56 UTC (rev 3517)
@@ -29,10 +29,6 @@
 #include "cChangeList.h"
 #include "cClassificationManager.h"
 #include "cCodeLabel.h"
-#include "cConstBurstSchedule.h"
-#include "cConstSchedule.h"
-#include "cDataFile.h"
-#include "cDemeProbSchedule.h"
 #include "cEnvironment.h"
 #include "functions.h"
 #include "cGenome.h"
@@ -43,13 +39,10 @@
 #include "cInitFile.h"
 #include "cInjectGenotype.h"
 #include "cInstSet.h"
-#include "cIntegratedSchedule.h"
 #include "cLineage.h"
 #include "cOrganism.h"
 #include "cPhenotype.h"
 #include "cPopulationCell.h"
-#include "cProbSchedule.h"
-#include "cProbDemeProbSchedule.h"
 #include "cResource.h"
 #include "cResourceCount.h"
 #include "cSaleItem.h"
@@ -84,73 +77,14 @@
 using namespace std;
 
 
-cPopulation::cPopulation(cWorld* world)
+cPopulation::cPopulation(cWorld* world, int numcells) // AP add in cTopologyInterface 10/2
 : m_world(world)
-, schedule(NULL)
 //, resource_count(world->GetEnvironment().GetResourceLib().GetSize())
 , birth_chamber(world)
 , environment(world->GetEnvironment())
 , num_organisms(0)
 , sync_events(false)
 {
-  // Avida specific information.
-  world_x = world->GetConfig().WORLD_X.Get();
-  world_y = world->GetConfig().WORLD_Y.Get();
-  world_z = world->GetConfig().WORLD_Z.Get();
-
-
-  const int num_cells = world_x * world_y * world_z;
-  const int geometry = world->GetConfig().WORLD_GEOMETRY.Get();
-
-  if(m_world->GetConfig().ENERGY_CAP.Get() == -1) {
-    m_world->GetConfig().ENERGY_CAP.Set(std::numeric_limits<double>::max());
-  }
-
-  if(m_world->GetConfig().LOG_SLEEP_TIMES.Get() == 1)  {
-    sleep_log = new tVector<pair<int,int> >[world_x*world_y];
-  }
-  // Print out world details
-  if (world->GetVerbosity() > VERBOSE_NORMAL) {
-    cout << "Building world " << world_x << "x" << world_y << "x" << world_z << " = " << num_cells << " organisms." << endl;
-    switch(geometry) {
-      case nGeometry::GRID: { cout << "Geometry: Bounded grid" << endl; break; }
-      case nGeometry::TORUS: { cout << "Geometry: Torus" << endl; break; }
-      case nGeometry::CLIQUE: { cout << "Geometry: Clique" << endl; break; }
-      case nGeometry::HEX: { cout << "Geometry: Hex" << endl; break; }
-	  case nGeometry::LATTICE: { cout << "Geometry: Lattice" << endl; break; }
-	  case nGeometry::PARTIAL: { cout << "Geometry: Partial" << endl; break; }
-      default:
-        cout << "Unknown geometry!" << endl;
-        assert(false);
-    }
-  }
-
-	// Not ready for prime time yet; need to look at how resources work in this now
-	// more complex world.
-	assert(world_z == 1);
-
-  // The following combination of options creates an infinite rotate-loop:
-  assert(!((m_world->GetConfig().DEMES_ORGANISM_PLACEMENT.Get()==0)
-           && (m_world->GetConfig().DEMES_ORGANISM_FACING.Get()==1)
-           && (m_world->GetConfig().WORLD_GEOMETRY.Get()==1)));
-
-  // Incompatible deme replication strategies:
-  assert(!(m_world->GetConfig().DEMES_REPLICATE_SIZE.Get()
-           && (m_world->GetConfig().DEMES_PROB_ORG_TRANSFER.Get()>0.0)));
-  assert(!(m_world->GetConfig().DEMES_USE_GERMLINE.Get()
-           && (m_world->GetConfig().DEMES_PROB_ORG_TRANSFER.Get()>0.0)));
-  assert(!(m_world->GetConfig().DEMES_USE_GERMLINE.Get()
-           && (m_world->GetConfig().MIGRATION_RATE.Get()>0.0)));
-
-#ifdef DEBUG
-  const int birth_method = m_world->GetConfig().BIRTH_METHOD.Get();
-
-// AP figure out what following lines are used for
-//  if(num_demes > 1) {
-//    assert(birth_method != POSITION_CHILD_FULL_SOUP_ELDEST);
-//  }
-#endif
-
   // Allocate the cells, resources, and market.
   cell_array.ResizeClear(num_cells);
   empty_cell_id_array.ResizeClear(cell_array.GetSize());
@@ -165,17 +99,11 @@
     }
   }
 
-  BuildTimeSlicer(0);
-
   // Setup the resources...
   const cResourceLib & resource_lib = environment.GetResourceLib();
   int global_res_index = -1;
   int deme_res_index = -1;
 
-  topology_manager = new cTopologyManager(world, this);
-
-
-
   cResourceCount tmp_res_count(resource_lib.GetSize() - topology_manager->num_deme_res);
   resource_count = tmp_res_count;
   resource_count.ResizeSpatialGrids(world_x, world_y);
@@ -2584,33 +2512,6 @@
   }
 }
 
-void cPopulation::BuildTimeSlicer(cChangeList * change_list)
-{
-  switch (m_world->GetConfig().SLICING_METHOD.Get()) {
-    case SLICE_CONSTANT:
-      schedule = new cConstSchedule(cell_array.GetSize());
-      break;
-    case SLICE_PROB_MERIT:
-      schedule = new cProbSchedule(cell_array.GetSize(), m_world->GetRandom().GetInt(0x7FFFFFFF));
-      break;
-    case SLICE_DEME_PROB_MERIT:
-      schedule = new cDemeProbSchedule(cell_array.GetSize(), m_world->GetRandom().GetInt(0x7FFFFFFF), topology_manager->deme_array.GetSize());
-      break;
-    case SLICE_PROB_DEMESIZE_PROB_MERIT:
-      schedule = new cProbDemeProbSchedule(cell_array.GetSize(), m_world->GetRandom().GetInt(0x7FFFFFFF), topology_manager->deme_array.GetSize());
-      break;
-    case SLICE_INTEGRATED_MERIT:
-      schedule = new cIntegratedSchedule(cell_array.GetSize());
-      break;
-    case SLICE_CONSTANT_BURST:
-      schedule = new cConstBurstSchedule(cell_array.GetSize(), m_world->GetConfig().SLICING_BURST_SIZE.Get());
-    default:
-      cout << "Warning: Requested Time Slicer not found, defaulting to Integrated." << endl;
-      schedule = new cIntegratedSchedule(cell_array.GetSize());
-      break;
-  }
-  schedule->SetChangeList(change_list);
-}
 
 
 void cPopulation::FindEmptyCell(tList<cPopulationCell> & cell_list,
@@ -2972,9 +2873,6 @@
 void cPopulation::SetChangeList(cChangeList *change_list){
   schedule->SetChangeList(change_list);
 }
-cChangeList *cPopulation::GetChangeList(){
-  return schedule->GetChangeList();
-}
 
 void cPopulation::AddBeginSleep(int cellID, int start_time) {
   sleep_log[cellID].Add(make_pair(start_time,-1));

Modified: branches/topology-manager/source/main/cPopulation.h
===================================================================
--- branches/topology-manager/source/main/cPopulation.h	2009-10-30 16:51:53 UTC (rev 3516)
+++ branches/topology-manager/source/main/cPopulation.h	2009-10-30 21:34:56 UTC (rev 3517)
@@ -45,6 +45,12 @@
 #ifndef cResourceCount_h
 #include "cResourceCount.h"
 #endif
+#ifndef cTopoElement_h
+#include "cTopoElement.h"
+#endif
+#ifndef cTopologyManager_h
+#include "cTopologyManager.h"
+#endif
 #ifndef cString_h
 #include "cString.h"
 #endif
@@ -60,14 +66,9 @@
 #ifndef tVector_h
 #include "tVector.h"
 #endif
-#ifndef cTopologyManager_h
-#include "cTopologyManager.h"
-#endif
 #ifndef cInstSet_h
 #include "cInstSet.h"
 #endif
-
-
 #if USE_tMemTrack
 # ifndef tMemTrack_h
 #  include "tMemTrack.h"
@@ -77,27 +78,25 @@
 
 class cAvidaContext;
 class cCodeLabel;
-class cChangeList;
 class cEnvironment;
 class cGenome;
 class cGenotype;
 class cLineage;
 class cOrganism;
 class cPopulationCell;
-class cSchedule;
 class cSaleItem;
 class cTopologyManager;
+class cTopoElement;
 
-
-class cPopulation
+class cPopulation : public cTopoElement
 {
+  friend class cTopologyManager;
 #if USE_tMemTrack
   tMemTrack<cPopulation> mt;
 #endif
 private:
   // Components...
   cWorld* m_world;
-  cSchedule* schedule;                // Handles allocation of CPU cycles
   tArray<int> empty_cell_id_array;     // Used for PREFER_EMPTY birth methods
   cResourceCount resource_count;       // Global resources available
   cBirthChamber birth_chamber;         // Global birth chamber.
@@ -109,6 +108,7 @@
 
   // Data Tracking...
   tList<cPopulationCell> reaper_queue; // Death order in some mass-action runs
+  tArray<cPopulationCell> cell_array;  // Local cells composing the population
 
   // Default organism setups...
   cEnvironment & environment;          // Physics & Chemistry description
@@ -126,7 +126,6 @@
   std::map<int, int> m_groups; //<! Maps the group id to the number of orgs in the group
 
   ///////////////// Private Methods ////////////////////
-  void BuildTimeSlicer(cChangeList* change_list); // Build the schedule object
 
   // Methods to place offspring in the population.
   cPopulationCell& PositionChild(cPopulationCell& parent_cell, bool parent_ok = true);
@@ -163,9 +162,6 @@
   cPopulation(cWorld* world);
   ~cPopulation();
 
-
-  tArray<cPopulationCell> cell_array;  // Local cells composing the population
-
   void InitiatePop();
 
   cTopologyManager* GetTopologyManager() { return topology_manager; } // AP : Need to invert this relationship in the future.
@@ -262,9 +258,6 @@
 
   bool UpdateMerit(int cell_id, double new_merit);
 
-  void SetChangeList(cChangeList* change_list);
-  cChangeList* GetChangeList();
-
   void AddBeginSleep(int cellID, int start_time);
   void AddEndSleep(int cellID, int end_time);
 

Modified: branches/topology-manager/source/main/cPopulationCell.h
===================================================================
--- branches/topology-manager/source/main/cPopulationCell.h	2009-10-30 16:51:53 UTC (rev 3516)
+++ branches/topology-manager/source/main/cPopulationCell.h	2009-10-30 21:34:56 UTC (rev 3517)
@@ -38,6 +38,9 @@
 #ifndef tList_h
 #include "tList.h"
 #endif
+#ifndef cPopulation_h
+#include "cPopulation.h"
+#endif
 
 class cHardwareBase;
 class cPopulation;
@@ -51,10 +54,10 @@
 
 private:
   cWorld* m_world;
-  
+
   cOrganism* m_organism;                    // The occupent of this cell.
   cHardwareBase* m_hardware;
-  
+
   tList<cPopulationCell> m_connections;  // A list of neighboring cells.
   cMutationRates* m_mut_rates;           // Mutation rates at this cell.
   tArray<int> m_inputs;                 // Environmental Inputs...
@@ -70,13 +73,13 @@
   int m_x; //!< The x-coordinate of the position of this cell in the environment.
   int m_y; //!< The y-coordinate of the position of this cell in the environment.
 
-  // @WRE: Statistic for movement  
+  // @WRE: Statistic for movement
   int m_visits; // The number of times Avidians move into the cell
-  
+
   void InsertOrganism(cOrganism* new_org);
   cOrganism* RemoveOrganism();
 
-  
+
 public:
   cPopulationCell() : m_world(NULL), m_organism(NULL), m_hardware(NULL), m_mut_rates(NULL), m_migrant(false) { ; }
   cPopulationCell(const cPopulationCell& in_cell);
@@ -105,7 +108,7 @@
   inline void IncVisits() { m_visits++; } // @WRE: Increments the visit count for a cell
   inline const cMutationRates& MutationRates() const { assert(m_mut_rates); return *m_mut_rates; }
   inline cMutationRates& MutationRates() { assert(m_mut_rates); return *m_mut_rates; }
-  
+
   inline int GetInput(int) const { return m_inputs[m_cell_id]; }
   inline const tArray<int>& GetInputs() const { return m_inputs; }
   inline int GetInputAt(int& input_pointer);
@@ -116,7 +119,7 @@
   inline int GetDemeID() const { return m_deme_id; }
   inline int GetCellData() const { return m_cell_data; }
   void SetCellData(const int data) { m_cell_data = data; }
-  
+
   inline int GetSpeculativeState() const { return m_spec_state; }
   inline void SetSpeculativeState(int count) { m_spec_state = count; }
   inline void DecSpeculative() { m_spec_state--; }

Added: branches/topology-manager/source/main/cTopoElement.h
===================================================================
--- branches/topology-manager/source/main/cTopoElement.h	                        (rev 0)
+++ branches/topology-manager/source/main/cTopoElement.h	2009-10-30 21:34:56 UTC (rev 3517)
@@ -0,0 +1,41 @@
+/*
+ *  cTopoElement.h
+ *  Avida
+ *
+ *  Created by Anu on 10/15/09.
+ *  Copyright 1999-2009 Michigan State University. All rights reserved.
+ *
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  as published by the Free Software Foundation; version 2
+ *  of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  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.
+ *
+ */
+
+
+#ifndef cTopoElement_h
+#define cTopoElement_h
+
+
+#include <cassert>
+
+
+class cTopoElement
+{
+protected:
+  cTopoElement(); // @not_implemented
+
+};
+
+
+#endif

Modified: branches/topology-manager/source/main/cTopologyManager.cc
===================================================================
--- branches/topology-manager/source/main/cTopologyManager.cc	2009-10-30 16:51:53 UTC (rev 3516)
+++ branches/topology-manager/source/main/cTopologyManager.cc	2009-10-30 21:34:56 UTC (rev 3517)
@@ -29,6 +29,13 @@
 #include "cPopulation.h"
 #include "cTopology.h"
 #include "cTopologyManager.h"
+#include "cProbSchedule.h"
+#include "cIntegratedSchedule.h"
+#include "cConstBurstSchedule.h"
+#include "cConstSchedule.h"
+#include "cDataFile.h"
+#include "cDemeProbSchedule.h"
+#include "cProbDemeProbSchedule.h"
 
 #include <fstream>
 #include <vector>
@@ -40,10 +47,70 @@
 #include <climits>
 
 
-cTopologyManager::cTopologyManager(cWorld* world, cPopulation* pop)
-: m_world(world), m_pop(pop), cell_array(pop->cell_array)
-, environment(world->GetEnvironment())
+cTopologyManager::cTopologyManager(cWorld* world)
+: m_world(world)
+, environment(world->GetEnvironment()), schedule(NULL)
 {
+
+  // Avida specific information.
+  world_x = world->GetConfig().WORLD_X.Get();
+  world_y = world->GetConfig().WORLD_Y.Get();
+  world_z = world->GetConfig().WORLD_Z.Get();
+
+
+  const int num_cells = world_x * world_y * world_z;
+  const int geometry = world->GetConfig().WORLD_GEOMETRY.Get();
+
+  if(m_world->GetConfig().ENERGY_CAP.Get() == -1) {
+    m_world->GetConfig().ENERGY_CAP.Set(std::numeric_limits<double>::max());
+  }
+
+  if(m_world->GetConfig().LOG_SLEEP_TIMES.Get() == 1)  {
+    sleep_log = new tVector<pair<int,int> >[world_x*world_y];
+  }
+  // Print out world details
+  if (world->GetVerbosity() > VERBOSE_NORMAL) {
+    cout << "Building world " << world_x << "x" << world_y << "x" << world_z << " = " << num_cells << " organisms." << endl;
+    switch(geometry) {
+      case nGeometry::GRID: { cout << "Geometry: Bounded grid" << endl; break; }
+      case nGeometry::TORUS: { cout << "Geometry: Torus" << endl; break; }
+      case nGeometry::CLIQUE: { cout << "Geometry: Clique" << endl; break; }
+      case nGeometry::HEX: { cout << "Geometry: Hex" << endl; break; }
+          case nGeometry::LATTICE: { cout << "Geometry: Lattice" << endl; break; }
+          case nGeometry::PARTIAL: { cout << "Geometry: Partial" << endl; break; }
+      default:
+        cout << "Unknown geometry!" << endl;
+        assert(false);
+    }
+  }
+
+
+  // Not ready for prime time yet; need to look at how resources work in this now
+  // more complex world.
+  assert(world_z == 1);
+
+  // The following combination of options creates an infinite rotate-loop:
+  assert(!((m_world->GetConfig().DEMES_ORGANISM_PLACEMENT.Get()==0)
+       && (m_world->GetConfig().DEMES_ORGANISM_FACING.Get()==1)
+       && (m_world->GetConfig().WORLD_GEOMETRY.Get()==1)));
+
+  // Incompatible deme replication strategies:
+  assert(!(m_world->GetConfig().DEMES_REPLICATE_SIZE.Get()
+       && (m_world->GetConfig().DEMES_PROB_ORG_TRANSFER.Get()>0.0)));
+  assert(!(m_world->GetConfig().DEMES_USE_GERMLINE.Get()
+       && (m_world->GetConfig().DEMES_PROB_ORG_TRANSFER.Get()>0.0)));
+  assert(!(m_world->GetConfig().DEMES_USE_GERMLINE.Get()
+       && (m_world->GetConfig().MIGRATION_RATE.Get()>0.0)));
+
+#ifdef DEBUG
+  const int birth_method = m_world->GetConfig().BIRTH_METHOD.Get();
+
+// AP figure out what following lines are used for
+//  if(num_demes > 1) {
+//    assert(birth_method != POSITION_CHILD_FULL_SOUP_ELDEST);
+//  }
+#endif
+
   int num_demes = m_world->GetConfig().NUM_DEMES.Get();
   // Invalid settings should be changed to one deme
   if (num_demes <= 0) {
@@ -126,6 +193,7 @@
   }
 
 
+  BuildTimeSlicer(0);
 
 
 }
@@ -135,8 +203,14 @@
 
 }
 
+cTopologyManager::InitiateTop()
+{
 
+}
 
+
+
+
 /*! Compete all demes with each other based on the given vector of fitness values.
 
 This form of compete demes uses fitness-proportional selection on a vector of deme
@@ -2539,3 +2613,40 @@
 {
   m_pop->KillOrganism(in_cell);
 }
+
+
+
+/*** Scheduling Functions ****/
+
+void cTopologyManager::BuildTimeSlicer(cChangeList * change_list)
+{
+  switch (m_world->GetConfig().SLICING_METHOD.Get()) {
+    case SLICE_CONSTANT:
+      schedule = new cConstSchedule(cell_array.GetSize());
+      break;
+    case SLICE_PROB_MERIT:
+      schedule = new cProbSchedule(cell_array.GetSize(), m_world->GetRandom().GetInt(0x7FFFFFFF));
+      break;
+    case SLICE_DEME_PROB_MERIT:
+      schedule = new cDemeProbSchedule(cell_array.GetSize(), m_world->GetRandom().GetInt(0x7FFFFFFF), topology_manager->deme_array.GetSize());
+      break;
+    case SLICE_PROB_DEMESIZE_PROB_MERIT:
+      schedule = new cProbDemeProbSchedule(cell_array.GetSize(), m_world->GetRandom().GetInt(0x7FFFFFFF), topology_manager->deme_array.GetSize());
+      break;
+    case SLICE_INTEGRATED_MERIT:
+      schedule = new cIntegratedSchedule(cell_array.GetSize());
+      break;
+    case SLICE_CONSTANT_BURST:
+      schedule = new cConstBurstSchedule(cell_array.GetSize(), m_world->GetConfig().SLICING_BURST_SIZE.Get());
+    default:
+      cout << "Warning: Requested Time Slicer not found, defaulting to Integrated." << endl;
+      schedule = new cIntegratedSchedule(cell_array.GetSize());
+      break;
+  }
+  schedule->SetChangeList(change_list);
+}
+
+cChangeList *cPopulation::GetChangeList()
+{
+  return schedule->GetChangeList();
+}

Modified: branches/topology-manager/source/main/cTopologyManager.h
===================================================================
--- branches/topology-manager/source/main/cTopologyManager.h	2009-10-30 16:51:53 UTC (rev 3516)
+++ branches/topology-manager/source/main/cTopologyManager.h	2009-10-30 21:34:56 UTC (rev 3517)
@@ -31,6 +31,9 @@
 #ifndef cPopulationCell_h
 #include "cPopulationCell.h"
 #endif
+#ifndef cEnvironment_h
+#include "cEnvironment.h"
+#endif
 #ifndef tArray_h
 #include "tArray.h"
 #endif
@@ -40,12 +43,35 @@
 #ifndef tVector_h
 #include "tVector.h"
 #endif
+/*
+#ifndef cTopologyChildrenInterface_h
+#include "cTopologyChildrenInterface.h"
+#endif
+*/
+#ifndef cTopoElement_h
+#include "cTopoElement.h"
+#endif
+#ifndef cPhenotype_h
+#include "cPhenotype.h"
+#endif
+#ifndef cResourceCount_h
+#include "cResourceCount.h"
+#endif
 
+class cChangeList;
+class cSchedule;
+class cEnvironment;
+class cDeme;
+class cPhenotype;
+class cResourceCount;
+class cTopoElement;
 
-class cTopologyManager
+class cTopologyManager : public cTopoElement
 {
 private:
   cWorld* m_world;
+  cSchedule* schedule;                // Handles allocation of CPU cycles
+
   cPopulation* m_pop;
   tArray<cPopulationCell>& cell_array;  // Local cells composing the population
   tArray<int> empty_cell_id_array;     // Used for PREFER_EMPTY birth methods
@@ -53,8 +79,14 @@
   int world_x;                         // Structured population width.
   int world_y;                         // Structured population height.
   int world_z; 						   // Population depth.
-z
 
+
+  /** Scheduling Functions **/
+  void BuildTimeSlicer(cChangeList* change_list); // Build the schedule object
+  cChangeList* GetChangeList();
+  void SetChangeList(cChangeList* change_list);
+
+
 public:
   cTopologyManager(); // not implemented
   cTopologyManager(cWorld* world, cPopulation* pop);
@@ -151,6 +183,10 @@
   void PrintDemeTotalAvgEnergy();
 
 
+  // AP 10/16/2009 Temporary Function.
+  cPopulation& GetPopulation() { return(*m_pop); }
+
+
   // Deme Resources
   const tArray<double>& GetDemeResources(int deme_id) { return GetDeme(deme_id).GetDemeResourceCount().GetResources(); }
   const tArray<double>& GetDemeCellResources(int deme_id, int cell_id) { return GetDeme(deme_id).GetDemeResourceCount().GetCellResources( GetDeme(deme_id).GetRelativeCellID(cell_id) ); }

Added: branches/topology-manager/source/main/cTopologyManagerChildInterface.h
===================================================================
--- branches/topology-manager/source/main/cTopologyManagerChildInterface.h	                        (rev 0)
+++ branches/topology-manager/source/main/cTopologyManagerChildInterface.h	2009-10-30 21:34:56 UTC (rev 3517)
@@ -0,0 +1,64 @@
+/*
+ *  cTopologyChildInterface.h
+ *  Avida
+ *
+ *  Created by David on 3/4/06.
+ *  Copyright 1999-2009 Michigan State University. All rights reserved.
+ *
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  as published by the Free Software Foundation; version 2
+ *  of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  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.
+ *
+ */
+
+// This class is responsible for establishing the interface that links an
+// organism back to its population.  It is a base class that is derived in:
+//
+//   cpu/cTestCPUInterface.{h,cc}      - Test CPU interface
+//   main/cPopulationInterface.{h,cc}  - Main population interface.
+//
+// Make sure that any new function you implment here also has versions in
+// those classes.
+/*
+#ifndef cTopologyManagerChildInterface_h
+#define cTopologyManagerChildInterface_h
+
+class cAvidaContext;
+class cCodeLabel;
+class cDeme;
+class cGenome;
+class cMetaGenome;
+class cOrganism;
+class cOrgMessage;
+class cOrgSinkMessage;
+template <class T> class tArray;
+
+
+class cTopologyManagerChildInterface
+{
+private:
+  cTopologyManagerChildInterface(const cTopologyManagerChildInterface&); // @not_implemented
+  cTopologyManagerChildInterface& operator=(const cTopologyManagerChildInterface&); // @not_implemented
+  cTopologyManager top;
+  CPopulation pop;
+
+public:
+  cTopologyManagerChildInterface() { ; }
+  virtual ~cTopologyManagerChildInterface() { ; }
+
+
+};
+
+#endif
+*/

Modified: branches/topology-manager/source/main/cWorld.cc
===================================================================
--- branches/topology-manager/source/main/cWorld.cc	2009-10-30 16:51:53 UTC (rev 3516)
+++ branches/topology-manager/source/main/cWorld.cc	2009-10-30 21:34:56 UTC (rev 3517)
@@ -36,6 +36,8 @@
 #include "cStats.h"
 #include "cTestCPU.h"
 #include "cTools.h"
+#include "cTopology.h"
+#include "cTopologyManager.h"
 #include "cFallbackWorldDriver.h"
 
 #include <cassert>
@@ -44,11 +46,11 @@
 cWorld::~cWorld()
 {
   // m_actlib is not owned by cWorld, DO NOT DELETE
-  
+
   // These must be deleted first
   delete m_analyze; m_analyze = NULL;
   delete m_pop; m_pop = NULL;
-  
+
   delete m_class_mgr; m_class_mgr = NULL;
   delete m_env; m_env = NULL;
   delete m_event_list; m_event_list = NULL;
@@ -58,7 +60,7 @@
   // Delete after all classes that may be logging items
   if (m_data_mgr) { m_data_mgr->FlushAll(); }
   delete m_data_mgr; m_data_mgr = NULL;
-  
+
   // Delete Last
   delete m_conf; m_conf = NULL;
 
@@ -71,51 +73,55 @@
 {
   m_own_driver = true;
   m_driver = new cFallbackWorldDriver();
-  
+
   // Setup Random Number Generator
   const int rand_seed = m_conf->RANDOM_SEED.Get();
   cout << "Random Seed: " << rand_seed;
   m_rng.ResetSeed(rand_seed);
   if (rand_seed != m_rng.GetSeed()) cout << " -> " << m_rng.GetSeed();
   cout << endl;
-  
+
   m_data_mgr = new cDataFileManager(m_conf->DATA_DIR.Get(), (m_conf->VERBOSITY.Get() > VERBOSE_ON));
   if (m_conf->VERBOSITY.Get() > VERBOSE_NORMAL)
     cout << "Data Directory: " << m_data_mgr->GetTargetDir() << endl;
-  
+
   m_class_mgr = new cClassificationManager(this);
   m_env = new cEnvironment(this);
   m_hw_mgr = new cHardwareManager(this);
-  
+
   // Initialize the default environment...
   // This must be after the HardwareManager in case REACTIONS that trigger instructions are used.
   if (!m_env->Load(m_conf->ENVIRONMENT_FILE.Get())) {
     cerr << "Error: Unable to load environment" << endl;
     Avida::Exit(-1);
   }
-  
+
   // Setup Stats Object
   m_stats = new cStats(this);
-    
+
   const cInstSet& inst_set = m_hw_mgr->GetInstSet();
   for (int i = 0; i < inst_set.GetSize(); i++)
     m_stats->SetInstName(i, inst_set.GetName(i));
-  
+
   // @MRR CClade Tracking
 	if (m_conf->TRACK_CCLADES.Get() > 0)
 		m_class_mgr->LoadCCladeFounders(m_conf->TRACK_CCLADES_IDS.Get());
-  
-	m_pop = new cPopulation(this);
-  m_pop->InitiatePop();
-  
+
+//  m_pop = new cPopulation(this);
+//  m_pop->InitiatePop();
+
+  m_top = new cTopologyManager(this);
+  m_top->InitiateTop();
+
+
   // Setup Event List
   m_event_list = new cEventList(this);
   if (!m_event_list->LoadEventFile(m_conf->EVENT_FILE.Get())) {
     cerr << "Error: Unable to load events" << endl;
     Avida::Exit(-1);
   }
-	
-  
+
+
   const bool revert_fatal = m_conf->REVERT_FATAL.Get() > 0.0;
   const bool revert_neg = m_conf->REVERT_DETRIMENTAL.Get() > 0.0;
   const bool revert_neut = m_conf->REVERT_NEUTRAL.Get() > 0.0;
@@ -123,7 +129,7 @@
   const bool revert_taskloss = m_conf->REVERT_TASKLOSS.Get() > 0.0;
   const bool fail_implicit = m_conf->FAIL_IMPLICIT.Get() > 0;
   m_test_on_div = (revert_fatal || revert_neg || revert_neut || revert_pos || revert_taskloss || fail_implicit);
-  
+
   const bool sterilize_fatal = m_conf->STERILIZE_FATAL.Get() > 0.0;
   const bool sterilize_neg = m_conf->STERILIZE_DETRIMENTAL.Get() > 0.0;
   const bool sterilize_neut = m_conf->STERILIZE_NEUTRAL.Get() > 0.0;
@@ -139,7 +145,7 @@
 }
 
 void cWorld::GetEvents(cAvidaContext& ctx)
-{  
+{
   if (m_pop->GetSyncEvents() == true) {
     m_event_list->Sync();
     m_pop->SetSyncEvents(false);
@@ -163,9 +169,9 @@
 {
   int num_resources = (double)GetEnvironment().GetResourceLib().GetSize();
   int num_nops = (double)GetHardwareManager().GetInstSet().GetNumNops();
-  
+
   if (num_resources <= 0 || num_nops <= 0) { return 0; }
-  
+
   double most_nops_needed = ceil(log((double)num_resources)/log((double)num_nops));
   double numerator = pow(num_nops, most_nops_needed + 1) - 1;
   double denominator = (double)(num_nops - 1);
@@ -176,7 +182,7 @@
 {
   // cleanup current driver, if needed
   if (m_own_driver) delete m_driver;
-  
+
   // store new driver information
   m_driver = driver;
   m_own_driver = take_ownership;

Modified: branches/topology-manager/source/main/cWorld.h
===================================================================
--- branches/topology-manager/source/main/cWorld.h	2009-10-30 16:51:53 UTC (rev 3516)
+++ branches/topology-manager/source/main/cWorld.h	2009-10-30 21:34:56 UTC (rev 3517)
@@ -37,7 +37,11 @@
 #ifndef cRandom_h
 #include "cRandom.h"
 #endif
+#ifndef cTopologyManager_h
+#include "cTopologyManager.h"
+#endif
 
+
 #if USE_tMemTrack
 # ifndef tMemTrack_h
 #  include "tMemTrack.h"
@@ -76,7 +80,8 @@
   cEnvironment* m_env;
   cEventList* m_event_list;
   cHardwareManager* m_hw_mgr;
-  cPopulation* m_pop;
+//  cPopulation* m_pop;
+  cTopologyManager* m_top;
   cStats* m_stats;
   cWorldDriver* m_driver;
 
@@ -108,7 +113,8 @@
   cDataFileManager& GetDataFileManager() { return *m_data_mgr; }
   cEnvironment& GetEnvironment() { return *m_env; }
   cHardwareManager& GetHardwareManager() { return *m_hw_mgr; }
-  cPopulation& GetPopulation() { return *m_pop; }
+//  cPopulation& GetPopulation() { return *m_pop; }
+  cPopulation& GetPopulation() { return m_top->GetPopulation(); }
   cRandom& GetRandom() { return m_rng; }
   cStats& GetStats() { return *m_stats; }
   cWorldDriver& GetDriver() { return *m_driver; }
@@ -144,7 +150,8 @@
     a.ArkvObj("m_env", m_env);
     a.ArkvObj("m_event_list", m_event_list);
     a.ArkvObj("m_hw_mgr", m_hw_mgr);
-    a.ArkvObj("m_pop", m_pop);
+//    a.ArkvObj("m_pop", m_pop);
+// AP 10/2 what is this ?
     a.ArkvObj("m_stats", m_stats);
     a.ArkvObj("m_driver", m_driver);
     a.ArkvObj("m_rng", m_rng);
@@ -167,7 +174,8 @@
     a.ArkvObj("m_env", m_env);
     a.ArkvObj("m_event_list", m_event_list);
     a.ArkvObj("m_hw_mgr", m_hw_mgr);
-    a.ArkvObj("m_pop", m_pop);
+//    a.ArkvObj("m_pop", m_pop);
+    // AP 10/2 what is this ?
     a.ArkvObj("m_stats", m_stats);
     a.ArkvObj("m_driver", m_driver);
     a.ArkvObj("m_rng", m_rng);




More information about the Avida-cvs mailing list