Biobjective hydro-thermal
This tutorial was generated using Literate.jl. Download the source as a .jl file. Download the source as a .ipynb file.
using SDDP, HiGHS, Statistics, Testfunction biobjective_example() model = SDDP.LinearPolicyGraph(; stages = 3, lower_bound = 0.0, optimizer = HiGHS.Optimizer, ) do subproblem, _ @variable(subproblem, 0 <= v <= 200, SDDP.State, initial_value = 50) @variables(subproblem, begin 0 <= g[i = 1:2] <= 100 0 <= u <= 150 s >= 0 shortage_cost >= 0 end) @expressions(subproblem, begin objective_1, g[1] + 10 * g[2] objective_2, shortage_cost end) @constraints(subproblem, begin inflow_constraint, v.out == v.in - u - s g[1] + g[2] + u == 150 shortage_cost >= 40 - v.out shortage_cost >= 60 - 2 * v.out shortage_cost >= 80 - 4 * v.out end) # You must call this for a biobjective problem! SDDP.initialize_biobjective_subproblem(subproblem) SDDP.parameterize(subproblem, 0.0:5:50.0) do ω set_normalized_rhs(inflow_constraint, ω) # You must call `set_biobjective_functions` from within # `SDDP.parameterize`. SDDP.set_biobjective_functions(subproblem, objective_1, objective_2) return end end pareto_weights = SDDP.train_biobjective(model; solution_limit = 10, iteration_limit = 10) solutions = [(k, v) for (k, v) in pareto_weights] sort!(solutions; by = x -> x[1]) @test length(solutions) == 10 # Test for convexity! The gradient must be decreasing as we move from left # to right. gradient(a, b) = (b[2] - a[2]) / (b[1] - a[1]) grad = Inf for i in 1:9 new_grad = gradient(solutions[i], solutions[i+1]) @test new_grad < grad grad = new_grad end returnendbiobjective_example()-------------------------------------------------------------------
SDDP.jl (c) Oscar Dowson and contributors, 2017-26
-------------------------------------------------------------------
problem
nodes : 3
state variables : 1
scenarios : 1.33100e+03
existing cuts : false
options
solver : serial mode
risk measure : SDDP.Expectation()
sampling scheme : SDDP.InSampleMonteCarlo
subproblem structure
VariableRef : [9, 9]
AffExpr in MOI.EqualTo{Float64} : [2, 4]
AffExpr in MOI.GreaterThan{Float64} : [3, 5]
VariableRef in MOI.GreaterThan{Float64} : [8, 8]
VariableRef in MOI.LessThan{Float64} : [5, 6]
-------------------------------------------------------------------
iteration simulation bound time (s) solves pid
-------------------------------------------------------------------
1 0.000000e+00 0.000000e+00 3.208978e-01 36 1
10 0.000000e+00 0.000000e+00 3.290200e-01 360 1
-------------------------------------------------------------------
status : iteration_limit
total time (s) : 3.290200e-01
total solves : 360
best bound : 0.000000e+00
numeric issues : 0
-------------------------------------------------------------------
-------------------------------------------------------------------
SDDP.jl (c) Oscar Dowson and contributors, 2017-26
-------------------------------------------------------------------
problem
nodes : 3
state variables : 1
scenarios : 1.33100e+03
existing cuts : true
options
solver : serial mode
risk measure : SDDP.Expectation()
sampling scheme : SDDP.InSampleMonteCarlo
subproblem structure
VariableRef : [9, 9]
AffExpr in MOI.EqualTo{Float64} : [2, 4]
AffExpr in MOI.GreaterThan{Float64} : [3, 7]
VariableRef in MOI.EqualTo{Float64} : [1, 1]
VariableRef in MOI.GreaterThan{Float64} : [8, 8]
VariableRef in MOI.LessThan{Float64} : [5, 6]
-------------------------------------------------------------------
iteration simulation bound time (s) solves pid
-------------------------------------------------------------------
1 6.750000e+02 5.500000e+02 1.399994e-03 407 1
10 4.500000e+02 5.733959e+02 1.308513e-02 731 1
-------------------------------------------------------------------
status : iteration_limit
total time (s) : 1.308513e-02
total solves : 731
best bound : 5.733959e+02
numeric issues : 0
-------------------------------------------------------------------
-------------------------------------------------------------------
SDDP.jl (c) Oscar Dowson and contributors, 2017-26
-------------------------------------------------------------------
problem
nodes : 3
state variables : 1
scenarios : 1.33100e+03
existing cuts : true
options
solver : serial mode
risk measure : SDDP.Expectation()
sampling scheme : SDDP.InSampleMonteCarlo
subproblem structure
VariableRef : [9, 9]
AffExpr in MOI.EqualTo{Float64} : [2, 4]
AffExpr in MOI.GreaterThan{Float64} : [3, 16]
VariableRef in MOI.EqualTo{Float64} : [1, 1]
VariableRef in MOI.GreaterThan{Float64} : [8, 8]
VariableRef in MOI.LessThan{Float64} : [5, 6]
-------------------------------------------------------------------
iteration simulation bound time (s) solves pid
-------------------------------------------------------------------
1 4.850000e+02 3.349793e+02 1.815081e-03 778 1
10 3.550000e+02 3.468286e+02 1.448703e-02 1102 1
-------------------------------------------------------------------
status : iteration_limit
total time (s) : 1.448703e-02
total solves : 1102
best bound : 3.468286e+02
numeric issues : 0
-------------------------------------------------------------------
-------------------------------------------------------------------
SDDP.jl (c) Oscar Dowson and contributors, 2017-26
-------------------------------------------------------------------
problem
nodes : 3
state variables : 1
scenarios : 1.33100e+03
existing cuts : true
options
solver : serial mode
risk measure : SDDP.Expectation()
sampling scheme : SDDP.InSampleMonteCarlo
subproblem structure
VariableRef : [9, 9]
AffExpr in MOI.EqualTo{Float64} : [2, 4]
AffExpr in MOI.GreaterThan{Float64} : [3, 21]
VariableRef in MOI.EqualTo{Float64} : [1, 1]
VariableRef in MOI.GreaterThan{Float64} : [8, 8]
VariableRef in MOI.LessThan{Float64} : [5, 6]
-------------------------------------------------------------------
iteration simulation bound time (s) solves pid
-------------------------------------------------------------------
1 1.887500e+02 1.995243e+02 1.382113e-03 1149 1
10 2.962500e+02 2.052855e+02 1.274300e-02 1473 1
-------------------------------------------------------------------
status : iteration_limit
total time (s) : 1.274300e-02
total solves : 1473
best bound : 2.052855e+02
numeric issues : 0
-------------------------------------------------------------------
-------------------------------------------------------------------
SDDP.jl (c) Oscar Dowson and contributors, 2017-26
-------------------------------------------------------------------
problem
nodes : 3
state variables : 1
scenarios : 1.33100e+03
existing cuts : true
options
solver : serial mode
risk measure : SDDP.Expectation()
sampling scheme : SDDP.InSampleMonteCarlo
subproblem structure
VariableRef : [9, 9]
AffExpr in MOI.EqualTo{Float64} : [2, 4]
AffExpr in MOI.GreaterThan{Float64} : [3, 28]
VariableRef in MOI.EqualTo{Float64} : [1, 1]
VariableRef in MOI.GreaterThan{Float64} : [8, 8]
VariableRef in MOI.LessThan{Float64} : [5, 6]
-------------------------------------------------------------------
iteration simulation bound time (s) solves pid
-------------------------------------------------------------------
1 3.737500e+02 4.626061e+02 1.638174e-03 1520 1
10 2.450000e+02 4.658509e+02 1.506996e-02 1844 1
-------------------------------------------------------------------
status : iteration_limit
total time (s) : 1.506996e-02
total solves : 1844
best bound : 4.658509e+02
numeric issues : 0
-------------------------------------------------------------------
-------------------------------------------------------------------
SDDP.jl (c) Oscar Dowson and contributors, 2017-26
-------------------------------------------------------------------
problem
nodes : 3
state variables : 1
scenarios : 1.33100e+03
existing cuts : true
options
solver : serial mode
risk measure : SDDP.Expectation()
sampling scheme : SDDP.InSampleMonteCarlo
subproblem structure
VariableRef : [9, 9]
AffExpr in MOI.EqualTo{Float64} : [2, 4]
AffExpr in MOI.GreaterThan{Float64} : [3, 33]
VariableRef in MOI.EqualTo{Float64} : [1, 1]
VariableRef in MOI.GreaterThan{Float64} : [8, 8]
VariableRef in MOI.LessThan{Float64} : [5, 6]
-------------------------------------------------------------------
iteration simulation bound time (s) solves pid
-------------------------------------------------------------------
1 1.675000e+02 1.129545e+02 1.355171e-03 1891 1
10 1.362500e+02 1.129771e+02 1.263404e-02 2215 1
-------------------------------------------------------------------
status : iteration_limit
total time (s) : 1.263404e-02
total solves : 2215
best bound : 1.129771e+02
numeric issues : 0
-------------------------------------------------------------------
-------------------------------------------------------------------
SDDP.jl (c) Oscar Dowson and contributors, 2017-26
-------------------------------------------------------------------
problem
nodes : 3
state variables : 1
scenarios : 1.33100e+03
existing cuts : true
options
solver : serial mode
risk measure : SDDP.Expectation()
sampling scheme : SDDP.InSampleMonteCarlo
subproblem structure
VariableRef : [9, 9]
AffExpr in MOI.EqualTo{Float64} : [2, 4]
AffExpr in MOI.GreaterThan{Float64} : [3, 36]
VariableRef in MOI.EqualTo{Float64} : [1, 1]
VariableRef in MOI.GreaterThan{Float64} : [8, 8]
VariableRef in MOI.LessThan{Float64} : [5, 6]
-------------------------------------------------------------------
iteration simulation bound time (s) solves pid
-------------------------------------------------------------------
1 2.562500e+02 2.788225e+02 2.117157e-03 2262 1
10 2.375000e+02 2.795671e+02 1.542807e-02 2586 1
-------------------------------------------------------------------
status : iteration_limit
total time (s) : 1.542807e-02
total solves : 2586
best bound : 2.795671e+02
numeric issues : 0
-------------------------------------------------------------------
-------------------------------------------------------------------
SDDP.jl (c) Oscar Dowson and contributors, 2017-26
-------------------------------------------------------------------
problem
nodes : 3
state variables : 1
scenarios : 1.33100e+03
existing cuts : true
options
solver : serial mode
risk measure : SDDP.Expectation()
sampling scheme : SDDP.InSampleMonteCarlo
subproblem structure
VariableRef : [9, 9]
AffExpr in MOI.EqualTo{Float64} : [2, 4]
AffExpr in MOI.GreaterThan{Float64} : [3, 43]
VariableRef in MOI.EqualTo{Float64} : [1, 1]
VariableRef in MOI.GreaterThan{Float64} : [8, 8]
VariableRef in MOI.LessThan{Float64} : [5, 6]
-------------------------------------------------------------------
iteration simulation bound time (s) solves pid
-------------------------------------------------------------------
1 3.812500e+02 4.072952e+02 1.821041e-03 2633 1
10 5.818750e+02 4.080500e+02 1.586103e-02 2957 1
-------------------------------------------------------------------
status : iteration_limit
total time (s) : 1.586103e-02
total solves : 2957
best bound : 4.080500e+02
numeric issues : 0
-------------------------------------------------------------------
-------------------------------------------------------------------
SDDP.jl (c) Oscar Dowson and contributors, 2017-26
-------------------------------------------------------------------
problem
nodes : 3
state variables : 1
scenarios : 1.33100e+03
existing cuts : true
options
solver : serial mode
risk measure : SDDP.Expectation()
sampling scheme : SDDP.InSampleMonteCarlo
subproblem structure
VariableRef : [9, 9]
AffExpr in MOI.EqualTo{Float64} : [2, 4]
AffExpr in MOI.GreaterThan{Float64} : [3, 47]
VariableRef in MOI.EqualTo{Float64} : [1, 1]
VariableRef in MOI.GreaterThan{Float64} : [8, 8]
VariableRef in MOI.LessThan{Float64} : [5, 6]
-------------------------------------------------------------------
iteration simulation bound time (s) solves pid
-------------------------------------------------------------------
1 8.525000e+02 5.197742e+02 1.667023e-03 3004 1
10 4.493750e+02 5.211793e+02 1.696992e-02 3328 1
-------------------------------------------------------------------
status : iteration_limit
total time (s) : 1.696992e-02
total solves : 3328
best bound : 5.211793e+02
numeric issues : 0
-------------------------------------------------------------------
-------------------------------------------------------------------
SDDP.jl (c) Oscar Dowson and contributors, 2017-26
-------------------------------------------------------------------
problem
nodes : 3
state variables : 1
scenarios : 1.33100e+03
existing cuts : true
options
solver : serial mode
risk measure : SDDP.Expectation()
sampling scheme : SDDP.InSampleMonteCarlo
subproblem structure
VariableRef : [9, 9]
AffExpr in MOI.EqualTo{Float64} : [2, 4]
AffExpr in MOI.GreaterThan{Float64} : [3, 53]
VariableRef in MOI.EqualTo{Float64} : [1, 1]
VariableRef in MOI.GreaterThan{Float64} : [8, 8]
VariableRef in MOI.LessThan{Float64} : [5, 6]
-------------------------------------------------------------------
iteration simulation bound time (s) solves pid
-------------------------------------------------------------------
1 3.437500e+01 5.937500e+01 1.632929e-03 3375 1
10 3.750000e+01 5.938557e+01 1.353693e-02 3699 1
-------------------------------------------------------------------
status : iteration_limit
total time (s) : 1.353693e-02
total solves : 3699
best bound : 5.938557e+01
numeric issues : 0
-------------------------------------------------------------------