Closed amirmm11 closed 1 year ago
I don't think @martinbiel has added risk. But you can model CVaR as a risk-neutral stochastic program using the primal formulation of CVaR.
I haven't tested, but something like this should work:
# CVaR_α[Z] = min ζ + 1 / α * E[(Z - ζ)₊]
# CVaR_α[Z] = min ζ + E[1 / α * (Z - ζ)₊]
# Make ζ a first-stage decision, then mimimize in expectation
@stochastic_model simple_model begin
@stage 1 begin
@decision(simple_model, x₁ >= 40)
@decision(simple_model, x₂ >= 20)
@decision(simple_model, ζ) # VaR quantile
@objective(simple_model, Min, 100*x₁ + 150*x₂ + ζ) # Add ζ
@constraint(simple_model, x₁ + x₂ <= 120)
end
@stage 2 begin
@uncertain q₁ q₂ d₁ d₂
@recourse(simple_model, 0 <= y₁ <= d₁)
@recourse(simple_model, 0 <= y₂ <= d₂)
@constraint(simple_model, 6*y₁ + 10*y₂ <= 60*x₁)
@constraint(simple_model, 8*y₁ + 5*y₂ <= 80*x₂)
# Model z₊ = (Z - ζ)₊
@recourse(simple_model, z₊ >= 0)
@constraint(simple_model, z₊ >= (-q₁*y₁ - q₂*y₂) - ζ)
# The second stage objective: 1 / α * (Z - ζ)₊
@objective(simple_model, Min, 1 / 0.5 * z₊)
end
end
Thank you @odow
@odow, what about if CVaR should be less than a value and I don't want to minimize CVaR? ζ + E[1 / α * (Z - ζ)₊] <= CVaR_max
Ah! Now this is a lot trickier.
You typically can't solve it using decomposition, so you've have to manually code the extensive two-stage formulation and add that constraint to the extensive form.
I am trying to see how I can model Portfolio Optimization with CVaR within the standard forms in StochasticPrograms.jl. I'd appreciate it if you could create a code snippet.