Package: hopsy
hopsy - Python bindings for HOPSA python interface for HOPS - theHighlyOptimized toolbox forPolytopeSampling.
Built usingpybind11hopsyis a Python package for Markov chain Monte Carlo sampling on convex polytopesP = {x : Ax ≤ b},which often arises in metabolic flux analysis.Installationhopsy can be easily installed from the Python Package Index usingpip install hopsy.
It is also possible to install the source dist on pypi in case there is no wheel for your particular OS yet.Alternatively, you can download the source code from our GitHub repository withgitclonehttps://github.com/modsim/hopsy--recursiveNote the--recursiveoption which is
needed for hops, eigen and pybind11 submodules.Next, compile either a binary wheel using pippipwheel--no-depshopsy/or use the standard CMake routinemkdirhopsy/cmake-build-release&&cdhopsy/cmake-build-release
cmake..
makeNote however that the binary wheel produced frompipcan be actually installed usingpip, usingpipinstallhopsy-x.y.z-tag.whlwhere the versionx.y.zand tagtagwill depend on the verison you downloaded and your build environment.
If you use the CMake routine, the compiled shared library will be located inbuild/and can
be used within the directory.To compile binary wheels for distribution (e.g. via the Python Package Index pypi.org), use themakewheels.shscript.Prerequisites for compiling from sourceOn Unix (Linux, OS X)A compiler with C++11 supportCMake >= 3.4 or Pip 10+Ninja or Pip 10+Docker (optional, for building wheels)MPI support for parallel temperingIf you want to use the parallel tempering implemented in hops, you need a working MPI installation, because threads would not work due to the python GIL.
The next step is to compile hopsy by source and to check that the script  examples/parallel_tempering.py works.
Both modes of the distribution should be found, otherwise there is some issue. In this case, please contact us.In order to use parallel tempering, python interpreter must be called with MPI:mpirun -np 10 parallel_tempering_application.pyIn this case, 10 parallel chains would be constructed.ExamplesA basic usage example is presented below. More examples can be found intests/directory or in the docs.importhopsyimportmatplotlib.pyplotasplt# the polytope is defined as#          P := {x : Ax <= b}# thus we need to define A and b. these constraints form the simple box [0,5]^2.A=[[1,0],[0,1],[-1,0],[0,-1]]b=[5,5,0,0]# next we construct a 2-dim standard Gaussianmodel=hopsy.Gaussian(dim=2)# the complete problem is defined by the target distribution and the constrained domain,# defined by the above mentioned inequalityproblem=hopsy.Problem(A,b,model)# the run object contains and constructs the markov chains. in the default case, the# Run object will have a single chain using the Hit-and-Run proposal algorithm and is# set to produce 10,000 samples.mc=hopsy.MarkovChain(problem,proposal=hopsy.GaussianHitAndRunProposal,starting_point=[.5,.5])rng=hopsy.RandomNumberGenerator(seed=42)# call sample on the mc and rng objectsacceptance_rate,states=hopsy.sample(mc,rng,n_samples=10_000,thinning=2)# the states have 3 dimensions: number of chains, number of samples, number of dimensions.plt.scatter(states[:,:,0].flatten(),states[:,:,1].flatten())plt.show()DevelopmentThe development of hopsy primarily takes place on (JuGit)[https://jugit.fz-juelich.de/IBG-1/ModSim/hopsy], where we have access to powerful continuous integration and a Docker registry. The GitHub repository is only a mirror, so please report issues and make pull requests on JuGit.
Please install pre-commit before commiting to our repository, see pre-commit step in .gitlab-ci.yml.Building docs & updading docsdocs-sources$ make html  # make will tell you which python packages you might be missing
docs-sources$ rm ../docs/* -r
docs-sources$ cp _build/html/* ../docs/ -r
docs-sources$ git add ../ docs && git commit -m "updated docs" && git push  # and so on...LinksSource Code & CI:https://jugit.fz-juelich.de/IBG-1/ModSim/hopsyPyPI:https://pypi.org/project/hopsy/Documentation:https://modsim.github.io/hopsy/Github Mirror:https://github.com/modsim/hopsyTestPyPI:https://test.pypi.org/project/hopsy/HOPS (C++ backend):https://gitlab-public.fz-juelich.de/IBG-1/ModSim/hopsLicensehopsy is licensed under theMIT license.