[Avida-SVN] r2555 - in branches/jobScheduling/source: cpu main

beckma24 at myxo.css.msu.edu beckma24 at myxo.css.msu.edu
Sun Apr 27 10:13:07 PDT 2008


Author: beckma24
Date: 2008-04-27 13:13:06 -0400 (Sun, 27 Apr 2008)
New Revision: 2555

Modified:
   branches/jobScheduling/source/cpu/cHardwareCPU.cc
   branches/jobScheduling/source/cpu/cHardwareCPU.h
   branches/jobScheduling/source/cpu/cTestCPUInterface.h
   branches/jobScheduling/source/main/cAvidaConfig.h
   branches/jobScheduling/source/main/cDeme.cc
   branches/jobScheduling/source/main/cOrgInterface.h
   branches/jobScheduling/source/main/cOrganism.cc
   branches/jobScheduling/source/main/cOrganism.h
   branches/jobScheduling/source/main/cPopulationInterface.cc
   branches/jobScheduling/source/main/cPopulationInterface.h
Log:
Added local and multi-hop alarm instruction and ATTACK_DECAY_RATE

Modified: branches/jobScheduling/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/jobScheduling/source/cpu/cHardwareCPU.cc	2008-04-25 23:40:34 UTC (rev 2554)
+++ branches/jobScheduling/source/cpu/cHardwareCPU.cc	2008-04-27 17:13:06 UTC (rev 2555)
@@ -408,8 +408,10 @@
     tInstLibEntry<tMethod>("retrieve-msg", &cHardwareCPU::Inst_RetrieveMessage, nInstFlag::STALL),
 
     // Alarms
-    tInstLibEntry<tMethod>("send-alarm-msg", &cHardwareCPU::Inst_Alarm_MSG, nInstFlag::STALL),
-    tInstLibEntry<tMethod>("send-alarm-msg-bit-cons24", &cHardwareCPU::Inst_Alarm_MSG_Bit_Cons24, nInstFlag::STALL),
+    tInstLibEntry<tMethod>("send-alarm-msg-local", &cHardwareCPU::Inst_Alarm_MSG_local, nInstFlag::STALL),
+    tInstLibEntry<tMethod>("send-alarm-msg-multihop", &cHardwareCPU::Inst_Alarm_MSG_multihop, nInstFlag::STALL),
+    tInstLibEntry<tMethod>("send-alarm-msg-bit-cons24-local", &cHardwareCPU::Inst_Alarm_MSG_Bit_Cons24_local, nInstFlag::STALL),
+    tInstLibEntry<tMethod>("send-alarm-msg-bit-cons24-multihop", &cHardwareCPU::Inst_Alarm_MSG_Bit_Cons24_multihop, nInstFlag::STALL),
     tInstLibEntry<tMethod>("alarm-label-high", &cHardwareCPU::Inst_Alarm_Label),
     tInstLibEntry<tMethod>("alarm-label-low", &cHardwareCPU::Inst_Alarm_Label),
 
@@ -4968,19 +4970,27 @@
   return true;
 }
 
