**The CoC-based Optimal VGI Microgrid Control Algorithm**

### **Obtain charging information:**

```
 Obtain PEV charging stage information.
```

**Obtain the PEV charging power capacity,** PCap:

```
if no voltage violation occurs
```
PCap = si=<sup>1</sup> PEV,i,max + si=<sup>2</sup> PEV,i;

**elseif** voltage violation occurs

**Curtailment Process 1**: PCap = Pcp;

**if** voltage violation remains at **Process 1**

**Curtailment Process 2**: PCap = Pcp − ΔPCap; ΔPCap is the power curtailment decision of the negotiation. **Enter the Optimal PEV Charging Control**


```
if Pcon ≥ DEV − 
                   si=2 PEV,i
```

```
PEV,i = PEV,i,max;si = 1; PEV,i = PEV,i;si = 2;
```

```
elseif Pcon < length(si(si = 1))∗PJ1772,min
```
Calculate CoC(i|si=1) with PEV,i <sup>=</sup> PJ1772,min

```
Sort CoC(i|si=1) set in ascending order.
```

```
Calculate ns = integer Pcon
                          PJ1772,min
```
Perform optimization defined in Equation (2) among the first ns number of PEVs. Shut off charging of rest stage 1 PEVs – set to state 0

**else**

Perform optimization defined in Equation (2)

**While** (PEV,i<sup>=</sup>**I**(min(**CoC**)) == PEV,i,max) set si = 3;

Pcon = Pcon − PEV,i; Perform optimization defined in Equation (2)

**Exit**
