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.2.1-cp312-cp312-win_amd64.whl (18.6 MB view details)

Uploaded CPython 3.12Windows x86-64

pystopt-6.2.1-cp312-cp312-manylinux_2_28_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

pystopt-6.2.1-cp312-cp312-macosx_11_0_arm64.whl (1.8 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pystopt-6.2.1-cp311-cp311-win_amd64.whl (18.6 MB view details)

Uploaded CPython 3.11Windows x86-64

pystopt-6.2.1-cp311-cp311-manylinux_2_28_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

pystopt-6.2.1-cp311-cp311-macosx_11_0_arm64.whl (1.8 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pystopt-6.2.1-cp310-cp310-win_amd64.whl (18.6 MB view details)

Uploaded CPython 3.10Windows x86-64

pystopt-6.2.1-cp310-cp310-manylinux_2_28_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

pystopt-6.2.1-cp310-cp310-macosx_11_0_arm64.whl (1.8 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for pystopt-6.2.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9d88b3a9fbeef155f13651a779be5fd4bb1b4bb8be0696badef9b61b3dc70713
MD5 2842f8273024efd4febdbbaf900a437c
BLAKE2b-256 b07c89cef85cd70f49011db06c08678679b5084bc23513aad9277bc8a14da71a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pystopt-6.2.1-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.2.1-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pystopt-6.2.1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 821bfbd31f7347f67c907d9731ac83f9bf9a51caa18f334cc96ffbf2340a2d41
MD5 944d830acc7987623e923a8a707caaf7
BLAKE2b-256 59e06821681cc3374268481966a74d5a548dd3f3c0d19dccbaff740a0b033892

See more details on using hashes here.

Provenance

The following attestation bundles were made for pystopt-6.2.1-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.2.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pystopt-6.2.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8fc4010d14ca3d9dcdb8a44955f652bd868af8130ec9f27f0e625ad39ff1ad3a
MD5 1007f72a7ae073f5ecfce481fbd51cee
BLAKE2b-256 9654ebb98681a0dc67dbc016add7475a076917b3d344efc104be70f93b9c481d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pystopt-6.2.1-cp312-cp312-macosx_11_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.2.1-cp311-cp311-win_amd64.whl.

File metadata

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

File hashes

Hashes for pystopt-6.2.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 096f30585a158bcb4f93ad4aa88b43e6dbdb0d2b4df33e2bf726abe2f3ed592d
MD5 fe56487d44e416f787c46b34d8c01aed
BLAKE2b-256 75b68c54bdaa6661843bfb8e6e5374c79bb5ee490e01a51ab70f98bdad2f5465

See more details on using hashes here.

Provenance

The following attestation bundles were made for pystopt-6.2.1-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.2.1-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pystopt-6.2.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 916f872abe389f6d51c94c4d05fc30a5ab8b7e0f30ed59ae1cd91e753043e324
MD5 d8f750d36d8e8e4c3f87459a5f5be701
BLAKE2b-256 03eeef9e5d862cb8ec4afd8c4f41f12cf301ac85ac045510b518428f9efd04ab

See more details on using hashes here.

Provenance

The following attestation bundles were made for pystopt-6.2.1-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.2.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pystopt-6.2.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 450121016a90576939b91c54c2d3ce5d57d597b23ddd46b0a0441d7a36ef88b0
MD5 fe59c65837a966f4503fbcac8c894469
BLAKE2b-256 671316c2c599afa26f901b884d5f7497cce8fcd516f3e5b2a44c5a8d7ac6d896

See more details on using hashes here.

Provenance

The following attestation bundles were made for pystopt-6.2.1-cp311-cp311-macosx_11_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.2.1-cp310-cp310-win_amd64.whl.

File metadata

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

File hashes

Hashes for pystopt-6.2.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a79d58687c29b266285207e8a8cb5a7641236a5d233f52312de72fb70be1d4d6
MD5 9502ca86390ae78607021d53260922a6
BLAKE2b-256 c39bcb22ea57101936f83527cc3458c3f0121370f159d8089979a6dfcd6da923

See more details on using hashes here.

Provenance

The following attestation bundles were made for pystopt-6.2.1-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.2.1-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pystopt-6.2.1-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cbd00f6bee76d41a325bf07b18b725751040251ba13928682157a00dbc6e180c
MD5 ec3bb5bffa446d03f33ded7ebc1fa18b
BLAKE2b-256 33635bf6ca41c8b66a2fae7f71a8d607c00fd386008f6c3a29a035a075bb7591

See more details on using hashes here.

Provenance

The following attestation bundles were made for pystopt-6.2.1-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.2.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pystopt-6.2.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e34cd3d24a24bb82bf3bb3e3d2423159245399cf96065e53929dc3084fc7dbe1
MD5 3567f65b677b88a47d39701afcc59446
BLAKE2b-256 10d982791970b7d03e308418e5e321742a5b9807ddb160d8deca82c06d0ad476

See more details on using hashes here.

Provenance

The following attestation bundles were made for pystopt-6.2.1-cp310-cp310-macosx_11_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