# A Convex Optimization Algorithm for Electricity Pricing of Charging Stations
## 3 Convex Optimization Algorithm
### SOCR Method
\begin{array}{l}\zeta_{ij,t}^{0}\geq|R_{ij,t}|,\forall t\in T,\forall ij\in L \\ \eta_{ij,t}^{0}\geq|S_{ij,t}|,\forall t\in T,\forall ij\in L\\ \zeta_{ij,t}^{0}\geq|\frac{W_{i}-W_{j,t}}{2}|,\forall t\in T,\forall ij\in L \\ \sigma_{ij,t}^{0}\geq|E_{ij,t}|,\forall t\in T,\forall ij\in L\end{array}  \tag{21}\]\[ \begin{array}{l}\zeta_{ij,t}^{k}=\cos(\frac{\pi}{2^{k+1}})\zeta_{ij,t}^{k-1}+ \sin(\frac{\pi}{2^{k+1}})\eta_{ij,t}^{k-1},k\in 1,\ldots,v,\forall t\in T,\forall ij\in L\\ \eta_{ij,t}^{k}\geq|-\sin(\frac{\pi}{2^{k+1}})\zeta_{ij,t}^{k-1}+\cos(\frac{ \pi}{2^{k+1}})\eta_{ij,t}^{k-1}|,k\in 1,\ldots,v,\forall t\in T,\forall ij\in L\\ \zeta_{ij,t}^{k}=\cos(\frac{\pi}{2^{k+1}})\zeta_{ij,t}^{k-1}+\sin(\frac{\pi}{ 2^{k+1}})\zeta_{ij,t}^{k-1},k\in 1,\ldots,v,\forall t\in T,\forall ij\in L\\ \sigma_{ij,t}^{k}\geq|-\sin(\frac{\pi}{2^{k+1}})\zeta_{ij,t}^{k-1}+\cos( \frac{\pi}{2^{k+1}})\sigma_{ij,t}^{k-1}|,k\in 1,\ldots,v,\forall t\in T,\forall ij \in L\end{array}  \tag{22}\]  
Finally, the upper bound of the polyhedron is defined by Equation (23). \[ \begin{array}{l}\zeta_{ij,t}^{v}\leq E_{ij,t},\forall t\in T,\forall ij\in L \\ \eta_{ij,t}^{v}\leq\tan(\frac{\pi}{2^{v+1}})\zeta^{v},\forall t\in T,\forall ij \in L\\ \xi_{ij,t}^{v}\leq\frac{W_{i,t}+W_{j,t}}{2},\forall t\in T,\forall ij\in L\\ \sigma_{ij,t}^{v}\leq\tan(\frac{\pi}{2^{v+1}})\xi_{ij,t}^{v},\forall t\in T, \forall ij\in L\end{array}  \tag{23}\]  
The details of polyhedral approximation method are described in Algorithm 1. ```
1:\(v\): = 0, obtain \(\varepsilon\) by Equation (20), construct model by Equations (11), (12), and (14)
2:while\(\varepsilon>10^{-7}\)do
3:\(v\)++, obtain \(\varepsilon\) by Equation (20)
4:endwhile
5:for\(t\) = 1 to \(T\)do
6:for\(ij\) = 1 to \(L\)do
7: add Equations (21) and (23) into model
8:for\(k\) = 1 to \(v\)do
9: add Equation (22) into model
10:enddo
11:enddo
12:enddo
13: solve MILP by branch and bound method
14:return\(P_{G,t}\), \(P_{c,t}\), \(\pi_{c,t}\), \(R_{ij,t}\), \(S_{ij,t}\), \(W_{i,t}\),\(f_{DSO}\),\(f_{CS_{8}}\) and\(f_{EV,n}\)
```  
**Algorithm 1**Polyhedral approximation algorithm  
The relaxation process is shown in Figure 2. The original non-convex feasible region is first relaxed to a second order cone and then to a series of polyhedrons, which can be solved quickly by simplex method. The original solution variables are projected into high-dimensional space by SOCR, so it is necessary to get the original variables by returning the mapping. Firstly, the voltage can be returned by Equation (24). \[V_{i,t}=\sqrt{W_{i,t}},\forall t\in T,\forall i\in I. \tag{24}\]  
Figure 2: Relaxation process. Then the power angle difference of the line can be obtained by Equations (25) and (26). Based on the agreement of \(\theta_{0,t}=0\), all angles can be obtained by solving the matrix. \[\tan(\theta_{i,t}-\theta_{j,t})=\tan\theta_{ij,t}=\frac{S_{ij,t}}{R_{ij,t}}, \forall t\in T,\forall ij\in L, \tag{25}\]  
\[\theta_{i,t}-\theta_{j,t}=\tan^{-1}\frac{S_{ij,t}}{R_{ij,t}},\forall t\in T, \forall ij\in L. \tag{26}\]  
The details of return mapping method are described in Algorithm 2. ```
1:\(R_{ij,t}\), \(S_{ij,t}\), and \(W_{i,t}\): calculated by Algorithm 1
2:for\(t=1\) to \(T\)do
3:for\(i=1\) to \(N\)do
4:\(V_{i,t}\): calculated by Equation (24)
5:enddo
6:\(\theta_{N0,t}\):=0
7:for\(ij=1\) to \(L\)do
8:\(\theta_{i,t}\): calculated by Equation (26)
9:enddo
10:enddo
11:return\(V_{i,t}\) and \(\theta_{i,t}\)
```  
**Algorithm 2: Return mapping algorithm**  
In order to verify the accuracy of relaxation, relaxation errors are defined as Equation (27) to check whether constraints are satisfied. \[gap_{ij,t}=|R_{ij,t}^{2}+S_{ij,t}^{2}-W_{i,t}W_{j,t}|,\forall t\in T,\forall ij \in L. \tag{27}\]