Skip to main content

StOpt Python bindings (C++ / pybind11)

Project description

The STochastic OPTimization library (StOpt) aims at providing tools in C++ for solving some stochastic optimization problems encountered in finance or in the industry. A python binding is available for some C++ objects provided permitting to easily solve an optimization problem by regression or tree methods. The possibility to create a R package for the regressors is also provided for linux and mac users. Different methods are available :

  • dynamic programming methods based on Monte Carlo with regressions (global, local , kernel and sparse regressors), for underlying states following some uncontrolled Stochastic Differential Equations (python binding provided). Transition problems can be solved by:
    • discretization of commands,
    • resolution of some LP and then the Bellman values are approximated by cuts
  • dynamic programming with a representation of uncertainties with a tree : transition problems are here solved by
    • some discretizations of the commands,
    • resolution of LP with cut representation of the Bellman values.
  • Semi-Lagrangian methods for Hamilton Jacobi Bellman general equations for underlying states following some controlled Stochastic Differential Equations (C++ only)
  • Stochastic Dual Dynamic Programming methods to deal with stochastic stocks management problems in high dimension. A SDDP module in python is provided. To use this module, the transitional optimization problem has to written in C++ and mapped to python (examples provided). Uncertainties can be given by Monte Carlo and can be represented by a state with a finite number of values (tree).
  • Some branching nesting methods to solve very high dimensional non linear PDEs and some appearing in HJB problems. Besides some methods are provided to solve by Monte Carlo some problems where the underlying stochastic state is controlled. For each method, a framework is provided to optimize the problem and then simulate it out of the sample using the optimal commands previously calculated. Parallelization methods based on OpenMP and MPI are provided in this framework permitting to solve high dimensional problems on clusters. The library should be flexible enough to be used at different levels depending on the user's willingness.

############################################################################################

GENERAL DOCUMENTATION AVAILABLE AT :

https://www.researchgate.net/project/The-STochastic-OPTimization-library-https-gitlabcom-stochastic-control-StOpt

or pick up latest version in :

https://hal.archives-ouvertes.fr/hal-01361291

############################################################################################

Please, while using the library for some research purpose, please cite:

