Global energy consumption is increasing, and there is a growing demand for renewable energy systems that replace fossil fuels with clean alternatives. Low-cost organic material, including organic wastes, can produce clean energy while reducing environmental soil, water, and air emissions. Anaerobic digesters (AD) can convert multiple streams of organic materials to renewable natural gas (RNG) and electricity, but they require optimal operation to minimize costs. This study employs a dynamic mixed-integer linear programming model (MILP) to optimize the collection, allocation, conversion, and dispatch of energy resources. The model optimizes the location of AD facilities producing RNG and power from combined streams that include agricultural biomass, manure, and municipal solid waste. It also optimizes the hourly dispatch of RNG and electricity based on urban residential, industrial, and commercial energy demand. The analysis shows that AD systems could generate RNG with a levelized cost of $0.011/kWh, electricity at a levelized cost of $0.025 to $0.039/kWh, and fertilizer at a cost ranging from $0.035 to $0.055/kWh. Scenario analysis indicates that RNG production is a viable alternative to renewable electricity. These cost estimates vary by location. Larger municipalities could lower costs by leveraging economies-of-scale to reduce capital costs and infrastructure optimizations to minimize waste. Furthermore, optimized AD systems could provide dispatchable heat and power to alleviate energy demand spikes in constrained municipalities. Future studies could evaluate the feasibility of these use cases.