[Avida-cvs] [avida-svn] r840 - branches/developers/avida-edward/source/python/AvidaGui2

jclune@myxo.css.msu.edu jclune at myxo.css.msu.edu
Mon Jul 17 13:39:15 PDT 2006


Author: jclune
Date: 2006-07-17 16:39:15 -0400 (Mon, 17 Jul 2006)
New Revision: 840

Modified:
   branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py
   branches/developers/avida-edward/source/python/AvidaGui2/pyMapProfile.py
   branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py
   branches/developers/avida-edward/source/python/AvidaGui2/pyPetriDishCtrl.py
   branches/developers/avida-edward/source/python/AvidaGui2/pySessionCtrl.py
   branches/developers/avida-edward/source/python/AvidaGui2/to-do_list
Log:
Fixed bugs related to lineage label map mode (cells going white, or not painted correctly on restart). Hopefully this is now working perfectly. Let me know if you see something screwy.

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py	2006-07-15 23:16:25 UTC (rev 839)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py	2006-07-17 20:39:15 UTC (rev 840)
@@ -459,10 +459,11 @@
     # If the user clicks the repopulate button pretend that they double
     # click the default empty petri dish from the freezer
 
-    print " RESTAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARTING"
     file_name = os.path.join(self.m_session_mdl.m_current_freezer, 
       "@default.empty")
     thawed_item = pyReadFreezer(file_name)
+    self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("startNewExperimentSig"),
+      ())
     self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("doDefrostDishSig"),
       ("@default.empty", thawed_item,))
     print "BDB -- in Restart_ExpActionSlot File name is " + file_name

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyMapProfile.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyMapProfile.py	2006-07-15 23:16:25 UTC (rev 839)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyMapProfile.py	2006-07-17 20:39:15 UTC (rev 840)
@@ -1,4 +1,5 @@
 
+
 from descr import *
 
 from qt import PYSIGNAL, QColor, QObject, Qt
@@ -31,7 +32,8 @@
     #GenotypeIdx = lambda c: c.GetOrganism().GetGenotype()
     LineageIdx = lambda c: c.GetOrganism().GetLineageLabel()+1
 
-    class gradualLinScaleUpdater:
+
+    class ancestorLinScaleUpdater:
       def __init__(self, range):
         self.m_range = range
         self.m_inf = 0.0
@@ -47,7 +49,6 @@
         self.m_should_reset = True
 
       def reset(self, should_reset):
-        #descr(should_reset)
         self.m_should_reset = should_reset
 
       def shouldReset(self):
@@ -82,6 +83,72 @@
           self.m_sup_rescale_rate = float(new_target_sup - self.m_sup) / self.m_updates_to_rescale
           self.m_target_sup = new_target_sup
 
