[Avida-cvs] [avida-svn] r761 - in development: source source/analyze source/drivers source/main source/tools support/config

brysonda@myxo.css.msu.edu brysonda at myxo.css.msu.edu
Tue Jun 20 16:33:04 PDT 2006


Author: brysonda
Date: 2006-06-20 19:33:04 -0400 (Tue, 20 Jun 2006)
New Revision: 761

Modified:
   development/source/analyze/cAnalyze.cc
   development/source/analyze/cAnalyze.h
   development/source/defs.h
   development/source/drivers/cDefaultRunDriver.cc
   development/source/main/avida.cc
   development/source/main/cAvidaConfig.cc
   development/source/main/cAvidaConfig.h
   development/source/main/cPopulation.cc
   development/source/main/cWorld.cc
   development/source/tools/cDataFile.cc
   development/source/tools/cDataFileManager.cc
   development/source/tools/cDataFileManager.h
   development/source/tools/cString.h
   development/support/config/avida-smt.cfg
   development/support/config/avida.cfg
Log:
- cDataFileManager now stores absolute path to data directory, where
  possible.  This will prevent changes to the current directory from
  affecting a particular world's output directory.
- Change default VERBOSITY to 1 (level also renamed to from QUIET to
  NORMAL)
- Add command line options -v0 .. -v4 that can be used to specify
  verbosity.
- Fold various initialization messages into various verbosity levels
- Add in display of command line processed set actions at -v2.
  Fulfills rdar://1509640


Modified: development/source/analyze/cAnalyze.cc
===================================================================
--- development/source/analyze/cAnalyze.cc	2006-06-20 01:12:32 UTC (rev 760)
+++ development/source/analyze/cAnalyze.cc	2006-06-20 23:33:04 UTC (rev 761)
@@ -69,7 +69,7 @@
 , inst_set(world->GetHardwareManager().GetInstSet())
 , m_ctx(world->GetDefaultContext())
 , m_jobqueue(world)
-, verbose(nAnalyze::VERBOSE_QUIET)
+, verbose(nAnalyze::VERBOSE_NORMAL)
 , interactive_depth(0)
 {
   
@@ -5285,7 +5285,7 @@
     int tmp = batch1;  batch1 = batch2;  batch2 = tmp;
   }
   
