Skip to content

Commit

Permalink
[docs] fixes to ARMA and objective state tutorials (odow#561)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Jan 2, 2023
1 parent 6b56ee4 commit 3a399c3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
8 changes: 5 additions & 3 deletions docs/src/tutorial/arma.jl
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,11 @@ model = SDDP.LinearPolicyGraph(
@variable(sp, ε[1:2])
## The equation describing our statistical model
A = [0.8 0.2; 0.2 0.8]
inflow_in = [inflow[i].in for i in 1:2]
inflow_out = [inflow[i].in for i in 1:2]
@constraint(sp, inflow_out .== A * inflow_in .+ ε)
@constraint(
sp,
[i = 1:2],
inflow[i].out == sum(A[i, j] * inflow[j].in for j in 1:2) + ε[i],
)
## The new water balance constraint using the state variable
@constraint(sp, x.out == x.in - g_h - s + inflow[1].out + inflow[2].out)
## Assume we have some empirical residuals:
Expand Down
11 changes: 8 additions & 3 deletions docs/src/tutorial/objective_states.jl
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,13 @@ model = SDDP.LinearPolicyGraph(
lower_bound = (50.0, 50.0),
upper_bound = (150.0, 150.0),
) do fuel_cost, ω
fuel_cost′ = fuel_cost[1] + 0.5 * (fuel_cost[1] - fuel_cost[2]) + ω.fuel
return (fuel_cost′, fuel_cost[1])
## fuel_cost is a tuple, containing the (fuel_cost[t-1], fuel_cost[t-2])
## This function returns a new tuple containing
## (fuel_cost[t], fuel_cost[t-1]). Thus, we need to compute the new
## cost:
new_cost = fuel_cost[1] + 0.5 * (fuel_cost[1] - fuel_cost[2]) + ω.fuel
## And then return the appropriate tuple:
return (new_cost, fuel_cost[1])
end

Ω = [
Expand All @@ -202,7 +207,7 @@ model = SDDP.LinearPolicyGraph(
]

SDDP.parameterize(subproblem, Ω) do ω
(fuel_cost, fuel_cost_old) = SDDP.objective_state(subproblem)
fuel_cost, _ = SDDP.objective_state(subproblem)
@stageobjective(subproblem, fuel_cost * thermal_generation)
return JuMP.fix(inflow, ω.inflow)
end
Expand Down

0 comments on commit 3a399c3

Please sign in to comment.