stochasticdp
A simple implementation of backwards induction for solving finite-horizon, finite-space stochastic dynamic programs.
Installation
stochasticdp is available on PyPI:
pip install stochasticdp
Usage
To initialize a stochastic dynamic program:
dp = StochasticDP(number_of_stages, states, decisions, minimize)
where
number_of_stages is an integer
states is a list
decisions is a list
minimize is a boolean
This results in a stochastic dynamic program with stages numbered 0, ..., number_of_stages - 1, and initializes the following dictionaries:
dp.probability, where dp.probability[m, n, t, x] is the probability of moving from state n to state m in stage t under decision x
dp.contribution, where dp.contribution[m, n, t, x] is the immediate contribution of resulting from moving from state n to state m in stage t under decision x
dp.boundary, where dp.boundary[n] is the boundary condition for the value-to-go function at state n
You only need to define probabilities and contributions for transitions that occur with positive probability.
You can use the following helper functions to populate these dictionaries:
# This sets dp.probability[m, n, t, x] = p and dp.contribution[m, n, t, x] = c
dp.add_transition(stage=t, from_state=n, decision=x, to_state=m, probability=p, contribution=c)
# This sets dp.boundary[n] = v
dp.boundary(state=n, value=v)
To solve the stochastic dynamic program:
value, policy = dp.solve()
where
value is a dictionary: value[t, n] is the value-to-go function at stage t and state n
policy is a dictionary: policy[t, n] is the set of optimizers of value[t, n]
Metadata
Release files for stochasticdp 0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| stochasticdp-0.4.tar.gz | 4.1 kB | Without provenance | Details for stochasticdp-0.4.tar.gz |
Release files / stochasticdp-0.4.tar.gz
| Download URL | stochasticdp-0.4.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
355d8925f3cc2d477685d38b99bf162716fd0e053713f8634a376ce39ab21cde
|
|
BLAKE2b-256 checksum How to use checksums |
c5685486738b05b0952855e1d347647e5cc6c10ad5be819157cb8ddfe869e990
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for stochasticdp 0.4
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.