-  if (verbose <= nAnalyze::VERBOSE_QUIET) {
+  if (verbose <= nAnalyze::VERBOSE_NORMAL) {
     cout << "Calculating Hamming Distance... ";
     cout.flush();
   } else {
@@ -5352,7 +5352,7 @@
     int tmp = batch1;  batch1 = batch2;  batch2 = tmp;
   }
   
-  if (verbose <= nAnalyze::VERBOSE_QUIET) {
+  if (verbose <= nAnalyze::VERBOSE_NORMAL) {
     cout << "Calculating Levenstein Distance... ";
     cout.flush();
   } else {
@@ -5419,7 +5419,7 @@
     int tmp = batch1;  batch1 = batch2;  batch2 = tmp;
   }
   
-  if (verbose <= nAnalyze::VERBOSE_QUIET) cout << "Calculating Species Distance... " << endl;
+  if (verbose <= nAnalyze::VERBOSE_NORMAL) cout << "Calculating Species Distance... " << endl;
   else cout << "Calculating Species Distance between batch "
     << batch1 << " and " << batch2 << endl;
   
@@ -5540,7 +5540,7 @@
     int tmp = batch1;  batch1 = batch2;  batch2 = tmp;
   }
   
-  if (verbose <= nAnalyze::VERBOSE_QUIET) cout << "Creating recombinants...  " << endl;
+  if (verbose <= nAnalyze::VERBOSE_NORMAL) cout << "Creating recombinants...  " << endl;
   else cout << "Creating recombinants between batch "
     << batch1 << " and " << batch2 << endl;
   
@@ -6928,7 +6928,7 @@
 
 void cAnalyze::BatchRename(cString cur_string)
 {
-  if (verbose <= nAnalyze::VERBOSE_QUIET) cout << "Renaming organisms..." << endl;
+  if (verbose <= nAnalyze::VERBOSE_NORMAL) cout << "Renaming organisms..." << endl;
   else cout << "Renaming organisms in batch " << cur_batch << endl;
   
   // If a number is given with rename, start at that number...
@@ -6973,22 +6973,22 @@
   cur_string.ToUpper();
   
   // If no arguments are given, assume a basic toggle.
-  if (cur_string.GetSize() == 0 && verbose <= nAnalyze::VERBOSE_QUIET) {
+  if (cur_string.GetSize() == 0 && verbose <= nAnalyze::VERBOSE_NORMAL) {
     verbose = nAnalyze::VERBOSE_ON;
   }
   else if (cur_string.GetSize() == 0 && verbose >= nAnalyze::VERBOSE_ON) {
-    verbose = nAnalyze::VERBOSE_QUIET;
+    verbose = nAnalyze::VERBOSE_NORMAL;
   }
   
   // Otherwise, read in the argument to decide the new mode.
   else if (cur_string == "SILENT") verbose = nAnalyze::VERBOSE_SILENT;
-  else if (cur_string == "QUIET") verbose = nAnalyze::VERBOSE_QUIET;
-  else if (cur_string == "OFF") verbose = nAnalyze::VERBOSE_QUIET;
+  else if (cur_string == "QUIET") verbose = nAnalyze::VERBOSE_NORMAL;
+  else if (cur_string == "OFF") verbose = nAnalyze::VERBOSE_NORMAL;
   else if (cur_string == "ON") verbose = nAnalyze::VERBOSE_ON;
   else if (cur_string == "DETAILS") verbose = nAnalyze::VERBOSE_DETAILS;
   else if (cur_string == "HIGH") verbose = nAnalyze::VERBOSE_DETAILS;
   // Print out new verbose level (nothing for silent!)
-  if (verbose == nAnalyze::VERBOSE_QUIET) {
+  if (verbose == nAnalyze::VERBOSE_NORMAL) {
     cout << "Verbose QUIET: Using minimal log messages..." << endl;
   } else if (verbose == nAnalyze::VERBOSE_ON) {
     cout << "Verbose ON: Using verbose log messages..." << endl;

Modified: development/source/analyze/cAnalyze.h
===================================================================
--- development/source/analyze/cAnalyze.h	2006-06-20 01:12:32 UTC (rev 760)
+++ development/source/analyze/cAnalyze.h	2006-06-20 23:33:04 UTC (rev 761)
@@ -42,7 +42,7 @@
 
 namespace nAnalyze {
   const int VERBOSE_SILENT  = 0;  // No output at all
-  const int VERBOSE_QUIET   = 1;  // Notification at start of commands.
+  const int VERBOSE_NORMAL   = 1;  // Notification at start of commands.
   const int VERBOSE_ON      = 2;  // Verbose output, detailing progress
   const int VERBOSE_DETAILS = 3;  // High level of details, as available.
 }

Modified: development/source/defs.h
===================================================================
--- development/source/defs.h	2006-06-20 01:12:32 UTC (rev 760)
+++ development/source/defs.h	2006-06-20 23:33:04 UTC (rev 761)
@@ -167,7 +167,7 @@
 
 typedef enum eVerbosity {
   VERBOSE_SILENT = 0,   // No output at all
-  VERBOSE_QUIET,        // Notification at start of commands.
+  VERBOSE_NORMAL,       // Notification at start of commands.
   VERBOSE_ON,           // Verbose output, detailing progress
   VERBOSE_DETAILS,      // High level of details, as available.
   VERBOSE_DEBUG         // Print Debug Information, as applicable.

Modified: development/source/drivers/cDefaultRunDriver.cc
===================================================================
--- development/source/drivers/cDefaultRunDriver.cc	2006-06-20 01:12:32 UTC (rev 760)
+++ development/source/drivers/cDefaultRunDriver.cc	2006-06-20 23:33:04 UTC (rev 761)
@@ -96,13 +96,15 @@
     
     
     // No viewer; print out status for this update....
-    cout.setf(ios::left);
-    cout.setf(ios::showpoint);
-    cout << "UD: " << setw(6) << stats.GetUpdate() << "  "
-      << "Gen: " << setw(9) << setprecision(7) << stats.SumGeneration().Average() << "  "
-      << "Fit: " << setw(9) << setprecision(7) << stats.GetAveFitness() << "  "
-      << "Size: " << population.GetNumOrganisms()
-      << endl;
+    if (m_world->GetConfig().VERBOSITY.Get() > VERBOSE_SILENT) {
+      cout.setf(ios::left);
+      cout.setf(ios::showpoint);
+      cout << "UD: " << setw(6) << stats.GetUpdate() << "  "
+        << "Gen: " << setw(9) << setprecision(7) << stats.SumGeneration().Average() << "  "
+        << "Fit: " << setw(9) << setprecision(7) << stats.GetAveFitness() << "  "
+        << "Size: " << population.GetNumOrganisms()
+        << endl;
+    }
     
     
     // Do Point Mutations

Modified: development/source/main/avida.cc
===================================================================
--- development/source/main/avida.cc	2006-06-20 01:12:32 UTC (rev 760)
+++ development/source/main/avida.cc	2006-06-20 23:33:04 UTC (rev 761)
@@ -77,6 +77,8 @@
   cout << "Avida comes with ABSOLUTELY NO WARRANTY." << endl;
   cout << "This is free software, and you are welcome to redistribute it" << endl;
   cout << "under certain conditions. See file COPYING for details." << endl << endl;
+
+  cout << "For more information, see: http://devolab.cse.msu.edu/software/avida/" << endl << endl;
 }
 
 void ExitAvida(int exit_code)

Modified: development/source/main/cAvidaConfig.cc
===================================================================
--- development/source/main/cAvidaConfig.cc	2006-06-20 01:12:32 UTC (rev 760)
+++ development/source/main/cAvidaConfig.cc	2006-06-20 23:33:04 UTC (rev 761)
@@ -314,6 +314,7 @@
       << "  -e[vents]             Print a list of all known events"<< endl
       << "  -s[eed] <value>       Set random seed to <value>"<<endl
       << "  -v[ersion]            Prints the version number"<<endl
+      << "  -v0 -v1 -v2 -v3 -v4   Set output verbosity to 0..4"
       << "  -set <name> <value>   Overide the genesis file"<<endl
       << "  -l[oad] <filename>    Load a clone file"<<endl
       << "  -a[nalyze]            Process analyze.cfg instead of normal run."<<endl
@@ -348,9 +349,15 @@
         arg_num++;  if (arg_num < argc) cur_arg = args[arg_num];
         cfg->CLONE_FILE.Set(cur_arg);
       }
-    } else if (cur_arg == "-version" || cur_arg == "-v") {
-      cout << " For more information, see: http://devolab.cse.msu.edu/software/avida/" << endl;
+    } else if (cur_arg == "-version") {
       exit(0);
+    } else if (cur_arg.Substring(0, 2) == "-v") {
+      if (cur_arg.GetSize() == 2) { // equivalent to -version
+        exit(0);
+      } else { // set verbosity
+        int level = cur_arg.Substring(2, cur_arg.GetSize() - 2).AsInt();
+        cfg->VERBOSITY.Set(level);
+      }
     } else if (cur_arg == "-set") {
       if (arg_num + 1 == argc || arg_num + 2 == argc) {
         cerr << "'-set' option must be followed by name and value" << endl;
@@ -379,14 +386,18 @@
   
   // Loop through all groups, then all entrys, and try to load each one.
   tListIterator<cBaseConfigGroup> group_it(cfg->group_list);
-  cBaseConfigGroup * cur_group;
+  cBaseConfigGroup* cur_group;
   cString val;
   while ((cur_group = group_it.Next()) != NULL) {
     // Loop through entries for this group...
     tListIterator<cBaseConfigEntry> entry_it(cur_group->GetEntryList());
-    cBaseConfigEntry * cur_entry;
+    cBaseConfigEntry* cur_entry;
     while ((cur_entry = entry_it.Next()) != NULL) {
-      if (sets.Find(cur_entry->GetName(), val)) cur_entry->LoadString(val);
+      if (sets.Find(cur_entry->GetName(), val)) {
+        cur_entry->LoadString(val);
+        if (cfg->VERBOSITY.Get() > VERBOSE_NORMAL)
+          cout << "CmdLine Set: " << cur_entry->GetName() << " " << val << endl;
+      }
     }
   }
   

Modified: development/source/main/cAvidaConfig.h
===================================================================
--- development/source/main/cAvidaConfig.h	2006-06-20 01:12:32 UTC (rev 760)
+++ development/source/main/cAvidaConfig.h	2006-06-20 23:33:04 UTC (rev 761)
@@ -84,7 +84,7 @@
   // The cBaseConfigEntry class is a bass class for all configuration entries.
   // It is used to manage the various types of entries in a dynamic fashion.
   class cBaseConfigEntry {
-private:
+  private:
     const cString config_name;   // Name of this setting
     const cString type;          // What type does this entry return?
     cString default_value;       // Value to use if not found in config file.
@@ -95,7 +95,7 @@
     // values (not changeable at run time).  Should this instance be one of
     // those classes?
     bool use_overide;
-public:
+  public:
       cBaseConfigEntry(const cString & _name, const cString & _type,
                        const cString & _def, const cString & _desc);
     virtual ~cBaseConfigEntry() { ; }
@@ -114,11 +114,11 @@
   // The cBaseConfigGroup class is a bass class for objects that collect the
   // configuration entries into logical groups.
   class cBaseConfigGroup {
-private:
+  private:
     cString group_name;
     cString description;
     tList<cBaseConfigEntry> entry_list;
-public:
+  public:
       cBaseConfigGroup(const cString & _name, const cString & _desc)
       : group_name(_name), description(_desc) { global_group_list.PushRear(this); }
     ~cBaseConfigGroup() { ; }
@@ -154,7 +154,7 @@
   CONFIG_ADD_VAR(VIEW_MODE, int, 0, "Initial viewer screen");
   CONFIG_ADD_VAR(CLONE_FILE, cString, "-", "Clone file to load");
   CONFIG_ADD_VAR(MT_CONCURRENCY, int, 1, "Number of concurrent analyze threads");
-  CONFIG_ADD_VAR(VERBOSITY, int, 0, "Control output verbosity");
+  CONFIG_ADD_VAR(VERBOSITY, int, 1, "Control output verbosity");
   
   CONFIG_ADD_GROUP(ARCH_GROUP, "Architecture Variables");
   CONFIG_ADD_VAR(MAX_UPDATES, int, -1, "Maximum updates to run experiment (-1 = no limit)");
@@ -270,8 +270,8 @@
   CONFIG_ADD_VAR(NET_STYLE, int, 0, "Communication Style.  0 = Random Next, 1 = Receiver Facing");
 #endif
   
-  void Load(const cString & filename);
-  void Print(const cString & filename);
+  void Load(const cString& filename);
+  void Print(const cString& filename);
   void Status();
   
   void GenerateOverides();

Modified: development/source/main/cPopulation.cc
===================================================================
--- development/source/main/cPopulation.cc	2006-06-20 01:12:32 UTC (rev 760)
+++ development/source/main/cPopulation.cc	2006-06-20 23:33:04 UTC (rev 761)
@@ -74,16 +74,19 @@
   world_y = world->GetConfig().WORLD_Y.Get();
   int geometry = world->GetConfig().WORLD_GEOMETRY.Get();
   const int num_cells = world_x * world_y;
-  cout << "Building world " << world_x << "x" << world_y
-    << " = " << num_cells << " organisms." << endl;
-  if (geometry == nGeometry::GRID) {
-    cout << "Geometry: Bounded grid" << endl;
-  } else if (geometry == nGeometry::TORUS) {
-    cout << "Geometry: Torus" << endl;
-  } else {
-    cout << "Geometry: Unknown" << endl;
+
+  // Print out world details
+  if (world->GetConfig().VERBOSITY.Get() > VERBOSE_NORMAL) {
+    cout << "Building world " << world_x << "x" << world_y << " = " << num_cells << " organisms." << endl;
+    if (geometry == nGeometry::GRID) {
+      cout << "Geometry: Bounded grid" << endl;
+    } else if (geometry == nGeometry::TORUS) {
+      cout << "Geometry: Torus" << endl;
+    } else {
+      cout << "Geometry: Unknown" << endl;
+    }
+    cout << endl;
   }
-  cout << endl;
   
   cell_array.Resize(num_cells);
   resource_count.ResizeSpatialGrids(world_x, world_y);

Modified: development/source/main/cWorld.cc
===================================================================
--- development/source/main/cWorld.cc	2006-06-20 01:12:32 UTC (rev 760)
+++ development/source/main/cWorld.cc	2006-06-20 23:33:04 UTC (rev 761)
@@ -58,14 +58,9 @@
   
   m_actlib = cDriverManager::GetActionLibrary();
   
-  // The data directory should end in a '/'
-  cString dir = m_conf->DATA_DIR.Get();
-  char dir_tail = dir[dir.GetSize() - 1];
-  if (dir_tail != '\\' && dir_tail != '/') {
-    dir += "/";
-    m_conf->DATA_DIR.Set(dir);
-  }
-  m_data_mgr = new cDataFileManager(dir);
+  m_data_mgr = new cDataFileManager(m_conf->DATA_DIR.Get(), (m_conf->VERBOSITY.Get() > VERBOSE_ON));
+  if (m_conf->VERBOSITY.Get() > VERBOSE_NORMAL)
+    cout << "Data Directory: " << m_data_mgr->GetTargetDir() << endl;
   
   m_class_mgr = new cClassificationManager(this);
   m_env = new cEnvironment(this);

Modified: development/source/tools/cDataFile.cc
===================================================================
--- development/source/tools/cDataFile.cc	2006-06-20 01:12:32 UTC (rev 760)
+++ development/source/tools/cDataFile.cc	2006-06-20 23:33:04 UTC (rev 761)
@@ -22,9 +22,6 @@
 
 cDataFile::cDataFile(cString& name) : m_name(name), num_cols(0), m_descr_written(false)
 {
-  //if (fopen(name,"r")) {
-    // cout << "File " << name() << " exists and is being overwritten" << endl;
-  //}
   m_fp.open(name);
   assert(m_fp.good());
   m_descr_written = false;

Modified: development/source/tools/cDataFileManager.cc
===================================================================
--- development/source/tools/cDataFileManager.cc	2006-06-20 01:12:32 UTC (rev 760)
+++ development/source/tools/cDataFileManager.cc	2006-06-20 23:33:04 UTC (rev 761)
@@ -12,9 +12,34 @@
 
 #include "cTools.h"
 
+#include <unistd.h>
+
+#define MAXIMUM_DIRECTORY_LENGTH 2048
+
 using namespace std;
 
 
+cDataFileManager::cDataFileManager(const cString& target_dir, bool verbose) : m_target_dir(target_dir)
+{
+  m_target_dir.Trim();
+  
+  // If 
+  if (m_target_dir.GetSize() == 0 || (m_target_dir[0] != '/' && m_target_dir[0] != '\\')) {
+    char* dirbuf = new char[MAXIMUM_DIRECTORY_LENGTH];    
+    char* cwd = getcwd(dirbuf, MAXIMUM_DIRECTORY_LENGTH);
+    if (cwd != NULL) {
+      m_target_dir = cString(cwd) + "/" + m_target_dir;
+    }
+    delete dirbuf;
+  }
+  
+  if (m_target_dir.GetSize() > 0) {
+    char dir_tail = m_target_dir[m_target_dir.GetSize() - 1];
+    if (dir_tail != '\\' && dir_tail != '/') m_target_dir += "/";
+    cTools::MkDir(m_target_dir, verbose);
+  }
+}
+
 cDataFileManager::~cDataFileManager()
 {
   tList<cString> names;

Modified: development/source/tools/cDataFileManager.h
===================================================================
--- development/source/tools/cDataFileManager.h	2006-06-20 01:12:32 UTC (rev 760)
+++ development/source/tools/cDataFileManager.h	2006-06-20 23:33:04 UTC (rev 761)
@@ -13,9 +13,6 @@
 
 #include <fstream>
 
-#ifndef cTools_h
-#include "cTools.h"
-#endif
 #ifndef cDataFile_h
 #include "cDataFile.h"
 #endif
@@ -41,7 +38,7 @@
   cDataFileManager& operator=(const cDataFileManager&); // @not_implemented
   
 public:
-  inline cDataFileManager(cString target_dir = "");
+  cDataFileManager(const cString& target_dir = "", bool verbose = false);
   ~cDataFileManager();
 
   /**
@@ -63,6 +60,8 @@
    * @return true if file existed, otherwise false.
    **/
   bool Remove(const cString& name);
+  
+  const cString& GetTargetDir() const { return m_target_dir; }
 };
 
 
@@ -77,14 +76,6 @@
 }
 #endif  
 
-inline cDataFileManager::cDataFileManager(cString target_dir) : m_target_dir(target_dir)
-{
-  if (m_target_dir.GetSize() > 0) {
-    char dir_tail = m_target_dir[m_target_dir.GetSize() - 1];
-    if (dir_tail != '\\' && dir_tail != '/') m_target_dir += "/";
-    cTools::MkDir(m_target_dir, true);
-  }
-}
 
 inline bool cDataFileManager::IsOpen(const cString & name)
 {

Modified: development/source/tools/cString.h
===================================================================
--- development/source/tools/cString.h	2006-06-20 01:12:32 UTC (rev 760)
+++ development/source/tools/cString.h	2006-06-20 23:33:04 UTC (rev 761)
@@ -308,20 +308,20 @@
    *
    * @return The integer value corresponding to the string.
    **/
-  int AsInt() const { return atoi(*this); }
+  int AsInt() const { return static_cast<int>(strtol(*this, NULL, 10)); }
   
   /**
    * Convert string to double.
    *
    * @return The double value corresponding to the string.
    **/
-  double AsDouble() const { return atof(*this); }
+  double AsDouble() const { return strtod(*this, NULL); }
 
   // Accessors & Information
   /**
    * Tests whether the string is empty.
    **/
-  bool IsEmpty() const { return GetSize()==0; } // Can just call GetSize
+  bool IsEmpty() const { return GetSize() == 0; } // Can just call GetSize
     
   /**
    * Test if the continuation character is at the end of the line

Modified: development/support/config/avida-smt.cfg
===================================================================
--- development/support/config/avida-smt.cfg	2006-06-20 01:12:32 UTC (rev 760)
+++ development/support/config/avida-smt.cfg	2006-06-20 23:33:04 UTC (rev 761)
@@ -13,7 +13,7 @@
 VIEW_MODE 0        # Initial viewer screen
 CLONE_FILE -       # Clone file to load
 MT_CONCURRENCY 1   # Number of concurrent analyze threads
-VERBOSITY 0        # Control output verbosity
+VERBOSITY 1        # Control output verbosity
 
 ### ARCH_GROUP ###
 # Architecture Variables

Modified: development/support/config/avida.cfg
===================================================================
--- development/support/config/avida.cfg	2006-06-20 01:12:32 UTC (rev 760)
+++ development/support/config/avida.cfg	2006-06-20 23:33:04 UTC (rev 761)
@@ -13,7 +13,7 @@
 VIEW_MODE 0        # Initial viewer screen
 CLONE_FILE -       # Clone file to load
 MT_CONCURRENCY 1   # Number of concurrent analyze threads
-VERBOSITY 0        # Control output verbosity
+VERBOSITY 1        # Control output verbosity
 
 ### ARCH_GROUP ###
 # Architecture Variables




More information about the Avida-cvs mailing list