gluc / ahp

Analytical Hierarchy Process (AHP) with R
98 stars 41 forks source link

Load() is not reading pairwise #7

Closed xhan85 closed 7 years ago

xhan85 commented 8 years ago

I have made a yaml file and am trying to use the ahp package. I can use the yaml.load_file function but cannot use Load() because it returns that it cannot load the ahp model. I have found that it's running into problems with the pairwise comparison sections under preferences. When I use a bare bones version of my yaml file, it's able to be loaded. But once the pairwise comparisons are added back in, I keep getting the same error. It is having issues somewhere with parsing out the information in the pairwise comparison section. Thanks in advance!

My full yaml file is:

Version: 1.0

Alternatives: &alternatives GIC Monitoring: Geologic Data: USGS: Energy Infrastructure: Variometer: Goal: name: Data Source preferences: pairwise:

#

End of Goal Section

#####################################

Here's what I'm running in R: Session info ------------------------------------------------------------------------------------------------------------------------------- setting value
version R version 3.3.2 (2016-10-31) system x86_64, mingw32
ui RStudio (1.0.125)
language (EN)
collate English_United States.1252
tz America/New_York
date 2016-12-01

Packages ----------------------------------------------------------------------------------------------------------------------------------- package version date source
ahp
0.2.10 2016-11-27 CRAN (R 3.3.2) backports 1.0.4 2016-10-24 CRAN (R 3.3.2) colorspace 1.3-0 2016-11-10 CRAN (R 3.3.2) curl 2.2 2016-10-21 CRAN (R 3.3.2) data.tree 0.6.2 2016-11-24 CRAN (R 3.3.2) devtools 1.12.0 2016-06-24 CRAN (R 3.3.2) DiagrammeR 0.8.4 2016-07-17 CRAN (R 3.3.2) digest 0.6.10 2016-08-02 CRAN (R 3.3.2) evaluate 0.10 2016-10-11 CRAN (R 3.3.2) formattable 0.2.0.1 2016-08-05 CRAN (R 3.3.2) git2r 0.16.0 2016-11-20 CRAN (R 3.3.2) htmltools 0.3.5 2016-03-21 CRAN (R 3.3.2) htmlwidgets 0.8 2016-11-09 CRAN (R 3.3.2) httr 1.2.1 2016-07-03 CRAN (R 3.3.2) igraph 1.0.1 2015-06-26 CRAN (R 3.3.0) influenceR 0.1.0 2015-09-03 CRAN (R 3.3.2) jsonlite 1.1 2016-09-14 CRAN (R 3.3.2) knitr 1.15.1 2016-11-22 CRAN (R 3.3.2) magrittr 1.5 2014-11-22 CRAN (R 3.3.2) memoise 1.0.0 2016-01-29 CRAN (R 3.3.2) munsell 0.4.3 2016-02-13 CRAN (R 3.3.2) plyr 1.8.4 2016-06-08 CRAN (R 3.3.2) R6 2.2.0 2016-10-05 CRAN (R 3.3.2) Rcpp 0.12.7 2016-09-05 CRAN (R 3.3.2) rmarkdown 1.2 2016-11-21 CRAN (R 3.3.2) rprojroot 1.1 2016-10-29 CRAN (R 3.3.2) rstudioapi 0.6 2016-06-27 CRAN (R 3.3.2) scales 0.4.1 2016-11-09 CRAN (R 3.3.2) stringi 1.1.2 2016-10-01 CRAN (R 3.3.2) stringr 1.1.0 2016-08-19 CRAN (R 3.3.2) visNetwork 1.0.2 2016-10-05 CRAN (R 3.3.2) withr 1.0.2 2016-06-20 CRAN (R 3.3.2) yaml * 2.1.14 2016-11-12 CRAN (R 3.3.2)

gluc commented 7 years ago

Your file doesn't seem to be indented correctly. I'm assuming this is a paste error. Yes, error handling is very limited at this stage. Happy to look into it. Ideally you prepare a gist with the file and the code you run, so I can directly reproduce.

xhan85 commented 7 years ago

Thank you so much (sorry for the long delay on my side)! I have made a gist with both the yaml file and my R code. If you're able to tell me where I went wrong, it would be much appreciated! You can access the gist here: https://gist.github.com/xhan85/388d8e3e868a2663338bd1bd2883ee24

gluc commented 7 years ago

I had a quick look. Your file is in version 2, so you need to put Version: 2.0 in first line of the ahp spec yaml.

Also you can load directly on the file path.

gic <- Load("U:/EOA/AHP/GIC Assessment_wdoane.yml")
Calculate(gic)
Analyze(gic)

Using this, I get:

                   Weight Energy Infrastructure GIC Monitoring Geologic Data  USGS Variometer Inconsistency
1 Data Source      100.0%                 28.6%          21.5%         19.4% 19.4%      11.1%          0.3%
2  ¦--Reliability   64.8%                 15.8%          15.8%         15.8% 15.8%       1.8%          0.0%
3  ¦--Coverage      23.0%                 11.9%           4.7%          2.7%  2.7%       0.9%          0.0%
4  ¦   ¦--Spatial   19.1%                 11.5%           2.3%          2.3%  2.3%       0.8%         11.3%
5  ¦   °--Temporal   3.8%                  0.4%           2.5%          0.4%  0.4%       0.1%          9.9%
6  °--Cost          12.2%                  0.9%           0.9%          0.9%  0.9%       8.4%          0.0%
xhan85 commented 7 years ago

Thank you so much!