[Avida-SVN] r1500 - development/source/main

goingssh at myxo.css.msu.edu goingssh at myxo.css.msu.edu
Tue Apr 24 14:18:45 PDT 2007


Author: goingssh
Date: 2007-04-24 17:18:44 -0400 (Tue, 24 Apr 2007)
New Revision: 1500

Modified:
   development/source/main/cPhenotype.cc
   development/source/main/cTaskLib.cc
Log:
made all occurrences of log(2) in cPhenotype.cc log(2.0) since VS is dumb
modified optimize task so can use any base to convert from binary string to double values, added this as a task parameter 

Modified: development/source/main/cPhenotype.cc
===================================================================
--- development/source/main/cPhenotype.cc	2007-04-24 07:20:04 UTC (rev 1499)
+++ development/source/main/cPhenotype.cc	2007-04-24 21:18:44 UTC (rev 1500)
@@ -912,7 +912,7 @@
   {
     promoter_activation[i] *= (1 - m_world->GetConfig().REGULATION_DECAY_FRAC.Get());
     promoter_repression[i] *= (1 - m_world->GetConfig().REGULATION_DECAY_FRAC.Get());
-    cur_promoter_weights[i] = base_promoter_weights[i] * exp((1+promoter_activation[i])*log(2)) / exp((1+promoter_repression[i])*log(2));
+    cur_promoter_weights[i] = base_promoter_weights[i] * exp((1+promoter_activation[i])*log(2.0)) / exp((1+promoter_repression[i])*log(2.0));
 
   }
 }
@@ -931,6 +931,6 @@
     promoter_repression[i] += m_world->GetConfig().REGULATION_STRENGTH.Get(); 
   }
   
-  cur_promoter_weights[i] = base_promoter_weights[i] * exp((1+promoter_activation[i])*log(2)) / exp((1+promoter_repression[i])*log(2));
+  cur_promoter_weights[i] = base_promoter_weights[i] * exp((1+promoter_activation[i])*log(2.0)) / exp((1+promoter_repression[i])*log(2.0));
 }
 

Modified: development/source/main/cTaskLib.cc
===================================================================
--- development/source/main/cTaskLib.cc	2007-04-24 07:20:04 UTC (rev 1499)
+++ development/source/main/cTaskLib.cc	2007-04-24 21:18:44 UTC (rev 1500)
@@ -2123,8 +2123,9 @@
 	schema.AddEntry("binary", 1, 0);
 	schema.AddEntry("varlength", 2, 8);
 	// Double Arguments
-	schema.AddEntry("max_Fx", 0, 1.0);
-	schema.AddEntry("min_Fx", 1, 0.0);
+	schema.AddEntry("basepow", 0, 2.0);
+	schema.AddEntry("max_Fx", 1, 1.0);
+	schema.AddEntry("min_Fx", 2, 0.0);
 
 
 	cArgContainer* args = cArgContainer::Load(argstr, schema, errors);
@@ -2171,14 +2172,16 @@
 	 if (args.GetInt(1))
 	 {
 		int len = args.GetInt(2);
-		int tempX = 0, tempY=0;
+		double base_pow = args.GetDouble(0);
+		double tempX = 0, tempY=0, tot=0;
 		for (int i=len-1; i>=0; i--)
 		{
-			tempX += ctx.GetOutputBuffer()[i+len]*pow(2.0,(len-1)-i);
-			tempY += ctx.GetOutputBuffer()[i]*pow(2.0,(len-1)-i);
+			tempX += ctx.GetOutputBuffer()[i+len]*pow(base_pow,(len-1)-i);
+			tempY += ctx.GetOutputBuffer()[i]*pow(base_pow,(len-1)-i);
+			tot += pow(base_pow,i);
 		}
-		x = (double)tempX/(pow(2.0,len)-1);
-		y = (double)tempY/(pow(2.0,len)-1);
+		x = (double)tempX/tot;
+		y = (double)tempY/tot;
 	 }
 	 else
 	 {




More information about the Avida-cvs mailing list