Text this: Optimizing energy flow in advanced microgrids: a prediction-independent two-stage hybrid system approach