## 6 Parameter Tuning  
So far, only the agent-based model has been described. The model has been built upon the insights gained by analysing the self-reported behaviour, gathered through questionnaires and interviews. By leveraging this information it was possible to identify barriers and drivers that affect the decision criterion regulating the installation of a PV panel (see Section 4). These factors were then used as a guide for the behaviour of the agents in the simulation world; however, the algorithm describing the agents' behaviour hinged on a set of parameters that cannot be easily obtained through analytical tools. At this point, the second stage of the proposed methodology came into play, namely the observed behaviour. Historical data will be used to fine-tune the model parameters, thus obtaining a model which is capable to faithfully describe real world dynamics and that can be used to make accurate predictions, as reported in Section 7. The historical data of the PV panels installation trend in the Emilia-Romagna region was gathered looking at the data provided by the Italian government [49], in particular, the PV installation trend in Emilia-Romagna from 2007 to 2017 (Unluckily the data regarding years earlier than 2007 is very scarce due to the almost negligible consideration given by the Italian government to PV technology). The data set is divided in two chunks: training set, from 2007 to 2013, and test set, from 2014 to 2017. The training set is used to fine-tune the model parameters (trying to fit the simulated trend to the observed one). Afterwards, the trained model can be used to predict the PV installation rate during the test period; then, it is possible evaluate the quality of the prediction and thus the accuracy of the model, by comparing the historical data with the predicted one. As a reminder, the parameters that needed to be tuned were the weights of the utility function: \(w_{pp}(c_{v})\), \(w_{B}(c_{v})\), \(w_{N}(c_{v})\), and \(w_{E}(c_{v})\). In practice, the scope was to find the weights values that better fit the curve representing the Emilia-Romagna PV power installation rate. The tuning problem can be seen as fitting a model to real data; there exist several methods to perform this task. After a preliminary evaluation of different methods, a genetic algorithm (GA) [60] came across as the technique that provided best results without requiring excessive computational resources. This happens because GAs are apt at finding solutions in spaces where it is hard to derive analytical models and it is not easy to mathematically find global optima. Another benefit derived from the use of a genetic algorithm is the fact that they have been proven to be very effective at dealing with problems where small changes in the weight configuration can lead to a great impact on the final outcome. This is the case of the proposed agent-based model: the four factors of the desire function are strongly intertwined and linearly combined (see Equation (1)). Moreover, the decision criterion is influenced also by the social interaction: the weights assigned to a given agent can modify its decision, which in turn has an impact on the decision process of other (possibly many) neighbours. The genetic algorithm began with a random initial population of parameters configurations (the \"individuals\" in GA terminology). The initial population was then evaluated by running the agent-based model and observing the PV installed power by all households, given the currently applied parameters. Since during the training phase, the target PV power is available (the real, historical PV installation data in Emilia-Romagna), it was possible to assess the accuracy of the fit of the current population, by measuring the difference between target and simulated power. After the evaluation, the GA selected the next generation of individuals (a different set of model parameters), which were evaluated as well, with the goal of finding the best fitting population.