[Avida-SVN] r2508 - in branches/jobScheduling: Avida.xcodeproj source/actions source/cpu source/main
beckma24 at myxo.css.msu.edu
beckma24 at myxo.css.msu.edu
Tue Apr 1 09:51:25 PDT 2008
Author: beckma24
Date: 2008-04-01 12:51:24 -0400 (Tue, 01 Apr 2008)
New Revision: 2508
Modified:
branches/jobScheduling/Avida.xcodeproj/project.pbxproj
branches/jobScheduling/source/actions/EnvironmentActions.cc
branches/jobScheduling/source/actions/PopulationActions.cc
branches/jobScheduling/source/cpu/cHardwareBase.h
branches/jobScheduling/source/cpu/cHardwareCPU.cc
branches/jobScheduling/source/cpu/cHardwareCPU.h
branches/jobScheduling/source/cpu/cHardwareGX.h
branches/jobScheduling/source/cpu/cTestCPUInterface.h
branches/jobScheduling/source/main/cAvidaConfig.h
branches/jobScheduling/source/main/cDeme.cc
branches/jobScheduling/source/main/cDeme.h
branches/jobScheduling/source/main/cDemeCellEvent.cc
branches/jobScheduling/source/main/cDemeCellEvent.h
branches/jobScheduling/source/main/cOrgInterface.h
branches/jobScheduling/source/main/cOrganism.cc
branches/jobScheduling/source/main/cOrganism.h
branches/jobScheduling/source/main/cPhenotype.h
branches/jobScheduling/source/main/cPopulation.cc
branches/jobScheduling/source/main/cPopulationInterface.cc
branches/jobScheduling/source/main/cPopulationInterface.h
branches/jobScheduling/source/main/cStats.h
Log:
Many addition to network security
Modified: branches/jobScheduling/Avida.xcodeproj/project.pbxproj
===================================================================
--- branches/jobScheduling/Avida.xcodeproj/project.pbxproj 2008-04-01 13:28:06 UTC (rev 2507)
+++ branches/jobScheduling/Avida.xcodeproj/project.pbxproj 2008-04-01 16:51:24 UTC (rev 2508)
@@ -220,6 +220,23 @@
};
/* End PBXBuildRule section */
+/* Begin PBXBuildStyle section */
+ B538C9640DA12D04008023D5 /* Development */ = {
+ isa = PBXBuildStyle;
+ buildSettings = {
+ COPY_PHASE_STRIP = NO;
+ };
+ name = Development;
+ };
+ B538C9650DA12D04008023D5 /* Deployment */ = {
+ isa = PBXBuildStyle;
+ buildSettings = {
+ COPY_PHASE_STRIP = YES;
+ };
+ name = Deployment;
+ };
+/* End PBXBuildStyle section */
+
/* Begin PBXContainerItemProxy section */
56F555DA0C3B36FC00E2E929 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
@@ -1817,12 +1834,16 @@
DCC30C4D0762532C008F7A48 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 702442D70859E0B00059BD9B /* Build configuration list for PBXProject "Avida" */;
- compatibilityVersion = "Xcode 2.4";
+ buildSettings = {
+ };
+ buildStyles = (
+ B538C9640DA12D04008023D5 /* Development */,
+ B538C9650DA12D04008023D5 /* Deployment */,
+ );
hasScannedForEncodings = 0;
mainGroup = DCC30C490762532C008F7A48;
productRefGroup = DCC3164E07626CF3008F7A48 /* Products */;
projectDirPath = "";
- projectRoot = "";
targets = (
7023ED520C0A590200362B9C /* full-suite */,
DCC3164C07626CF3008F7A48 /* avida */,
Modified: branches/jobScheduling/source/actions/EnvironmentActions.cc
===================================================================
--- branches/jobScheduling/source/actions/EnvironmentActions.cc 2008-04-01 13:28:06 UTC (rev 2507)
+++ branches/jobScheduling/source/actions/EnvironmentActions.cc 2008-04-01 16:51:24 UTC (rev 2508)
@@ -732,9 +732,11 @@
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
+ int m_total_events; // total number of unique event to create; they may overlab
+ bool m_static_position;
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)
+ 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), m_static_position(true), m_total_events(1)
{
cString largs(args);
if (largs.GetSize()) m_x1 = largs.PopWord().AsInt();
@@ -743,16 +745,18 @@
if (largs.GetSize()) m_y2 = largs.PopWord().AsInt();
if (largs.GetSize()) m_delay = largs.PopWord().AsInt();
if (largs.GetSize()) m_duration = largs.PopWord().AsInt();
+ if (largs.GetSize()) m_static_position = static_cast<bool>(largs.PopWord().AsInt());
+ if (largs.GetSize()) m_total_events = static_cast<bool>(largs.PopWord().AsInt());
}
- static const cString GetDescription() { return "Arguments: <int x1> <int y1> <int x2> <int y2> <int delay> <int duraion>"; }
+ static const cString GetDescription() { return "Arguments: <int x1> <int y1> <int x2> <int y2> <int delay> <int duraion> <bool static_position> <int total_events>"; }
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);
+ pop.GetDeme(i).SetCellEvent(m_x1, m_y1, m_x2, m_y2, m_delay, m_duration, m_static_position, m_total_events);
}
}
};
Modified: branches/jobScheduling/source/actions/PopulationActions.cc
===================================================================
--- branches/jobScheduling/source/actions/PopulationActions.cc 2008-04-01 13:28:06 UTC (rev 2507)
+++ branches/jobScheduling/source/actions/PopulationActions.cc 2008-04-01 16:51:24 UTC (rev 2508)
@@ -1076,6 +1076,7 @@
'corners' - ...demes with upper left and lower right corners filled.
'deme-age' - ...demes that are a certain age
'birth-count' ...demes that have had a certain number of births.
+ 'events-killed' ...demes that have killed a certian number of events
*/
class cActionReplicateDemes : public cAction
@@ -1094,6 +1095,7 @@
else if (in_trigger == "corners") m_rep_trigger = 2;
else if (in_trigger == "deme-age") m_rep_trigger = 3;
else if (in_trigger == "birth-count") m_rep_trigger = 4;
+ else if (in_trigger == "events-killed") m_rep_trigger = 5;
else {
cString err("Unknown replication trigger '");
err += in_trigger;
Modified: branches/jobScheduling/source/cpu/cHardwareBase.h
===================================================================
--- branches/jobScheduling/source/cpu/cHardwareBase.h 2008-04-01 13:28:06 UTC (rev 2507)
+++ branches/jobScheduling/source/cpu/cHardwareBase.h 2008-04-01 16:51:24 UTC (rev 2508)
@@ -190,6 +190,9 @@
// -------- State Transfer --------
virtual void InheritState(cHardwareBase& in_hardware){ ; }
+ //alarm
+ virtual bool Jump_To_Alarm_Label() { return false; }
+
protected:
// -------- No-Operation Instruction --------
bool Inst_Nop(cAvidaContext& ctx); // A no-operation instruction that does nothing!
Modified: branches/jobScheduling/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/jobScheduling/source/cpu/cHardwareCPU.cc 2008-04-01 13:28:06 UTC (rev 2507)
+++ branches/jobScheduling/source/cpu/cHardwareCPU.cc 2008-04-01 16:51:24 UTC (rev 2508)
@@ -211,6 +211,7 @@
tInstLibEntry<tMethod>("if-resources", &cHardwareCPU::Inst_IfResources, nInstFlag::STALL),
// Data collection
tInstLibEntry<tMethod>("collect-cell-data", &cHardwareCPU::Inst_CollectCellData, nInstFlag::STALL),
+ tInstLibEntry<tMethod>("collect-cell-data-and-kill-event", &cHardwareCPU::Inst_CollectCellDataAndKillEvent, nInstFlag::STALL),
tInstLibEntry<tMethod>("donate-rnd", &cHardwareCPU::Inst_DonateRandom, nInstFlag::STALL),
tInstLibEntry<tMethod>("donate-kin", &cHardwareCPU::Inst_DonateKin, nInstFlag::STALL),
@@ -391,6 +392,12 @@
tInstLibEntry<tMethod>("send-msg", &cHardwareCPU::Inst_SendMessage, nInstFlag::STALL),
tInstLibEntry<tMethod>("retrieve-msg", &cHardwareCPU::Inst_RetrieveMessage, nInstFlag::STALL),
+
+ // Alarms
+ tInstLibEntry<tMethod>("send-alarm-msg", &cHardwareCPU::Inst_Alarm_MSG, nInstFlag::STALL),
+ tInstLibEntry<tMethod>("alarm-label", &cHardwareCPU::Inst_Alarm_Label),
+
+
// Placebo instructions
tInstLibEntry<tMethod>("skip", &cHardwareCPU::Inst_Skip),
@@ -3169,12 +3176,20 @@
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();
+ GetRegister(out_reg) = organism->GetCellData();
return true;
}
+bool cHardwareCPU::Inst_CollectCellDataAndKillEvent(cAvidaContext& ctx) {
+ const int out_reg = FindModifiedRegister(REG_BX);
+ int eventID = organism->GetCellData();
+ GetRegister(out_reg) = eventID;
+
+ organism->GetOrgInterface().GetDeme()->KillCellEvent(eventID);
+ return true;
+}
+
void cHardwareCPU::DoDonate(cOrganism* to_org)
{
assert(to_org != NULL);
@@ -4769,7 +4784,34 @@
return true;
}
+bool cHardwareCPU::Inst_Alarm_MSG(cAvidaContext& ctx) {
+ return organism->BcastAlarmMSG(ctx);
+}
+bool cHardwareCPU::Inst_Alarm_Label(cAvidaContext& ctx) {
+ return true;
+}
+
+bool cHardwareCPU::Jump_To_Alarm_Label() {
+ static cInstruction label_inst = GetInstSet().GetInst(cStringUtil::Stringf("alarm-label"));
+
+ cHeadCPU search_head(IP());
+ int start_pos = search_head.GetPosition();
+ search_head++;
+
+ while (start_pos != search_head.GetPosition()) {
+ if (search_head.GetInst() == label_inst) {
+ // move IP to here
+ IP().Set(search_head.GetPosition());
+ m_advance_ip = false; // Don't automatically move the IP
+ return true;
+ }
+ search_head++;
+ }
+ return false;
+}
+
+
//// Placebo insts ////
bool cHardwareCPU::Inst_Skip(cAvidaContext& ctx)
{
Modified: branches/jobScheduling/source/cpu/cHardwareCPU.h
===================================================================
--- branches/jobScheduling/source/cpu/cHardwareCPU.h 2008-04-01 13:28:06 UTC (rev 2507)
+++ branches/jobScheduling/source/cpu/cHardwareCPU.h 2008-04-01 16:51:24 UTC (rev 2508)
@@ -458,6 +458,7 @@
//! Execute the following instruction if all resources are above their min level.
bool Inst_IfResources(cAvidaContext& ctx);
bool Inst_CollectCellData(cAvidaContext& ctx);
+ bool Inst_CollectCellDataAndKillEvent(cAvidaContext& ctx);
void DoDonate(cOrganism * to_org);
void DoEnergyDonate(cOrganism* to_org);
@@ -595,6 +596,12 @@
bool Inst_SendMessage(cAvidaContext& ctx);
bool Inst_RetrieveMessage(cAvidaContext& ctx);
+ //// Alarm ////
+ bool Inst_Alarm_MSG(cAvidaContext& ctx);
+ bool Inst_Alarm_Label(cAvidaContext& ctx);
+ bool Jump_To_Alarm_Label();
+
+
//// Placebo ////
bool Inst_Skip(cAvidaContext& ctx);
};
Modified: branches/jobScheduling/source/cpu/cHardwareGX.h
===================================================================
--- branches/jobScheduling/source/cpu/cHardwareGX.h 2008-04-01 13:28:06 UTC (rev 2507)
+++ branches/jobScheduling/source/cpu/cHardwareGX.h 2008-04-01 16:51:24 UTC (rev 2508)
@@ -370,6 +370,7 @@
// -------- Parasite Stuff --------
bool InjectHost(const cCodeLabel& in_label, const cGenome& injection);
+
// -------- Input/Output Buffers --------
virtual tBuffer<int>& GetInputBuf() { return m_current->GetInputBuf(); }
virtual tBuffer<int>& GetOutputBuf() { return m_current->GetOutputBuf(); }
Modified: branches/jobScheduling/source/cpu/cTestCPUInterface.h
===================================================================
--- branches/jobScheduling/source/cpu/cTestCPUInterface.h 2008-04-01 13:28:06 UTC (rev 2507)
+++ branches/jobScheduling/source/cpu/cTestCPUInterface.h 2008-04-01 16:51:24 UTC (rev 2508)
@@ -49,7 +49,11 @@
cDeme* GetDeme() { return 0; }
void SetCellID(int in_id) { ; }
void SetDemeID(int in_id) { ; }
+
+ int GetCellData() { return -1; }
+ void SetCellData(const int newData) { ; }
+
bool Divide(cAvidaContext& ctx, cOrganism* parent, cGenome& child_genome);
cOrganism* GetNeighbor();
int GetNumNeighbors();
@@ -77,6 +81,7 @@
int GetFacing() { return 0; }
bool SendMessage(cOrgMessage& msg) { return false; }
+ bool BcastAlarm() { return false; }
};
Modified: branches/jobScheduling/source/main/cAvidaConfig.h
===================================================================
--- branches/jobScheduling/source/main/cAvidaConfig.h 2008-04-01 13:28:06 UTC (rev 2507)
+++ branches/jobScheduling/source/main/cAvidaConfig.h 2008-04-01 16:51:24 UTC (rev 2508)
@@ -305,6 +305,7 @@
CONFIG_ADD_VAR(DEMES_ORGANISM_FACING, int, 0, "How organisms are facing during deme replication.\n0=unchanged (default).\n1=northwest.\n2=random.");
CONFIG_ADD_VAR(DEMES_MAX_AGE, int, 500, "The maximum age of a deme (in updates) to be\nused for age-based replication (default=500).");
CONFIG_ADD_VAR(DEMES_MAX_BIRTHS, int, 100, "The maximum number of births that can occur\nwithin a deme; used with birth-count\nreplication (default=100).");
+ CONFIG_ADD_VAR(DEMES_MAX_EVENTS_KILLED, int, 100, "The maximum number of event that must be killed\nwithin a deme; used with events-killed\nreplication (default=100).");
CONFIG_ADD_VAR(GERMLINE_COPY_MUT, double, 0.0075, "Prob. of copy mutations occuring during\ngermline replication (default=0.0075).");
CONFIG_ADD_VAR(GERMLINE_INS_MUT, double, 0.05, "Prob. of an insertion mutation occuring\nduring germline replication (default=0.05).");
CONFIG_ADD_VAR(GERMLINE_DEL_MUT, double, 0.05, "Prob. of a deletion mutation occuring\nduring germline replication (default=0.05).");
Modified: branches/jobScheduling/source/main/cDeme.cc
===================================================================
--- branches/jobScheduling/source/main/cDeme.cc 2008-04-01 13:28:06 UTC (rev 2507)
+++ branches/jobScheduling/source/main/cDeme.cc 2008-04-01 16:51:24 UTC (rev 2508)
@@ -79,7 +79,7 @@
for(int i = 0; i < cell_events.GetSize(); i++) {
cDemeCellEvent& event = cell_events[i];
if(event.GetDelay() == _age) {
- event.ActivateEvent(m_world); //start event
+ event.ActivateEvent(); //start event
int eventCell = event.GetNextEventCellID();
while(eventCell != -1) {
// place event ID in cells' data
@@ -90,8 +90,8 @@
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);
+ //set cell data to -1
+ m_world->GetPopulation().GetCell(GetCellID(eventCell)).SetCellData(-1);
eventCell = event.GetNextEventCellID();
}
}
@@ -130,7 +130,8 @@
time_used = 0;
birth_count = 0;
cur_normalized_time_used = 0;
-
+ eventsKilled = 0;
+
if(resetResources) deme_resource_count.ReinitializeResources();
}
@@ -248,11 +249,32 @@
deme_resource_count.ModifyCell(cell_resources, relative_cell_id);
}
-void cDeme::SetCellEvent(int x1, int y1, int x2, int y2, int delay, int duration) {
- cDemeCellEvent demeEvent = cDemeCellEvent(x1, y1, x2, y2, delay, duration, width);
- cell_events.Push(demeEvent);
+void cDeme::SetCellEvent(int x1, int y1, int x2, int y2, int delay, int duration, bool static_position, int total_events) {
+ for(int i = 0; i < total_events; i++) {
+ cDemeCellEvent demeEvent = cDemeCellEvent(x1, y1, x2, y2, delay, duration, width, GetHeight(), static_position, m_world);
+ cell_events.Push(demeEvent);
+ }
}
+void cDeme::KillCellEvent(const int eventID) {
+ for(int i = 0; i < cell_events.GetSize(); i++) {
+ cDemeCellEvent& event = cell_events[i];
+ if(event.GetEventID() == eventID) {
+ // remove event ID for all cells
+ int eventCell = event.GetNextEventCellID();
+ while(eventCell != -1) {
+ if(event.GetEventID() == m_world->GetPopulation().GetCell(GetCellID(eventCell)).GetCellData()) { // eventID == CellData
+ //set cell data to -1
+ m_world->GetPopulation().GetCell(GetCellID(eventCell)).SetCellData(-1);
+ eventCell = event.GetNextEventCellID();
+ }
+ }
+ event.DeactivateEvent(); //event over
+ eventsKilled++;
+ }
+ }
+}
+
double cDeme::CalculateTotalEnergy() {
assert(m_world->GetConfig().ENERGY_ENABLED.Get());
Modified: branches/jobScheduling/source/main/cDeme.h
===================================================================
--- branches/jobScheduling/source/main/cDeme.h 2008-04-01 13:28:06 UTC (rev 2507)
+++ branches/jobScheduling/source/main/cDeme.h 2008-04-01 16:51:24 UTC (rev 2508)
@@ -58,6 +58,7 @@
int gestation_time; // Time used during last generation
double cur_normalized_time_used; // normalized by merit and number of orgs
double last_normalized_time_used;
+ unsigned int eventsKilled;
// End of phenotypic traits
@@ -80,7 +81,7 @@
public:
cDeme() : _id(0), width(0), birth_count(0), org_count(0), _age(0), generation(0), total_org_energy(0.0),
time_used(0), gestation_time(0), cur_normalized_time_used(0.0), last_normalized_time_used(0.0),
- deme_resource_count(0), m_germline_genotype_id(0) { ; }
+ eventsKilled(0), deme_resource_count(0), m_germline_genotype_id(0) { ; }
~cDeme() { ; }
void Setup(int id, const tArray<int>& in_cells, int in_width = -1, cWorld* world = NULL);
@@ -110,6 +111,8 @@
int GetGeneration() const { return generation; }
+ int GetEventsKilled() const { return eventsKilled; }
+
bool IsEmpty() const { return org_count == 0; }
bool IsFull() const { return org_count == cell_ids.GetSize(); }
@@ -150,7 +153,8 @@
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);
+ void SetCellEvent(int x1, int y1, int x2, int y2, int delay, int duration, bool static_position, int total_events);
+ void KillCellEvent(const int eventID);
double CalculateTotalEnergy();
Modified: branches/jobScheduling/source/main/cDemeCellEvent.cc
===================================================================
--- branches/jobScheduling/source/main/cDemeCellEvent.cc 2008-04-01 13:28:06 UTC (rev 2507)
+++ branches/jobScheduling/source/main/cDemeCellEvent.cc 2008-04-01 16:51:24 UTC (rev 2508)
@@ -1,24 +1,37 @@
#include "cDemeCellEvent.h"
#include "cWorld.h"
-cDemeCellEvent::cDemeCellEvent(int x1, int y1, int x2, int y2, int delay, int duration, int width) :
+cDemeCellEvent::cDemeCellEvent(int x1, int y1, int x2, int y2, int delay, int duration, int deme_width, int deme_height, bool static_pos, cWorld* world) :
m_delay(delay)
, m_duration(duration)
, m_iter(0)
+ , m_deme_width(deme_width)
+ , m_deme_height(deme_height)
+ , m_event_width(x2-x1)
+ , m_event_height(y2-y1)
, m_active(false)
+ , m_static_pos(static_pos)
+ , m_world(world)
{
assert(x1 <= x2);
assert(y1 <= y2);
- assert(y1 < width && y2 < width);
- assert(delay >= 0);
+ assert(y1 < deme_width && y2 < deme_width);
+ assert(x1 < deme_height && x2 < deme_height);
+ assert(delay >= -1);
assert(duration >= 0);
m_event_cells.ResizeClear((x2-x1+1) * (y2-y1+1));
+ if(m_delay == -1) {
+ delay = m_world->GetRandom().GetInt(m_world->GetConfig().DEMES_MAX_AGE.Get() - m_duration);
+ }
+
int i = 0;
- for(int j = y1; j <= y2; j++) {
- for(int k = x1; k <= x2; k++) {
- m_event_cells[i] = j*width+k;
- i++;
+ if(m_static_pos) {
+ for(int j = y1; j <= y2; j++) {
+ for(int k = x1; k <= x2; k++) {
+ m_event_cells[i] = j*m_deme_width+k;
+ i++;
+ }
}
}
}
@@ -31,8 +44,21 @@
return -1;
}
-void cDemeCellEvent::ActivateEvent(cWorld* m_world) {
+void cDemeCellEvent::ActivateEvent() {
m_eventID = m_world->GetRandom().GetInt(0x7FFFFFFF);
+
+ if(!m_static_pos) {
+ //non-static event position
+ int rand_x1 = m_world->GetRandom().GetInt(m_deme_width-m_event_width);
+ int rand_y1 = m_world->GetRandom().GetInt(m_deme_height-m_event_height);
+ int i = 0;
+ for(int j = rand_y1; j <= rand_y1+m_event_height; j++) {
+ for(int k = rand_x1; k <= rand_x1+m_event_width; k++) {
+ m_event_cells[i] = j*m_deme_width+k;
+ i++;
+ }
+ }
+ }
m_active = true;
}
Modified: branches/jobScheduling/source/main/cDemeCellEvent.h
===================================================================
--- branches/jobScheduling/source/main/cDemeCellEvent.h 2008-04-01 13:28:06 UTC (rev 2507)
+++ branches/jobScheduling/source/main/cDemeCellEvent.h 2008-04-01 16:51:24 UTC (rev 2508)
@@ -7,18 +7,20 @@
class cDemeCellEvent {
private:
tArray<int> m_event_cells;
- int m_delay, m_duration, m_eventID, m_iter;
- bool m_active;
+ int m_delay, m_duration, m_eventID, m_iter, m_deme_width, m_deme_height;
+ int m_event_width, m_event_height;
+ bool m_active, m_static_pos;
+ cWorld* m_world;
public:
- cDemeCellEvent() { cDemeCellEvent(-1, -1, -1, -1, 0, 0, 0); }
- cDemeCellEvent(int x1, int y1, int x2, int y2, int delay, int duration, int width);
+ cDemeCellEvent() { cDemeCellEvent(-1, -1, -1, -1, 0, 0, 0, 0, true, NULL); }
+ cDemeCellEvent(int x1, int y1, int x2, int y2, int delay, int duration, int deme_width, int deme_height, bool static_pos, cWorld* world);
int GetNextEventCellID();
int GetDelay() { return m_delay; }
int GetDuration() { return m_duration; }
int GetEventID() { return m_eventID; }
- void ActivateEvent(cWorld* m_world);
+ void ActivateEvent();
void DeactivateEvent();
};
#endif
Modified: branches/jobScheduling/source/main/cOrgInterface.h
===================================================================
--- branches/jobScheduling/source/main/cOrgInterface.h 2008-04-01 13:28:06 UTC (rev 2507)
+++ branches/jobScheduling/source/main/cOrgInterface.h 2008-04-01 16:51:24 UTC (rev 2508)
@@ -59,6 +59,9 @@
virtual cDeme* GetDeme() = 0;
virtual void SetCellID(int in_id) = 0;
virtual void SetDemeID(int in_id) = 0;
+
+ virtual int GetCellData() = 0;
+ virtual void SetCellData(const int newData) = 0;
virtual bool Divide(cAvidaContext& ctx, cOrganism* parent, cGenome& child_genome) = 0;
virtual cOrganism* GetNeighbor() = 0;
@@ -86,6 +89,8 @@
virtual bool UpdateMerit(double new_merit) = 0;
virtual bool TestOnDivide() = 0;
virtual bool SendMessage(cOrgMessage& msg) = 0;
+
+ virtual bool BcastAlarm() = 0;
};
Modified: branches/jobScheduling/source/main/cOrganism.cc
===================================================================
--- branches/jobScheduling/source/main/cOrganism.cc 2008-04-01 13:28:06 UTC (rev 2507)
+++ branches/jobScheduling/source/main/cOrganism.cc 2008-04-01 16:51:24 UTC (rev 2508)
@@ -666,3 +666,21 @@
return 0;
}
+
+
+bool cOrganism::BcastAlarmMSG(cAvidaContext& ctx) {
+ assert(m_interface);
+
+ // If we're able to succesfully send an alarm...
+ if(m_interface->BcastAlarm()) {
+ // check to see if we've performed any tasks...
+ DoOutput(ctx);
+ return true;
+ }
+ return false;
+}
+
+void cOrganism::moveIPtoAlarmLabel() {
+ // move IP to alarm_label
+ m_hardware->Jump_To_Alarm_Label();
+}
Modified: branches/jobScheduling/source/main/cOrganism.h
===================================================================
--- branches/jobScheduling/source/main/cOrganism.h 2008-04-01 13:28:06 UTC (rev 2507)
+++ branches/jobScheduling/source/main/cOrganism.h 2008-04-01 16:51:24 UTC (rev 2508)
@@ -27,6 +27,7 @@
#define cOrganism_h
#include <iostream>
+#include <string>
#include <vector>
#ifndef cCPUMemory_h
@@ -210,7 +211,8 @@
tListNode<tListNode<cSaleItem> >* AddSoldItem(tListNode<cSaleItem>* node) { return m_sold_items.PushRear(node); }
tList<tListNode<cSaleItem> >* GetSoldItems() { return &m_sold_items; }
void UpdateMerit(double new_merit) { m_interface->UpdateMerit(new_merit); }
-
+ int GetCellData() { return m_interface->GetCellData(); }
+ void SetCellData(const int data) { m_interface->SetCellData(data); }
// -------- Input and Output Methods --------
void DoInput(const int value);
@@ -347,6 +349,15 @@
//! Called to check for (and initialize) messaging support within this organism.
inline void InitMessaging() { if(!m_msg) m_msg = new cMessagingSupport(); }
// -------- End of messaging support --------
+
+
+
+
+ /***** context switch********/
+public:
+ bool BcastAlarmMSG(cAvidaContext& ctx);
+ void moveIPtoAlarmLabel();
+
};
Modified: branches/jobScheduling/source/main/cPhenotype.h
===================================================================
--- branches/jobScheduling/source/main/cPhenotype.h 2008-04-01 13:28:06 UTC (rev 2507)
+++ branches/jobScheduling/source/main/cPhenotype.h 2008-04-01 16:51:24 UTC (rev 2508)
@@ -94,7 +94,6 @@
cMerit merit; // Relative speed of CPU
double executionRatio; // ratio of current execution merit over base execution merit
double energy_store; // Amount of energy. Determines relative speed of CPU when turned on.
- double energy_tobe_applied; //Energy that has not yet been added to energy store.
int genome_length; // Number of instructions in genome.
int bonus_instruction_count; // Number of times MERIT_BONUS_INT is in genome.
int copied_size; // Instructions copied into genome.
@@ -108,6 +107,7 @@
// 2. These are "in progress" variables, updated as the organism operates
double cur_bonus; // Current Bonus
double cur_energy_bonus; // Current energy bonus
+ double energy_tobe_applied; // Energy that has not yet been added to energy store.
int cur_num_errors; // Total instructions executed illeagally.
int cur_num_donates; // Number of donations so far
tArray<int> cur_task_count; // Total times each task was performed
Modified: branches/jobScheduling/source/main/cPopulation.cc
===================================================================
--- branches/jobScheduling/source/main/cPopulation.cc 2008-04-01 13:28:06 UTC (rev 2507)
+++ branches/jobScheduling/source/main/cPopulation.cc 2008-04-01 16:51:24 UTC (rev 2508)
@@ -874,7 +874,7 @@
4: deme fitness = strong rank selection on (parents) fitness (2^-deme fitness rank)
5: deme fitness = average organism life (current, not parents) fitness (works with donations)
6: deme fitness = strong rank selection on life (current, not parents) fitness
- */
+*/
// For ease of use, each organism
// is setup as if it we just injected into the population.
@@ -1059,6 +1059,11 @@
cDeme & from_deme = deme_array[from_deme_id];
cDeme & to_deme = deme_array[to_deme_id];
+
+/// ReplaceDeme(cDeme& source_deme, cDeme& target_deme)
+
+
+
// Do the actual copy!
for (int i = 0; i < from_deme.GetSize(); i++) {
int from_cell_id = from_deme.GetCellID(i);
@@ -1097,6 +1102,7 @@
2: 'corners' - ...demes with upper left and lower right corners filled.
3: 'deme-age' - ...demes who have reached their maximum age
4: 'birth-count' ...demes that have had a certain number of births.
+5: 'events-killed' ...demes that have killed a certian number of events
*/
@@ -1141,6 +1147,11 @@
if(source_deme.GetBirthCount() < m_world->GetConfig().DEMES_MAX_BIRTHS.Get()) continue;
break;
}
+ case 5: {
+ // Replicate demes that have killed a certain number of event.
+ if(source_deme.GetEventsKilled() < m_world->GetConfig().DEMES_MAX_EVENTS_KILLED.Get()) continue;
+ break;
+ }
default: {
cerr << "ERROR: Invalid replication trigger " << rep_trigger
<< " in cPopulation::ReplicateDemes()" << endl;
@@ -2823,6 +2834,7 @@
stats.SumDemeGestationTime().Clear();
stats.SumDemeNormalizedTimeUsed().Clear();
stats.SumDemeMerit().Clear();
+ stats.SumDemeEventsKilled().Clear();
for(int i = 0; i < GetNumDemes(); i++) {
cDeme& deme = GetDeme(i);
@@ -2836,6 +2848,7 @@
stats.SumDemeGestationTime().Add(deme.GetGestationTime());
stats.SumDemeNormalizedTimeUsed().Add(deme.GetLastNormalizedTimeUsed());
stats.SumDemeMerit().Add(deme.GetDemeMerit().GetDouble());
+ stats.SumDemeEventsKilled().Add(deme.GetEventsKilled());
}
}
Modified: branches/jobScheduling/source/main/cPopulationInterface.cc
===================================================================
--- branches/jobScheduling/source/main/cPopulationInterface.cc 2008-04-01 13:28:06 UTC (rev 2507)
+++ branches/jobScheduling/source/main/cPopulationInterface.cc 2008-04-01 16:51:24 UTC (rev 2508)
@@ -46,7 +46,14 @@
return &m_world->GetPopulation().GetDeme(m_deme_id);
}
+int cPopulationInterface::GetCellData() {
+ return m_world->GetPopulation().GetCell(m_cell_id).GetCellData();
+}
+void cPopulationInterface::SetCellData(const int newData) {
+ m_world->GetPopulation().GetCell(m_cell_id).SetCellData(newData);
+}
+
bool cPopulationInterface::Divide(cAvidaContext& ctx, cOrganism* parent, cGenome& child_genome)
{
assert(parent != NULL);
@@ -258,3 +265,21 @@
return true;
}
+
+bool cPopulationInterface::BcastAlarm() {
+ cPopulationCell& cell = m_world->GetPopulation().GetCell(m_cell_id);
+ assert(cell.IsOccupied()); // This organism; sanity.
+
+ for(int i = 0; i < cell.ConnectionList().GetSize(); i++) {
+ cPopulationCell* rcell = cell.ConnectionList().GetPos(i);
+ assert(rcell != NULL); // Cells should never be null.
+
+ // Fail if the cell we're facing is not occupied.
+ if(!rcell->IsOccupied())
+ continue;
+ cOrganism* recvr = rcell->GetOrganism();
+ assert(recvr != NULL);
+ recvr->moveIPtoAlarmLabel();
+ }
+ return true;
+}
Modified: branches/jobScheduling/source/main/cPopulationInterface.h
===================================================================
--- branches/jobScheduling/source/main/cPopulationInterface.h 2008-04-01 13:28:06 UTC (rev 2507)
+++ branches/jobScheduling/source/main/cPopulationInterface.h 2008-04-01 16:51:24 UTC (rev 2508)
@@ -61,6 +61,9 @@
cDeme* GetDeme();
void SetCellID(int in_id) { m_cell_id = in_id; }
void SetDemeID(int in_id) { m_deme_id = in_id; }
+
+ int GetCellData();
+ void SetCellData(const int newData);
bool Divide(cAvidaContext& ctx, cOrganism* parent, cGenome& child_genome);
cOrganism* GetNeighbor();
@@ -89,7 +92,7 @@
bool TestOnDivide();
//! Send a message to the faced organism.
bool SendMessage(cOrgMessage& msg);
-
+ bool BcastAlarm();
};
Modified: branches/jobScheduling/source/main/cStats.h
===================================================================
--- branches/jobScheduling/source/main/cStats.h 2008-04-01 13:28:06 UTC (rev 2507)
+++ branches/jobScheduling/source/main/cStats.h 2008-04-01 16:51:24 UTC (rev 2508)
@@ -274,6 +274,7 @@
cIntSum sum_deme_gestation_time;
cDoubleSum sum_deme_normalized_time_used;
cDoubleSum sum_deme_merit;
+ cIntSum sum_deme_events_killed;
// Speculative Execution Stats
int m_spec_total;
@@ -418,6 +419,7 @@
cIntSum& SumDemeGestationTime() { return sum_deme_gestation_time; }
cDoubleSum& SumDemeNormalizedTimeUsed() { return sum_deme_normalized_time_used; }
cDoubleSum& SumDemeMerit() { return sum_deme_merit; }
+ cIntSum& SumDemeEventsKilled() { return sum_deme_events_killed; }
#if INSTRUCTION_COUNT
void ZeroInst();
@@ -458,6 +460,7 @@
const cIntSum& SumDemeGestationTime() const { return sum_deme_generation; }
const cDoubleSum& SumDemeNormalizedTimeUsed() const { return sum_deme_normalized_time_used; }
const cDoubleSum& SumDemeMerit() const { return sum_deme_merit; }
+ const cIntSum& SumDemeEventsKilled() const { return sum_deme_events_killed; }
void IncResamplings() { ++num_resamplings; } // @AWC 06/29/06
More information about the Avida-cvs
mailing list