## 3 Mathematical Modeling
### Follower (BSS) Model  
After obtaining the charge/discharge price decided by the RE company, the BSS will optimize the charging and discharging power based on the battery-swapping demand in order to maximize its own benefit. The revenue of BSS is shown in Equation (5).  
\[\sum_{t=1}^{N_{t}}sW^{t}+\sum_{t=1}^{N_{t}}P_{\rm d}^{t}o^{t}\Delta t-\sum_{t=1 }^{N_{t}}P_{\rm c}^{t}o^{t}\Delta t \tag{5}\]  
where \(W^{t}\) is the battery swapping demand at time \(t\), and \(s\) is the unit price of battery swapping service charged by the BSS from EV users, and it is a fixed value decided by BSS. Equation (5) consists of three parts: the first part is the income of the battery-swapping service, charging from the EV users, the second part is the income from the sale of electricity to the RE company, and the third part is the cost of purchasing electricity from the RE company to charge the batteries. When the battery swapping demand is known, the income of the battery swapping service is fixed, so the payoff function of the BSS can be expressed as Equation (6).  
\[\max\sum_{t=1}^{N_{t}}(P_{\rm d}^{t}-P_{\rm c}^{t})o^{t}\Delta t \tag{6}\]  
The decision variable is the charging and discharging power in each period of the next day. The strategy space is defined by the following constraints:  
(1) Charge/discharge power constraint  
\[0\leq P_{\rm c}^{t}\leq P_{\rm cmax}^{t} \tag{7}\]  
\[0\leq P_{\rm d}^{t}\leq P_{\rm dmax}^{t} \tag{8}\]  
where \(P_{\rm cmax}^{t}\) and \(P_{\rm dmax}^{t}\) is the upper limit of charging and discharging power of BSS, respectively, which is constrained by the rated power of the PCS in BSS.  
(2) Capacity constraint of the batteries in BSS  
\[Q^{t}\leq Q_{\rm max} \tag{9}\]  
\[Q^{t}=Q_{0}+\sum_{i=1}^{t}\left(P_{\rm c}^{i}\eta_{\rm c}\Delta t-P_{\rm d}^{i} \Delta t/\eta_{\rm d}-W^{i}\right) \tag{10}\]  
where \(Q^{t}\) is the energy storage of BSS at time \(t\), \(Q_{\rm max}\) is the rated capacity of BSS, \(Q_{0}\) is the initial energy storage of BSS, \(\eta_{\rm c}\) and \(\eta_{\rm d}\) denotes the efficiency of charging and discharging, respectively.  
The battery-swapping demand of EVs is expressed in the form of quantity of electricity, that is, the number of batteries switched by EV users in each period multiplied by the capacity of a single battery. In order to simplify the model, we assume that the battery specifications in BSS are the same and that the charging and discharging strategies of a single battery can meet its limitations of battery capacity. Thus the iterative formula of the overall residual energy of BSS is similar to that of ESS, as shown in Equation (10). We only consider the overall energy optimization of BSS in this paper. When the overall charge/discharge strategy of BSS is given, the specific charge/discharge control of a single battery belongs to the internal energy management problem of BSS, which is not involved in this paper.  
(3) BSS energy storage constraint at the end of a decision-making cycle  
\[Q^{N_{t}}\geq Q_{\rm end} \tag{11}\]where \(Q_{\rm end}\) refers to the minimum energy storage of the BSS required at the end of the decision-making cycle. Without prejudice to the battery swapping services at the next decision-making cycle, \(Q_{\rm end}\) is usually equal to \(Q_{0}\).  
(4) Battery swapping demand reserve constraint  
\[Q^{t}\geq Q_{\rm min}+(1+\alpha)W^{t+1} \tag{12}\]  
where \(Q_{\rm min}\) is the minimum energy stored in the BSS. In order to prevent battery life shortening from over discharge, 10%-30% of \(Q_{\rm max}\) is usually taken as \(Q_{\rm min}\). Considering the uncertainty of battery-swapping demand, it is necessary to prepare a certain amount of fully charged batteries as reserve. Consequently, the reserve ratio \(\alpha\) is introduced.  
(5) Zero emission constraint over EVs  
\[P_{\rm c}^{t}\leq P_{\rm RE}^{t} \tag{13}\]  
According to the contract between BSS and the RE company, BSS can only charge the battery by the power from renewable energy in order to realize zero emissions of EVs.