Optimal Energy Storage System and Smart Switch Placement in Dynamic Microgrids with Applications to Marine Energy Integration