[Avida-SVN] r2496 - in development: Avida.xcodeproj source source/analyze source/main source/tools

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Sun Mar 23 20:50:24 PDT 2008


Author: brysonda
Date: 2008-03-23 23:50:24 -0400 (Sun, 23 Mar 2008)
New Revision: 2496

Added:
   development/source/tools/cConstBurstSchedule.cc
   development/source/tools/cConstBurstSchedule.h
Modified:
   development/Avida.xcodeproj/project.pbxproj
   development/source/analyze/cAnalyze.cc
   development/source/defs.h
   development/source/main/cAvidaConfig.h
   development/source/main/cPopulation.cc
   development/source/tools/cConstSchedule.cc
   development/source/tools/cConstSchedule.h
Log:
Add a new scheduler, cConstBurstSchedule. Will schedule organisms in SLICING_BURST_SIZE batches of instructions.  When SLICING_BURST_SIZE = 1 this scheduler is functionally equivalent to cConstSchedule.

Also change a cPopulation if statement that looked like it should be a comparison rather then an assignment.

Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj	2008-03-23 21:33:47 UTC (rev 2495)
+++ development/Avida.xcodeproj/project.pbxproj	2008-03-24 03:50:24 UTC (rev 2496)
@@ -201,6 +201,7 @@
 		70B6514F0BEA6FCC002472ED /* main.cc in Sources */ = {isa = PBXBuildFile; fileRef = 701EF27E0BEA5D2300DAE168 /* main.cc */; };
 		70B651B70BEA9AEC002472ED /* unit-tests in CopyFiles */ = {isa = PBXBuildFile; fileRef = 70B6514C0BEA6FAD002472ED /* unit-tests */; };
 		70DCAC9C097AF7C0002F8733 /* primitive.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70DCAC9B097AF7C0002F8733 /* primitive.cc */; };
+		70EFD6600D975B6E00FAD32A /* cConstBurstSchedule.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70EFD65F0D975B5E00FAD32A /* cConstBurstSchedule.cc */; };
 		B4FA258A0C5EB65E0086D4B5 /* cPlasticPhenotype.cc in Sources */ = {isa = PBXBuildFile; fileRef = B4FA25810C5EB6510086D4B5 /* cPlasticPhenotype.cc */; };
 		B4FA25A90C5EB7880086D4B5 /* cPhenPlastGenotype.cc in Sources */ = {isa = PBXBuildFile; fileRef = B4FA259E0C5EB7600086D4B5 /* cPhenPlastGenotype.cc */; };
 		B516AF840C91E2D400023D53 /* cDemeCellEvent.cc in Sources */ = {isa = PBXBuildFile; fileRef = B516AF790C91E24600023D53 /* cDemeCellEvent.cc */; };
@@ -822,6 +823,8 @@
 		70DCF58009CFBD3D00924128 /* tcmalloc-logging.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = "tcmalloc-logging.h"; sourceTree = "<group>"; };
 		70E130BF0C442B2900CE9249 /* cCoords.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cCoords.h; sourceTree = "<group>"; };
 		70E130E30C4551E900CE9249 /* cASTVisitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cASTVisitor.h; sourceTree = "<group>"; };
+		70EFD65E0D975B5E00FAD32A /* cConstBurstSchedule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cConstBurstSchedule.h; sourceTree = "<group>"; };
+		70EFD65F0D975B5E00FAD32A /* cConstBurstSchedule.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cConstBurstSchedule.cc; sourceTree = "<group>"; };
 		70F7DAEF09290468009E311D /* cClassificationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cClassificationManager.h; sourceTree = "<group>"; };
 		70F7DAF009290468009E311D /* cClassificationManager.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cClassificationManager.cc; sourceTree = "<group>"; };
 		70F7DC9E09293E6F009E311D /* cGenotype.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cGenotype.cc; sourceTree = "<group>"; };
@@ -1606,6 +1609,8 @@
 				70BCB2470AB7B634003FF331 /* cArgSchema.h */,
 				703D4D6D0ABA374A0032C8A0 /* cArgSchema.cc */,
 				70F9FD990C4E89C40083B788 /* tAutoRelease.h */,
+				70EFD65E0D975B5E00FAD32A /* cConstBurstSchedule.h */,
+				70EFD65F0D975B5E00FAD32A /* cConstBurstSchedule.cc */,
 			);
 			path = tools;
 			sourceTree = "<group>";
@@ -2014,6 +2019,7 @@
 				7076FEB10D347FD000556CAF /* cAnalyzeTreeStats_Gamma.cc in Sources */,
 				70A778390D69D5CA00735F1E /* cDemeProbSchedule.cc in Sources */,
 				2A57A3FF0D6B954D00FC54C7 /* cProbDemeProbSchedule.cc in Sources */,
