Environmental Impact Assessment and Optimization of Urban Energy Systems