[Avida-SVN] r2131 - in branches/energy/source: cpu drivers main
beckma24 at myxo.css.msu.edu
beckma24 at myxo.css.msu.edu
Mon Oct 8 13:36:51 PDT 2007
Author: beckma24
Date: 2007-10-08 16:36:51 -0400 (Mon, 08 Oct 2007)
New Revision: 2131
Modified:
branches/energy/source/cpu/cHardwareCPU.cc
branches/energy/source/drivers/cDefaultRunDriver.cc
branches/energy/source/main/cDeme.cc
branches/energy/source/main/cDeme.h
branches/energy/source/main/cPopulationCell.cc
branches/energy/source/main/cPopulationCell.h
branches/energy/source/main/cStats.cc
branches/energy/source/main/cStats.h
Log:
Reimplemented cell blocking when message is sent... now more realistic
Modified: branches/energy/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/energy/source/cpu/cHardwareCPU.cc 2007-10-08 19:24:17 UTC (rev 2130)
+++ branches/energy/source/cpu/cHardwareCPU.cc 2007-10-08 20:36:51 UTC (rev 2131)
@@ -4533,10 +4533,11 @@
if(!sending_cell.SendingIsBlocked() && !sending_cell.SendingIsPaused()) {
// block neighbors in connection list and track
int oldFacing = sending_cell.GetFacing();
+ int currentUpdate = m_world->GetStats().GetUpdate();
+ int currentSubupdate = m_world->GetStats().GetSubUpdate();
for(int i = 0; i < organism->GetNeighborhoodSize(); i++) {
cPopulationCell* neighbor = sending_cell.ConnectionList().GetPos(i);
- neighbor->BlockSending();
- pop.GetDeme(sending_cell.GetDemeID()).InsertInBlockedList(neighbor->GetID(), neighbor);
+ neighbor->BlockSending(currentUpdate+1, currentSubupdate);
}
int newFacing = sending_cell.GetFacing();
assert(oldFacing == newFacing);
@@ -4545,8 +4546,7 @@
Inst_SendMessage(ctx);
// pause self
- sending_cell.PauseSending();
- pop.GetDeme(sending_cell.GetDemeID()).InsertInPausedList(cell_id, &sending_cell);
+ sending_cell.PauseSending(currentUpdate+1, currentSubupdate);
return true;
}
return false;
@@ -4572,6 +4572,12 @@
return true;
}
+/*
+bool cHardwareCPU::Inst_carrer_sense(cAvidaContext& ctx) {
+ //better name
+}
+*/
+
//// Placebo insts ////
bool cHardwareCPU::Inst_Skip(cAvidaContext& ctx)
{
Modified: branches/energy/source/drivers/cDefaultRunDriver.cc
===================================================================
--- branches/energy/source/drivers/cDefaultRunDriver.cc 2007-10-08 19:24:17 UTC (rev 2130)
+++ branches/energy/source/drivers/cDefaultRunDriver.cc 2007-10-08 20:36:51 UTC (rev 2131)
@@ -75,12 +75,7 @@
m_world->GetEvents(ctx);
if (m_done == true) break;
-
- // Clear deme TDMA
- for(int i=0; i<population.GetNumDemes(); ++i) {
- population.GetDeme(i).SetupUpdate();
- }
-
+
// Increment the Update.
stats.IncCurrentUpdate();
@@ -108,6 +103,7 @@
break;
}
population.ProcessStep(ctx, step_size);
+ stats.IncSubUpdate();
}
// end of update stats...
Modified: branches/energy/source/main/cDeme.cc
===================================================================
--- branches/energy/source/main/cDeme.cc 2007-10-08 19:24:17 UTC (rev 2130)
+++ branches/energy/source/main/cDeme.cc 2007-10-08 20:36:51 UTC (rev 2131)
@@ -126,20 +126,6 @@
}
}
-void cDeme::SetupUpdate() {
- //remove sending block from all blocked cells in deme
- for(map<int, cPopulationCell*>::iterator iter = cells_blocked_from_sending.begin(); iter != cells_blocked_from_sending.end(); iter++) {
- (*iter).second->UnblockSending();
- }
- cells_blocked_from_sending.clear();
-
- //remove sending pause from all paused cells in deme
- for(map<int, cPopulationCell*>::iterator iter = cells_paused_from_sending.begin(); iter != cells_paused_from_sending.end(); iter++) {
- (*iter).second->UnpauseSending();
- }
- cells_paused_from_sending.clear();
-}
-
/*! Replacing this deme's germline has the effect of changing the deme's lineage.
There's still some work to do here; the lineage labels of the Genomes in the germline
are all messed up.
@@ -267,12 +253,3 @@
void cDeme::PrintPredicate(int pred_id, std::ostream& out) {
message_pred_list[pred_id]->Print(out);
}
-
-
-void cDeme::InsertInBlockedList(int cell_id, cPopulationCell* cell) {
- cells_blocked_from_sending[cell_id] = cell;
-}
-
-void cDeme::InsertInPausedList(int cell_id, cPopulationCell* cell) {
- cells_paused_from_sending[cell_id] = cell;
-}
Modified: branches/energy/source/main/cDeme.h
===================================================================
--- branches/energy/source/main/cDeme.h 2007-10-08 19:24:17 UTC (rev 2130)
+++ branches/energy/source/main/cDeme.h 2007-10-08 20:36:51 UTC (rev 2131)
@@ -101,8 +101,6 @@
// -= Update support =-
//! Called once, at the end of every update.
void ProcessUpdate();
- //! Called once, at the begining of every update.
- void SetupUpdate();
/*! 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; }
@@ -126,9 +124,6 @@
bool PredicatePreviouslySatisfied(int pred_id);
cString GetPredicateName(int pred_id);
void PrintPredicate(int pred_id, std::ostream& out);
-
- void InsertInBlockedList(int cell_id, cPopulationCell* cell);
- void InsertInPausedList(int cell_id, cPopulationCell* cell);
};
#endif
Modified: branches/energy/source/main/cPopulationCell.cc
===================================================================
--- branches/energy/source/main/cPopulationCell.cc 2007-10-08 19:24:17 UTC (rev 2130)
+++ branches/energy/source/main/cPopulationCell.cc 2007-10-08 20:36:51 UTC (rev 2131)
@@ -46,8 +46,8 @@
, m_deme_id(in_cell.m_deme_id)
, m_organism_count(in_cell.m_organism_count)
, m_cell_data(in_cell.m_cell_data)
- , m_blocked_from_sending(in_cell.m_blocked_from_sending)
- , m_sending_paused(in_cell.m_sending_paused)
+ , m_blocked_from_sending_until(in_cell.m_blocked_from_sending_until)
+ , m_sending_paused_until(in_cell.m_sending_paused_until)
{
// Copy the mutation rates into a new structure
m_mut_rates = new cMutationRates(*in_cell.m_mut_rates);
@@ -68,8 +68,8 @@
m_deme_id = in_cell.m_deme_id;
m_organism_count = in_cell.m_organism_count;
m_cell_data = in_cell.m_cell_data;
- m_blocked_from_sending = in_cell.m_blocked_from_sending;
- m_sending_paused = in_cell.m_sending_paused;
+ m_blocked_from_sending_until = in_cell.m_blocked_from_sending_until;
+ m_sending_paused_until = in_cell.m_sending_paused_until;
// Copy the mutation rates, constructing the structure as necessary
if (m_mut_rates == NULL)
@@ -217,7 +217,22 @@
return uptakeAmount;
}
+void cPopulationCell::BlockSending(int update, int subupdate) {
+ m_blocked_from_sending_until = make_pair(update, subupdate);
+}
+bool cPopulationCell::SendingIsBlocked() {
+ return m_world->GetStats().TimeHasPassed(m_blocked_from_sending_until.first, m_blocked_from_sending_until.second);
+}
+
+void cPopulationCell::PauseSending(int update, int subupdate) {
+ m_sending_paused_until = make_pair(update, subupdate);
+}
+
+bool cPopulationCell::SendingIsPaused() {
+ return m_world->GetStats().TimeHasPassed(m_sending_paused_until.first, m_sending_paused_until.second);
+}
+
bool cPopulationCell::OK()
{
// Nothing for the moment...
Modified: branches/energy/source/main/cPopulationCell.h
===================================================================
--- branches/energy/source/main/cPopulationCell.h 2007-10-08 19:24:17 UTC (rev 2130)
+++ branches/energy/source/main/cPopulationCell.h 2007-10-08 20:36:51 UTC (rev 2131)
@@ -65,16 +65,19 @@
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.
- bool m_blocked_from_sending;
- bool m_sending_paused;
+ std::pair<int, int> m_blocked_from_sending_until; // <update, subupdate>
+ std::pair<int, int> m_sending_paused_until; // <update, subupdate>
void InsertOrganism(cOrganism* new_org);
cOrganism* RemoveOrganism();
-
public:
cPopulationCell() : m_world(NULL), m_organism(NULL), m_hardware(NULL), m_mut_rates(NULL),
- m_organism_count(0), m_blocked_from_sending(false), m_sending_paused(false) { ; }
+ m_organism_count(0) {
+ m_blocked_from_sending_until = std::make_pair(0,0);
+ m_sending_paused_until = std::make_pair(0,0);
+ }
+
cPopulationCell(const cPopulationCell& in_cell);
~cPopulationCell() { delete m_mut_rates; }
@@ -109,14 +112,12 @@
double UptakeCellEnergy(double frac_to_uptake);
- inline void BlockSending() { if(!m_sending_paused) m_blocked_from_sending = true; }
- inline void UnblockSending() { m_blocked_from_sending = false; }
- inline bool SendingIsBlocked() { return m_blocked_from_sending; }
+ void BlockSending(int update, int subupdate);
+ bool SendingIsBlocked();
+
+ void PauseSending(int update, int subupdate);
+ bool SendingIsPaused();
- inline void PauseSending() { m_sending_paused = true; }
- inline void UnpauseSending() { m_sending_paused = false; }
- inline bool SendingIsPaused() { return m_sending_paused; }
-
bool OK();
};
Modified: branches/energy/source/main/cStats.cc
===================================================================
--- branches/energy/source/main/cStats.cc 2007-10-08 19:24:17 UTC (rev 2130)
+++ branches/energy/source/main/cStats.cc 2007-10-08 20:36:51 UTC (rev 2131)
@@ -1197,4 +1197,12 @@
relative_pos_event_count.SetAll(0);
}
+bool cStats::TimeHasPassed(int in_update, int in_subupdate) {
+ int currentUpdate = m_world->GetStats().GetUpdate();
+ int currentSubupdate = m_world->GetStats().GetSubUpdate();
+ if(in_update < currentUpdate || (in_update == currentUpdate && in_subupdate < currentSubupdate))
+ return true;
+ return false;
+}
+
Modified: branches/energy/source/main/cStats.h
===================================================================
--- branches/energy/source/main/cStats.h 2007-10-08 19:24:17 UTC (rev 2130)
+++ branches/energy/source/main/cStats.h 2007-10-08 20:36:51 UTC (rev 2131)
@@ -293,6 +293,7 @@
// Accessors...
int GetUpdate() const { return m_update; }
int GetSubUpdate() const { return sub_update; }
+ bool TimeHasPassed(int in_update, int in_subupdate);
double GetGeneration() const { return SumGeneration().Average(); }
cGenotype* GetDomGenotype() const { return dom_genotype; }
More information about the Avida-cvs
mailing list