[Avida-cvs] [avida-svn] r605 - in development/source: analyze drivers event

brysonda@myxo.css.msu.edu brysonda at myxo.css.msu.edu
Wed Apr 12 13:03:13 PDT 2006


Author: brysonda
Date: 2006-04-12 16:03:12 -0400 (Wed, 12 Apr 2006)
New Revision: 605

Modified:
   development/source/analyze/cAnalyze.cc
   development/source/analyze/cAnalyzeUtil.cc
   development/source/analyze/cAnalyzeUtil.h
   development/source/drivers/cDefaultAnalyzeDriver.cc
   development/source/event/cEventManager.cc
Log:
Clean up some superseded events.

Change cAnalyze construction so that it does not run immediately.  This could have been problematic for scheduled Actions triggering analyze mode unintentionally.

Change cAnalyze::RunFile to set/clear the Analyze mode flag within the default context.

Modified: development/source/analyze/cAnalyze.cc
===================================================================
--- development/source/analyze/cAnalyze.cc	2006-04-12 03:37:01 UTC (rev 604)
+++ development/source/analyze/cAnalyze.cc	2006-04-12 20:03:12 UTC (rev 605)
@@ -97,8 +97,6 @@
   // @DMB -  FillResources(0);
 
   m_testcpu = m_world->GetHardwareManager().CreateTestCPU();
-  
-  RunFile(m_world->GetConfig().ANALYZE_FILE.Get());
 }
 
 

Modified: development/source/analyze/cAnalyzeUtil.cc
===================================================================
--- development/source/analyze/cAnalyzeUtil.cc	2006-04-12 03:37:01 UTC (rev 604)
+++ development/source/analyze/cAnalyzeUtil.cc	2006-04-12 20:03:12 UTC (rev 605)
@@ -153,45 +153,6 @@
 }
 
 
-void cAnalyzeUtil::AnalyzeLandscape(cWorld* world, const cGenome & genome, cInstSet &inst_set,
-                                    int sample_size, int min_found, int max_sample_size, int update)
-{
-  cAvidaContext& ctx = world->GetDefaultContext();
-
-  cLandscape landscape(world, genome, inst_set);
-  ofstream& fp = world->GetDataFileOFStream("land_analyze.dat");
-  
-  int num_found = 0;
-  for (int dist = 1; dist <= 10; dist++) {
-    landscape.Reset(genome);
-    landscape.SetDistance(dist);
-    landscape.SetTrials(sample_size);
-    if (dist == 1) {
-      landscape.Process(ctx);
-    } else {
-      landscape.SetMinFound(min_found);
-      landscape.SetMaxTrials(max_sample_size);
-      landscape.RandomProcess(ctx);
-    }
-    num_found = landscape.GetNumFound();
-    
-    fp << update                       << " "  // 1
-      << dist                         << " "  // 2
-      << landscape.GetProbDead()      << " "  // 3
-      << landscape.GetProbNeg()       << " "  // 4
-      << landscape.GetProbNeut()      << " "  // 5
-      << landscape.GetProbPos()       << " "  // 6
-      << landscape.GetNumTrials()     << " "  // 7
-      << num_found                    << " "  // 8
-      << landscape.GetAveFitness()    << " "  // 9
-      << landscape.GetAveSqrFitness() << " "  // 10
-      << endl;
-    
-    if ((dist > 1) && (num_found < min_found)) break;
-  }
-}
-
-
 void cAnalyzeUtil::PairTestLandscape(cWorld* world, const cGenome &genome, cInstSet &inst_set,
                                      int sample_size, int update)
 {

Modified: development/source/analyze/cAnalyzeUtil.h
===================================================================
--- development/source/analyze/cAnalyzeUtil.h	2006-04-12 03:37:01 UTC (rev 604)
+++ development/source/analyze/cAnalyzeUtil.h	2006-04-12 20:03:12 UTC (rev 605)
@@ -37,9 +37,6 @@
   // Landscape-based analysis
   static cGenome CalcLandscape(cWorld* world, int dist, const cGenome & genome,
 			       cInstSet & inst_set);
-  static void AnalyzeLandscape(cWorld* world, const cGenome & genome, cInstSet & inst_set,
-			       int sample_size=1000, int min_found=0,
-			       int max_sample_size=0, int update=-1);
   static void PairTestLandscape(cWorld* world, const cGenome & genome, cInstSet & inst_set,
 				int sample_size=0, int update=-1);
 

Modified: development/source/drivers/cDefaultAnalyzeDriver.cc
===================================================================
--- development/source/drivers/cDefaultAnalyzeDriver.cc	2006-04-12 03:37:01 UTC (rev 604)
+++ development/source/drivers/cDefaultAnalyzeDriver.cc	2006-04-12 20:03:12 UTC (rev 605)
@@ -35,11 +35,12 @@
 
 void cDefaultAnalyzeDriver::Run()
 {
+  m_world->GetDefaultContext().SetAnalyzeMode();
   cout << "In analyze mode!!" << endl;
   cAnalyze& analyze = m_world->GetAnalyze();
-  if (m_interactive == true) {
-    analyze.RunInteractive();
-  }
+  analyze.RunFile(m_world->GetConfig().ANALYZE_FILE.Get());
+  if (m_interactive == true) analyze.RunInteractive();
+  m_world->GetDefaultContext().ClearAnalyzeMode();
 }
 
 void cDefaultAnalyzeDriver::RaiseException(const cString& in_string)

Modified: development/source/event/cEventManager.cc
===================================================================
--- development/source/event/cEventManager.cc	2006-04-12 03:37:01 UTC (rev 604)
+++ development/source/event/cEventManager.cc	2006-04-12 20:03:12 UTC (rev 605)
@@ -1855,107 +1855,6 @@
   }
 };
 
