Algorithms for Optimal Topology Design, Placement, Sizing and Operation of Distributed Energy Resources in Resilient Off-grid Microgrids