network
HPVsim sexual partnership network.
Multi-layer heterosexual partnership network. A single SexualNetwork instance holds all partnership layers (e.g. marital m + casual c) in one edges table tagged by layer_id. debut and participant are inherited from ss.SexualNetwork as single per-agent values shared across all layers. step() dissolves all pairs (single end_pairs on the combined edges table) and then forms new pairs per layer in sequence, so no sibling-network coordination is needed.
Age assortativity comes from the per-layer mixing_{layer} matrices: rows are the male age band, columns 1..N the female age band, and column 0 holds each row’s male age-band label. See _add_pairs_for_layer, which takes the female bin’s column and indexes it by male bin.
Classes
| Name | Description |
|---|---|
| SexualNetwork | Multi-layer (marital m, casual c) heterosexual partnership network. |
SexualNetwork
network.SexualNetwork(pars=None, **kwargs)Multi-layer (marital m, casual c) heterosexual partnership network.
Pars live flat on self.pars — see hpv.NetworkPars for the full default set. Naming: per-layer pars use _marital / _casual suffix; per-sex pars use _f / _m. All Dist-typed pars are ss.Dist instances (no v2 dict form). init_pre groups them into self._layer_pars / self._debut for runtime access.
Overrides net_beta to compound the per-act probability across the per-edge acts count: 1 - (1 - edges.beta * disease_beta)^acts. The starsim base treats edges.beta as a final scalar (edges.beta * (1 - (1 - disease_beta)^acts)); this override treats it as a per-act probability multiplier.
Methods
| Name | Description |
|---|---|
| active | Network participation requires a non-fine (level0) agent. |
| edges_for_layer | Boolean mask into self.edges selecting edges in layer lkey. |
| n_pairs_in_layer | Active pair count in layer lkey. |
| set_network_states | Sample debut, participant, and per-layer partners_target |
| step | Dissolve all pairs (single end_pairs on the combined edges |
active
network.SexualNetwork.active(people)Network participation requires a non-fine (level0) agent.
Fine multiscale agents (people.fine) are high-resolution cancer stand-ins excluded from transmission; only non-fine (level0) agents participate.
The fine state is registered by hpv.Sim only when it builds its own People (people is None). A network attached to a bare ss.People (e.g. in network unit tests) has no fine state, so guard the access and treat every agent as non-fine — matching the 'fine' in people.states guards used throughout demographics.py.
edges_for_layer
network.SexualNetwork.edges_for_layer(lkey)Boolean mask into self.edges selecting edges in layer lkey.
n_pairs_in_layer
network.SexualNetwork.n_pairs_in_layer(lkey)Active pair count in layer lkey.
set_network_states
network.SexualNetwork.set_network_states()Sample debut, participant, and per-layer partners_target for any alive agent without initialized state (participant=False).
Runs once at init for the starting population and once per step to handle newly-added agents (births, AgeMigration immigrants).
step
network.SexualNetwork.step()Dissolve all pairs (single end_pairs on the combined edges table), then form new pairs per layer in sequence.