Skip to content

Commit 016b57e

Browse files
committed
update readme
1 parent 5722d21 commit 016b57e

File tree

1 file changed

+55
-44
lines changed

1 file changed

+55
-44
lines changed

README.md

Lines changed: 55 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,54 +6,65 @@
66

77
## Design
88

9+
A typical example of `Trajectory`:
10+
911
```
10-
┌────────────────────────────┐
11-
│(state=..., action=..., ...)│
12-
└──────────────┬─────────────┘
13-
push! │ append!
14-
┌───────────────────▼───────────────────┐
15-
│ Trajectory │
16-
│ ┌─────────────────────────────────┐ │
17-
│ │ Traces │ │
18-
│ │ ┌───────────────────┐ │ │
19-
│ │ state: │CircularArrayBuffer│ │ │
20-
│ │ └───────────────────┘ │ │
21-
│ │ ┌───────────────────┐ │ │
22-
│ │ action:│CircularArrayBuffer│ │ │
23-
│ │ └───────────────────┘ │ │
24-
│ │ ...... │ │
25-
│ └─────────────────────────────────┘ │
26-
| Sampler |
27-
└───────────────────┬───────────────────┘
28-
│ batch sampling
29-
┌──────────────▼─────────────┐
30-
│(state=..., action=..., ...)│
31-
└────────────────────────────┘
12+
╭──── Trajectory ──────────────────────────────────────────────────────────────────────────────────────────────────╮
13+
│ ╭──── Traces ────────────────────────────────────────────────────────────────────────────────────────────────╮ │
14+
│ │ ╭──── state: Trac... ────╮╭──── action: Tra... ────╮╭──── reward: Tra... ────╮╭──── terminal: T... ────╮ │ │
15+
│ │ │ ╭──────────────────╮ ││ ╭──────────────────╮ ││ ╭──────────────────╮ ││ ╭──────────────────╮ │ │ │
16+
│ │ │ │ SubArray │ ││ │ 1 │ ││ │ 1.0 │ ││ │ false │ │ │ │
17+
│ │ │ │ (2,3) │ ││ ╰──────────────────╯ ││ ╰──────────────────╯ ││ ╰──────────────────╯ │ │ │
18+
│ │ │ ╰──────────────────╯ ││ ╭──────────────────╮ ││ ╭──────────────────╮ ││ ╭──────────────────╮ │ │ │
19+
│ │ │ ╭──────────────────╮ ││ │ 2 │ ││ │ 2.0 │ ││ │ false │ │ │ │
20+
│ │ │ │ SubArray │ ││ ╰──────────────────╯ ││ ╰──────────────────╯ ││ ╰──────────────────╯ │ │ │
21+
│ │ │ │ (2,3) │ ││ ╭──────────────────╮ ││ ╭──────────────────╮ ││ ╭──────────────────╮ │ │ │
22+
│ │ │ ╰──────────────────╯ ││ │ ... │ ││ │ ... │ ││ │ ... │ │ │ │
23+
│ │ │ ╭──────────────────╮ ││ ╰──────────────────╯ ││ ╰──────────────────╯ ││ ╰──────────────────╯ │ │ │
24+
│ │ │ │ ... │ ││ ╭──────────────────╮ ││ ╭──────────────────╮ ││ ╭──────────────────╮ │ │ │
25+
│ │ │ ╰──────────────────╯ ││ │ 3 │ ││ │ 3.0 │ ││ │ true │ │ │ │
26+
│ │ │ ╭──────────────────╮ ││ ╰──────────────────╯ ││ ╰──────────────────╯ ││ ╰──────────────────╯ │ │ │
27+
│ │ │ │ SubArray │ ││ ╭──────────────────╮ │╰───────── size: (4,) ───╯╰───────── size: (4,) ───╯ │ │
28+
│ │ │ │ (2,3) │ ││ │ 3 │ │ │ │
29+
│ │ │ ╰──────────────────╯ ││ ╰──────────────────╯ │ │ │
30+
│ │ │ ╭──────────────────╮ │╰───────── size: (5,) ───╯ │ │
31+
│ │ │ │ SubArray │ │ │ │
32+
│ │ │ │ (2,3) │ │ │ │
33+
│ │ │ ╰──────────────────╯ │ │ │
34+
│ │ ╰──── size: (2, 3, 5) ───╯ │ │
35+
│ ╰────────────────────────────────────────────────────────────────────────────────────── 4 traces in total ───╯ │
36+
│ ╭──── sampler ───────────────────────────────────────────────────────╮ │
37+
│ │ BatchSampler │ │
38+
│ │ ━━━━━━━━━━━━━━ │ │
39+
│ │ │ │ │
40+
│ │ ├── transformer => identity (generic function...: identity │ │
41+
│ │ ├── rng => Random._GLOBAL_RNG: Random._GLOBAL_RNG() │ │
42+
│ │ └── batch_size => Int64: 5 │ │
43+
│ ╰────────────────────────────────────────────────────────────────────╯ │
44+
│ ╭──── controler ────────────────────────────╮ │
45+
│ │ InsertSampleRatioControler │ │
46+
│ │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ │ │
47+
│ │ │ │ │
48+
│ │ ├── threshold => Int64: 4 │ │
49+
│ │ ├── n_sampled => Int64: 0 │ │
50+
│ │ ├── ratio => Float64: 0.25 │ │
51+
│ │ └── n_inserted => Int64: 4 │ │
52+
│ ╰───────────────────────────────────────────╯ │
53+
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
3254
```
3355

56+
Exported APIs are:
57+
58+
```julia
59+
push!(trajectory; [trace_name=value]...)
60+
append!(trajectory; [trace_name=value]...)
61+
62+
for sample in trajectory
63+
# consume samples from the trajectory
64+
end
3465
```
35-
┌──────────────┐ ┌──────────────┐
36-
│Single Element│ │Batch Elements│
37-
└──────┬───────┘ └──────┬───────┘
38-
│ │
39-
push! └──────┐ ┌───────┘ append!
40-
│ │
41-
┌─────────────┼────┼─────────────────────────────┐
42-
│ ┌──▼────▼──┐ AsyncTrajectory │
43-
│ │Channel In│ │
44-
│ └─────┬────┘ │
45-
│ take! │ │
46-
│ ┌─────▼─────┐ push! ┌────────────┐ │
47-
│ │RateLimiter├──────────► Trajectory │ │
48-
│ └─────┬─────┘ append! └────*───────┘ │
49-
│ │ * │
50-
│ put! │********************** │
51-
│ │ batch sampling │
52-
│ ┌─────▼─────┐ │
53-
│ │Channel Out│ │
54-
│ └───────────┘ │
55-
└────────────────────────────────────────────────┘
56-
```
66+
67+
A wide variety of `container`s, `sampler`s, and `controler`s are provided. For the full list, please read the doc.
5768

5869
## Acknowledgement
5970

0 commit comments

Comments
 (0)