|
1 | 1 | export ElasticArraySARTSTraces |
2 | 2 |
|
3 | | -using ElasticArrays: ElasticArray, resize_lastdim! |
4 | | - |
5 | 3 | const ElasticArraySARTSTraces = Traces{ |
6 | | - SS′AA′RT, |
| 4 | + SS′ART, |
7 | 5 | <:Tuple{ |
8 | | - <:MultiplexTraces{SS′,<:Trace{<:ElasticArray}}, |
9 | | - <:MultiplexTraces{AA′,<:Trace{<:ElasticArray}}, |
10 | | - <:Trace{<:ElasticArray}, |
11 | | - <:Trace{<:ElasticArray}, |
| 6 | + <:MultiplexTraces{SS′,<:Trace{<:ElasticArrayBuffer}}, |
| 7 | + <:Trace{<:ElasticArrayBuffer}, |
| 8 | + <:Trace{<:ElasticArrayBuffer}, |
| 9 | + <:Trace{<:ElasticArrayBuffer}, |
12 | 10 | } |
13 | 11 | } |
14 | 12 |
|
15 | 13 | function ElasticArraySARTSTraces(; |
16 | 14 | state=Int => (), |
17 | 15 | action=Int => (), |
18 | 16 | reward=Float32 => (), |
19 | | - terminal=Bool => () |
20 | | -) |
| 17 | + terminal=Bool => ()) |
| 18 | + |
21 | 19 | state_eltype, state_size = state |
22 | 20 | action_eltype, action_size = action |
23 | 21 | reward_eltype, reward_size = reward |
24 | 22 | terminal_eltype, terminal_size = terminal |
25 | 23 |
|
26 | | - MultiplexTraces{SS′}(ElasticArray{state_eltype}(undef, state_size..., 0)) + |
27 | | - MultiplexTraces{AA′}(ElasticArray{action_eltype}(undef, action_size..., 0)) + |
| 24 | + MultiplexTraces{SS′}(ElasticArrayBuffer{state_eltype}(state_size..., capacity+1)) + |
28 | 25 | Traces( |
29 | | - reward=ElasticArray{reward_eltype}(undef, reward_size..., 0), |
30 | | - terminal=ElasticArray{terminal_eltype}(undef, terminal_size..., 0), |
| 26 | + action = ElasticArrayBuffer{action_eltype}(action_size..., capacity), |
| 27 | + reward=ElasticArrayBuffer{reward_eltype}(reward_size..., capacity), |
| 28 | + terminal=ElasticArrayBuffer{terminal_eltype}(terminal_size..., capacity), |
31 | 29 | ) |
32 | 30 | end |
33 | | - |
34 | | -##### |
35 | | -# extensions for ElasticArrays |
36 | | -##### |
37 | | - |
38 | | -Base.push!(a::ElasticArray, x) = append!(a, x) |
39 | | -Base.push!(a::ElasticArray{T,1}, x) where {T} = append!(a, [x]) |
40 | | -Base.empty!(a::ElasticArray) = resize_lastdim!(a, 0) |
0 commit comments