Optimal resource allocation for seismic reliability upgrading of existing structures and lifeline networks