Stochastic Optimization: Casual Notes

本文深入探讨了随机优化(SO)的基本概念、理论依据及应用,对比了确定性问题与不确定性问题的处理方法,详细解释了阶段、周期、瞬态模型与稳态模型等关键概念。文中介绍了几种重要的SO参考书籍,并讨论了场景生成、非预期性原则、地平线效应等核心议题,同时提出了三种评估离散化质量的方法。

Currently learning stochastic optimization (SO) theory, I will note important content here. Some book references are:

  1. King & Wallace (2012) Modeling with Stochastic Programming. This one focus on how to model a problem rather than how to solve it. Less math is involved, good for beginner.
  2. Birge, John R., and Francois Louveaux. Introduction to stochastic programming. Springer Science & Business Media, 2011.
  3. Shapiro, Alexander, Darinka Dentcheva, and Andrzej Ruszczyński. Lectures on stochastic programming: modeling and theory. Society for Industrial and Applied Mathematics, 2014.

Why do we need it

  • The real world problem is never deterministic
  • Sensitivity Analysis is not a way of handling uncertainty. It’s an analysis of deterministic decision problems.
  • Parameter estimations are always wrong.

Concepts

  • Stage: time points where we make decisions after learning something new. Stages must be identified first. Different models follows with different definition of stages.
  • Period: the time clock. Often defined according to the occurence of random events. For example, consider a facility location problem considering random daily demands in the future. Fixing the location of facilities is one-stage decision, while the random demands occur every day, so it is about multi-period.
  • Transient modeling vs Steady-state modeling. The former mean we make decision now based on what we have now. While the latter provide all possible decisions on all possible scenarios. SO is about the former one. For the later, I’d call it ‘anticipativity’, it’s treated by Stochastic DP…
  • Time line: a SO modeling is not clear until the time line is drawn:
    1st stage decision (here and now) -> some uncertainty disclosed -> 2nd stage decision (wait and see)-> some uncertainty disclosed…

Stages

As i understood, the basic form of a two-stage problem:
optimize f(x)+Eξ(min⁡y(w,x)+q(w))f(x) + E_{\xi}(\min y(w,x) + q(w))f(x)+Eξ(miny(w,x)+q(w))
where xxx is the first-stage decision, while w∈ξw\in \xiwξ is a random event. The objective is to find the optimal FIRST-STAGE decision resulting the best expected profit/cost.

  • Inherently two-stage: first stage is long term investment and the second stage is short term usage of this investment. Two stage, two different decision types.

  • Inherently multi-stage: many stages, same type of decision.

  • Two stage or multi-stage? It depends on the modeler. If the decision is made in a rolling horizon manner, then instead of make a multi-stage model, we may use two-stage as a simplification. Later stages are aggregated since we do not need so much detail.

  • Non-anticipativity: if two scenarios are indistinguishable before time t, then the action taken at time t on each scenario must be the same.

  • Horizon effect in multistage SO: some multistage problem has infinite time horizon. When the horizon is long, we are approaching a steady-state, but in SO we only care about the transient decision, so we have to represent the steady state in the model in order to obtain the right transient behavior. We don’t really care what to do far in the future.

To deal with horizon effect, King & Wallace (2012) presented what they call Dual Equilibrium as a tool to consider infinite stead-stage effect into the SO model. Check chapter 2.3.6.

Scenario generation

A SO is often solved in its deterministic form based on a number of scenarios generated to describe the uncertainty. To do this, firstly we must generate scenarios correctly.

It’s important to realize, that we pass from random variables to discretization because of the algorithm that we are choosing. So it’s important to ensure that the discretization is not too far from reality W.R.T the ALGORITHM!

Algorithms that do not need scenarios as input

  • stochastic decomposition. Need very efficient implementation and only for linear programs.
  • stochastic quasi-gradients
  • importance sampling

Use scenarios trees as input
Two problems:

  • A small number of scenarios => bad result. Quality depends on the randomness of generation.
  • A great number of scenarios => too large to be solved…

