Stochastic Programming for Hydropower Operations Modeling and - PowerPoint PPT Presentation
Stochastic Programming for Hydropower Operations Modeling and Algorithms Martin Biel KTH - Royal Institute of Technology JUNE 28, 2018 Price forecasts Irregular power production: solar and wind Nuclear power phase-out Common:
β’ No clearcut way to calculate stochastic measures: EVPI, VSS β’ The model creation is somewhat infmexible β’ Parallel L-shaped using the Distributed module in Juliaβ¦ β’ β¦but StructJuMP relies on MPI β’ Creating a new hydromodel involves reimplementing a new type Initial Approach - Issues Martin Biel (KTH) Stochastic Programming for Hydropower 7 / 25 β’ A lot of code repetition
β’ The model creation is somewhat infmexible β’ Parallel L-shaped using the Distributed module in Juliaβ¦ β’ β¦but StructJuMP relies on MPI β’ Creating a new hydromodel involves reimplementing a new type Initial Approach - Issues Martin Biel (KTH) Stochastic Programming for Hydropower 7 / 25 β’ A lot of code repetition β’ No clearcut way to calculate stochastic measures: EVPI, VSS
β’ Parallel L-shaped using the Distributed module in Juliaβ¦ β’ β¦but StructJuMP relies on MPI β’ Creating a new hydromodel involves reimplementing a new type Initial Approach - Issues Martin Biel (KTH) Stochastic Programming for Hydropower 7 / 25 β’ A lot of code repetition β’ No clearcut way to calculate stochastic measures: EVPI, VSS β’ The model creation is somewhat infmexible
β’ β¦but StructJuMP relies on MPI β’ Creating a new hydromodel involves reimplementing a new type Initial Approach - Issues Martin Biel (KTH) Stochastic Programming for Hydropower 7 / 25 β’ A lot of code repetition β’ No clearcut way to calculate stochastic measures: EVPI, VSS β’ The model creation is somewhat infmexible β’ Parallel L-shaped using the Distributed module in Juliaβ¦
β’ Creating a new hydromodel involves reimplementing a new type Initial Approach - Issues Martin Biel (KTH) Stochastic Programming for Hydropower 7 / 25 β’ A lot of code repetition β’ No clearcut way to calculate stochastic measures: EVPI, VSS β’ The model creation is somewhat infmexible β’ Parallel L-shaped using the Distributed module in Juliaβ¦ β’ β¦but StructJuMP relies on MPI
Initial Approach - Issues Martin Biel (KTH) Stochastic Programming for Hydropower 7 / 25 β’ A lot of code repetition β’ No clearcut way to calculate stochastic measures: EVPI, VSS β’ The model creation is somewhat infmexible β’ Parallel L-shaped using the Distributed module in Juliaβ¦ β’ β¦but StructJuMP relies on MPI β’ Creating a new hydromodel involves reimplementing a new type
β Flexible model creation β Parallel capabilities based on the Distributed module β Stochastic programming constructs β Model creation focused on data and optimization formulation β Effjcient model reinitialization β Predefjned models β’ Short-term production planning β’ Optimal orders on the day-ahead market New Approach Martin Biel (KTH) Stochastic Programming for Hydropower 8 / 25 β’ StochasticPrograms.jl β’ HydroModels.jl
β Parallel capabilities based on the Distributed module β Stochastic programming constructs β Model creation focused on data and optimization formulation β Effjcient model reinitialization β Predefjned models β’ Short-term production planning β’ Optimal orders on the day-ahead market New Approach Martin Biel (KTH) Stochastic Programming for Hydropower 8 / 25 β’ StochasticPrograms.jl β Flexible model creation β’ HydroModels.jl
β Stochastic programming constructs β Model creation focused on data and optimization formulation β Effjcient model reinitialization β Predefjned models β’ Short-term production planning β’ Optimal orders on the day-ahead market New Approach Martin Biel (KTH) Stochastic Programming for Hydropower 8 / 25 β’ StochasticPrograms.jl β Flexible model creation β Parallel capabilities based on the Distributed module β’ HydroModels.jl
β Model creation focused on data and optimization formulation β Effjcient model reinitialization β Predefjned models β’ Short-term production planning β’ Optimal orders on the day-ahead market New Approach Martin Biel (KTH) Stochastic Programming for Hydropower 8 / 25 β’ StochasticPrograms.jl β Flexible model creation β Parallel capabilities based on the Distributed module β Stochastic programming constructs β’ HydroModels.jl
β Effjcient model reinitialization β Predefjned models β’ Short-term production planning β’ Optimal orders on the day-ahead market New Approach Martin Biel (KTH) Stochastic Programming for Hydropower 8 / 25 β’ StochasticPrograms.jl β Flexible model creation β Parallel capabilities based on the Distributed module β Stochastic programming constructs β’ HydroModels.jl β Model creation focused on data and optimization formulation
β Predefjned models β’ Short-term production planning β’ Optimal orders on the day-ahead market New Approach Martin Biel (KTH) Stochastic Programming for Hydropower 8 / 25 β’ StochasticPrograms.jl β Flexible model creation β Parallel capabilities based on the Distributed module β Stochastic programming constructs β’ HydroModels.jl β Model creation focused on data and optimization formulation β Effjcient model reinitialization
New Approach Martin Biel (KTH) Stochastic Programming for Hydropower 8 / 25 β’ StochasticPrograms.jl β Flexible model creation β Parallel capabilities based on the Distributed module β Stochastic programming constructs β’ HydroModels.jl β Model creation focused on data and optimization formulation β Effjcient model reinitialization β Predefjned models β’ Short-term production planning β’ Optimal orders on the day-ahead market
StochasticPrograms.jl - Simple Example where Stochastic Programming for Hydropower Martin Biel (KTH) s.t. minimize Q ( x 1 , x 2 , π) = min y 1 , y 2 ββ x 1 , x 2 ββ s.t. 9 / 25 100 x 1 + 150 x 2 + π½ π [ Q ( x 1 , x 2 , π)] x 1 + x 2 β€ 120 x 1 β₯ 40 x 2 β₯ 20 q 1 (π) y 1 + q 2 (π) y 2 6 y 1 + 10 y 2 β€ 60 x 1 8 y 1 + 5 y 2 β€ 80 x 2 0 β€ y 1 β€ d 1 (π) 0 β€ y 2 β€ d 2 (π)
StochasticPrograms.jl - Simple Example Martin Biel (KTH) Stochastic Programming for Hydropower 10 / 25 sp = StochasticProgram(solver=ClpSolver()) @first_stage sp = begin @variable(model, xβ >= 40) @variable(model, xβ >= 20) @objective(model, Min, 100*xβ + 150*xβ) @constraint(model, xβ+xβ <= 120) end @second_stage sp = begin @decision xβ xβ s = scenario @variable(model, 0 <= yβ <= s.d[1]) @variable(model, 0 <= yβ <= s.d[2]) @objective(model, Min, s.q[1]*yβ + s.q[2]*yβ) @constraint(model, 6*yβ + 10*yβ <= 60*xβ) @constraint(model, 8*yβ + 5*yβ <= 80*xβ) end
StochasticPrograms.jl - Simple Example Creates a generator function for the fjrst stage model Stochastic Programming for Hydropower Martin Biel (KTH) 10 / 25 sp = StochasticProgram(solver=ClpSolver()) @first_stage sp = begin @variable(model, xβ >= 40) @variable(model, xβ >= 20) @objective(model, Min, 100*xβ + 150*xβ) @constraint(model, xβ+xβ <= 120) end @second_stage sp = begin @decision xβ xβ s = scenario @variable(model, 0 <= yβ <= s.d[1]) @variable(model, 0 <= yβ <= s.d[2]) @objective(model, Min, s.q[1]*yβ + s.q[2]*yβ) @constraint(model, 6*yβ + 10*yβ <= 60*xβ) @constraint(model, 8*yβ + 5*yβ <= 80*xβ) end
StochasticPrograms.jl - Simple Example Creates a generator function for the second stage model Stochastic Programming for Hydropower Martin Biel (KTH) 10 / 25 sp = StochasticProgram(solver=ClpSolver()) @first_stage sp = begin @variable(model, xβ >= 40) @variable(model, xβ >= 20) @objective(model, Min, 100*xβ + 150*xβ) @constraint(model, xβ+xβ <= 120) end @second_stage sp = begin @decision xβ xβ s = scenario @variable(model, 0 <= yβ <= s.d[1]) @variable(model, 0 <= yβ <= s.d[2]) @objective(model, Min, s.q[1]*yβ + s.q[2]*yβ) @constraint(model, 6*yβ + 10*yβ <= 60*xβ) @constraint(model, 8*yβ + 5*yβ <= 80*xβ) end
StochasticPrograms.jl - Simple Example Explicitly denote that some variables originate from the fjrst stage Stochastic Programming for Hydropower Martin Biel (KTH) 10 / 25 sp = StochasticProgram(solver=ClpSolver()) @first_stage sp = begin @variable(model, xβ >= 40) @variable(model, xβ >= 20) @objective(model, Min, 100*xβ + 150*xβ) @constraint(model, xβ+xβ <= 120) end @second_stage sp = begin @decision xβ xβ s = scenario @variable(model, 0 <= yβ <= s.d[1]) @variable(model, 0 <= yβ <= s.d[2]) @objective(model, Min, s.q[1]*yβ + s.q[2]*yβ) @constraint(model, 6*yβ + 10*yβ <= 60*xβ) @constraint(model, 8*yβ + 5*yβ <= 80*xβ) end
StochasticPrograms.jl - Simple Example Injection point for scenario data Stochastic Programming for Hydropower Martin Biel (KTH) 10 / 25 sp = StochasticProgram(solver=ClpSolver()) @first_stage sp = begin @variable(model, xβ >= 40) @variable(model, xβ >= 20) @objective(model, Min, 100*xβ + 150*xβ) @constraint(model, xβ+xβ <= 120) end @second_stage sp = begin @decision xβ xβ s = scenario @variable(model, 0 <= yβ <= s.d[1]) @variable(model, 0 <= yβ <= s.d[2]) @objective(model, Min, s.q[1]*yβ + s.q[2]*yβ) @constraint(model, 6*yβ + 10*yβ <= 60*xβ) @constraint(model, 8*yβ + 5*yβ <= 80*xβ) end
StochasticPrograms.jl - Simple Example Martin Biel (KTH) Stochastic Programming for Hydropower 11 / 25 struct SimpleScenario <: AbstractScenarioData p:: Float64 d:: Vector { Float64 } q:: Vector { Float64 } end StochasticPrograms.probability(s::SimpleScenario) = s.p
StochasticPrograms.jl - Simple Example Add two scenarios to the stochastic program Martin Biel (KTH) Stochastic Programming for Hydropower 11 / 25 struct SimpleScenario <: AbstractScenarioData p:: Float64 d:: Vector { Float64 } q:: Vector { Float64 } end StochasticPrograms.probability(s::SimpleScenario) = s.p s1 = SimpleScenario(0.4,[500.0,100],[-24.0,-28]) s2 = SimpleScenario(0.6,[300.0,300],[-28.0,-32]) append!(sp,[s1,s2])
StochasticPrograms.jl - Simple Example Martin Biel (KTH) Stochastic Programming for Hydropower 11 / 25 print(sp)
StochasticPrograms.jl - Simple Example Martin Biel (KTH) Stochastic Programming for Hydropower 11 / 25 print(sp) First-stage ============== Min 100 xβ + 150 xβ Subject to xβ + xβ β€ 120 xβ β₯ 40 xβ β₯ 20 Second-stage ============== Subproblem 1: Min -24 yβ - 28 yβ Subject to 6 yβ + 10 yβ - 60 xβ β€ 0 8 yβ + 5 yβ - 80 xβ β€ 0 0 β€ yβ β€ 500 0 β€ yβ β€ 100 Subproblem 2: Min -28 yβ - 32 yβ Subject to 6 yβ + 10 yβ - 60 xβ β€ 0 8 yβ + 5 yβ - 80 xβ β€ 0 0 β€ yβ β€ 300 0 β€ yβ β€ 300
β’ JuMP models are not created instantly β’ Model defjnitions are stored in generating lambda functions β’ These model recipes are then used as building blocks β’ The generating functions contain certain placeholders keywords β’ Upon model creation, the keywords contain the required data fjelds β’ Flexible model creation and reformulation β’ Effjcient parallel implementation β’ Versatility Implementation Details Deferred model creation Data injection Implications Martin Biel (KTH) Stochastic Programming for Hydropower 12 / 25
β’ Model defjnitions are stored in generating lambda functions β’ These model recipes are then used as building blocks β’ The generating functions contain certain placeholders keywords β’ Upon model creation, the keywords contain the required data fjelds β’ Flexible model creation and reformulation β’ Effjcient parallel implementation β’ Versatility Implementation Details Deferred model creation Data injection Implications Martin Biel (KTH) Stochastic Programming for Hydropower 12 / 25 β’ JuMP models are not created instantly
β’ These model recipes are then used as building blocks β’ The generating functions contain certain placeholders keywords β’ Upon model creation, the keywords contain the required data fjelds β’ Flexible model creation and reformulation β’ Effjcient parallel implementation β’ Versatility Implementation Details Deferred model creation Data injection Implications Martin Biel (KTH) Stochastic Programming for Hydropower 12 / 25 β’ JuMP models are not created instantly β’ Model defjnitions are stored in generating lambda functions
β’ The generating functions contain certain placeholders keywords β’ Upon model creation, the keywords contain the required data fjelds β’ Flexible model creation and reformulation β’ Effjcient parallel implementation β’ Versatility Implementation Details Deferred model creation Data injection Implications Martin Biel (KTH) Stochastic Programming for Hydropower 12 / 25 β’ JuMP models are not created instantly β’ Model defjnitions are stored in generating lambda functions β’ These model recipes are then used as building blocks
β’ The generating functions contain certain placeholders keywords β’ Upon model creation, the keywords contain the required data fjelds β’ Flexible model creation and reformulation β’ Effjcient parallel implementation β’ Versatility Implementation Details Deferred model creation Data injection Implications Martin Biel (KTH) Stochastic Programming for Hydropower 12 / 25 β’ JuMP models are not created instantly β’ Model defjnitions are stored in generating lambda functions β’ These model recipes are then used as building blocks
β’ Upon model creation, the keywords contain the required data fjelds β’ Flexible model creation and reformulation β’ Effjcient parallel implementation β’ Versatility Implementation Details Deferred model creation Data injection Implications Martin Biel (KTH) Stochastic Programming for Hydropower 12 / 25 β’ JuMP models are not created instantly β’ Model defjnitions are stored in generating lambda functions β’ These model recipes are then used as building blocks β’ The generating functions contain certain placeholders keywords
β’ Flexible model creation and reformulation β’ Effjcient parallel implementation β’ Versatility Implementation Details Deferred model creation Data injection Implications Martin Biel (KTH) Stochastic Programming for Hydropower 12 / 25 β’ JuMP models are not created instantly β’ Model defjnitions are stored in generating lambda functions β’ These model recipes are then used as building blocks β’ The generating functions contain certain placeholders keywords β’ Upon model creation, the keywords contain the required data fjelds
β’ Flexible model creation and reformulation β’ Effjcient parallel implementation β’ Versatility Implementation Details Deferred model creation Data injection Implications Martin Biel (KTH) Stochastic Programming for Hydropower 12 / 25 β’ JuMP models are not created instantly β’ Model defjnitions are stored in generating lambda functions β’ These model recipes are then used as building blocks β’ The generating functions contain certain placeholders keywords β’ Upon model creation, the keywords contain the required data fjelds
β’ Effjcient parallel implementation β’ Versatility Implementation Details Deferred model creation Data injection Implications Martin Biel (KTH) Stochastic Programming for Hydropower 12 / 25 β’ JuMP models are not created instantly β’ Model defjnitions are stored in generating lambda functions β’ These model recipes are then used as building blocks β’ The generating functions contain certain placeholders keywords β’ Upon model creation, the keywords contain the required data fjelds β’ Flexible model creation and reformulation
β’ Versatility Implementation Details Deferred model creation Data injection Implications Martin Biel (KTH) Stochastic Programming for Hydropower 12 / 25 β’ JuMP models are not created instantly β’ Model defjnitions are stored in generating lambda functions β’ These model recipes are then used as building blocks β’ The generating functions contain certain placeholders keywords β’ Upon model creation, the keywords contain the required data fjelds β’ Flexible model creation and reformulation β’ Effjcient parallel implementation
Implementation Details Deferred model creation Data injection Implications Martin Biel (KTH) Stochastic Programming for Hydropower 12 / 25 β’ JuMP models are not created instantly β’ Model defjnitions are stored in generating lambda functions β’ These model recipes are then used as building blocks β’ The generating functions contain certain placeholders keywords β’ Upon model creation, the keywords contain the required data fjelds β’ Flexible model creation and reformulation β’ Effjcient parallel implementation β’ Versatility
dep = DEP(sp) Minimization problem with: * 5 linear constraints * 6 variables Solver is ClpMathProg β’ First stage generator β’ Second stage generator on all available scenarios β’ Connections possible due to the @decision annotation β’ DEP model is cached internally until new scenarios are added Stochastic Programming for Hydropower Martin Biel (KTH) StochasticPrograms.jl - Deterministically Equivalent Model minimize Ax = b s.t. c T x + π½ π [ Q ( x , π(π))] x ββ n 13 / 25
β’ First stage generator β’ Second stage generator on all available scenarios β’ Connections possible due to the @decision annotation β’ DEP model is cached internally until new scenarios are added StochasticPrograms.jl - Deterministically Equivalent Model minimize Stochastic Programming for Hydropower Martin Biel (KTH) 13 / 25 Ax = b s.t. c T x + π½ π [ Q ( x , π(π))] x ββ n dep = DEP(sp) Minimization problem with: * 5 linear constraints * 6 variables Solver is ClpMathProg
β’ Second stage generator on all available scenarios β’ Connections possible due to the @decision annotation β’ DEP model is cached internally until new scenarios are added StochasticPrograms.jl - Deterministically Equivalent Model minimize Stochastic Programming for Hydropower Martin Biel (KTH) 13 / 25 s.t. Ax = b c T x + π½ π [ Q ( x , π(π))] x ββ n dep = DEP(sp) Minimization problem with: * 5 linear constraints * 6 variables Solver is ClpMathProg β’ First stage generator
β’ Connections possible due to the @decision annotation β’ DEP model is cached internally until new scenarios are added StochasticPrograms.jl - Deterministically Equivalent Model minimize Stochastic Programming for Hydropower Martin Biel (KTH) 13 / 25 Ax = b s.t. c T x + π½ π [ Q ( x , π(π))] x ββ n dep = DEP(sp) Minimization problem with: * 5 linear constraints * 6 variables Solver is ClpMathProg β’ First stage generator β’ Second stage generator on all available scenarios
β’ DEP model is cached internally until new scenarios are added StochasticPrograms.jl - Deterministically Equivalent Model minimize Stochastic Programming for Hydropower Martin Biel (KTH) 13 / 25 s.t. Ax = b c T x + π½ π [ Q ( x , π(π))] x ββ n dep = DEP(sp) Minimization problem with: * 5 linear constraints * 6 variables Solver is ClpMathProg β’ First stage generator β’ Second stage generator on all available scenarios β’ Connections possible due to the @decision annotation
StochasticPrograms.jl - Deterministically Equivalent Model minimize Stochastic Programming for Hydropower Martin Biel (KTH) 13 / 25 Ax = b s.t. c T x + π½ π [ Q ( x , π(π))] x ββ n dep = DEP(sp) Minimization problem with: * 5 linear constraints * 6 variables Solver is ClpMathProg β’ First stage generator β’ Second stage generator on all available scenarios β’ Connections possible due to the @decision annotation β’ DEP model is cached internally until new scenarios are added
StochasticPrograms.jl - Deterministically Equivalent Model Martin Biel (KTH) Stochastic Programming for Hydropower 13 / 25 print(dep)
StochasticPrograms.jl - Deterministically Equivalent Model Martin Biel (KTH) Stochastic Programming for Hydropower 13 / 25 print(dep) Min 100 xβ + 150 xβ - 9.6 yβ_1 - 11.2 yβ_1 - 16.8 yβ_2 - 19.2 yβ_2 Subject to xβ + xβ β€ 120 6 yβ_1 + 10 yβ_1 - 60 xβ β€ 0 8 yβ_1 + 5 yβ_1 - 80 xβ β€ 0 6 yβ_2 + 10 yβ_2 - 60 xβ β€ 0 8 yβ_2 + 5 yβ_2 - 80 xβ β€ 0 xβ β₯ 40 xβ β₯ 20 0 β€ yβ_1 β€ 500 0 β€ yβ_1 β€ 100 0 β€ yβ_2 β€ 300 0 β€ yβ_2 β€ 300
β’ Extended form solve(sp,solver=ClpSolver()) :Optimal getobjectivevalue(sp) -855.83 β’ L-shaped solve(sp,solver=LShapedSolver(:ls,ClpSolver())) L-Shaped Gap Time: 0:00:01 (4 iterations) Objective: -855.8333333333358 Gap: 2.1229209144670507e-15 Number of cuts: 5 :Optimal β’ Convenience function (Value of the recourse problem) VRP(sp,solver=ClpSolver()) -855.83 Stochastic Programming for Hydropower StochasticPrograms.jl - Solving Models Martin Biel (KTH) 14 / 25
β’ L-shaped solve(sp,solver=LShapedSolver(:ls,ClpSolver())) L-Shaped Gap Time: 0:00:01 (4 iterations) Objective: -855.8333333333358 Gap: 2.1229209144670507e-15 Number of cuts: 5 :Optimal β’ Convenience function (Value of the recourse problem) VRP(sp,solver=ClpSolver()) -855.83 Stochastic Programming for Hydropower Martin Biel (KTH) StochasticPrograms.jl - Solving Models 14 / 25 β’ Extended form solve(sp,solver=ClpSolver()) :Optimal getobjectivevalue(sp) -855.83
β’ Convenience function (Value of the recourse problem) VRP(sp,solver=ClpSolver()) -855.83 StochasticPrograms.jl - Solving Models Stochastic Programming for Hydropower Martin Biel (KTH) 14 / 25 β’ Extended form solve(sp,solver=ClpSolver()) :Optimal getobjectivevalue(sp) -855.83 β’ L-shaped solve(sp,solver=LShapedSolver(:ls,ClpSolver())) L-Shaped Gap Time: 0:00:01 (4 iterations) Objective: -855.8333333333358 Gap: 2.1229209144670507e-15 Number of cuts: 5 :Optimal
StochasticPrograms.jl - Solving Models Martin Biel (KTH) Stochastic Programming for Hydropower 14 / 25 β’ Extended form solve(sp,solver=ClpSolver()) :Optimal getobjectivevalue(sp) -855.83 β’ L-shaped solve(sp,solver=LShapedSolver(:ls,ClpSolver())) L-Shaped Gap Time: 0:00:01 (4 iterations) Objective: -855.8333333333358 Gap: 2.1229209144670507e-15 Number of cuts: 5 :Optimal β’ Convenience function (Value of the recourse problem) VRP(sp,solver=ClpSolver()) -855.83
ws = WS(sp,s1) Minimization problem with: * 3 linear constraints * 4 variables Solver is ClpMathProg β’ First stage generator β’ Second stage generator on the given scenario StochasticPrograms.jl - Wait-And-See Models Stochastic Programming for Hydropower Martin Biel (KTH) π minimize Μ for given x β₯ 0 Ax = b s.t. π) x ββ n 15 / 25 c T x + Q ( x , Μ
β’ First stage generator β’ Second stage generator on the given scenario StochasticPrograms.jl - Wait-And-See Models Μ Stochastic Programming for Hydropower Martin Biel (KTH) minimize π for given x β₯ 0 Ax = b s.t. π) x ββ n 15 / 25 c T x + Q ( x , Μ ws = WS(sp,s1) Minimization problem with: * 3 linear constraints * 4 variables Solver is ClpMathProg
β’ Second stage generator on the given scenario StochasticPrograms.jl - Wait-And-See Models for given Stochastic Programming for Hydropower Martin Biel (KTH) minimize Μ π x β₯ 0 Ax = b s.t. π) x ββ n 15 / 25 c T x + Q ( x , Μ ws = WS(sp,s1) Minimization problem with: * 3 linear constraints * 4 variables Solver is ClpMathProg β’ First stage generator
StochasticPrograms.jl - Wait-And-See Models for given Stochastic Programming for Hydropower Martin Biel (KTH) minimize Μ π x β₯ 0 Ax = b s.t. π) x ββ n 15 / 25 c T x + Q ( x , Μ ws = WS(sp,s1) Minimization problem with: * 3 linear constraints * 4 variables Solver is ClpMathProg β’ First stage generator β’ Second stage generator on the given scenario
StochasticPrograms.jl - Wait-And-See Models Martin Biel (KTH) Stochastic Programming for Hydropower 15 / 25 print(ws)
StochasticPrograms.jl - Wait-And-See Models Martin Biel (KTH) Stochastic Programming for Hydropower 15 / 25 print(ws) Min 100 xβ + 150 xβ - 24 yβ - 28 yβ Subject to xβ + xβ β€ 120 6 yβ + 10 yβ - 60 xβ β€ 0 8 yβ + 5 yβ - 80 xβ β€ 0 xβ β₯ 40 xβ β₯ 20 0 β€ yβ β€ 500 0 β€ yβ β€ 100
function expected(scenarios:: Vector {SimpleScenario}) return SimpleScenario(sum([s.p for s in scenarios]), sum([s.p*s.d for s in scenarios]), sum([s.p*s.q for s in scenarios])) end StochasticPrograms.jl - Expected Value Problems Must be possible to take expectation over scenarios Stochastic Programming for Hydropower Martin Biel (KTH) π = π½ π [π(π)] minimize Μ where x β₯ 0 Ax = b s.t. π) x ββ n 16 / 25 c T x + Q ( x , Μ
StochasticPrograms.jl - Expected Value Problems where Stochastic Programming for Hydropower Martin Biel (KTH) Must be possible to take expectation over scenarios minimize Μ π = π½ π [π(π)] x β₯ 0 Ax = b s.t. π) x ββ n 16 / 25 c T x + Q ( x , Μ function expected(scenarios:: Vector {SimpleScenario}) return SimpleScenario(sum([s.p for s in scenarios]), sum([s.p*s.d for s in scenarios]), sum([s.p*s.q for s in scenarios])) end
StochasticPrograms.jl - Expected Value Problems Martin Biel (KTH) Stochastic Programming for Hydropower 16 / 25 evp = EVP(sp) Minimization problem with: * 3 linear constraints * 4 variables Solver is ClpMathProg print(evp)
StochasticPrograms.jl - Expected Value Problems Martin Biel (KTH) Stochastic Programming for Hydropower 16 / 25 evp = EVP(sp) Minimization problem with: * 3 linear constraints * 4 variables Solver is ClpMathProg print(evp) Min 100 xβ + 150 xβ - 26.4 yβ - 30.4 yβ Subject to xβ + xβ β€ 120 6 yβ + 10 yβ - 60 xβ β€ 0 8 yβ + 5 yβ - 80 xβ β€ 0 xβ β₯ 40 xβ β₯ 20 0 β€ yβ β€ 380 0 β€ yβ β€ 220
x Μ = [50,50]; eval_decision(sp,x Μ ,solver=ClpSolver()) 356.0 β’ Create fjrst stage variables using generator β’ Fixate them to the given values β’ Generate the second stage problems β’ Again, linking handled through @decision β’ Solve resulting JuMP model Stochastic Programming for Hydropower Martin Biel (KTH) StochasticPrograms.jl - Decision Evaulation x + π½ π [ Q ( Μ x , π(π))] 17 / 25 c T Μ
β’ Fixate them to the given values β’ Generate the second stage problems β’ Again, linking handled through @decision β’ Solve resulting JuMP model StochasticPrograms.jl - Decision Evaulation Stochastic Programming for Hydropower Martin Biel (KTH) 17 / 25 x + π½ π [ Q ( Μ x , π(π))] c T Μ Μ x = [50,50]; eval_decision(sp,x Μ ,solver=ClpSolver()) 356.0 β’ Create fjrst stage variables using generator
β’ Generate the second stage problems β’ Again, linking handled through @decision β’ Solve resulting JuMP model StochasticPrograms.jl - Decision Evaulation Stochastic Programming for Hydropower Martin Biel (KTH) 17 / 25 x , π(π))] x + π½ π [ Q ( Μ c T Μ Μ x = [50,50]; eval_decision(sp,x Μ ,solver=ClpSolver()) 356.0 β’ Create fjrst stage variables using generator β’ Fixate them to the given values
β’ Again, linking handled through @decision β’ Solve resulting JuMP model StochasticPrograms.jl - Decision Evaulation Stochastic Programming for Hydropower Martin Biel (KTH) 17 / 25 x + π½ π [ Q ( Μ x , π(π))] c T Μ Μ x = [50,50]; eval_decision(sp,x Μ ,solver=ClpSolver()) 356.0 β’ Create fjrst stage variables using generator β’ Fixate them to the given values β’ Generate the second stage problems
β’ Solve resulting JuMP model StochasticPrograms.jl - Decision Evaulation Stochastic Programming for Hydropower Martin Biel (KTH) 17 / 25 x , π(π))] x + π½ π [ Q ( Μ c T Μ Μ x = [50,50]; eval_decision(sp,x Μ ,solver=ClpSolver()) 356.0 β’ Create fjrst stage variables using generator β’ Fixate them to the given values β’ Generate the second stage problems β’ Again, linking handled through @decision
StochasticPrograms.jl - Decision Evaulation Martin Biel (KTH) Stochastic Programming for Hydropower 17 / 25 x + π½ π [ Q ( Μ x , π(π))] c T Μ x Μ = [50,50]; eval_decision(sp,x Μ ,solver=ClpSolver()) 356.0 β’ Create fjrst stage variables using generator β’ Fixate them to the given values β’ Generate the second stage problems β’ Again, linking handled through @decision β’ Solve resulting JuMP model
β’ Expected wait-and-see solution (EWS) EWS(sp,solver=ClpSolver()) -1518.75 β’ Expected value of perfect information (EVPI = VRP - EWS) EVPI(sp,solver=ClpSolver()) 662.92 β’ Value of the stochastic solution (VSS = EEV - VRP) VSS(sp,solver=ClpSolver()) 286.92 Stochastic Programming for Hydropower Martin Biel (KTH) Many of the required calculations are embarassingly parallel StochasticPrograms.jl - Stochastic Measures 18 / 25 β’ Expected value of using the expected solution (EEV) EEV(sp,solver=ClpSolver()) -568.92
β’ Expected value of perfect information (EVPI = VRP - EWS) EVPI(sp,solver=ClpSolver()) 662.92 β’ Value of the stochastic solution (VSS = EEV - VRP) VSS(sp,solver=ClpSolver()) 286.92 Stochastic Programming for Hydropower Martin Biel (KTH) Many of the required calculations are embarassingly parallel StochasticPrograms.jl - Stochastic Measures 18 / 25 β’ Expected value of using the expected solution (EEV) EEV(sp,solver=ClpSolver()) -568.92 β’ Expected wait-and-see solution (EWS) EWS(sp,solver=ClpSolver()) -1518.75
β’ Value of the stochastic solution (VSS = EEV - VRP) VSS(sp,solver=ClpSolver()) 286.92 StochasticPrograms.jl - Stochastic Measures Stochastic Programming for Hydropower Martin Biel (KTH) Many of the required calculations are embarassingly parallel 18 / 25 β’ Expected value of using the expected solution (EEV) EEV(sp,solver=ClpSolver()) -568.92 β’ Expected wait-and-see solution (EWS) EWS(sp,solver=ClpSolver()) -1518.75 β’ Expected value of perfect information (EVPI = VRP - EWS) EVPI(sp,solver=ClpSolver()) 662.92
StochasticPrograms.jl - Stochastic Measures Many of the required calculations are embarassingly parallel Stochastic Programming for Hydropower Martin Biel (KTH) 18 / 25 β’ Expected value of using the expected solution (EEV) EEV(sp,solver=ClpSolver()) -568.92 β’ Expected wait-and-see solution (EWS) EWS(sp,solver=ClpSolver()) -1518.75 β’ Expected value of perfect information (EVPI = VRP - EWS) EVPI(sp,solver=ClpSolver()) 662.92 β’ Value of the stochastic solution (VSS = EEV - VRP) VSS(sp,solver=ClpSolver()) 286.92
StochasticPrograms.jl - Stochastic Measures Many of the required calculations are embarassingly parallel Stochastic Programming for Hydropower Martin Biel (KTH) 18 / 25 β’ Expected value of using the expected solution (EEV) EEV(sp,solver=ClpSolver()) -568.92 β’ Expected wait-and-see solution (EWS) EWS(sp,solver=ClpSolver()) -1518.75 β’ Expected value of perfect information (EVPI = VRP - EWS) EVPI(sp,solver=ClpSolver()) 662.92 β’ Value of the stochastic solution (VSS = EEV - VRP) VSS(sp,solver=ClpSolver()) 286.92
LShapedSolvers.jl L-shaped algorithm variants Martin Biel (KTH) Stochastic Programming for Hydropower 19 / 25 β’ L-shaped [Van Slyke,Wets] β’ Multicut L-shaped [Birge,Louveaux] β’ Regularized decomposition [RuszczyΕski] β’ Trust-region L-shaped [Linderoth,Wright] β’ Level-set [FΓ‘biΓ‘n,SzΕke]
β’ Distributed L-shaped variants 1. Distributed L-shaped with multiple cuts: LShapedSolver(:dls) 2. Distributed regularized L-shaped: LShapedSolver(:drd) 3. Distributed L-shaped with trust region: LShapedSolver(:dtr) 4. Distributed L-shaped with level sets: LShapedSolver(:dlv) β’ Trait based implementation. Every solver is a combination of a: β Regularization trait β Parallelization trait β’ Subproblems are solved using MathProgBase solvers Stochastic Programming for Hydropower Martin Biel (KTH) LShapedSolvers.jl 20 / 25 β’ L-shaped variants 1. L-shaped with multiple cuts (default): LShapedSolver(:ls) 2. L-shaped with regularized decomposition: LShapedSolver(:rd) 3. L-shaped with trust region: LShapedSolver(:tr) 4. L-shaped with level sets: LShapedSolver(:lv)
β’ Trait based implementation. Every solver is a combination of a: β Regularization trait β Parallelization trait β’ Subproblems are solved using MathProgBase solvers LShapedSolvers.jl Stochastic Programming for Hydropower Martin Biel (KTH) 20 / 25 β’ L-shaped variants 1. L-shaped with multiple cuts (default): LShapedSolver(:ls) 2. L-shaped with regularized decomposition: LShapedSolver(:rd) 3. L-shaped with trust region: LShapedSolver(:tr) 4. L-shaped with level sets: LShapedSolver(:lv) β’ Distributed L-shaped variants 1. Distributed L-shaped with multiple cuts: LShapedSolver(:dls) 2. Distributed regularized L-shaped: LShapedSolver(:drd) 3. Distributed L-shaped with trust region: LShapedSolver(:dtr) 4. Distributed L-shaped with level sets: LShapedSolver(:dlv)
β’ Subproblems are solved using MathProgBase solvers LShapedSolvers.jl Stochastic Programming for Hydropower Martin Biel (KTH) 20 / 25 β’ L-shaped variants 1. L-shaped with multiple cuts (default): LShapedSolver(:ls) 2. L-shaped with regularized decomposition: LShapedSolver(:rd) 3. L-shaped with trust region: LShapedSolver(:tr) 4. L-shaped with level sets: LShapedSolver(:lv) β’ Distributed L-shaped variants 1. Distributed L-shaped with multiple cuts: LShapedSolver(:dls) 2. Distributed regularized L-shaped: LShapedSolver(:drd) 3. Distributed L-shaped with trust region: LShapedSolver(:dtr) 4. Distributed L-shaped with level sets: LShapedSolver(:dlv) β’ Trait based implementation. Every solver is a combination of a: β Regularization trait β Parallelization trait
LShapedSolvers.jl Martin Biel (KTH) Stochastic Programming for Hydropower 20 / 25 β’ L-shaped variants 1. L-shaped with multiple cuts (default): LShapedSolver(:ls) 2. L-shaped with regularized decomposition: LShapedSolver(:rd) 3. L-shaped with trust region: LShapedSolver(:tr) 4. L-shaped with level sets: LShapedSolver(:lv) β’ Distributed L-shaped variants 1. Distributed L-shaped with multiple cuts: LShapedSolver(:dls) 2. Distributed regularized L-shaped: LShapedSolver(:drd) 3. Distributed L-shaped with trust region: LShapedSolver(:dtr) 4. Distributed L-shaped with level sets: LShapedSolver(:dlv) β’ Trait based implementation. Every solver is a combination of a: β Regularization trait β Parallelization trait β’ Subproblems are solved using MathProgBase solvers
β’ The user creates a model recipe using the @hydromodel macro β’ Defjne model indices β’ Defjne model data β’ Defjne modelindices(::AbstractHydroModelData, ::Horizon, args...) β’ Defjne optimization problem β’ horizon : the time horizon if the model β’ indices : structure with model indices β’ data : structure with model data HydroModels.jl Creating a Planning Problem Data injection keywords Martin Biel (KTH) Stochastic Programming for Hydropower 21 / 25 β’ Also based on deferred model creation and data injection
β’ Defjne model indices β’ Defjne model data β’ Defjne modelindices(::AbstractHydroModelData, ::Horizon, args...) β’ Defjne optimization problem β’ horizon : the time horizon if the model β’ indices : structure with model indices β’ data : structure with model data HydroModels.jl Creating a Planning Problem Data injection keywords Martin Biel (KTH) Stochastic Programming for Hydropower 21 / 25 β’ Also based on deferred model creation and data injection β’ The user creates a model recipe using the @hydromodel macro
β’ horizon : the time horizon if the model β’ indices : structure with model indices β’ data : structure with model data HydroModels.jl Creating a Planning Problem Data injection keywords Martin Biel (KTH) Stochastic Programming for Hydropower 21 / 25 β’ Also based on deferred model creation and data injection β’ The user creates a model recipe using the @hydromodel macro β’ Defjne model indices β’ Defjne model data β’ Defjne modelindices(::AbstractHydroModelData, ::Horizon, args...) β’ Defjne optimization problem
HydroModels.jl Creating a Planning Problem Data injection keywords Martin Biel (KTH) Stochastic Programming for Hydropower 21 / 25 β’ Also based on deferred model creation and data injection β’ The user creates a model recipe using the @hydromodel macro β’ Defjne model indices β’ Defjne model data β’ Defjne modelindices(::AbstractHydroModelData, ::Horizon, args...) β’ Defjne optimization problem β’ horizon : the time horizon if the model β’ indices : structure with model indices β’ data : structure with model data
Recommend
More recommend
Explore More Topics
Stay informed with curated content and fresh updates.