  We show that the following group constructions preserve the semilinearity of
the solution sets for knapsack equations (equations of the form $g_1^{x_1}
\cdots g_k^{x_k} = g$ in a group $G$, where the variables $x_1, \ldots, x_k$
take values in the natural numbers): graph products, amalgamated free products
with finite amalgamated subgroups, HNN-extensions with finite associated
subgroups, and finite extensions. Moreover, we study the dependence of the
so-called magnitude for the solution set of a knapsack equation (the magnitude
is a complexity measure for semi-linear sets) with respect to the length of the
knapsack equation (measured in number of generators). We investigate, how this
dependence changes under the above group operations.
