Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update air conditioning example #801

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion docs/src/examples/air_conditioning.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
# # Air conditioning

# Taken from [Anthony Papavasiliou's notes on SDDP](https://web.archive.org/web/20200504214809/https://perso.uclouvain.be/anthony.papavasiliou/public_html/SDDP.pdf)
# This is a variation of the problem that first appears in the book
# Introduction to Stochastic Programming by Birge and Louveaux, 1997,
# Springer-Verlag, New York, on page 237, Example 1. For a rescaled problem,
# they reported an optimal value of 6.25 with a first-stage solution of x1 = 2
# (production)and y1 = 1 (store production). On this variation, without rescaling,
# it would be equivalent to 62500, 200 and 100, respectively.

# Consider the following problem
# * Produce air conditioners for 3 months
Expand Down Expand Up @@ -49,7 +55,19 @@ function air_conditioning_model(duality_handler)
)
end
SDDP.train(model; duality_handler = duality_handler)
@test isapprox(SDDP.calculate_bound(model), 62_500.0, atol = 0.1)
lb = SDDP.calculate_bound(model)
println("Lower bound is: $lb")
@test isapprox(lb, 62_500.0, atol = 0.1)

sims = SDDP.simulate(model, 1, [:production, :stored_production])
x1 = sims[1][1][:production]
y1 = sims[1][1][:stored_production].out
@test isapprox(x1, 200, atol = 0.1)
@test isapprox(y1, 100, atol = 0.1)
println(
"With first stage soluctions $(x1) (production) and $(y1) (stored_production).",
)

return
end

Expand Down
Loading