You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We can elaborate on this once my thesis is written, saving this here while I remember.
This is a nice way to avoid confusing the whole stage/node/do sp, t/do sp, t, i situation.
struct PolicyGraph{T}
root::T
subproblems::Dict{T, Vector{Tuple{T, Float64}}}endfunctionLinearGraph(stages::Int)
subproblems =Dict{Int, Vector{Tuple{Int, Float64}}}()
subproblems[0] = Tuple{Int, Float64}[]
for t in1:stages
subproblems[t] = Tuple{Int, Float64}[]
push!(subproblems[t-1], (t, 1.0))
endPolicyGraph(0, subproblems)
endfunctionMarkovianGraph(transition_probabilities::AbstractVector{AbstractArray{Float64, 2}})
# check is Markov transition matrix
i =1for T in transition_probabilities
@assertsize(T, 1) == i
i =size(T, 2)
for j in1:size(T, 1)
@assertisapprox(sum(T[j,:]), 1.0)
endend
typ = Tuple{Int, Int}
subproblems =Dict{typ, Vector{Tuple{typ, Float64}}}()
subproblems[(0,1)] = Tuple{typ, Float64}[]
for (t, T) inenumerate(transition_probabilities)
for j in1:size(T, 2)
subproblems[(t, j)] = Tuple{typ, Float64}[]
endfor i in1:size(T, 1)
for j in1:size(T, 2)
push!(subproblems[(t-1, i)], ((t, j), T[i,j]))
endendendPolicyGraph((0,1), subproblems)
end
SDDPModel(
policy_graph =LinearGraph(3)
) do sp, index
stage = index
# stage = 1,2,3endSDDPModel(
policy_graph =MarkovianGraph([
[1.0]',
[0.20.8],
[0.50.5; 0.10.9]
])
) do sp, index
(stage, markov_state) = index
# (stage, markov_state) = (1,1), (2,1), (2,2), (3,1), (3,2)end
functionchildren(g::PolicyGraph{T}, subproblem::T) where T
[s[2] for s in g.subproblems[subproblem]]
end
g =LinearGraph(3)
children(g, 0) # [1]children(g, 2) # [3]children(g, 3) # []
g =MarkovianGraph([
[1.0]',
[0.20.8],
[0.50.5; 0.10.9]
]
children(g, (0,1)) # [(1,1)]children(g, (2,2)) # [(3,1), (3,2)]children(g, (3,1)) # []
The text was updated successfully, but these errors were encountered:
odow
changed the title
Proposal: More Exotic Node Graphs
Proposal: More Exotic Staging Graphs
Feb 22, 2018
We can elaborate on this once my thesis is written, saving this here while I remember.
This is a nice way to avoid confusing the whole stage/node/
do sp, t
/do sp, t, i
situation.The text was updated successfully, but these errors were encountered: