Distributed Energy Systems Integration and Demand Optimization for Autonomous Operations and Electric Grid Transactions