{"id":43537955,"url":"https://github.com/modsim/hopsy","last_synced_at":"2026-02-03T17:18:00.265Z","repository":{"id":38390821,"uuid":"381640138","full_name":"modsim/hopsy","owner":"modsim","description":"Python interface to C++ sampling library HOPS","archived":false,"fork":false,"pushed_at":"2025-09-22T13:28:50.000Z","size":120930,"stargazers_count":14,"open_issues_count":0,"forks_count":3,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-10-29T01:02:53.774Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/modsim.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":"CLA.md"}},"created_at":"2021-06-30T09:06:19.000Z","updated_at":"2025-09-22T13:28:54.000Z","dependencies_parsed_at":"2025-12-07T19:00:08.745Z","dependency_job_id":null,"html_url":"https://github.com/modsim/hopsy","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/modsim/hopsy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modsim%2Fhopsy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modsim%2Fhopsy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modsim%2Fhopsy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modsim%2Fhopsy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/modsim","download_url":"https://codeload.github.com/modsim/hopsy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modsim%2Fhopsy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29050353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-03T15:43:47.601Z","status":"ssl_error","status_checked_at":"2026-02-03T15:43:46.709Z","response_time":96,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-02-03T17:17:55.720Z","updated_at":"2026-02-03T17:18:00.257Z","avatar_url":"https://github.com/modsim.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hopsy - a methods marketplace for convex polytope sampling powered by the C++ library HOPS\n\n[![pipeline status](https://jugit.fz-juelich.de/IBG-1/ModSim/hopsy/badges/main/pipeline.svg)](https://jugit.fz-juelich.de/IBG-1/ModSim/hopsy/-/commits/main)\n[![docstring coverage](https://jugit.fz-juelich.de/IBG-1/ModSim/hopsy/-/raw/main/docs/docov.svg)](/docs/docov.svg)\n[![license: MIT](https://assets-global.website-files.com/5e0f1144930a8bc8aace526c/65dd9eb5aaca434fac4f1c34_License-MIT-blue.svg)](/LICENSE)\n\n\n\u003cimg src=\"docs/_static/hopsy.png\" alt=\"HOPSY Logo\" width=\"300\"/\u003e\n\n**hopsy** is a versatile open-source domain-agnostic platform for (MCMC)-sampling convex polytopes\n\nP = {x : Ax \u0026#8804; b},\n\nwhich appear in many domains:\n- metabolic flux analysis\n- ecological modeling\n- optimization of chromatography pipelines\n- Bayesian multi criteria decision analysis in economics\n- Bell scenarios in quantum mechanics\n- ...\n\n**hopsy** is a Python3 package powered by the C++ library [HOPS](https://jugit.fz-juelich.de/IBG-1/ModSim/hops).\nUsing `pybind11` **hopsy** calls and extends HOPS with a range of useful features, bringing the performance of C++\nand simplicity of Python together in one package.\nDetails and more use-cases are described [here](https://www.biorxiv.org/content/10.1101/2023.12.22.573091v1).\n\n\n## Installation\n\nhopsy can be easily installed from the Python Package Index using ``pip install hopsy``.\nIt is also possible to install the source dist on pypi in case there is no wheel for your particular OS yet.\n\nAlternatively, you can download the source code from our GitHub repository with\n\n```bash\ngit clone https://github.com/modsim/hopsy --recursive\n```\n\nNote the `--recursive` option which is\nneeded for hops, eigen and pybind11 submodules.\n\nNext, compile either a binary wheel using pip\n\n```bash\npip wheel --no-deps hopsy/\n```\n\nor use the standard CMake routine\n\n```bash\nmkdir hopsy/cmake-build-release \u0026\u0026 cd hopsy/cmake-build-release\ncmake ..\nmake\n```\n\nNote however that the binary wheel produced from ``pip`` can be actually installed using ``pip``, using\n\n```bash\npip install hopsy-x.y.z-tag.whl\n```\n\nwhere the version `x.y.z` and tag `tag` will depend on the verison you downloaded and your build environment.\nIf you use the CMake routine, the compiled shared library will be located in `build/` and can\nbe used within the directory.\n\nTo compile binary wheels for distribution (e.g. via the Python Package Index pypi.org), use the `makewheels.sh` script.\n\n\n### Prerequisites for compiling from source\n\n**On Unix (Linux, OS X)**\n\n* A compiler with C++11 support\n* CMake \u003e= 3.4 or Pip 10+\n* Ninja or Pip 10+\n* Docker (optional, for building wheels)\n\n\n## MPI support for parallel tempering\n\nIf 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.\nThe next step is to compile hopsy by source and to check that the script  examples/parallel\\_tempering.py works.\nBoth modes of the distribution should be found, otherwise there is some issue. In this case, please contact us.\n\nIn order to use parallel tempering, python interpreter must be called with MPI:\n\n```\nmpirun -np 10 parallel_tempering_application.py\n```\n\nIn this case, 10 parallel chains would be constructed.\n\n\n## Examples\n\nA basic usage example is presented below. More examples can be found in `tests/` directory or in the docs.\n\n```python\nimport hopsy\nimport matplotlib.pyplot as plt\n\n# the polytope is defined as\n#          P := {x : Ax \u003c= b}\n# thus we need to define A and b. these constraints form the simple box [0,5]^2.\nA = [[1, 0], [0, 1], [-1, 0], [0, -1]]\nb = [5, 5, 0, 0]\n\n# next we construct a 2-dim standard Gaussian\nmodel = hopsy.Gaussian(dim=2)\n\n# the complete problem is defined by the target distribution and the constrained domain,\n# defined by the above mentioned inequality\nproblem = hopsy.Problem(A, b, model)\n\n# the run object contains and constructs the markov chains. in the default case, the\n# Run object will have a single chain using the Hit-and-Run proposal algorithm and is\n# set to produce 10,000 samples.\nmc = hopsy.MarkovChain(problem, proposal=hopsy.GaussianHitAndRunProposal, starting_point=[.5, .5])\nrng = hopsy.RandomNumberGenerator(seed=42)\n\n# call sample on the mc and rng objects\nacceptance_rate, states = hopsy.sample(mc, rng, n_samples=10_000, thinning=2)\n\n# the states have 3 dimensions: number of chains, number of samples, number of dimensions.\nplt.scatter(states[:, :, 0].flatten(), states[:, :, 1].flatten())\nplt.show()\n```\n\n\u003cimg src=\"docs/_static/gaussscatter.png\" alt=\"2-dimensional truncated Gaussian scatter plot\" width=\"600\"/\u003e\n\n\n[`cibuildwheel`]:          https://cibuildwheel.readthedocs.io\n[FAQ]: http://pybind11.rtfd.io/en/latest/faq.html#working-with-ancient-visual-studio-2009-builds-on-windows\n[vs2015_runtime]: https://www.microsoft.com/en-us/download/details.aspx?id=48145\n\n## Development\n\nThe 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.\nPlease install pre-commit before commiting to our repository, see pre-commit step in .gitlab-ci.yml.\n\n\n### Building docs \u0026 updading docs\n\n```\ndocs-sources$ make html  # make will tell you which python packages you might be missing\ndocs-sources$ rm ../docs/* -r\ndocs-sources$ cp _build/html/* ../docs/ -r\ndocs-sources$ git add ../ docs \u0026\u0026 git commit -m \"updated docs\" \u0026\u0026 git push  # and so on...\n```\n\n\n## Links\n- Source Code \u0026 CI: https://jugit.fz-juelich.de/IBG-1/ModSim/hopsy\n- PyPI: https://pypi.org/project/hopsy/\n- Documentation: https://modsim.github.io/hopsy/\n- Github Mirror: https://github.com/modsim/hopsy\n- TestPyPI: https://test.pypi.org/project/hopsy/\n- HOPS (C++ backend): https://gitlab-public.fz-juelich.de/IBG-1/ModSim/hops\n- Publication: https://academic.oup.com/bioinformatics/article/40/7/btae430/7702329\n\n## Citing\n\nIf you like `hopsy` and used it in your scientific work, please cite our [paper](https://academic.oup.com/bioinformatics/article/40/7/btae430/7702329)\n```\n@article{10.1093/bioinformatics/btae430,\n    author = {Paul, Richard D and Jadebeck, Johann F and Stratmann, Anton and Wiechert, Wolfgang and Nöh, Katharina},\n    title = \"{hopsy — a methods marketplace for convex polytope sampling in Python}\",\n    journal = {Bioinformatics},\n    volume = {40},\n    number = {7},\n    pages = {btae430},\n    year = {2024},\n    month = {07},\n    issn = {1367-4811},\n    doi = {10.1093/bioinformatics/btae430},\n    url = {https://doi.org/10.1093/bioinformatics/btae430},\n}\n```\n\n## License\n\nhopsy is licensed under the [MIT license](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmodsim%2Fhopsy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmodsim%2Fhopsy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmodsim%2Fhopsy/lists"}