Using R, I would like to simulate a number of feasible portfolios which contain different combinations of assets. I would like to generalize the constraints and be able to add more asset classes in if necessary.
For example, assume there are 4 asset classes, each subject to the following constraints:
- 0 <= x1 < 0.5
- 0 <= x2 < 0.3
- 0 <= x3 < 0.5
- 0 <= x4 < 1
- x1 + x2 + x3 + x4 = 1
How can I simulate 10 000 random portfolios (or matrices in this case) that satisfy all those conditions without simulating all combinations first and then throwing away the ones that do not satisfy the conditions? I do not want to scale portfolios that do not satisfy the last condition either. Any help would be greatly appreciated!