[Avida-cvs] [avida-svn] r790 - in development/source: actions event

brysonda@myxo.css.msu.edu brysonda at myxo.css.msu.edu
Mon Jul 3 09:34:59 PDT 2006


Author: brysonda
Date: 2006-07-03 12:34:58 -0400 (Mon, 03 Jul 2006)
New Revision: 790

Modified:
   development/source/actions/LandscapeActions.cc
   development/source/event/cEventManager.cc
Log:
Transition predict w/nu landscape events into actions.

Modified: development/source/actions/LandscapeActions.cc
===================================================================
--- development/source/actions/LandscapeActions.cc	2006-07-01 02:35:06 UTC (rev 789)
+++ development/source/actions/LandscapeActions.cc	2006-07-03 16:34:58 UTC (rev 790)
@@ -29,7 +29,7 @@
 #include "defs.h"
 
 
-class cActionAnalyzeLandscape : public cAction
+class cActionAnalyzeLandscape : public cAction  // @parallelized
 {
 private:
   cString m_filename;
@@ -143,7 +143,7 @@
  this is that it supports multithreaded execution, whereas lazy evaluation during
  detailing will be serialized.
 */
-class cActionCalcLandscape : public cAction
+class cActionCalcLandscape : public cAction  // @parallelized
 {
 public:
   cActionCalcLandscape(cWorld* world, const cString& args) : cAction(world, args) { ; }
@@ -175,7 +175,7 @@
 };
 
 
-class cActionFullLandscape : public cAction
+class cActionFullLandscape : public cAction  // @parallelized
 {
 private:
   cString m_filename;
@@ -243,10 +243,110 @@
 };
 
 
-class cActionRandomLandscape : public cAction
+class cActionPredictWLandscape : public cAction  // @not_parallelized
 {
 private:
   cString m_filename;
+  
+public:
+  cActionPredictWLandscape(cWorld* world, const cString& args)
+  : cAction(world, args), m_filename("land-predict.dat")
+  {
+    cString largs(args);
+    if (largs.GetSize()) m_filename = largs.PopWord();
+  }
+  
+  const cString GetDescription()
+  {
+    return "PredictWLandscape [filename='land-predict.dat']";
+  }
+  
+  void Process(cAvidaContext& ctx)
+  {
+    cInstSet& inst_set = m_world->GetHardwareManager().GetInstSet();
+    std::ofstream& outfile = m_world->GetDataFileOFStream(m_filename);
+
+    if (ctx.GetAnalyzeMode()) {
+      if (m_world->GetConfig().VERBOSITY.Get() >= VERBOSE_ON) {
+        cString msg("Predicting W Landscape on batch ");
+        msg += cStringUtil::Convert(m_world->GetAnalyze().GetCurrentBatchID());
+        m_world->GetDriver().NotifyComment(msg);
+      } else if (m_world->GetConfig().VERBOSITY.Get() > VERBOSE_SILENT) {
+        m_world->GetDriver().NotifyComment("Predicting W Landscape...");
+      }
+      
+      tListIterator<cAnalyzeGenotype> batch_it(m_world->GetAnalyze().GetCurrentBatch().List());
+      cAnalyzeGenotype* genotype = NULL;
+      while (genotype = batch_it.Next()) {
+        cLandscape land(m_world, genotype->GetGenome(), inst_set);
+        land.PredictWProcess(ctx, outfile);
+      }
+    } else {
+      if (m_world->GetConfig().VERBOSITY.Get() >= VERBOSE_DETAILS)
+        m_world->GetDriver().NotifyComment("Predicting W Landscape...");
+      
+      const cGenome& best_genome = m_world->GetClassificationManager().GetBestGenotype()->GetGenome();
+      cLandscape land(m_world, best_genome, inst_set);
+      land.PredictWProcess(ctx, outfile, m_world->GetStats().GetUpdate());
+    }
+  }
+};
+
+
+class cActionPredictNuLandscape : public cAction  // @not_parallized
+{
+private:
+  cString m_filename;
+  
+public:
+  cActionPredictNuLandscape(cWorld* world, const cString& args)
+  : cAction(world, args), m_filename("land-predict.dat")
+  {
+    cString largs(args);
+    if (largs.GetSize()) m_filename = largs.PopWord();
+  }
+  
+  const cString GetDescription()
+  {
+    return "PredictNuLandscape [filename='land-predict.dat']";
+  }
+  
+  void Process(cAvidaContext& ctx)
+  {
+    cInstSet& inst_set = m_world->GetHardwareManager().GetInstSet();
+    std::ofstream& outfile = m_world->GetDataFileOFStream(m_filename);
+
+    if (ctx.GetAnalyzeMode()) {
+      if (m_world->GetConfig().VERBOSITY.Get() >= VERBOSE_ON) {
+        cString msg("Predicting Nu Landscape on batch ");
+        msg += cStringUtil::Convert(m_world->GetAnalyze().GetCurrentBatchID());
+        m_world->GetDriver().NotifyComment(msg);
+      } else if (m_world->GetConfig().VERBOSITY.Get() > VERBOSE_SILENT) {
+        m_world->GetDriver().NotifyComment("Predicting Nu Landscape...");
+      }
+      
+      tListIterator<cAnalyzeGenotype> batch_it(m_world->GetAnalyze().GetCurrentBatch().List());
+      cAnalyzeGenotype* genotype = NULL;
+      while (genotype = batch_it.Next()) {
+        cLandscape land(m_world, genotype->GetGenome(), inst_set);
+        land.PredictWProcess(ctx, outfile);
+      }
+    } else {
+      if (m_world->GetConfig().VERBOSITY.Get() >= VERBOSE_DETAILS)
+        m_world->GetDriver().NotifyComment("Predicting Nu Landscape...");
+      
+      const cGenome& best_genome = m_world->GetClassificationManager().GetBestGenotype()->GetGenome();
+      cLandscape land(m_world, best_genome, inst_set);
+      land.PredictWProcess(ctx, outfile, m_world->GetStats().GetUpdate());
+    }
+  }
+};
+
+
+class cActionRandomLandscape : public cAction  // @parallelized
+{
+private:
+  cString m_filename;
   int m_dist;
   int m_trials;
   tList<cLandscape> m_batch;
@@ -315,7 +415,7 @@
 };
 
 
-class cActionSampleLandscape : public cAction
+class cActionSampleLandscape : public cAction  // @parallelized
 {
 private:
   cString m_filename;
@@ -384,7 +484,7 @@
 };
 
 
-class cActionMutationalNeighborhood : public cAction
+class cActionMutationalNeighborhood : public cAction  // @parallelized
 {
 private:
   cString m_filename;
@@ -465,6 +565,8 @@
   action_lib->Register<cActionAnalyzeLandscape>("AnalyzeLandscape");
   action_lib->Register<cActionCalcLandscape>("CalcLandscape");
   action_lib->Register<cActionFullLandscape>("FullLandscape");
+  action_lib->Register<cActionPredictWLandscape>("PredictWLandscape");
+  action_lib->Register<cActionPredictNuLandscape>("PredictNuLandscape");
   action_lib->Register<cActionRandomLandscape>("RandomLandscape");
   action_lib->Register<cActionSampleLandscape>("SampleLandscape");
   action_lib->Register<cActionMutationalNeighborhood>("MutationalNeighborhood");

Modified: development/source/event/cEventManager.cc
===================================================================
--- development/source/event/cEventManager.cc	2006-07-01 02:35:06 UTC (rev 789)
+++ development/source/event/cEventManager.cc	2006-07-03 16:34:58 UTC (rev 790)
@@ -429,66 +429,6 @@
   }
 };
 
