Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Aug 30, 2024
1 parent dd2ae58 commit a49d179
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions docs/src/tutorials/algorithms/rolling_horizon.jl
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,28 @@ model
renewable_production = Float64[]
storage_level = Float64[0.0] # Include an initial storage level

# We'll also plot the solution at each of the time-steps to help visualize the
# solution to the rolling horizon problems.

function plot_solution(model, offset)
plot = Plots.plot(;
ylabel = "MW",
xlims = (0, total_time_length),
xticks = 0:12:total_time_length,
)
x = offset .+ (1:optimization_window)
y = hcat(value.(model[:p]), value.(model[:r]), value.(model[:d]))
if offset == 0
Plots.areaplot!(x, y; label = ["thermal" "solar" "discharge"])
Plots.areaplot!(x, -value.(model[:c]); label = "charge")
else
Plots.areaplot!(x, y; label = false)
Plots.areaplot!(x, -value.(model[:c]); label = false)
end
return plot
end
plots = Any[]

# Now we can iterate across the windows of our rolling horizon problem, and at
# each window, we:

Expand All @@ -230,6 +252,7 @@ for offset in 0:move_forward:total_time_length-1
push!(renewable_production, value(model[:r][t]))
push!(storage_level, value(model[:s][t]))
end
push!(plots, plot_solution(model, offset))
end

# We can now plot the solution to the week-long problem:
Expand All @@ -243,6 +266,15 @@ Plots.plot(
xticks = 0:12:total_time_length,
)

# and visualize each of the rolling horizon subplots:

Plots.plot(
plots...;
layout = (length(plots), 1),
size = (600, 800),
margin = 3Plots.mm,
)

# ## Final remark

# [ParametricOptInterface.jl](@ref) offers an easy way to update the parameters
Expand Down

0 comments on commit a49d179

Please sign in to comment.