On Engineering Self-Organizing Environments: Stochastic Methods for Dynamic Resource Allocation