一个马尔科夫链实例

马尔科夫早就了解过,但一直没有真正用马尔科夫的思想求解问题,更没有用到论文中去。

最近发现了一本好书: 《Foundations of stochastic inventory theory》,斯坦福大学出版的。这本书不厚,才 200多页,讲的比较清晰,目测比其他库存管理的教材要好,准备精度完这本书。

下面探讨书中的一个马尔科夫实例。

1. 状态(state)

一个零售商面对的顾客有两种状态,
状态 s1: 上一个月买过该零售商的商品
状态 s2:上一个月没有买过该零售商的商品

2. 决策 (action)

零售商可以做出 3 个决策及对应的决策成本:
决策 a1 : 什么都不做 成本:0
决策 a2 : 发礼物,小促销 成本:0.5
决策 a3: 发礼物, 大促销 成本:0.5

3. 状态转移及转移概率 (transition equation and possibility)
Initial state sssAction aaaNext state1 and possibility ps1ap_{s_1}^{a}ps1aNext state2 and possibility ps2ap_{s_2}^{a}ps2a
s1a1s1, 0.99s2, 0.01
s1a2s1, 0.93s2, 0.07
s1a3s1, 0.85s2, 0.15
s2a1s1, 0.80s2, 0.20
s2a2s1, 0.72s2, 0.28
s2a3s1, 0.50s2, 0.50
4. 折现率 (discount factor)

折现率 α=0.99\alpha=0.99α=0.99
有效转移概率 qsja=α∗psjaq_{s_j}^a=\alpha*p_{s_j}^aqsja=αpsja

####5. 即时收益(immediate value)
若顾客不购买商品,收益为 0;
不促销时,顾客购买商品,收益为 8;
小促销时,顾客购买商品,收益为 7;
大促销时,顾客购买商品,收益为 3;

减去成本,得到的期望即时回报(immediate return)r(s,a)r(s, a)r(s,a) 为:

Initial state sssAction aaaAction cost c(a)c(a)c(a)Expected immediate return
s1a100.99*(0.990+0.018)-0 = 0.08
s1a20.50.99*(0.930+0.077)-0.5 = -0.01
s1a30.50.99*(0.850+0.153)-0.5 = -0.05
s2a100.99*(0.80+0.28)-0 = 1.6
s2a20.50.99*(0.720+0.287)-0.5 = 1.4
s2a30.50.99*(0.50+0.53)-0.5 = 1

若是单周期决策,从上表可以看出,不论初始状态是什么,最有决策都是 a1a1a1,即不促销不发礼物。

6. 两阶段决策

若是两阶段决策,则期望回报和需要再算一层。

Initial state sssAction aaaAction cost c(a)c(a)c(a)Expected immediate returnExpected sum immediate return
s1a100.99*(0.990+0.018)-0 = 0.080.08 + 0.99*(0.990.08+0.011.6)=0.1736
s1a20.50.99*(0.930+0.077)-0.5 = -0.01-0.01 + 0.99*(0.930.08+0.071.9)=0.17
s1a30.50.99*(0.850+0.153)-0.5 = -0.05-0.05+0.99(0.850.08+0.151.6)=0.2
s2a100.99*(0.80+0.28)-0 = 1.60.6+0.99(0.850.08+0.151.6)=1.87
s2a20.50.99*(0.720+0.287)-0.5 = 1.41.4+0.99(0.850.08+0.151.6)=1.85
s2a30.50.99*(0.50+0.53)-0.5 = 11+0.99(0.850.08+0.151.6)=1.75

从上表可以得出最优决策策略是:若初始状态为 s1s_1s1,最优决策 a3a_3a3,即大促销;若初始状态为 s2s_2s2, 最优决策 a1a_1a1,即不促销。

7. 最优递推方程

定义 fn(s)f^{n}(s)fn(s) 表示初始状态为 sss,之后 nnn 个阶段的最优期望回报,则最优递推方程可以表示为:
fn(s)=max⁡ar(s,a)+α∑jpsjfn−1(j)f^{n}(s)=\max_{a}\quad r(s, a)+\alpha\sum_j p_{sj}f^{n-1}(j)fn(s)=amaxr(s,a)+αjpsjfn1(j)

更规范的可以这样写:
fn(s)=sup⁡a∈Ar(s,a)+α∑jpsjfn−1(j)f^{n}(s)=\sup_{a\in A}\quad r(s, a)+\alpha\sum_j p_{sj}f^{n-1}(j)fn(s)=aAsupr(s,a)+αjpsjfn1(j)

界限方程一般是: f0(s)=v(s)f^{0}(s)=v(s)f0(s)=v(s)

这就是一个动态规划表达式。

Rebuild started: Project: Project *** Using Compiler 'V6.22', folder: 'E:\Keil_v5\ARM\ARMCLANG\Bin' Rebuild target 'Target 1' assembling startup_stm32f10x_md.s... Start/core_cm3.c(445): error: non-ASM statement in naked function is not supported 445 | uint32_t result=0; | ^ Start/core_cm3.c(442): note: attribute is here 442 | uint32_t __get_PSP(void) __attribute__( ( naked ) ); | ^ Start/core_cm3.c(465): error: parameter references not allowed in naked functions 465 | "BX lr \n\t" : : "r" (topOfProcStack) ); | ^ Start/core_cm3.c(461): note: attribute is here 461 | void __set_PSP(uint32_t topOfProcStack) __attribute__( ( naked ) ); | ^ Start/core_cm3.c(479): error: non-ASM statement in naked function is not supported 479 | uint32_t result=0; | ^ Start/core_cm3.c(476): note: attribute is here 476 | uint32_t __get_MSP(void) __attribute__( ( naked ) ); | ^ Start/core_cm3.c(499): error: parameter references not allowed in naked functions 499 | "BX lr \n\t" : : "r" (topOfMainStack) ); | ^ Start/core_cm3.c(495): note: attribute is here 495 | void __set_MSP(uint32_t topOfMainStack) __attribute__( ( naked ) ); | ^ 4 errors generated. compiling core_cm3.c... compiling misc.c... compiling system_stm32f10x.c... compiling stm32f10x_adc.c... compiling stm32f10x_dac.c... compiling stm32f10x_exti.c... compiling stm32f10x_dbgmcu.c... compiling stm32f10x_dma.c... compiling stm32f10x_crc.c... compiling stm32f10x_cec.c... compiling stm32f10x_bkp.c... compiling stm32f10x_can.c... compiling stm32f10x_flash.c... compiling stm32f10x_pwr.c... compiling stm32f10x_fsmc.c... compiling stm32f10x_
03-31
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

心态与习惯

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值