[GRASS-SVN] r54129 - grass-addons/grass6/raster/mcda/r.mcda.ahp

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Dec 1 09:12:34 PST 2012


Author: gianluca
Date: 2012-12-01 09:12:34 -0800 (Sat, 01 Dec 2012)
New Revision: 54129

Removed:
   grass-addons/grass6/raster/mcda/r.mcda.ahp/Makefile
   grass-addons/grass6/raster/mcda/r.mcda.ahp/description.html
   grass-addons/grass6/raster/mcda/r.mcda.ahp/r.mcda.ahp.py
Log:


Deleted: grass-addons/grass6/raster/mcda/r.mcda.ahp/Makefile
===================================================================
--- grass-addons/grass6/raster/mcda/r.mcda.ahp/Makefile	2012-12-01 17:12:23 UTC (rev 54128)
+++ grass-addons/grass6/raster/mcda/r.mcda.ahp/Makefile	2012-12-01 17:12:34 UTC (rev 54129)
@@ -1,7 +0,0 @@
-MODULE_TOPDIR = ../..
-
-PGM = r.mcda.ahp
-
-include $(MODULE_TOPDIR)/include/Make/Script.make
-
-default: script

Deleted: grass-addons/grass6/raster/mcda/r.mcda.ahp/description.html
===================================================================
--- grass-addons/grass6/raster/mcda/r.mcda.ahp/description.html	2012-12-01 17:12:23 UTC (rev 54128)
+++ grass-addons/grass6/raster/mcda/r.mcda.ahp/description.html	2012-12-01 17:12:34 UTC (rev 54129)
@@ -1,33 +0,0 @@
-<h2>DESCRIPTION</h2>
-<p>The <em>r.mcda.ahp</em> Generate a raster map classified with analytic hierarchy process (AHP) [Saaty, 1977 and Saaty & Vargas, 1991]</p>
-<em>(GRASS python Script)</em>
-<p></p>
-<h2>NOTES</h2>
-<p>It is mandatory to build a pairwise comparation table with the same order of input of criteria maps in the criteria field.</p>
-<p>Example: r.mcda.ahp criteria=reclass_slope,reclass_sand,reclass_elev pairwise=pairwise output=outputMap</p>
-<p>The file "pairwise" has to have a structure like this:</p>
-<p>#start file</p>
-<p>1.0, 0.2, 3.0</p>
-<p>5.0, 1.0, 5.0</p>
-<p>0.3, 0.2, 1.0</p>
-<p>#comment: order: reclass_slope,reclass_sand,reclass_</p>
-<p>#end file</p>
-The first row and first column are related to the first criteria (reclass_slope in our case); the second row and second column are related to the second criteria (reclass_sand in our case) and the third row and third column are related to the third criteria
- ( reclass_elev in our cas), and so on.
-<p>In the work directory should be generated a log.txt file were you can find additional information like: eigenvectors, eigenvalues, weights</p>
-<h2>TODO</h2>
-<h2>SEE ALSO</h2>
-<em>
-<a href="r.roughset.html">r.roughset</a>,
-<a href="r.mcda.regime.html">r.mcda.regime</a>,
-<a href="r.mcda.fuzzy.html">r.mcda.fuzzy</a>
-<a href="r.mcda.electre.html">r.mcda.electre</a>,
-<a href="r.mcda.roughset.html">r.mcda.roughset</a>
-<a href="r.in.drsa.html">r.in.drsa</a>
-<a href="r.to.drsa.html">r.to.drsa</a>
-</em>
-<h2>AUTHORS</h2>
-Antonio Boggia - Gianluca Massei<br>
-Department of Economics and Appraisal - University of Perugia - Italy
-<p><i>Last changed: $Date$</i>
-

