breed [roadnodes roadnode] ;; entities of the road network breed [metronodes metronode] ;; entities of the metro network breed [criticalnodes criticalnode] ;; entities of the critical infrastructure network undirected-link-breed [rrr rr] ;; edges of road network (connection road network nodes) undirected-link-breed [recroad recr] ;; new edges introduced in the road subsystem after the recovery phase undirected-link-breed [mmm mm] ;; edges of metro network (connection metro network nodes) undirected-link-breed [recmetro recm] ;; new edges introduced in the metro subsystem after the recovery phase undirected-link-breed [rmrm rm] ;; links between the subsystems of roads and metro (connection/dependence between road and metro nodes) undirected-link-breed [recrmrm recrm] ;; new trans-system edges introduced in the system after the recovery phase undirected-link-breed [chroad chr] ;; temporary edges to check the potentional entropy of the road subsystem undirected-link-breed [chmetro chm] ;; temporary edges to check the potentional entropy of the metro subsystem roadnodes-own [roadcapacity ;; capacity measure of the nodes of the road network road_factor ;; average length of out-links of each node of the road network, used as a factor of performance road_utility_factor ;; average population's needs from the neighboring patches of each road node my_r_links ;; number of my-links of each road network's node missing_linksR ;; difference between original links and the links after the disturbance of the road subsystem ch_R_entropy ;; entropy of each node of the road subsystem based on the curretnt links / original links R_entropy ;; marginal entropy of each node of the road subsystem during the check for the recovery status ] metronodes-own [metrocapacity ;; capacity measure of the nodes of the metro network metro_factor ;; average length of out-links of each node of the metro network, used as a factor of performance metro_utility_factor ;; average population's needs from the neighboring patches of each metro node my_m_links ;; number of my-links of each metro network's node missing_linksM ;; difference between original links and the links after the disturbance of the metro subsystem ch_M_entropy ;; entropy of each node of the metro subsystem based on the curretnt links / original links M_entropy ;; marginal entropy of each node of the metro subsystem during the check for the recovery status ] criticalnodes-own [cicapacity ;; capacity measure of the nodes of the critical infrastructure network is-on? ;; boolean variable to identify if a criticalnode is on or not ci_range ;; distance of the closest criticalnode ci_factor ;; number of served agents of each node of the critical infrastructure network, used as a factor of performance / 10 ci_roadfactor ;; number of served roadnodes of each node of the critical infrastructure network ci_metrofactor ;; number of served metronodes of each node of the critical infrastructure network ci_utility_factor ;; average population's needs from the neighboring patches of each critical node my_CI_factor ;; number of my coverage factor of each critical infrastructure network's node missing_linksCI ;; difference between original links and the links after the disturbance of the critical infrastructure subsystem ch_CI_entropy ;; entropy of each node of the critical infrastructure subsystem based on the curretnt links / original links CI_entropy ;; marginal entropy of each node of the critical infrastructure subsystem during the check for the recovery status ] turtles-own [nodeneighbors ;; list of initial number of connections for each node of the entire system nodelinks ;; list of number of connections for each node of the entire system missing_linksRM ;; difference between original links and the links after the disturbance of the road-metro trans-system links is-dist? ;; boolean variable to identify if an agent is missing an intra-system link or not is-dist-RM? ;; boolean variable to identify if an agent is missing a trans-system link or not is-served? ;; boolean variable to identify if a road or metro agent is missing the connection to the CI nodes or not is-served-RM? ;; boolean variable to identify if a road-metro trans-system link is missing the connection to the CI nodes or not original_neighborsR ;; number of road node's neighbors at the beginning of the run original_neighborsM ;; number of metro node's neighbors at the beginning of the run original_neighbors_RM ;; number of trans-system road-metro neighbors at the beginning of the run original_neighborsCI ;; number of critical infrastrucure node's neighbors at the beginning of the run ch_RM_entropy ;; entropy of each RM-node of the metro subsystem based on the curretnt RM-links / original RM-links priopop ;; popuation for each node calculated at the beginning of the run for the prioritization of recovery ] patches-own [population ;; attribute related with the population's density new_population ;; population-based utility measure affected by the system's performance loss new_populationRM ;; population-based utility measure affected by the road-metro subsystem's performance loss ] globals [roadcapacitylist ;; list of the capacity measure of the road subsystem metrocapacitylist ;; list of the capacity measure of the metro subsystem CIcapacitylist ;; list of the capacity measure of the CI subsystem original_rm_road ;; number of road nodes connected with metro nodes at the beginning of the run original_rm_metro ;; number of metro nodes connected with road nodes at the beginning of the run original_rm_roadnodes ;; set of road nodes interconnected with metro nodes via rmrm links at the begining of the run rm_roadnodes ;; set of road nodes with rmrm or recovered rmrm links throughout the run original_rm_metronodes ;; set of metro nodes interconnected with road nodes via rmrm links at the begining of the run rm_metronodes ;; set of metro nodes with rmrm or recovered rmrm links throughout the run roadrm ;; capacity measure of interconnected road nodes metrorm ;; capacity measure of interconnected metro nodes rmcapacity ;; capacity measure of interconnected road and metro nodes totalcapacity ;; capacity measure of the nodes of the entire system totalcapacitylist ;; list of the capacity measure of the entire system totalcapacitylevel ;; capacity percentage original_neighbors ;; number of each node's neighbors at the beginning of the run this_entropy_R ;; marginal entropy of the road subsystem during the check for the recovery status this_entropy_M ;; marginal entropy of the metro subsystem during the check for the recovery status ch_entropy_list_R ;; the list of the road subsystem's entropy values during the check for the recovery status ch_entropy_list_M ;; the list of the metro subsystem's entropy values during the check for the recovery status ch_roadnode ;; to identify the disturbed road nodes ch_metronode ;; to identify the disturbed metro nodes ch_metronode_RM ;; to identify the disturbed road-metro links using the nodes of the metro subsystem ch_roadnode_RM ;; to identify the disturbed road-metro links using the nodes of the road subsystem rec_roadnode ;; the road node identified to create the link and recover the road subsystem rec_roadnode2 ;; rec_roadnode_casc ;; the second road node identified to create the additional link and restore the road subsystem from the cascading event rec_metronode ;; the metro node identified to create the link and recover the metro subsystem rec_metronode2 ;; rec_metronode_casc ;; the second metro node identified to create the additional link and restore the metro subsystem from the cascading event ;; Global variables for performance-based resilience calculation recovery_tick_list ;; auxiliary list of ticks during the recovery in order to set the inital recovery_tick recovery_tick ;; ticks after recovery is completed initialperf ;; total capacity percentage before disturbance distperf ;; min total capacity performance during the disturbance finalperf ;; total capacity percentage after recovery totalloss ;; total loss in the performance of the system (observed performance - initial performance) totallosslist ;; list of differences (observed performance - initial performance) of the entire system resilience ;; resilience measure defined by Bruneau et al. 2003 based on resilience triangle z_resilience ;; resilience measure defined by Zobel 2011 R=1-(XT/2T*) based on resilience triangle h-r_resilience ;; resilience measure defined by Henry & Ramirez-Marquez 2012 ;; Global variables for entropy calculation roadlinks ;; maximum possible road nodes' connections sort-road ;; list of road nodes by turtle ID metrolinks ;; maximum possible metro nodes' connections sort-metro ;; list of metro nodes by turtle ID served_nodes ;; maximum possible agents powered by a single CI node at the beginning of the run served_roadnodes ;; maximum possible roadnodes powered by a single CI node at the beginning of the run served_metronodes ;; maximum possible metronodes powered by a single CI node at the beginning of the run sort-critical ;; list of CI nodes by turtle ID p4r ;; probability of road nodes' connections to be the same as their initial connections p4m ;; probability of metro nodes' connections to be the same as their initial connections p4c ;; probability of CI nodes' connections to be the same as their initial connections h4r ;; plogp for the road subsystem h4m ;; plogp for the metro subsystem h4c ;; plogp for the CI subsystem entropy ;; measure of the Shannon entropy of the subsystems' nodes' connections over the total connections (EntropyExplorerTwoColors) entropylist ;; list of entropy measures as recorded during the run p41r ;; probability of road nodes' connections not to be the same as their initial connections (S. Lloyd's tutorial) p41m ;; probability of metro nodes' connections not to be the same as their initial connections (S. Lloyd's tutorial) p41c ;; probability of CI nodes' connections not to be the same as their initial connections h41r ;; plogp for the road subsystem h41m ;; plogp for the metro subsystem h41c ;; plogp for the CI subsystem p4rm ;; joint probability for the connnections in road and metro subsystems p4rc ;; joint probability for the connnections in road and CI subsystems p4mc ;; joint probability for the connnections in metro and CI subsystems p4rmc ;; joint probability for the connnections in road, metro and CI subsystems h4rm ;; plogp for the joint probability h4rc ;; plogp for the joint probability h4mc ;; plogp for the joint probability h4rmc ;; plogp for the joint probability sr ;; marginal entropy of the road subsystem sm ;; marginal entropy of the metro subsystem sc ;; marginal entropy of the CI subsystem srm ;; entropy of joint propability (active only in case of dependent disturbances) src ;; entropy of joint propability (active only in case of dependent disturbances) smc ;; entropy of joint propability (active only in case of dependent disturbances) srmc ;; entropy of joint propability (active only in case of dependent disturbances) entropyr:m ;; mutual entropy of the entire system entropyr:c ;; mutual entropy of the road - CI system entropym:c ;; mutual entropy of the metro - CI system entropyr:m:c ;; mutual entropy of the road - metro - CI system entropyr:mlist ;; list of entropyr:m measures as recorded during the run entropyr:clist ;; list of entropyr:c measures as recorded during the run entropym:clist ;; list of entropyr:c measures as recorded during the run entropyr:m:clist ;; list of entropyr:m:c measures as recorded during the run entropy_dep ;; mutual entropy of the etnire system (entropy 4) considering dependent disturbances of joint probabilities entropy_dep_list ;; list of entropy_dep measures as recorded during the run original_h4r ;; marginal entropy of the road subsystem at the beginning of the run original_h4m ;; marginal entropy of the metro subsystem at the beginning of the run original_entropy_dep ;; entropy of the entire system at the beginning of the run initialent ;; total information entropy before disturbance totalent ;; total loss in the information entropy of the system (observed entropy - initial entropy) totalentlist ;; list of differences (observed utility - initial utility) of the entire system entropymetric ;; resilience measure defined by Bruneau et al. 2003 based on resilience triangle adapted for information entropy ;; Global variables for population needs' calculation popneeds ;; utility amount earned from the operation of each node of the two subsystems popneedsR ;; utility amount earned from the operation of each node of the road subsystem popneedsM ;; utility amount earned from the operation of each node of the metro subsystem popneedsRM ;; utility amount earned from the operation of each node of the road-metro subsystem popneedsCI ;; utility amount earned from the operation of each node of the CI subsystem popneedslist ;; list of popneeds values initialutil ;; total utility amount before disturbance totalutil ;; total loss in the utility of the system (observed utility - initial utility) totalutillist ;; list of differences (observed utility - initial utility) of the entire system utility ;; resilience measure defined by Bruneau et al. 2003 based on resilience triangle adapted for utility ] ;;;; VARIABLES REPRESENTED IN THE INTERFACE TAB ;; show_gradient: switch to control the appearance of the gradient map of population density attribute ;; dist_tick : ticks when the disturbance starts ;; recovery_lag : number of ticks between the original disturbance and the respectiive recovery ;; disturbance_type : chooser for the type of disturbance: Simple, Cascading, Complex ;; initial_response_type : chooser for the type of initial response based on the level of smartness: 0, 1, 2, 3 ;; recovery_type : chooser for the type of the recovery process, based on the level of smartnes: 0,1,2,3,4 ;; utility_prioitization : chooser for the utility prioritization type, based on the relevant process (level of smartnes): no, inspection, recovery, both ;; road_dist_links : user input for the number of the disturbed links in the road network ;;;;;;;;;;;;;;;;;;;;;;;;;;;; MAIN PROCEDURES ;;;;;;;;;;;;;;;;;;;;;;;;;;;; MAIN PROCEDURES ;;;;;;;;;;;;;;;;;;;;;;;;;;;; to setup clear-all import-pcolors "test map.png" setup-patches setup-road-net setup-metro-net setup-road-metro-dep setup-CI-net setup-road-CI-dep setup-metro-CI-dep setup-road-metro-CI-dep setup-metrics reset-ticks end to go if ticks > 100 [stop] countroadcapacity countmetrocapacity countCIcapacity counttotalcapacity ;;;;;;;;;;; DISTURBANCE ;;;;;;;;;;;;;; if disturbance_type = "simple" [simple_disturb] if disturbance_type = "cascading" [cascading_disturb] if disturbance_type = "complex" [complex_disturb] ;;;;;;;;;;; INITIAL REPSONSE ;;;;;;;;;;;;;; if initial_response_type = "response 0" [if utility_prioritization = "no" or utility_prioritization ="recovery" [response_0]] if initial_response_type = "response 0" [if utility_prioritization = "inspection" or utility_prioritization ="both" [response_0_prioritized]] if initial_response_type = "response 1" [if utility_prioritization = "no" or utility_prioritization ="recovery" [response_1]] if initial_response_type = "response 1" [if utility_prioritization = "inspection" or utility_prioritization ="both" [response_1_prioritized]] if initial_response_type = "response 2" [if utility_prioritization = "no" or utility_prioritization ="recovery" [response_2]] if initial_response_type = "response 2" [if utility_prioritization = "inspection" or utility_prioritization ="both" [response_2_prioritized]] if initial_response_type = "response 3" [if utility_prioritization = "no" or utility_prioritization ="recovery" [response_3]] if initial_response_type = "response 3" [if utility_prioritization = "inspection" or utility_prioritization ="both" [response_3_prioritized]] ;;;;;;;;;;; RECOVERY ;;;;;;;;;;;;;; if recovery_type = "recovery 0" [if utility_prioritization = "no" or utility_prioritization ="inspection" [recovery_0]] if recovery_type = "recovery 0" [if utility_prioritization = "recovery" or utility_prioritization ="both" [recovery_0_prioritized]] if recovery_type = "recovery 1" [if utility_prioritization = "no" or utility_prioritization ="inspection" [recovery_1]] if recovery_type = "recovery 1" [if utility_prioritization = "recovery" or utility_prioritization ="both" [recovery_1_prioritized]] if recovery_type = "recovery 2" [if utility_prioritization = "no" or utility_prioritization ="inspection" [recovery_2]] if recovery_type = "recovery 2" [if utility_prioritization = "recovery" or utility_prioritization ="both" [recovery_2_prioritized]] if recovery_type = "recovery 3" [recovery_3] if recovery_type = "recovery 4" [recovery_4] set-recovery-tick calcresilience calcentropy calcpopulationneeds tick end ;;;;;;;;; SETUP PROCEDURES ;;;;;;;;; SETUP PROCEDURES ;;;;;;;;; SETUP PROCEDURES ;;;;;;;;; SETUP PROCEDURES to setup-patches ;;; 1) blue region 1;;;; ask patches with [pcolor >= 111.7 and pcolor <= 132.7 or pcolor = 83.3 or pcolor = 2.9 or pcolor = 2.8] [set population 0.2653 + random-float 0.11 + random-float -0.11] ;;; 2) light blue region 4 ;;;; ask patches with [pcolor >= 56.0 and pcolor <= 78.2] [set population 0.9088 + random-float 0.11 + random-float -0.11] ;;; 3) brown region 4-5 only in NetLogo ask patches with [pcolor >= 34.3 and pcolor <= 36.6] [set population mean list (0.9088)(1.3378) + random-float 0.11 + random-float -0.11] ;;; 5) light green region 6 ;;;; ask patches with [pcolor >= 44.2 and pcolor <= 44.7 ] [set population 1.3378 + random-float 0.11 + random-float -0.11] ;;; 6) green- region 6-7 only in NetLogo ask patches with [pcolor >= 46.9 and pcolor <= 47.0] [set population mean list (1.3378)(1.5523) + random-float 0.11 + random-float -0.11] ;;; 7) region 7 ;;;; ask patches with [pcolor = 44.0 or pcolor = 44.6 or pcolor >= 45.5 and pcolor < 46.9 ] [set population 1.5523 + random-float 0.11 + random-float -0.11] ;;; 8) orange region 8 ;;;; ask patches with [pcolor >= 23.0 and pcolor <= 28.3] [set population 1.7668 + random-float 0.11 + random-float -0.11] ;;; 9) red region 9 ;;;; ask patches with [pcolor >= 13.5 and pcolor <= 18.5] [set population 1.9813 + random-float 0.11 + random-float -0.11] ;;; 10) dark red region 10 ;;;; ask patches with [pcolor >= 12.6 and pcolor <= 13.4] [set population 2.1958 + random-float 0.11 + random-float -0.11] ;;; grey region - sea ;;;; ask patches with [pcolor = 7.1] [set population 0] if show_gradient [ask patches with [ population > 0] [set pcolor scale-color green population 2.5 0 ]] end to setup-road-net ;;setting up of road network nodes create-roadnodes 60 ask roadnodes [set shape "circle" set color red set size 1 set is-dist? false set is-dist-RM? false] ;;;;; setting precise positions ;;;; ask roadnode 0 [setxy -35 38 create-rr-with roadnode 4] ask roadnode 1 [setxy -25 37 create-rr-with roadnode 3 ] ask roadnode 2 [setxy -37 33 create-rr-with roadnode 6] ask roadnode 3 [setxy -21 34 create-rr-with roadnode 4 create-rr-with roadnode 5] ask roadnode 4 [setxy -24 31 create-rr-with roadnode 6] ask roadnode 5 [setxy -12 28 create-rr-with roadnode 9 create-rr-with roadnode 7] ask roadnode 6 [setxy -12 24 create-rr-with roadnode 12] ask roadnode 7 [setxy -8 26 create-rr-with roadnode 6 create-rr-with roadnode 9 create-rr-with roadnode 10 create-rr-with roadnode 11 create-rr-with roadnode 14] ask roadnode 8 [setxy -8 34 create-rr-with roadnode 9] ask roadnode 9 [setxy -8 30 create-rr-with roadnode 10] ask roadnode 10 [setxy -1 26 create-rr-with roadnode 13] ask roadnode 11 [setxy -7 21 create-rr-with roadnode 12 create-rr-with roadnode 19] ask roadnode 12 [setxy -8 19 create-rr-with roadnode 22] ask roadnode 13 [setxy 4 22 create-rr-with roadnode 14 create-rr-with roadnode 16 create-rr-with roadnode 17] ask roadnode 14 [setxy 2 18 create-rr-with roadnode 18] ask roadnode 15 [setxy 16 28 create-rr-with roadnode 16] ask roadnode 16 [setxy 9 28] ask roadnode 17 [setxy 11 18 create-rr-with roadnode 25] ask roadnode 18 [setxy 6 15 create-rr-with roadnode 19] ask roadnode 19 [setxy 4 12 create-rr-with roadnode 21 create-rr-with roadnode 22] ask roadnode 20 [setxy 9 14 create-rr-with roadnode 17 create-rr-with roadnode 18 create-rr-with roadnode 21 create-rr-with roadnode 24] ask roadnode 21 [setxy 8 9 create-rr-with roadnode 22 create-rr-with roadnode 23 create-rr-with roadnode 29] ask roadnode 22 [setxy 2 10 create-rr-with roadnode 23] ask roadnode 23 [setxy 8 6 create-rr-with roadnode 38 create-rr-with roadnode 39] ask roadnode 24 [setxy 14 8 create-rr-with roadnode 23 create-rr-with roadnode 25 create-rr-with roadnode 28] ask roadnode 25 [setxy 18 9 create-rr-with roadnode 27] ask roadnode 26 [setxy 24 7 create-rr-with roadnode 27] ask roadnode 27 [setxy 21 4 create-rr-with roadnode 30] ask roadnode 28 [setxy 17 3 create-rr-with roadnode 30 create-rr-with roadnode 31] ask roadnode 29 [setxy 11 3 create-rr-with roadnode 31 create-rr-with roadnode 32] ask roadnode 30 [setxy 20 1 create-rr-with roadnode 31 create-rr-with roadnode 34] ask roadnode 31 [setxy 17 0 create-rr-with roadnode 32 create-rr-with roadnode 35] ask roadnode 32 [setxy 13 -3 create-rr-with roadnode 35 create-rr-with roadnode 36 create-rr-with roadnode 37] ask roadnode 33 [setxy 32 1] ask roadnode 34 [setxy 26 -4 create-rr-with roadnode 33 create-rr-with roadnode 35 create-rr-with roadnode 49] ask roadnode 35 [setxy 17 -5 create-rr-with roadnode 36 create-rr-with roadnode 44] ask roadnode 36 [setxy 17 -9 create-rr-with roadnode 37 create-rr-with roadnode 43] ask roadnode 37 [setxy 12 -10 create-rr-with roadnode 38 create-rr-with roadnode 42] ask roadnode 38 [setxy 9 -10 create-rr-with roadnode 39 create-rr-with roadnode 41] ask roadnode 39 [setxy 7 -10 create-rr-with roadnode 40] ask roadnode 40 [setxy 6 -15 create-rr-with roadnode 41 create-rr-with roadnode 45] ask roadnode 41 [setxy 8 -15 create-rr-with roadnode 42 create-rr-with roadnode 45] ask roadnode 42 [setxy 12 -14 create-rr-with roadnode 43 create-rr-with roadnode 46] ask roadnode 43 [setxy 17 -14 create-rr-with roadnode 44 create-rr-with roadnode 47] ask roadnode 44 [setxy 20 -13 create-rr-with roadnode 48] ask roadnode 45 [setxy 7 -24 create-rr-with roadnode 54 create-rr-with roadnode 55 create-rr-with roadnode 58] ask roadnode 46 [setxy 13 -22 create-rr-with roadnode 47 create-rr-with roadnode 58] ask roadnode 47 [setxy 18 -20 create-rr-with roadnode 48 create-rr-with roadnode 52] ask roadnode 48 [setxy 22 -19 create-rr-with roadnode 51] ask roadnode 49 [setxy 39 -10 create-rr-with roadnode 50] ask roadnode 50 [setxy 32 -21 create-rr-with roadnode 51] ask roadnode 51 [setxy 23 -21 create-rr-with roadnode 59] ask roadnode 52 [setxy 18 -26 create-rr-with roadnode 53 create-rr-with roadnode 56 create-rr-with roadnode 59] ask roadnode 53 [setxy 12 -32 create-rr-with roadnode 55 create-rr-with roadnode 58] ask roadnode 54 [setxy 6 -32] ask roadnode 55 [setxy 9 -35] ask roadnode 56 [setxy 20 -33 create-rr-with roadnode 57] ask roadnode 57 [setxy 24 -38] ask roadnode 58 [setxy 9 -24] ask roadnode 59 [setxy 24 -26] ;;;;; setting up the network ;;;; ask rrr [set color red set thickness 0.3] end to setup-metro-net ;;setting up of metro network nodes create-metronodes 13 ask metronodes [set shape "circle" set color blue set size 1 set is-dist? false set is-dist-RM? false] ;;;;; setting precise positions ;;;; ask metronode 60 [setxy -14 29] ask metronode 61 [setxy -9 26] ask metronode 62 [setxy -3 22] ask metronode 63 [setxy 1 19] ask metronode 64 [setxy 8 15] ask metronode 65 [setxy 14 9] ask metronode 66 [setxy 17 2] ask metronode 67 [setxy 14 -2] ask metronode 68 [setxy 12 -8] ask metronode 69 [setxy 12 -15] ask metronode 70 [setxy 13 -21] ask metronode 71 [setxy 16 -27] ask metronode 72 [setxy 23 -30] ;;;;; setting up the network ;;;; foreach sort metronodes [met -> ask met [if who != 72 [create-mm-with metronode ([who] of met + 1)]] ] ask mmm [set color blue set thickness 0.3] end to setup-road-metro-dep ;;setting up of road-metro network dependency links ask metronode 60 [create-rm-with roadnode 5] ask metronode 61 [create-rm-with roadnode 7] ask metronode 63 [create-rm-with roadnode 14] ask metronode 64 [create-rm-with roadnode 20] ask metronode 65 [create-rm-with roadnode 24] ask metronode 66 [create-rm-with roadnode 28] ask metronode 67 [create-rm-with roadnode 32] ask metronode 68 [create-rm-with roadnode 37] ask metronode 69 [create-rm-with roadnode 42] ask metronode 70 [create-rm-with roadnode 46] ask metronode 71 [create-rm-with roadnode 52] ask rmrm [set color violet set thickness 0.3] end to setup-CI-net ;;setting up of power network nodes create-criticalnodes 6 ask criticalnodes [set shape "target" set size 2 set is-on? true] ;;;;; setting precise positions ;;;; ask criticalnode 73 [setxy 13 13 set color white set ci_range (distance criticalnode 74)] ask criticalnode 74 [setxy 16 -2 set color white set ci_range (distance criticalnode 75)] ask criticalnode 75 [setxy 9 21 set color 27 set ci_range (distance criticalnode 77)] ask criticalnode 76 [setxy -16 32 set color 27 set ci_range (distance criticalnode 77)] ask criticalnode 77 [setxy 11 -24 set color 27 set ci_range (distance criticalnode 75) / 2] ask criticalnode 78 [setxy -20 22 set color 27 set ci_range (distance criticalnode 76)] end to setup-road-CI-dep ask roadnodes [let ci-ref-node min-one-of criticalnodes with [is-on? = true] [distance myself] if distance ci-ref-node <= [ci_range] of ci-ref-node [ask roadnodes [set is-served? true]]] end to setup-metro-CI-dep ask metronodes [let ci-ref-node min-one-of criticalnodes with [is-on? = true] [distance myself] if distance ci-ref-node <= [ci_range] of ci-ref-node [ask metronodes [set is-served? true]]] end to setup-road-metro-CI-dep ask metronodes with [any? my-rmrm = true] [let ci-ref-node min-one-of criticalnodes with [is-on? = true] [distance myself] if distance ci-ref-node <= [ci_range] of ci-ref-node [ask metronodes with [any? my-rmrm = true] [set is-served-RM? true]]] end to setup-metrics set recovery_tick_list [] set roadcapacitylist [] set metrocapacitylist [] set CIcapacitylist [] set totalcapacitylist [] set totallosslist [] set entropylist [] set entropyr:mlist [] set entropyr:clist [] set entropym:clist [] set entropyr:m:clist [] set entropy_dep_list [] set totalentlist [] set popneedslist [] set totalutillist [] end to set-recovery-tick if ticks > dist_tick + recovery_lag [if not any? turtles with [color = black] and last totalcapacitylist / item (length totalcapacitylist - 2) totalcapacitylist > 1 [set recovery_tick_list lput ticks recovery_tick_list set recovery_tick first recovery_tick_list ]] end ;;;;;;;;; PROCEDURES ;;;;;;;;; PROCEDURES;;;;;;;;; PROCEDURES ;;;;;;;;; PROCEDURES ;;;;;;;;; to countroadcapacity ask roadnodes with [count rr-neighbors > 0] [if ticks < 2 [set road_factor (mean [link-length] of my-out-rrr) / 10] set road_utility_factor mean [population] of neighbors set roadcapacity (count my-rrr + count my-recroad) * road_factor * road_utility_factor set roadcapacitylist sum [roadcapacity] of roadnodes] end to countmetrocapacity ask metronodes with [count mm-neighbors > 0] [if ticks < 2 [set metro_factor (mean [link-length] of my-out-mmm) / 10] set metro_utility_factor mean [population] of neighbors in-radius 3 set metrocapacity (count my-out-mmm + count my-out-recmetro) * metro_factor * metro_utility_factor set metrocapacitylist sum [metrocapacity] of metronodes] end to countCIcapacity ask criticalnodes with [is-on? = true] [set ci_factor (count turtles with [is-dist? = false] in-radius ci_range ) / 10 set ci_utility_factor mean [population] of neighbors in-radius ci_range set cicapacity ((count patches with [population > 0] in-radius ci_range)/ 100) * ci_factor * ci_utility_factor set CIcapacitylist sum [cicapacity] of criticalnodes] ask criticalnodes with [is-on? = true] [set ci_roadfactor (count roadnodes with [is-dist? = false] in-radius ci_range) set ci_metrofactor (count metronodes with [is-dist? = false] in-radius ci_range)] end to counttotalcapacity if ticks < 2 [set original_rm_road count roadnodes with [any? my-rmrm] set original_rm_roadnodes roadnodes with [any? my-rmrm]] set rm_roadnodes roadnodes with [any? my-rmrm or any? my-recrmrm] set roadrm sum [roadcapacity] of rm_roadnodes / original_rm_road if ticks < 2 [set original_rm_metro count metronodes with [any? my-rmrm] set original_rm_metronodes metronodes with [any? my-rmrm]] set rm_metronodes metronodes with [any? my-rmrm or any? my-recrmrm] set metrorm sum [metrocapacity] of rm_metronodes / original_rm_metro set rmcapacity (roadrm + metrorm ) set totalcapacity ( roadcapacitylist + metrocapacitylist + rmcapacity + CIcapacitylist ) if totalcapacity > 0 [set totalcapacitylist lput totalcapacity totalcapacitylist set totalcapacitylevel ( totalcapacity / max totalcapacitylist * 100)] end ;;;;;; DISTURBANCE PROCEDURES ;;;;;; DISTURBANCE PROCEDURES ;;;;;; to simple_disturb ;user-input condition of disturbance if road = true [if ticks = dist_tick [let disturbed_R n-of road_dist_links roadnodes ask disturbed_R [ask one-of my-rrr with [both-ends != other disturbed_R] [die]]]] if metro = true [if ticks = dist_tick [let disturbed_M n-of metro_dist_links metronodes ask disturbed_M [ask one-of my-mmm with [both-ends != other disturbed_M] [die]]]] end to cascading_disturb ;user-input condition of disturbance if road = true [if ticks = dist_tick [ask n-of road_dist_links roadnodes with [count my-rrr > 2] [ask n-of 2 my-rrr [die]]]] if metro = true [if ticks = dist_tick [ask n-of metro_dist_links metronodes with [count my-mmm >= 2] [ask my-mmm [die]]]] end to complex_disturb ;user-input condition of disturbance if road = true and metro = true [if ticks = dist_tick [ask n-of road_dist_links rmrm [die]]] end ;;;;;;; INITIAL RESPONSE PROCEDURES ;;;;;;; to response_0 ; sequential repetitive checks and then recovery ask roadnodes [foreach sort roadnodes [r -> ask r [if ticks < 2 [set original_neighborsR count rr-neighbors] let i position r sort roadnodes if ticks = dist_tick + recovery_lag + i and original_neighborsR > count rr-neighbors [set is-dist? true] if ticks > count roadnodes [ask roadnodes with [is-dist? = true] [set color black]]]]] ask original_rm_roadnodes [foreach sort original_rm_roadnodes [r+ -> ask r+ [let ri position r+ sort roadnodes if ticks = dist_tick + recovery_lag + ri and count original_rm_roadnodes > count rm-neighbors [ask original_rm_roadnodes with [not any? rm-neighbors] [set is-dist-RM? true set color black]] ] ]] ask metronodes [foreach sort metronodes [m -> ask m [if ticks < 2 [set original_neighborsM count mm-neighbors] let n position m sort turtles if ticks = dist_tick + recovery_lag + n and original_neighborsM >= count mm-neighbors + 1 [set is-dist? true] if ticks > count roadnodes + count metronodes [ask metronodes with [is-dist? = true] [set color black]] ]]] ask original_rm_metronodes [foreach sort original_rm_metronodes [m+ -> ask m+ [let mi position m+ sort metronodes if ticks = dist_tick + recovery_lag + mi and count original_rm_metronodes > count rm-neighbors [ask original_rm_metronodes with [not any? rm-neighbors] [set is-dist-RM? true set color black]] ] ]] end to response_1 ; sequential repetitive checks and recovery combined ask roadnodes [foreach sort roadnodes [r -> ask r [if ticks < 2 [set original_neighborsR count rr-neighbors] let i position r sort roadnodes if ticks = dist_tick + recovery_lag + i and original_neighborsR > count rr-neighbors [set is-dist? true set color black] if ticks = dist_tick + recovery_lag + i and count original_rm_roadnodes > count rm_roadnodes [ask original_rm_roadnodes with [not any? rm-neighbors] [set is-dist-RM? true set color black]]]]] ask metronodes [foreach sort metronodes [m -> ask m [if ticks < 2 [set original_neighborsM count mm-neighbors] let n position m sort turtles if ticks = dist_tick + recovery_lag + n and original_neighborsM >= count mm-neighbors + 1 [set is-dist? true set color black] if ticks = dist_tick + recovery_lag + n and count original_rm_metronodes > count rm_metronodes [ask original_rm_metronodes with [not any? rm-neighbors] [set is-dist-RM? true set color black]]]]] end to response_2 ; parallel repetitive checks and recovery combined ask roadnodes [foreach sort roadnodes [r -> ask r [if ticks < 2 [set original_neighborsR count rr-neighbors] let i position r sort roadnodes if ticks = dist_tick + i and original_neighborsR > count rr-neighbors [set is-dist? true set color black] if ticks = dist_tick + recovery_lag + i and count original_rm_roadnodes > count rm_roadnodes [ask original_rm_roadnodes with [not any? rm-neighbors] [set is-dist-RM? true set color black]]]]] ask metronodes [foreach sort metronodes [m -> ask m [if ticks < 2 [set original_neighborsM count mm-neighbors] let n position m sort metronodes if ticks = dist_tick + n and original_neighborsM > count mm-neighbors [set is-dist? true set color black] if ticks = dist_tick + recovery_lag + n and count original_rm_metronodes > count rm_metronodes [ask original_rm_metronodes with [not any? rm-neighbors] [set is-dist-RM? true set color black]]]]] end to response_3 ; constant monitoring of agents and immediate pesponse - the smartest if ticks < 1 [ask roadnodes [set original_neighborsR count rr-neighbors]] if ticks < 1 [ask metronodes [set original_neighborsM count mm-neighbors]] ;; Check for road links failure ;;; if initial_response_type = "response 3" [ask roadnodes [if ticks = dist_tick + 1 and original_neighborsR > count rr-neighbors [set is-dist? true set color black]] if ticks = dist_tick + 1 and count original_rm_roadnodes > count rm_roadnodes [ask original_rm_roadnodes with [not any? rm-neighbors] [set is-dist-RM? true set color black]] ;;Check for metro links failure ;;; ask metronodes [if ticks = dist_tick + 1 and original_neighborsM > count mm-neighbors [set is-dist? true set color black]] if ticks = dist_tick + 1 and count original_rm_metronodes > count rm_metronodes [ask original_rm_metronodes with [not any? rm-neighbors] [set is-dist-RM? true set color black]] ] end ;;;;;;; RECOVERY PROCEDURES ;;;;;;; RECOVERY PROCEDURES ;;;;;;; to recovery_0 ; restore link at the node with lost links at the end of all the inspections ;ROAD simple and cascading if ticks > dist_tick + recovery_lag and count roadnodes with [color = black] > 1 and disturbance_type = "simple" [ask roadnodes with [is-dist? = true] [create-recr-with min-one-of other roadnodes with [is-dist? = true] [distance myself] ]] ;one-of other roadnodes and min-one-of other roadnodes [distance myself] ]] if ticks > dist_tick + recovery_lag and count roadnodes with [color = black] > 2 and disturbance_type = "cascading" [ask roadnodes with [is-dist? = true] [set ch_roadnode one-of roadnodes with [original_neighborsR - count rr-neighbors >= 2] ask ch_roadnode [set rec_roadnode min-n-of 2 other roadnodes with [is-dist? = true] [distance myself] ;original_neighborsR - count rr-neighbors < 2 and create-recroad-with rec_roadnode]]] ask recroad [set color yellow] ;METRO simple and cascading if ticks > dist_tick + recovery_lag and count metronodes with [color = black] > 1 [ask metronodes with [is-dist? = true] [create-recm-with min-one-of other metronodes with [is-dist? = true] [distance myself]]] if ticks > dist_tick + recovery_lag and count metronodes with [color = black] > 2 and disturbance_type = "cascading" [ask metronodes with [is-dist? = true] [set ch_metronode one-of metronodes with [original_neighborsM - count mm-neighbors >= 2] ask ch_metronode [set rec_metronode min-n-of 2 other metronodes with [is-dist? = true] [distance ch_metronode] create-recmetro-with rec_metronode]]] ask recmetro [set color yellow] ;ROAD - METRO if ticks > dist_tick + recovery_lag + 1 and count roadnodes with [is-dist-RM? = true] > 1 and count metronodes with [is-dist-RM? = true] > 1 and count rm_roadnodes < original_rm_road [ask one-of original_rm_roadnodes with [is-dist-RM? = true] [create-recrm-with min-one-of original_rm_metronodes in-radius 5 with [is-dist-RM? = true] [distance myself] ] ask recrmrm [set color yellow]] ;;;color identification for recovery;;;; ask roadnodes with [is-dist? = true] [if count my-rrr + count my-recroad >= original_neighborsR [set is-dist? false set color red]] ask metronodes with [is-dist? = true] [if count my-mmm + count my-recmetro >= original_neighborsM [set is-dist? false set color blue]] ask original_rm_roadnodes with [is-dist-RM? = true] [if count rm_roadnodes = original_rm_road [set is-dist-RM? false set color red]] ask original_rm_metronodes with [is-dist-RM? = true] [if count rm_metronodes = original_rm_metro [set is-dist-RM? false set color blue]] end to recovery_1 ; restore links at the node with lost links based on the trigger of entropy increase if ticks = 2 ;dist_tick [set original_h4r (-1 * sum h4r) set original_h4m (-1 * sum h4m)] ;ROAD simple and cascading if ticks > dist_tick + recovery_lag and (-1 * sum h4r) > original_h4r and count roadnodes with [color = black] >= 2 [ask roadnodes with [is-dist? = true] [create-recr-with min-one-of other roadnodes with [is-dist? = true] [distance myself]]] if ticks > dist_tick + recovery_lag and (-1 * sum h4r) != original_h4r and count roadnodes with [color = black] > 2 and disturbance_type = "cascading" ;count roadnodes with [is-dist? = true] > 2 [ask roadnodes with [is-dist? = true] [set ch_roadnode one-of roadnodes with [original_neighborsR - count rr-neighbors >= 2] ask ch_roadnode [set rec_roadnode min-n-of 2 other roadnodes with [original_neighborsR - count rr-neighbors < 2] [distance myself] create-recroad-with rec_roadnode]]] if ticks > dist_tick + recovery_lag and count roadnodes with [color = black] = 1 and disturbance_type = "cascading" and any? recroad [ask roadnodes with [is-dist? = true] [create-recr-with min-one-of other roadnodes with [any? recr-neighbors] [distance myself]]] ask recroad [set color yellow] ;METRO simple and cascading if ticks > dist_tick + recovery_lag and (-1 * sum h4m) > original_h4m and count metronodes with [color = black] >= 2 [ask metronodes with [is-dist? = true] [create-recm-with min-one-of other metronodes with [is-dist? = true] [distance myself]]] if ticks > dist_tick + recovery_lag and (-1 * sum h4m) > original_h4m and count metronodes with [color = black] > 2 and disturbance_type = "cascading" [ask metronodes [set ch_metronode metronodes with [original_neighborsM - count mm-neighbors >= 2] ask ch_metronode [set rec_metronode min-n-of 2 other metronodes with [original_neighborsM - count mm-neighbors - count recm-neighbors < 2] [distance myself] create-recmetro-with rec_metronode in-radius 10]]] ask recmetro [set color yellow] ;ROAD - METRO if ticks > dist_tick + recovery_lag and count rm_roadnodes < original_rm_road and any? roadnodes with [is-dist-RM? = true] and any? metronodes with [is-dist-RM? = true] [ask original_rm_roadnodes with [count my-rmrm = 0] [create-recrm-with min-one-of original_rm_metronodes with [is-dist-RM? = true] [distance myself] set is-dist-RM? false ask recrmrm [set color yellow]]] ;;;color identification for recovery;;;; ask roadnodes with [is-dist? = true] [if count my-rrr + count my-recroad >= original_neighborsR [set is-dist? false set color red]] ask metronodes with [is-dist? = true] [if count my-mmm + count my-recmetro >= original_neighborsM [set is-dist? false set color blue]] ask original_rm_roadnodes with [is-dist-RM? = true] [if count rm_roadnodes = original_rm_road [set is-dist-RM? false set color red]] ask original_rm_metronodes with [is-dist-RM? = true] [if count rm_metronodes = original_rm_metro [set is-dist-RM? false set color blue]] end to recovery_2 ; restore links based on the list of missing links per node - memory of agents ;;;;; check missing links ;;;;;; ;ROAD simple and cascading ask roadnodes [set missing_linksR (original_neighborsR - count my-rrr)] ifelse ticks > dist_tick + recovery_lag and disturbance_type = "cascading" and count roadnodes with [color = black] > 2 [ask roadnodes [set ch_roadnode roadnodes with [missing_linksR = max [missing_linksR] of roadnodes] set rec_roadnode roadnodes with [missing_linksR = (max [missing_linksR] of roadnodes - 1)] ]] [ask roadnodes [set ch_roadnode roadnodes with [missing_linksR = max [missing_linksR] of roadnodes] ]] ;METRO simple and cascading ask metronodes [set missing_linksM (original_neighborsM - count my-mmm)] ifelse ticks > dist_tick + recovery_lag and disturbance_type = "cascading" and count metronodes with [color = black] > 2 [ask metronodes [set ch_metronode metronodes with [missing_linksM = max [missing_linksM] of metronodes] set rec_metronode metronodes with [missing_linksM = max [missing_linksM] of metronodes - 1]]] [ask metronodes [set ch_metronode metronodes with [missing_linksM = max [missing_linksM] of metronodes] ]] ;ROAD - METRO if recovery_type = "recovery 2" [ask original_rm_metronodes [set missing_linksRM (count original_rm_metronodes - count my-rmrm)] if any? metronodes with [is-dist-RM? = true ] [ask metronodes [set ch_metronode_RM metronodes with [missing_linksRM = max [missing_linksRM] of metronodes]]] ] ;;;;;;; recover ;;;;;;;;;;;;; if ticks = 2 [set original_h4r (-1 * sum h4r) set original_h4m(-1 * sum h4m) set original_entropy_dep entropy_dep] if ticks > dist_tick + recovery_lag and (-1 * sum h4r) != original_h4r [ask ch_roadnode [if disturbance_type = "simple" and count roadnodes with [color = black] >= 2 and count ch_roadnode > 1 [create-recr-with min-one-of other ch_roadnode [distance myself]] if disturbance_type = "cascading" and count roadnodes with [color = black] > 2 [create-recroad-with min-n-of 2 rec_roadnode [distance myself] ] if disturbance_type = "cascading" and count roadnodes with [color = black] = 2 [create-recr-with min-one-of other roadnodes with [missing_linksR > 0] [distance myself]] if disturbance_type = "cascading" and any? roadnodes with [color = black] and count roadnodes with [color = black] < 2 and any? recroad [create-recr-with min-one-of other roadnodes with [any? recr-neighbors] [distance myself]] ]] ;;;redundant recroad links' removal ;;; if ticks > dist_tick + recovery_lag and any? roadnodes with [count rr-neighbors + count recr-neighbors > original_neighborsR] [ask roadnodes with [count rr-neighbors + count recr-neighbors > original_neighborsR] [let redundant recr-with max-one-of recr-neighbors [distance myself] ask redundant [die]]] ask recroad [set color yellow] if ticks > dist_tick + recovery_lag and (-1 * sum h4m) > original_h4m [ask ch_metronode [if disturbance_type = "simple" and count metronodes with [color = black] >= 2 and count ch_metronode > 1 [create-recm-with min-one-of other ch_metronode [distance myself] create-recm-with min-one-of other metronodes with [missing_linksM > 0] [distance myself]] if disturbance_type = "cascading" and count metronodes with [color = black] > 2 [create-recmetro-with min-n-of 2 rec_metronode [distance myself] ]]] ;;;redundant recmetro links' removal ;;; if ticks > dist_tick + recovery_lag and any? metronodes with [count mm-neighbors + count recm-neighbors > original_neighborsM] [ask metronodes with [count mm-neighbors + count recm-neighbors > original_neighborsM] [let redundant recm-with max-one-of recm-neighbors [distance myself] ask redundant [die]]] ask recmetro [set color yellow] if ticks > dist_tick + recovery_lag + 1 and entropy_dep > original_entropy_dep and any? roadnodes with [is-dist-RM? = true] and any? metronodes with [is-dist-RM? = true] [ask ch_metronode_RM [create-recrm-with min-one-of original_rm_roadnodes with [is-dist-RM? = true] [distance myself] ] ask recrmrm [set color yellow]] ;;;color identification for recovery;;;; ask roadnodes with [is-dist? = true] [if count my-rrr + count my-recroad >= original_neighborsR [set is-dist? false set color red]] ask metronodes with [is-dist? = true] [if count my-mmm + count my-recmetro >= original_neighborsM [set is-dist? false set color blue]] ask original_rm_roadnodes with [is-dist-RM? = true] [if count rm_roadnodes >= original_rm_road [set is-dist-RM? false set color red]] ask original_rm_metronodes with [is-dist-RM? = true] [if count rm_metronodes >= original_rm_metro [set is-dist-RM? false set color blue]] end to check_rec_max_entropy ; check of the potential entropy of system with the use of temporary (dummy) links ;;;; check entropy of all the possible recoveries/linkages with each one of the other ROAD nodes -> identify recovery that yields max entropy in the ROAD SUBSYSTEM if ticks > dist_tick + recovery_lag and any? roadnodes with [is-dist? = true] and disturbance_type != "complex" [ask roadnodes [ifelse count my-rrr > 0 [set ch_R_entropy (-1 * (count my-rrr / original_neighborsR) * log (count my-rrr / original_neighborsR) 2)] [set ch_R_entropy -1] set ch_roadnode max-n-of road_dist_links roadnodes [ch_R_entropy]] ask roadnodes [set ch_entropy_list_R [] foreach sort roadnodes [r -> ifelse r != ch_roadnode [ask r [create-chr-with min-one-of other ch_roadnode [distance myself] let ch_p4r (count my-rrr + count my-chroad) / original_neighborsR let ch_h4r ch_p4r * log ch_p4r 2 set R_entropy -1 * ch_h4r set this_entropy_R -1 * ch_h4r ]] [set this_entropy_R -1] ;; I can set this_entropy_ of ch_node to 0 for the min Ent approach OR to -1 for the max Ent approach set ch_entropy_list_R lput this_entropy_R ch_entropy_list_R ask chroad [die]]] ask ch_roadnode [set rec_roadnode min-one-of other roadnodes with [R_entropy = max ch_entropy_list_R] [distance myself]]] ;;;; check entropy of all the possible recoveries/linkages with each one of the other METRO nodes -> identify recovery that yields max entropy in the METRO SUBSYSTEM if ticks > dist_tick + recovery_lag and any? metronodes with [is-dist? = true] and disturbance_type != "complex" [ask metronodes [ifelse count my-mmm > 0 [set ch_M_entropy (-1 * (count my-mmm / original_neighborsM) * log (count my-mmm / original_neighborsM) 2)] [set ch_M_entropy 1] set ch_metronode max-n-of metro_dist_links metronodes [ch_M_entropy]] ask metronodes [set ch_entropy_list_M [] foreach sort metronodes [m -> ifelse m != ch_metronode [ask m [create-chm-with min-one-of other ch_metronode [distance myself] let ch_p4m (count my-mmm + count my-chmetro) / original_neighborsM let ch_h4m (ch_p4m * log ch_p4m 2) set M_entropy -1 * ch_h4m set this_entropy_M -1 * ch_h4m ]] [set this_entropy_M -1] set ch_entropy_list_M lput this_entropy_M ch_entropy_list_M ask chmetro [die]]] ask ch_metronode [set rec_metronode min-one-of other metronodes with [M_entropy = max ch_entropy_list_M] [distance myself] ]] ;;; check entropy of all the possible recoveries/linkages with each one of the ROAD-METRO trans-system links if ticks > dist_tick + recovery_lag and count roadnodes with [is-dist-RM? = true and color = black] > 1 and count metronodes with [is-dist-RM? = true and color = black] > 1 [ask turtles with [any? rm-neighbors] [ask original_rm_metronodes with [is-dist-RM? = false] [set ch_RM_entropy (-1 * (count my-rmrm / original_rm_metro) * log (count my-rmrm / original_rm_metro) 2)] ask original_rm_metronodes with [is-dist-RM? = true] [set ch_RM_entropy 1] ask original_rm_roadnodes with [is-dist-RM? = false] [set ch_RM_entropy (-1 * (count my-rmrm / original_rm_road) * log (count my-rmrm / original_rm_road) 2)] ask original_rm_roadnodes with [is-dist-RM? = true] [set ch_RM_entropy 1] set ch_metronode_RM metronodes with [ch_RM_entropy = max [ch_RM_entropy] of original_rm_metronodes] set ch_roadnode_RM roadnodes with [ch_RM_entropy = max [ch_RM_entropy] of original_rm_roadnodes] ]] end to recovery_3 ; links based on the check of max entropy if ticks = 2 [set original_h4r (-1 * sum h4r) set original_h4m (-1 * sum h4m) set original_entropy_dep entropy_dep] if ticks < 1 [ask roadnodes [set priopop mean [population] of neighbors4] ask metronodes [set priopop mean [population] of neighbors in-radius 3]] if any? turtles with [is-dist? = true] or any? turtles with [is-dist-RM? = true] and recovery_type = "recovery 3" [ifelse utility_prioritization != "recovery" and utility_prioritization !="both" [check_rec_max_entropy] [check_rec_max_entropy_prioritized]] ;;;ROAD if ticks > dist_tick + recovery_lag and (-1 * sum h4r) != original_h4r and disturbance_type != "complex" [if count roadnodes with [color = black] > 2 and any? ch_roadnode [ifelse utility_prioritization != "recovery" and utility_prioritization !="both" [ask ch_roadnode [;create-recr-with min-one-of other roadnodes with [color = black] [distance myself] ;rec_roadnode ;[distance myself] ;no need because entropy method is topologically agnostic create-recr-with min-one-of other roadnodes with [is-dist? = true and who != [who] of myself] [distance myself]]] [foreach sort-on [priopop] ch_roadnode [ch_3R -> ask ch_3R [create-recr-with min-one-of other roadnodes with [is-dist? = true and who != [who] of myself] [distance myself]]]]]] if count roadnodes with [color = black] = 2 [ask one-of roadnodes with [color = black] [create-recr-with min-one-of other roadnodes with [color = black] [distance myself] ]] if any? roadnodes with [count rr-neighbors + count recr-neighbors < original_neighborsR] [ask one-of roadnodes with [count rr-neighbors + count recr-neighbors < original_neighborsR] [create-recr-with min-one-of other roadnodes with [count rr-neighbors < original_neighborsR] [distance myself] ]] if count roadnodes with [color = black] = 1 and any? recroad and disturbance_type = "simple" [ask one-of roadnodes with [color = black] [create-recr-with min-one-of other roadnodes with [any? recr-neighbors] [distance myself] ]] ask roadnodes with [is-dist? = true] [if count my-rrr + count my-recroad >= original_neighborsR [set is-dist? false set color red]] ;;;redundant recroad links' removal ;;; if ticks > dist_tick + recovery_lag and any? roadnodes with [count rr-neighbors + count recr-neighbors > original_neighborsR] [ask roadnodes with [count rr-neighbors + count recr-neighbors > original_neighborsR] [let redundant recr-with max-one-of recr-neighbors [distance myself] ask redundant [die]]] ask recroad [set color yellow] ;;; METRO if ticks > dist_tick + recovery_lag and (-1 * sum h4m) > original_h4m and disturbance_type != "complex" [if count metronodes with [color = black] > 2 and any? ch_metronode [ifelse utility_prioritization != "recovery" and utility_prioritization !="both" [ask ch_metronode [create-recm-with min-one-of other metronodes with [is-dist? = true and who != [who] of myself] [distance myself]]] [foreach sort-on [priopop] ch_metronode [ch_3M -> ask ch_3M [create-recm-with min-one-of other metronodes with [is-dist? = true and who != [who] of myself] [distance myself]]]]]] if count metronodes with [color = black] = 2 [ask one-of metronodes with [is-dist? = true] [create-recm-with min-one-of other metronodes with [is-dist? = true] [distance myself]]] if any? metronodes with [count mm-neighbors + count recm-neighbors < original_neighborsM] [ask one-of metronodes with [count mm-neighbors + count recm-neighbors < original_neighborsM] [create-recm-with min-one-of other metronodes with [count mm-neighbors < original_neighborsM] [distance myself] ]] ask metronodes with [is-dist? = true] [if count my-mmm + count my-recmetro >= original_neighborsM [set is-dist? false set color blue]] ;;;redundant recmero links' removal ;;; if ticks > dist_tick + recovery_lag and any? metronodes with [count mm-neighbors + count recm-neighbors > original_neighborsM] [ask metronodes with [count mm-neighbors + count recm-neighbors > original_neighborsM] [let redundant recm-with max-one-of recm-neighbors [distance myself] ask redundant [die]]] ask recmetro [set color yellow] ;;;ROAD - METRO if ticks > dist_tick + recovery_lag and any? roadnodes with [is-dist-RM? = true and color = black] and any? metronodes with [is-dist-RM? = true and color = black] [ifelse recovery_type != "recovery" and recovery_type != "both" [ask ch_metronode_RM [create-recrm-with min-one-of ch_roadnode_RM [distance myself] ]] [foreach sort-on [priopop] ch_metronode_RM [rec_3RM -> ask rec_3RM [create-recrm-with min-one-of ch_roadnode_RM [distance myself] ]]]] ask recrmrm [set color yellow] ask original_rm_roadnodes with [is-dist-RM? = true] [if count rm_roadnodes >= original_rm_road [set is-dist-RM? false set color red]] ask original_rm_metronodes with [is-dist-RM? = true] [if count rm_metronodes >= original_rm_metro [set is-dist-RM? false set color blue]] end to check_rec_min_entropy ; check of the potential entropy of system with the use of temporary (dummy) links ;;;; check entropy of all the possible recoveries/linkages with each one of the other ROAD nodes -> identify recovery that yields max entropy in the ROAD SUBSYSTEM if ticks > dist_tick [ask roadnodes [ifelse count my-rrr > 0 [set ch_R_entropy (-1 * (count my-rrr / original_neighborsR) * log (count my-rrr / original_neighborsR) 2)] [set ch_R_entropy 0] set ch_roadnode max-n-of road_dist_links roadnodes [ch_R_entropy]]] ;;;; check entropy of all the possible recoveries/linkages with each one of the other METRO nodes -> identify recovery that yields max entropy in the METRO SUBSYSTEM if ticks > dist_tick [ask metronodes [ifelse count my-mmm > 0 [set ch_M_entropy (-1 * (count my-mmm / original_neighborsM) * log (count my-mmm / original_neighborsM) 2)] [set ch_M_entropy 0] set ch_metronode max-n-of metro_dist_links metronodes [ch_M_entropy]]] ;;; check entropy of all the possible recoveries/linkages with each one of the ROAD-METRO trans-system links if ticks > dist_tick + recovery_lag and count roadnodes with [is-dist-RM? = true and color = black] > 1 and count metronodes with [is-dist-RM? = true and color = black] > 1 [ask turtles with [any? rm-neighbors] [ask original_rm_metronodes with [is-dist-RM? = false] [set ch_RM_entropy (-1 * (count my-rmrm + count my-recrmrm / original_rm_metro) * log (count my-rmrm + count my-recrmrm / original_rm_metro) 2)] ask original_rm_metronodes with [is-dist-RM? = true] [set ch_RM_entropy 1] ask original_rm_roadnodes with [is-dist-RM? = false] [set ch_RM_entropy (-1 * (count my-rmrm + count my-recrmrm / original_rm_metro) * log (count my-rmrm + count my-recrmrm / original_rm_metro) 2)] ask original_rm_roadnodes with [is-dist-RM? = true] [set ch_RM_entropy 1] set ch_metronode_RM metronodes with [ch_RM_entropy = max [ch_RM_entropy] of original_rm_metronodes ] set ch_roadnode_RM roadnodes with [ch_RM_entropy = min [ch_RM_entropy] of original_rm_roadnodes ] ]] end to recovery_4 ; links based on the check of min entropy if ticks = 2 [set original_h4r (-1 * sum h4r) set original_h4m (-1 * sum h4m) set original_entropy_dep entropy_dep] if ticks < 1 [ask roadnodes [set priopop mean [population] of neighbors4] ask metronodes [set priopop mean [population] of neighbors in-radius 3]] if recovery_type = "recovery 4" and any? turtles with [is-dist? = true] or any? turtles with [is-dist-RM? = true] [ifelse utility_prioritization != "recovery" and utility_prioritization !="both" [check_rec_min_entropy] [check_rec_min_entropy_prioritized]] ;;;ROAD if ticks > dist_tick + recovery_lag and (-1 * sum h4r) != original_h4r and disturbance_type != "complex" [if count roadnodes with [color = black] > 2 and any? ch_roadnode [ifelse utility_prioritization != "recovery" and utility_prioritization !="both" [ask ch_roadnode [create-recr-with min-one-of other roadnodes [R_entropy]]] ;with [is-dist? = true and who != [who] of myself] [foreach sort-on [priopop] ch_roadnode [ch_3R -> ask ch_3R [create-recr-with min-one-of other roadnodes with [is-dist? = true and who != [who] of myself] [R_entropy]]]]] if count roadnodes with [color = black] = 2 [ask one-of roadnodes with [color = black] [create-recr-with min-one-of other roadnodes with [color = black] [R_entropy]]] if count roadnodes with [color = black] = 1 and any? recroad and disturbance_type = "simple" [ask one-of roadnodes with [color = black] [create-recr-with min-one-of other roadnodes with [any? recr-neighbors] [R_entropy]]] ] ask roadnodes with [is-dist? = true] [if count my-rrr + count my-recroad >= original_neighborsR [set is-dist? false set color red]] ask recroad [set color yellow] ;;; METRO if ticks > dist_tick + recovery_lag and (-1 * sum h4m) > original_h4m and disturbance_type != "complex" [if count metronodes with [is-dist? = true] > 2 and any? ch_metronode [ifelse utility_prioritization != "recovery" and utility_prioritization !="both" [ask ch_metronode [create-recm-with min-one-of other metronodes [M_entropy]]] [foreach sort-on [priopop] ch_metronode [ch_3M -> ask ch_3M [create-recm-with min-one-of other metronodes with [is-dist? = true and who != [who] of myself] [M_entropy]]]]] if count metronodes with [color = black] = 2 [ask one-of metronodes with [color = black] [create-recm-with min-one-of other metronodes with [color = black] [M_entropy]]] ] ask metronodes with [is-dist? = true] [if count my-mmm + count my-recmetro >= original_neighborsM [set is-dist? false set color blue]] ask recmetro [set color yellow] ;;;ROAD - METRO if ticks > dist_tick + recovery_lag and any? roadnodes with [is-dist-RM? = true and color = black] and any? metronodes with [is-dist-RM? = true and color = black] [ifelse recovery_type != "recovery" and recovery_type != "both" [ask ch_metronode_RM [create-recrm-with min-one-of ch_roadnode_RM [distance myself] ]] [foreach sort-on [priopop] ch_metronode_RM [rec_3RM -> ask rec_3RM [create-recrm-with min-one-of ch_roadnode_RM [distance myself] ]]]] ask recrmrm [set color yellow] ask original_rm_roadnodes with [is-dist-RM? = true] [if count rm_roadnodes = original_rm_road [set is-dist-RM? false set color red]] ask original_rm_metronodes with [is-dist-RM? = true] [if count rm_metronodes = original_rm_metro [set is-dist-RM? false set color blue]] end ;;;;;; UTILITY PRIORITIZATION IN INITIAL RESPONSE ;;;;;; UTILITY PRIORITIZATION IN INITIAL RESPONSE ;;;;;; to response_0_prioritized ; sequential repetitive checks and then recovery - agents inspected in priopop descending order if ticks < 1 [ask roadnodes [set priopop mean [population] of neighbors4] ask metronodes [set priopop mean [population] of neighbors in-radius 3]] ask roadnodes [foreach sort-on [(- priopop)] roadnodes [r -> ask r [if ticks < 2 [set original_neighborsR count rr-neighbors] let i position r sort-on [(- priopop)] roadnodes if ticks = dist_tick + recovery_lag + i and original_neighborsR > count rr-neighbors [set is-dist? true] if ticks > count roadnodes [ask roadnodes with [is-dist? = true] [set color black]] if ticks = dist_tick + recovery_lag + i and count original_rm_roadnodes > count roadnodes with [any? rm-neighbors] [ask original_rm_roadnodes with [count rm-neighbors = 0] [set is-dist-RM? true] ask original_rm_metronodes with [count rm-neighbors = 0] [set is-dist-RM? true] ] if ticks > count roadnodes + count metronodes + 1 [ask original_rm_roadnodes with [is-dist-RM? = true] [set color black] ask original_rm_metronodes with [is-dist-RM? = true] [set color black] ]]] ] ask metronodes [foreach sort-on [(- priopop)] metronodes [m -> ask m [if ticks < 2 [set original_neighborsM count mm-neighbors] let n position m sort-on [(- priopop)] turtles if ticks = dist_tick + recovery_lag + n and original_neighborsM >= count mm-neighbors + 1 [set is-dist? true] if ticks > count roadnodes + count metronodes [ask metronodes with [is-dist? = true] [set color black]] if ticks = dist_tick + recovery_lag + n and count original_rm_metronodes > count metronodes with [any? rm-neighbors] [set is-dist-RM? true if ticks > count roadnodes + count metronodes + 1 [ask original_rm_metronodes with [is-dist-RM? = true] [set color black] ]]]]] end to response_1_prioritized ; sequential repetitive checks and recovery combined - agents inspected in priopop descending order if ticks < 1 [ask roadnodes [set priopop mean [population] of neighbors4] ask metronodes [set priopop mean [population] of neighbors in-radius 3]] ask roadnodes [foreach sort-on [(- priopop)] roadnodes [r -> ask r [if ticks < 2 [set original_neighborsR count rr-neighbors] let i position r sort-on [(- priopop)] roadnodes if ticks = dist_tick + recovery_lag + i and original_neighborsR > count rr-neighbors [set is-dist? true set color black] if ticks = dist_tick + recovery_lag + i and count original_rm_roadnodes > count rm_roadnodes [ask original_rm_roadnodes with [not any? my-rmrm] [set is-dist-RM? true set color black]]]]] ask metronodes [foreach sort-on [(- priopop)] metronodes [m -> ask m [if ticks < 2 [set original_neighborsM count mm-neighbors] let n position m sort-on [(- priopop)] turtles if ticks = dist_tick + recovery_lag + n and original_neighborsM >= count mm-neighbors + 1 [set is-dist? true set color black] if ticks = dist_tick + recovery_lag + n and count original_rm_metronodes > count rm_metronodes [ask original_rm_metronodes with [not any? my-rmrm] [set is-dist-RM? true set color black]]]]] end to response_2_prioritized ; parallel repetitive checks and recovery combined - agents inspected in priopop descending order if ticks < 1 [ask roadnodes [set priopop mean [population] of neighbors4] ask metronodes [set priopop mean [population] of neighbors in-radius 3]] ask roadnodes [foreach sort-on [(- priopop)] roadnodes [r -> ask r [if ticks < 2 [set original_neighborsR count rr-neighbors] let i position r sort-on [(- priopop)] roadnodes if ticks = dist_tick + i and original_neighborsR > count rr-neighbors [set is-dist? true set color black] if ticks = dist_tick + recovery_lag + i and count original_rm_roadnodes > count rm_roadnodes [ask original_rm_roadnodes with [not any? my-rmrm] [set is-dist-RM? true set color black]]]]] ask metronodes [foreach sort-on [(- priopop)] metronodes [m -> ask m [if ticks < 2 [set original_neighborsM count mm-neighbors] let n position m sort-on [(- priopop)] metronodes if ticks = dist_tick + n and original_neighborsM > count mm-neighbors [set is-dist? true set color black] if ticks = dist_tick + recovery_lag + n and count original_rm_metronodes > count rm_metronodes [ask original_rm_metronodes with [not any? my-rmrm] [set is-dist-RM? true set color black]]]]] end to response_3_prioritized ; constant monitoring of agents and immediate pesponse - the smartest - agents inspected in priopop descending order if ticks < 1 [ask roadnodes [set priopop mean [population] of neighbors4] ask metronodes [set priopop mean [population] of neighbors in-radius 3]] if ticks < 1 [ask roadnodes [set original_neighborsR count rr-neighbors]] if ticks < 1 [ask metronodes [set original_neighborsM count mm-neighbors]] ;; Check for road links failure ;;; if initial_response_type = "response 3" [ask roadnodes [foreach sort-on [(- priopop)] roadnodes [r -> ask r [if ticks = dist_tick + 1 and original_neighborsR > count rr-neighbors [set is-dist? true set color black]]]] foreach sort-on [(- priopop)] original_rm_roadnodes [rmn -> ask rmn [if ticks = dist_tick + 1 and count original_rm_roadnodes > count rm_roadnodes [ask original_rm_roadnodes with [not any? my-rmrm] [set is-dist-RM? true set color black]]]] ;;Check for metro links failure ;;; ask metronodes [foreach sort-on [(- priopop)] metronodes [m -> ask m [if ticks = dist_tick + 1 and original_neighborsM > count mm-neighbors [set is-dist? true set color black]]]] foreach sort-on [(- priopop)] original_rm_metronodes [mrn -> ask mrn [if ticks = dist_tick + 1 and count original_rm_metronodes > count rm_metronodes [ask original_rm_metronodes with [not any? my-rmrm] [set is-dist-RM? true set color black]]]] ] end ;;;;;; UTILITY PRIORITIZATION IN RECOVERY ;;;;;; UTILITY PRIORITIZATION IN RECOVERY ;;;;;; to recovery_0_prioritized ; restore links as in recovey_0 but with utility prioritization if ticks < 1 [ask roadnodes [set priopop mean [population] of neighbors4] ask metronodes [set priopop mean [population] of neighbors in-radius 3]] ;ROAD simple and cascading if ticks > dist_tick + recovery_lag and count roadnodes with [color = black] > 1 [ask roadnodes with [is-dist? = true and priopop = max [priopop] of roadnodes with [is-dist? = true]] [create-recr-with min-one-of other roadnodes with [is-dist? = true] [distance myself]]] if ticks > dist_tick + recovery_lag and count roadnodes with [color = black] > 2 and disturbance_type = "cascading" [ask roadnodes with [is-dist? = true] [set ch_roadnode roadnodes with [original_neighborsR - count rr-neighbors >= 2] ask ch_roadnode [set rec_roadnode max-n-of 2 other roadnodes with [is-dist? = true] [priopop] ; first sort-on [priopop] roadnodes with [original_neighborsR - count rr-neighbors > 2] ;min-one-of other roadnodes with [is-dist? = true] [distance myself] ;original_neighborsR - count rr-neighbors < 2 and create-recroad-with rec_roadnode ]]] ask recroad [set color yellow] ;;;redundant recroad links' removal ;;; if ticks > dist_tick + recovery_lag and any? roadnodes with [count rr-neighbors + count recr-neighbors > original_neighborsR] [ask roadnodes with [count rr-neighbors + count recr-neighbors > original_neighborsR] [let redundant recr-with max-one-of recr-neighbors [distance myself] ask redundant [die]]] ;METRO simple and cascading if ticks > dist_tick + recovery_lag and count metronodes with [color = black] > 1 [ask metronodes with [is-dist? = true and priopop = max [priopop] of metronodes with [is-dist? = true]] [create-recm-with min-one-of other metronodes with [is-dist? = true] [distance myself]]] if ticks > dist_tick + recovery_lag and count metronodes with [color = black] > 2 and disturbance_type = "cascading" [ask metronodes with [is-dist? = true] [set ch_metronode one-of metronodes with [original_neighborsM - count mm-neighbors >= 2] ask ch_metronode [set rec_metronode max-n-of 2 other metronodes with [is-dist? = true] [priopop] create-recmetro-with rec_metronode]]] ask recmetro [set color yellow] ;;;redundant recmetro links' removal ;;; if ticks > dist_tick + recovery_lag and any? metronodes with [count mm-neighbors + count recm-neighbors > original_neighborsM] [ask metronodes with [count mm-neighbors + count recm-neighbors > original_neighborsM] [let redundant recm-with max-one-of recm-neighbors [distance myself] ask redundant [die]]] ;ROAD - METRO if ticks > dist_tick + recovery_lag + 1 and count roadnodes with [is-dist-RM? = true] > 1 and count metronodes with [is-dist-RM? = true] > 1 and count rm_roadnodes < original_rm_road [foreach sort-on [priopop] original_rm_roadnodes with [is-dist-RM? = true] [rm_R -> ask rm_R [create-recrm-with min-one-of other original_rm_metronodes with [count my-rmrm = 0] [distance myself]]] ask recrmrm [set color yellow]] ;;;color identification for recovery;;;; ask roadnodes with [is-dist? = true] [if count my-rrr + count my-recroad >= original_neighborsR [set is-dist? false set color red]] ask metronodes with [is-dist? = true] [if count my-mmm + count my-recmetro >= original_neighborsM [set is-dist? false set color blue]] ask original_rm_roadnodes with [is-dist-RM? = true] [if count rm_roadnodes = original_rm_road [set is-dist-RM? false set color red]] ask original_rm_metronodes with [is-dist-RM? = true] [if count rm_metronodes = original_rm_metro [set is-dist-RM? false set color blue]] end to recovery_1_prioritized ; restore links as in recovey_1 but with utility prioritization if ticks = 2 ;dist_tick [set original_h4r (-1 * sum h4r) set original_h4m (-1 * sum h4m)] if ticks < 1 [ask roadnodes [set priopop mean [population] of neighbors4] ask metronodes [set priopop mean [population] of neighbors in-radius 3]] ;ROAD simple and cascading if ticks > dist_tick + recovery_lag and (-1 * sum h4r) > original_h4r and count roadnodes with [color = black] >= 2 and disturbance_type != "cascading" [ask max-one-of roadnodes with [is-dist? = true] [priopop] [create-recr-with one-of other roadnodes in-radius 10 with [is-dist? = true] ]] if ticks > dist_tick + recovery_lag and (-1 * sum h4r) != original_h4r and count roadnodes with [color = black] > 2 and disturbance_type = "cascading" [ask roadnodes [set ch_roadnode max-one-of roadnodes with [original_neighborsR - count rr-neighbors >= 2] [priopop] ask ch_roadnode [set rec_roadnode min-n-of 2 other roadnodes with [is-dist? = true] [distance myself] ;[priopop] create-recroad-with rec_roadnode]]] if ticks > dist_tick + recovery_lag and count roadnodes with [color = black] = 1 and disturbance_type = "cascading" and any? recroad [ask roadnodes with [is-dist? = true] [create-recr-with max-one-of other roadnodes with [any? recr-neighbors] [priopop]]] ask recroad [set color yellow] ;;;redundant recroad links' removal ;;; ; if ticks > dist_tick + recovery_lag and any? roadnodes with [count rr-neighbors + count recr-neighbors > original_neighborsR] ; [ask roadnodes with [count rr-neighbors + count recr-neighbors > original_neighborsR] ; [let redundant recr-with max-one-of recr-neighbors [distance myself] ; ask redundant ; [die]]] ;METRO simple and cascading if ticks > dist_tick + recovery_lag and (-1 * sum h4m) > original_h4m and count metronodes with [color = black] >= 2 [ask max-one-of metronodes with [is-dist? = true] [priopop] [create-recm-with min-one-of other metronodes with [is-dist? = true] [distance myself]]] if ticks > dist_tick + recovery_lag and (-1 * sum h4m) > original_h4m and count metronodes with [color = black] > 2 and disturbance_type = "cascading" [ask metronodes [set ch_metronode max-one-of metronodes with [original_neighborsM - count mm-neighbors >= 2] [priopop] ask ch_metronode [set rec_metronode min-n-of 2 other metronodes with [is-dist? = true] [distance myself];[priopop] create-recmetro-with rec_metronode]]] if ticks > dist_tick + recovery_lag and count metronodes with [color = black] = 1 and disturbance_type = "cascading" and any? recmetro [ask metronodes with [is-dist? = true] [create-recm-with max-one-of other metronodes with [any? recm-neighbors] [priopop]]] ask recmetro [set color yellow] ;;;redundant recmetro links' removal ;;; if ticks > dist_tick + recovery_lag and any? metronodes with [count mm-neighbors + count recm-neighbors > original_neighborsM] [ask metronodes with [count mm-neighbors + count recm-neighbors > original_neighborsM] [let redundant recm-with max-one-of recm-neighbors [distance myself] ask redundant [die]]] ;ROAD - METRO if ticks > dist_tick + recovery_lag and count rm_roadnodes < original_rm_road [ask original_rm_roadnodes with [is-dist-RM? = true and priopop = max [priopop] of roadnodes with [is-dist-RM? = true]] [create-recrmrm-with other original_rm_metronodes with [count my-rmrm = 0] set is-dist-RM? false]] ask recrmrm [set color yellow] ;;;color identification for recovery;;;; ask roadnodes with [is-dist? = true] [if count my-rrr + count my-recroad = original_neighborsR [set is-dist? false set color red]] ask metronodes with [is-dist? = true] [if count my-mmm + count my-recmetro = original_neighborsM [set is-dist? false set color blue]] ask original_rm_roadnodes with [is-dist-RM? = true] [if count rm_roadnodes = original_rm_road [set is-dist-RM? false set color red]] ask original_rm_metronodes with [is-dist-RM? = true] [if count rm_metronodes = original_rm_metro [set is-dist-RM? false set color blue]] end to recovery_2_prioritized ; restore links as in recovey_2 but with utility prioritization if ticks < 1 [ask roadnodes [set priopop mean [population] of neighbors4] ask metronodes [set priopop mean [population] of neighbors in-radius 3]] ;;;;; check missing links ;;;;;; ;ROAD simple and cascading ask roadnodes [set missing_linksR (original_neighborsR - count my-rrr)] ifelse ticks > dist_tick + recovery_lag and disturbance_type = "cascading" and count roadnodes with [color = black] > 2 [ask roadnodes [set ch_roadnode roadnodes with [missing_linksR = max [missing_linksR] of roadnodes] set rec_roadnode roadnodes with [missing_linksR = (max [missing_linksR] of roadnodes - 1)]]] [ask roadnodes [set ch_roadnode roadnodes with [missing_linksR = max [missing_linksR] of roadnodes]]] ; ;METRO simple and cascading ask metronodes [set missing_linksM (original_neighborsM - count my-mmm)] ifelse ticks > dist_tick + recovery_lag and disturbance_type = "cascading" and count metronodes with [color = black] > 2 [ask metronodes [set ch_metronode metronodes with [missing_linksM = max [missing_linksM] of metronodes] set rec_metronode metronodes with [missing_linksM = max [missing_linksM] of metronodes - 1 ]]] [ask metronodes [set ch_metronode metronodes with [missing_linksM = max [missing_linksM] of metronodes ]]] ;ROAD - METRO ask original_rm_metronodes [set missing_linksRM (count original_rm_metronodes - count my-rmrm)] if any? metronodes with [is-dist-RM? = true and priopop = max [priopop] of metronodes with [is-dist-RM? = true]] [ask metronodes [set ch_metronode_RM metronodes with [missing_linksRM = max [missing_linksRM] of metronodes]]] ;;;;;;; recover ;;;;;;;;;;;;; if ticks = 2 [set original_h4r (-1 * sum h4r) set original_h4m(-1 * sum h4m) set original_entropy_dep entropy_dep] if ticks > dist_tick + recovery_lag and (-1 * sum h4r) != original_h4r and count roadnodes with [color = black] >= 1 [ask ch_roadnode with [priopop = max [priopop] of roadnodes with [color = black]] [if disturbance_type = "simple" and count roadnodes with [color = black] >= 1 and count ch_roadnode > 1 [create-recr-with min-one-of other ch_roadnode [distance myself] ]]] if ticks > dist_tick + recovery_lag and (-1 * sum h4r) != original_h4r and count roadnodes with [color = black] >= 3 and disturbance_type = "cascading" and count rec_roadnode > 1 [foreach sort-on [priopop] ch_roadnode [ch_2R -> ask ch_2R [create-recroad-with min-n-of 2 rec_roadnode [distance myself]]]] if ticks > dist_tick + recovery_lag and (-1 * sum h4r) != original_h4r and count roadnodes with [color = black] = 2 [ask ch_roadnode with [color = black] [create-recr-with min-one-of other roadnodes with [missing_linksR > 0 and color = black] [distance myself]]] ;;;redundant recroad links' removal ;;; if ticks > dist_tick + recovery_lag and any? roadnodes with [count rr-neighbors + count recr-neighbors > original_neighborsR] [ask roadnodes with [count rr-neighbors + count recr-neighbors > original_neighborsR] [let redundant recr-with max-one-of recr-neighbors [distance myself] ask redundant [die]]] ask recroad [set color yellow] if ticks > dist_tick + recovery_lag and (-1 * sum h4m) > original_h4m and count metronodes with [color = black] >= 2 [ask ch_metronode with [priopop = max [priopop] of metronodes with [color = black]] [if disturbance_type = "simple" and count metronodes with [color = black] >= 2 and count ch_metronode >= 1 [create-recm-with min-one-of other ch_metronode [distance myself]]]] if ticks > dist_tick + recovery_lag and (-1 * sum h4m) > original_h4m and disturbance_type = "cascading" and count metronodes with [color = black] > 2 ;and count rec_metronode > 1 [foreach sort-on [priopop] ch_metronode [ch_2M -> ask ch_2M [create-recmetro-with min-n-of 2 rec_metronode [distance myself]]]] if ticks > dist_tick + recovery_lag and (-1 * sum h4m) != original_h4m and count metronodes with [color = black] = 2 [ask ch_metronode with [color = black] [create-recm-with min-one-of other metronodes with [missing_linksM > 0 and color = black] [distance myself]]] ;;;redundant recmetro links' removal ;;; if ticks > dist_tick + recovery_lag and any? metronodes with [count mm-neighbors + count recm-neighbors > original_neighborsM] [ask metronodes with [count mm-neighbors + count recm-neighbors > original_neighborsM] [let redundant recm-with max-one-of recm-neighbors [distance myself] ask redundant [die]]] ask recmetro [set color yellow] if ticks > dist_tick + recovery_lag + 1 and any? roadnodes with [is-dist-RM? = true] and any? metronodes with [is-dist-RM? = true] [foreach sort-on [priopop] ch_metronode_RM [ch_RM -> ask ch_RM [create-recrm-with min-one-of original_rm_roadnodes with [is-dist-RM? = true][distance myself]]]] ask recrmrm [set color yellow] ;;;color identification for recovery;;;; ask roadnodes with [is-dist? = true] [if count my-rrr + count my-recroad = original_neighborsR [set is-dist? false set color red]] ask metronodes with [is-dist? = true] [if count my-mmm + count my-recmetro = original_neighborsM [set is-dist? false set color blue]] ask original_rm_roadnodes with [is-dist-RM? = true] [if count rm_roadnodes = original_rm_road [set is-dist-RM? false set color red]] ask original_rm_metronodes with [is-dist-RM? = true] [if count rm_metronodes = original_rm_metro [set is-dist-RM? false set color blue]] end to check_rec_max_entropy_prioritized ; check of the potential entropy of system but with utility prioritization ;;;; check entropy of all the possible recoveries/linkages with each one of the other ROAD nodes -> identify recovery that yields max entropy in the ROAD SUBSYSTEM if ticks > dist_tick + recovery_lag and any? roadnodes with [is-dist? = true] and disturbance_type != "complex" [ask roadnodes [ifelse count my-rrr > 0 [set ch_R_entropy (-1 * (count my-rrr / original_neighborsR) * log (count my-rrr / original_neighborsR) 2)] [set ch_R_entropy -1] set ch_roadnode max-n-of road_dist_links roadnodes with [priopop > (mean[priopop] of roadnodes / 8)] [ch_R_entropy] ]] ;;;; check entropy of all the possible recoveries/linkages with each one of the other METRO nodes -> identify recovery that yields max entropy in the METRO SUBSYSTEM if ticks > dist_tick + recovery_lag and any? metronodes with [is-dist? = true] and disturbance_type != "complex" [ask metronodes [ifelse count my-mmm > 0 [set ch_M_entropy (-1 * (count my-mmm / original_neighborsM) * log (count my-mmm / original_neighborsM) 2)] [set ch_M_entropy 1] set ch_metronode max-n-of metro_dist_links metronodes with [priopop > (mean[priopop] of metronodes / 8)] [ch_M_entropy]]] ;with [ch_M_entropy = max [ch_M_entropy] of metronodes and priopop = max [priopop] of metronodes with [is-dist? = true]]] ;;; check entropy of all the possible recoveries/linkages with each one of the ROAD-METRO trans-system links if ticks > dist_tick + recovery_lag and any? roadnodes with [is-dist-RM? = true] and any? metronodes with [is-dist-RM? = true] [ask turtles with [any? rm-neighbors] [ask original_rm_metronodes with [is-dist-RM? = false] [set ch_RM_entropy (-1 * (count my-rmrm / original_rm_metro) * log (count my-rmrm / original_rm_metro) 2)] ask original_rm_metronodes with [is-dist-RM? = true] [set ch_RM_entropy 1] ask original_rm_roadnodes with [is-dist-RM? = false] [set ch_RM_entropy (-1 * (count my-rmrm / original_rm_road) * log (count my-rmrm / original_rm_road) 2)] ask original_rm_roadnodes with [is-dist-RM? = true] [set ch_RM_entropy 1] set ch_metronode_RM metronodes with [ch_RM_entropy = max [ch_RM_entropy] of original_rm_metronodes] set ch_roadnode_RM roadnodes with [ch_RM_entropy = max [ch_RM_entropy] of original_rm_roadnodes]] ] end to check_rec_min_entropy_prioritized ; check of the potential entropy of system but with utility prioritization ;;;; check entropy of all the possible recoveries/linkages with each one of the other ROAD nodes -> identify recovery that yields max entropy in the ROAD SUBSYSTEM if ticks > dist_tick ;+ recovery_lag ;and any? roadnodes with [is-dist? = true] [ask roadnodes [ifelse count my-rrr > 0 [set ch_R_entropy (-1 * (count my-rrr / original_neighborsR) * log (count my-rrr / original_neighborsR) 2)] [set ch_R_entropy -1] set ch_roadnode max-n-of road_dist_links roadnodes with [priopop > mean [priopop] of roadnodes] [ch_R_entropy]]] ;;;; check entropy of all the possible recoveries/linkages with each one of the other METRO nodes -> identify recovery that yields max entropy in the METRO SUBSYSTEM if ticks > dist_tick [ask metronodes [ifelse count my-mmm > 0 [set ch_M_entropy (-1 * (count my-mmm / original_neighborsM) * log (count my-mmm / original_neighborsM) 2)] [set ch_M_entropy 1] set ch_metronode max-n-of metro_dist_links metronodes with [priopop > mean [priopop] of metronodes] [ch_M_entropy]]] ;;; check entropy of all the possible recoveries/linkages with each one of the ROAD-METRO trans-system links if ticks > dist_tick + recovery_lag and count roadnodes with [is-dist-RM? = true and color = black] > 1 and count metronodes with [is-dist-RM? = true and color = black] > 1 [ask turtles with [any? rm-neighbors] [ask original_rm_metronodes with [is-dist-RM? = false] [set ch_RM_entropy (-1 * (count my-rmrm + count my-recrmrm / original_rm_metro) * log (count my-rmrm + count my-recrmrm / original_rm_metro) 2)] ask original_rm_metronodes with [is-dist-RM? = true] [set ch_RM_entropy 1] ask original_rm_roadnodes with [is-dist-RM? = false] [set ch_RM_entropy (-1 * (count my-rmrm + count my-recrmrm / original_rm_metro) * log (count my-rmrm + count my-recrmrm / original_rm_metro) 2)] ask original_rm_roadnodes with [is-dist-RM? = true] [set ch_RM_entropy 1] set ch_metronode_RM metronodes with [ch_RM_entropy = max [ch_RM_entropy] of original_rm_metronodes ] set ch_roadnode_RM roadnodes with [ch_RM_entropy = min [ch_RM_entropy] of original_rm_roadnodes ] ]] end ;;;;;; RESILIENCE ASSESSMENT PROCEDURES ;;;;;;; RESILIENCE ASSESSMENT PROCEDURES ;;;;;;; to calcresilience if ticks < dist_tick [set initialperf mean (sublist totalcapacitylist 0 (length totalcapacitylist)) ] set distperf (min totalcapacitylist) / max totalcapacitylist if ticks > recovery_tick [set finalperf item (length totalcapacitylist - 1) totalcapacitylist] foreach totalcapacitylist [ i -> set totalloss (i - initialperf )] set totallosslist lput totalloss totallosslist set resilience (1 - (abs (sum totallosslist) / (initialperf * 100))) ;;; static deterministic resilience metric by Bruneau et al. 2003 if length totalcapacitylist != recovery_tick [set z_resilience 1 - (((((initialperf / max totalcapacitylist) - distperf)) * (recovery_lag + 2))/ (2 * (length totalcapacitylist - recovery_tick )) )] ;;; deterministic resilience metric by Zobel 2011 if initialperf != finalperf and initialperf != distperf [set h-r_resilience (finalperf - distperf) / (initialperf - distperf)] ;;; deterministic time-based resilience metric by Henry & Ramirez-Marquez 2012 end to calcentropy ;; calculate the probability of nodes' connections as aggregated set (sum -> if the two subsystems are statistically independent (Bais & Farmer 2007)) ask roadnodes [if ticks < 2 [set roadlinks max [count my-links] of roadnodes] set sort-road sort roadnodes foreach sort-road [?1 -> ask ?1 [set my_R_links count my-links]]] if roadlinks > 0 [set p4r map [?1 -> ?1 / roadlinks] [my_R_links] of roadnodes] ;; based on code from BRADFORD expectations set h4r map [?2 -> ?2 * log ?2 2] filter [n -> n > 0] p4r ;; BRADFORD expectations if roadlinks > 0 [set p41r map [?1 -> 1 - ?1 / roadlinks] [my_R_links] of roadnodes ];; based on S. Lloyd's tutorial set h41r map [?2 -> ?2 * log ?2 2] filter [n -> n > 0] p41r set sr (-1 * sum h4r) + (-1 * sum h41r) ;; calculate the probability of nodes' connections as aggregated set (sum -> if the two subsystems are statistically independent (Bais & Farmer 2007)) ask metronodes [if ticks < 2 [set metrolinks max [count my-links] of metronodes] set sort-metro sort metronodes foreach sort-metro [?1 -> ask ?1 [set my_M_links count my-links]]] set p4m map [?1 -> ?1 / metrolinks ] [my_M_links] of metronodes ;; based on code from BRADFORD expectations set h4m map [?2 -> ?2 * log ?2 2] filter [n -> n > 0] p4m ;; BRADFORD expectations set p41m map [?1 -> 1 - ?1 / metrolinks] [my_M_links] of metronodes ;; based on S. Lloyd's tutorial set h41m map [?2 -> ?2 * log ?2 2] filter [n -> n > 0] p41m set sm (-1 * sum h4m) + (-1 * sum h41m) ;; calculate the probability of powernodes' connections as aggregated set (sum -> if the two subsystems are statistically independent (Bais & Farmer 2007)) ask criticalnodes [if ticks < 2 [set served_nodes max [ci_factor * 10] of criticalnodes set served_roadnodes max [ci_roadfactor] of criticalnodes set served_metronodes max [ci_metrofactor] of criticalnodes] set my_CI_factor ci_factor * 10] set p4c map [?1 -> ?1 / served_nodes] [my_CI_factor] of criticalnodes ;; based on code from BRADFORD expectations set h4c map [?2 -> ?2 * log ?2 2] filter [n -> n > 0] p4c ;; BRADFORD expectations set p41c map [?1 -> 1 - ?1 / served_nodes] [my_CI_factor] of criticalnodes ;; based on S. Lloyd's tutorial set h41c map [?2 -> ?2 * log ?2 2] filter [n -> n > 0] p41c set sc (-1 * sum h4c) + (-1 * sum h41c) ;; calculate the entropy based on the summation of the entropies of the two subsystems, i.e. and *if the two subsystems are statistically independent (Bais & Farmer 2007) ;set h4y (p4y * log p4y 2) ;set h4c (p4c * log p4c 2) ;; add the h's of each subsystem's nodes and multiply by -1 to get Shannon entropy and then add the two entropies set entropy (-1 * sum h4r) + (-1 * sum h4m) + (-1 * sum h4c) set entropylist lput entropy entropylist ;; method to calculate joint probability for dependent disruptions ;; the unidirectional links cannot reflect the disturbance's propagation + directed network! ask turtles ;[foreach sort turtles [?1 -> ask ?1 [if ticks < 1 [set nodeneighbors count link-neighbors] set nodelinks nodeneighbors - count link-neighbors ] ;; calculation of srm let index range length [nodeneighbors] of turtles ifelse any? turtles with [nodelinks >= 2] [set p4rm (count turtles with [nodelinks >= 2]) / (length [nodeneighbors] of turtles) set h4rm p4rm * log p4rm 2 set srm -1 * h4rm ] [set p4rm 0 set h4rm 0 set srm -1 * h4rm ] set entropyr:m sr + sm - srm set entropyr:mlist lput entropyr:m entropyr:mlist set entropy_dep (-1 * sum h4r) + (-1 * sum h4m) - srm set entropy_dep_list lput entropy_dep entropy_dep_list ;; calculation of srp ifelse any? roadnodes with [nodelinks >= 1 and is-served? = false] [set p4rc (count roadnodes with [nodelinks >= 1 and is-served? = false]) / served_roadnodes set h4rc p4rc * log p4rc 2 set src -1 * h4rc] [set p4rc 0 set h4rc 0 set src -1 * h4rc] set entropyr:c sr + sc - src set entropyr:clist lput entropyr:c entropyr:clist ;; calculation of smp ifelse any? metronodes with [nodelinks >= 1 and is-served? = false] [set p4mc (count metronodes with [nodelinks >= 1 and is-served? = false]) / served_metronodes set h4mc p4mc * log p4mc 2 set smc -1 * h4mc] [set p4mc 0 set h4mc 0 set smc -1 * h4mc] set entropym:c sm + sc - smc set entropym:clist lput entropym:c entropym:clist ;; calculation of srmp ifelse any? roadnodes with [nodelinks >= 1 and is-served? = false] and any? metronodes with [nodelinks >= 1 and is-served? = false] [set p4rmc (count turtles with [nodelinks >= 1 and is-served? = false]) / served_nodes set h4rmc p4rmc * log p4rmc 2 set srmc -1 * h4rmc] [set p4rmc 0 set h4rmc 0 set srmc -1 * h4rmc] set entropyr:m:c sr + sm + sc - srmc set entropyr:m:clist lput entropyr:m:c entropyr:m:clist set entropy_dep (-1 * sum h4r) + (-1 * sum h4m) + (-1 * sum h4c) - srm - src - smc - srmc set entropy_dep_list lput entropy_dep entropy_dep_list ;; calcualte Bruneau Resilience Metric for system's information entropy ;; if ticks < dist_tick [set initialent mean (sublist entropy_dep_list 0 (length entropy_dep_list)) ] foreach entropy_dep_list [ i -> set totalent (i - initialent )] set totalentlist lput totalent totalentlist set entropymetric (1 - (abs (sum totalentlist) / (initialent * 100))) ;;; static deterministic resilience metric by Bruneau et al. 2003 end to calcpopulationneeds if ticks = 1 [ask turtles [set original_neighbors_RM count rm-neighbors]] ask roadnodes [ifelse original_neighborsR > count rr-neighbors + count recr-neighbors [set new_population 0] [set new_population mean [population] of patches in-radius 4] set popneedsR mean [new_population] of roadnodes] ask metronodes [ifelse original_neighborsM > count mm-neighbors + count recm-neighbors [set new_population 0] [set new_population mean [population] of patches in-radius 6] set popneedsM mean [new_population] of metronodes] ask criticalnodes with [is-on? = true] [set new_population mean ([population] of patches with [population > 0] in-radius ci_range) + mean [new_population] of roadnodes in-radius ci_range + mean [new_population] of metronodes in-radius ci_range set popneedsCI mean [new_population] of criticalnodes] ask turtles [ifelse original_neighbors_RM > count rm-neighbors + count recrm-neighbors [set new_populationRM 0] [set new_populationRM mean [population] of patches in-radius 2] set popneedsRM mean [new_populationRM] of turtles] set popneeds popneedsR + popneedsM + popneedsCI + popneedsRM ifelse popneeds != 0 [set popneedslist lput popneeds popneedslist] [set popneedslist 0 ] ;; calcualte Bruneau Resilience Metric for system's utility ;; if ticks < dist_tick [set initialutil mean (sublist popneedslist 0 (length popneedslist)) ] foreach popneedslist [ i -> set totalutil (i - initialutil)] set totalutillist lput totalutil totalutillist set utility (1 - (abs (sum totalutillist) / (initialutil * 100))) ;;; static deterministic resilience metric by Bruneau et al. 2003 end @#$#@#$#@ GRAPHICS-WINDOW 219 10 632 424 -1 -1 5.0 1 10 1 1 1 0 0 0 1 -40 40 -40 40 0 0 1 ticks 30.0 BUTTON 5 10 68 43 setup setup NIL 1 T OBSERVER NIL NIL NIL NIL 1 SWITCH 7 51 145 84 show_gradient show_gradient 0 1 -1000 BUTTON 76 10 131 43 go go T 1 T OBSERVER NIL NIL NIL NIL 1 BUTTON 139 11 197 44 go once go NIL 1 T OBSERVER NIL NIL NIL NIL 1 MONITOR 7 171 92 216 recovery tick recovery_tick 0 1 11 MONITOR 7 219 92 264 Road Capacity roadcapacitylist 3 1 11 MONITOR 7 267 91 312 Metro Capacity metrocapacitylist 3 1 11 SLIDER 7 93 103 126 dist_tick dist_tick 0 50 10.0 1 1 NIL HORIZONTAL SLIDER 6 134 103 167 recovery_lag recovery_lag 1 50 10.0 1 1 NIL HORIZONTAL CHOOSER 114 92 213 137 disturbance_type disturbance_type "simple" "cascading" "complex" 0 SWITCH 114 143 213 176 road road 0 1 -1000 SWITCH 114 244 213 277 metro metro 0 1 -1000 MONITOR 641 13 744 50 Initial Performance initialperf 3 1 9 MONITOR 750 13 850 50 Final Performance finalperf 3 1 9 PLOT 639 52 899 172 Total System Performance Levels ticks performance % 0.0 10.0 0.0 100.0 true false "" "" PENS "default" 1.0 0 -16777216 true "" "plot totalcapacitylevel" MONITOR 640 175 708 220 Zobel Resilience z_resilience 6 1 11 MONITOR 714 175 790 220 Henry & R-Marquez Resilience h-r_resilience 6 1 11 MONITOR 797 175 898 220 Bruneau Resilience resilience 6 1 11 PLOT 643 237 901 381 Entropy of Subsystems NIL NIL 0.0 100.0 0.0 1.0 true false "" "" PENS "Total Entropy Independent" 1.0 0 -16777216 true "" "if ticks > 2\n [plot (-1 * sum h4r) + (-1 * sum h4m)]" "Marginal Road subsytem" 1.0 0 -2674135 true "" "if ticks > 2\n [plot -1 * sum h4r]" "Marginal Metro subsystem" 1.0 0 -13345367 true "" "if ticks > 2\n [plot -1 * sum h4m]" "Total Entropy Dependent" 1.0 0 -8630108 true "" "plot entropy_dep" "Marginal Entropy CI subsystem" 1.0 0 -7171555 true "" "if ticks > 2\n [plot -1 * sum h4c]" MONITOR 643 384 693 421 min min entropy_dep_list 3 1 9 MONITOR 696 384 746 421 max max entropy_dep_list 3 1 9 MONITOR 755 384 805 421 initial mean sublist entropy_dep_list 0 dist_tick 3 1 9 MONITOR 809 384 859 421 final mean sublist entropy_dep_list recovery_tick length entropy_dep_list 3 1 9 MONITOR 863 384 913 421 event mean sublist entropy_dep_list dist_tick recovery_tick 3 1 9 PLOT 422 431 635 565 Utility Factor NIL NIL 0.0 10.0 0.0 5.0 true false "" "" PENS "utility Road" 1.0 0 -2674135 true "" "plot popneedsR" "utility Metro" 1.0 0 -13345367 true "" "plot popneedsM" "utility MAX" 1.0 0 -16777216 true "" "plot popneeds" "utility Road-Metro" 1.0 0 -8630108 true "" "plot popneedsRM" "utility CI" 1.0 0 -7171555 true "" "plot popneedsCI" MONITOR 222 431 328 472 prioritized roadnode sort roadnodes with [is-dist? = true and priopop = max [priopop] of roadnodes with [color = black]] 17 1 10 MONITOR 333 431 420 472 disturbed roadnode sort roadnodes with [is-dist? = true] 17 1 10 MONITOR 222 476 329 517 prioritized metronode sort metronodes with [is-dist? = true and priopop = max [priopop] of metronodes with [color = black]] 17 1 10 MONITOR 334 476 419 517 disturbed metronodes sort metronodes with [is-dist? = true] 17 1 10 MONITOR 295 526 352 563 initial last reverse popneedslist 2 1 9 MONITOR 357 526 414 563 final last popneedslist 2 1 9 CHOOSER 3 366 158 411 initial_response_type initial_response_type "response 0" "response 1" "response 2" "response 3" 3 CHOOSER 3 419 158 464 recovery_type recovery_type "recovery 0" "recovery 1" "recovery 2" "recovery 3" "recovery 4" 3 CHOOSER 3 471 158 516 utility_prioritization utility_prioritization "no" "inspection" "recovery" "both" 2 INPUTBOX 114 179 199 239 road_dist_links 3.0 1 0 Number INPUTBOX 113 280 203 340 metro_dist_links 1.0 1 0 Number MONITOR 8 315 90 360 CI Capacity CIcapacitylist 3 1 11 MONITOR 823 426 908 471 Entropy Metric entropymetric 5 1 11 MONITOR 640 520 721 565 Utility Metric utility 5 1 11 MONITOR 642 431 750 476 Hospital utility mean [utility] of criticalnodes with [color = white] 4 1 11 MONITOR 642 470 751 515 Fire strations utility mean [utility] of criticalnodes with [color != white] 4 1 11 @#$#@#$#@ ## WHAT IS IT? The model represents in a ruductionist way the organization of the complex urban system of the city of Thessaloniki, Greece and tries to explore the impacts of diverse response and recovery strategies of different levels of smartness, on the resilience after a given disturbance. The property of resilience is evaluated with three different approaches in this model, namely based on: the system’s performance levels and the entropy of system’s performance the utility of the urban system The model calculates: - the performance levels (considering the system's connectivity = number and arrangement of links) - three different performance-based resilience metrics, i.e.: by Bruneau, by Zobel, and by Henry & Ramirez - Marquez - the entropy of the possible connections (number of links) of each node of each subsystem (yellow and cyan) presented separately and as a total for the entire system - the mutual entropy of the nodes possible connections, by estimating the values of marginal and joint entropies, suitable for more complex conditions of disturbance. - the entropy-based resilence metric - the utility levels (considering the citizens' needs) - the utility-based resilience metric ## HOW IT WORKS In each subsystem of this model, one of the links dies (disruptive event) and the agents/ nodes start to check which one is missing a link. This check occurs in a consecutive order: it starts with the fisrt node and after the completion and if the missing link is not detected, it moves to the second node of the subsystem. The time required for each check is recorded as an incremental delay in the recovery time (recovery_tick), affecting the resilience of the entire system. In this version of the model, the two subsystems start the procedures of check simultaneously, so that they can recover in parallel. When some links are lost, there is more disorder in the system (potential for more information), which is reflected in the increase of Shannon’s entropy. The different definitions of entropy are developed as follows: entropy4: p= each node’s remaining connections (number of links) / each subsystem’s maximum initial connections observed in a single node. The different capacities of the two subsystems are effectively reflected as well as the mutual loss of connection between nodes. However, this approach does not provide a convincing formula for the entropy of the entire system. The applied addition of the entropies of the subsystems is only valid if the disturbances are statistically independent (Bais & Farmer, 2007). entropy41: Based on the approaches of Information Theory (Cover & Thomas, 2017; Lloyd, 2022) the entropy of each subsystem is estimated as the marginal entropy / information with p = each node’s (remaining) connections/ subsystem’s maximum initial node’s connections + each node’s lost connections / subsystem’s maximum initial node’s connections. Then, the joint probability is defined to capture the events of multiple lost connections in a single node by counting the nodes with more than 2 lost connections simultaneously / subsystem’s maximum initial node’s connections. Finally, according to the formula of mutual entropy I(X;Y)=I(X) + I(Y) – I(XY) (Cover & Thomas, 2017) the entire system’s mutual entropy is calculated. entropy42: combining the approach of entropy4 with the joint probability for the dependent disturbances, the entire system’s mutual entropy is calculated for every type of disturbance. popneeds: utility amount earned from the operation of each node of the respective subsystems, depending on the relevant population density and the fanctionality of the examined node. ## HOW TO USE IT The user is expected to start the model’s set up and then run the model either for one step at a time by pressing the button “go once”, or until the end by pressing the “go” button. The simulations stop automatically after 100 ticks. The user can select and simulate different response and recovery strategies, which represnet various levels of smartness, by combining through the respective choosers the initial response process, the recovery process, and the prioritazion process. ## THINGS TO NOTICE The user can only observe from run to run that the different measures of resilience describe the same event, but they yield different values. This fact is related with the respective definitions and therefore, the mathematical expressions of entropy. The user can also observe the effectivness of the different response and recovery strategies that represent various levels of smartness and their impacts. @#$#@#$#@ default true 0 Polygon -7500403 true true 150 5 40 250 150 205 260 250 airplane true 0 Polygon -7500403 true true 150 0 135 15 120 60 120 105 15 165 15 195 120 180 135 240 105 270 120 285 150 270 180 285 210 270 165 240 180 180 285 195 285 165 180 105 180 60 165 15 arrow true 0 Polygon -7500403 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150 box false 0 Polygon -7500403 true true 150 285 285 225 285 75 150 135 Polygon -7500403 true true 150 135 15 75 150 15 285 75 Polygon -7500403 true true 15 75 15 225 150 285 150 135 Line -16777216 false 150 285 150 135 Line -16777216 false 150 135 15 75 Line -16777216 false 150 135 285 75 bug true 0 Circle -7500403 true true 96 182 108 Circle -7500403 true true 110 127 80 Circle -7500403 true true 110 75 80 Line -7500403 true 150 100 80 30 Line -7500403 true 150 100 220 30 butterfly true 0 Polygon -7500403 true true 150 165 209 199 225 225 225 255 195 270 165 255 150 240 Polygon -7500403 true true 150 165 89 198 75 225 75 255 105 270 135 255 150 240 Polygon -7500403 true true 139 148 100 105 55 90 25 90 10 105 10 135 25 180 40 195 85 194 139 163 Polygon -7500403 true true 162 150 200 105 245 90 275 90 290 105 290 135 275 180 260 195 215 195 162 165 Polygon -16777216 true false 150 255 135 225 120 150 135 120 150 105 165 120 180 150 165 225 Circle -16777216 true false 135 90 30 Line -16777216 false 150 105 195 60 Line -16777216 false 150 105 105 60 car false 0 Polygon -7500403 true true 300 180 279 164 261 144 240 135 226 132 213 106 203 84 185 63 159 50 135 50 75 60 0 150 0 165 0 225 300 225 300 180 Circle -16777216 true false 180 180 90 Circle -16777216 true false 30 180 90 Polygon -16777216 true false 162 80 132 78 134 135 209 135 194 105 189 96 180 89 Circle -7500403 true true 47 195 58 Circle -7500403 true true 195 195 58 circle false 0 Circle -7500403 true true 0 0 300 circle 2 false 0 Circle -7500403 true true 0 0 300 Circle -16777216 true false 30 30 240 cow false 0 Polygon -7500403 true true 200 193 197 249 179 249 177 196 166 187 140 189 93 191 78 179 72 211 49 209 48 181 37 149 25 120 25 89 45 72 103 84 179 75 198 76 252 64 272 81 293 103 285 121 255 121 242 118 224 167 Polygon -7500403 true true 73 210 86 251 62 249 48 208 Polygon -7500403 true true 25 114 16 195 9 204 23 213 25 200 39 123 cylinder false 0 Circle -7500403 true true 0 0 300 dot false 0 Circle -7500403 true true 90 90 120 face happy false 0 Circle -7500403 true true 8 8 285 Circle -16777216 true false 60 75 60 Circle -16777216 true false 180 75 60 Polygon -16777216 true false 150 255 90 239 62 213 47 191 67 179 90 203 109 218 150 225 192 218 210 203 227 181 251 194 236 217 212 240 face neutral false 0 Circle -7500403 true true 8 7 285 Circle -16777216 true false 60 75 60 Circle -16777216 true false 180 75 60 Rectangle -16777216 true false 60 195 240 225 face sad false 0 Circle -7500403 true true 8 8 285 Circle -16777216 true false 60 75 60 Circle -16777216 true false 180 75 60 Polygon -16777216 true false 150 168 90 184 62 210 47 232 67 244 90 220 109 205 150 198 192 205 210 220 227 242 251 229 236 206 212 183 fish false 0 Polygon -1 true false 44 131 21 87 15 86 0 120 15 150 0 180 13 214 20 212 45 166 Polygon -1 true false 135 195 119 235 95 218 76 210 46 204 60 165 Polygon -1 true false 75 45 83 77 71 103 86 114 166 78 135 60 Polygon -7500403 true true 30 136 151 77 226 81 280 119 292 146 292 160 287 170 270 195 195 210 151 212 30 166 Circle -16777216 true false 215 106 30 flag false 0 Rectangle -7500403 true true 60 15 75 300 Polygon -7500403 true true 90 150 270 90 90 30 Line -7500403 true 75 135 90 135 Line -7500403 true 75 45 90 45 flower false 0 Polygon -10899396 true false 135 120 165 165 180 210 180 240 150 300 165 300 195 240 195 195 165 135 Circle -7500403 true true 85 132 38 Circle -7500403 true true 130 147 38 Circle -7500403 true true 192 85 38 Circle -7500403 true true 85 40 38 Circle -7500403 true true 177 40 38 Circle -7500403 true true 177 132 38 Circle -7500403 true true 70 85 38 Circle -7500403 true true 130 25 38 Circle -7500403 true true 96 51 108 Circle -16777216 true false 113 68 74 Polygon -10899396 true false 189 233 219 188 249 173 279 188 234 218 Polygon -10899396 true false 180 255 150 210 105 210 75 240 135 240 house false 0 Rectangle -7500403 true true 45 120 255 285 Rectangle -16777216 true false 120 210 180 285 Polygon -7500403 true true 15 120 150 15 285 120 Line -16777216 false 30 120 270 120 leaf false 0 Polygon -7500403 true true 150 210 135 195 120 210 60 210 30 195 60 180 60 165 15 135 30 120 15 105 40 104 45 90 60 90 90 105 105 120 120 120 105 60 120 60 135 30 150 15 165 30 180 60 195 60 180 120 195 120 210 105 240 90 255 90 263 104 285 105 270 120 285 135 240 165 240 180 270 195 240 210 180 210 165 195 Polygon -7500403 true true 135 195 135 240 120 255 105 255 105 285 135 285 165 240 165 195 line true 0 Line -7500403 true 150 0 150 300 line half true 0 Line -7500403 true 150 0 150 150 pentagon false 0 Polygon -7500403 true true 150 15 15 120 60 285 240 285 285 120 person false 0 Circle -7500403 true true 110 5 80 Polygon -7500403 true true 105 90 120 195 90 285 105 300 135 300 150 225 165 300 195 300 210 285 180 195 195 90 Rectangle -7500403 true true 127 79 172 94 Polygon -7500403 true true 195 90 240 150 225 180 165 105 Polygon -7500403 true true 105 90 60 150 75 180 135 105 plant false 0 Rectangle -7500403 true true 135 90 165 300 Polygon -7500403 true true 135 255 90 210 45 195 75 255 135 285 Polygon -7500403 true true 165 255 210 210 255 195 225 255 165 285 Polygon -7500403 true true 135 180 90 135 45 120 75 180 135 210 Polygon -7500403 true true 165 180 165 210 225 180 255 120 210 135 Polygon -7500403 true true 135 105 90 60 45 45 75 105 135 135 Polygon -7500403 true true 165 105 165 135 225 105 255 45 210 60 Polygon -7500403 true true 135 90 120 45 150 15 180 45 165 90 sheep false 15 Circle -1 true true 203 65 88 Circle -1 true true 70 65 162 Circle -1 true true 150 105 120 Polygon -7500403 true false 218 120 240 165 255 165 278 120 Circle -7500403 true false 214 72 67 Rectangle -1 true true 164 223 179 298 Polygon -1 true true 45 285 30 285 30 240 15 195 45 210 Circle -1 true true 3 83 150 Rectangle -1 true true 65 221 80 296 Polygon -1 true true 195 285 210 285 210 240 240 210 195 210 Polygon -7500403 true false 276 85 285 105 302 99 294 83 Polygon -7500403 true false 219 85 210 105 193 99 201 83 square false 0 Rectangle -7500403 true true 30 30 270 270 square 2 false 0 Rectangle -7500403 true true 30 30 270 270 Rectangle -16777216 true false 60 60 240 240 star false 0 Polygon -7500403 true true 151 1 185 108 298 108 207 175 242 282 151 216 59 282 94 175 3 108 116 108 target false 0 Circle -7500403 true true 0 0 300 Circle -16777216 true false 30 30 240 Circle -7500403 true true 60 60 180 Circle -16777216 true false 90 90 120 Circle -7500403 true true 120 120 60 tree false 0 Circle -7500403 true true 118 3 94 Rectangle -6459832 true false 120 195 180 300 Circle -7500403 true true 65 21 108 Circle -7500403 true true 116 41 127 Circle -7500403 true true 45 90 120 Circle -7500403 true true 104 74 152 triangle false 0 Polygon -7500403 true true 150 30 15 255 285 255 triangle 2 false 0 Polygon -7500403 true true 150 30 15 255 285 255 Polygon -16777216 true false 151 99 225 223 75 224 truck false 0 Rectangle -7500403 true true 4 45 195 187 Polygon -7500403 true true 296 193 296 150 259 134 244 104 208 104 207 194 Rectangle -1 true false 195 60 195 105 Polygon -16777216 true false 238 112 252 141 219 141 218 112 Circle -16777216 true false 234 174 42 Rectangle -7500403 true true 181 185 214 194 Circle -16777216 true false 144 174 42 Circle -16777216 true false 24 174 42 Circle -7500403 false true 24 174 42 Circle -7500403 false true 144 174 42 Circle -7500403 false true 234 174 42 turtle true 0 Polygon -10899396 true false 215 204 240 233 246 254 228 266 215 252 193 210 Polygon -10899396 true false 195 90 225 75 245 75 260 89 269 108 261 124 240 105 225 105 210 105 Polygon -10899396 true false 105 90 75 75 55 75 40 89 31 108 39 124 60 105 75 105 90 105 Polygon -10899396 true false 132 85 134 64 107 51 108 17 150 2 192 18 192 52 169 65 172 87 Polygon -10899396 true false 85 204 60 233 54 254 72 266 85 252 107 210 Polygon -7500403 true true 119 75 179 75 209 101 224 135 220 225 175 261 128 261 81 224 74 135 88 99 wheel false 0 Circle -7500403 true true 3 3 294 Circle -16777216 true false 30 30 240 Line -7500403 true 150 285 150 15 Line -7500403 true 15 150 285 150 Circle -7500403 true true 120 120 60 Line -7500403 true 216 40 79 269 Line -7500403 true 40 84 269 221 Line -7500403 true 40 216 269 79 Line -7500403 true 84 40 221 269 wolf false 0 Polygon -16777216 true false 253 133 245 131 245 133 Polygon -7500403 true true 2 194 13 197 30 191 38 193 38 205 20 226 20 257 27 265 38 266 40 260 31 253 31 230 60 206 68 198 75 209 66 228 65 243 82 261 84 268 100 267 103 261 77 239 79 231 100 207 98 196 119 201 143 202 160 195 166 210 172 213 173 238 167 251 160 248 154 265 169 264 178 247 186 240 198 260 200 271 217 271 219 262 207 258 195 230 192 198 210 184 227 164 242 144 259 145 284 151 277 141 293 140 299 134 297 127 273 119 270 105 Polygon -7500403 true true -1 195 14 180 36 166 40 153 53 140 82 131 134 133 159 126 188 115 227 108 236 102 238 98 268 86 269 92 281 87 269 103 269 113 x false 0 Polygon -7500403 true true 270 75 225 30 30 225 75 270 Polygon -7500403 true true 30 75 75 30 270 225 225 270 @#$#@#$#@ NetLogo 6.2.0 @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ default 0.0 -0.2 0 0.0 1.0 0.0 1 1.0 0.0 0.2 0 0.0 1.0 link direction true 0 Line -7500403 true 150 150 90 180 Line -7500403 true 150 150 210 180 @#$#@#$#@ 0 @#$#@#$#@