package ortools

  1. Overview
  2. Docs
Build and export Google OR-Tools models

Install

dune-project
 Dependency

Authors

Maintainers

Sources

ortools-9.15.0-3.tbz
sha256=2dfa5a221f07e7756afda6f23d066aae8ebb73254e201a44921f24e0491c5f7b
sha512=be451a999703a032444c632e0c87b4e391449cee0daa9f4837b0798fc7b8b1ce10abf7bc11dc7439a381a9281a7fb02b9239c75c3df0e4e70d2c690eeb8ae78c

Description

Google OR-Tools is an open source software suite for optimization, tuned for tackling the world's toughest problems in vehicle routing, flows, integer and linear programming, and constraint programming. This package provides OCaml functions for working with the Protocol Buffer formats that are read and written by the different solvers. It does not actually depend on the OR-Tools software, which need not even be installed. The interface currently only supports a subset of the features provided by the CP-SAT solver. Pull requests for more features and solvers are welcome.

Added to opam-repository:

README

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:

  • ortools is 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. See utils/sat_solve_pb.{c,py} for examples of interfacing with the CP-SAT solver.
  • ortools_solvers builds on ortools to provide a simple OCaml interface for calling CP-SAT. This package builds its own version of OR-Tools and the libraries abseil, re2, protobuf, and protobuf-c.

Online docs: https://inria.github.io/ocaml-ortools/

opam install ocamlfind ortools_solvers
ocamlfind ocamlopt -o cp_is_fun_sat.exe \
            -package ortools_solvers -linkpkg \
            samples/sat/cp_is_fun_sat.ml
./cp_is_fun_sat.exe

TODOs

  • Finish migrating OR-Tools sat/samples
  • Use alcotest to test the interface.
  • CP-SAT: Support Interval constraints
  • CP-SAT: Support NoOverlap constraints
  • CP-SAT: Support NoOverlap2D constraints
  • CP-SAT: Support Element constraints
  • CP-SAT: Support Circuit constraints
  • CP-SAT: Support Routes constraints
  • CP-SAT: Support Table constraints
  • CP-SAT: Support Automaton constraints
  • CP-SAT: Support Inverse constraints
  • CP-SAT: Support Reservoir constraints
  • CP-SAT: Support Cumulative constraints
  • CP-SAT: Support Dummy constraints
  • Support other solvers

Dune

The ortools-solvers package tries to solve the difficulties of installing CP-SAT on a given platform and calling it from an OCaml program. To do this, the source of OR-Tools and required libraries is included in the package and built with the OCaml interface.

On macOS, the build relies on the homebrew packages protobuf, protobuf-c, and re2, and also an internal build of eigen3. On Linux, all of these libraries are built internally.

There are currently a number of known imperfections based on assumed limitations of dune (at the time of writing):

  1. The build assumes that it is possible to run cmake -j 8 (ortools_solvers/dune). Running without any parallelism is much slower, but requesting too much parallelism can overwhelm the build machine. Dune does not currently provide a way of sharing cores between itself and an external build process controlled by cmake/make. See this discussion.
  2. To run an OCaml program that uses ortools-solvers, the loader must be able to find libortools.so (and also libabsl_log_internal_message.so, libabsl_raw_logging_internal.so, libabsl_raw_hash_set.so, and protobuf.so). This is not a problem once ortools-solvers is installed since the stub uses $CAMLORIGIN to specify the -L and -rpath flags (ortools_solvers/stubs/dune). However, to test against a local build before installation, it is necessary to manually set and export either DYLD_LIBRARY_PATH (macOS) or LD_LIBRARY_PATH (Linux). This is also the reason why the build does not try to run such tests, e.g., by running the programs in samples/sat, during continuous integration. (DYLD_LIBRARY_PATH=_build/install/default/lib/ortools_solvers dune exec -- samples/sat/cp_is_fun_sat.exe).

Dependencies (3)

  1. pbrt >= "4.0"
  2. dune >= "3.21"
  3. ocaml >= "4.14.2"

Dev Dependencies (1)

  1. odoc with-doc

Used by (1)

  1. ortools_solvers

Conflicts

None