gluc / ahp

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

Visualize does not complete #6

Open ghost opened 7 years ago

ghost commented 7 years ago

Running Visualize(myAhp) leads to a JavaScript abort as shown in the stack trace below. When running inside RStudio the stack trace appears in the Viewer panel. When running from an R shell the stack trace appears in the browser. Running other AHP commands such as Calculate(myAhp), Anaylze(myAhp), AnalyzeTable(myAhp) and tree prints succeed as expected.

However, on the same model, running g <- GetGraph(myAhp) yields a class from which the DOT notation representation can be copied and pasted to GraphViz for successful drawing. Consequently, the issue may not be associated with AHP itself but rather with the dependent JS libraries.

Stack trace:

abort(0) at jsStackTrace@http://localhost:18175/session/viewhtml6fea52a704ac/lib/viz-0.3/viz.js:5:22072
stackTrace@http://localhost:18175/session/viewhtml6fea52a704ac/lib/viz-0.3/viz.js:5:22258
abort@http://localhost:18175/session/viewhtml6fea52a704ac/lib/viz-0.3/viz.js:28:10656
nullFunc_iii@http://localhost:18175/session/viewhtml6fea52a704ac/lib/viz-0.3/viz.js:5:662065
a8@http://localhost:18175/session/viewhtml6fea52a704ac/lib/viz-0.3/viz.js:21:31634
iC@http://localhost:18175/session/viewhtml6fea52a704ac/lib/viz-0.3/viz.js:9:83383
aD@http://localhost:18175/session/viewhtml6fea52a704ac/lib/viz-0.3/viz.js:9:102098
uF@http://localhost:18175/session/viewhtml6fea52a704ac/lib/viz-0.3/viz.js:9:173805
pG@http://localhost:18175/session/viewhtml6fea52a704ac/lib/viz-0.3/viz.js:9:204484
xc@http://localhost:18175/session/viewhtml6fea52a704ac/lib/viz-0.3/viz.js:11:740
http://localhost:18175/session/viewhtml6fea52a704ac/lib/viz-0.3/viz.js:28:403
ccallFunc@http://localhost:18175/session/viewhtml6fea52a704ac/lib/viz-0.3/viz.js:5:8402
http://localhost:18175/session/viewhtml6fea52a704ac/lib/viz-0.3/viz.js:47:42
renderValue@http://localhost:18175/session/viewhtml6fea52a704ac/lib/grViz-binding-0.8.4/grViz.js:38:27
http://localhost:18175/session/viewhtml6fea52a704ac/lib/htmlwidgets-0.8/htmlwidgets.js:625:30
forEach@[native code]
forEach@http://localhost:18175/session/viewhtml6fea52a704ac/lib/htmlwidgets-0.8/htmlwidgets.js:55:21
http://localhost:18175/session/viewhtml6fea52a704ac/lib/htmlwidgets-0.8/htmlwidgets.js:551:14
forEach@[native code]
forEach@http://localhost:18175/session/viewhtml6fea52a704ac/lib/htmlwidgets-0.8/htmlwidgets.js:55:21
staticRender@http://localhost:18175/session/viewhtml6fea52a704ac/lib/htmlwidgets-0.8/htmlwidgets.js:549:12
http://localhost:18175/session/viewhtml6fea52a704ac/lib/htmlwidgets-0.8/htmlwidgets.js:638:38

R session info:

R version 3.2.3 (2015-12-10)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.12.1 (unknown)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ahp_0.2.10

loaded via a namespace (and not attached):
 [1] igraph_1.0.1        Rcpp_0.12.8         rstudioapi_0.6      knitr_1.15.1        magrittr_1.5        munsell_0.4.3       colorspace_1.3-1   
 [8] R6_2.2.0            stringr_1.1.0       plyr_1.8.4          tools_3.2.3         visNetwork_1.0.2    influenceR_0.1.0    DiagrammeR_0.8.4   
[15] htmltools_0.3.5     yaml_2.1.14         digest_0.6.10       rprojroot_1.1       htmlwidgets_0.8     evaluate_0.10       rmarkdown_1.2      
[22] stringi_1.1.2       scales_0.4.1        backports_1.0.4     data.tree_0.6.2     jsonlite_1.1        formattable_0.2.0.1
gluc commented 7 years ago

Hmm, that's a tough one. My guess would be that it's a problem in DiagrammeR. I had previously experienced problems with special characters in node names, for instance. If you prepare a reproducible example, I might be able to help, no promises though :-(

ghost commented 7 years ago

The first time I ran this "reproducible" example, the visualization succeeded. Subsequent runs, however, failed. Stopping and restarting R and RStudio did not repair the state. So I post here a small example and model file to learn if others experience the same sort of non-determinism.


library(ahp)
ahpName <- "model.txt" # text suffix for issue posting
if (! file.exists(ahpName)) {
  stop(paste("Cannot find AHP file",ahpName))
}

myAhp <- Load(ahpName)

# calculate
Calculate(myAhp)

# visualize -- fails
Visualize(myAhp)

# analyze -- succeeds

Analyze(myAhp)
AnalyzeTable(myAhp)

model.txt