Let $(q_i)_{i\leq n}$ be unit quaternions, $a_{ij}$ be unit quaternions, and $w_{ij}$ be positive real numbers. We consider the expression:$$\sum_{i,j} w_{ij} \arccos(\operatorname{Re}(q_i a_{ij} \bar{q_j})).$$ Can we find a closed form of the $q_i$ that minimizes this sum? Alternatively, can we prove that this problem is convex, so that it can be solved with a solver?
EDIT: Perhaps a more convenient writing:
Denoting $q = (q_i)_{i\leq n}$, $A = (a_{ij})_{ij}$ and $E_{ii}=e_ie_i^{T}$ therefore if we set $A_{ij}=E_{ii}AE_{jj}$ the formula can be rewritten $$\sum_{i,j}w_{ij}\arccos(\operatorname{Re}(q^{T}A_{ij}\bar{q}))$$