Let $A$ and $B$ are two given Hermitian operators on matrix algebra $M_n(\mathbb{C})$. $A$ is positive semi-definite with unit trace. I want to know the general method for calculating the following quantity \begin{equation} \sup_{U\in \mathcal{U}_n} |Tr(UAU^*B)|, \end{equation} where $Tr$ is the trace operation, $\mathcal{U}_n$ is the group of $n \times n$ unitary matrices. Is there a general method (algorithmic?) for finding such quantities?
Moreover, is there a similar method if we try to calculate
\begin{equation} \sup_{X\in Gl_n(\mathbb{C})} \frac{|Tr(XAX^*B)|}{Tr(XAX^*)} \end{equation}
Partial work: I know, this is unbounded with respect to $n$. However I want to see the above quantities for a fixed $n>2$, where $A$ and $B$ are known.