Deleted: grass-addons/grass6/raster/mcda/r.mcda.ahp/r.mcda.ahp.py
===================================================================
--- grass-addons/grass6/raster/mcda/r.mcda.ahp/r.mcda.ahp.py	2012-12-01 17:12:23 UTC (rev 54128)
+++ grass-addons/grass6/raster/mcda/r.mcda.ahp/r.mcda.ahp.py	2012-12-01 17:12:34 UTC (rev 54129)
@@ -1,111 +0,0 @@
-#!/usr/bin/env python
-############################################################################
-#
-# MODULE:       r.mcda.ahp
-# AUTHOR:       Gianluca Massei - Antonio Boggia
-# PURPOSE:      Generate a raster map classified with  analytic hierarchy process (AHP) [Saaty, 1977 and Saaty & Vargas, 1991]
-# COPYRIGHT:    c) 2010 Gianluca Massei, Antonio Boggia  and the GRASS 
-#                       Development Team. This program is free software under the 
-#                       GNU General PublicLicense (>=v2). Read the file COPYING 
-#                       that comes with GRASS for details.
-#
-#############################################################################
-
-
-#%Module
-#% description: Generate a raster map classified with analytic hierarchy process (AHP).
-#% keywords: raster, analytic hierarchy process (AHP), Multi Criteria Decision Analysis (MCDA)
-#%End
-#%option
-#% key: criteria
-#% type: string
-#% multiple: yes
-#% gisprompt: old,cell,raster
-#% key_desc: name
-#% description: Name of criteria raster maps 
-#% required: yes
-#%end
-#%option
-#% key: pairwise
-#% type: string
-#% gisprompt: old,file,input
-#% description: Pairwise comparison matrix
-#% required: yes
-#%end
-#%option
-#% key: output
-#% type: string
-#% gisprompt: new_file,cell,output
-#% description: output classified raster map
-#% required: yes
-#%end
-#%flag
-#% key:k 
-#% description:build a void pairwise comparison matrix and exit (no yet implemented)
-#%end
-
-import sys
-import grass.script as grass
-import numpy as np
-import warnings
-
-def calculateWeight(pairwise):
-    "Define vector of weight based on eigenvector and eigenvalues"
-    pairwise=np.genfromtxt(pairwise, delimiter=",")
-    warnings.simplefilter("ignore", np.ComplexWarning)
-    eigenvalues, eigenvector=np.linalg.eig(pairwise)
-    maxindex=np.argmax(eigenvalues)
-    eigenvalues=np.float32(eigenvalues)
-    eigenvector=np.float32(eigenvector)
-    weight=eigenvector[:, maxindex] #extract vector from eigenvector with max vaue in eigenvalues
-    weight.tolist() #convert array(numpy)  to vector
-    weight=[ w/sum(weight) for w in weight ]
-    return weight, eigenvalues,  eigenvector
-    
-def calculateMap(criteria, weight, outputMap):
-    "Parser a formula for mapcalc and run grass.mapcalc"
-    formula=''
-    for i in range(len(criteria)-1):
-        formula += "%s*%s + " % (criteria[i], weight[i])
-    formula +="%s*%s " % (criteria[len(criteria)-1], weight[len(criteria)-1])
-    grass.mapcalc(outputMap +"=" +formula)
-    return 0
-    
-def Consistency(weight,eigenvalues):
-    "Calculete Consistency index in accord with Saaty (1977)"
-    RI=[0.00, 0.00, 0.00,0.52,0.90,1.12,1.24,1.32,1.41]     #order of matrix: 0,1,2,3,4,5,6,7,8
-    order=len(weight)
-    CI= (np.max(eigenvalues)-order)/(order-1)
-    return CI/RI[order-1]
-    
-def ReportLog(eigenvalues,eigenvector, weight, consistency):
-    "Make a log file"
-    log=open("log.txt", "w")
-    log.write("eigenvalues:\n%s" % eigenvalues)
-    log.write("\neigenvector:\n%s" % eigenvector)
-    log.write("\nweight:\n%s" % weight)
-    log.write("\nconsistency:\n%s" % consistency)
-    log.close()
-    return 0
-    
-def main():
-    "main"
-    criteria = options['criteria'].split(',')
-    pairwise = options['pairwise']
-    outputMap = options['output']
-    gregion = grass.region()
-    nrows = gregion['rows']
-    ncols = gregion['cols']
-    ewres=int(gregion['ewres'])
-    nsres=int(gregion['nsres'])
-    weight, eigenvalues,  eigenvector = calculateWeight(pairwise)
-    calculateMap(criteria, weight, outputMap)
-    consistency=Consistency(weight,eigenvalues)
-    ReportLog(eigenvalues,eigenvector, weight, consistency)
-    
-    
-if __name__ == "__main__":
-    options, flags = grass.parser()
-    sys.exit(main())
-
-



More information about the grass-commit mailing list