# A Generalized Framework for the Estimation of Edge Infection Probabilities
## 3 Properties of GIIM
### Computation  
The GIIM defines a general optimization task, which can be solved with the iterative refinement of an initial edge weight configuration. The number of edges, even in a medium-sized graph, can be in the tens or hundreds of thousands, so finding the proper combination of weights can be challenging; therefore, choosing an appropriate optimization method is crucial. Here, we recommend and use the Fully Informed Particle Swarm method of [PERSON] [26; 27], which has proved successful in previous inverse infection tasks [4]. The optimization task was defined in Section 2.2 as the minimization of the error between computed and reference observations. The method is initialized with randomly selected edge infection values within reasonable bounds, and then a simulation of the infection process is computed to create observations. The error between the reference and computed observations is counted and used to adjust the edge infection values. The process is then repeated. The search strategy is Particle Swarm Optimization: an iterative multi-agent non-gradient metaheuristic. Each agent has a position that represents an edge weight configuration, and the agents refine their positions by interacting with their neighbors. This is implemented by adding the velocity of the agent to the position of the agent. The velocity of the agent is computed from its previous value, the best result found by the agent and its neighbors and a random vector. The goodness of an agent is the goodness of the edge weight configuration it represents, and the goodness is evaluated by running an infection model and computing the error of the resulting observations. The agents are connected to each other through a pre-defined topology describing the neighborhood of each agent. The specifics of the update rules for the positions and velocities, as well as the agent topology, are not fixed; there are several approaches in the literature. Here, like in [23], we follow the recommendations of [PERSON] and [PERSON] [26] by adopting a von Neumann neighborhood for the agents and the following update rules:  
\[\vec{v}_{i}\leftarrow\chi\Bigg{(}\vec{v}_{i}+\sum_{n=1}^{N_{i}} \frac{U(0,\varphi)(\vec{b}_{\mathit{hbr}(n)}-\vec{x}_{i})}{N_{i}}\Bigg{)}, \tag{1}\] \[\vec{x}_{i}\leftarrow\vec{x}_{i}+\vec{v}_{i}, \tag{2}\]where \(\vec{x}_{i}\) and \(\vec{v}_{i}\) denote the coordinate and velocity of particle \(i\), \(U(min,max)\) is a uniform random number generator, \(\vec{b}_{i}\) is the best location found so far by particle \(i\), \(N_{i}\) is the number of neighbors that \(i\) has, and \(nbr(n)\) is the \(n\)th neighbor of \(i\). The formula has two parameters: \(\chi\) is the constriction coefficient, and \(\varphi\) is the acceleration constant. Again, we use the recommendations of [PERSON] et al. and set \(\chi=0.7298\) and \(\varphi=4.1\). At the beginning, the positions of the agents are initialized with random values, and the velocities are set to zero. Then, at the end of each iteration, the positions and velocities are updated synchronously according to the above equations. The search is stopped if the method does not find a better global result in a set number of iterations. Algorithm 2 gives an outline of PSO. ```
1:for all\(a_{i}\)do
2: Initialize \(\vec{x}_{i}\) for agent \(a_{i}\) within the boundaries of the search space
3: Initialize \(\vec{v}_{i}\) for agent \(a_{i}\)
4: Set \(\vec{b}_{i}\leftarrow\vec{x}_{i}\)
5: Select the neighbors of \(a_{i}\) according to the topology
6:endfor
7:repeat
8:for all\(a_{i}\)do
9: Update \(\vec{v}_{i}\) according to Equation (1)
10: Update \(\vec{x}_{i}\) according to Equation (2)
11: Calculate the error function \(e(\vec{x}_{i})\) in position \(\vec{x}_{i}\)
12:if\(e(\vec{x}_{i})<e(\vec{b}_{i})\)then
13:\(\vec{b}_{i}\leftarrow\vec{x}_{i}\)
14:endif
15:endfor
16:until termination criterium is met
```  
**Algorithm 2** Particle Swarm Optimization  
The above algorithm can be implemented in a parallel way.