Skip to main content

No project description provided

Project description

Contributors Forks Stargazers Issues MIT License LinkedIn


Pywr-next

This is repository contains the current work-in-progress for the next major revision to Pywr. It uses Rust as a backend instead of Cython. It is currently not ready for use beyond development and experimentation. Comments and discussions are welcome.

User Guide · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgments

About The Project

Pywr-1.x is a Python library which utilises Cython for performance. Over time this has resulted in a "core" set of data structures and objects that are written in Cython to gain maximum performance. Cython has the nice benefit of making it easy to extend that core functionality using regular Python. However, the border between what is Python and what is Cython is a bit blurred and not well designed in certain places.

One option for the future development of Pywr (e.g. Pywr-2.x) would be a more explicit separation between the compute "core" and higher level functionality. Rust is a candidate for writing that core largely independent of Python, and possibly offers the benefits of (1) greater performance than Cython, and (2) easier maintenance in the future.

(back to top)

Requirements

Any major revision to Pywr will have the following feature requirements:

  • Retain the "Parameter" system from Pywr-1.x - this is core functionality that makes Pywr really flexible.
  • Extendable in Python space.
  • An improved approach for outputting data and metrics.
  • Better error handling.
  • Cross-platform.
  • Faster!
  • Strong input file (JSON) schema.

Built With

Rust Python

(back to top)

Getting started

Installing pre-compiled wheels

See instructions in the Pywr book.

Compiling from source

This repository contains a version of Clp using Git submodules. In order to build those submodules must be initialised first.

git submodule init
git submodule update

Rust is required for installation of the Python extension. To create a Python development installation requires first compiling the Rust library and then the Python extension. The following example uses a virtual environment to install the Python dependencies, compile the Pywr extension and run the Pywr Python CLI.

python -m venv .venv # create a new virtual environment
source .venv/bin/activate # activate the virtual environment (linux)
# .venv\Scripts\activate # activate the virtual environment (windows)
pip install maturin  # install maturin for building the Python extension
maturin develop # compile the Pywr Python extension
python -m pywr  # run the Pywr Python CLI

(back to top)

Usage

Rust CLI

A basic command line interface is included such that you can use this version of Pywr without Python. This CLI is in the pywr-cli crate.

To see the CLI commands available run the following:

cargo run -p pywr-cli -- --help

To run a Pywr v2 model use the following:

cargo run -p pywr-cli -- run tests/models/simple1.json

Python CLI

If the Python extension has been compiled using the above instructions a model can be run using the basic Python CLI.

python -m pywr run tests/models/simple1.json

Porting a Pywr v1.x model to v2.x

This version of Pywr is not backward compatible with Pywr v1.x. One of the major reasons for this version is the lack of a strong schema in the Pywr v1.x JSON files. Pywr v2.x uses an updated JSON schema that is defined in this repository. Therefore, v1.x JSON files must be converted to the v2.x JSON schema. This conversion can be undertaken manually, but there is also a work-in-progress conversion tool. The conversion tool uses a v1.x schema defined in the pywr-schema project.

Please note that conversion from Pywr v1.x to v2.x is experimental and not all features of Pywr are implemented in pywr-schema or have been implemented in Pywr v2.x yet. Due to the changes between these versions it is very likely an automatic conversion will not completely convert your model, and it WILL require manual testing and checking.

cargo run --no-default-features -- convert /path/to/my/v1.x/model.json

Feedback on porting models is very welcome, so please open an issue with any questions or problems.

(back to top)

Crates

This repository contains the following crates:

Pywr-core

A low-level Rust library for constructing network models. This crate interfaces with linear program solvers.

Feature flags:

Feature Description Default
pyo3 Enable the Python bindings. True
highs Enable the HiGHS LP solver. False
ipm-ocl Enable the OpenCL IPM solver (requires nightly). False
ipm-simd Enable the AVX IPM solver (requires nightly). False
cbc Enable the CBC MILP solver. False

Pywr-schema

A Rust library for validating Pywr JSON files against a schema, and then building a model from the schema using pywr-core.

Feature flags:

Feature Description Default
core Enable building models from the schema with pywr-core. This feature is enabled by default, but requires a lot of dependencies. If you only require schema validation and manipulation consider building this crate with default-features = false True
pyo3 Enable the Python bindings. True
highs Enable the HiGHS LP solver. False
ipm-ocl Enable the OpenCL IPM solver (requires nightly). False
ipm-simd Enable the AVX IPM solver (requires nightly). False
cbc Enable the CBC MILP solver. False

Pywr-cli

A command line interface for running Pywr models.

Pywr-python

A Python extension (and package) for constructing and running Pywr models.

Roadmap

  • Proof-of-concept - demonstrate the benefits of the RIIR approach.
  • Redesign of outputs & metrics.
  • Redesign of variable API for integration with external optimisation algorithms.
  • Implement outstanding Parameters from Pywr v1.x
  • Design & implement Python API using Rust extension.
  • Release Pywr v2.x beta

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the Apache 2.0 or MIT License. See LICENSE.txt for more information.

(back to top)

Contact

James Tomlinson - tomo.bbe@gmail.com

Project Link: https://github.com/pywr/pywr-next

(back to top)

