# Network¶

Agents are connected to form a sexual and injecting network that evolves (i.e., updates) at each time step. To construct the network, the program assigns a value K to each index agent , where K is defined as the number of partnerships with other agents per time step. The value is determined by a random sampling procedure from negative binomial distribution functions

- ::
- Ki;t NB(p; r) = (ki;t + r 1)!)(r 1)!ki;t! pr(1 p)ki;t ki;t 2 @0

with mean given by:

- ::
- m = pr / 1 p

for all agents per time step. Negative binomial models of partnership formation represent a search process with stopping rules, such that partners are acquired with probability until suitable partners are found. Pre vious studies have demonstrated that negative binomial distributions provide a reasonable approximation to real- world partnership networks, in which the variance of the distribution is greater than would be expected assuming constant-rate function (e.g., Poisson). We de ned negative binomial distribution functions for each class of agent based on previously published estimates of partner- ship degrees and distributions. We use the mean annual number of sexual partners reported by the input parame- ters to determine the partner acquisition and dissolution rates per monthly time step for each agent class.

The construction of the network is an iterative process in which the program precedes sequentially through the network set of N agents at each time step, matching each agent in need of partners to other in need of partners. As the network is an contact transmission risk network (not a social network), and in an effort to improve computa- tional efficiency, the model only engages links between pairs of agents who are of transmissible status and can engage in risk behavior. For example, a link between two heterosexual male agents is not permissible, unless both are PWID (i.e., they can inject together), and their partnership is serodiscordant (i.e., HIV transmission is possible). Once a new agent acquires the target infec- tion, they immediately become part of the transmissible pool and begin engaging in risk behavior. In order to ac- count for assortative mixing, the likelihood that any two agents are connected is weighted to favor links between nodes with similar characteristics by default, as described below in the pairing algorithm, but can be adjusted to fit the model needs. Specifically, the probability of contact is weighted to favor the formation of links between nodes from the same agent class. For example, PWID are more likely to connect with other PWID, while men who have sex with men (MSM) are more likely to connect with other MSM.

At each time step, agents are re-assigned partners based on a retention algorithm in order to avoid overesti- mating sexual and injecting partner turnover that would occur if agent partnerships were randomly mixed at each time step. Specifically, partners are added or removed to each index agent (i’s) network according to the random value, determined from the NB distributions (described above). If the agent’s target number of partners is higher than its current partnerships, the agent randomly drops links from its network. If the agent has too few partners, the agent becomes part of a set of agents which need part- nerships (NP). Once the total population is checked, we iterate over the NP set, pairing agents in partnerships us- ing the pairing algorithm, until no available matches can be made. Typically the remaining unpaired agents in the NP pool are less than 3% of those seeking partners at any given timestep, but due to the speed and efficiency of the algorithm, this is deemed acceptable.

## Partnering¶

The partner pairing algorithm uses a novel K-Nearest Neighbor searching algorithm where agents are matched with a set of Z agents within a de ned parameter space. In this algorithm, agents are placed into a S-dimensional space, where S is the total number of relevant param- eters for matching partners (age, race, ethnicity, sexual orientation, monogamy, etc). Next, for a given partner- seeking agent, we find the S-dimensional “feature vector” in this S-dimensional space between the agent of interest and agents in its local space. This feature vector rep- resents the natural extension of a Euclidian vector with additional scaling factors to in uence the weight/impact of each metric or vector indices, and is calculated as such:

```
F⃗ij = r⃗i ⃗rj = ΣSn=1 Qn(in jn)2
```

where Qn is the scaling factor for the nth matching pa- rameter. This tunable scaling factor allows for control- lable weights for each matching parameter. For example, if agents in the model aim to seek partners primarily of the same age, the age scaling factor Qage can be increased to result in an increased feature vector for agents of dis- similar ages. Conversely, if a parameter is no longer of interest for partnering, the scaling factor can be set to 0, effectively removing that component from two agents’ feature vector.

This algorithm returns the n closest agents (minimum feature vectors) of the set of Z agents, then randomly chooses on to become their partner. In order to ensure the chosen agent is an appropriate match (i.e. MSM not paired sexually with a HM), the Z set must be chosen appropriately prior to executing the subroutine. More simply, if a MSM agent is seeking a sexual partner, sub- set Z would be de ned as the intersection between the Need Partner (NP) pool and the total MSM agents, thus returning the subset Z of MSM agents also needing part- ners. If this pool returns null, then our agent has no eligible matches, and is removed from the NP pool itself. In order to increase computational efficiency, rather than measuring the feature vector to all eligible partners, the agent rst searches within their local bin chosen at random from the set of S bins. This allows for a higher stochasticity in the partnering algorithm, and prevents agents from partnering only with agents in their local S space.