Building NativeRL Jar Files - PathmindAI/nativerl GitHub Wiki

Required Software

Refer to requirements.txt for the latest

Build Instructions

  1. Install CMake, the JDK, Maven, and Python on the system
    • On Windows, from the "Visual Studio 2019" folder found inside the Start menu, open:
      • "x64 Native Tools Command Prompt for VS 2019" and run c:\msys64\mingw64.exe inside
      • Making sure the MSYS2_PATH_TYPE=inherit line is not commented out in mingw64.ini or mingw32.ini.
  2. Run mvn clean install -Djavacpp.platform.custom -Djavacpp.platform.linux-x86_64 -Djavacpp.platform.macosx-x86_64 -Djavacpp.platform.windows-x86_64
    • To build for TensorFlow 1.x, append -Dtfv2=false to that command.
  3. Find all output files inside the nativerl/target/nativerl-1.8.1-SNAPSHOT-bin.zip archive
    • This also produces nativerl-policy/target/nativerl-policy-1.8.1-SNAPSHOT.jar (~231mb) for the PathmindHelper

Building with Docker

First build the image.

docker build . -t nativerl

Then start the container by mounting your current working directory.

docker run -v $HOME/.m2:/root/.m2 --mount "src=$(pwd),target=/app,type=bind" nativerl

After a successful build you'll find the results in the target folder. These instructions work on Unix machines, on Windows you'll likely have to use ${PWD} instead of $(pwd) in the run step.

Sample Build Steps on CentOS 7 with Anaconda

sudo yum update
sudo yum install centos-release-scl
sudo yum install gcc-c++ make java-1.8.0-openjdk-devel git wget devtoolset-7 rh-maven35

sudo wget https://github.com/Kitware/CMake/releases/download/v3.21.3/cmake-3.21.3-linux-x86_64.sh
sudo bash cmake-3.21.3-linux-x86_64.sh --prefix=/usr/local --exclude-subdir --skip-license

wget https://repo.anaconda.com/archive/Anaconda3-2019.03-Linux-x86_64.sh
bash Anaconda3-2019.03-Linux-x86_64.sh
conda install pybind11 tensorflow
pip install ray[rllib]==1.3.0

scl enable devtoolset-7 rh-maven35 bash
mvn clean install -Djavacpp.platform=linux-x86_64

We can also package the Anaconda environment this way:

conda install -c conda-forge conda-pack
conda pack -o rllibpack.tar.gz

Once this is done, we can take all those archives and extract them on another machine ready for execution:

cd /path/to/rllibpack/
tar --totals -xf /path/to/rllibpack.tar.gz
source bin/activate
conda-unpack

cd /path/to/anylogic_model/
unzip -j nativerl-1.8.1-SNAPSHOT-bin.zip

Running the Tests

  1. Follow the build instructions above
  2. Include in the PATH the directory containing the anylogic executable
    • The version of AnyLogic installed there needs to have PathmindHelper available in its Palette
  3. Inside the nativerl-tests subdirectory, run mvn clean test
    • We can also run the tests from the parent directory by appending -Ptests