[Avida-SVN] r2061 - in branches/energy: . Avida.xcodeproj source/actions source/cpu source/main
beckma24 at myxo.css.msu.edu
beckma24 at myxo.css.msu.edu
Thu Sep 6 11:48:28 PDT 2007
Author: beckma24
Date: 2007-09-06 14:48:28 -0400 (Thu, 06 Sep 2007)
New Revision: 2061
Modified:
branches/energy/Avida.xcodeproj/project.pbxproj
branches/energy/CMakeLists.txt
branches/energy/source/actions/EnvironmentActions.cc
branches/energy/source/actions/PopulationActions.cc
branches/energy/source/actions/PrintActions.cc
branches/energy/source/cpu/cHardwareCPU.cc
branches/energy/source/cpu/cHardwareCPU.h
branches/energy/source/main/cDeme.cc
branches/energy/source/main/cDeme.h
branches/energy/source/main/cPopulation.cc
branches/energy/source/main/cPopulationCell.cc
branches/energy/source/main/cPopulationCell.h
Log:
Added:
data field to cPopulationCell
collect-cell-data instruction
cDemeCellEvent.cc and .h
environment action DelayedDemeEvent
print action DumpCellDataGrid
Made other minor changes
Modified: branches/energy/Avida.xcodeproj/project.pbxproj
===================================================================
--- branches/energy/Avida.xcodeproj/project.pbxproj 2007-09-06 15:58:57 UTC (rev 2060)
+++ branches/energy/Avida.xcodeproj/project.pbxproj 2007-09-06 18:48:28 UTC (rev 2061)
@@ -195,6 +195,12 @@
70F9FC100C469DD70083B788 /* cASTDumpVisitor.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70F9FC0F0C469DC10083B788 /* cASTDumpVisitor.cc */; };
B4FA258A0C5EB65E0086D4B5 /* cPlasticPhenotype.cc in Sources */ = {isa = PBXBuildFile; fileRef = B4FA25810C5EB6510086D4B5 /* cPlasticPhenotype.cc */; };
B4FA25A90C5EB7880086D4B5 /* cPhenPlastGenotype.cc in Sources */ = {isa = PBXBuildFile; fileRef = B4FA259E0C5EB7600086D4B5 /* cPhenPlastGenotype.cc */; };
+ B524E6520C8EFE19002AC57D /* cDemeCellEvent.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = B524E6510C8EFE19002AC57D /* cDemeCellEvent.h */; };
+ B524E6530C8EFE19002AC57D /* cDemeCellEvent.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = B524E6510C8EFE19002AC57D /* cDemeCellEvent.h */; };
+ B524E6540C8EFE19002AC57D /* cDemeCellEvent.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = B524E6510C8EFE19002AC57D /* cDemeCellEvent.h */; };
+ B524E6680C8EFF1B002AC57D /* cDemeCellEvent.cc in Sources */ = {isa = PBXBuildFile; fileRef = B524E6670C8EFF1B002AC57D /* cDemeCellEvent.cc */; };
+ B524E6690C8EFF1B002AC57D /* cDemeCellEvent.cc in Sources */ = {isa = PBXBuildFile; fileRef = B524E6670C8EFF1B002AC57D /* cDemeCellEvent.cc */; };
+ B524E66A0C8EFF1B002AC57D /* cDemeCellEvent.cc in Sources */ = {isa = PBXBuildFile; fileRef = B524E6670C8EFF1B002AC57D /* cDemeCellEvent.cc */; };
/* End PBXBuildFile section */
/* Begin PBXBuildRule section */
@@ -315,6 +321,7 @@
dstSubfolderSpec = 16;
files = (
700E2B87085DE54400CF158A /* avida-viewer in CopyFiles */,
+ B524E6540C8EFE19002AC57D /* cDemeCellEvent.h in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -339,6 +346,7 @@
7049F3730A66AD7E00640512 /* default-transsmt.org in CopyFiles */,
70B1A7430B7E3FFD00067486 /* instset-experimental.cfg in CopyFiles */,
70B1A75A0B7E431F00067486 /* experimental.org in CopyFiles */,
+ B524E6520C8EFE19002AC57D /* cDemeCellEvent.h in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -359,6 +367,7 @@
dstSubfolderSpec = 16;
files = (
702F532F0993060A00B2B507 /* avida-s in CopyFiles */,
+ B524E6530C8EFE19002AC57D /* cDemeCellEvent.h in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -834,6 +843,8 @@
B4FA25810C5EB6510086D4B5 /* cPlasticPhenotype.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cPlasticPhenotype.cc; sourceTree = "<group>"; };
B4FA25820C5EB6510086D4B5 /* cPlasticPhenotype.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cPlasticPhenotype.h; sourceTree = "<group>"; };
B4FA259E0C5EB7600086D4B5 /* cPhenPlastGenotype.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cPhenPlastGenotype.cc; sourceTree = "<group>"; };
+ B524E6510C8EFE19002AC57D /* cDemeCellEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cDemeCellEvent.h; sourceTree = "<group>"; };
+ B524E6670C8EFF1B002AC57D /* cDemeCellEvent.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cDemeCellEvent.cc; sourceTree = "<group>"; };
DCC30FCF0762539D008F7A48 /* Doxyfile */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = Doxyfile; sourceTree = "<group>"; };
DCC3109C0762539E008F7A48 /* avida.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = avida.cc; sourceTree = "<group>"; };
DCC31547076253A4008F7A48 /* cCycleCheck.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cCycleCheck.cc; sourceTree = "<group>"; };
@@ -1393,6 +1404,8 @@
702D4F3908DA61E2007BA469 /* cBirthChamber.h */,
1097463D0AE9606E00929ED6 /* cDeme.cc */,
1097463E0AE9606E00929ED6 /* cDeme.h */,
+ B524E6510C8EFE19002AC57D /* cDemeCellEvent.h */,
+ B524E6670C8EFF1B002AC57D /* cDemeCellEvent.cc */,
702D4EFC08DA5341007BA469 /* cEnvironment.cc */,
702D4EF508DA5328007BA469 /* cEnvironment.h */,
70CA6EB208DB7F8200068AC2 /* cFitnessMatrix.cc */,
@@ -1860,6 +1873,7 @@
7023ECCC0C0A444200362B9C /* cViewInfo.cc in Sources */,
7023ECCD0C0A444600362B9C /* cZoomScreen.cc in Sources */,
7023ECCE0C0A444800362B9C /* viewer.cc in Sources */,
+ B524E66A0C8EFF1B002AC57D /* cDemeCellEvent.cc in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -2008,6 +2022,7 @@
7023ECDD0C0A44CE00362B9C /* cSymbolTable.cc in Sources */,
704368D60C31991500A05ABA /* ASTree.cc in Sources */,
70F9FC100C469DD70083B788 /* cASTDumpVisitor.cc in Sources */,
+ B524E6690C8EFF1B002AC57D /* cDemeCellEvent.cc in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -2016,6 +2031,7 @@
buildActionMask = 2147483647;
files = (
70DCAC9C097AF7C0002F8733 /* primitive.cc in Sources */,
+ B524E6680C8EFF1B002AC57D /* cDemeCellEvent.cc in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: branches/energy/CMakeLists.txt
===================================================================
--- branches/energy/CMakeLists.txt 2007-09-06 15:58:57 UTC (rev 2060)
+++ branches/energy/CMakeLists.txt 2007-09-06 18:48:28 UTC (rev 2061)
@@ -206,6 +206,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
Modified: branches/energy/source/actions/EnvironmentActions.cc
===================================================================
--- branches/energy/source/actions/EnvironmentActions.cc 2007-09-06 15:58:57 UTC (rev 2060)
+++ branches/energy/source/actions/EnvironmentActions.cc 2007-09-06 18:48:28 UTC (rev 2061)
@@ -455,8 +455,40 @@
}
};
+class cActionDelayedDemeEvent : public cAction
+{
+private:
+ int m_x1, m_y1, m_x2, m_y2; // bounding box of event in deme
+ int m_delay; // deme age when event occurs
+ int m_duration; // length of event; subverted when deme is reset
+
+public:
+ cActionDelayedDemeEvent(cWorld* world, const cString& args) : cAction(world, args), m_x1(-1), m_y1(-1), m_x2(-1), m_y2(-1), m_delay(-1), m_duration(-1)
+ {
+ cString largs(args);
+ if (largs.GetSize()) m_x1 = largs.PopWord().AsInt();
+ if (largs.GetSize()) m_y1 = largs.PopWord().AsInt();
+ if (largs.GetSize()) m_x2 = largs.PopWord().AsInt();
+ if (largs.GetSize()) m_y2 = largs.PopWord().AsInt();
+ if (largs.GetSize()) m_delay = largs.PopWord().AsInt();
+ if (largs.GetSize()) m_duration = largs.PopWord().AsInt();
+ }
+
+ static const cString GetDescription() { return "Arguments: <int x1> <int y1> <int x2> <int y2> <int delay> <int duraion>"; }
+
+ void Process(cAvidaContext& ctx)
+ {
+ cPopulation& pop = m_world->GetPopulation();
+ int numDemes = pop.GetNumDemes();
+ for(int i = 0; i < numDemes; i++) {
+ pop.GetDeme(i).SetCellEvent(m_x1, m_y1, m_x2, m_y2, m_delay, m_duration);
+ }
+ }
+};
+
void RegisterEnvironmentActions(cActionLibrary* action_lib)
{
+ action_lib->Register<cActionDelayedDemeEvent>("DelayedDemeEvent");
action_lib->Register<cActionInjectResource>("InjectResource");
action_lib->Register<cActionInjectScaledResource>("InjectScaledResource");
action_lib->Register<cActionOutflowScaledResource>("OutflowScaledResource");
Modified: branches/energy/source/actions/PopulationActions.cc
===================================================================
--- branches/energy/source/actions/PopulationActions.cc 2007-09-06 15:58:57 UTC (rev 2060)
+++ branches/energy/source/actions/PopulationActions.cc 2007-09-06 18:48:28 UTC (rev 2061)
@@ -990,6 +990,7 @@
'all' - ...all non-empty demes in the population.
'full_deme' - ...demes that have been filled up.
'corners' - ...demes with upper left and lower right corners filled.
+ 'deme-age' - ...demes that are a certain age
*/
class cActionReplicateDemes : public cAction
Modified: branches/energy/source/actions/PrintActions.cc
===================================================================
--- branches/energy/source/actions/PrintActions.cc 2007-09-06 15:58:57 UTC (rev 2060)
+++ branches/energy/source/actions/PrintActions.cc 2007-09-06 18:48:28 UTC (rev 2061)
@@ -2178,6 +2178,36 @@
}
};
+class cActionDumpCellDataGrid : public cAction
+{
+private:
+ cString m_filename;
+
+public:
+ cActionDumpCellDataGrid(cWorld* world, const cString& args) : cAction(world, args), m_filename("")
+ {
+ cString largs(args);
+ if (largs.GetSize()) m_filename = largs.PopWord();
+ }
+ static const cString GetDescription() { return "Arguments: [string fname='']"; }
+ void Process(cAvidaContext& ctx)
+ {
+ cString filename(m_filename);
+ if (filename == "") filename.Set("grid_cell_data.%d.dat", m_world->GetStats().GetUpdate());
+ ofstream& fp = m_world->GetDataFileOFStream(filename);
+
+ for (int i = 0; i < m_world->GetPopulation().GetWorldY(); i++) {
+ for (int j = 0; j < m_world->GetPopulation().GetWorldX(); j++) {
+ cPopulationCell& cell = m_world->GetPopulation().GetCell(i * m_world->GetPopulation().GetWorldX() + j);
+ double cell_data = cell.GetCellData();
+ fp << cell_data << " ";
+ }
+ fp << endl;
+ }
+ m_world->GetDataFileManager().Remove(filename);
+ }
+};
+
class cActionDumpFitnessGrid : public cAction
{
private:
@@ -2647,6 +2677,7 @@
action_lib->Register<cActionDumpReceiverGrid>("DumpReceiverGrid");
action_lib->Register<cActionDumpEnergyGrid>("DumpEnergyGrid");
action_lib->Register<cActionDumpExecutionRatioGrid>("DumpExecutionRatioGrid");
+ action_lib->Register<cActionDumpCellDataGrid>("DumpCellDataGrid");
action_lib->Register<cActionDumpSleepGrid>("DumpSleepGrid");
// Print Settings
Modified: branches/energy/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/energy/source/cpu/cHardwareCPU.cc 2007-09-06 15:58:57 UTC (rev 2060)
+++ branches/energy/source/cpu/cHardwareCPU.cc 2007-09-06 18:48:28 UTC (rev 2061)
@@ -203,7 +203,9 @@
tInstLibEntry<tMethod>("sense", &cHardwareCPU::Inst_SenseLog2), // If you add more sense instructions
tInstLibEntry<tMethod>("sense-unit", &cHardwareCPU::Inst_SenseUnit), // and want to keep stats, also add
tInstLibEntry<tMethod>("sense-m100", &cHardwareCPU::Inst_SenseMult100), // the names to cStats::cStats() @JEB
-
+ // Data collection
+ tInstLibEntry<tMethod>("collect-cell-data", &cHardwareCPU::Inst_CollectCellData),
+
tInstLibEntry<tMethod>("donate-rnd", &cHardwareCPU::Inst_DonateRandom),
tInstLibEntry<tMethod>("donate-kin", &cHardwareCPU::Inst_DonateKin),
tInstLibEntry<tMethod>("donate-edt", &cHardwareCPU::Inst_DonateEditDist),
@@ -221,7 +223,6 @@
tInstLibEntry<tMethod>("rotate-r", &cHardwareCPU::Inst_RotateR),
tInstLibEntry<tMethod>("rotate-left-one", &cHardwareCPU::Inst_RotateLeftOne),
tInstLibEntry<tMethod>("rotate-right-one", &cHardwareCPU::Inst_RotateRightOne),
-
tInstLibEntry<tMethod>("rotate-label", &cHardwareCPU::Inst_RotateLabel),
tInstLibEntry<tMethod>("set-cmut", &cHardwareCPU::Inst_SetCopyMut),
@@ -366,7 +367,7 @@
// Messaging
tInstLibEntry<tMethod>("send-msg", &cHardwareCPU::Inst_SendMessage),
tInstLibEntry<tMethod>("retrieve-msg", &cHardwareCPU::Inst_RetrieveMessage),
-
+
// Placebo instructions
tInstLibEntry<tMethod>("skip", &cHardwareCPU::Inst_Skip),
@@ -3079,6 +3080,13 @@
// Note that we are converting <double> resources to <int> register values
}
+bool cHardwareCPU::Inst_CollectCellData(cAvidaContext& ctx) {
+ int cellID = organism->GetCellID();
+ const int out_reg = FindModifiedRegister(REG_BX);
+ GetRegister(out_reg) = m_world->GetPopulation().GetCell(cellID).GetCellData();
+ return true;
+}
+
void cHardwareCPU::DoDonate(cOrganism* to_org)
{
assert(to_org != NULL);
@@ -4215,17 +4223,17 @@
bool cHardwareCPU::Inst_Sleep(cAvidaContext& ctx) {
cPopulation& pop = m_world->GetPopulation();
+ int cellID = organism->GetCellID();
if(m_world->GetConfig().LOG_SLEEP_TIMES.Get() == 1) {
- pop.AddEndSleep(organism->GetCellID(), m_world->GetStats().GetUpdate());
+ pop.AddEndSleep(cellID, m_world->GetStats().GetUpdate());
}
- int cellID = organism->GetCellID();
organism->SetSleeping(false); //this instruction get executed at the end of a sleep cycle
m_world->GetStats().decNumAsleep(pop.GetCell(cellID).GetDemeID());
if(m_world->GetConfig().APPLY_ENERGY_METHOD.Get() == 2) {
organism->GetPhenotype().RefreshEnergy();
organism->GetPhenotype().ApplyToEnergyStore();
double newMerit = cMerit::EnergyToMerit(organism->GetPhenotype().GetStoredEnergy() * organism->GetPhenotype().GetEnergyUsageRatio(), m_world);
- pop.UpdateMerit(organism->GetCellID(), newMerit);
+ pop.UpdateMerit(cellID, newMerit);
}
return true;
}
@@ -4237,7 +4245,7 @@
}
bool cHardwareCPU::Inst_GetCellPosition(cAvidaContext& ctx) {
- int absolute_cell_ID = organism->GetOrgInterface().GetCellID();
+ int absolute_cell_ID = organism->GetCellID();
int deme_id = organism->GetOrgInterface().GetDemeID();
std::pair<int, int> pos = m_world->GetPopulation().GetDeme(deme_id).GetCellPosition(absolute_cell_ID);
const int xreg = FindModifiedRegister(REG_BX);
@@ -4356,7 +4364,6 @@
return true;
}
-
//// Placebo insts ////
bool cHardwareCPU::Inst_Skip(cAvidaContext& ctx)
{
Modified: branches/energy/source/cpu/cHardwareCPU.h
===================================================================
--- branches/energy/source/cpu/cHardwareCPU.h 2007-09-06 15:58:57 UTC (rev 2060)
+++ branches/energy/source/cpu/cHardwareCPU.h 2007-09-06 18:48:28 UTC (rev 2061)
@@ -425,6 +425,7 @@
bool Inst_SenseUnit(cAvidaContext& ctx);
bool Inst_SenseMult100(cAvidaContext& ctx);
bool DoSense(cAvidaContext& ctx, int conversion_method, double base);
+ bool Inst_CollectCellData(cAvidaContext& ctx);
void DoDonate(cOrganism * to_org);
void DoEnergyDonate(cOrganism* to_org);
Modified: branches/energy/source/main/cDeme.cc
===================================================================
--- branches/energy/source/main/cDeme.cc 2007-09-06 15:58:57 UTC (rev 2060)
+++ branches/energy/source/main/cDeme.cc 2007-09-06 18:48:28 UTC (rev 2061)
@@ -22,15 +22,17 @@
*/
#include "cDeme.h"
+#include "cPopulation.h"
#include "cPopulationCell.h"
#include "cResource.h"
+#include "cWorld.h"
-
-void cDeme::Setup(const tArray<int> & in_cells, int in_width)
+void cDeme::Setup(const tArray<int> & in_cells, int in_width, cWorld* world)
{
cell_ids = in_cells;
birth_count = 0;
org_count = 0;
+ m_world = world;
// If width is negative, set it to the full number of cells.
width = in_width;
@@ -60,13 +62,36 @@
return std::make_pair(cellid % GetWidth(), cellid / GetWidth());
}
+void cDeme::ProcessUpdate() {
+ for(int i = 0; i < cell_events.GetSize(); i++) {
+ cDemeCellEvent& event = cell_events[i];
+ if(event.GetDelay() == _age) {
+ event.ActivateEvent(); //start event
+ int eventCell = event.GetNextEventCellID();
+ while(eventCell != -1) {
+ // place event ID in cells' data
+ m_world->GetPopulation().GetCell(GetCellID(eventCell)).SetCellData(event.GetEventID());
+ eventCell = event.GetNextEventCellID();
+ }
+ } else if(event.GetDelay()+event.DetDuration() == _age) {
+ int eventCell = event.GetNextEventCellID();
+ while(eventCell != -1) {
+ if(event.GetEventID() == m_world->GetPopulation().GetCell(GetCellID(eventCell)).GetCellData()) { // eventID == CellData
+ //set cell data to 0
+ m_world->GetPopulation().GetCell(GetCellID(eventCell)).SetCellData(0);
+ eventCell = event.GetNextEventCellID();
+ }
+ }
+ event.DeactivateEvent(); //event over
+ }
+ }
+ ++_age;
+}
void cDeme::Reset()
{
birth_count = 0;
- _age = 0;
- //clear cell energy
-
+ _age = 0;
deme_resource_count.ReinitializeResources();
}
@@ -141,3 +166,10 @@
}
deme_resource_count.ModifyCell(cell_resources, relative_cell_id);
}
+
+void cDeme::SetCellEvent(int x1, int y1, int x2, int y2, int delay, int duration) {
+ std::cerr<<"cDeme::SetCellEvent1 " <<cell_events.GetSize()<<std::endl;
+ cDemeCellEvent demeEvent = cDemeCellEvent(x1, y1, x2, y2, delay, duration, width, m_world);
+ cell_events.Push(demeEvent);
+ std::cerr<<"cDeme::SetCellEvent2 " <<cell_events.GetSize()<<std::endl;
+}
Modified: branches/energy/source/main/cDeme.h
===================================================================
--- branches/energy/source/main/cDeme.h 2007-09-06 15:58:57 UTC (rev 2060)
+++ branches/energy/source/main/cDeme.h 2007-09-06 18:48:28 UTC (rev 2061)
@@ -24,12 +24,14 @@
#ifndef cDeme_h
#define cDeme_h
+#include "cDemeCellEvent.h"
#include "cGermline.h"
#include "tArray.h"
#include "cResourceCount.h"
#include "cStringList.h"
class cResource;
+class cWorld;
/*! Demes are groups of cells in the population that are somehow bound together
as a unit. The deme object is used from within cPopulation to manage these
@@ -38,6 +40,7 @@
class cDeme
{
private:
+ cWorld* m_world;
tArray<int> cell_ids;
int width; //!< Width of this deme.
int birth_count; //!< Number of organisms that have been born into this deme since reset.
@@ -51,11 +54,13 @@
cResourceCount deme_resource_count; //!< Resources available to the deme
tArray<int> energy_res_ids; //!< IDs of energy resources
+ tArray<cDemeCellEvent> cell_events;
+
public:
cDeme() : width(0), birth_count(0), org_count(0), _age(0), deme_resource_count(0) { ; }
~cDeme() { ; }
- void Setup(const tArray<int>& in_cells, int in_width = -1);
+ void Setup(const tArray<int>& in_cells, int in_width = -1, cWorld* world = NULL);
int GetSize() const { return cell_ids.GetSize(); }
int GetCellID(int pos) const { return cell_ids[pos]; }
@@ -85,7 +90,7 @@
// -= Update support =-
//! Called once, at the end of every update.
- void ProcessUpdate() { ++_age; }
+ void ProcessUpdate();
/*! Returns the age of this deme, updates. Age is defined as the number of
updates since the last time Reset() was called. */
int GetAge() const { return _age; }
@@ -100,6 +105,8 @@
void UpdateDemeRes() { deme_resource_count.GetResources(); }
void Update(double time_step) { deme_resource_count.Update(time_step); }
int GetRelativeCellID(int absolute_cell_id) { return absolute_cell_id % GetSize(); } //!< assumes all demes are the same size
+
+ void SetCellEvent(int x1, int y1, int x2, int y2, int delay, int duration);
};
#endif
Modified: branches/energy/source/main/cPopulation.cc
===================================================================
--- branches/energy/source/main/cPopulation.cc 2007-09-06 15:58:57 UTC (rev 2060)
+++ branches/energy/source/main/cPopulation.cc 2007-09-06 18:48:28 UTC (rev 2061)
@@ -119,7 +119,6 @@
// Allocate the cells, resources, and market.
cell_array.ResizeClear(num_cells);
-// resource_count.ResizeSpatialGrids(world_x, world_y);
market.Resize(MARKET_SIZE);
// Setup the cells. Do things that are not dependent upon topology here.
@@ -145,7 +144,7 @@
deme_cells[offset] = cell_id;
cell_array[cell_id].SetDemeID(deme_id);
}
- deme_array[deme_id].Setup(deme_cells, deme_size_x);
+ deme_array[deme_id].Setup(deme_cells, deme_size_x, m_world);
}
// Setup the topology.
@@ -195,11 +194,7 @@
for(int i = 0; i < GetNumDemes(); i++) {
cResourceCount tmp_deme_res_count(num_deme_res);
GetDeme(i).SetDemeResourceCount(tmp_deme_res_count);
- //TODO: make sure grid is the right grid/size
- //GetDeme(i).GetDemeResourceCount().ResizeSpatialGrids(world_x, world_y);
-
GetDeme(i).ResizeSpatialGrids(deme_size_x, deme_size_y);
-// GetDeme(i).GetDemeResourceCount().
}
for (int i = 0; i < resource_lib.GetSize(); i++) {
@@ -1058,6 +1053,7 @@
0: 'all' - ...all non-empty demes in the population.
1: 'full_deme' - ...demes that have been filled up.
2: 'corners' - ...demes with upper left and lower right corners filled.
+3: 'deme-age' - ...demes who have reached their maximum age
*/
void cPopulation::ReplicateDemes(int rep_trigger)
Modified: branches/energy/source/main/cPopulationCell.cc
===================================================================
--- branches/energy/source/main/cPopulationCell.cc 2007-09-06 15:58:57 UTC (rev 2060)
+++ branches/energy/source/main/cPopulationCell.cc 2007-09-06 18:48:28 UTC (rev 2061)
@@ -44,6 +44,7 @@
, m_cell_id(in_cell.m_cell_id)
, m_deme_id(in_cell.m_deme_id)
, m_organism_count(in_cell.m_organism_count)
+ , m_cell_data(in_cell.m_cell_data)
{
// Copy the mutation rates into a new structure
m_mut_rates = new cMutationRates(*in_cell.m_mut_rates);
@@ -62,6 +63,7 @@
m_cell_id = in_cell.m_cell_id;
m_deme_id = in_cell.m_deme_id;
m_organism_count = in_cell.m_organism_count;
+ m_cell_data = in_cell.m_cell_data;
// Copy the mutation rates, constructing the structure as necessary
if (m_mut_rates == NULL)
@@ -82,6 +84,7 @@
m_x = x;
m_y = y;
m_deme_id = -1;
+ m_cell_data = 0;
if (m_mut_rates == NULL)
m_mut_rates = new cMutationRates(in_rates);
Modified: branches/energy/source/main/cPopulationCell.h
===================================================================
--- branches/energy/source/main/cPopulationCell.h 2007-09-06 15:58:57 UTC (rev 2060)
+++ branches/energy/source/main/cPopulationCell.h 2007-09-06 18:48:28 UTC (rev 2061)
@@ -57,6 +57,7 @@
int m_cell_id; // Unique id for position of cell in population.
int m_deme_id; // ID of the deme that this cell is part of.
int m_organism_count; // Total number of orgs to ever inhabit this cell.
+ int m_cell_data; // "data" that is local to the cell and can be retrieaved by the org.
// location in population
int m_x; //!< The x-coordinate of the position of this cell in the environment.
@@ -95,6 +96,8 @@
inline int GetID() const { return m_cell_id; }
inline int GetDemeID() const { return m_deme_id; }
inline int GetOrganismCount() const { return m_organism_count; }
+ inline int GetCellData() const { return m_cell_data; }
+ void SetCellData(const int data) { m_cell_data = data; }
inline bool IsOccupied() const { return m_organism != NULL; }
More information about the Avida-cvs
mailing list