1+ export ElasticArraySARTTraces
2+
3+ using ElasticArrays: ElasticArray, resize_lastdim!
4+
5+ const ElasticArraySARTTraces = Traces{
6+ SS′AA′RT,
7+ <: Tuple {
8+ <: MultiplexTraces{SS′,<:Trace{<:ElasticArray}} ,
9+ <: MultiplexTraces{AA′,<:Trace{<:ElasticArray}} ,
10+ <: Trace{<:ElasticArray} ,
11+ <: Trace{<:ElasticArray} ,
12+ }
13+ }
14+
15+ function ElasticArraySARTTraces (;
16+ state= Int => (),
17+ action= Int => (),
18+ reward= Float32 => (),
19+ terminal= Bool => ()
20+ )
21+ state_eltype, state_size = state
22+ action_eltype, action_size = action
23+ reward_eltype, reward_size = reward
24+ terminal_eltype, terminal_size = terminal
25+
26+ MultiplexTraces {SS′} (ElasticArray {state_eltype} (undef, state_size... , 0 )) +
27+ MultiplexTraces {AA′} (ElasticArray {action_eltype} (undef, action_size... , 0 )) +
28+ Traces (
29+ reward= ElasticArray {reward_eltype} (undef, reward_size... , 0 ),
30+ terminal= ElasticArray {terminal_eltype} (undef, terminal_size... , 0 ),
31+ )
32+ 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