/
FAST_hydro_thermal.jl
46 lines (40 loc) · 1.45 KB
/
FAST_hydro_thermal.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Copyright (c) 2017-23, Oscar Dowson and SDDP.jl contributors. #src
# This Source Code Form is subject to the terms of the Mozilla Public #src
# License, v. 2.0. If a copy of the MPL was not distributed with this #src
# file, You can obtain one at http://mozilla.org/MPL/2.0/. #src
# # FAST: the hydro-thermal problem
# An implementation of the Hydro-thermal example from [FAST](https://github.com/leopoldcambier/FAST/tree/daea3d80a5ebb2c52f78670e34db56d53ca2e778/examples/hydro%20thermal)
using SDDP, HiGHS, Test
function fast_hydro_thermal()
model = SDDP.LinearPolicyGraph(;
stages = 2,
upper_bound = 0.0,
sense = :Max,
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_sense(det) == MOI.MAX_SENSE
@test JuMP.objective_value(det) == -10
SDDP.train(model)
@test SDDP.calculate_bound(model) == -10
return
end
fast_hydro_thermal()