+        #descr("self.m_sup", self.m_sup)
+#        if self.m_sup <= 0:
+        if self.m_sup_rescale_rate != 0:
+          if inf <= self.m_sup:
+            #self.m_sup = self.m_target_sup
+            self.m_sup += self.m_sup_rescale_rate
+          else:
+            max_rate = self.m_sup * self.m_max_rescale_factor
+            self.m_sup += min(self.m_sup_rescale_rate, max_rate)
+          if abs(self.m_target_sup - self.m_sup) < abs(self.m_sup_rescale_rate):
+            self.m_sup = self.m_target_sup
+            self.m_sup_rescale_rate = 0
+
+        return self.getRange()
+
+    class gradualLinScaleUpdater:
+      def __init__(self, range):
+        self.m_range = range
+        self.m_inf = 0.0
+        self.m_sup = 0.0
+        self.m_target_inf = 0.0
+        self.m_target_sup = 0.0
+        self.m_inf_tolerance_coeff = 0.1
+        self.m_sup_tolerance_coeff = 0.1
+        self.m_inf_rescale_rate = 0.0
+        self.m_sup_rescale_rate = 0.0
+        self.m_max_rescale_factor = 0.03
+        self.m_updates_to_rescale = 40
+        self.m_should_reset = True
+
+      def reset(self, should_reset):
+        self.m_should_reset = should_reset
+
+      def shouldReset(self):
+        descr("Testing whether I should reset", self.m_should_reset)
+        return self.m_should_reset 
+
+      def getRange(self):
+        #descr()
+        return self.m_inf, self.m_sup
+
+      def resetRange(self, population):
+        #descr(population)
+        (inf, sup) = self.m_range.getRange()
+        #descr("(inf, sup)", (inf, sup))
+        #(self.m_target_inf, self.m_target_sup) = (self.m_inf, self.m_sup) = (inf, sup)
+        (self.m_target_inf, self.m_target_sup) = (self.m_inf, self.m_sup) = (0, sup)
+        self.m_inf_rescale_rate = self.m_sup_rescale_rate = 0
+
+        return self.getRange()
+
+      def updateRange(self, population):
+        #descr(population)
+        descr("self.m_should_reset",self.m_should_reset)
+        if self.m_should_reset:
+          return self.resetRange(population)
+
+        (inf, sup) = self.m_range.getRange()
+        descr("(inf, sup)", (inf, sup))
+
+        if (sup < (1 - self.m_sup_tolerance_coeff) * self.m_target_sup) or (self.m_target_sup < sup):
+          new_target_sup = sup * (1 + self.m_sup_tolerance_coeff)
+          #self.m_sup_rescale_rate = float(new_target_sup - self.m_sup)
+          self.m_sup_rescale_rate = float(new_target_sup - self.m_sup) / self.m_updates_to_rescale
+          self.m_target_sup = new_target_sup
+
         #if (inf > (1 + self.m_inf_tolerance_coeff) * self.m_target_inf) or (self.m_target_inf > inf):
         #  new_target_inf = inf * (1 - self.m_inf_tolerance_coeff)
         #  #self.m_sup_rescale_rate = float(new_target_sup - self.m_sup)
@@ -138,20 +205,29 @@
           self.connect(
             self.m_avida.m_avida_thread_mdtr, PYSIGNAL("AvidaUpdatedSig"),
             self.avidaUpdatedSlot)
+          self.m_should_reset = True
+          self.m_session_mdl.m_max_lineages_ever = 0
+          self.m_session_mdl.m_lock_max_lineages_ever = False
+          
       def avidaUpdatedSlot(self):
         if self.m_avida and self.m_avida.m_population:
-          self.m_range = self.m_range_functor(self.m_avida.m_population)
+          self.m_range = self.m_range_functor(self.m_avida.m_population,self.m_session_mdl)
       def getRange(self):
         return self.m_range
 
-    NullRng = lambda p: (0, 0)
-    MeritRng = lambda p: (p.GetStats().GetMinMerit(), p.GetStats().GetMaxMerit())
-    FitnessRng = lambda p: (p.GetStats().GetMinFitness(), p.GetStats().GetMaxFitness())
-    GestationTimeRng = lambda p: (p.GetStats().GetMinGestationTime(), p.GetStats().GetMaxGestationTime())
-    SizeRng = lambda p: (p.GetStats().GetMinGenomeLength(), p.GetStats().GetMaxGenomeLength())
-    LineageRng = lambda p: (0, p.GetStats().GetNumLineages())
+    #q here is the session_mdl, which is only used in LineageRng
+    NullRng = lambda p,q: (0, 0)
+    MeritRng = lambda p,q: (p.GetStats().GetMinMerit(), p.GetStats().GetMaxMerit())
+    FitnessRng = lambda p,q: (p.GetStats().GetMinFitness(), p.GetStats().GetMaxFitness())
+    GestationTimeRng = lambda p,q: (p.GetStats().GetMinGestationTime(), p.GetStats().GetMaxGestationTime())
+    SizeRng = lambda p,q: (p.GetStats().GetMinGenomeLength(), p.GetStats().GetMaxGenomeLength())
+    def LineageRng (p,session_mdl):
+      m_session_mdl = session_mdl
+      if (p.GetStats().GetNumLineages() > 0) and not m_session_mdl.m_lock_max_lineages_ever:
+        m_session_mdl.m_max_lineages_ever = p.GetStats().GetNumLineages()
+        m_session_mdl.m_lock_max_lineages_ever = True
+      return (0,m_session_mdl.m_max_lineages_ever)
 
