this time slot and also battery state.

The charging rate control law shown in Fig. 2 means to serve the demand as fast as possible when the battery has sufficient power.

![A sketch for the whole algorithm.[]{data-label="fig_3"}](2.eps){width="80mm"}

![A sketch for the whole algorithm.[]{data-label="fig_3"}](sketch.eps){width="80mm"}

### Renewable energy input

Every charging station determines the charging rate of their harvested renewable energy at time slot $t$, depending on the battery state, also in a distributed way, $$R_i(t)
= \left\{
\begin{aligned}
\min\{R_{i}^{max},(U_{i}(t)-\sum_{j=1}^{J_{i}}r_{ij}(t))^+\}~~~~\\
0~~~~\\
\end{aligned}
\right.
\begin{aligned}
&\text{if}~ H_{i}(t) \leq 0 \\
&\text{otherwise}~~ ~~
\end{aligned}$$

It is intuitive that $H_i(t)<0$ means that the battery is thirsty so that all available renewable energy should be charged into it; however, when there is enough electricity in the battery, no renewable energy will be charged into, for the sake of battery constraints in (\[eq\_5\]).

### Consumption from the power grid

By introducing the Lagrangian dual problem $\widehat \textbf{P6}$, each charging station can locally solve a subproblem given by $$\label{eq_24}
\begin{array}{cc}
\min & \Lambda _{i}\left( D_{i}^{d}\left( t\right) ,\vec{\lambda}\right) \\
\text{s.t.} & 0\!\leq\!D_{i}^{d}\left( t\right)\!\leq\!\left(
\sum\limits_{j=1}^{J_{i}}r_{ij}\left( t\right)\!-\!U_{i}\left( t\right) \right)
^{+}.\end{array}$$

The dual problem is solved by using gradient projection method, and the Lagrangian multipliers are updated as following: $$\label{eq_25}
\begin{split}
&\lambda_l(n\!+\!1,t)\!=\!\left[\lambda_l(n,t)\!-\!\kappa\left(P_l\!-\!\!\!\!\sum_{i:X_{li}=1}\!\!D_i^d(n,t)-\textbf{E}\{N_l(t)\}-\frac{\sigma_{N_l}}
