Building NativeRL Jar Files - PathmindAI/nativerl GitHub Wiki
Required Software
- Linux, Mac, or Windows
- Clang, GCC, or MSVC
- On Windows, please also install MSYS2
- CMake 3+ https://cmake.org/download/
- JDK 8+
- On Windows, make sure that
jvm.dllcan be found in thePATH.
- On Windows, make sure that
- Maven 3+ https://maven.apache.org/download.cgi
- JavaCPP 1.5.1+ https://github.com/bytedeco/javacpp
- Python 3.7+ https://www.python.org/downloads/
- pybind11 2.2.4+ https://github.com/pybind/pybind11
- RLlib 1.3.0 https://docs.ray.io/en/releases-1.3.0/rllib.html
Refer to requirements.txt for the latest
Build Instructions
- 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.exeinside - Making sure the
MSYS2_PATH_TYPE=inheritline is not commented out inmingw64.iniormingw32.ini.
- "x64 Native Tools Command Prompt for VS 2019" and run
- On Windows, from the "Visual Studio 2019" folder found inside the Start menu, open:
- 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=falseto that command.
- To build for TensorFlow 1.x, append
- Find all output files inside the
nativerl/target/nativerl-1.8.1-SNAPSHOT-bin.ziparchive- This also produces
nativerl-policy/target/nativerl-policy-1.8.1-SNAPSHOT.jar(~231mb) for the PathmindHelper
- This also produces
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
- Follow the build instructions above
- Include in the
PATHthe directory containing theanylogicexecutable- The version of AnyLogic installed there needs to have PathmindHelper available in its Palette
- Inside the
nativerl-testssubdirectory, runmvn clean test- We can also run the tests from the parent directory by appending
-Ptests
- We can also run the tests from the parent directory by appending