+				70EFD6600D975B6E00FAD32A /* cConstBurstSchedule.cc in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: development/source/analyze/cAnalyze.cc
===================================================================
--- development/source/analyze/cAnalyze.cc	2008-03-23 21:33:47 UTC (rev 2495)
+++ development/source/analyze/cAnalyze.cc	2008-03-24 03:50:24 UTC (rev 2496)
@@ -7106,7 +7106,7 @@
   }
 
   // test cpu
-  cTestCPU* testcpu = m_world->GetHardwareManager().CreateTestCPU();
+  //cTestCPU* testcpu = m_world->GetHardwareManager().CreateTestCPU();
   
   // get current batch
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());

Modified: development/source/defs.h
===================================================================
--- development/source/defs.h	2008-03-23 21:33:47 UTC (rev 2495)
+++ development/source/defs.h	2008-03-24 03:50:24 UTC (rev 2496)
@@ -97,7 +97,8 @@
   SLICE_PROB_MERIT,
   SLICE_INTEGRATED_MERIT,
   SLICE_DEME_PROB_MERIT,
-  SLICE_PROB_DEMESIZE_PROB_MERIT
+  SLICE_PROB_DEMESIZE_PROB_MERIT,
+  SLICE_CONSTANT_BURST,
 };
 
 enum ePOSITION_CHILD

Modified: development/source/main/cAvidaConfig.h
===================================================================
--- development/source/main/cAvidaConfig.h	2008-03-23 21:33:47 UTC (rev 2495)
+++ development/source/main/cAvidaConfig.h	2008-03-24 03:50:24 UTC (rev 2496)
@@ -389,7 +389,8 @@
   
   CONFIG_ADD_GROUP(TIME_GROUP, "Time Slicing");
   CONFIG_ADD_VAR(AVE_TIME_SLICE, int, 30, "Ave number of insts per org per update");
-  CONFIG_ADD_VAR(SLICING_METHOD, int, 1, "0 = CONSTANT: all organisms get default...\n1 = PROBABILISTIC: Run _prob_ proportional to merit.\n2 = INTEGRATED: Perfectly integrated deterministic.\n3 = DemeProbabalistic, each deme gets the same number of CPU cycles, which are awarded probabalistically within each deme.\n4 = ProbDemeProbabalistic, each deme gets CPU cycles proportional to its living population size, which are awarded probabalistically within each deme.");
+  CONFIG_ADD_VAR(SLICING_METHOD, int, 1, "0 = CONSTANT: all organisms get default...\n1 = PROBABILISTIC: Run _prob_ proportional to merit.\n2 = INTEGRATED: Perfectly integrated deterministic.\n3 = DemeProbabalistic, each deme gets the same number of CPU cycles, which are awarded probabalistically within each deme.\n4 = ProbDemeProbabalistic, each deme gets CPU cycles proportional to its living population size, which are awarded probabalistically within each deme.\n5 = CONSTANT BURST: all organisms get default, in SLICING_BURST_SIZE chunks");
+  CONFIG_ADD_VAR(SLICING_BURST_SIZE, int, 1, "Sets the scheduler burst size, when supported.");
   CONFIG_ADD_VAR(BASE_MERIT_METHOD, int, 4, "0 = Constant (merit independent of size)\n1 = Merit proportional to copied size\n2 = Merit prop. to executed size\n3 = Merit prop. to full size\n4 = Merit prop. to min of executed or copied size\n5 = Merit prop. to sqrt of the minimum size\n6 = Merit prop. to num times MERIT_BONUS_INST is in genome.");
   CONFIG_ADD_VAR(BASE_CONST_MERIT, int, 100, "Base merit when BASE_MERIT_METHOD set to 0");
   CONFIG_ADD_VAR(DEFAULT_BONUS, double, 1.0, "Initial bonus before any tasks");

Modified: development/source/main/cPopulation.cc
===================================================================
--- development/source/main/cPopulation.cc	2008-03-23 21:33:47 UTC (rev 2495)
+++ development/source/main/cPopulation.cc	2008-03-24 03:50:24 UTC (rev 2496)
@@ -29,6 +29,7 @@
 #include "cChangeList.h"
 #include "cClassificationManager.h"
 #include "cCodeLabel.h"
+#include "cConstBurstSchedule.h"
 #include "cConstSchedule.h"
 #include "cDataFile.h"
 #include "cDemeProbSchedule.h"
@@ -2278,7 +2279,7 @@
 
       //get a random direction to move in deme list
       int rnd_deme_id = m_world->GetRandom().GetInt(1);
-      if (rnd_deme_id = 0) rnd_deme_id = -1;
+      if (rnd_deme_id == 0) rnd_deme_id = -1;
       
       //set the new deme_id
       deme_id = (deme_id + rnd_deme_id + deme_array.GetSize()) % deme_array.GetSize();
@@ -3286,6 +3287,8 @@
     case SLICE_INTEGRATED_MERIT:
       schedule = new cIntegratedSchedule(cell_array.GetSize());
       break;
+    case SLICE_CONSTANT_BURST:
+      schedule = new cConstBurstSchedule(cell_array.GetSize(), m_world->GetConfig().SLICING_BURST_SIZE.Get());
     default:
       cout << "Warning: Requested Time Slicer not found, defaulting to Integrated." << endl;
       schedule = new cIntegratedSchedule(cell_array.GetSize());
@@ -3884,10 +3887,9 @@
  
   //Rescale by the geometric mean of the difference from the top score and the average
   if ( dynamic_scaling == 1 ) {
-    int num_org_not_max = 0;
     double dynamic_factor = 1.0;
     if (highest_fitness > 0) {
-      dynamic_factor = 2/highest_fitness;
+      dynamic_factor = 2 / highest_fitness;
     }
     
     total_fitness = 0;

Added: development/source/tools/cConstBurstSchedule.cc
===================================================================
--- development/source/tools/cConstBurstSchedule.cc	                        (rev 0)
+++ development/source/tools/cConstBurstSchedule.cc	2008-03-24 03:50:24 UTC (rev 2496)
@@ -0,0 +1,51 @@
+/*
+ *  cConstBurstSchedule.cc
+ *  Avida
+ *
+ *  Created by David on 3/23/08.
+ *  Copyright 2008 Michigan State University. All rights reserved.
+ *
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  as published by the Free Software Foundation; version 2
+ *  of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ */
+
+#include "cConstBurstSchedule.h"
+
+#include "cChangeList.h"
+#include "cMerit.h"
+
+
+bool cConstBurstSchedule::OK() { return true; }
+
+void cConstBurstSchedule::Adjust(int item_id, const cMerit& merit, int deme_id)
+{
+  if (cChangeList *change_list = GetChangeList()) change_list->MarkChange(item_id);
+
+  if (merit == 0.0) m_active[item_id] = false;
+  else m_active[item_id] = true;
+}
+
+
+int cConstBurstSchedule::GetNextID()
+{
+  // If the current id is no longer active or the burst has finished, move on to the next
+  if (!m_active[m_cur_id] || ++m_burst_state == m_burst_sz) {
+    m_burst_state = 0;
+    while (!m_active[m_cur_id]) if (++m_cur_id == item_count) m_cur_id = 0;
+  }
+  
+  return m_cur_id;
+}

