Cobb–Douglas utility maximized by spending a "fixed fraction of income on each good"?
A &quot;fixed fraction&quot; doesn't mean an &quot;equal fraction&quot;, or at least that's not the intended meaning.
It can be easily verified that the solution to
\begin{equation}
\max_{x_1,x_2}\;x_1^{a_1}x_2^{a_2}\qquad\text{s.t.}\; \pi_1x_1+\pi_2x_2\le w
\end{equation}
is
\begin{equation}
x_1^*=\frac{a_1}{a_1+a_2}\frac{w}{\pi_1}\quad\text{and}\quad x_2^*=\frac{a_2}{a_1+a_2}\frac{w}{\pi_2}.
\end{equation}
Plugging in the values you used: $a_1=0.8,a_2=0.2,\pi_1=\pi_2=1$, the solution is consistent with your numerical simulation.
Generalizing to the $n$-goods case (with $\sum_ia_i=1$), the demand for $x_i$ is
\begin{equation}
x_i^*=\frac{a_i}{\pi_i}w,
\end{equation}
where the &quot;fixed&quot; fraction refers to $a_i/\pi_i$.