## 3 Methods: Heuristic Algorithms and Parallel Computing Algorithm
### Parallel Computing Algorithm for Exhaustive Search
#### 3.5.3 Algorithm Parallelization  
The day-ahead local energy market bidding optimization problem has nine agents: three consumers, three producers, and three prosumers. Prosumer agents are consumers with PV generation capabilities. The agent data correspond to a derivation of standard power profiles of residential houses and PV systems based on the open datasets available in [38]. As shown in Figure 1, each agent has a pair of values corresponding to each period's quantity and price in the day-ahead market. Consequently, each agent has 48 variables, and the solution gathers all agents within a vector with 432 variables. However, most of the variables are fixed, since the lower and upper boundaries are the same. Table 1 shows the fixed variables and the variables that can change for the quantity and price by the agent and period. The empty cells represent the fixed variables. The last column presents the number of variables that can change by period for all agents. This analysis reduces the number of variables from 432 to 206.  
The exhaustive search methodology evaluates all possible solutions of the 206 variables. This paper refers to the number of possible values for each variable as states. Defining the states as \(N\), the number of possible solutions is defined as:  
\[Total=N^{206}.\]  
Evaluating only two states of the solution (\(N=2\)), the number of possible solutions is \(1.02\times 10^{62}\). The workstation that evaluates all possible solutions is an Intel Xeon E5-26700/2.60 GHz/Ram 128 GB/16 cores. The workstation can evaluate in parallel 10,000 solutions in 18 s using 16 cores. Considering the number of solutions to evaluate, the workstation is not capable of evaluating them in an acceptable time. However, the problem's nature allows dividing the exhaustive search by period, since the behavior of the agents for all periods are independent. To reduce the required time to perform the exhaustive search, the problem is fractioned and analyzed by period, reducing the number of variables from 206 to 6 regarding periods 1 to 7 and 20 to 24, 8 for period 8, 10 for periods 9 to 10 and 19, and 12 corresponding to periods 11 to 18. Using (1) to calculate the new number of possible solutions with \(N=2\), this number is reduced from \(1.02\times 10^{62}\) to 36,864, allowing the workstation to evaluate all possibilities in 66.35 s. Table 2 presents the summary of the states, combinations, and expected simulation time by period.  
\begin{table}
\begin{tabular}{c c c c c c c c c c c c c c c c} \hline \hline \multirow{2}{*}{**Period**} & \multicolumn{6}{c}{**Quantity**} & \multicolumn{6}{c}{**Price**} & \multirow{2}{*}{**Total**} \\ \cline{2-13} \cline{2-13}  & **A1** & & & & & & & & & & & & & & & \\ \hline  
*Total** & **0** & **0** & **0** & **12** & **9** & **10** & **24** & **24** & **0** & **0** & **0** & **12** & **9** & **10** & **24** & **24** & **206** \\ \hline \hline \end{tabular}
\end{table}
Table 1: Fixed and changeable decision variables for nine agents.  
The first fitness of the initial solution is \(Global_{opt}=183.16\). After evaluating the 36.864 possible solutions, the fitness of the final solution is \(Global_{opt}=1.5910\). The final solution corresponds to the combination of the variable values of the best solution found by period. If the initial solution is the best solution of one period, the variable values in the final solution regarding that period are the values of the initial solution.  
This reduction allows increasing the states to perform a more detailed search in the optimization problem search space. Table 3 presents the new settings of all combinations by period. The number of combinations is 344,393,472, and the expected evaluation time is 619,908.25 s (7.17 days). After evaluating all combinations, the fitness of the final solution improves from \(Global_{opt}=1.5910\) to \(Global_{opt}=1.4741\).