Copyright (C) 2020-2023 James Tomlinson Associates Ltd.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pywr-2.0.0b3.tar.gz (8.0 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pywr-2.0.0b3-cp313-cp313t-win_amd64.whl (21.2 MB view details)

Uploaded CPython 3.13tWindows x86-64

pywr-2.0.0b3-cp313-cp313t-manylinux_2_28_x86_64.whl (22.1 MB view details)

Uploaded CPython 3.13tmanylinux: glibc 2.28+ x86-64

pywr-2.0.0b3-cp313-cp313t-macosx_11_0_arm64.whl (19.3 MB view details)

Uploaded CPython 3.13tmacOS 11.0+ ARM64

pywr-2.0.0b3-cp313-cp313t-macosx_10_12_x86_64.whl (20.5 MB view details)

Uploaded CPython 3.13tmacOS 10.12+ x86-64

pywr-2.0.0b3-cp310-abi3-win_amd64.whl (21.3 MB view details)

Uploaded CPython 3.10+Windows x86-64

pywr-2.0.0b3-cp310-abi3-manylinux_2_28_x86_64.whl (22.1 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ x86-64

pywr-2.0.0b3-cp310-abi3-macosx_11_0_arm64.whl (19.3 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

pywr-2.0.0b3-cp310-abi3-macosx_10_12_x86_64.whl (20.5 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file pywr-2.0.0b3.tar.gz.

File metadata

  • Download URL: pywr-2.0.0b3.tar.gz
  • Upload date:
  • Size: 8.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.12.6

File hashes

Hashes for pywr-2.0.0b3.tar.gz
Algorithm Hash digest
SHA256 93fc39433ea25cbdfcb86375f7735f6668d1362ca274bcdac84dfb334162338a
MD5 6f24ac9fd7d0c801b0b9855eb6871a70
BLAKE2b-256 72a19332ed94a680d12c626095857aaf5d8e379a1b64ab13c928c8274e741af8

See more details on using hashes here.

File details

Details for the file pywr-2.0.0b3-cp313-cp313t-win_amd64.whl.

File metadata

  • Download URL: pywr-2.0.0b3-cp313-cp313t-win_amd64.whl
  • Upload date:
  • Size: 21.2 MB
  • Tags: CPython 3.13t, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.12.6

File hashes

Hashes for pywr-2.0.0b3-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 0c62ab08d85882848ba3e9f5230d7e723140b1edfe362883e18194d6c86c9f41
MD5 7c89114524a341b79f81e9342e560b1b
BLAKE2b-256 718b6e9b115458e31f4b6f8075e4fb210d5df98022502581a05ff246788097a4

See more details on using hashes here.

File details

Details for the file pywr-2.0.0b3-cp313-cp313t-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pywr-2.0.0b3-cp313-cp313t-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 70e09f861957205e00cefa6083afecf544df39c54145acf24780ee81cddfa992
MD5 96fd8b6b2e7ade86b36766e181c76d41
BLAKE2b-256 1644818af2149c282efbf2857df89099d5674985dbf794fcbdbef3dcb067726e

See more details on using hashes here.

File details

Details for the file pywr-2.0.0b3-cp313-cp313t-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pywr-2.0.0b3-cp313-cp313t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a9a0ed78f2d05386c42b624602929883bfe4dc19c8d0957e619eceb291b3aa74
MD5 460571f59b6d5c3d6190432019435f26
BLAKE2b-256 b40e685dc9cac8f966717bf97ec0a105b863917cc87049a2ffe2a6e6c6dd9847

See more details on using hashes here.

File details

Details for the file pywr-2.0.0b3-cp313-cp313t-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pywr-2.0.0b3-cp313-cp313t-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 312d5d4ae756d0f65539752adb6428e8038dd8e4b20811b9acc76a8514394127
MD5 0f284a7c91ef7e553b8274053ae8f737
BLAKE2b-256 805fbc50f7391101d5e99159ab2b1e2af35b29f5dc90906735ccca75513ee26d

See more details on using hashes here.

File details

Details for the file pywr-2.0.0b3-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: pywr-2.0.0b3-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 21.3 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.12.6

File hashes

Hashes for pywr-2.0.0b3-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 bbe95abd62c0412e833172cba4f8dd858796a9aca1094aaac78dac6737a4ae3e
MD5 04166a8b850130a0bdb0a00fa2b2addd
BLAKE2b-256 468f42e812beaf147a4f470aab486c92c97418e104569c04235df9a606660c67

See more details on using hashes here.

File details

Details for the file pywr-2.0.0b3-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pywr-2.0.0b3-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2be635371cfb0bddb15e4faffa716b7871a3ce2099e210e465ec7bff96df5bff
MD5 99eaa05b0e3aabc0f9d3e6c3fbf7d855
BLAKE2b-256 11b02060ab5e1c50f014f04257a6dca2be1a806b92c6a6c5275dcdb1b50d7e8f

See more details on using hashes here.

File details

Details for the file pywr-2.0.0b3-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pywr-2.0.0b3-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c1276f1ef5effb27641d6bbe146d3fa81f0042710c4175814f08d32603832675
MD5 4ae8395d681c979be103521cba08a3d9
BLAKE2b-256 5d4f615ca98aaa318eda3d1ce1bd35b1648ad1d38813631cc7673e97c1813dfb

See more details on using hashes here.

File details

Details for the file pywr-2.0.0b3-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pywr-2.0.0b3-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ef1a9a2ed109085117ace9a5ba662e51e6cf5e8d992c6089d814d6a8123f43e6
MD5 a1521bf18aade81c2d1b8ce58bacd89c
BLAKE2b-256 2a5143b633fa17fe83c248c39e28c59021b282fecf654fbacf1aa34cdcd90a08

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page