FAST: the hydro-thermal problem

An implementation of the Hydro-thermal example from FAST

using SDDP, HiGHS, Test

function fast_hydro_thermal()
    model = SDDP.PolicyGraph(
        SDDP.LinearGraph(2),
        lower_bound = 0.0,
        optimizer = HiGHS.Optimizer,
    ) do sp, t
        @variable(sp, 0 <= x <= 8, SDDP.State, initial_value = 0.0)
        @variables(sp, begin
            y >= 0
            p >= 0
            ξ
        end)
        @constraints(sp, begin
            p + y >= 6
            x.out <= x.in - y + ξ
        end)
        RAINFALL = (t == 1 ? [6] : [2, 10])
        SDDP.parameterize(sp, RAINFALL) do ω
            return JuMP.fix(ξ, ω)
        end
        @stageobjective(sp, 5 * p)
    end

    det = SDDP.deterministic_equivalent(model, HiGHS.Optimizer)
    set_silent(det)
    JuMP.optimize!(det)
    @test JuMP.objective_value(det) == 10

    SDDP.train(model, iteration_limit = 10, log_frequency = 5)
    @test SDDP.calculate_bound(model) == 10
    return
end

fast_hydro_thermal()
------------------------------------------------------------------------------
          SDDP.jl (c) Oscar Dowson and SDDP.jl contributors, 2017-23

Problem
  Nodes           : 2
  State variables : 1
  Scenarios       : 2.00000e+00
  Existing cuts   : false
  Subproblem structure                      : (min, max)
    Variables                               : (6, 6)
    VariableRef in MOI.EqualTo{Float64}     : (1, 1)
    VariableRef in MOI.LessThan{Float64}    : (1, 2)
    AffExpr in MOI.LessThan{Float64}        : (1, 1)
    AffExpr in MOI.GreaterThan{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, 1e+00]
  Non-zero Objective range  [1e+00, 5e+00]
  Non-zero Bounds range     [8e+00, 8e+00]
  Non-zero RHS range        [6e+00, 6e+00]
No problems detected

 Iteration    Simulation       Bound         Time (s)    Proc. ID   # Solves
        5    0.000000e+00   1.000000e+01   4.620075e-03          1         25
       10    2.000000e+01   1.000000e+01   1.659298e-02          1         50

Terminating training
  Status         : iteration_limit
  Total time (s) : 1.659298e-02
  Total solves   : 50
  Best bound     :  1.000000e+01
  Simulation CI  :  6.000000e+00 ± 5.987899e+00
------------------------------------------------------------------------------

This page was generated using Literate.jl.