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

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Nov 14 10:20:20 PST 2015


Author: mic
Date: 2015-11-14 10:20:20 -0800 (Sat, 14 Nov 2015)
New Revision: 66827

Modified:
   grass-addons/grass7/raster/r.agent/libagent/ant.py
   grass-addons/grass7/raster/r.agent/libagent/anthill.py
   grass-addons/grass7/raster/r.agent/libagent/grassland.py
   grass-addons/grass7/raster/r.agent/libagent/playground.py
   grass-addons/grass7/raster/r.agent/libagent/world.py
Log:
improve documentation comments

Modified: grass-addons/grass7/raster/r.agent/libagent/ant.py
===================================================================
--- grass-addons/grass7/raster/r.agent/libagent/ant.py	2015-11-13 15:22:36 UTC (rev 66826)
+++ grass-addons/grass7/raster/r.agent/libagent/ant.py	2015-11-14 18:20:20 UTC (rev 66827)
@@ -15,8 +15,20 @@
 #from grass.script import core as grass
 
 class Ant(agent.Agent):
-    """Implementation of an Ant Agent for an Anthill, an ACO kind of World."""
+    """
+    Implementation of an Ant like Agent for an Anthill, a kind of World
+    that works after ACO rules (see Anthill).
 
+    Ants are wandering around by chance until they find some goal cell,
+    then they will mark their way back home with pheromone. Following ants
+    choose the marked cells on the playground more likely then unmarked
+    spots.
+
+    There are several optimizations / idealizations to choose from,
+    as ACO comes from graph theory and raster layers map quite large
+    graphs (e.g. loops are a major source of sorrow).
+    """
+
     def __init__(self, timetolive, world, position):
         """
         Create an Agent for an Anthill World

Modified: grass-addons/grass7/raster/r.agent/libagent/anthill.py
===================================================================
--- grass-addons/grass7/raster/r.agent/libagent/anthill.py	2015-11-13 15:22:36 UTC (rev 66826)
+++ grass-addons/grass7/raster/r.agent/libagent/anthill.py	2015-11-14 18:20:20 UTC (rev 66827)
@@ -2,7 +2,7 @@
 MODULE:       r.agent.*
 AUTHOR(S):    michael lustenberger inofix.ch
 PURPOSE:      library file for the r.agent.* suite
-COPYRIGHT:    (C) 2011 by Michael Lustenberger and the GRASS Development Team
+COPYRIGHT:    (C) 2015 by Michael Lustenberger and the GRASS Development Team
 
               This program is free software under the GNU General Public
               License (>=v2). Read the file COPYING that comes with GRASS
@@ -19,8 +19,15 @@
 
 class Anthill(world.World):
     """
-    World class for using the Ant Colony Optimization Algorithm for
-    modelling Agent Based worlds.
+    This kind of world makes use of the Ant Colony Optimization (ACO)
+    algorithm for coordinating its agent's actions (for ACO, see
+    https://en.wikipedia.org/wiki/Ant_colony_optimization_algorithms).
+
+    The agents are implemented as ants, wandering around by chance
+    if they find a goal cell they will mark their way back home
+    with pheromone. The following ants then choose the marked cells
+    on the playground more likely then unmarked spots. The pheromone
+    evaporates over time.
     """
     # constant names for the layers
     SITE = "sitemap"
@@ -29,8 +36,8 @@
 
     def __init__(self, pg=None):
         """
