This library can be used to solve for optimal driver and spotter schedules for endurance racing events. It uses the HiGHS optimization library.
It has been structured as a C-API library (jres_solver) and a simple CLI client (jres_solver) that uses the library.
Note
this is a C++ port of the python Solver https://github.com/popmonkey/jres_solver
.
├── include/
| └── jres_solver/ # The public C-API header for the library
├── src/ # The C++ library implementation
| ├── jres_solver.cpp # C-API Wrapper and Orchestrator
| ├── jres_solver_base.cpp # Shared logic for the solver
| ├── jres_standard_solver.cpp # Standard Solver (Elastic/Diagnostic enabled)
| ├── jres_internal_types.cpp # Internal C++ data structures
| ├── jres_json_converter.cpp # JSON conversion logic
| ├── analysis/ # Analysis logic (e.g. capacity)
| ├── constraints/ # Constraint implementations
| ├── formatter/ # Formatter implementation
| └── utils/ # Utility functions
├── lib/
│ ├── cxxopts/ # (Git Submodule) cxxopts header-only library
│ └── json/ # (Git Submodule) nlohmann/json header-only library
├── cmd/
│ ├── solver/ # A CLI solver
│ └── formatter/ # A CLI formatter
├── test/ # Google Test suite
└── CMakeLists.txt # The main build script
This project relies on cmake for building and git for dependency management (via submodules). The only external binary dependency is the HiGHS library.
First, clone the repo and initialize the lib submodules:
git clone git@github.com:popmonkey/jres_solver_cpp.git jres_solver_cpp
cd jres_solver_cpp
git submodule update --init --recursive
The HiGHS library must be installed on your system.
Note
If CMake cannot find a system-installed version of HiGHS, it will automatically download and build it as part of the project configuration process. While this simplifies setup, a pre-installed version is recommended for faster build times.
This is the easiest method for macOS:
brew install highs
HiGHS is modern and may not be in the default repositories of older Linux distributions. We recommend building from source:
git clone https://github.com/ERGO-Code/HiGHS.git
cd HiGHS
cmake -B build -DFAST_BUILD=ON
cmake --build build
sudo cmake --install buildThe recommended way to install HiGHS on Windows is via vcpkg:
vcpkg install highs:x64-windows-staticWe use a standard out-of-source CMake build.
-
Create a build directory:
mkdir build cd build -
Run CMake (Configure):
On macOS (Homebrew):
cmake .. -DCMAKE_PREFIX_PATH=/opt/homebrewOn Linux:
cmake ..On Windows (via vcpkg):
cmake .. -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -
Run Make (Build):
cmake --build .
This will create the main products in the build/ directory:
libjres_solver.soorlibjres_solver.a(or.dll/.lib): The shared or static library. The type depends on theBUILD_SHARED_LIBSCMake option (defaults to ON).jres_solver(orjres_solver.exe): The solver CLI executable.jres_formatter(orjres_formatter.exe): The formatter CLI executable.
The jres_solver executable is a client that uses the jres_solver library.
# Run with a file
./jres_solver -i ../data/short_race.json -s integrated
# Run diagnostics on a failing schedule
./jres_solver -i ../data/infeasible.json --diagnose
# Get help
./jres_solver --help
The jres_formatter executable formats solver output into various report formats.
# Get help
./jres_formatter --help