## 2 Methodology
### Mixed Integer Linear Problem Formulation
 \tag{21}\]\[S_{i}(0) =S_{i}^{ini}\quad\forall i, \tag{23}\] \[S_{i}(N_{t}) =S_{i}(0)\quad\forall i,\] (24) \[S_{j}(t) =S_{j}(t-1)+\eta_{j}^{c}(t)\cdot P_{j}^{c}(t)\cdot\Delta T-\frac{1 }{\eta_{j}^{d}(t)}\cdot P_{j}^{d}(t)\cdot\Delta T-\rho_{j}\cdot\Delta T-\Delta S _{j}(t)\quad\forall j,t,\] (25) \[S_{j}(0) =S_{j}^{ini}\quad\forall j,\] (26) \[S_{j}(N_{t}) =S_{j}(0)\quad\forall j. \tag{27}\]  
In particular, Equations (7) and (8) are inequality constraints imposing the unidirectional power flow at the grid connection (either withdrawal or injection) for each timestep. Analogous formulations are assumed for charge and discharge power of storage devices in Equations (9) and (10) and of EVs in Equations (11) and (12). Moreover, Equations (13) and (14) represent the operating limits of power exchange at point of common coupling, and Equations (15)-(17) impose boundaries on charge power, discharge power, and state-of-charge (SOC) of storage. In Equation (17), battery SOC limits are a function of time, due to a proper model of capacity reduction depending on battery aging. Residual capacity of the \(i\)-th battery at time \(t\)\(E_{i}(t)\) can be determined from nominal capacity \(E_{i}^{nom}\) as a function of the total number of cycles experienced by the battery in its operation lifetime until the selected interval \(\varphi_{i}(t)\), as follows [50]:  
\[E_{i}(t)=E_{i}^{nom}\cdot a_{i}\cdot\exp(-b_{i}\cdot\varphi_{i}(t)), \tag{28}\]  
where coefficients \(a_{i}\) and \(b_{i}\) depend on the selected battery type. The number of cycles \(\varphi_{i}(t)\), which is kept lower than \(\Phi_{i}\) to avoid replacement, is related to battery charge and discharge, depending on the imposed depth-of-discharge \(DOD_{i}\). Therefore, in Equation (17), \(\overline{S}_{i}(t)=E_{i}(t)\) and \(\underline{S}_{i}(t)=E_{i}(t)\cdot DOD_{i}\). Analogously to batteries, EV exploitation limits are imposed by Equations (18)-(20), accounting for aging as well, although the upper limits of charge and discharge power are null for the expected EV driving intervals. The equality constraint in Equation (21) ensures the power balance at common DC bus described in Equation (21). In this equation, parameters \(h\) and \(\alpha\) represent inverter efficiency and cable losses coefficient, respectively, for the connection of devices indicated by the subscripts. Moreover, the update of SOC is imposed, respecting initial and final values, written for batteries in Equations (22)-(24) and for EVs in Equations (25)-(27). In particular, \(\Delta S_{j}(t)\) represents the amount of energy exploited for mobility by the \(j\)-th EV at the \(t\)-th time step, determined according to proper forecast. The value of \(\Delta S_{j}(t)\) is generally not null, only in EV driving intervals. Some parameters, such as the converter efficiency, storage efficiency, storage capacity, and cable losses, show a non-linear dependence on the operating point of the device, which can be defined by the exchanged active power. In order to account for these features in the proposed MILP formulation, an iterative methodology is proposed, as sketched in Figure 1. In particular, the methodology starts from the vector \(\mathbf{u}^{0}\) of initial values of parameters (e.g., nominal efficiency, battery capacity of the previous day), and by solving the MILP problem in Equation (4) the initial solution \(\mathbf{x}^{0}\) is obtained. Therefore, the methodology includes, for each iteration \(k\), the update of parameter vector \(\mathbf{u}^{k}\) (e.g., through proper efficiency curves) and a new solution of the MILP problem in Equation (4), obtaining the state variable vector at \(k\)-th iteration \(\mathbf{x}^{k}\) using \(\mathbf{u}^{k}\). A convergence criterion is placed on the difference of the problem solution, determined as the sum of absolute values of differences of each component of the solution vector between two iteration steps, which does not have to overcome a specified threshold \(\varepsilon\).