Skip to main content

pyshop

Status:

Latest Release build status coverage report

The nicest python interface to SHOP!

SHOP (Short-term Hydro Optimization Program) is a modelling tool for short-term hydro operation planning developed by SINTEF Energy Research in Trondheim, Norway. SHOP is used for both scientific and commercial purposes, please visit the SHOP home page for further information and inquiries regarding access and use.

The pyshop package is an open source python wrapper for SHOP, and requires the proper SHOP binaries to function (see step 2).

1 Installing pyshop

We currently offer two ways to use pyshop:

  1. Install pyshop through pypi (simple and quick)
  2. Install pyshop through Sintef's Gitlab Package Registry (useful if you want to avoid public registries)

Install pyshop using pypi

Install PyShop with pandas and visualization support:

pip install "sintef-pyshop[all]"

For a pandas-free installation without visualization dependencies:

pip install sintef-pyshop

You can also clone this repository and install the latest development version. To do this, open a terminal in the cloned pyshop directory and give the command:

pip install ".[all]"

You should now see pyshop appear in the list of installed python modules when typing:

pip list

Install pyshop using Gitlab Package Registry

Create a personal access token.

Run the command below with your personal access token: pip install "sintef-pyshop[all]" --index-url https://__token__:<your_personal_token>@gitlab.sintef.no/api/v4/projects/4012/packages/pypi/simple

2 Download the desired SHOP binaries for your system

NOTE: You may not distribute the CPLEX library as it requires end user license

The SHOP core is separate from the pyshop package, and must be downloaded separately. The latest SHOP binaries are found on the SHOP Portal. Access to the portal must be granted by SINTEF Energy Research.

The following binaries are required for pyshop to run:

Windows:

  • cplex2010.dll
  • shop_cplex_interface.dll
  • shop_utility.dll (since SHOP 17.2.0)
  • shop_pybind.pyd
  • shop_nanobind_backend.cp3XX-win_amd64.pyd (one per supported Python major version, the correct one is picked automatically at runtime)

Linux:

  • libcplex2010.so
  • shop_cplex_interface.so
  • libshop_utility.so (since SHOP 17.2.0)
  • shop_pybind.so (covers all Python major versions >= 3.10)

SHOP releases using the nanobind binding need the compiled nanobind backend from thenanobind-backend PyPI package on Linux, which sintef-pyshop installs as a dependency.

The solver specific binary is listed as cplex2010 here, but will change as new CPLEX versions become available. It is also possible to use the GUROBI and OSI solvers with SHOP. Note that the shop_cplex_interface.so used to contain the CPLEX binaries in the Linux distribution before SHOP version 14.3, and so older SHOP versions do not require the separate libcplex2010.so file.

3 Environment and license file

A working SHOP license file, SHOP_license.dat, is required to run SHOP through pyshop, and can be generated on the SHOP Portal. The environment variables SHOP_LICENSE_PATH and SHOP_BINARY_PATH can be used to tell SHOP where the files are located. The old environment variable ICC_COMMAND_PATH used for these purposes is now deprecated. Please see the "Environment variables" documentation page in the SHOP documentation on the SHOP Portal for further information. These environment variables can be overridden by manually specifying the license_path and solver_path input arguments when creating an instance of the ShopSession class, see step 4. Note that all binaries listed in step 2 should be located in the same directory, though SHOP versions older than 14.4.0.5 require libcplex2010.so to be placed in the '/lib' directory when running pyshop in a Linux environment.

4 Running SHOP

Now that pyshop is installed, the SHOP binaries are downloaded, and the license file and binary paths are located, it is possible to run SHOP in python using pyshop:

from pyshop import ShopSession

shop = ShopSession(license_path="C:/License/File/Path", solver_path="C:/SHOP/versions/latest")

Please visit the SHOP documentation for a detailed guides on how to use pyshop. For more in depth examples you should look at the topics within the documentation, since all of the examples in the documentation are written using pyshop. E.g: Run a standard optimization

Dataframe backends

See Dataframe backends for alternate getter outputs, setter input formats, and pandas-only features.

Visual Studio Code Dev Containers

Visual Studio Dev Containers lets you run a fully functional development environment using Docker and Visual Studio Code. This might simplify setting up pyshop for new users. Follow the guide below to setup the devcontainer for pyshop.

Installation

Install the following dependencies:

  1. Install the code editor called Visual Studio Code. Visual Studio Code is free
  2. Install a Docker GUI: Docker desktop (might require a paid license depending on your organization), or a free alternative called Podman

Setup

  1. Create a folder called .devcontainer in your root directory with a file called devcontainer.json. Your folder structure should look like the example below:

    Devcontainer folder setup

  2. Copy and paste the contents of devcontainer.json into your devcontainer.json file.

  3. Create a folder called bin in your root directory and add the following files: libcplex2010.so, shop_cplex_interface.so, libshop_utility.so (since SHOP 17.2.0), your shop license e.g SHOP_license.dat, shop pybind e.g shop_pybind.cpython-312-x86_64-linux-gnu.so. Your bin folder should now look like: Binary folder with the required files

  4. Open your project using the devcontainer config files by running the command: Searching for devcontainer command

More in depth guides on how to customize devcontainers can be found in the devcontainer documentation

Metadata

Release files for sintef-pyshop 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sintef-pyshop 2.1.0
File Size Uploaded Provenance Actions
sintef_pyshop-2.1.0.tar.gz 71.4 kB Without provenance Details for sintef_pyshop-2.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sintef-pyshop 2.1.0
File Interpreter ABI Platform Actions
sintef_pyshop-2.1.0-py3-none-any.whl Python 3 none any Details for sintef_pyshop-2.1.0-py3-none-any.whl

Total release size: 124.5 kB

Release files / sintef_pyshop-2.1.0.tar.gz

Download URL sintef_pyshop-2.1.0.tar.gz
Size 71.4 kB
Tags Source
SHA-256 checksum
How to use checksums
fcfa4e663514f94ec2ffaa2bc6cf099aaa3cf854457cca064125535da2de2048
BLAKE2b-256 checksum
How to use checksums
9e61f3844c8efbe08def45e48f8c5bfe33781a23f4f7c11caf597978fbf870b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Release files / sintef_pyshop-2.1.0-py3-none-any.whl

Download URL sintef_pyshop-2.1.0-py3-none-any.whl
Size 53.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5665c98bb3bea022b8817a3fe9fc3d78bdc27dcd6f09b414a820d41296b8dfd5
BLAKE2b-256 checksum
How to use checksums
cafdf00f937c679ada4ac950a122519fa10c9b866ad31a90dfef1b03697c2720
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Security for sintef-pyshop 2.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page