encyclopegia.org

Stochastic dynamic programming

Originally introduced by Richard E.[src] Bellman in , stochastic dynamic programming (SDP) is a technique for modelling and solving problems of decision making under uncertainty.[src] Closely related to stochastic programming and dynamic programming, stochastic dynamic programming represents the problem under scrutiny in the form of a Bellman equation.[src] The aim is to compute a policy prescribing how to act optimally in the face of uncertainty.[src]

Originally introduced by Richard E.[src] Bellman in , stochastic dynamic programming (SDP) is a technique for modelling and solving problems of decision making under uncertainty.[src] Closely related to stochastic programming and dynamic programming, stochastic dynamic programming represents the problem under scrutiny in the form of a Bellman equation.[src] The aim is to compute a policy prescribing how to act optimally in the face of uncertainty.[src] Consider a discrete system defined on n stages in which each stage t=1,\ldots,n is characterized by an initial state s_t\in S_t , where S_t is the set of feasible states at the beginning of stage t ; a decision variable x_t\in X_t , where X_t is the set of feasible actions at stage t – note that X_t may be a function of the initial state s_t ; an immediate cost/reward function p_t(s_t,x_t) , representing the cost/reward at stage t if s_t is the initial state and x_t the action selected; a state transition function g_t(s_t,x_t) that leads the system towards state s_{t+1}=g_t(s_t,x_t) .[src] Let f_t(s_t) represent the optimal cost/reward obtained by following an optimal policy over stages t,t+1,\ldots,n .[src] Without loss of generality in what follow we will consider a reward maximisation setting.[src] In deterministic dynamic programming one usually deals with functional equations taking the following structure f_t(s_t)=\max_{x_t\in X_t}\{p_t(s_t,x_t)+f_{t+1}(s_{t+1})\} where s_{t+1}=g_t(s_t,x_t) and the boundary condition of the system is f_n(s_n)=\max_{x_n\in X_n}\{p_n(s_n,x_n)\}.[src] The aim is to determine the set of optimal actions that maximise f_1(s_1) .[src] Given the current state s_t and the current action x_t , we know with certainty the reward secured during the current stage and – thanks to the state transition function g_t – the future state towards which the system transitions.[src] In practice, however, even if we know the state of the system at the beginning of the current stage as well as the decision taken, the state of the system at the beginning of the next stage and the current period reward are often random variables that can be observed only at the end of the current stage.[src] Stochastic dynamic programming deals with problems in which the current period reward and/or the next period state are random, i.e.[src] with multi-stage stochastic systems.[src] The decision maker's goal is to maximise expected (discounted) reward over a given planning horizon.[src] In their most general form, stochastic dynamic programs deal with functional equations taking the following structure f_t(s_t)=\max_{x_t\in X_t(s_t)} \left\{(\text{expected reward during stage } t\mid s_t,x_t) + \alpha\sum_{s_{t+1}} \Pr(s_{t+1}\mid s_t,x_t)f_{t+1}(s_{t+1})\right\} where f_t(s_t) is the maximum expected reward that can be attained during stages t,t+1,\ldots,n , given state s_t at the beginning of stage t ; x_t belongs to the set X_t(s_t) of feasible actions at stage t given initial state s_t ; \alpha is the discount factor; \Pr(s_{t+1}\mid s_t,x_t) is the conditional probability that the state at the end of stage t is s_{t+1} given current state s_t and selected action x_t .[src] Markov decision processes represent a special class of stochastic dynamic programs in which the underlying stochastic process has state transitions satisfying the Markov property.[src] Gambling game can be formulated as a Stochastic Dynamic Program as follows: there are n=4 games (i.e.[src] stages) in the planning horizon the state s in period t represents the initial wealth at the beginning of period t ; the action given state s in period t is the bet amount b ; the transition probability p^a_{i,j} from state i to state j when action a is taken in state i is easily derived from the probability of winning (0.4) or losing (0.6) a game.[src] Let f_t(s) be the probability that, by the end of game 4, the gambler has at least $6, given that she has $ s at the beginning of game t .[src] the immediate profit incurred if action b is taken in state s is given by the expected value p_t(s,b)=0.4 f_{t+1}(s+b)+0.6 f_{t+1}(s-b) .[src] To derive the functional equation, define b_t(s) as a bet that attains f_t(s) , then at the beginning of game t=4 if s it is impossible to attain the goal, i.e.[src] f_4(s)=0 for s ; if s\geq 6 the goal is attained, i.e.[src] f_4(s)=1 for s\geq 6 ; if 3\leq s\leq 5 the gambler should bet enough to attain the goal, i.e.[src] f_4(s)=0.4 for 3\leq s\leq 5 .[src] For t the functional equation is f_t(s)=\max_{b_t(s)}\{ 0.4 f_{t+1}(s+b)+0.6 f_{t+1}(s-b)\} , where b_t(s) ranges in 0,...,s ; the aim is to find f_1(2) .[src] Given the functional equation, an optimal betting policy can be obtained via forward recursion or backward recursion algorithms, as outlined below.[src] f_1(2)= \min\left\{ \begin{array}{rr} b&\text{success probability in periods 1,2,3,4}\\ \hline 0&0.4f_{2}(2+0)+0.6f_{2}(2-0)\\ 1&0.4f_{2}(2+1)+0.6f_{2}(2-1)\\ 2&0.4f_{2}(2+2)+0.6f_{2}(2-2)\\ \end{array} \right.[src] At this point we have not computed yet f_{2}(4),f_{2}(3), f_{2}(2), f_{2}(1), f_{2}(0) , which are needed to compute f_1(2) ; we proceed and compute these items.[src] Note that f_{2}(2+0)= f_{2}(2-0)=f_{2}(2) , therefore one can leverage memoization and perform the necessary computations only once.[src] Computation of f_{2}(4),f_{2}(3), f_{2}(2), f_{2}(1), f_{2}(0) f_2(0)= \min\left\{ \begin{array}{rr} b&\text{success probability in periods 2,3,4}\\ \hline 0&0.4f_{3}(0+0)+0.6f_{3}(0-0)\\ \end{array} \right.[src] f_2(1)= \min\left\{ \begin{array}{rr} b&\text{success probability in periods 2,3,4}\\ \hline 0&0.4f_{3}(1+0)+0.6f_{3}(1-0)\\ 1&0.4f_{3}(1+1)+0.6f_{3}(1-1)\\ \end{array} \right.[src] f_2(2)= \min\left\{ \begin{array}{rr} b&\text{success probability in periods 2,3,4}\\ \hline 0&0.4f_{3}(2+0)+0.6f_{3}(2-0)\\ 1&0.4f_{3}(2+1)+0.6f_{3}(2-1)\\ 2&0.4f_{3}(2+2)+0.6f_{3}(2-2)\\ \end{array} \right.[src] f_2(3)= \min\left\{ \begin{array}{rr} b&\text{success probability in periods 2,3,4}\\ \hline 0&0.4f_{3}(3+0)+0.6f_{3}(3-0)\\ 1&0.4f_{3}(3+1)+0.6f_{3}(3-1)\\ 2&0.4f_{3}(3+2)+0.6f_{3}(3-2)\\ 3&0.4f_{3}(3+3)+0.6f_{3}(3-3)\\ \end{array} \right.[src] f_2(4)= \min\left\{ \begin{array}{rr} b&\text{success probability in periods 2,3,4}\\ \hline 0&0.4f_{3}(4+0)+0.6f_{3}(4-0)\\ 1&0.4f_{3}(4+1)+0.6f_{3}(4-1)\\ 2&0.4f_{3}(4+2)+0.6f_{3}(4-2) \end{array} \right.[src] We have now computed f_2(k) for all k that are needed to compute f_1(2) .[src] However, this has led to additional suspended recursions involving f_{3}(4), f_{3}(3), f_{3}(2), f_{3}(1), f_{3}(0) .[src] We proceed and compute these values.[src] Computation of f_{3}(4), f_{3}(3), f_{3}(2), f_{3}(1), f_{3}(0) f_3(0)= \min\left\{ \begin{array}{rr} b&\text{success probability in periods 3,4}\\ \hline 0&0.4f_{4}(0+0)+0.6f_{4}(0-0)\\ \end{array} \right.[src] f_3(1)= \min\left\{ \begin{array}{rr} b&\text{success probability in periods 3,4}\\ \hline 0&0.4f_{4}(1+0)+0.6f_{4}(1-0)\\ 1&0.4f_{4}(1+1)+0.6f_{4}(1-1)\\ \end{array} \right.[src] f_3(2)= \min\left\{ \begin{array}{rr} b&\text{success probability in periods 3,4}\\ \hline 0&0.4f_{4}(2+0)+0.6f_{4}(2-0)\\ 1&0.4f_{4}(2+1)+0.6f_{4}(2-1)\\ 2&0.4f_{4}(2+2)+0.6f_{4}(2-2)\\ \end{array} \right.[src] f_3(3)= \min\left\{ \begin{array}{rr} b&\text{success probability in periods 3,4}\\ \hline 0&0.4f_{4}(3+0)+0.6f_{4}(3-0)\\ 1&0.4f_{4}(3+1)+0.6f_{4}(3-1)\\ 2&0.4f_{4}(3+2)+0.6f_{4}(3-2)\\ 3&0.4f_{4}(3+3)+0.6f_{4}(3-3)\\ \end{array} \right.[src] f_3(4)= \min\left\{ \begin{array}{rr} b&\text{success probability in periods 3,4}\\ \hline 0&0.4f_{4}(4+0)+0.6f_{4}(4-0)\\ 1&0.4f_{4}(4+1)+0.6f_{4}(4-1)\\ 2&0.4f_{4}(4+2)+0.6f_{4}(4-2) \end{array} \right.[src] f_3(5)= \min\left\{ \begin{array}{rr} b&\text{success probability in periods 3,4}\\ \hline 0&0.4f_{4}(5+0)+0.6f_{4}(5-0)\\ 1&0.4f_{4}(5+1)+0.6f_{4}(5-1) \end{array} \right.[src] Since stage 4 is the last stage in our system, f_{4}(\cdot) represent boundary conditions that are easily computed as follows.[src] Boundary conditions \begin{array}{ll} f_4(0)=0&b_4(0)=0\\ f_4(1)=0&b_4(1)=\{0,1\}\\ f_4(2)=0&b_4(2)=\{0,1,2\}\\ f_4(3)=0.4&b_4(3)=\{3\}\\ f_4(4)=0.4&b_4(4)=\{2,3,4\}\\ f_4(5)=0.4&b_4(5)=\{1,2,3,4,5\}\\ f_4(d)=1&b_4(d)=\{0,\ldots,d-6\}\text{ for }d\geq 6 \end{array} At this point it is possible to proceed and recover the optimal policy and its value via a backward pass involving, at first, stage 3 Backward pass involving f_3(\cdot) f_3(0)= \min\left\{ \begin{array}{rr} b&\text{success probability in periods 3,4}\\ \hline 0&0.4(0)+0.6(0)=0\\ \end{array} \right.[src] f_3(1)= \min\left\{ \begin{array}{rrr} b&\text{success probability in periods 3,4}&\mbox{max}\\ \hline 0&0.4(0)+0.6(0)=0&\leftarrow b_3(1)=0\\ 1&0.4(0)+0.6(0)=0&\leftarrow b_3(1)=1\\ \end{array} \right.[src] f_3(2)= \min\left\{ \begin{array}{rrr} b&\text{success probability in periods 3,4}&\mbox{max}\\ \hline 0&0.4(0)+0.6(0)=0\\ 1&0.4(0.4)+0.6(0)=0.16&\leftarrow b_3(2)=1\\ 2&0.4(0.4)+0.6(0)=0.16&\leftarrow b_3(2)=2\\ \end{array} \right.[src] f_3(3)= \min\left\{ \begin{array}{rrr} b&\text{success probability in periods 3,4}&\mbox{max}\\ \hline 0&0.4(0.4)+0.6(0.4)=0.4&\leftarrow b_3(3)=0\\ 1&0.4(0.4)+0.6(0)=0.16\\ 2&0.4(0.4)+0.6(0)=0.16\\ 3&0.4(1)+0.6(0)=0.4&\leftarrow b_3(3)=3\\ \end{array} \right.[src] f_3(4)= \min\left\{ \begin{array}{rrr} b&\text{success probability in periods 3,4}&\mbox{max}\\ \hline 0&0.4(0.4)+0.6(0.4)=0.4&\leftarrow b_3(4)=0\\ 1&0.4(0.4)+0.6(0.4)=0.4&\leftarrow b_3(4)=1\\ 2&0.4(1)+0.6(0)=0.4&\leftarrow b_3(4)=2\\ \end{array} \right.[src] f_3(5)= \min\left\{ \begin{array}{rrr} b&\text{success probability in periods 3,4}&\mbox{max}\\ \hline 0&0.4(0.4)+0.6(0.4)=0.4\\ 1&0.4(1)+0.6(0.4)=0.64&\leftarrow b_3(5)=1\\ \end{array} \right.[src] and, then, stage 2.[src] Backward pass involving f_2(\cdot) f_2(0)= \min\left\{ \begin{array}{rrr} b&\text{success probability in periods 2,3,4}&\mbox{max}\\ \hline 0&0.4(0)+0.6(0)=0&\leftarrow b_2(0)=0\\ \end{array} \right.[src] f_2(1)= \min\left\{ \begin{array}{rrr} b&\text{success probability in periods 2,3,4}&\mbox{max}\\ \hline 0&0.4(0)+0.6(0)=0\\ 1&0.4(0.16)+0.6(0)=0.064&\leftarrow b_2(1)=1\\ \end{array} \right.[src] f_2(2)= \min\left\{ \begin{array}{rrr} b&\text{success probability in periods 2,3,4}&\mbox{max}\\ \hline 0&0.4(0.16)+0.6(0.16)=0.16&\leftarrow b_2(2)=0\\ 1&0.4(0.4)+0.6(0)=0.16&\leftarrow b_2(2)=1\\ 2&0.4(0.4)+0.6(0)=0.16&\leftarrow b_2(2)=2\\ \end{array} \right.[src] f_2(3)= \min\left\{ \begin{array}{rrr} b&\text{success probability in periods 2,3,4}&\mbox{max}\\ \hline 0&0.4(0.4)+0.6(0.4)=0.4&\leftarrow b_2(3)=0\\ 1&0.4(0.4)+0.6(0.16)=0.256\\ 2&0.4(0.64)+0.6(0)=0.256\\ 3&0.4(1)+0.6(0)=0.4&\leftarrow b_2(3)=3\\ \end{array} \right.[src] f_2(4)= \min\left\{ \begin{array}{rrr} b&\text{success probability in periods 2,3,4}&\mbox{max}\\ \hline 0&0.4(0.4)+0.6(0.4)=0.4\\ 1&0.4(0.64)+0.6(0.4)=0.496&\leftarrow b_2(4)=1\\ 2&0.4(1)+0.6(0.16)=0.496&\leftarrow b_2(4)=2\\ \end{array} \right.[src] We finally recover the value f_1(2) of an optimal policy f_1(2)= \min\left\{ \begin{array}{rrr} b&\text{success probability in periods 1,2,3,4}&\mbox{max}\\ \hline 0&0.4(0.16)+0.6(0.16)=0.16\\ 1&0.4(0.4)+0.6(0.064)=0.1984&\leftarrow b_1(2)=1\\ 2&0.4(0.496)+0.6(0)=0.1984&\leftarrow b_1(2)=2\\ \end{array} \right.[src] This is the optimal policy that has been previously illustrated.[src] Note that there are multiple optimal policies leading to the same optimal value f_1(2)=0.1984 ; for instance, in the first game one may either bet $1 or $2.[src] Python implementation.[src] The one that follows is a complete Python implementation of this example.[src] import functools class memoize: def __init__(self, func): self.func = func self.memoized = {} self.method_cache = {} def __call__(self, *args): return self.cache_get(self.memoized, args, lambda: self.func(*args)) def __get__(self, obj, objtype): return self.cache_get( self.method_cache, obj, lambda: self.__class__(functools.partial(self.func, obj)), ) def cache_get(self, cache, key, func): try: return cache[key] except KeyError: cache[key] = func() return cache[key] def reset(self): self.memoized = {} self.method_cache = {} class State: """The state of the gambler's ruin problem""" def __init__(self, t: int, wealth: float): """state constructor Arguments: t {int} -- time period wealth {float} -- initial wealth """ self.t, self.wealth = t, wealth def __eq__(self, other): return self.__dict__ == other.__dict__ def __str__(self): return str(self.t) + " " + str(self.wealth) def __hash__(self): return hash(str(self)) class GamblersRuin: def __init__( self, bettingHorizon: int, targetWealth: float, pmf: list[list[tuple[int, float ], ): """The gambler's ruin problem.[src] Arguments: bettingHorizon {int} -- betting horizon targetWealth {float} -- target wealth pmf {list[list[tuple[int, float ]} -- probability mass function """ # initialize instance variables self.bettingHorizon, self.targetWealth, self.pmf = ( bettingHorizon, targetWealth, pmf, ) # lambdas self.ag = lambda s: [ i for i in range(0, min(self.targetWealth // 2, s.wealth) + 1) ] # action generator self.st = lambda s, a, r: State( s.t + 1, s.wealth - a + a * r ) # state transition self.iv = ( lambda s, a, r: 1 if s.wealth - a + a * r >= self.targetWealth else 0 ) # immediate value function self.cache_actions = {} # cache with optimal state/action pairs def f(self, wealth: float) -> float: s = State(0, wealth) return self._f(s) def q(self, t: int, wealth: float) -> float: s = State(t, wealth) return self.cache_actions[str(s)] @memoize def _f(self, s: State) -> float: # Forward recursion values = [sum([p[1]*(self._f(self.st(s, a, p[0])) if s.t Java implementation.[src] GamblersRuin.java is a standalone Java 8 implementation of the above example.[src] ==Sources== .[src] Dover paperback edition (2003) .[src] In two volumes.[src]

71 sentences · 71 cited inline · 0 references stored

References

No reference rows published for this article.

Cite this article

MLA

"Stochastic dynamic programming." encyclopegia.org, 2026, https://encyclopegia.org/wiki/stochastic-dynamic-programming. Accessed 25 November 2026.

Chicago

"Stochastic dynamic programming." encyclopegia.org. Accessed November 25, 2026. https://encyclopegia.org/wiki/stochastic-dynamic-programming.

APA

encyclopegia.org. (2026). Stochastic dynamic programming. Retrieved November 25, 2026, from https://encyclopegia.org/wiki/stochastic-dynamic-programming

Accessed November 25, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

Dynamic Host Configuration Protocol

stub · references available

Category:Programming languages

stub · references available

programming paradigm

stub · references available

extreme programming

stub · references available

high-level programming language

stub · references available

logic programming

stub · references available

return-oriented programming

stub · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1373671007 · 0.5 · snapshot enwiki-001373671007

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.