Skip to content

Commit 65d3d36

Browse files
committed
[DEV] Add functions to concatenate PolyhedralFunctions
1 parent 845d1d2 commit 65d3d36

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/utils.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,21 @@ function remove_redundant_cuts!(Vts::Vector{PolyhedralFunction})
8686
end
8787
end
8888

89+
"""Concatenate collection of arrays of PolyhedralFunction."""
90+
function catcutsarray(polyfunarray::Vector{StochDynamicProgramming.PolyhedralFunction}...)
91+
assert(length(polyfunarray) > 0)
92+
ntimes = length(polyfunarray[1])
93+
return StochDynamicProgramming.PolyhedralFunction[catcuts([V[t] for V in polyfunarray]...) for t in 1:ntimes]
94+
end
95+
96+
97+
"""Concatenate collection of PolyhedralFunction."""
98+
function catcuts(Vts::StochDynamicProgramming.PolyhedralFunction...)
99+
betas = vcat([V.betas for V in Vts]...)
100+
lambdas = vcat([V.lambdas for V in Vts]...)
101+
numcuts = sum([V.numCuts for V in Vts])
102+
return StochDynamicProgramming.PolyhedralFunction(betas, lambdas, numcuts)
103+
end
89104

90105
"""
91106
Extract a vector stored in a 3D Array

0 commit comments

Comments
 (0)