R with MOEA Framework using Renjin Script Engine
Using R with Java is painful, ugly.
While I was recently revisiting REpochX which I quickly wrote long time ago to evolve R grammars using Grammatical Evolution, I decided to do the same with MOEA Framework instead of EpochX as the latter does not look actively maintained.
Firstly, MOEA Framework is very comprehensive and the coding practice is a lot moderner compared to similar evolutionary computing libraries.
But, again, R/Java bindings... That's killing me.
There are quite a few different ways which we used in the past: JRI (from rJava), Rserve, OpenCPU and so on. All these require the programmer to manage an R installation and instances/daemons.
Enabled by the Java scripting interface, Renjin solves this mess nicely. Similar to jpython, jruby etc..., you can program in R in Java by passing R statements to the respective R scripting engine and consume results: R Language implemented in Java.
Renjin is not complete. The packaging system mimics the original R packaging, but there are many (now mainstream) libraries which are not available to Renjin users.
Nevermind... Below is a simple Java program which demonstrates the idea of using R with MOEA Framework through the Renjin Script Engine.
Don't forget to add the following to your
<dependency> <groupId>org.moeaframework</groupId> <artifactId>moeaframework</artifactId> <version>2.6</version> </dependency> <dependency> <groupId>org.renjin</groupId> <artifactId>renjin-script-engine</artifactId> <version>0.7.0-RC7</version> </dependency>