-
     def sigmoid(x, midpoint, steepness):
       val = steepness * (x - midpoint)
       return  exp(val)/(1 + exp(val))
@@ -204,7 +280,8 @@
         ),
        ('Ancestor Organism',
          continuousIndexer(LineageIdx),
-         gradualLinScaleUpdater(RangeReport(LineageRng, self.m_session_mdl)),
+         #gradualLinScaleUpdater(RangeReport(LineageRng, self.m_session_mdl)),
+         ancestorLinScaleUpdater(RangeReport(LineageRng, self.m_session_mdl)),
          sigmoidColorLookup
          ),
       #('Genotype',       GenotypeIdx,),

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py	2006-07-15 23:16:25 UTC (rev 839)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py	2006-07-17 20:39:15 UTC (rev 840)
@@ -39,6 +39,8 @@
     self.connect(self.m_petri_dish_toggle, SIGNAL("clicked()"), 
       self.ToggleDishSlot)
     self.connect(self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("startNewExperimentSig"), self.SetMapModeAndGraphModeToDefaultsSlot)
+    self.connect(self.m_session_mdl.m_session_mdtr, 
       PYSIGNAL("doDefrostDishSig"), self.DefrostSlot)
     self.connect(self.m_session_mdl.m_session_mdtr, 
        PYSIGNAL("doDisablePetriDishSig"), self.SetDishDisabledSlot)
@@ -216,6 +218,12 @@
       current_page = self.m_petri_dish_widget_stack.visibleWidget()
       current_page_int = self.m_petri_dish_widget_stack.id(current_page)
 
+  def SetMapModeAndGraphModeToDefaultsSlot(self):
+    descr()
+    self.m_mode_combobox.setCurrentItem(2)
+    self.m_mode_index = self.m_mode_combobox.currentItem()
+    self.modeActivatedSlot(self.m_mode_index)
+    
   def DefrostSlot(self, dish_name, petri_dict):
       descr()
 

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyPetriDishCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyPetriDishCtrl.py	2006-07-15 23:16:25 UTC (rev 839)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyPetriDishCtrl.py	2006-07-17 20:39:15 UTC (rev 840)
@@ -145,7 +145,8 @@
       print "pyPetriDishCtrl.setAvidaSlot() deleting old_avida ..."
       self.m_org_clicked_on_item = None
       self.m_last_cell_outlined = None
-      self.m_last_cell_outlined_color = None
+      self.m_last_cell_outlined_color = (QPen(Qt.NoPen))
+
       del old_avida
     if(self.m_avida):
       pass
@@ -185,20 +186,12 @@
     self.m_occupied_cells_ids = []
 
     if self.m_avida is not None:
-      print "ABOUT TO OUTLINE CELLS"
       m_founding_cells_dict = self.m_session_mdl.m_founding_cells_dict
 
       for k, v in m_founding_cells_dict.iteritems():
         cell_info_item = self.updateCellItem(int(k))
         cell_info_item.setPen(QPen(QColor(Qt.gray)))
 
-      print "CELLS OUTLINED"
-
-#      cell_info_item = self.updateCellItem(475)
-#      cell_info_item.setPen(QPen(QColor(Qt.gray)))
-#      why doesn't this work?
-#      cell_info_item.setBrush(QBrush(QColor((Qt.gray))))
-
     self.m_thread_work_cell_item_index = 0
     self.m_cs_min_value = 0
     self.m_cs_value_range = 0
