transitlos.flex.xp_scoring¶
Cell scoring as plain array code that runs on a CUDA GPU (CuPy) when one is usable, else on the CPU (NumPy): the same definition as scoring.py / flexcore.c / score.js.
ev = XPData(subs, nbg) # uploads the sample once (cells, stations, block-group index); subs = objects with prof, cst, cdist, bg, pop
num = ev.numerator(params) # [nbg] sum over each block group's cells of population * level of service (float64, on the host)
The device is chosen by transitlos.flex.backend (CuPy if a CUDA device works, else NumPy); cells are processed in chunks, so the full US sample fits on any card.
XPData(subs, nbg, xp=None, chunk_cells=None)
¶
Station profiles and cell stations of several areas held on the CPU or GPU, to recompute block-group scores fast for many parameter sets (the fits).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subs
|
Per-area data (profiles, cell stations, distances, block group and population per cell). |
required | |
nbg
|
Number of block groups. |
required | |
xp
|
Array library; |
None
|
|
chunk_cells
|
Cells per chunk (memory). |
None
|
stop_scores(S, part)
¶
Stop score of every (station, profile) slot of one area.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
S
|
Prepared parameters. |
required | |
part
|
One area's data. |
required |
Returns:
| Type | Description |
|---|---|
|
|
cell_scores(S, part, lo, hi)
¶
Level of service of the cells lo:hi of one area (best station and profile per cell).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
S
|
Prepared parameters. |
required | |
part
|
One area's data. |
required | |
lo
|
First cell. |
required | |
hi
|
Last cell (exclusive). |
required |
Returns:
| Type | Description |
|---|---|
|
Array of cell scores. |
numerator(params)
¶
params: the ScoreParams as a dict (to_json). Returns the numerator of every block group's predictor (numpy float64 [nbg]).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
Scoring parameters as a dict. |
required |
backend()
¶
The array library of the current device (see :func:transitlos.flex.backend.xp).
Returns:
| Type | Description |
|---|---|
|
The |