Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MDSJWrapper fails to scan distance matrix #37

Open
tpetkovich opened this issue Sep 5, 2018 · 3 comments
Open

MDSJWrapper fails to scan distance matrix #37

tpetkovich opened this issue Sep 5, 2018 · 3 comments
Labels

Comments

@tpetkovich
Copy link

Greetings,

I do have some problem with the network.layout.animate.MDJS(). Even if the output to the MDSJWrapper.class should be valid with a layout.distance() generated matrix, the MDSJWrapper outputs "distance matrix is missing entries?" for all entries, and the layout output coords will be random.

To reproduce, just use the example in the Statnet tutorial (https://statnet.github.io/Workshops/ndtv_workshop.html#adjusting-spacing-of-isolates-and-components):

data(msm.sim)
msmAt50<-network.extract(msm.sim,at=50)
network.size(msmAt50)
plot(msmAt50,coord=network.layout.animate.MDSJ(msmAt50),vertex.cex=0.5)

It will not result the desired output, instead just a random layout.

Version info:

> system('java -version')
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=Hungarian_Hungary.1250  LC_CTYPE=Hungarian_Hungary.1250    LC_MONETARY=Hungarian_Hungary.1250
[4] LC_NUMERIC=C                       LC_TIME=Hungarian_Hungary.1250    

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

other attached packages:
[1] MASS_7.3-50          ndtv_0.12.2          sna_2.4              statnet.common_4.1.4 animation_2.5       
[6] networkDynamic_0.9.0 network_1.13.0.1    

loaded via a namespace (and not attached):
[1] compiler_3.5.1  tools_3.5.1     base64_2.0      coda_0.19-1     yaml_2.2.0      grid_3.5.1      jsonlite_1.5   
[8] openssl_1.0.2   lattice_0.20-35

@tpetkovich
Copy link
Author

tpetkovich commented Sep 5, 2018

I have managed to trace the problem. It is caused by the Java VM, because it is using my locale settings and the scanner function does not recognize commas as decimal separators. (Instead it would expect periods)
It would be nice to add a "scanner.useLocale(Locale.US);" to the java code, so there would be less problems with locale settings.

@skyebend
Copy link
Contributor

skyebend commented Sep 6, 2018

ah ha! thank you! this probably explains #29 , which I haven't been otherwise able to reproduce. Were you also seeing the error message from MDSJ layout?

@skyebend skyebend added the bug label Sep 6, 2018
@tpetkovich
Copy link
Author

tpetkovich commented Sep 6, 2018

Yes, the output looks like this:

> network.layout.animate.MDSJ(network.initialize(5))
 [1] "distance matrix is missing entries?" "distance matrix is missing entries?" "distance matrix is missing entries?"
 [4] "distance matrix is missing entries?" "distance matrix is missing entries?" "distance matrix is missing entries?"
 [7] "distance matrix is missing entries?" "distance matrix is missing entries?" "distance matrix is missing entries?"
[10] "distance matrix is missing entries?" "distance matrix is missing entries?" "distance matrix is missing entries?"
[13] "distance matrix is missing entries?" "distance matrix is missing entries?" "distance matrix is missing entries?"
[16] "distance matrix is missing entries?" "distance matrix is missing entries?" "distance matrix is missing entries?"
[19] "distance matrix is missing entries?" "distance matrix is missing entries?" "distance matrix is missing entries?"
[22] "distance matrix is missing entries?" "distance matrix is missing entries?" "distance matrix is missing entries?"
[25] "distance matrix is missing entries?" "MDSJ starting stress: 0.0"           "MDSJ ending stress: 0.0"            
          [,1]      [,2]
[1,] 0.6093728 0.8179096
[2,] 0.5387998 0.1502008
[3,] 0.7931164 0.8762649
[4,] 0.4284446 0.5294074
[5,] 0.7514934 0.8307045

My temporary solution was to trace edit network.layout.animate.MDSJ

45  command = paste("java -cp ", paste(mdsj.path, file.path(mdsj.path, 
46    "mdsj.jar"), sep = sep), "MDSJWrapper", n, dim, verbosity, 
47    max_iter, filename, coord.file)

to:

45  command = paste("java -Duser.language=en -cp ", paste(mdsj.path, file.path(mdsj.path, 
46    "mdsj.jar"), sep = sep), "MDSJWrapper", n, dim, verbosity, 
47    max_iter, filename, coord.file)

But in the long term, scanner.useLocale(Locale.US); could be the best option to fix in the MDSJWrapper class.

My another attempt was to set the JAVA_TOOL_OPTIONS global environment variable in Windows to apply "-Duser.language=en" for java runs globally. But it outputs a "Picked up JAVA_TOOL_OPTIONS: -Duser.language=en” line before every java execution, and that was messing up the MDSJWrapper output (even if the coordinates were good, the added line offset the whole output, and the R parser could not handle it). This means, that in situations, when the JAVA_TOOL_OPTIONS or _JAVA_OPTIONS environment variables are set, the R parser will fail to read the output correctly. And there may be plenty of situations, when something sets those environment variables: https://www.google.com/search?q=picked+up+java_tool_options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants