## 2 Methodology
### Problem Formulation
In addition to their strengths, weaknesses, and applicability, the average execution time is given based on our experimental results. This shows that MOPSO outperforms the other methods. The average time for MOPSO is significantly lower than GA, SA, and MILP, making it more suitable for real-time applications. RL, while adaptive, has a high execution time due to extensive training requirements. Although MOPSO may converge to a local optimum, its speed and ability to handle multi-objective problems make it the best choice for SGBs. Figure 1 gives a flowchart of the load optimization for CSGTs. It begins with the data input including load demand, energy prices, occupancy, and weather. If the building is in grid-connected mode, the load is optimized using the grid supply, otherwise the load is managed using battery storage and RESs. In the latter case, the battery SOC is \begin{table}
\begin{tabular}{l c c c} \hline \hline
**Algorithm** & **Strengths and** & **Weaknesses** & **References** & **Average Execution Time** \\  & **Applicability** & & & **(s)** \\ \hline \multirow{6}{*}{Genetic Algorithm (GA)} & Effective for & & & \\  & multi-objective & & & \\  & optimization and & parameter tuning: & & \\  & nonlinear problems; & computationally & [17; 18] & 6.21 \\  & suitable for large search & expensive for real-time & & \\  & spaces. & & & \\  & Fast convergence; ideal for & & & \\  & real-time applications; & & & \\  & effectively handles & & & \\  & multi-objective problems. & & & \\  & Suitable for discrete and & & & \\  & continuous problems; & & & \\  & simple implementation. & & & \\  & Adaptive and can learn & & & \\  & optimal strategies over & & \\  & time; suitable for dynamic & & & \\  & environments. & & & \\  & Provides exact solutions & & \\  & with linear constraints; & & & \\  & well-suited to small-scale & & & \\  & problems. & & & \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Comparison of Optimization Algorithms for Energy Management. \begin{table}
\begin{tabular}{l c c c} \hline \hline
**Hyperparameter** & **Values** & **Best Value** & **Selection Method** \\ \hline LSTM Units & [64; 128; 256] & 128 & Grid Search \\ CNN Kernel Size & \{3 × 3 × 5 × 5 × 5 × 5 × 5 × 5 × 5 × 5 × 5 × 5 × 5 × 5 × 5 × 5 × 5 × 5 × 5 × 5 × 5 × 5 × 5 × 5 × 5 × 5 × 5 × 5 × 5 × 5 × 5 × 5 × 5 × 5 × 5 × 5 × 5 × 5 × × 5 × 5 × × 5 × 5 × × 5 × × 5 × 5 × × 5 × × 5 × 5 × × 5 × × 5 × × 5 × × × 5 × × × × × × × × × × × × × ×  
checked to ensure it is within the acceptable range. If it is, the system proceeds to charge and/or discharge the battery as needed, otherwise, the process terminates. This flowchart illustrates the dynamic approach to balance grid dependency, renewable resources, and battery usage for load optimization. Model performance is assessed using the Mean Absolute Error (MAE) and coefficient of determination (\(R^{2}\)). The MAE is  
\[\text{MAE}=\frac{1}{n}\sum_{i=1}^{n}|\text{Predicted}_{i}-\text{ Actual}_{i}|, \tag{14}\]  
where Predicted\({}_{i}\) is the \(i\)th predicted value, Actual\({}_{i}\) is the corresponding actual value, and \(n\) is the number of values. The coefficient of determination is  
\[R^{2}=1-\frac{\sum_{i=1}^{n}(\text{Predicted}_{i}-\text{ Actual}_{i})^{2}}{\sum_{i=1}^{n}(\text{Actual}_{i}-\overline{\text{Actual}})^{2}}, \tag{15}\]  
where \(\overline{\text{Actual}}\) is the average actual value.