[Avida-SVN] r3272 - in development/source: actions cpu main

beckma24 at myxo.css.msu.edu beckma24 at myxo.css.msu.edu
Sat May 30 13:49:47 PDT 2009


Author: beckma24
Date: 2009-05-30 16:49:46 -0400 (Sat, 30 May 2009)
New Revision: 3272

Modified:
   development/source/actions/EnvironmentActions.cc
   development/source/actions/PopulationActions.cc
   development/source/cpu/cHardwareCPU.cc
   development/source/cpu/cHardwareCPU.h
   development/source/main/cDeme.h
Log:
More treatment data tracking

Modified: development/source/actions/EnvironmentActions.cc
===================================================================
--- development/source/actions/EnvironmentActions.cc	2009-05-30 20:06:38 UTC (rev 3271)
+++ development/source/actions/EnvironmentActions.cc	2009-05-30 20:49:46 UTC (rev 3272)
@@ -926,18 +926,14 @@
 	double factionTreatable; // total number of unique event to create; they may overlab
 	
 public:
-	cActionSetFracDemeTreatable(cWorld* world, const cString& args) : 
-	cAction(world, args), 
-	factionTreatable(0.0)
-	{
+	cActionSetFracDemeTreatable(cWorld* world, const cString& args) : cAction(world, args), factionTreatable(0.0) {
 		cString largs(args);
 		if (largs.GetSize()) factionTreatable = largs.PopWord().AsDouble();
 	}
 	
 	static const cString GetDescription() { return "Arguments: <double factionTreatable>"; }
 	
-	void Process(cAvidaContext& ctx)
-	{
+	void Process(cAvidaContext& ctx) {
 		cPopulation& pop = m_world->GetPopulation();
 		int numDemes = pop.GetNumDemes();
 		for(int i = 0; i < numDemes; i++) {

Modified: development/source/actions/PopulationActions.cc
===================================================================
--- development/source/actions/PopulationActions.cc	2009-05-30 20:06:38 UTC (rev 3271)
+++ development/source/actions/PopulationActions.cc	2009-05-30 20:49:46 UTC (rev 3272)
@@ -913,6 +913,7 @@
 	double m_exponent;
 	int m_printUpdate;
 	cIntSum m_totalkilled;
+	cDoubleSum m_killProd;
 
 public:
 	cAction_TherapyStructuralNumInst(cWorld* world, const cString& args) : cAction(world, args), m_inst("nand"), m_exprWeight(1.0), m_exponent(1.0), m_printUpdate(100)
@@ -922,8 +923,8 @@
 		if (largs.GetSize()) m_exprWeight = largs.PopWord().AsDouble();
 		if (largs.GetSize()) m_exponent = largs.PopWord().AsDouble();
 		if (largs.GetSize()) m_printUpdate = largs.PopWord().AsInt();
-		cerr<<m_printUpdate<<endl;
 		m_totalkilled.Clear();
+		m_killProd.Clear();
 	}
 	
 	static const cString GetDescription() { return "Arguments: [cString inst=nand] [double exprWeight=1.0] [double exponent=1.0(linear)]"; }
@@ -931,7 +932,9 @@
 	void Process(cAvidaContext& ctx)
 	{
 		int totalkilled = 0;
-		
+		cDoubleSum currentKillProb;
+		currentKillProb.Clear();
+
 		// for each deme in the population...
 		cPopulation& pop = m_world->GetPopulation();
 		const int numDemes = pop.GetNumDemes();
@@ -954,7 +957,7 @@
 
 				double killprob = min(pow(m_exprWeight*count,m_exponent), 100.0)/100.0;
 				// cout << count << " " << killprob << endl;
-
+				currentKillProb.Add(killprob);
 				// decide if it should be killed or not, based on the kill probability
 				if (ctx.GetRandom().P(killprob)) {
 					m_world->GetPopulation().KillOrganism(cell);
@@ -963,6 +966,7 @@
 			}
 		}
 		m_totalkilled.Add(totalkilled);
+		m_killProd.Add(currentKillProb.Average());
 			
 		const int update = m_world->GetStats().GetUpdate();
 		if(update % m_printUpdate == 0) {
@@ -970,8 +974,10 @@
 			df.WriteComment("Number of organisms killed by structural therapy NumInst");
 			df.Write(update, "Update");
 			df.Write(m_totalkilled.Average(), "Mean organisms killed per update since last print");
+			df.Write(m_killProd.Average(), "Mean organism kill probablity");
 			df.Endl();
 			m_totalkilled.Clear();
+			m_killProd.Clear();
 		}
 	}
 };
@@ -993,6 +999,7 @@
 	double m_exponent;
 	int m_printUpdate;
 	cIntSum m_totalkilled;
+	cDoubleSum m_killProd;
 	
 public:
 	cAction_TherapyStructuralRatioDistBetweenNearest(cWorld* world, const cString& args) : cAction(world, args), m_inst("nand"), m_exprWeight(1.0), m_exponent(1.0), m_printUpdate(100)
@@ -1003,6 +1010,7 @@
 		if (largs.GetSize()) m_exponent = largs.PopWord().AsDouble();
 		if (largs.GetSize()) m_printUpdate = largs.PopWord().AsInt();
 		m_totalkilled.Clear();
+		m_killProd.Clear();
 	}
 	
 	static const cString GetDescription() { return "Arguments: [cString inst=nand] [double exprWeight=1.0] [double exponent=1.0(linear)] [int print=100]"; }
