hopsy - Highly Optimized Polytope Sampling in Python#


hopsy logo

hopsy is a scientific Python tool for Markov chain Monte Carlo sampling on convex polytopes of the form

\[\mathcal{P} := \{ x : Ax \leq b \},\]

a problem that often arises in Bayesian metabolic flux analysis. It is built using pybind11 and works on the powerful C++ polytope sampling tool HOPS. Its goal is to combine the efficiency of the C++-backend with the flexibility of the Python language whilst maintaining a comprehensible API and interoperability with other Python libraries.

hopsy offers not only a magnitude of efficiently implemented algorithms specialized for sampling linearily constrained spaces, but also allows for implementing custom samplers in C++. Similarily, besides providing a few test models, hopsy allows sampling user-implemented models. A few examples including \(^{13}\mathrm{C}\)-metabolic flux analysis, bioreactor kinetics, statistical physics simulations and a SIR-model can be found in the examples section.

An important task, especially when sampling expensive to evaluate target functions, is tuning of the proposal’s hyperparameters. hopsy offers a Thompson Sampling-based approach which can perform tuning based on different objective functions. Please refer to this chapter for more information.

Further resources#

If you encounter bugs, please feel free to open an issue on GitHub, where you can also find the source code. For questions, help or feedback regarding hopsy, visit us on our Gitter!