-        Create a world based on the natural laws of the Ant Colony Optimization
-        algorithm (plus adaptions honouring the complexity of the raster case).
+        Create a world based on the natural laws of the ACO algorithm
+        (plus adaptions honouring the complexity of the raster case).
         """
         # get all attributes from the basic world
         super(Anthill, self).__init__(pg, ant.Ant)

Modified: grass-addons/grass7/raster/r.agent/libagent/grassland.py
===================================================================
--- grass-addons/grass7/raster/r.agent/libagent/grassland.py	2015-11-13 15:22:36 UTC (rev 66826)
+++ grass-addons/grass7/raster/r.agent/libagent/grassland.py	2015-11-14 18:20:20 UTC (rev 66827)
@@ -2,7 +2,7 @@
 MODULE:       r.agent.*
 AUTHOR(S):    michael lustenberger inofix.ch
 PURPOSE:      library file for the r.agent.* suite
-COPYRIGHT:    (C) 2011 by Michael Lustenberger and the GRASS Development Team
+COPYRIGHT:    (C) 2015 by Michael Lustenberger and the GRASS Development Team
 
               This program is free software under the GNU General Public
               License (>=v2). Read the file COPYING that comes with GRASS
@@ -14,8 +14,14 @@
 from grass.script import array as garray
 
 class Grassland(playground.Playground):
-    """A GrassLand is a Playground and the interface to GRASS."""
+    """
+    A GrassLand is a Playground and the interface to GRASS.
 
+    Besides the plain raster layers it also connects them to the
+    layer names used in GRASS and it can parse vector layers (for
+    now only point vectors though) from GRASS too.
+    """
+
     # internal logging class name
     ME = "r.agent::libagent.grassland.Grassland()"
 

Modified: grass-addons/grass7/raster/r.agent/libagent/playground.py
===================================================================
--- grass-addons/grass7/raster/r.agent/libagent/playground.py	2015-11-13 15:22:36 UTC (rev 66826)
+++ grass-addons/grass7/raster/r.agent/libagent/playground.py	2015-11-14 18:20:20 UTC (rev 66827)
@@ -2,7 +2,7 @@
 MODULE:       r.agent.*
 AUTHOR(S):    michael lustenberger inofix.ch
 PURPOSE:      library file for the r.agent.* suite
-COPYRIGHT:    (C) 2011 by Michael Lustenberger and the GRASS Development Team
+COPYRIGHT:    (C) 2015 by Michael Lustenberger and the GRASS Development Team
 
               This program is free software under the GNU General Public
               License (>=v2). Read the file COPYING that comes with GRASS
@@ -14,8 +14,9 @@
 
 class Playground(object):
     """
-    A Playground is a major component of a World, defining
-    and organizing space.
+    A Playground is a major component of a World, defining and organizing
+    space, i.e. it mainly consists of a set of raster layers, makes
+    them accessible and puts them in relation to one another.
     """
     STRAIGHT = 0
     DIAGONAL = sqrt(2)-1

Modified: grass-addons/grass7/raster/r.agent/libagent/world.py
===================================================================
--- grass-addons/grass7/raster/r.agent/libagent/world.py	2015-11-13 15:22:36 UTC (rev 66826)
+++ grass-addons/grass7/raster/r.agent/libagent/world.py	2015-11-14 18:20:20 UTC (rev 66827)
@@ -2,7 +2,7 @@
 MODULE:       r.agent.*
 AUTHOR(S):    michael lustenberger inofix.ch
 PURPOSE:      library file for the r.agent.* suite
-COPYRIGHT:    (C) 2011 by Michael Lustenberger and the GRASS Development Team
+COPYRIGHT:    (C) 2015 by Michael Lustenberger and the GRASS Development Team
 
               This program is free software under the GNU General Public
               License (>=v2). Read the file COPYING that comes with GRASS
@@ -16,7 +16,16 @@
 from math import sqrt
 
 class World(object):
-    """Generic World class as basis for more complex worlds."""
+    """
+    Generic World class as basis for more complex worlds.
+    A world is a place where things happen. A world normally
+    consists of some playground, i.e. a setup of various
+    layers. Furthermore it holds a list of agents that will
+    act in that world, e.g. change values on layers. More
+    complex worlds might also hold lists of some artefacts
+    (e.g. attractors) or vector-coordinates to indicate points
+    on the playground...
+    """
     # walking constants
     ## agents default ability to move
     FREEDOM = 8



More information about the grass-commit mailing list