-bool cHardwareCPU::Inst_Alarm_MSG(cAvidaContext& ctx) {
+bool cHardwareCPU::Inst_Alarm_MSG_multihop(cAvidaContext& ctx) {
   const int reg_used = FindModifiedRegister(REG_BX);  
-  return organism->BcastAlarmMSG(ctx, abs(GetRegister(reg_used)%2)); // jump to Alarm-label-  odd=high  even=low
+  return organism->BcastAlarmMSG(ctx, abs(GetRegister(reg_used)%2), m_world->GetConfig().BCAST_HOPS.Get()); // jump to Alarm-label-  odd=high  even=low
 }
 
-bool cHardwareCPU::Inst_Alarm_MSG_Bit_Cons24(cAvidaContext& ctx) {
+bool cHardwareCPU::Inst_Alarm_MSG_Bit_Cons24_multihop(cAvidaContext& ctx) {
   const int reg_used = FindModifiedRegister(REG_BX);
-  const int op1 = FindModifiedNextRegister(reg_used);
-  GetRegister(reg_used) = (BitCount(GetRegister(op1) & MASK24) >= CONSENSUS24) ? 1 : 0;
+  return organism->BcastAlarmMSG(ctx, (BitCount(GetRegister(reg_used) & MASK24) >= CONSENSUS24) ? 1 : 0, m_world->GetConfig().BCAST_HOPS.Get());// jump to Alarm-label-high OR Alarm-label-low
+}
 
-  return organism->BcastAlarmMSG(ctx, GetRegister(reg_used));// jump to Alarm-label-high OR Alarm-label-low
+bool cHardwareCPU::Inst_Alarm_MSG_local(cAvidaContext& ctx) {
+  const int reg_used = FindModifiedRegister(REG_BX);  
+  return organism->BcastAlarmMSG(ctx, abs(GetRegister(reg_used)%2), 1); // jump to Alarm-label-  odd=high  even=low
 }
 
+bool cHardwareCPU::Inst_Alarm_MSG_Bit_Cons24_local(cAvidaContext& ctx) {
+  const int reg_used = FindModifiedRegister(REG_BX);
+  return organism->BcastAlarmMSG(ctx, (BitCount(GetRegister(reg_used) & MASK24) >= CONSENSUS24) ? 1 : 0, 1);// jump to Alarm-label-high OR Alarm-label-low
+}
+
+
 bool cHardwareCPU::Inst_Alarm_Label(cAvidaContext& ctx) {
   return true;
 }

Modified: branches/jobScheduling/source/cpu/cHardwareCPU.h
===================================================================
--- branches/jobScheduling/source/cpu/cHardwareCPU.h	2008-04-25 23:40:34 UTC (rev 2554)
+++ branches/jobScheduling/source/cpu/cHardwareCPU.h	2008-04-27 17:13:06 UTC (rev 2555)
@@ -608,8 +608,10 @@
   bool Inst_RetrieveMessage(cAvidaContext& ctx);
   
   //// Alarm ////
-  bool Inst_Alarm_MSG(cAvidaContext& ctx);
-  bool Inst_Alarm_MSG_Bit_Cons24(cAvidaContext& ctx);
+  bool Inst_Alarm_MSG_local(cAvidaContext& ctx);
+  bool Inst_Alarm_MSG_multihop(cAvidaContext& ctx);
+  bool Inst_Alarm_MSG_Bit_Cons24_local(cAvidaContext& ctx);
+  bool Inst_Alarm_MSG_Bit_Cons24_multihop(cAvidaContext& ctx);
   bool Inst_Alarm_Label(cAvidaContext& ctx);
   bool Jump_To_Alarm_Label(int jump_label);
 

Modified: branches/jobScheduling/source/cpu/cTestCPUInterface.h
===================================================================
--- branches/jobScheduling/source/cpu/cTestCPUInterface.h	2008-04-25 23:40:34 UTC (rev 2554)
+++ branches/jobScheduling/source/cpu/cTestCPUInterface.h	2008-04-27 17:13:06 UTC (rev 2555)
@@ -83,7 +83,7 @@
   int GetFacing() { return 0; }
   bool SendMessage(cOrgMessage& msg) { return false; }
   
-  bool BcastAlarm(int jump_label) { return false; }
+  bool BcastAlarm(int jump_label, int bcast_range) { return false; }
   
   void DivideOrgTestamentAmongDeme(double value) {;}
 };

Modified: branches/jobScheduling/source/main/cAvidaConfig.h
===================================================================
--- branches/jobScheduling/source/main/cAvidaConfig.h	2008-04-25 23:40:34 UTC (rev 2554)
+++ branches/jobScheduling/source/main/cAvidaConfig.h	2008-04-27 17:13:06 UTC (rev 2555)
@@ -478,6 +478,7 @@
   CONFIG_ADD_VAR(FRAC_ENERGY_RELINQUISH, double, 1.0, "Fraction of organisms energy to relinquish");
   CONFIG_ADD_VAR(ENERGY_PASSED_ON_DEME_REPLICATION_METHOD, int, 0, "Who get energy passed from a parent deme\n0 = Energy divided among organisms injected to offspring deme\n1 = Energy divided among cells in offspring deme");
   CONFIG_ADD_VAR(INHERIT_EXE_RATE, int, 0, "Inherit energy rate from parent? 0=no  1=yes");
+  CONFIG_ADD_VAR(ATTACK_DECAY_RATE, double, 0.0, "Percent of cell's energy decayed by attack");
 
   CONFIG_ADD_GROUP(SECOND_PASS_GROUP, "Tracking metrics known after the running experiment previously");
   CONFIG_ADD_VAR(TRACK_CCLADES, int, 0, "Enable tracking of coalescence clades");

Modified: branches/jobScheduling/source/main/cDeme.cc
===================================================================
--- branches/jobScheduling/source/main/cDeme.cc	2008-04-25 23:40:34 UTC (rev 2554)
+++ branches/jobScheduling/source/main/cDeme.cc	2008-04-27 17:13:06 UTC (rev 2555)
@@ -103,7 +103,7 @@
       while(eventCell != -1) {
         if(event.GetEventID() == m_world->GetPopulation().GetCell(GetCellID(eventCell)).GetCellData()){
           tArray<double> cell_resources = deme_resource_count.GetCellResources(eventCell);  // uses global cell_id; is this a problem
-          cell_resources[res->GetID()] *= -0.05;
+          cell_resources[res->GetID()] *= m_world->GetConfig().ATTACK_DECAY_RATE.Get();
           deme_resource_count.ModifyCell(cell_resources, eventCell);
         }        
         eventCell = event.GetNextEventCellID();

Modified: branches/jobScheduling/source/main/cOrgInterface.h
===================================================================
--- branches/jobScheduling/source/main/cOrgInterface.h	2008-04-25 23:40:34 UTC (rev 2554)
+++ branches/jobScheduling/source/main/cOrgInterface.h	2008-04-27 17:13:06 UTC (rev 2555)
@@ -92,7 +92,7 @@
   virtual bool TestOnDivide() = 0;
   virtual bool SendMessage(cOrgMessage& msg) = 0;
 
-  virtual bool BcastAlarm(int jump_jabel) = 0;
+  virtual bool BcastAlarm(int jump_jabel, int bcast_range) = 0;
   virtual void DivideOrgTestamentAmongDeme(double value) = 0;
   
 };

Modified: branches/jobScheduling/source/main/cOrganism.cc
===================================================================
--- branches/jobScheduling/source/main/cOrganism.cc	2008-04-25 23:40:34 UTC (rev 2554)
+++ branches/jobScheduling/source/main/cOrganism.cc	2008-04-27 17:13:06 UTC (rev 2555)
@@ -669,11 +669,11 @@
 }
 
 
