In the hydro-thermal scheduling example, if I define a matrix type state variable, I will not be able to set a matrix initial value to it:
using SDDP
graph = SDDP.LinearGraph(3)
function subproblem_builder(subproblem::Model, node::Int)
# State variables
# @variable(subproblem, 0 <= volume[1:2, 1:2] <= 200, SDDP.State, initial_value = 200) # OK
@variable(subproblem, 0 <= volume[1:2, 1:2] <= 200, SDDP.State, initial_value = [200 200; 200 200]) # Not OK
# Control variables
@variables(subproblem, begin
thermal_generation >= 0
hydro_generation >= 0
hydro_spill >= 0
end)
# Random variables
@variable(subproblem, inflow)
Ω = [0.0, 50.0, 100.0]
P = [1 / 3, 1 / 3, 1 / 3]
SDDP.parameterize(subproblem, Ω, P) do ω
return JuMP.fix(inflow, ω)
end
# Transition function and constraints
@expressions(
subproblem,
begin
volume_out, [volume[i,j].out for i in 1:2, j in 1:2]
volume_in, [volume[i,j].in for i in 1:2, j in 1:2]
end
)
@constraints(
subproblem,
begin
volume_out .== volume_in .- hydro_generation .- hydro_spill .+ inflow
demand_constraint, hydro_generation + thermal_generation == 150
end
)
# Stage-objective
fuel_cost = [50, 100, 150]
@stageobjective(subproblem, fuel_cost[node] * thermal_generation)
return subproblem
end
model = SDDP.PolicyGraph(
subproblem_builder,
graph;
sense = :Min,
lower_bound = 0.0,
optimizer = HiGHS.Optimizer,
)
ERROR: MethodError: no method matching isnan(::Matrix{Int64})
BTW, is there any better method to querying the out
/ in
field from a matrix type state variable volume
than [volume[i,j].out for i in 1:2, j in 1:2]
?
Thanks!