[GRASS-SVN] r49199 - in grass-addons/grass7/raster/r.agent: . libagent

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Nov 13 11:46:54 EST 2011


Author: mic
Date: 2011-11-13 08:46:53 -0800 (Sun, 13 Nov 2011)
New Revision: 49199

Added:
   grass-addons/grass7/raster/r.agent/libagent/aco.py
   grass-addons/grass7/raster/r.agent/libagent/ant.py
Modified:
   grass-addons/grass7/raster/r.agent/libagent/agent.py
   grass-addons/grass7/raster/r.agent/libagent/world.py
   grass-addons/grass7/raster/r.agent/tests.py
Log:
adding stubs for new version

Added: grass-addons/grass7/raster/r.agent/libagent/aco.py
===================================================================
--- grass-addons/grass7/raster/r.agent/libagent/aco.py	                        (rev 0)
+++ grass-addons/grass7/raster/r.agent/libagent/aco.py	2011-11-13 16:46:53 UTC (rev 49199)
@@ -0,0 +1,27 @@
+############################################################################
+#
+# 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
+#
+#               This program is free software under the GNU General Public
+#               License (>=v2). Read the file COPYING that comes with GRASS
+#               for details.
+#
+#############################################################################
+
+from math import sqrt
+from math import exp
+from random import randint
+import world
+import error
+import ant
+
+class ACO(world.World):
+    """World class for using the Ant Colony Optimization Algorithm for
+       modelling Agent Based worlds."""
+    def __init__(self):
+        world.World.__init__(self)
+        world.World.__init__(self, ant.Ant)
+


Property changes on: grass-addons/grass7/raster/r.agent/libagent/aco.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native

Modified: grass-addons/grass7/raster/r.agent/libagent/agent.py
===================================================================
--- grass-addons/grass7/raster/r.agent/libagent/agent.py	2011-11-13 16:21:59 UTC (rev 49198)
+++ grass-addons/grass7/raster/r.agent/libagent/agent.py	2011-11-13 16:46:53 UTC (rev 49199)
@@ -11,8 +11,6 @@
 #
 #############################################################################
 
-import world
-
 class Agent(object):
     """Generic Agent class with limited capabilities, as a basis for
        child classes."""

Added: grass-addons/grass7/raster/r.agent/libagent/ant.py
===================================================================
--- grass-addons/grass7/raster/r.agent/libagent/ant.py	                        (rev 0)
+++ grass-addons/grass7/raster/r.agent/libagent/ant.py	2011-11-13 16:46:53 UTC (rev 49199)
@@ -0,0 +1,32 @@
+############################################################################
+#
+# 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
+#
+#               This program is free software under the GNU General Public
+#               License (>=v2). Read the file COPYING that comes with GRASS
+#               for details.
+#
+#############################################################################
+
+from random import choice, randint
+import agent
+import error
+
+class Ant(agent.Agent):
+    """Implementation of an Ant Agent for an ACO kind of World."""
+    def __init__(self, timetolive, world, position):
+        agent.Agent.__init__(self, timetolive, world, position)
+        self.position.extend([None,None,0,0])
+        self.home = self.position[:]
+        self.laststeps = [self.position[:]]
+        self.visitedsteps = []
+        self.done = False
+        self.nextstep = [None,None,0,0,0,0]
+        self.goal = []
+        self.penalty = 0.0
+#
+
+


Property changes on: grass-addons/grass7/raster/r.agent/libagent/ant.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native

Modified: grass-addons/grass7/raster/r.agent/libagent/world.py
===================================================================
--- grass-addons/grass7/raster/r.agent/libagent/world.py	2011-11-13 16:21:59 UTC (rev 49198)
+++ grass-addons/grass7/raster/r.agent/libagent/world.py	2011-11-13 16:46:53 UTC (rev 49199)
@@ -11,6 +11,10 @@
 #
 #############################################################################
 
+import agent
+import playground
+import error
+
 class World(object):
     """Generic World class as basis for more complex worlds."""
     def __init__(self, agenttype=None, pg=None):

Modified: grass-addons/grass7/raster/r.agent/tests.py
===================================================================
--- grass-addons/grass7/raster/r.agent/tests.py	2011-11-13 16:21:59 UTC (rev 49198)
+++ grass-addons/grass7/raster/r.agent/tests.py	2011-11-13 16:46:53 UTC (rev 49199)
@@ -50,17 +50,36 @@
     """Test suite for Class: World"""
     w = world.World()
 
+def testACO():
+    """Test suite for World-Class: ACO"""
+    w = aco.ACO()
 
+def testAgent(ttl):
+    """Test suite for Class: Agent"""
+    w = world.World()
+    w = agent.Agent(ttl, w)
+
+def testAnt(ttl, position):
+    """Test suite for Agent-Class: Ant"""
+    w = world.World()
+    w = ant.Ant(ttl, w, position)
+
 if __name__ == "__main__":
     """Main method for testing when run as a script."""
     import sys
     from libagent import error
     from libagent import playground
     from libagent import world
+    from libagent import aco
+    from libagent import agent
+    from libagent import ant
 
     alltests = {"error":[testError, ["Error Test Suite", "(this error is good)"]],
                 "playground":[testPlayground, []],
-                "world":[testWorld, []]}
+                "world":[testWorld, []],
+                "aco":[testACO, []],
+                "Agent":[testAgent, [1]],
+                "Ant":[testAnt, [1, []]]}
 
     if len(sys.argv) == 1:
         for test,details in alltests.iteritems():



More information about the grass-commit mailing list