@article{gevret2018stochastic, title={STochastic OPTimization library in C++}, author={Gevret, Hugo and Langren{'e}, Nicolas and Lelong, Jerome and Warin, Xavier and Maheshwari, Aditya}, year={2018} }

###########################################################################################

Licence : The library is published under the GNU LESSER GENERAL PUBLIC LICENSE (see LICENCE.txt, COPYING, COPYING.LESSER files)

###########################################################################################

News (2022/02) : from V5.0, MPI interface changes permitting to have two levels of MPI parallelization in a single software.

###########################################################################################

The library can be built on Linux/Mac/Windows using some recent compilers. It has been tested with

  • gcc, clang, intel icc, intel DPC++ on linux,
  • clang on mac
  • visual studio on windows (VS2019, VS2022)
  • intel DPC++ on windows

############################################################################################

############################################################################################

##################

Prerequisite

##################

StOpt library uses some external library. One is included in the package so do no need any installation :

The following libraries need to be installed :

StOpt relies on cmake for compilation http://www.cmake.org/ and permits to generate projects (Kdevelopp or Visual Studio for example).

##################################

Important for multithreading

##################################

StOpt uses multithread : so OMP_NUM_THREADS environment variable has to be set to a number of threads to use.

##################################

Important to use python

##################################

Python test case are located in StOpt/test/python. To use python the PYTHONPATH and LD_LIBRARY_PATH should be updated to include the directory containing the StOpt (.so, .pyd) library (default is the lib directory where the library is built). If the build is achieved in /home/ME/GIT_REPOS/BUILD_RELEASE_GCC then under linux and MacOS:

LD_LIBRARY_PATH=/home/ME/GIT_REPOS/BUILD_RELEASE_GCC/lib/:$LD_LIBRARY_PATH
PYTHONPATH=/home/ME/GIT_REPOS/BUILD_RELEASE_GCC/lib:$PYTHONPATH

####################################

INSTALLATION, TESTS LINUX/MAC

#################################### ####################################

Install package for zlib, bzip2, python, scipy (http://www.scipy.org/), eigen, boost (including boost mpi if necessary), cmake and cmake gui (ccmake) using your favorite package manager (apt, snap, yaourt, .. on linux, homebrew on Mac OS) Go to StOpt directory (containing directories geners-1.10.0, StOpt ...)

cd ..  
mkdir BUILD  
cd BUILD
cmake ../StOpt
cmake ../StOpt

(Rerun cmake so that the python libs can be found..) If packages for libraries are not in usual place, use ccmake (ccmake ../StOpt) to define included directories and libraries needed. In cmake gui define :

  • if python bindings should be compiled (default no)
  • if the library should use mpi (default true)
  • if the library should compile sddp test (default false (COIN CLP needed)) This gui can be called by
ccmake ../StOpt
make

Test cases are run by:

ctest

A package can be build using cpack :

  • for debian : cpack -G DEB
  • for Red Hat : cpack -G RPM
  • a GZIP compression : cpack -G TGZ

Installation in /usr/local

make install

For installation in given directory /home/toto/test (installation will be achieved in /home/toto/test/usr/local)

make DESTDIR=/home/toto/test install

It is also possible to have installation in /home/toto/test such that the directory tree looks like /home/toto/test/lib, /home/toto/test/include...

cmake -DCMAKE_INSTALL_PREFIX=/home/toto/test ../StOpt
make install

##########################################################################

Python test

##########################################################################

To run the python tests if library compiled with python (don't forget to update PYTHONPATH in your .bashrc):

cd ../StOpt/test/python
python -m unittest discover

In StOpt/test/python/functional python version of C++ test cases are available.

Two kind of mappings are available.

  • A first mapping is achieved at the grids and conditional expectation level.
  • A second one is achieved at a time step resolution level (file HighLevel.py)

In order to test python mpi :

mpirun -np x python test*HighLevelMpi.py

with "x" number of mpi processus generated.

special case for Mac User

The boost installation can be achieved with a package manager : homebrew for example will install the missing dependencies (openmpi ...) In case of a boost compîlation from source, check that "boost mpi" is compiled and installed. If not : In the directory where the boost file is decompressed,

./boostrap.sh

Edit a file user-config.jam and add (don't forget the space between mpi and ;)

using mpi ;
./bjam --user-config=user-config.jam install

Most of package can be installed with homebrew (eigen, pybind11). Only when activating the SDDP option, Coin utils, osi and clp have to be compiled and installed as the homebrew project only provide binaries.

##################################

INSTALLATION, TESTS WINDOWS :##

################################## ##################################

Minimal Requirement

  • Win 10
  • Visual Studio 2019

WINDOWS : Download CMake for Windows, git for windows, vcpkg and install them

Compile your own StOpt libs ( when using python bindings) to use the python library

#####################################################################################

Add python dependance in file vcpkg.json in StOpt directory if a special python version is needed

in vcpkg directory,

git rev-parse HEAD

get back builtin-base string

replace the builtin-base in the vcpkg.json file and modify it according to your python version

StOpt compilation and local vcpkg package installation

In the directory where StOpt is cloned :

mkdir BUILD
cd BUILD
SET VCPKG_FEATURE_FLAGS=versions
cmake -DCMAKE_TOOLCHAIN_FILE=VcpkgDir/vcpkg/scripts/buildsystems/vcpkg.cmake -DBUILD_SDDP=ON -DBUILD_DPCUTS=ON  ../StOpt
cmake --build . --config=Release

In order to use DPC++ on windows, ninja (https://ninja-build.org/) should be installed and use the tool chain:

cmake -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icx -GNinja -DCMAKE_TOOLCHAIN_FILE=VcpkgDir/vcpkg/scripts/buildsystems/vcpkg.cmake -DBUILD_SDDP=ON -DBUILD_DPCUTS=ON  ../StOpt
cmake --build . --config=Release

alternative : Create your own StOpt c++ vcpkg package (latest python)

#########################################################################

In vcpkg directory VcpkgDir (absolute path):

vcpkg install eigen3 --triplet x64-windows-release
vcpkg install mpi --triplet x64-windows-release
vcpkg install coinutils  --triplet x64-windows-release
vcpkg install coin-or-osi --triplet x64-windows-release
vcpkg install coin-or-clp --triplet x64-windows-release
vcpkg install boost --triplet x64-windows-release
vcpkg install boost-mpi --triplet x64-windows-release
vcpkg install pthreads --triplet x64-windows-release
vcpkg install python3 --triplet x64-windows-release

To install StOpt library from vcpkg registry, clone the git repo in a directory :

https://gitlab.com/stochastic-control/stopt-vcpkg-registry-with-python

In vcpkg directory :

vcpkg install stopt --overlay-ports=PathToVCPKGRegistry\stopt-vcpkg-registry-with-python\ports\stopt  --triplet x64-windows-release

###############################################################################

Helper for cmake compilation for projects using StOpt

###############################################################################

in utils directory, a file FindStOpt.cmake and a file FindGeners.cmake are provided to help compilation in projects using cmake

################################################################################

R package

###############################################################################

A readme.txt is available in directory StOpt/R

###############################################################################

Docker

###############################################################################

Thanks to Benjamin Texier a Dockerfile is available based on ubuntu and anaconda to test the python interface in a jupyter notebook

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

pystopt-6.3-cp313-cp313-win_amd64.whl (19.0 MB view details)

Uploaded CPython 3.13Windows x86-64

pystopt-6.3-cp313-cp313-manylinux_2_28_x86_64.whl (4.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

pystopt-6.3-cp313-cp313-macosx_15_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

pystopt-6.3-cp312-cp312-win_amd64.whl (19.0 MB view details)

Uploaded CPython 3.12Windows x86-64

pystopt-6.3-cp312-cp312-manylinux_2_28_x86_64.whl (4.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

pystopt-6.3-cp312-cp312-macosx_15_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

pystopt-6.3-cp311-cp311-win_amd64.whl (19.0 MB view details)

Uploaded CPython 3.11Windows x86-64

pystopt-6.3-cp311-cp311-manylinux_2_28_x86_64.whl (4.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

pystopt-6.3-cp311-cp311-macosx_15_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

pystopt-6.3-cp310-cp310-win_amd64.whl (19.0 MB view details)

Uploaded CPython 3.10Windows x86-64

pystopt-6.3-cp310-cp310-manylinux_2_28_x86_64.whl (4.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

pystopt-6.3-cp310-cp310-macosx_15_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

File details

Details for the file pystopt-6.3-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: pystopt-6.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 19.0 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pystopt-6.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 7bf6df8be660a2a5d6600c83d4217408d3b5b5ddc2da3b3911a4a818e6af636e
MD5 25131dc8eb8cfaee1805e534b770ac29
BLAKE2b-256 2c1cfe6e4f8dfe997892643f74cc9c8b725de06bd6beb3451129fa22ebec150c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pystopt-6.3-cp313-cp313-win_amd64.whl:

Publisher: build-wheels.yml on XWarin/stopt-wheels-builder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pystopt-6.3-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pystopt-6.3-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1beddf1c50c6e2e19fd990a4a033a4196c88a424336de16cc7f90384bfa85109
MD5 3c6e3552a9923ad03110fc3e9e7045ee
BLAKE2b-256 0932cefcc432afa468a372d6a2a17bd58460f190c7e25c7524a119de0d425378

See more details on using hashes here.

Provenance

The following attestation bundles were made for pystopt-6.3-cp313-cp313-manylinux_2_28_x86_64.whl:

Publisher: build-wheels.yml on XWarin/stopt-wheels-builder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pystopt-6.3-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pystopt-6.3-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 83c5588b562e5b0556f5226d886b035d0d80259d8c1a70f58e0b7da1ac73189e
MD5 263fe7959638a65e6f9d86bd720a595c
BLAKE2b-256 e4061faa927ea6454f520c40670abee735d84dd04adcc9eec56375b98aae900f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pystopt-6.3-cp313-cp313-macosx_15_0_arm64.whl:

Publisher: build-wheels.yml on XWarin/stopt-wheels-builder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pystopt-6.3-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pystopt-6.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 19.0 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pystopt-6.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f701843bf662aa951479936310391ff2dc7fb4f903014dc4bd4ed3a67801aa3c
MD5 7df8590dead64720f9b204970aaf1e43
BLAKE2b-256 424e113f2c5021986a122ae3b3d4ea266ecffe164efd69d89f72a006b5434926

See more details on using hashes here.

Provenance

The following attestation bundles were made for pystopt-6.3-cp312-cp312-win_amd64.whl:

Publisher: build-wheels.yml on XWarin/stopt-wheels-builder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pystopt-6.3-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pystopt-6.3-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8bd4fbd896cc6f566c6218b01f79473b517a88b2a0602888a2fb897a2f5550d2
MD5 555eb1a598967f0d0ca38710dfd50dfc
BLAKE2b-256 605a02b90e7e8c862bbe015c8efeef2e1a94a82cd4b6a45e4a9147b105b0e6b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pystopt-6.3-cp312-cp312-manylinux_2_28_x86_64.whl:

Publisher: build-wheels.yml on XWarin/stopt-wheels-builder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pystopt-6.3-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pystopt-6.3-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 0fc973f75e5928b6f9b4e5801ccf9dc2cf1c819097f228d87de3b246320880fa
MD5 06a0fca8170adc1286553811669df576
BLAKE2b-256 0692cc2f47199d5ee134553344b879eaf9dfd80b5c7f93aeff95e103507a24e7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pystopt-6.3-cp312-cp312-macosx_15_0_arm64.whl:

Publisher: build-wheels.yml on XWarin/stopt-wheels-builder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pystopt-6.3-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pystopt-6.3-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 19.0 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pystopt-6.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 e5ae62d4c4fe4be39e2ce5eec5be2275d004abae14497ca041458169904b078c
MD5 8bd80e2b8a2213859f5cd683d61c7bb7
BLAKE2b-256 c695e63658b53e33d738b8b355c20b600429accf681f0476749ecdb0ddc3396f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pystopt-6.3-cp311-cp311-win_amd64.whl:

Publisher: build-wheels.yml on XWarin/stopt-wheels-builder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pystopt-6.3-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pystopt-6.3-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 856af22879319bb4de5b91ecb37ecd258deb3341fa30dfdf46bb5fe73e75acde
MD5 2827f4807e6572fe474bc1b882b0c142
BLAKE2b-256 82ad3078e6fcd851b199a9841fcac53c98ef78197b0ab1c05b3d2485e0ffd9fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for pystopt-6.3-cp311-cp311-manylinux_2_28_x86_64.whl:

Publisher: build-wheels.yml on XWarin/stopt-wheels-builder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pystopt-6.3-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pystopt-6.3-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 d93708cb0758ad10419c40d457d71b2a05267bfbaf4ca7bb12d6e4bcb7892d53
MD5 fb0088070505406eb045c7c391016eeb
BLAKE2b-256 f05d22dfe1df13de44a1f8f7c4661d6b1c3d9793fea873203931037c1a8fdc9f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pystopt-6.3-cp311-cp311-macosx_15_0_arm64.whl:

Publisher: build-wheels.yml on XWarin/stopt-wheels-builder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pystopt-6.3-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pystopt-6.3-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 19.0 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pystopt-6.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b75c9c875a79a2239f3b8e1b57da2b645ad9655cf5f87fca862c6fd2dc360a69
MD5 0d4f4e375acc79714c9bcac77e535923
BLAKE2b-256 41a5b43a1b6ae4f1cd629cb1cc3e60025979ed337f5f187725cf5fabbf33be28

See more details on using hashes here.

Provenance

The following attestation bundles were made for pystopt-6.3-cp310-cp310-win_amd64.whl:

Publisher: build-wheels.yml on XWarin/stopt-wheels-builder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pystopt-6.3-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pystopt-6.3-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 98b554ff4bf80ad67993a3da4ad943da3f6077ede83551eb4987bdfb5b0d1760
MD5 05cc1b915e5c7db266d11d26458f52ba
BLAKE2b-256 a86b009dcbf0938bf0dabe06523a072f5a2505e1d3feafafbe6d09282b5366be

See more details on using hashes here.

Provenance

The following attestation bundles were made for pystopt-6.3-cp310-cp310-manylinux_2_28_x86_64.whl:

Publisher: build-wheels.yml on XWarin/stopt-wheels-builder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pystopt-6.3-cp310-cp310-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pystopt-6.3-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 9da72c3d40528f4b2cbec8018c85045e876ccabea569f33b677728556db21d1a
MD5 e6afcabbc69d3a0624f94d3f531cb6f2
BLAKE2b-256 8d3041d5d0c0b303b22feed5631a72d3ef135d8395d36e9e6c1fda669e368f2b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pystopt-6.3-cp310-cp310-macosx_15_0_arm64.whl:

Publisher: build-wheels.yml on XWarin/stopt-wheels-builder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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