*4.3. Distributed Algorithm*

To search the Nash equilibrium of the formulated non-cooperative game and population evolution result of the residential communities participating in DR, a distributed algorithm is proposed which is shown in Algorithm 1. In the algorithm, an interior point method is employed to solve Equation (22), which has superior performance in solving convex optimization problems. In addition, steps 2–10 are designed to search the Nash equilibrium among communities in the day-ahead bidding market, and steps 11–14 are designed to obtain the population evolution result of residential communities participating in DR.

**Algorithm 1:** Searching for Nash equilibrium and population evolution result

**Input:** Parameters *a<sup>t</sup> h* , *b<sup>t</sup> h* , *Lh*,min *<sup>n</sup>* , *Lh*,max *<sup>n</sup>* , etc. **Output:** Nash equilibrium, population evolution result. **Initialization:** Number of group *N* in week 1. **1** *h* = 1; **2 Repeat 3** *n* = 1; **4 for** *n* ≤ *N*(*h*) **do 5** Initialize bidding strategy vector *L<sup>h</sup> n*; **<sup>6</sup>** Each community *<sup>n</sup>* <sup>∈</sup> *<sup>N</sup>* updates *<sup>L</sup><sup>h</sup> <sup>n</sup>* by solving Equation (22); **7** *n* = *n* + 1; **8 end 9 Until** No community changes its strategy; **10 Return** Nash equilibrium  *Lh*<sup>∗</sup> *<sup>n</sup>* , *Lh*<sup>∗</sup> −*n* ; **11** Calculate transition probability α and β; **12 Update** group population with Equation (40); **13** *h* = *h* + 1; **14** Go back to step **2** until |*N*(*h*+1) − *N*(*h*)| changes in a termination criterion.
