Failure prevention and restoration in power systems