-bool cOrganism::BcastAlarmMSG(cAvidaContext& ctx, int jump_label) {
+bool cOrganism::BcastAlarmMSG(cAvidaContext& ctx, int jump_label, int bcast_range) {
   assert(m_interface);
   
   // If we're able to succesfully send an alarm...
-  if(m_interface->BcastAlarm(jump_label)) {
+  if(m_interface->BcastAlarm(jump_label, bcast_range)) {
     // check to see if we've performed any tasks...
     DoOutput(ctx);
     return true;

Modified: branches/jobScheduling/source/main/cOrganism.h
===================================================================
--- branches/jobScheduling/source/main/cOrganism.h	2008-04-25 23:40:34 UTC (rev 2554)
+++ branches/jobScheduling/source/main/cOrganism.h	2008-04-27 17:13:06 UTC (rev 2555)
@@ -359,7 +359,7 @@
   
   /***** context switch********/
 public: 
-  bool BcastAlarmMSG(cAvidaContext& ctx, int jump_label);
+  bool BcastAlarmMSG(cAvidaContext& ctx, int jump_label, int bcast_range);
   void moveIPtoAlarmLabel(int jump_label);
   
   

Modified: branches/jobScheduling/source/main/cPopulationInterface.cc
===================================================================
--- branches/jobScheduling/source/main/cPopulationInterface.cc	2008-04-25 23:40:34 UTC (rev 2554)
+++ branches/jobScheduling/source/main/cPopulationInterface.cc	2008-04-27 17:13:06 UTC (rev 2555)
@@ -276,15 +276,14 @@
 }
 
 
-bool cPopulationInterface::BcastAlarm(int jump_label) {
+bool cPopulationInterface::BcastAlarm(int jump_label, int bcast_range) {
   bool successfully_sent(false);
   cPopulationCell& scell = m_world->GetPopulation().GetCell(m_cell_id);
   assert(scell.IsOccupied()); // This organism; sanity.
 
-  const int BCAST_RANGE = m_world->GetConfig().BCAST_HOPS.Get();
   const int ALARM_SELF = m_world->GetConfig().ALARM_SELF.Get(); // does an alarm affect the sender; 0=no  non-0=yes
   
-  if(BCAST_RANGE > 1) { // multi-hop messaging
+  if(bcast_range > 1) { // multi-hop messaging
     cDeme& deme = m_world->GetPopulation().GetDeme(GetDemeID());
     for(int i = 0; i < deme.GetSize(); i++) {
       int possible_receiver_id = deme.GetCellID(i);
@@ -296,7 +295,7 @@
         pair<int, int> possible_receiver_pos = deme.GetCellPosition(possible_receiver_id);
         int hop_distance = max( abs(sender_pos.first  - possible_receiver_pos.first),
                               abs(sender_pos.second - possible_receiver_pos.second));
-        if(hop_distance <= BCAST_RANGE) {
+        if(hop_distance <= bcast_range) {
           // send alarm to organisms
           cOrganism* recvr = rcell.GetOrganism();
           assert(recvr != NULL);

Modified: branches/jobScheduling/source/main/cPopulationInterface.h
===================================================================
--- branches/jobScheduling/source/main/cPopulationInterface.h	2008-04-25 23:40:34 UTC (rev 2554)
+++ branches/jobScheduling/source/main/cPopulationInterface.h	2008-04-27 17:13:06 UTC (rev 2555)
@@ -94,7 +94,7 @@
   bool TestOnDivide();
   //! Send a message to the faced organism.
   bool SendMessage(cOrgMessage& msg);
-  bool BcastAlarm(int jump_label);
+  bool BcastAlarm(int jump_label, int bcast_range);
   
   void DivideOrgTestamentAmongDeme(double value);
 };




More information about the Avida-cvs mailing list