# Joint Acquisition Time Design and Sensor Association for Wireless Sensor Networks in Microgrids
## 4 Problem Formulation and Problem Solution
### Problem Solution
#### 4.3.1 Acquisition Time Optimization  
We first optimize the acquisition time \(\boldsymbol{T}\) with given sensor association \(\mathbf{X}\). At this time, the optimization problem \(\mathbf{P}\) can be expressed as follows:  
\[\begin{split}\mathbf{P1}:\underset{T}{max}&\sum_{n}U(t _{n})-\beta\left(p_{c}\sum_{n}t_{n}+\sum_{i}E_{CM_{i}}+\sum_{j}E_{CH_{j}} \right)\\ &=\sum_{n}U(t_{n})-\beta\left(p_{c}\sum_{n}t_{n}+\sum_{i}\left[ \frac{1}{\eta}(p_{t}+\alpha)*l*t_{i}*\sum_{j}\frac{x_{ij}}{r_{ij}}\right] \right.\\ &+\sum_{j}\left[e_{c}*\sum_{i}(l*t_{i}*x_{ij})+E_{DA}*\big{(}\sum _{i}(l*t_{i}*x_{ij})+l*t_{j}\big{)}\right]\right)\\ s.t.& 0<t_{n}<T_{\max},\forall n\in\mathcal{N}. \end{split} \tag{12}\]  
It can be seen that when the satisfaction function \(U(\cdot)\) is modeled as a convex function, the problem is a convex optimization problem about \(\boldsymbol{T}\), so the strong duality condition holds. Therefore, its Lagrangian function and dual problem can be constructed as follows:  
\[\begin{split} L(\boldsymbol{T},\boldsymbol{\lambda},\boldsymbol{ \
u})&=\sum_{n}U(t_{n})-\beta\left(p_{c}\sum_{n}t_{n}+\sum_{i} \left[\frac{1}{\eta}(p_{t}+\alpha)*l*t_{i}*\sum_{j}\frac{x_{ij}}{r_{ij}}\right] +\sum_{j}\left[e_{c}*\sum_{i}(l*t_{i}*x_{ij})\right.\\ &\left.+E_{DA}*\big{(}\sum_{i}(l*t_{i}*x_{ij})+l*t_{j}\big{)} \right]\right)+\sum_{n}\lambda_{n}t_{n}+\sum_{n}\
u_{n}(T_{\max}-t_{n}),\end{split} \tag{13}\]where \(\lambda=\{\lambda_{n},\forall n\in\mathcal{N}\},\boldsymbol{v}=\{v_{n},\forall n \in\mathcal{N}\}\) is a non-negative Lagrangian multiplier. Then the dual function is expressed as follows:  
\[D(\lambda,\boldsymbol{v})=\underset{\boldsymbol{T}}{max}\,L(\boldsymbol{T}, \lambda,\boldsymbol{v}). \tag{14}\]  
The dual problem is as follows:  
\[\underset{\boldsymbol{\lambda},\boldsymbol{v}}{min} D(\lambda,\boldsymbol{v}) \tag{15}\] \[s.t. \lambda\succeq 0,\] \[\boldsymbol{v}\succeq 0.\]  
In order to obtain the dual function, we take the first derivative of the Lagrangian function with respect to \(\boldsymbol{T}\) to obtain:  
\[t_{n}^{*}=\left\{\begin{array}{l}U^{\prime-1}\Bigg{[}\beta\big{(}p_{c}+ \frac{(p_{t}+\alpha)t}{\eta}*\sum\limits_{j}\frac{x_{ij}}{r_{ij}}+l(e_{c}+E_{DA} )\sum\limits_{j}x_{ij}\big{)}-\lambda_{n}+v_{n}\Bigg{]},if\;n\in\mathcal{L},\\ U^{\prime-1}\Bigg{[}\beta(p_{c}+l)-\lambda_{n}+v_{n}\Bigg{]},if\;n\in\mathcal{ K},\end{array}\right. \tag{16}\]  
when \(t_{m}^{*}\) is found, and the dual function can be obtained. Then, we can solve the dual problem to obtain the optimal solution of \(\mathbf{P1}\). For the dual problem, we use the sub-gradient method to obtain the optimal Lagrangian multiplier. The iterative expression is as follows:  
\[\lambda_{n}^{(r+1)}=[\lambda_{n}^{r}+s_{r}t_{n}]^{+},\forall n\in\mathcal{N}, \tag{17}\]  
\[v_{n}^{(r+1)}=[v_{n}^{r}+s_{r}(T_{\max}-t_{n})]^{+},\forall n\in\mathcal{N}, \tag{18}\]  
where \([x]^{+}\triangleq max\{x,0\}\), \(s_{r}\) is the \(r\)-th iteration step, and its value is set to \(s_{r}=\beta/\|g^{r}\|\); \(g^{r}\) is the current gradient of the dual function for the \(r\)-th iteration. The details of subgradient iteration can be seen from algorithm ATSAO.