[GRASS-SVN] r54860 - grass-addons/grass7/raster/r.agent/libagent

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Feb 3 02:19:13 PST 2013


Author: mic
Date: 2013-02-03 02:19:12 -0800 (Sun, 03 Feb 2013)
New Revision: 54860

Modified:
   grass-addons/grass7/raster/r.agent/libagent/aco.py
   grass-addons/grass7/raster/r.agent/libagent/ant.py
Log:
starting ACO and use super()

Modified: grass-addons/grass7/raster/r.agent/libagent/aco.py
===================================================================
--- grass-addons/grass7/raster/r.agent/libagent/aco.py	2013-02-03 10:12:53 UTC (rev 54859)
+++ grass-addons/grass7/raster/r.agent/libagent/aco.py	2013-02-03 10:19:12 UTC (rev 54860)
@@ -13,6 +13,7 @@
 import world
 import ant
 
+from sys import maxsize
 from math import sqrt
 from math import exp
 from random import randint
@@ -21,5 +22,15 @@
     """World class for using the Ant Colony Optimization Algorithm for
        modelling Agent Based worlds."""
     def __init__(self):
-        world.World.__init__(self, ant.Ant)
+        # get all attributes from the basic world
+        super(ACO, self).__init__(ant.Ant)
+        # add the main layers
+        ## one containing the points of interest
+        self.addlayertopg("sitemap")
+        ## one containing the time cost for traversing cells
+        self.addlayertopg("penaltymap")
+        ## and finally the markings from the agents
+        self.addlayertopg("pheromap")
+        # list of the points of origin / sites
+        self.holes = []
 

Modified: grass-addons/grass7/raster/r.agent/libagent/ant.py
===================================================================
--- grass-addons/grass7/raster/r.agent/libagent/ant.py	2013-02-03 10:12:53 UTC (rev 54859)
+++ grass-addons/grass7/raster/r.agent/libagent/ant.py	2013-02-03 10:19:12 UTC (rev 54860)
@@ -23,7 +23,7 @@
         @param World the agent knows the worlds he lives in
         @param list coordinate of the current position
         """
-        agent.Agent.__init__(self, timetolive, world, position)
+        super(Ant, self).__init__(timetolive, world, freedom, position)
         self.position.extend([None,None,0,0])
         self.home = self.position[:]
         self.laststeps = [self.position[:]]



More information about the grass-commit mailing list