@@ -1010,6 +1018,8 @@
 	void Process(cAvidaContext& ctx)
 	{
 		int totalkilled = 0;
+		cDoubleSum currentKillProb;
+		currentKillProb.Clear();
 		// for each deme in the population...
 		cPopulation& pop = m_world->GetPopulation();
 		const int numDemes = pop.GetNumDemes();
@@ -1036,7 +1046,7 @@
 				int ratioNumerator = min(genomeSize, pow(m_exprWeight*minDist, m_exponent));
 				double killprob = (genomeSize - static_cast<double>(ratioNumerator))/genomeSize;
 				// cout<<minDist << " " << killprob<<endl;
-				
+				currentKillProb.Add(killprob);
 				// decide if it should be killed or not, based on the kill probability
 				if (ctx.GetRandom().P(killprob)) {
 					m_world->GetPopulation().KillOrganism(cell);
@@ -1045,6 +1055,7 @@
 			}
 		}
 		m_totalkilled.Add(totalkilled);
+		m_killProd.Add(currentKillProb.Average());
 		
 		const int update = m_world->GetStats().GetUpdate();
 		if(update % m_printUpdate == 0) {
@@ -1052,8 +1063,10 @@
 			df.WriteComment("Number of organisms killed by structural therapy RatioDistBetweenNearest");
 			df.Write(update, "Update");
 			df.Write(m_totalkilled.Average(), "Mean organisms killed per update since last print");
+			df.Write(m_killProd.Average(), "Mean organism kill probablity");
 			df.Endl();
 			m_totalkilled.Clear();
+			m_killProd.Clear();
 		}
 	}
 };

Modified: development/source/cpu/cHardwareCPU.cc
===================================================================
--- development/source/cpu/cHardwareCPU.cc	2009-05-30 20:06:38 UTC (rev 3271)
+++ development/source/cpu/cHardwareCPU.cc	2009-05-30 20:49:46 UTC (rev 3272)
@@ -188,7 +188,10 @@
     tInstLibEntry<tMethod>("and", &cHardwareCPU::Inst_And),
     tInstLibEntry<tMethod>("order", &cHardwareCPU::Inst_Order),
     tInstLibEntry<tMethod>("xor", &cHardwareCPU::Inst_Xor),
-    
+
+		// treatable instructions
+		tInstLibEntry<tMethod>("nand-treatable", &cHardwareCPU::Inst_NandTreatable, nInstFlag::DEFAULT, "Nand BX by CX and place the result in ?BX?, fails if deme is treatable"),
+		
     tInstLibEntry<tMethod>("copy", &cHardwareCPU::Inst_Copy),
     tInstLibEntry<tMethod>("read", &cHardwareCPU::Inst_ReadInst),
     tInstLibEntry<tMethod>("write", &cHardwareCPU::Inst_WriteInst),
@@ -2565,6 +2568,19 @@
   return true;
 }
 
+bool cHardwareCPU::Inst_NandTreatable(cAvidaContext& ctx)
+{
+/*	
+	if(!m_organism->GetDeme()->isTreatable() && m_world->GetRandom().P(probFail))
+		return true;
+	
+  const int dst = FindModifiedRegister(REG_BX);
+  const int op1 = REG_BX;
+  const int op2 = REG_CX;
+  GetRegister(dst) = ~(GetRegister(op1) & GetRegister(op2));
+  */return true;
+}
+
 bool cHardwareCPU::Inst_Nor(cAvidaContext& ctx)
 {
   const int dst = FindModifiedRegister(REG_BX);

Modified: development/source/cpu/cHardwareCPU.h
===================================================================
--- development/source/cpu/cHardwareCPU.h	2009-05-30 20:06:38 UTC (rev 3271)
+++ development/source/cpu/cHardwareCPU.h	2009-05-30 20:49:46 UTC (rev 3272)
@@ -433,6 +433,9 @@
   bool Inst_Order(cAvidaContext& ctx);
   bool Inst_Xor(cAvidaContext& ctx);
 
+  // Double Argument Math that are treatable
+	bool Inst_NandTreatable(cAvidaContext& ctx);
+
   // Biological
   bool Inst_Copy(cAvidaContext& ctx);
   bool Inst_ReadInst(cAvidaContext& ctx);

Modified: development/source/main/cDeme.h
===================================================================
--- development/source/main/cDeme.h	2009-05-30 20:06:38 UTC (rev 3271)
+++ development/source/main/cDeme.h	2009-05-30 20:49:46 UTC (rev 3272)
@@ -143,7 +143,7 @@
 	
   
 public:
-  cDeme() : _id(0), width(0), replicateDeme(false), treatable(true), cur_birth_count(0), last_birth_count(0), cur_org_count(0), last_org_count(0), injected_count(0), birth_count_perslot(0),
+  cDeme() : _id(0), width(0), replicateDeme(false), treatable(false), cur_birth_count(0), last_birth_count(0), cur_org_count(0), last_org_count(0), injected_count(0), birth_count_perslot(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), 
 						MSG_sendFailed(0), MSG_dropped(0), MSG_SuccessfullySent(0), MSG_sent(0), energyInjectedIntoOrganisms(0.0), energyRemainingInDemeAtReplication(0.0), total_energy_testament(0.0),




More information about the Avida-cvs mailing list