-///// predict_w_landscape /////
-
-/**
-**/
-
-
-class cEvent_predict_w_landscape : public cEvent {
-private:
-  cString datafile;
-public:
-  const cString GetName() const { return "predict_w_landscape"; }
-  const cString GetDescription() const { return "predict_w_landscape  [string datafile=\"land-predict.dat\"]"; }
-  
-  void Configure(cWorld* world, const cString& in_args)
-  {
-    m_world = world;
-    m_args = in_args;
-    cString args(in_args);
-    if (args == "") datafile="land-predict.dat"; else datafile=args.PopWord();
-  }
-  ///// predict_w_landscape /////
-  void Process(){
-    cAvidaContext& ctx = m_world->GetDefaultContext();
-
-    cGenome & genome = m_world->GetClassificationManager().GetBestGenotype()->GetGenome();
-    cLandscape landscape(m_world, genome, m_world->GetHardwareManager().GetInstSet());
-    landscape.PredictWProcess(ctx, m_world->GetDataFileOFStream(datafile));
-  }
-};
-
-///// predict_nu_landscape /////
-
-/**
-**/
-
-
-class cEvent_predict_nu_landscape : public cEvent {
-private:
-  cString datafile;
-public:
-  const cString GetName() const { return "predict_nu_landscape"; }
-  const cString GetDescription() const { return "predict_nu_landscape  [string datafile=\"land-predict.dat\"]"; }
-  
-  void Configure(cWorld* world, const cString& in_args)
-  {
-    m_world = world;
-    m_args = in_args;
-    cString args(in_args);
-    if (args == "") datafile="land-predict.dat"; else datafile=args.PopWord();
-  }
-  ///// predict_nu_landscape /////
-  void Process() {
-    cAvidaContext& ctx = m_world->GetDefaultContext();
-
-    cGenome& genome = m_world->GetClassificationManager().GetBestGenotype()->GetGenome();
-    cLandscape landscape(m_world, genome, m_world->GetHardwareManager().GetInstSet());
-    landscape.PredictNuProcess(ctx, m_world->GetDataFileOFStream(datafile));
-  }
-};
-
 ///// pairtest_landscape /////
 
 /**
@@ -2031,8 +1971,6 @@
   REGISTER(mod_point_mut);
   REGISTER(set_point_mut);
   REGISTER(calc_landscape);
-  REGISTER(predict_w_landscape);
-  REGISTER(predict_nu_landscape);
   REGISTER(pairtest_landscape);
   REGISTER(test_dom);
   REGISTER(analyze_population);




More information about the Avida-cvs mailing list