# Solution list from “Solve” too large for my RAM space

I was trying to evaluate a sum of the form $$\sum_{\{x_1,x_2,\ldots,x_{n}\}}f(x_1,x_2,\ldots,x_{n}),$$ where $$\{x_1,x_2,\ldots,x_{n}\}$$ are solutions of a system of linear equations and inequalities of the form, say, $$x_1+x_2+\cdots+x_{15}=4,x_7+x_9+x_{19}+x_{20}=4,\cdots,0\leq x_i\leq4.$$ I used “Solve” to generate the list of all solutions of the linear equations and then substitute them into the sum. This works to about $$n=29$$, but for larger $$n$$ the RAM space runs out just to store the solution list of the linear equations. Now I need to solve the problem for $$n=31$$, is there a way to circumvent the RAM issue? For example is there a way to generate the solutions on the fly and use them in the sum, and when a solution has been used it will be immediately dumped from memory?