Given a Hermitian matrix $X\in\mathbb{R}^{n\times n}$ we can use Schur decomposition to diagonalize it:
\begin{equation} U^*XU=\begin{bmatrix}\lambda_1 & & \\ & \ddots & \\ & &\lambda_n\end{bmatrix}. \end{equation}
What if the diagonal elements after the transformation are subject to certain upper bound? Then we can try to diagonalize $X$ as much as possible to satisfy the constraint. But we need some proper measure of the deviation from diagonality. Maybe the sum of squares of the off-diagonal elements? Let $T=T_\text{diag}+T_\text{off}$, where
\begin{equation} T_\text{diag}=\begin{bmatrix}t_{11} & & &\\&t_{22}&&\\& & \ddots & \\ & & &0\end{bmatrix},\quad T_\text{off}=\begin{bmatrix}0 & t_{12} & \ldots & t_{1n}\\t_{21}&0&\ldots&t_{2n}\\\vdots&\vdots & \ddots & \vdots \\t_{n1} &t_{n2} & \ldots &t_{nn}\end{bmatrix}. \end{equation}
Then the sum of squares of off-diagonal elements in $T$ is the square of the Frobenious norm of $T_\text{off}$.
Then, we formulate the following optimization problem:
\begin{array}{ll} \text{minimize} & ||T_\text{off}||_F\\U\in\mathcal{U}\\\text{subject to} & U^*XU=T=T_\text{diag}+T_\text{off}\\&T_{ii}\leq a_{ii},\end{array}
where $||T_\text{off}||_F$ is the Frobenious norm of $T_\text{off}$ and $\mathcal{U}$ is the set of all $n\times n$ unitary matrices. I am wondering if we can get a closed-form solution?