Optimal Resource Allocation for Seismic Reliability Upgrading of Existing Structures and Lifeline Networks