[Avida-SVN] r2163 - branches/developers/avida-edward/source/python/AvidaGui2

kaben at myxo.css.msu.edu kaben at myxo.css.msu.edu
Tue Oct 30 19:31:15 PDT 2007


Author: kaben
Date: 2007-10-30 22:31:15 -0400 (Tue, 30 Oct 2007)
New Revision: 2163

Modified:
   branches/developers/avida-edward/source/python/AvidaGui2/Avida_ED_startup_utils.py
   branches/developers/avida-edward/source/python/AvidaGui2/pyAvidaThreadedDriver.py
   branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py
   branches/developers/avida-edward/source/python/AvidaGui2/pyPetriConfigureCtrl.py
   branches/developers/avida-edward/source/python/AvidaGui2/pySessionCtrl.py
   branches/developers/avida-edward/source/python/AvidaGui2/pyWriteGenesisEvent.py
Log:
Fixed the following bugs in Avida-ED:
- Runs could not be repeated.
- Processing thread sometimes tried to continue processing after it had been
  deleted, causing memory trashing.
- Workaround for processing thread bug prevented deleting populations until app
  exit, a known memory leak.


Modified: branches/developers/avida-edward/source/python/AvidaGui2/Avida_ED_startup_utils.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/Avida_ED_startup_utils.py	2007-10-30 22:02:46 UTC (rev 2162)
+++ branches/developers/avida-edward/source/python/AvidaGui2/Avida_ED_startup_utils.py	2007-10-31 02:31:15 UTC (rev 2163)
@@ -14,6 +14,8 @@
 s_splash.message("Loading core Avida modules ...")
 
 import AvidaCore
+
+import os
 import sys
 
 from descr import descr, info, question, warning, critical
@@ -102,6 +104,59 @@
   return edu_main_controller
 
 
+res_dir = os.getcwd()
+
+def AvidaConsole():
+  sys.exc_clear()
+  sys.exc_traceback = sys.last_traceback = None
+  s_splash.message("Loading Avida-ED in console mode ...")
+  s_splash.show()
+
+  avida = None
+
+  genesis_file_name = "./genesis.default"
+
+  try:
+    Reload()
+    from pyAvida import pyAvida
+
+    s_splash.message("Running Avida-ED in console mode ...")
+
+    os.chdir(os.path.join(res_dir, "console_work"))
+    print "os.getcwd()", os.getcwd()
+    genesis = AvidaCore.cGenesis()
+    genesis.Open(AvidaCore.cString(genesis_file_name))
+    if 0 == genesis.IsOpen():
+      print "Unable to find file " + genesis_file_name
+      return None
+    avida = pyAvida()
+    avida.construct(genesis)
+
+  finally:
+    s_splash.clear()
+    s_splash.hide()
+
+    # BDB temporarily turn off prompting for new/existing workspace at
+    # the beginning of a new program.  Leave just in case we decide to
+    # go back to this system
+    #
+    # edu_main_controller.m_prompt_for_workspace_ctrl.showDialog()
+    print """
+    
+    To disable debugging messages, type 'AvidaGui2.descr.DEBUG = False'.
+
+    Type 'avida_ed=AvidaEd()' to reload the AvidaEd user interface.
+    
+    """
+  return avida
+
+def LoopTest():
+  for i in range(10):
+    avida = AvidaConsole()
+    for j in range(200):
+      avida.m_avida_threaded_driver.ProcessUpdate()
+    os.rename('average.dat', 'average.dat.%d' % i)
+
 # Instantiate (or reinstantiate) the Avida-ED gui. Return controller for
 # new gui instance.
 #

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyAvidaThreadedDriver.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyAvidaThreadedDriver.py	2007-10-30 22:02:46 UTC (rev 2162)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyAvidaThreadedDriver.py	2007-10-31 02:31:15 UTC (rev 2163)
@@ -1,5 +1,5 @@
 
-from AvidaCore import pyAvidaDriver
+from AvidaCore import pyAvidaDriver, cTools
 import atexit, threading
 
 from descr import descr
@@ -45,6 +45,10 @@
       self.m_do_update_semaphore.acquire()
       # begin update.
       self.m_lock.acquire()
+      if self.getDoneFlag():
+        self.m_lock.release()
+        self.m_updated_semaphore.release()
+        return
       self.m_updating = self.ProcessSome(self.m_process_bitesize)
       while self.m_updating:
         # yield lock to other threads.

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py	2007-10-30 22:02:46 UTC (rev 2162)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py	2007-10-31 02:31:15 UTC (rev 2163)
@@ -52,26 +52,14 @@
     while self.m_widget_stack.visibleWidget():
       self.m_widget_stack.removeWidget(self.m_widget_stack.visibleWidget())
 