@@ -228,17 +221,17 @@
 
   def updateOrgClickedOutlineCellNumberSlot(self, org_clicked_on_item = None):
     if self.m_org_clicked_on_item:
-      self.m_org_clicked_on_item.setPen(self.m_last_m_org_clicked_on_item_color)
+      self.m_org_clicked_on_item.setPen(self.m_last_cell_outlined_color)
     self.m_org_clicked_on_item = org_clicked_on_item
     if self.m_org_clicked_on_item:
+      self.m_last_cell_outlined_color = self.m_org_clicked_on_item.pen()
       self.updateCellItems(self.m_org_clicked_on_item.m_population_cell.GetID())
       self.m_last_m_org_clicked_on_item = self.m_org_clicked_on_item
     else:
-        if hasattr(self,"m_last_cell_outlined"):
-          if self.m_last_cell_outlined is not None:
-              print "HERE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
-              self.m_last_cell_outlined.setPen(self.m_last_m_org_clicked_on_item_color)
-              self.updateCellItems(self.m_last_m_org_clicked_on_item.m_population_cell.GetID())
+      if hasattr(self,"m_last_cell_outlined"):
+        if self.m_last_cell_outlined is not None:
+            self.m_last_cell_outlined.setPen(self.m_last_cell_outlined_color)
+            self.updateCellItems(self.m_last_m_org_clicked_on_item.m_population_cell.GetID())
 
   def updateCellItem(self, cell_id):
     if self.m_cell_info[cell_id] is None:
@@ -254,9 +247,6 @@
 
     if self.m_org_clicked_on_item:
       if cell_info_item.m_population_cell.GetID == self.m_org_clicked_on_item.m_population_cell.GetID:
-        print "COLOR ABOUT TO BE TURNED GREEN IS ", cell_info_item.pen().color().getRgb()
-#        self.m_last_m_org_clicked_on_item_color = cell_info_item.pen().color().getRgb()
-        self.m_last_m_org_clicked_on_item_color = cell_info_item.pen()
         cell_info_item.setPen(QPen(QColor(0,255,0)))
         self.m_last_cell_outlined = cell_info_item      
     return cell_info_item

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pySessionCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pySessionCtrl.py	2006-07-15 23:16:25 UTC (rev 839)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pySessionCtrl.py	2006-07-17 20:39:15 UTC (rev 840)
@@ -66,6 +66,10 @@
     # set a global variable for the location of starting cells
     self.m_session_mdl.m_founding_cells_dict = None
 
+    # set a global variable for locking the ancestor lineage map mode max range
+    self.m_session_mdl.m_max_lineages_ever = 0
+    self.m_session_mdl.m_lock_max_lineages_ever = False
+
     # BDB -- hack to overcome problem with program crashing when Core ends
 
     self.m_session_mdl.m_update_to_pause = -99

Modified: branches/developers/avida-edward/source/python/AvidaGui2/to-do_list
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/to-do_list	2006-07-15 23:16:25 UTC (rev 839)
+++ branches/developers/avida-edward/source/python/AvidaGui2/to-do_list	2006-07-17 20:39:15 UTC (rev 840)
@@ -58,7 +58,6 @@
 ************Jeff*******************
 
 Priority High
--fix the bugs with the lineage label (typically full petri dish)
 -make the org report give the name of the ancestor when they are clicked on
 -make tasks reflect parent tasks (not real time) in org report (pending group decision) (1/26/06)
 -add task information to petri dish
@@ -245,7 +244,9 @@
 -Petri dish now outlines the organisms that are about to start that run
 -Scroll bars are working again (though hard coded)
 -Scroll bars are now dynamic (30th)
+-fix the bugs with the lineage label (typically full petri dish)
 
+
 July
 -fix the prerun crashes for clicking around petri dish ancestors
 -fix the problem that the gray outline of ancestors is going away if they are clicked on then off again pre-run




More information about the Avida-cvs mailing list