# Hybrid Energy Routing Approach for Energy Internet
## 4 Subscriber Matching Mechanism
Thus, for instance, if the broker wants to reduce the \(Cost_{p}\) by giving 80% of importance to the \(Cost_{p}\), the importance of the power loss \(w_{c+p}\) will be just 20% and \(\alpha\) in this case is equal to 0.2. If the broker wants to give the same importance to the two objectives, \(\alpha\) took the value 0.5. The broker decides the value of \(\alpha\) according to the system generation capacities. Whenever the number of producers or power generation capacity decreases, the degree of power loss importance increases. 1. The ER selects the producer with the minimum fitness value (Equation (5)), informs the broker to do the necessary updates (8) and to inform the selected producer (7), creates the virtual circuit to start the transfer of energy using the selected efficient path, updates the pre-existing power in its power tables and informs the other ERs: \[Minimize\big{(}Fitness_{p}\big{)}\] (5)  
_Case 2: A multi-source consumer (heavy load)_  
In this case, none of the available prosumers can provide the whole demanded energy, so multiple producers would be chosen by the subscriber matching mechanism to satisfy the consumer demand. The number of selected suppliers for a given consumer (load) should be as limited as possible, to minimize the subscriber matching mechanism complexity, maximize the stability and ensure the security and robustness of the grid [20; 21; 39]. Using the possible producers list (\(L\)), first, the ER creates a vector \(C_{n}^{c}\) of a set of producers/prosumers. \[C_{n}^{c}= \begin{pmatrix}S_{1}\\ S_{2}\\ \ldots\\ S_{m}\end{pmatrix} _{m\times 1}= \begin{pmatrix}p_{11}&p_{12}&\ldots&p_{1n}\\ p_{21}&p_{22}&\ldots&p_{2n}\\ \ldots&\ldots&\ldots&\ldots\\ p_{m1}&p_{m2}&\ldots&p_{mm}\end{pmatrix} _{m\times n}\]  
Each set \(S\) in \(C_{n}^{c}\) contains a number of producers (\(n\)), where the sum of their available power satisfies the consumer's demand (6):  
\[\Sigma_{k=1}^{n}P_{k}>=P_{c},k\in L \tag{6}\]  
Then, for each set \(S_{k}\) in \(C_{n}^{c}\), the ER invokes the energy particle swarm optimization algorithm (_EPSOA_) to determine the required power amount from each producer in set \(S_{k}\) to obtain the minimum fitness value (\(Fitness_{S_{k}}\)):  
\[Fitness_{S_{k}}=\Sigma_{i=1}^{n}Fitness_{p_{i}} \tag{7}\]  
Algorithms 2 and 3 represent the proposed energy particle swarm optimization algorithm (_EPSOA_) with its objective function, respectively. The algorithms' parameters are shown in Table 5.  
The _EPSOA_ initially creates \(k\) particles. A particle reflects the amount of power to be supplied by each producer in the set \(S\) to satisfy the consumer demand (each particle is equivalent to one row in the energy combination matrix). In each particle, if the set contains \(n\) producers, the amount of power obtained from producer 1 to producer \((n-1)\) is randomly within the permissible range, while \(n\)th producer completes the consumer demand. The algorithm evaluates the fitness value including cost and power loss (Equation (7)) of each particle using the objective function in Algorithm 3, initializes _pbest_ and chooses the particle with the minimum fitness value as _gbest_. The algorithm is iterative where in each iteration, the values of \(X\) and \(V\) are updated using Equations (7) and (8). These equations are taken from [33]. \[V_{i}^{t+1}=wV_{i}^{t}+C_{1}r_{1}[pbest_{i}^{t}-X_{i}^{t}]+C_{2}r_{2}[gbest^{ t}-X_{i}^{t}] \tag{8}\]  
\[X_{i}^{t+1}=X_{i}^{t}+V_{i}^{t+1} \tag{9}\]The new values of \(X^{t+1}\) must verify the constraints (10), (11), (13) and (14) while the values of \(pbest\) and \(gbest\) are updated as in Algorithm 2.