jupedsim_scenarios.population#

Population mixes: validation and resolution of per-area profile shares.

A spawn area may carry parameters.population_mix, a list of {"profile": id, "share": int} entries referencing the top-level population_profiles map. Resolved groups are attached to each area’s parameters under GROUPS_KEY, which is derived state and is rebuilt on every initialisation.

Attributes#

Exceptions#

PopulationMixError

A population mix or a referenced profile is invalid; the run does not start.

Functions#

allocate_counts(shares, n) → list[int]

Split n agents by percentage shares using the largest remainder.

attach_population_groups(data) → None

Rebuild GROUPS_KEY on every area from its current mix.

load_population_presets() → dict

The packaged population presets.

reject_mix_owned_params(key, entry, kwargs) → None

Refuse direct radius or speed settings on an area that has a mix.

resolve_groups(mix, profiles) → list[dict]

Resolved groups of a validated mix, in mix order.

validate_population(data) → None

Reject invalid mixes and the profiles they reference before placement.

Module Contents#

exception PopulationMixError[source]#

Bases: ValueError

A population mix or a referenced profile is invalid; the run does not start.

allocate_counts(shares: list[int], n: int) → list[int][source]#

Split n agents by percentage shares using the largest remainder.

attach_population_groups(data: dict) → None[source]#

Rebuild GROUPS_KEY on every area from its current mix.

load_population_presets() → dict[source]#

The packaged population presets.

reject_mix_owned_params(key: str, entry: dict, kwargs: dict) → None[source]#

Refuse direct radius or speed settings on an area that has a mix.

resolve_groups(mix: list, profiles: dict) → list[dict][source]#

Resolved groups of a validated mix, in mix order.

validate_population(data: dict) → None[source]#

Reject invalid mixes and the profiles they reference before placement.

GROUPS_KEY = '_population_groups'[source]#
MIX_KEY = 'population_mix'[source]#
SUPPORTED_DISTRIBUTIONS = ('constant', 'gaussian')[source]#