SLDP: example 1
This example is derived from Section 4.2 of the paper: Ahmed, S., Cabral, F. G., & da Costa, B. F. P. (2019). Stochastic Lipschitz Dynamic Programming. Optimization Online. PDF
using SDDP, HiGHS, Test
function sldp_example_one()
model = SDDP.LinearPolicyGraph(
stages = 8,
lower_bound = 0.0,
optimizer = HiGHS.Optimizer,
) do sp, t
@variable(sp, x, SDDP.State, initial_value = 2.0)
@variables(sp, begin
x⁺ >= 0
x⁻ >= 0
0 <= u <= 1, Bin
ω
end)
@stageobjective(sp, 0.9^(t - 1) * (x⁺ + x⁻))
@constraints(sp, begin
x.out == x.in + 2 * u - 1 + ω
x⁺ >= x.out
x⁻ >= -x.out
end)
points = [
-0.3089653673606697,
-0.2718277412744214,
-0.09611178608243474,
0.24645863921577763,
0.5204224537256875,
]
return SDDP.parameterize(φ -> JuMP.fix(ω, φ), sp, [points; -points])
end
SDDP.train(model, iteration_limit = 100, log_frequency = 10)
@test SDDP.calculate_bound(model) <= 1.1675
return
end
sldp_example_one()------------------------------------------------------------------------------
SDDP.jl (c) Oscar Dowson and SDDP.jl contributors, 2017-23
Problem
Nodes : 8
State variables : 1
Scenarios : 1.00000e+08
Existing cuts : false
Subproblem structure : (min, max)
Variables : (7, 7)
VariableRef in MOI.LessThan{Float64} : (1, 2)
VariableRef in MOI.ZeroOne : (1, 1)
AffExpr in MOI.GreaterThan{Float64} : (2, 2)
AffExpr in MOI.EqualTo{Float64} : (1, 1)
VariableRef in MOI.GreaterThan{Float64} : (4, 4)
Options
Solver : serial mode
Risk measure : SDDP.Expectation()
Sampling scheme : SDDP.InSampleMonteCarlo
Numerical stability report
Non-zero Matrix range [1e+00, 2e+00]
Non-zero Objective range [5e-01, 1e+00]
Non-zero Bounds range [1e+00, 1e+00]
Non-zero RHS range [1e+00, 1e+00]
No problems detected
Iteration Simulation Bound Time (s) Proc. ID # Solves
10 3.248004e+00 1.165036e+00 1.027749e-01 1 880
20 2.212205e+00 1.165481e+00 2.037828e-01 1 1760
30 2.554054e+00 1.165750e+00 3.110359e-01 1 2640
40 2.987695e+00 1.165750e+00 4.208329e-01 1 3520
50 3.682757e+00 1.167410e+00 5.331409e-01 1 4400
60 3.633475e+00 1.167410e+00 6.788750e-01 1 5280
70 3.483926e+00 1.167410e+00 7.975378e-01 1 6160
80 3.198985e+00 1.167410e+00 9.145708e-01 1 7040
90 3.497207e+00 1.167410e+00 1.030831e+00 1 7920
100 4.070719e+00 1.167410e+00 1.151645e+00 1 8800
Terminating training
Status : iteration_limit
Total time (s) : 1.151645e+00
Total solves : 8800
Best bound : 1.167410e+00
Simulation CI : 3.209543e+00 ± 8.791427e-02
------------------------------------------------------------------------------This page was generated using Literate.jl.