-    self.m_one_population_ctrl  = pyOnePopulationCtrl(self.m_widget_stack,  
-                                    "m_one_population_ctrl")
-    self.m_two_population_ctrl  = pyTwoPopulationCtrl(self.m_widget_stack,  
-                                    "m_two_population_ctrl")
-    self.m_one_organism_ctrl    = pyOneOrganismCtrl(self.m_widget_stack,    
-                                    "m_one_organism_ctrl")
-    self.m_two_organism_ctrl    = pyTwoOrganismCtrl(self.m_widget_stack,    
-                                    "m_two_organism_ctrl")
-    self.m_one_analyze_ctrl     = pyOneAnalyzeCtrl(self.m_widget_stack,     
-                                    "m_one_analyze_ctrl")
-    self.m_two_analyze_ctrl     = pyTwoAnalyzeCtrl(self.m_widget_stack,     
-                                    "m_two_analyze_ctrl")
+    self.m_one_population_ctrl  = pyOnePopulationCtrl(self.m_widget_stack, "m_one_population_ctrl")
+    self.m_one_organism_ctrl    = pyOneOrganismCtrl(self.m_widget_stack, "m_one_organism_ctrl")
+    self.m_one_analyze_ctrl     = pyOneAnalyzeCtrl(self.m_widget_stack, "m_one_analyze_ctrl")
 
     for (cli, ctrl) in (
       (self.m_nav_bar_ctrl.m_one_population_cli, self.m_one_population_ctrl),
-#      (self.m_nav_bar_ctrl.m_two_population_cli, self.m_two_population_ctrl),
       (self.m_nav_bar_ctrl.m_one_organism_cli,   self.m_one_organism_ctrl),
-#      (self.m_nav_bar_ctrl.m_two_organism_cli,   self.m_two_organism_ctrl),
       (self.m_nav_bar_ctrl.m_one_analyze_cli,    self.m_one_analyze_ctrl),
-#      (self.m_nav_bar_ctrl.m_two_analyze_cli,    self.m_two_analyze_ctrl),
     ):
       self.m_cli_to_ctrl_dict[cli] = ctrl
       self.m_ctrl_to_cli_dict[ctrl] = cli

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyPetriConfigureCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyPetriConfigureCtrl.py	2007-10-30 22:02:46 UTC (rev 2162)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyPetriConfigureCtrl.py	2007-10-31 02:31:15 UTC (rev 2163)
@@ -600,9 +600,14 @@
     if 0 == genesis.IsOpen():
       warningNoMethodName("Unable to find file " +  genesisFileName)
       return
+    descr("self.setAvidaSlot(None) ...")
+    self.setAvidaSlot(None)
+    descr("self.setAvidaSlot(None) done.")
     avida = pyAvida()
     avida.construct(genesis)
+    descr("self.setAvidaSlot(avida) ...")
     self.setAvidaSlot(avida)
+    descr("self.setAvidaSlot(avida) done.")
 
     # Stops self from hearing own setAvidaSig signal
 

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pySessionCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pySessionCtrl.py	2007-10-30 22:02:46 UTC (rev 2162)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pySessionCtrl.py	2007-10-31 02:31:15 UTC (rev 2163)
@@ -5,7 +5,7 @@
 from pySessionControllerFactory import *
 from pyBeforeStartingCtrl import *
 
-from AvidaCore import cString
+from AvidaCore import cRandom, cString, cTools 
 
 import qt
 
@@ -29,6 +29,8 @@
       self.m_session_mdl.m_session_mdtr, PYSIGNAL("setAvidaSig"),
       self.setAvidaSlot)
     # print "pySessionCtrl.__del__() sending setAvidaSig(None) ..."
+    self.m_session_mdl.m_session_mdtr.emit(
+      qt.PYSIGNAL("setAvidaSig"), (None,))
 
     # print 'pySessionCtrl.__del__() done.'
 

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyWriteGenesisEvent.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyWriteGenesisEvent.py	2007-10-30 22:02:46 UTC (rev 2162)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyWriteGenesisEvent.py	2007-10-31 02:31:15 UTC (rev 2163)
@@ -115,7 +115,9 @@
     #   I need to make a merits_dict with organism number as key, and
     #   merit as value.
     genesis = cGenesis()
+
     cConfig.Setup(genesis)
+
     genesis.Open(cString(genesis_file_name))
     environment = cEnvironment()
     environment.Load(cString(settings_dict["ENVIRONMENT_FILE"]))
@@ -138,7 +140,11 @@
     for key in organisms_dict.keys():
       genome = organisms_dict[key]
       analyze_genotype = cAnalyzeGenotype(cString(genome), inst_set) 
+
+      random_number_generator_state = cRandom(cTools.globalRandom())
       analyze_genotype.Recalculate()
+      cTools.globalRandom().Clone(random_number_generator_state)
+
       merit = analyze_genotype.GetMerit()
       merits_dict[key] = merit
 




More information about the Avida-cvs mailing list