If you install the partitions
package, you have the restrictedparts
function that will enumerate all the ways you can add n numbers together to get a sum S. In your case, you want to restrict the summands to be multiples of 5, and the restriction is to add up to S=100. Instead, divide your summands by 5 and have the total add up to 20. If you want 2 assets, then the code restrictedparts(100/5,2) * 5
will give you the 10 unordered pairs.
You can then loop through the columns and enumerate, for each, the set of all permutations of asset allocations. You'll have to deal carefully with the case where there are repeated elements - for example, we generate {100,0} which represents <100,0> and <0,100> whereas {50,50} only represents the single allocation <50,50>. You can deal with this by using the set
attribute of permuatations
restrictedparts(100/5,20) * 5
gives 627 partitions that add up to 100% - and you'll need to permute each of these to get your full list of allocations.