package ortools
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=3967abe3ecfdaa6c2c098be954825f792d0b925b5342a4ddb1ce5cf2d9f81e50
sha512=5d6feb4b5d664812aad0e103f9a9991405739b4d3532a86059e069f7d4a5f5804d444e15937217af1e7838024305802176ccd8be0268467dfa0f68cfe60e7fe7
doc/README.html
OCaml interface to Google OR-Tools
Currently only a subset of CP-SAT is supported.
Pull requests providing the missing features are welcome, but please pay attention to documentation and tests.
This project provides two packages:
ortoolsis an OCaml interface for building CP-SAT models. It does not require an installation of OR-Tools as it simply works with the protocol buffer format. Seeutils/sat_solve_pb.{c,py}for examples of interfacing with the CP-SAT solver.ortools_solversbuilds onortoolsto provide a simple OCaml interface for calling CP-SAT. Building and installing it requires an OR-Tools installation (see below).
Building with Google OR-Tools
Ensure that libortools.9.dylib (macOS) or libortools.so.9 (Linux), and the other runtime libraries, are accessible by your compiler and loader.
For example, on macOS, set the LIBRARY_PATH (for compilation) and DYLD_LIBRARY_PATH (for execution) environment variables.
On Linux, set the LD_LIBRARY_PATH (for compilation and execution) environment variable.
There are several options for obtaining the runtime libraries.
- Download or build from source following the official instructions (see the C++ section).
- Install the Python libraires with
pip. The OR-Tools runtime can be found insite-packages/ortools/.libs. - From the or-tools releases on github, download
Google.OrTools.runtime.<os>-<arch>.9.<minor>.<patch>.nupkgwhere os ∈ { linux, osx, win } and arch ∈ { arm64, x64 } andunzipit. The required files are inruntimes/*/native.
I would have liked all this to be automatic, but:
- There do not seem to be suitable brew/linux packages that could be linked from opam;
- Vendoring the source in the opam package and building it on install is error-prone and resource-intensive;
- Including several binary versions in the opam package is tedious to maintain and wasteful to download; and
- Dynamically downloading the library on build is prevented by opam sandboxing (see the
downloadbranch for a prototype).
Protocol Buffer Interfaces
The Protocol Buffers interfaces have been generated with ocaml-protc (with pull/263).
If required, they can be regenerated as follows.
git clone git@github.com:google/or-tools.git
cd or-tools
git checkout v9.14 % TODO: update with required version
opam install ocaml-protoc
ocaml-protoc --binary --pp --make --ml_out src/model \
<path-to-or-tools>/ortools/sat/cp_model.proto
ocaml-protoc --binary --pp --make --ml_out src/model \
<path-to-or-tools>/ortools/sat/sat_parameters.proto