Where to sample from : if you do not have reliable information on the true distribution, just use the empirical one !

What is a good discretization?
It depends on the model! Our aim is not to approximate the real distribution, instead, we want the algorithm to feel like using the real distribution.

Approach 1

  • in-sample stability: f(xi∗,Ti)≈f(xj∗,Tj)f(x^*_i,\Tau_i)\approx f(x^*_j,\Tau_j)f(xi,Ti)f(xj,Tj)
  • out-of-sample stability: f(xi∗,ξ)≈f(xj∗,ξ)f(x^*_i,\xi)\approx f(x^*_j,\xi)f(xi,ξ)f(xj,ξ). The rhs can be computed by a simulation model with much more scenarios, or simply, by testing f(xi∗,Tj)≈f(xj∗,Ti)f(x^*_i,\Tau_j)\approx f(x^*_j,\Tau_i)f(xi,Tj)f(xj,Ti)
  • Bias. It can be both in and out sample stable, but bad… This should be tested by statistical methods, i.e. evaluating the quality of solution, in addition to the stability.

Approach 2
Replicate the distribution by respecting some important properties like: first moment, second moment, third moment… Use some regression methods to do this or use the iterative procedure provided by King & Wallace (2012).
Approach 3
Generating scenarios by minimizing the distance between the generated one and the real one. This is called scenario reduction methods. It’s used when we somehow know the distribution but want to use minimum number of scenarios to represent it. This must integrate an optimization procedure into the scenario generation module.

Optimality gap estimators

  • Use the expectation of solutions on many trees as an estimator of the expectation of solutions over the true distribution, some bound results can be derived.
`jags.model` 函数在执行时出现 Compiling model graph、Resolving undeclared variables、Allocating nodes、Initializing model 相关问题,可能有以下原因及解决办法: ### 模型编译耗时过长 若数据量较大或者模型较为复杂,编译过程可能需要较长时间。可通过减少数据量或简化模型结构来解决。例如,减少观测值数量或减少模型中的参数数量。同时,在运行代码前关闭不必要的程序,以释放系统资源,提高编译速度。 ### 内存不足 如果数据集非常大或者模型结构复杂,可能会导致 R 耗尽系统内存。可以使用 `memory.size()` 和 `memory.limit()` 函数来查看和调整 R 的内存限制。代码示例如下: ```R # 查看当前内存使用情况 memory.size() # 增加内存限制(仅适用于 Windows 系统) memory.limit(size = 8000) ``` ### 代码语法错误 虽然当前代码本身可能没有语法错误,但后续代码可能存在语法问题,导致 R 在执行时出错并停止。可以仔细检查后续代码是否存在拼写错误、缺少括号、引号不匹配等问题。例如,在模型代码中,确保所有的括号、方括号和引号都正确配对。 ### JAGS 模型文件或数据问题 `model_string` 可能包含错误的 JAGS 模型代码,或者 `data` 和 `inits` 中的数据格式不正确,导致 `jags.model` 函数无法正确编译模型。可以检查 `model_string` 的语法,以及 `data` 和 `inits` 的数据类型和结构是否符合 JAGS 的要求。例如,在 JAGS 模型中,确保所有变量都被正确声明和使用。以下是一个简单的 JAGS 模型示例: ```R Ozone_model <- "model{ # Likelihood # Random effects for(i in 1:ns){ alpha[i] ~ dnorm(0, 1) } for(j in 1:nt){ gamma[j] ~ dnorm(0, 1) } # Priors mu ~ dnorm(0,0.01) }" dat <- list(ns = 10, nt = 10) init <- list(alpha = rep(0, 10), gamma = rep(0, 10), mu = 0) model1 <- jags.model(textConnection(Ozone_model), inits = init, data = dat, n.chains = 1) ``` ### 包依赖问题 如果没有正确安装或加载 `rjags` 包,代码可能会出现问题。可以使用以下代码确保 `rjags` 包已正确安装和加载: ```R if (!require(rjags)) { install.packages("rjags") library(rjags) } ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值