-///// sample_landscape /////
-
-/**
-**/
-
-
-class cEvent_sample_landscape : public cEvent {
-private:
-  int sample_size;
-public:
-  const cString GetName() const { return "sample_landscape"; }
-  const cString GetDescription() const { return "sample_landscape  [int sample_size=0]"; }
-  
-  void Configure(cWorld* world, const cString& in_args)
-  {
-    m_world = world;
-    m_args = in_args;
-    cString args(in_args);
-    if (args == "") sample_size=0; else sample_size=args.PopWord().AsInt();
-  }
-  ///// sample_landscape /////
-  void Process(){
-    cAvidaContext& ctx = m_world->GetDefaultContext();
-
-    cGenome& genome = m_world->GetClassificationManager().GetBestGenotype()->GetGenome();
-    cLandscape landscape(m_world, genome, m_world->GetHardwareManager().GetInstSet());
-    if (sample_size == 0) sample_size = m_world->GetHardwareManager().GetInstSet().GetSize() - 1;
-    landscape.SetTrials(sample_size);
-    landscape.SampleProcess(ctx);
-    landscape.PrintStats(m_world->GetDataFileOFStream("land-sample.dat"), m_world->GetStats().GetUpdate());
-  }
-};
-
-///// random_landscape /////
-
-/**
-**/
-
-
-class cEvent_random_landscape : public cEvent {
-private:
-  int landscape_dist;
-  int sample_size;
-public:
-    const cString GetName() const { return "random_landscape"; }
-  const cString GetDescription() const { return "random_landscape  [int landscape_dist=1] [int sample_size=0]"; }
-  
-  void Configure(cWorld* world, const cString& in_args)
-  {
-    m_world = world;
-    m_args = in_args;
-    cString args(in_args);
-    if (args == "") landscape_dist=1; else landscape_dist=args.PopWord().AsInt();
-    if (args == "") sample_size=0; else sample_size=args.PopWord().AsInt();
-  }
-  ///// random_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.SetDistance(landscape_dist);
-    landscape.SetTrials(sample_size);
-    landscape.RandomProcess(ctx);
-    landscape.PrintStats(m_world->GetDataFileOFStream("land-random.dat"), m_world->GetStats().GetUpdate());
-  }
-};
-
-///// analyze_landscape /////
-
-/**
-**/
-
-
-class cEvent_analyze_landscape : public cEvent {
-private:
-  int sample_size;
-  int min_found;
-  int max_sample_size;
-public:
-    const cString GetName() const { return "analyze_landscape"; }
-  const cString GetDescription() const { return "analyze_landscape  [int sample_size=1000] [int min_found=0] [int max_sample_size=0]"; }
-  
-  void Configure(cWorld* world, const cString& in_args)
-  {
-    m_world = world;
-    m_args = in_args;
-    cString args(in_args);
-    if (args == "") sample_size=1000; else sample_size=args.PopWord().AsInt();
-    if (args == "") min_found=0; else min_found=args.PopWord().AsInt();
-    if (args == "") max_sample_size=0; else max_sample_size=args.PopWord().AsInt();
-  }
-  ///// analyze_landscape /////
-  void Process(){
-    cGenome & genome = m_world->GetClassificationManager().GetBestGenotype()->GetGenome();
-    cAnalyzeUtil::AnalyzeLandscape(m_world, genome, m_world->GetHardwareManager().GetInstSet(),
-                     sample_size, min_found, max_sample_size,
-                     m_world->GetStats().GetUpdate());
-  }
-};
-
 ///// pairtest_landscape /////
 
 /**
@@ -3617,9 +3516,6 @@
   REGISTER(calc_landscape);
   REGISTER(predict_w_landscape);
   REGISTER(predict_nu_landscape);
-  REGISTER(sample_landscape);
-  REGISTER(random_landscape);
-  REGISTER(analyze_landscape);
   REGISTER(pairtest_landscape);
   REGISTER(test_dom);
   REGISTER(analyze_population);




More information about the Avida-cvs mailing list