# Design and Development of a Management System for Energy Microgrids Using Linear Programming
## 2 Materials and Methods
### Proposed Optimization Approach  
Mathematically, the problem is described as follows: Let \(\mathcal{G}\) be a set of available generation technologies (Solar: S, Wind: W, Diesel: D), \(\mathcal{I}\) be a set of electric generators, conventional and non-conventional, each of them with technical parameters and dimensions depending on the associated technology, and \(\mathcal{T}\) be the set of time periods within the planning horizon. In addition, consider a battery system with the capacity to charge when the total power of the microgrid exceeds the demand load and also supports the microgrid by serving as another energy source. The goal is to satisfy the expected load demand for each time period (\(d_{t}\)) into an energy microgrid, determining the functional capacity connected to the network of each generation technology in each time frame, all while minimizing the total cost of operation. Table 11 presents model variables. According to the nature of the problem, the optimization model needs to calculate how much power needs to be produced by each generator at each time period (\(t\in\mathcal{T}\)). Therefore, based on the work of [15], Equations (1)-(3) describe, respectively, the solar, wind, and diesel generation. Let \(f(i)\to G=\{S,W,D\}\) serve as the function that returns the type of generator technology \(i\in I\). Thereby, power generation \(g_{it}\) depends on whether the generator is switched on or off. \[f(i)=S\to g_{St}=\left(G_{S,test}*\frac{R_{t}}{R_{S,test}}\right)*x_{St} \tag{1}\]  
\[f(i)=W\to g_{Wt}= \begin{cases}0,&W_{t}<W_{min}\\ \frac{1}{2}\big{(}\rho_{W}A^{W}W_{t}^{3}\eta_{W}\big{)}*x_{Wt},&W_{min}\leq W_ {t}<W_{a}\\ \frac{1}{2}\big{(}\rho_{W}A^{W}W_{a}^{3}\eta_{W}\big{)}*x_{Wt},&W_{a}\leq W_{t} \leq W_{max}\\ 0,&W_{t}>W_{max}\end{cases}  \tag{2}\]  
\[f(i)=D\to x_{Dt}*g_{min}^{D}\leq g_{Dt}\leq x_{Dt}*g_{max}^{D} \tag{3}\]  
In the generation equations, the concept of installed capacity is used to measure how much energy can be generated from a specific source. In the case of renewable sources, the concept of peak power is used by the technology, which allows one to calculate how much electricity would be transformed according the amount of the primary source. Considering the decisions and the associated generation functions, the mathematical model is defined as follows:  
\[\min\sum_{i\in I}\
u a\_op_{i}*g_{it} \tag{4}\]  
The objective function (4) seeks to minimize the variable operational costs of the energy system. The variable operational cost, \(va\_op_{i}\), is associated with the maintenance of the equipment during its life-cycle and the fuel, if any is used by the generator. \[\sum_{i\in I:f(i)\in\{S,W,D\}}g_{it}=el_{t}+eb_{t}+ew_{t} \tag{5}\]  
\[d_{t}=el_{t}+g_{Bt}+g_{Ft} \tag{6}\]  
The first group of constraints is related to the control of the use of the generated energy. Equation (5) splits the generated energy into the portion that seeks to satisfy the demand, the portion that is used to load the battery, and a potential portion that is discarded. Meanwhile, constraints in Equation (6) ensure that the demand is satisfied through the sum of the energy generated for that purpose, the energy coming from the battery, and the energy from a dummy generator representing the unmet demand. \[b_{t} =b_{t-1}*(1-\sigma)+\left[(eb_{t}*\eta_{bat})-\left(\frac{g_{Bt}}{ \eta_{inv}}\right)\right]*\delta t \tag{7}\] \[b_{t} \leq u_{B} \tag{8}\]  
The second group of constraints is related to the state of charge of the battery. The constraint in Equation (7) calculates the state of charge of the battery system, at the end of the period \(t\), taking into account the energy dissipation \(\sigma\), and the charging and discharging efficiencies, \(\eta_{bat}\) and \(\eta_{inv}\), respectively. Equation (8) sets the limit to the capacity of the battery \(u_{B}\).