Agent-Based Modeling for Optimal Economic Policy with Exogenous Shocks