Added: development/source/tools/cConstBurstSchedule.h
===================================================================
--- development/source/tools/cConstBurstSchedule.h	                        (rev 0)
+++ development/source/tools/cConstBurstSchedule.h	2008-03-24 03:50:24 UTC (rev 2496)
@@ -0,0 +1,68 @@
+/*
+ *  cConstBurstSchedule.h
+ *  Avida
+ *
+ *  Created by David on 3/23/08.
+ *  Copyright 2008 Michigan State University. All rights reserved.
+ *
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  as published by the Free Software Foundation; version 2
+ *  of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ */
+
+#ifndef cConstBurstSchedule_h
+#define cConstBurstSchedule_h
+
+#ifndef cSchedule_h
+#include "cSchedule.h"
+#endif
+#ifndef tArray_h
+#include "tArray.h"
+#endif
+
+class cMerit;
+
+/**
+ * This class rotates between all items to schedule, giving each equal time.
+ **/
+class cConstBurstSchedule : public cSchedule
+  {
+  private:
+    int m_burst_sz;
+    tArray<bool> m_active;
+
+    int m_cur_id;
+    int m_burst_state;
+    
+    
+    cConstBurstSchedule(); // @not_implemented
+    cConstBurstSchedule(const cConstBurstSchedule&); // @not_implemented
+    cConstBurstSchedule& operator=(const cConstBurstSchedule&); // @not_implemented
+    
+    
+  public:
+    cConstBurstSchedule(int item_sz, int burst_sz)
+      : cSchedule(item_sz), m_burst_sz(burst_sz), m_active(item_sz), m_cur_id(0), m_burst_state(0)
+    {
+      m_active.SetAll(false);
+    }
+    ~cConstBurstSchedule() { ; }
+    
+    bool OK();
+    void Adjust(int item_id, const cMerit& merit, int deme_id = 0);
+    int GetNextID();
+  };
+
+#endif

Modified: development/source/tools/cConstSchedule.cc
===================================================================
--- development/source/tools/cConstSchedule.cc	2008-03-23 21:33:47 UTC (rev 2495)
+++ development/source/tools/cConstSchedule.cc	2008-03-24 03:50:24 UTC (rev 2496)
@@ -25,7 +25,6 @@
 
 #include "cConstSchedule.h"
 
-#include "cDeme.h"
 #include "cChangeList.h"
 #include "cMerit.h"
 

Modified: development/source/tools/cConstSchedule.h
===================================================================
--- development/source/tools/cConstSchedule.h	2008-03-23 21:33:47 UTC (rev 2495)
+++ development/source/tools/cConstSchedule.h	2008-03-24 03:50:24 UTC (rev 2496)
@@ -33,7 +33,6 @@
 #include "tArray.h"
 #endif
 
-class cDeme;
 class cMerit;
 
 /**




More information about the Avida-cvs mailing list