Demand Generators
deepbullwhip.demand.base.DemandGenerator
Bases: ABC
Abstract base class for demand generators.
Source code in deepbullwhip/demand/base.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | |
generate(T, seed=None)
abstractmethod
Generate a demand time series of length T.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
T
|
int
|
Number of periods. |
required |
seed
|
int or None
|
Random seed for reproducibility. |
None
|
Returns:
| Type | Description |
|---|---|
TimeSeries
|
1-D array of non-negative demand values, shape (T,). |
Source code in deepbullwhip/demand/base.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | |
deepbullwhip.demand.semiconductor.SemiconductorDemandGenerator
Bases: DemandGenerator
AR(1) + seasonal + structural-shock demand, calibrated to WSTS data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
float
|
Mean monthly demand ($B/month), scaled internally to weekly. |
50.2
|
phi
|
float
|
AR(1) autocorrelation coefficient. |
0.72
|
sigma_eps
|
float
|
Residual coefficient of variation (sigma_eps / mu). |
0.08
|
seasonal_amp
|
float
|
Seasonal amplitude as fraction of weekly mean. |
0.06
|
shock_period
|
int
|
Period index when the structural shock begins. |
104
|
shock_magnitude
|
float
|
Shock size as fraction of weekly mean. |
0.1
|
Source code in deepbullwhip/demand/semiconductor.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
generate_batch(T=156, n_paths=100, seed=None)
Generate N demand paths in parallel. Returns shape (n_paths, T).
The AR(1) time dependency requires a sequential loop over T, but all N paths are updated simultaneously via vectorized operations. This is the primary GPU/vectorization opportunity: O(T) steps each processing N paths in parallel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
T
|
int
|
Number of periods per path. |
156
|
n_paths
|
int
|
Number of independent demand paths to generate. |
100
|
seed
|
int or None
|
Random seed for reproducibility. |
None
|
Returns:
| Type | Description |
|---|---|
(ndarray, shape(n_paths, T))
|
|
Source code in deepbullwhip/demand/semiconductor.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |