# A New \"Doctor and Patient\" Optimization Algorithm: An Application to Energy Commitment Problem
## 3 Doctor and Patient Optimization (DPO)
### Implementation of DPO  
After designing the proposed DPO algorithm, it can be used to solve optimization problems. Implementation of DPO is expressed in Algorithm 1. ```
Start DPO
1 System tuning and parameters determination. 2 Formation of the initial population of patients: \(P\). 3 For iteration = 1: iteration max
4 Fitness function evaluation. 5 Updating \(f_{\textit{worst}}\) and \(P_{\textit{worst}}\) based (4). 6 Updating \(f_{\textit{best}}\) and \(P_{\textit{best}}\) based (5). 7 Updating \(F_{i}^{n}\) based (3). 8 For i = 1:N
9 Updating \(\textit{ dosage}_{i}\) based (2). 10 Updating \(P_{i}\) based phase a. 11 Updating \(P_{i}\) based phase b. 12 Updating \(P_{i}\) based phase c.
13 End for i
14 Saving \(f_{\textit{best}}\) and \(P_{\textit{best}}\). 15 End for iteration
16 Return best solution. End DPO

## 4 Energy Commitment (EC) Problem

The EC analysis should be performed in a suitable area, such as the energy grid, which includes the public, commercial, residential, industrial, agricultural, and transportation sectors. In the energy grid, the energy demand is determined as the sum of the demand in the various grid subdivisions using Equation (11). \[EC_{f}=EC_{1}+EC_{2}+\ldots+EC_{N}=\ \sum_{i=1}^{N}EC_{i}, \tag{11}\]

where \(EC_{f}\) is the total energy demand, \(EC_{i}\) is the energy demand of the \(i\)-th sector of grid, and \(N\) is the number of different sectors of the energy grid. In various sectors, the energy consumption is expressed in Equation (12):

\[E_{1}=\ [EC_{1}\ EC_{2}\ldots EC_{i}\ldots\ EC_{N}]^{T}. \tag{12}\]

Here, \(E_{1}\) is the energy demand matrix in the various energy sectors. Final energy consumption based on different energy carriers is determined by Equation (13):

\[E_{2}=\ T_{1,2}\,\times\,E_{1}, \tag{13}\]

where \(E_{2}\) is the final energy consumption based on different energy carriers, and \(T_{1,2}\) is the transform matrix of different energy sectors to different energy carriers. Energy loss is modeled using Equation (14). \[E_{3}=\ T_{2,3}\,\times\,E_{2}. \tag{14}\]

Here, \(E_{3}\) is the final energy consumption based on different energy carriers considering losses, and \(T_{2,3}\) is the efficiency matrix. Input fuels to generation unit in order to electrical energy demand supply are calculated by Equations (15) and (16). \[E_{u}=\ T_{u}\,\times\,E_{e}, \tag{15}\]

\[E_{e_{1}}=\ T_{u,f}\,\times\,E_{u}, \tag{16}\]

where \(E_{u}\) is the value of generation of different units, \(T_{u}\) is the separation matrix of electricity generated by different units that is specified by UC solving, \(E_{e}\) is the total electrical energy demand, \(E_{e_{1}}\) is the input fuel to different units, and \(T_{u,f}\) is the unit efficiency matrix. The input of energy carriers to the units are calculated by Equation (17). \[E_{e_{2}}=\ T_{f,e}\,\times\,E_{e_{1}}, \tag{17}\]

where \(E_{e_{2}}\) is the value of energy carriers for electricity generation, and \(T_{f,e}\) is the conversion matrix of input fuel to energy carriers. In this stage after conversion of electrical energy demand to source energy carriers, final energy consumption is calculated using Equation (18). \[E_{4}=\ E_{3}+E_{e_{2}}-E_{e}. \tag{18}\]

\(E_{4}\) is the final energy consumption after converting electrical energy demand to an input from energy carriers to units. At this stage, Equation (19) is used to simulate the process of refining crude oil. \[E_{p_{1}}=\ T_{p}\ \times\ E_{p}. \tag{19}\]

Here, \(E_{p_{1}}\) represents the energy carriers produced by refining the oil, \(T_{p}\) is the separation matrix of products produced from the refining process, and \(E_{p}\) is the maximum capacity of refineries. Final energy consumption considering the refining crude oil process is determined using Equation (20). \[E_{5}=\ E_{4}+E_{p}-E_{p_{1}}. \tag{20}\]

Here, \(E_{5}\) is the final energy consumption after refining crude oil. Actually \(E_{5}\) determines energy carriers to supply energy demand. Finally, the import and export of energy carriers is determined using Equation (21).