Skip to main content

Python interface to Prodrisk

Project description

pyprodrisk

The nicest python interface to Prodrisk!

Prodrisk is a modeling tool for medium-term hydro operation planning developed by SINTEF Energy Research in Trondheim, Norway. Prodrisk is used for both scientific and commerical purposes, please visit the Prodrisk home page for further information and inquiries regarding access and use.

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

1 Installing pyprodrisk

The pyprodrisk package can be installed using pip, the package installer for python. Please visit the pip home page for installation and any pip related issues. You can install the official pyprodrisk release through the terminal command:

pip install pyprodrisk

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

pip install .

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

pip list

This package contains optional dependencies for certain functions. To install these, use:

pip install pyprodrisk[full]

2 Download the desired Prodrisk binaries for your system

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

The Prodrisk core and API are separate from the pyprodrisk package, and must be downloaded separately. The latest Prodrisk binaries are found on the Prodrisk portal. Access to the portal must be granted by SINTEF Energy Research.

The following binaries are required for pyprodrisk to run:

Windows:

  • A ltm_core_bin folder containing the prodrisk and genpris binaries, and cplex2010.dll (only needed if you have a HPO license).
  • The Prodrisk API binary prodrisk_pybind.pyd

Linux:

  • A ltm_core_bin folder containing the prodrisk- and genpris binaries, and cplex2010.dll (only needed if you have a HPO license).
  • The Prodrisk API binary prodrisk_pybind.so

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 OSI coin solver with Prodrisk, by setting the attribute use_coin_osi=True on a Prodrisk session object.

3 Environment and license file

To use a license file to access your Prodrisk license, the environment variable LTM_LICENSE_CONTROL_SYSTEM should be set to TRUE (note: all capical letters!).

The Prodrisk license file, LTM_License.dat, must always be located in the directory specified by the environment variable LTM_LICENSE_PATH. The LTM_LICENSE_PATH can be added as a persistent environment variable in the regular ways, or it can be set by pyprodrisk on a session basis. If the keyword argument license_path is specified when creating an instance of the ProdriskSession class (see step 4), the environment variables LTM_LICENSE_CONTROL_SYSTEM is set to TRUE, and LTM_LICENSE_PATH and is overridden in the local environment of the executing process. If Prodrisk complains about not finding the license file, it is likely an issue with the LTM_LICENSE_PATH and/or LTM_LICENSE_CONTROL_SYSTEM are not being correctly specified.

The LTM_LICENSE_PATH is also the default place pyprodrisk will look for the Prodrisk API binary prodrisk_pybind mentioned in step 2. If the binaries are placed elsewhere, the keyword argument solver_path must be used when a ProdriskSession instance is created to ensure the correct binaries are loaded.

The setting attribute prodrisk_path should be set on a ProdriskSession to the directory where the ltm_core_bin (prodrisk and genpris binaries) mentioned in step 2 is installed, e.g. prodrisk.prodrisk_path = "/path/to/ltm_core_bin/"

Note that libcplex2010.so also may be placed in the '/lib' directory when running pyprodrisk in a Linux environment.

4 Running Prodrisk

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

import pyprodrisk as pys

prodrisk = pys.ProdriskSession(license_path="C:/License/File/Path", solver_path="C:/Prodrisk/versions/10.3.0")
prodrisk.prodrisk_path = "C:/Prodrisk/versions/10.3.0/ltm_core_bin/"

#If you have a HPO license you may use the cplex solver:
prodrisk.use_coin_osi = False

#Set time resolution
#Build topolgy
#Add temporal input
#Run model
#Retreive results

Please visit the Prodrisk Portal for a detailed tutorial and several examples using pyprodrisk.

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

pyprodrisk-2.0.1.tar.gz (23.8 kB view details)

Uploaded Source

Built Distribution

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

pyprodrisk-2.0.1-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file pyprodrisk-2.0.1.tar.gz.

File metadata

  • Download URL: pyprodrisk-2.0.1.tar.gz
  • Upload date:
  • Size: 23.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for pyprodrisk-2.0.1.tar.gz
Algorithm Hash digest
SHA256 26bb3364e492a6db37f8da726a9b34a0f0422d3e3ea4c644b409a7094e8ae3e5
MD5 167eceac8fd9a5efc0b81abe4e1abd7a
BLAKE2b-256 c15ed627a6154402608c224e680a45e3aa1a76cedd3f51c952a17bdc1c004c46

See more details on using hashes here.

File details

Details for the file pyprodrisk-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: pyprodrisk-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 22.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for pyprodrisk-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4d4d2e9d102d1fa492e5f2adedc14dd085ec34f1a7b922078727884fc60e9861
MD5 60bc5ac2d988c762a7abef9aa9c779fc
BLAKE2b-256 6119a697f668edce8d039ed6b9fbd3fab2939cce73b50349518c19c7d747041e

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