Solution to variational problem I am struggling to see how to get to the solution of the equation below. The problem equation and solution come from here (see eqn 3 and eqn4). They state that this is a variational problem,
$$
p^{*}(a | w)=\underset{p(a | w)}{\arg \max } \sum_{a} \left[ p(a | w) U(w, a)-\frac{1}{\beta}  p(a | w) \log \frac{p(a | w)}{p_{0}(a)} \right]
$$
given that $0<p(a | w)<1$ and $\sum_{a} p(a | w) =1$
The answer is:
$$
p^{*}(a | w)=\frac{1}{Z(w)} p_{0}(a) e^{\beta U(w, a)}
$$
where $Z$ is the normalisation constant
$$
Z(w)=\Sigma_{a} p_{0}(a) e^{\beta U(w, a)}
$$
Edit: Added the constraint that p lies between 0 and 1 (as it's a probability)

The problem can restated more clearly as looking for $$\text{argmax}_{x\in \mathbb R^n} \sum_{i=1}^n x_i U_i -\frac 1\beta x_i\log\frac{x_i}{y_i} \quad \text{such that }\sum_{i=1}^n x_i=1 $$
Note that the constraints $x_i\geq 0$ are implicit since $\log x_i$ appears in the objective. The Lagrangian is $$\mathcal L(x,\gamma) = \sum_{i=1}^n x_i U_i -\frac 1\beta x_i\log\frac{x_i}{y_i} + \gamma ( \sum_{i=1}^n x_i-1)$$
and $\displaystyle \frac{\partial \mathcal L}{\partial x_i}(x,\gamma) = U_i-\frac 1\beta \left( \log\frac{x_i}{y_i}+1\right)+\gamma$, which is $0$ if and only if $\displaystyle y_ie^{\beta U_i}e^{\gamma-1}=1$.
The constraint on the $x_i$ implies $e^{\gamma-1}= \sum_{i=1}^n y_ie^{\beta U_i}$, so that the optimal $x$ is given by $$x_i= \frac{y_ie^{\beta U_i}}{\sum_{i=1}^n y_ie^{\beta U_i}}$$
