# Simulation of Calibrated Complex Synthetic Population Data with XGBoost
## 3 Calibration of a Population  
### Post-Calibration with Combinatorial Optimization  
The post-calibration step can be described as a combinatorial optimization problem that aims to select households from the synthetic population in such a way that the difference between the margins from the selection and a given set of population margins is minimized. To be more precise, let \(\mathbf{U}^{\prime}\) be a synthetic population generated from a sample \(\mathbf{S}\), let \(f(\mathbf{t},\hat{\mathbf{t}})\) be an objective function that measures the difference between two sets of margins \(\mathbf{t}\) and \(\hat{\mathbf{t}}\), then the optimization problem can be defined as follows:  
\[\min_{\hat{\mathbf{t}}}f(\mathbf{t},\hat{\mathbf{t}}) \tag{8}\] \[\hat{\mathbf{t}}= \begin{pmatrix}\hat{t}_{1}\\ \vdots\\ \hat{t}_{M}\end{pmatrix} \] (9) \[\hat{t}_{m}=\sum_{i=1}^{N}\delta_{i}\mathbf{I}_{[\text{individual $i$ part of margin cell $m$}]}\quad m=1,\ldots,M\] (10) \[\delta_{i}\in\{0,1\},\ i=1,\ldots,N\] (11) \[\delta_{i}=\delta_{j}\ \forall\ \text{individuals}\ j\ \text{in same household as individual $i$}, \tag{12}\]  
with \(N\) as the number of people in the synthetic population and \(\mathbf{1}_{[. ]}\) representing the indicator functions that equal \(1\) if the expression in \([. ]\) is true. The vectors \(\mathbf{t}\) and \(\hat{\mathbf{t}}\) represent the target population margins and the population margins of the selected synthetic population, respectively. Each \(t_{m}\), \(m=1,\ldots,M\) contains the number of people for a set of variables, e.g., number of people by age, sex and geographic region. Setting \(\delta_{i}=1\) implies that the individual \(i\) is selected from the synthetic population \(\mathbf{U}^{\prime}\), and to preserve the household structure, so are all individuals \(j\) belonging to the same household as the individual \(i\). The use of combinatorial optimization to create synthetic populations was presented in [24; 25]. Since such problems are difficult to solve, they are often split into several smaller problems by dividing the synthetic population into non-overlapping groups, typically representing small geographical areas for which the margins \(\mathbf{t}\) are available. Many smaller problems are easier to solve than one large problem. When solving combinatorial optimization problems, so-called metaheuristics are usually used. These algorithms try to comb the search space of possible solutions in an efficient way to find at least a local minima of \(f()\) in a reasonable amount of time. The meta-heuristic used in this contribution is the so-called simulated annealing algorithm (SA; [26; 27]). SA is inspired by a physical process in which the material is cooled in a controlled manner. The pseudo-code of the SA as implemented in simPop for the post-calibration problem is presented in Algorithm 3. A more detailed description of the SA algorithm is given in the Appendix B.1. An important aspect of SA is that worse solutions can be accepted, especially at the beginning of the algorithm when the temperature \(T\) is high. This can prevent SA from getting trapped in local optima. Ref. [28] compared the SA algorithm with deterministic \begin{table}
\begin{tabular}{l l l l} \hline \hline  & **MSE** & **MAE** & \(\chi^{2}\) **Test Statistics** \\ \hline Multinomial & 42 & 0.42 & 117.381 \\ XGBoost & 5 & 0.21 & 121.291 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Overview of the categorical performance metrics for both XGBoost and multinomial approach across all generated 100 synthetic populations. re-weighting and conditional probabilities to create a synthetic population at different spatial scales and concluded that the SA algorithm consistently outperformed the other two methods. Algorithm 3 has the following disadvantages:  
* It is only possible to supply one target distribution \(\mathbf{t}\) as constraint. This can be a major limitation if only the marginal and not the joint distribution of variables for re-calibration are not available or accessible.