;infection_status ;0 uninfected ;1 early latent ;2 late latent ;3 TB extrapulmonary ;4 TB smear- ;5 TB smear+ ;6 treatment ;7 recovered ;infection_location ;1 home ;2 repeat daily ;3 repeat weekly ;4 random talk ;5 random no talk ;12 months of 30 days extensions[ csv profiler nw rnd ] undirected-link-breed [repeat_links repeat_link] undirected-link-breed [hh_links hh_link] globals[ ;;;;;;;;;;;;;;;;input file globals;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; run_in_length end_time pop_size mean_random_contacts var_random_contacts mean_repeat_contacts var_repeat_contacts prop_repeat_contacts_daily repeat_contacts_multiplier prob_talk_random_contact contact_duration_hh contact_duration_repeat_daily contact_duration_repeat_weekly contact_duration_random_talk contact_duration_random_nontalk transmission_prob reduced_transmission_smearneg transmission_prob_notalk_weight reinfection_relative_risk_HIVneg reinfection_relative_risk_HIVpos prop_sus_var_infection susceptibility_var infectiousness_var clustering_coefficient seed_number max_age mean_hh_size var_hh_size self_cure_rate reduced_self_cure_HIVpos TB_mortality_rate_smearpos_HIVneg TB_mortality_rate_smearpos_HIVpos TB_mortality_rate_smearneg_HIVneg TB_mortality_rate_smearneg_HIVpos reduced_TB_mortality_treatment_HIVneg reduced_TB_mortality_treatment_HIVpos TB_treatment_dropout_rate_HIVneg TB_treatment_dropout_rate_HIVpos treatment_rate_extra_HIVneg treatment_rate_extra_HIVpos treatment_rate_smearneg_HIVneg treatment_rate_smearneg_HIVpos treatment_rate_smearpos_HIVneg treatment_rate_smearpos_HIVpos develop_tb_y1_rate develop_tb_y2_rate develop_tb_y3_rate develop_tb_y4_rate develop_tb_y5_rate develop_tb_reactivation_rate HIV_increased_risk_develop_disease HIV_increased_risk_reactivation prop_extrapulmonary_HIVneg prop_pul_smearpos_HIVneg prop_extrapulmonary_HIVpos prop_pul_smearpos_HIVpos develop_smearpos_rate_HIVneg develop_smearpos_rate_HIVpos initial_prop_HIV_pos HIV_infection_rate prop_15_HIV_pos prop_15_latent prop_15_recent_latent_annual ;;;;;;;;;;;;;;;;immediately calculated from inputs;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; infectiousness_alp_gam susceptibility_alp_gam random_contacts_alp random_contacts_gam repeat_contacts_alp repeat_contacts_gam hh_size_alp hh_size_gam ;;;;;;;;;;;;;;;;input and output;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; file infection_location_infection_HIVpos_1st1 infection_location_infection_HIVpos_1st2 infection_location_infection_HIVpos_1st3 infection_location_infection_HIVpos_1st4 infection_location_infection_HIVpos_1st5 infection_location_infection_HIVneg_1st1 infection_location_infection_HIVneg_1st2 infection_location_infection_HIVneg_1st3 infection_location_infection_HIVneg_1st4 infection_location_infection_HIVneg_1st5 infection_location_infection_HIVpos_re1 infection_location_infection_HIVpos_re2 infection_location_infection_HIVpos_re3 infection_location_infection_HIVpos_re4 infection_location_infection_HIVpos_re5 infection_location_infection_HIVneg_re1 infection_location_infection_HIVneg_re2 infection_location_infection_HIVneg_re3 infection_location_infection_HIVneg_re4 infection_location_infection_HIVneg_re5 hhsize_person_weighted_list random_infector_list infection_location_disease_HIVpos_1st1 infection_location_disease_HIVpos_1st2 infection_location_disease_HIVpos_1st3 infection_location_disease_HIVpos_1st4 infection_location_disease_HIVpos_1st5 infection_location_disease_HIVneg_1st1 infection_location_disease_HIVneg_1st2 infection_location_disease_HIVneg_1st3 infection_location_disease_HIVneg_1st4 infection_location_disease_HIVneg_1st5 infection_location_disease_HIVpos_re1 infection_location_disease_HIVpos_re2 infection_location_disease_HIVpos_re3 infection_location_disease_HIVpos_re4 infection_location_disease_HIVpos_re5 infection_location_disease_HIVneg_re1 infection_location_disease_HIVneg_re2 infection_location_disease_HIVneg_re3 infection_location_disease_HIVneg_re4 infection_location_disease_HIVneg_re5 develop_disease_time_HIVneg_1_list develop_disease_time_HIVneg_2_list develop_disease_time_HIVneg_3_list develop_disease_time_HIVneg_4_list develop_disease_time_HIVneg_5_list develop_disease_time_HIVpos_1_list develop_disease_time_HIVpos_2_list develop_disease_time_HIVpos_3_list develop_disease_time_HIVpos_4_list develop_disease_time_HIVpos_5_list number_sus_hivpos number_early_hivpos number_late_hivpos number_extra_hivpos number_smearpos_hivpos number_smearneg_hivpos number_treatment_hivpos number_recovered_hivpos number_sus_hivneg number_early_hivneg number_late_hivneg number_extra_hivneg number_smearpos_hivneg number_smearneg_hivneg number_treatment_hivneg number_recovered_hivneg selfcure_HIVneg selfcure_HIVpos treated_HIVneg treated_HIVpos died_HIVneg died_HIVpos died_HIVneg_ontreat died_HIVpos_ontreat treat_dropout_HIVneg treat_dropout_HIVpos treat_success_HIVneg treat_success_HIVpos first_treatment second_treatment thirdplus_treatment infector_list_infection infector_list_disease potential_infector_list counted_infection_infections counted_infection_disease number_infected_list_summary number_disease_list_summary ;;;;;;;;;;;;;;;;other;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; number_triplets closed_triplets_needed total_closed_triplets_needed repeat_contact_number1_list repeat_contact_number2_list repeat_contact_number3_list duplicates_list contact_diff i1 i2 distance2_contacts_temp distance2_contacts1_list distance2_contacts2_list infectiousness_list loop_counter hh_size_list current_hh_turtleset proportion_added number_infected_list ] turtles-own [ random_contact_number repeat_contact_number_daily repeat_contact_number_weekly repeat_contact_number repeat_contact_number1 repeat_contact_number2 contacts_still_needed infection_status pre_treatment_disease_type infection_location time_exposed time_infected infectiousness susceptibility infection_number adjusted_infectiousness episode infector age hh_size number_infected HIV reinfection_relative_risk time_on_treatment number_of_treatments on_treatweight develop_disease_time ] repeat_links-own [ daily ;1 yes, 0 no ] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;setup and go;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to setup ca resize-world 0 100 0 100 nw:set-context turtles repeat_links read_in_inputs calculate_parameter_values set proportion_added 0.01 setup_people setup_hhs setup_repeat_contact seed_infection setup_lists reset-ticks end to go demography TB_processes infect HIV_processes if ticks > run_in_length [ track_prevalence ] if ticks = end_time [ create_number_infected_list create_number_infected_disease_list output_file stop ] tick end to go-once go end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;setup lists;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to setup_lists set number_infected_list [] set number_sus_hivpos [] set number_early_hivpos [] set number_late_hivpos [] set number_extra_hivpos [] set number_smearpos_hivpos [] set number_smearneg_hivpos [] set number_treatment_hivpos [] set number_recovered_hivpos [] set number_sus_hivneg [] set number_early_hivneg [] set number_late_hivneg [] set number_extra_hivneg [] set number_smearpos_hivneg [] set number_smearneg_hivneg [] set number_treatment_hivneg [] set number_recovered_hivneg [] set infector_list_infection [] set infector_list_disease [] set potential_infector_list [] set counted_infection_infections [] set counted_infection_disease [] set number_infected_list_summary [] set number_disease_list_summary [] set develop_disease_time_HIVneg_1_list [] set develop_disease_time_HIVneg_2_list [] set develop_disease_time_HIVneg_3_list [] set develop_disease_time_HIVneg_4_list [] set develop_disease_time_HIVneg_5_list [] set develop_disease_time_HIVpos_1_list [] set develop_disease_time_HIVpos_2_list [] set develop_disease_time_HIVpos_3_list [] set develop_disease_time_HIVpos_4_list [] set develop_disease_time_HIVpos_5_list [] end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;read in inputs;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to read_in_inputs set file csv:from-file (word "inputs" input_number ".csv") foreach file [ run (word "set " item 0 ? " " item 1 ?) ] set max_age (max_age - 15) end to calculate_parameter_values if infectiousness_var > 0 [set infectiousness_alp_gam (1 / infectiousness_var)] if susceptibility_var > 0 [set susceptibility_alp_gam (1 / susceptibility_var)] if var_random_contacts > 0 [set random_contacts_alp (mean_random_contacts ^ 2 / var_random_contacts)] if var_random_contacts > 0 [set random_contacts_gam (1 / (var_random_contacts / mean_random_contacts))] if var_repeat_contacts > 0 [set repeat_contacts_alp (mean_repeat_contacts ^ 2 / var_repeat_contacts)] if var_repeat_contacts > 0 [set repeat_contacts_gam (1 / (var_repeat_contacts / mean_repeat_contacts))] if var_hh_size > 0 [set hh_size_alp (mean_hh_size ^ 2 / var_hh_size)] if var_hh_size > 0 [set hh_size_gam (1 / (var_hh_size / mean_hh_size))] end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;setup people;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to setup_people create-turtles pop_size [ setxy random-xcor random-ycor ifelse var_random_contacts > 0 [set random_contact_number round random-gamma random_contacts_alp random_contacts_gam] [set random_contact_number round mean_random_contacts] ifelse var_repeat_contacts > 0 [set repeat_contact_number (random-gamma repeat_contacts_alp repeat_contacts_gam)] [set repeat_contact_number mean_repeat_contacts] set repeat_contact_number round (repeat_contact_number * prop_repeat_contacts_daily + repeat_contact_number * (1 - prop_repeat_contacts_daily) * repeat_contacts_multiplier) ifelse infectiousness_var > 0 [set infectiousness random-gamma infectiousness_alp_gam infectiousness_alp_gam] [set infectiousness 1] ifelse susceptibility_var > 0 [set susceptibility random-gamma susceptibility_alp_gam susceptibility_alp_gam] [set susceptibility 1] ifelse random-float 1 < initial_prop_HIV_pos [set HIV 1 set reinfection_relative_risk reinfection_relative_risk_HIVpos] [set HIV 0 set reinfection_relative_risk reinfection_relative_risk_HIVneg] set age random (360 * max_age) ] if (sum [repeat_contact_number] of turtles) mod 2 > 0 [ ask one-of turtles with [repeat_contact_number > 1] [ set repeat_contact_number (repeat_contact_number - 1) ] ] set number_triplets sum [repeat_contact_number * (repeat_contact_number - 1)] of turtles if clustering_coefficient > 0 [set total_closed_triplets_needed round((number_triplets * clustering_coefficient)) set closed_triplets_needed total_closed_triplets_needed] end to setup_repeat_contact let repeats 0 while [closed_triplets_needed > 0 and repeats < 100] [add_repeat_repeat_links add_clustering set repeats (repeats + 1)] set proportion_added 1 add_repeat_repeat_links final_repeat_links ask repeat_links [ if random-float 1 < prop_repeat_contacts_daily / (prop_repeat_contacts_daily + (1 - prop_repeat_contacts_daily) * repeat_contacts_multiplier) [set daily 1] ] end to add_repeat_repeat_links update_repeat_links_needed set repeat_contact_number1_list [] set repeat_contact_number2_list [] ask turtles [ repeat repeat_contact_number1 [ set repeat_contact_number1_list lput who repeat_contact_number1_list ] repeat repeat_contact_number2 [ set repeat_contact_number2_list lput who repeat_contact_number2_list ] ] set repeat_contact_number1_list shuffle repeat_contact_number1_list set repeat_contact_number2_list shuffle repeat_contact_number2_list set loop_counter 0 while [duplicates repeat_contact_number1_list repeat_contact_number2_list < length repeat_contact_number1_list] [ let position1 (duplicates repeat_contact_number1_list repeat_contact_number2_list) ifelse position1 < (length repeat_contact_number1_list - 1) [ let a1 item position1 repeat_contact_number1_list let b1 item (position1 + 1) repeat_contact_number1_list ifelse a1 = b1 [let i random length repeat_contact_number1_list set repeat_contact_number1_list replace-item position1 repeat_contact_number1_list item i repeat_contact_number1_list set repeat_contact_number1_list replace-item i repeat_contact_number1_list a1 ] [set repeat_contact_number1_list replace-item position1 repeat_contact_number1_list b1 set repeat_contact_number1_list replace-item (position1 + 1) repeat_contact_number1_list a1] ] [let a1 item position1 repeat_contact_number1_list let b1 item 0 repeat_contact_number1_list ifelse a1 = b1 [let i random length repeat_contact_number1_list set repeat_contact_number1_list replace-item position1 repeat_contact_number1_list item i repeat_contact_number1_list set repeat_contact_number1_list replace-item i repeat_contact_number1_list a1] [set repeat_contact_number1_list replace-item position1 repeat_contact_number1_list b1 set repeat_contact_number1_list replace-item 0 repeat_contact_number1_list a1]] set loop_counter (loop_counter + 1) if loop_counter > 100 [ask repeat_links [die] setup_repeat_contact] ] (foreach repeat_contact_number1_list repeat_contact_number2_list [ if random-float 1 < proportion_added [ ask turtle ?1 [create-repeat_link-with turtle ?2] ] ] ) end to update_repeat_links_needed ask turtles [ set contacts_still_needed (repeat_contact_number - count my-repeat_links) ifelse contacts_still_needed mod 2 = 0 [set repeat_contact_number1 contacts_still_needed / 2 set repeat_contact_number2 repeat_contact_number1 ] [ifelse random 2 = 0 [set repeat_contact_number1 floor (contacts_still_needed / 2) set repeat_contact_number2 ceiling (contacts_still_needed / 2)] [set repeat_contact_number2 floor (contacts_still_needed / 2) set repeat_contact_number1 ceiling (contacts_still_needed / 2)] ] ] set contact_diff ((sum [repeat_contact_number1] of turtles - sum [repeat_contact_number2] of turtles) / 2) ifelse contact_diff > 0 [ carefully [ ask n-of contact_diff turtles with [repeat_contact_number1 > 0] [set repeat_contact_number1 (repeat_contact_number1 - 1) set repeat_contact_number2 (repeat_contact_number2 + 1)] ] [ while [contact_diff > 0] [ ask one-of turtles with [repeat_contact_number1 > 0] [set repeat_contact_number1 (repeat_contact_number1 - 1) set repeat_contact_number2 (repeat_contact_number2 + 1)] set contact_diff ((sum [repeat_contact_number1] of turtles - sum [repeat_contact_number2] of turtles) / 2) ] ] ] [ carefully [ ask n-of (- contact_diff) turtles with [repeat_contact_number2 > 0] [set repeat_contact_number1 (repeat_contact_number1 + 1) set repeat_contact_number2 (repeat_contact_number2 - 1)] ] [ while [contact_diff < 0] [ ask one-of turtles with [repeat_contact_number2 > 0] [set repeat_contact_number1 (repeat_contact_number1 + 1) set repeat_contact_number2 (repeat_contact_number2 - 1)] set contact_diff ((sum [repeat_contact_number1] of turtles - sum [repeat_contact_number2] of turtles) / 2) ] ] ] end to add_clustering if closed_triplets_needed > 0 [ create_set_of_distance2 (foreach distance2_contacts1_list distance2_contacts2_list [ ask turtle ?1 [ if repeat_contact_number - count my-repeat_links > 0 [ ask turtle ?2 [ if (repeat_contact_number - count my-repeat_links > 0) and (is-repeat_link? repeat_link who [who] of myself = false) [ ask turtle ?1 [ create-repeat_link-with turtle ?2 ] ] ] ] ] ] ) set closed_triplets_needed (total_closed_triplets_needed - sum [ nw:clustering-coefficient * count my-repeat_links * (count my-repeat_links - 1) ] of turtles) ] end to final_repeat_links while [count turtles with [repeat_contact_number - count my-repeat_links > 0] > 0] [ ask turtles [let repeat_links_still_needed repeat_contact_number - count my-repeat_links if repeat_links_still_needed > 0 [ let current who repeat repeat_links_still_needed [ ifelse count other turtles with [repeat_contact_number - count my-repeat_links > 0] = 0 [ ask one-of repeat_links with [end1 != myself and end2 != myself] [die] let other_turtles turtle-set other turtles with [repeat_contact_number - count my-repeat_links > 0] ask one-of repeat_links with [end1 != myself and end2 != myself and member? end1 other_turtles = false and member? end2 other_turtles = false] [ ask end1 [create-repeat_link-with turtle current] ask end2 [create-repeat_link-with one-of other_turtles] die ] ] [ let other_turtles turtle-set other turtles with [repeat_contact_number - count my-repeat_links > 0] ask one-of repeat_links with [end1 != myself and end2 != myself and member? end1 other_turtles = false and member? end2 other_turtles = false] [ ask end1 [create-repeat_link-with turtle current] ask end2 [create-repeat_link-with one-of other_turtles] die ] ] ] ] ] ] end to create_set_of_distance2 ask turtles [set contacts_still_needed repeat_contact_number - count my-repeat_links] set distance2_contacts1_list [] set distance2_contacts2_list [] ask turtles with [contacts_still_needed > 0 and count my-repeat_links > 0] [ let me who set distance2_contacts_temp [] ask repeat_link-neighbors [ ask repeat_link-neighbors with [who > me and is-repeat_link? repeat_link who me = false and contacts_still_needed > 0] [ set distance2_contacts_temp lput who distance2_contacts_temp ] ] set distance2_contacts_temp remove-duplicates distance2_contacts_temp repeat (length distance2_contacts_temp) [set distance2_contacts1_list lput who distance2_contacts1_list] set distance2_contacts2_list sentence distance2_contacts2_list distance2_contacts_temp ] end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;setup hhs;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to setup_hhs set hh_size_list [] set hhsize_person_weighted_list [] while [sum hh_size_list < pop_size] [ ifelse var_hh_size > 0 [set hh_size_list lput (round (random-gamma hh_size_alp hh_size_gam)) hh_size_list] [set hh_size_list lput mean_hh_size hh_size_list] ] set hh_size_list remove 0 hh_size_list while [sum hh_size_list > pop_size] [ let i last hh_size_list let j (i - 1) set hh_size_list remove-item (length(hh_size_list) - 1) hh_size_list set hh_size_list lput j hh_size_list ] foreach hh_size_list [ set current_hh_turtleset n-of ? turtles with [hh_size = 0] ask current_hh_turtleset [ create-hh_links-with other current_hh_turtleset set hh_size 1 ] ] ask turtles [set hh_size count my-hh_links set hhsize_person_weighted_list lput hh_size hhsize_person_weighted_list] end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;functions;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to-report global-clustering-coefficient let closed-triplets sum [ nw:clustering-coefficient * count my-repeat_links * (count my-repeat_links - 1) ] of turtles let triplets sum [ count my-repeat_links * (count my-repeat_links - 1) ] of turtles report closed-triplets / triplets end to-report duplicates [a b] (foreach a b (n-values length a [?]) [ if ?1 = ?2 [report ?3] ] ) report (length a + 1) end to-report binomial [n p] report length filter [? < p] n-values n [random-float 1] end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;demography;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to demography ask turtles [ ifelse age > (360 * max_age) [ if (infection_status = 3 or infection_status = 4 or infection_status = 5 or infection_status = 6) and ticks > run_in_length [add_to_number_infected_list] reset_person ] [set age (age + 30)] ] end to dying_tasks if (infection_status = 3 or infection_status = 4 or infection_status = 5 or infection_status = 6) and ticks > run_in_length [ add_to_number_infected_list ifelse HIV = 0 [set died_HIVneg (died_HIVneg + 1)] [set died_HIVpos (died_HIVpos + 1)] ] if (infection_status = 4 or infection_status = 5 or (infection_status = 6 and (pre_treatment_disease_type = 4 or pre_treatment_disease_type = 5))) and ticks > run_in_length and ticks <= (end_time - 12 * 5) [ set potential_infector_list lput (1000 * who + episode) potential_infector_list ] if (infection_status = 6) and ticks > run_in_length [ ifelse HIV = 0 [set died_HIVneg_ontreat (died_HIVneg_ontreat + 1)] [set died_HIVpos_ontreat (died_HIVpos_ontreat + 1)] ] end to reset_person ifelse random-float 1 < prop_15_latent [ set infection_status 2 set time_exposed 12 * 4 let recent random-float prop_15_latent set infection_number 1 if recent < prop_15_recent_latent_annual * 4 [ set infection_status 1 set time_exposed 12 * 3 if recent < prop_15_recent_latent_annual * 3 [ set time_exposed 12 * 2 if recent < prop_15_recent_latent_annual * 2 [ set time_exposed 12 if recent < prop_15_recent_latent_annual [ set time_exposed 0 ] ] ] ] ] [set time_exposed 0 set infection_status 0 set infection_number 0] set age 0 set time_infected 0 ifelse infectiousness_var > 0 [set infectiousness random-gamma infectiousness_alp_gam infectiousness_alp_gam] [set infectiousness 1] ifelse susceptibility_var > 0 [set susceptibility random-gamma susceptibility_alp_gam susceptibility_alp_gam] [set susceptibility 1] set number_infected 0 set episode 0 set infector 0 set time_on_treatment 0 set number_of_treatments 0 ifelse random-float 1 < prop_15_HIV_pos [set HIV 1 set reinfection_relative_risk reinfection_relative_risk_HIVpos] [set HIV 0 set reinfection_relative_risk reinfection_relative_risk_HIVneg] set infection_location 0 end to switch_people let switcher 0 ask one-of other turtles [ set switcher who ] set infection_status [infection_status] of turtle who set age [age] of turtle who set time_exposed [time_exposed] of turtle who set time_infected [time_infected] of turtle who set infectiousness [infectiousness] of turtle who set susceptibility [susceptibility] of turtle who set number_infected [number_infected] of turtle who set time_on_treatment [time_on_treatment] of turtle who set infection_number [infection_number] of turtle who set number_of_treatments [number_of_treatments] of turtle who set HIV [HIV] of turtle who set reinfection_relative_risk [reinfection_relative_risk] of turtle who set infection_location [infection_location] of turtle who set adjusted_infectiousness [adjusted_infectiousness] of turtle who set infector [infector] of turtle who set episode [episode] of turtle who ask turtle who [reset_person] end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;seed infection;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to seed_infection ask n-of seed_number turtles [ set infection_status 5 set adjusted_infectiousness (infectiousness) set time_exposed 0 set time_infected -1 ] end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;TB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to TB_processes self_cure TB_kill TB_treat smear_convert develop_disease latent_progress end to self_cure ask turtles with [infection_status = 4 or infection_status = 5] [ ifelse HIV = 0 [ if random-float 1 < self_cure_rate [ set infection_status 2 if ticks > run_in_length [ add_to_number_infected_list set selfcure_HIVneg (selfcure_HIVneg + 1) if ticks > run_in_length and ticks <= (end_time - 12 * 5) [ set potential_infector_list lput (1000 * who + episode) potential_infector_list ] ] set number_infected 0 ] ] [ if random-float 1 < self_cure_rate * reduced_self_cure_HIVpos [ set infection_status 2 if ticks > run_in_length [ add_to_number_infected_list set selfcure_HIVpos (selfcure_HIVpos + 1) if ticks > run_in_length and ticks <= (end_time - 12 * 5) [ set potential_infector_list lput (1000 * who + episode) potential_infector_list ] ] set number_infected 0 ] ] ] end to TB_kill ask turtles with [infection_status = 3 or (infection_status = 6 and pre_treatment_disease_type = 3)] [ ifelse infection_status = 6 [ ifelse HIV = 0 [set on_treatweight reduced_TB_mortality_treatment_HIVneg] [set on_treatweight reduced_TB_mortality_treatment_HIVpos] ] [set on_treatweight 1] ifelse HIV = 0 [ if random-float 1 < 1 - (1 - TB_mortality_rate_smearpos_HIVneg) ^ on_treatweight [ dying_tasks switch_people ] ] [ if random-float 1 < 1 - (1 - TB_mortality_rate_smearpos_HIVpos) ^ on_treatweight [ dying_tasks switch_people ] ] ] ask turtles with [infection_status = 4 or (infection_status = 6 and pre_treatment_disease_type = 4)] [ ifelse infection_status = 6 [ ifelse HIV = 0 [set on_treatweight reduced_TB_mortality_treatment_HIVneg] [set on_treatweight reduced_TB_mortality_treatment_HIVpos] ] [set on_treatweight 1] ifelse HIV = 0 [ if random-float 1 < 1 - (1 - TB_mortality_rate_smearneg_HIVneg) ^ on_treatweight [ dying_tasks switch_people ] ] [ if random-float 1 < 1 - (1 - TB_mortality_rate_smearneg_HIVpos) ^ on_treatweight [ dying_tasks switch_people ] ] ] ask turtles with [infection_status = 5 or (infection_status = 6 and pre_treatment_disease_type = 5)] [ ifelse infection_status = 6 [ ifelse HIV = 0 [set on_treatweight reduced_TB_mortality_treatment_HIVneg] [set on_treatweight reduced_TB_mortality_treatment_HIVpos] ] [set on_treatweight 1] ifelse HIV = 0 [ if random-float 1 < 1 - (1 - TB_mortality_rate_smearpos_HIVneg) ^ on_treatweight [ dying_tasks switch_people ] ] [ if random-float 1 < 1 - (1 - TB_mortality_rate_smearpos_HIVpos) ^ on_treatweight [ dying_tasks switch_people ] ] ] end to TB_treat ask turtles with [infection_status = 6] [ ifelse time_on_treatment > 5 [ if ticks > run_in_length [ add_to_number_infected_list ifelse HIV = 0 [set treat_success_HIVneg (treat_success_HIVneg + 1)] [set treat_success_HIVpos (treat_success_HIVpos + 1)] if ticks > run_in_length and ticks <= (end_time - 12 * 5) and (pre_treatment_disease_type = 4 or pre_treatment_disease_type = 5) [ set potential_infector_list lput (1000 * who + episode) potential_infector_list ] ] set infection_status 7 ] [ ifelse HIV = 0 [ if random-float 1 < TB_treatment_dropout_rate_HIVneg [ set infection_status pre_treatment_disease_type if ticks > run_in_length [set treat_dropout_HIVneg (treat_dropout_HIVneg + 1)] ] ] [ if random-float 1 < TB_treatment_dropout_rate_HIVpos [ set infection_status pre_treatment_disease_type if ticks > run_in_length [set treat_dropout_HIVpos (treat_dropout_HIVpos + 1)] ] ] set time_on_treatment (time_on_treatment + 1) ] ] ask turtles with [infection_status = 3 and HIV = 0] [ if random-float 1 < treatment_rate_extra_HIVneg [ if ticks > run_in_length [ set treated_HIVneg (treated_HIVneg + 1) ifelse number_of_treatments = 0 [set first_treatment (first_treatment + 1)] [ ifelse number_of_treatments = 1 [set second_treatment (second_treatment + 1)] [set thirdplus_treatment (thirdplus_treatment + 1)] ] ] set pre_treatment_disease_type infection_status set infection_status 6 set number_of_treatments (number_of_treatments + 1) set time_on_treatment 0 set number_infected 0] ] ask turtles with [infection_status = 3 and HIV = 1] [ if random-float 1 < treatment_rate_extra_HIVpos [ if ticks > run_in_length [ set treated_HIVpos (treated_HIVpos + 1) ifelse number_of_treatments = 0 [set first_treatment (first_treatment + 1)] [ ifelse number_of_treatments = 1 [set second_treatment (second_treatment + 1)] [set thirdplus_treatment (thirdplus_treatment + 1)] ] ] set pre_treatment_disease_type infection_status set infection_status 6 set number_of_treatments (number_of_treatments + 1) set time_on_treatment 0 set number_infected 0] ] ask turtles with [infection_status = 4 and HIV = 0] [ if random-float 1 < treatment_rate_smearneg_HIVneg [ if ticks > run_in_length [ set treated_HIVneg (treated_HIVneg + 1) ifelse number_of_treatments = 0 [set first_treatment (first_treatment + 1)] [ ifelse number_of_treatments = 1 [set second_treatment (second_treatment + 1)] [set thirdplus_treatment (thirdplus_treatment + 1)] ] ] set pre_treatment_disease_type infection_status set infection_status 6 set number_of_treatments (number_of_treatments + 1) set time_on_treatment 0 set number_infected 0] ] ask turtles with [infection_status = 4 and HIV = 1] [ if random-float 1 < treatment_rate_smearneg_HIVpos [ if ticks > run_in_length [ set treated_HIVpos (treated_HIVpos + 1) ifelse number_of_treatments = 0 [set first_treatment (first_treatment + 1)] [ ifelse number_of_treatments = 1 [set second_treatment (second_treatment + 1)] [set thirdplus_treatment (thirdplus_treatment + 1)] ] ] set pre_treatment_disease_type infection_status set infection_status 6 set number_of_treatments (number_of_treatments + 1) set time_on_treatment 0 set number_infected 0] ] ask turtles with [infection_status = 5 and HIV = 0] [ if random-float 1 < treatment_rate_smearpos_HIVneg [ if ticks > run_in_length [ set treated_HIVneg (treated_HIVneg + 1) ifelse number_of_treatments = 0 [set first_treatment (first_treatment + 1)] [ ifelse number_of_treatments = 1 [set second_treatment (second_treatment + 1)] [set thirdplus_treatment (thirdplus_treatment + 1)] ] ] set pre_treatment_disease_type infection_status set infection_status 6 set number_of_treatments (number_of_treatments + 1) set time_on_treatment 0 set number_infected 0] ] ask turtles with [infection_status = 5 and HIV = 1] [ if random-float 1 < treatment_rate_smearpos_HIVpos [ if ticks > run_in_length [ set treated_HIVpos (treated_HIVpos + 1) ifelse number_of_treatments = 0 [set first_treatment (first_treatment + 1)] [ ifelse number_of_treatments = 1 [set second_treatment (second_treatment + 1)] [set thirdplus_treatment (thirdplus_treatment + 1)] ] ] set pre_treatment_disease_type infection_status set infection_status 6 set number_of_treatments (number_of_treatments + 1) set time_on_treatment 0 set number_infected 0] ] end to smear_convert ask turtles with [infection_status = 4] [ ifelse HIV = 0 [ if random-float 1 < develop_smearpos_rate_HIVneg [set infection_status 5 set adjusted_infectiousness (infectiousness)] ] [ if random-float 1 < develop_smearpos_rate_HIVpos [set infection_status 5 set adjusted_infectiousness (infectiousness)] ] ] end to develop_disease ask turtles with [infection_status = 1 or infection_status = 2] [ ifelse HIV = 0 [ ifelse infection_status = 1 [ ifelse time_exposed < 12 [ if random-float 1 < 1 - exp(- develop_tb_y1_rate * (prop_sus_var_infection + (1 - prop_sus_var_infection) * susceptibility)) [set develop_disease_time 0 develop_disease_process] ] [ifelse time_exposed < 12 * 2 [ if random-float 1 < 1 - exp(- develop_tb_y2_rate * (prop_sus_var_infection + (1 - prop_sus_var_infection) * susceptibility)) [set develop_disease_time 1 develop_disease_process] ] [ifelse time_exposed < 12 * 3 [ if random-float 1 < 1 - exp(- develop_tb_y3_rate * (prop_sus_var_infection + (1 - prop_sus_var_infection) * susceptibility)) [set develop_disease_time 2 develop_disease_process] ] [ifelse time_exposed < 12 * 4 [ if random-float 1 < 1 - exp(- develop_tb_y4_rate * (prop_sus_var_infection + (1 - prop_sus_var_infection) * susceptibility)) [set develop_disease_time 3 develop_disease_process] ] [if random-float 1 < 1 - exp(- develop_tb_y5_rate * (prop_sus_var_infection + (1 - prop_sus_var_infection) * susceptibility)) [set develop_disease_time 4 develop_disease_process]]]]] ] [ if random-float 1 < 1 - exp(- develop_tb_reactivation_rate * (prop_sus_var_infection + (1 - prop_sus_var_infection) * susceptibility)) [set develop_disease_time 5 develop_disease_process] ] ] [ifelse infection_status = 1 [ ifelse time_exposed < 12 [ if random-float 1 < 1 - exp(- develop_tb_y1_rate * (prop_sus_var_infection + (1 - prop_sus_var_infection) * susceptibility) * HIV_increased_risk_develop_disease) [set develop_disease_time 0 develop_disease_process] ] [ifelse time_exposed < 12 * 2 [ if random-float 1 < 1 - exp(- develop_tb_y2_rate * (prop_sus_var_infection + (1 - prop_sus_var_infection) * susceptibility) * HIV_increased_risk_reactivation) [set develop_disease_time 1 develop_disease_process] ] [ifelse time_exposed < 12 * 3 [ if random-float 1 < 1 - exp(- develop_tb_y3_rate * (prop_sus_var_infection + (1 - prop_sus_var_infection) * susceptibility) * HIV_increased_risk_reactivation) [set develop_disease_time 2 develop_disease_process] ] [ifelse time_exposed < 12 * 4 [ if random-float 1 < 1 - exp(- develop_tb_y4_rate * (prop_sus_var_infection + (1 - prop_sus_var_infection) * susceptibility) * HIV_increased_risk_reactivation) [set develop_disease_time 3 develop_disease_process] ] [if random-float 1 < 1 - exp(- develop_tb_y5_rate * (prop_sus_var_infection + (1 - prop_sus_var_infection) * susceptibility) * HIV_increased_risk_reactivation) [set develop_disease_time 4 develop_disease_process]]]]] ] [ if random-float 1 < 1 - exp(- develop_tb_reactivation_rate * (prop_sus_var_infection + (1 - prop_sus_var_infection) * susceptibility) * HIV_increased_risk_reactivation) [set develop_disease_time 5 develop_disease_process] ] ] ] end to develop_disease_process ;called by people chosen to develop disease set episode (episode + 1) ifelse HIV = 0 [ ifelse random-float 1 < prop_extrapulmonary_HIVneg [set infection_status 3 set adjusted_infectiousness 0] [ifelse random-float 1 < prop_pul_smearpos_HIVneg [set infection_status 5 set adjusted_infectiousness (infectiousness) set infector_list_disease lput infector infector_list_disease] [set infection_status 4 set adjusted_infectiousness (infectiousness * reduced_transmission_smearneg) set infector_list_disease lput infector infector_list_disease] ] ] [ ifelse random-float 1 < prop_extrapulmonary_HIVpos [set infection_status 3 set adjusted_infectiousness 0] [ifelse random-float 1 < prop_pul_smearpos_HIVpos [set infection_status 5 set adjusted_infectiousness (infectiousness) set infector_list_disease lput infector infector_list_disease] [set infection_status 4 set adjusted_infectiousness (infectiousness * reduced_transmission_smearneg) set infector_list_disease lput infector infector_list_disease] ] ] if ticks > run_in_length and infection_location > 0 [ ifelse infection_number = 1 [ ifelse HIV = 1 [ ifelse infection_location = 1 [set infection_location_disease_HIVpos_1st1 (infection_location_disease_HIVpos_1st1 + 1) set develop_disease_time_HIVpos_1_list lput develop_disease_time develop_disease_time_HIVpos_1_list] [ ifelse infection_location = 2 [set infection_location_disease_HIVpos_1st2 (infection_location_disease_HIVpos_1st2 + 1) set develop_disease_time_HIVpos_2_list lput develop_disease_time develop_disease_time_HIVpos_2_list] [ ifelse infection_location = 3 [set infection_location_disease_HIVpos_1st3 (infection_location_disease_HIVpos_1st3 + 1) set develop_disease_time_HIVpos_3_list lput develop_disease_time develop_disease_time_HIVpos_3_list] [ ifelse infection_location = 4 [set infection_location_disease_HIVpos_1st4 (infection_location_disease_HIVpos_1st4 + 1) set develop_disease_time_HIVpos_4_list lput develop_disease_time develop_disease_time_HIVpos_4_list] [set infection_location_disease_HIVpos_1st5 (infection_location_disease_HIVpos_1st5 + 1) set develop_disease_time_HIVpos_5_list lput develop_disease_time develop_disease_time_HIVpos_5_list] ] ] ] ] [ ifelse infection_location = 1 [set infection_location_disease_HIVneg_1st1 (infection_location_disease_HIVneg_1st1 + 1) set develop_disease_time_HIVneg_1_list lput develop_disease_time develop_disease_time_HIVneg_1_list] [ ifelse infection_location = 2 [set infection_location_disease_HIVneg_1st2 (infection_location_disease_HIVneg_1st2 + 1) set develop_disease_time_HIVneg_2_list lput develop_disease_time develop_disease_time_HIVneg_2_list] [ ifelse infection_location = 3 [set infection_location_disease_HIVneg_1st3 (infection_location_disease_HIVneg_1st3 + 1) set develop_disease_time_HIVneg_3_list lput develop_disease_time develop_disease_time_HIVneg_3_list] [ ifelse infection_location = 4 [set infection_location_disease_HIVneg_1st4 (infection_location_disease_HIVneg_1st4 + 1) set develop_disease_time_HIVneg_4_list lput develop_disease_time develop_disease_time_HIVneg_4_list] [set infection_location_disease_HIVneg_1st5 (infection_location_disease_HIVneg_1st5 + 1) set develop_disease_time_HIVneg_5_list lput develop_disease_time develop_disease_time_HIVneg_5_list] ] ] ] ] ] [ ifelse HIV = 1 [ ifelse infection_location = 1 [set infection_location_disease_HIVpos_re1 (infection_location_disease_HIVpos_re1 + 1) set develop_disease_time_HIVpos_1_list lput develop_disease_time develop_disease_time_HIVpos_1_list] [ ifelse infection_location = 2 [set infection_location_disease_HIVpos_re2 (infection_location_disease_HIVpos_re2 + 1) set develop_disease_time_HIVpos_2_list lput develop_disease_time develop_disease_time_HIVpos_2_list] [ ifelse infection_location = 3 [set infection_location_disease_HIVpos_re3 (infection_location_disease_HIVpos_re3 + 1) set develop_disease_time_HIVpos_3_list lput develop_disease_time develop_disease_time_HIVpos_3_list] [ ifelse infection_location = 4 [set infection_location_disease_HIVpos_re4 (infection_location_disease_HIVpos_re4 + 1) set develop_disease_time_HIVpos_4_list lput develop_disease_time develop_disease_time_HIVpos_4_list] [set infection_location_disease_HIVpos_re5 (infection_location_disease_HIVpos_re5 + 1) set develop_disease_time_HIVpos_5_list lput develop_disease_time develop_disease_time_HIVpos_5_list] ] ] ] ] [ ifelse infection_location = 1 [set infection_location_disease_HIVneg_re1 (infection_location_disease_HIVneg_re1 + 1) set develop_disease_time_HIVneg_1_list lput develop_disease_time develop_disease_time_HIVneg_1_list] [ ifelse infection_location = 2 [set infection_location_disease_HIVneg_re2 (infection_location_disease_HIVneg_re2 + 1) set develop_disease_time_HIVneg_2_list lput develop_disease_time develop_disease_time_HIVneg_2_list] [ ifelse infection_location = 3 [set infection_location_disease_HIVneg_re3 (infection_location_disease_HIVneg_re3 + 1) set develop_disease_time_HIVneg_3_list lput develop_disease_time develop_disease_time_HIVneg_3_list] [ ifelse infection_location = 4 [set infection_location_disease_HIVneg_re4 (infection_location_disease_HIVneg_re4 + 1) set develop_disease_time_HIVneg_4_list lput develop_disease_time develop_disease_time_HIVneg_4_list] [set infection_location_disease_HIVneg_re5 (infection_location_disease_HIVneg_re5 + 1) set develop_disease_time_HIVneg_5_list lput develop_disease_time develop_disease_time_HIVneg_5_list] ] ] ] ] ] ] end to latent_progress ask turtles with [infection_status = 1] [ ifelse time_exposed > 5 * 12 [ set infection_status 2 ] [ set time_exposed (time_exposed + 1) ] ] end to add_to_number_infected_list set number_infected_list lput number_infected number_infected_list end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;infect;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to infect infect_hh infect_repeat infect_random end to infect_hh ask turtles with [infection_status = 3 or infection_status = 4 or infection_status = 5] [ ask hh_link-neighbors with [infection_status = 0 or infection_status = 1 or infection_status = 2 or infection_status = 7] [ ifelse infection_status = 0 [ if random-float 1 < 1 - exp(- transmission_prob * (1 - prop_sus_var_infection + prop_sus_var_infection * susceptibility) * [adjusted_infectiousness] of myself * contact_duration_hh * 30) [ set infection_status 1 set time_exposed 0 set infection_number (infection_number + 1) if ticks > run_in_length [ set infection_location 1 ifelse HIV = 1 [set infection_location_infection_HIVpos_1st1 (infection_location_infection_HIVpos_1st1 + 1)] [set infection_location_infection_HIVneg_1st1 (infection_location_infection_HIVneg_1st1 + 1)] ] ask turtle [who] of myself [set number_infected (number_infected + 1)] set infector ([who] of myself * 1000 + [episode] of myself) set infector_list_infection lput infector infector_list_infection ] ] [ if random-float 1 < 1 - exp(- transmission_prob * (1 - prop_sus_var_infection + prop_sus_var_infection * susceptibility) * [adjusted_infectiousness] of myself * contact_duration_hh * reinfection_relative_risk * 30) [ set infection_status 1 set infection_location 1 set time_exposed 0 set infection_number (infection_number + 1) if ticks > run_in_length [ set infection_location 1 ifelse HIV = 1 [set infection_location_infection_HIVpos_re1 (infection_location_infection_HIVpos_re1 + 1)] [set infection_location_infection_HIVneg_re1 (infection_location_infection_HIVneg_re1 + 1)] ] ask turtle [who] of myself [set number_infected (number_infected + 1)] set infector ([who] of myself * 1000 + [episode] of myself) set infector_list_infection lput infector infector_list_infection ] ] ] ] end to infect_repeat ask turtles with [infection_status = 3 or infection_status = 4 or infection_status = 5] [ ask repeat_link-neighbors with [infection_status = 0 or infection_status = 1 or infection_status = 2 or infection_status = 7] [ ifelse [daily] of link-with myself = 1 [ ifelse infection_status = 0 [ if random-float 1 < 1 - exp(- transmission_prob * (1 - prop_sus_var_infection + prop_sus_var_infection * susceptibility) * [adjusted_infectiousness] of myself * contact_duration_repeat_daily * 30) [ set infection_status 1 set time_exposed 0 set infection_number (infection_number + 1) if ticks > run_in_length [ set infection_location 2 ifelse HIV = 1 [set infection_location_infection_HIVpos_1st2 (infection_location_infection_HIVpos_1st2 + 1)] [set infection_location_infection_HIVneg_1st2 (infection_location_infection_HIVneg_1st2 + 1)] ] ask turtle [who] of myself [set number_infected (number_infected + 1)] set infector ([who] of myself * 1000 + [episode] of myself) set infector_list_infection lput infector infector_list_infection ] ] [ if random-float 1 < 1 - exp(- transmission_prob * (1 - prop_sus_var_infection + prop_sus_var_infection * susceptibility) * [adjusted_infectiousness] of myself * contact_duration_repeat_daily * reinfection_relative_risk * 30) [ set infection_status 1 set time_exposed 0 set infection_number (infection_number + 1) if ticks > run_in_length [ set infection_location 2 ifelse HIV = 1 [set infection_location_infection_HIVpos_re2 (infection_location_infection_HIVpos_re2 + 1)] [set infection_location_infection_HIVneg_re2 (infection_location_infection_HIVneg_re2 + 1)] ] ask turtle [who] of myself [set number_infected (number_infected + 1)] set infector ([who] of myself * 1000 + [episode] of myself) set infector_list_infection lput infector infector_list_infection ] ] ] [ let contact_num binomial 30 (1 / repeat_contacts_multiplier) if contact_num > 0 [ ifelse infection_status = 0 [ if random-float 1 < 1 - exp(- transmission_prob * (1 - prop_sus_var_infection + prop_sus_var_infection * susceptibility) * [adjusted_infectiousness] of myself * contact_duration_repeat_weekly * contact_num) [ set infection_status 1 set time_exposed 0 set infection_number (infection_number + 1) if ticks > run_in_length [ set infection_location 3 ifelse HIV = 1 [set infection_location_infection_HIVpos_1st3 (infection_location_infection_HIVpos_1st3 + 1)] [set infection_location_infection_HIVneg_1st3 (infection_location_infection_HIVneg_1st3 + 1)] ] ask turtle [who] of myself [set number_infected (number_infected + 1)] set infector ([who] of myself * 1000 + [episode] of myself) set infector_list_infection lput infector infector_list_infection ] ] [ if random-float 1 < 1 - exp(- transmission_prob * (1 - prop_sus_var_infection + prop_sus_var_infection * susceptibility) * [adjusted_infectiousness] of myself * contact_duration_repeat_weekly * reinfection_relative_risk * contact_num) [ set infection_status 1 set time_exposed 0 set infection_number (infection_number + 1) if ticks > run_in_length [ set infection_location 3 ifelse HIV = 1 [set infection_location_infection_HIVpos_re3 (infection_location_infection_HIVpos_re3 + 1)] [set infection_location_infection_HIVneg_re3 (infection_location_infection_HIVneg_re3 + 1)] ] ask turtle [who] of myself [set number_infected (number_infected + 1)] set infector ([who] of myself * 1000 + [episode] of myself) set infector_list_infection lput infector infector_list_infection ] ] ] ] ] ] end to infect_random let total_random_contacts 30 * sum [random_contact_number] of turtles with [infection_status = 3 or infection_status = 4 or infection_status = 5] set infectiousness_list [] set random_infector_list [] ask turtles with [infection_status = 3 or infection_status = 4 or infection_status = 5] [ repeat 30 * random_contact_number [ set infectiousness_list lput adjusted_infectiousness infectiousness_list set random_infector_list lput who random_infector_list ] ] (foreach (rnd:weighted-n-of-with-repeats total_random_contacts turtles [random_contact_number]) infectiousness_list random_infector_list [ ask ?1 [ ifelse random-float 1 < prob_talk_random_contact [ if infection_status = 0 or infection_status = 1 or infection_status = 2 or infection_status = 7 [ ifelse infection_status = 0 [ if random-float 1 < 1 - exp(- transmission_prob * (1 - prop_sus_var_infection + prop_sus_var_infection * susceptibility) * ?2 * contact_duration_random_talk) [ set infection_status 1 set time_exposed 0 set infection_number (infection_number + 1) if ticks > run_in_length [ set infection_location 4 ifelse HIV = 1 [set infection_location_infection_HIVpos_1st4 (infection_location_infection_HIVpos_1st4 + 1)] [set infection_location_infection_HIVneg_1st4 (infection_location_infection_HIVneg_1st4 + 1)] ] ask turtle ?3 [set number_infected (number_infected + 1)] set infector ([who] of turtle ?3 * 1000 + [episode] of turtle ?3) set infector_list_infection lput infector infector_list_infection ] ] [ if random-float 1 < 1 - exp(- transmission_prob * (1 - prop_sus_var_infection + prop_sus_var_infection * susceptibility) * ?2 * reinfection_relative_risk * contact_duration_random_talk) [ set infection_status 1 set time_exposed 0 set infection_number (infection_number + 1) if ticks > run_in_length [ set infection_location 4 ifelse HIV = 1 [set infection_location_infection_HIVpos_re4 (infection_location_infection_HIVpos_re4 + 1)] [set infection_location_infection_HIVneg_re4 (infection_location_infection_HIVneg_re4 + 1)] ] ask turtle ?3 [set number_infected (number_infected + 1)] set infector ([who] of turtle ?3 * 1000 + [episode] of turtle ?3) set infector_list_infection lput infector infector_list_infection ] ] ] ] [ if infection_status = 0 or infection_status = 1 or infection_status = 2 or infection_status = 7 [ ifelse infection_status = 0 [ if random-float 1 < 1 - exp(- transmission_prob * (1 - prop_sus_var_infection + prop_sus_var_infection * susceptibility) * ?2 * transmission_prob_notalk_weight * contact_duration_random_nontalk) [ set infection_status 1 set time_exposed 0 set infection_number (infection_number + 1) if ticks > run_in_length [ set infection_location 5 ifelse HIV = 1 [set infection_location_infection_HIVpos_1st5 (infection_location_infection_HIVpos_1st5 + 1)] [set infection_location_infection_HIVneg_1st5 (infection_location_infection_HIVneg_1st5 + 1)] ] ask turtle ?3 [set number_infected (number_infected + 1)] set infector ([who] of turtle ?3 * 1000 + [episode] of turtle ?3) set infector_list_infection lput infector infector_list_infection ] ] [ if random-float 1 < 1 - exp(- transmission_prob * (1 - prop_sus_var_infection + prop_sus_var_infection * susceptibility) * ?2 * reinfection_relative_risk * transmission_prob_notalk_weight * contact_duration_random_nontalk) [ set infection_status 1 set time_exposed 0 set infection_number (infection_number + 1) if ticks > run_in_length [ set infection_location 5 ifelse HIV = 1 [set infection_location_infection_HIVpos_re5 (infection_location_infection_HIVpos_re5 + 1)] [set infection_location_infection_HIVneg_re5 (infection_location_infection_HIVneg_re5 + 1)] ] ask turtle ?3 [set number_infected (number_infected + 1)] set infector ([who] of turtle ?3 * 1000 + [episode] of turtle ?3) set infector_list_infection lput infector infector_list_infection ] ] ] ] ] ] ) end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;HIV;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to HIV_processes ask turtles with [HIV = 0] [ if random-float 1 < HIV_infection_rate [set HIV 1 set reinfection_relative_risk reinfection_relative_risk_HIVpos] ] end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;output;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to track_prevalence set number_sus_hivpos lput (count turtles with [infection_status = 0 and HIV = 1]) number_sus_hivpos set number_early_hivpos lput (count turtles with [infection_status = 1 and HIV = 1]) number_early_hivpos set number_late_hivpos lput (count turtles with [infection_status = 2 and HIV = 1]) number_late_hivpos set number_extra_hivpos lput (count turtles with [infection_status = 3 and HIV = 1]) number_extra_hivpos set number_smearpos_hivpos lput (count turtles with [infection_status = 4 and HIV = 1]) number_smearpos_hivpos set number_smearneg_hivpos lput (count turtles with [infection_status = 5 and HIV = 1]) number_smearneg_hivpos set number_treatment_hivpos lput (count turtles with [infection_status = 6 and HIV = 1]) number_treatment_hivpos set number_recovered_hivpos lput (count turtles with [infection_status = 7 and HIV = 1]) number_recovered_hivpos set number_sus_hivneg lput (count turtles with [infection_status = 0 and HIV = 0]) number_sus_hivneg set number_early_hivneg lput (count turtles with [infection_status = 1 and HIV = 0]) number_early_hivneg set number_late_hivneg lput (count turtles with [infection_status = 2 and HIV = 0]) number_late_hivneg set number_extra_hivneg lput (count turtles with [infection_status = 3 and HIV = 0]) number_extra_hivneg set number_smearpos_hivneg lput (count turtles with [infection_status = 4 and HIV = 0]) number_smearpos_hivneg set number_smearneg_hivneg lput (count turtles with [infection_status = 5 and HIV = 0]) number_smearneg_hivneg set number_treatment_hivneg lput (count turtles with [infection_status = 6 and HIV = 0]) number_treatment_hivneg set number_recovered_hivneg lput (count turtles with [infection_status = 7 and HIV = 0]) number_recovered_hivneg end to output_file output-type (word ("file_number") ",") output-type (word ("proportion_infected") ",") output-type (word ("infection_location_infection_HIVpos_1st1") ",") output-type (word ("infection_location_infection_HIVpos_1st2") ",") output-type (word ("infection_location_infection_HIVpos_1st3") ",") output-type (word ("infection_location_infection_HIVpos_1st4") ",") output-type (word ("infection_location_infection_HIVpos_1st5") ",") output-type (word ("infection_location_infection_HIVneg_1st1") ",") output-type (word ("infection_location_infection_HIVneg_1st2") ",") output-type (word ("infection_location_infection_HIVneg_1st3") ",") output-type (word ("infection_location_infection_HIVneg_1st4") ",") output-type (word ("infection_location_infection_HIVneg_1st5") ",") output-type (word ("infection_location_infection_HIVpos_re1") ",") output-type (word ("infection_location_infection_HIVpos_re2") ",") output-type (word ("infection_location_infection_HIVpos_re3") ",") output-type (word ("infection_location_infection_HIVpos_re4") ",") output-type (word ("infection_location_infection_HIVpos_re5") ",") output-type (word ("infection_location_infection_HIVneg_re1") ",") output-type (word ("infection_location_infection_HIVneg_re2") ",") output-type (word ("infection_location_infection_HIVneg_re3") ",") output-type (word ("infection_location_infection_HIVneg_re4") ",") output-type (word ("infection_location_infection_HIVneg_re5") ",") output-type (word ("infection_location_disease_HIVpos_1st1") ",") output-type (word ("infection_location_disease_HIVpos_1st2") ",") output-type (word ("infection_location_disease_HIVpos_1st3") ",") output-type (word ("infection_location_disease_HIVpos_1st4") ",") output-type (word ("infection_location_disease_HIVpos_1st5") ",") output-type (word ("infection_location_disease_HIVneg_1st1") ",") output-type (word ("infection_location_disease_HIVneg_1st2") ",") output-type (word ("infection_location_disease_HIVneg_1st3") ",") output-type (word ("infection_location_disease_HIVneg_1st4") ",") output-type (word ("infection_location_disease_HIVneg_1st5") ",") output-type (word ("infection_location_disease_HIVpos_re1") ",") output-type (word ("infection_location_disease_HIVpos_re2") ",") output-type (word ("infection_location_disease_HIVpos_re3") ",") output-type (word ("infection_location_disease_HIVpos_re4") ",") output-type (word ("infection_location_disease_HIVpos_re5") ",") output-type (word ("infection_location_disease_HIVneg_re1") ",") output-type (word ("infection_location_disease_HIVneg_re2") ",") output-type (word ("infection_location_disease_HIVneg_re3") ",") output-type (word ("infection_location_disease_HIVneg_re4") ",") output-type (word ("infection_location_disease_HIVneg_re5") ",") output-type (word ("clustering_coefficient") ",") output-type (word ("mean_hh_size") ",") output-type (word ("number_sus_hivpos") ",") output-type (word ("number_early_hivpos") ",") output-type (word ("number_late_hivpos") ",") output-type (word ("number_extra_hivpos") ",") output-type (word ("number_smearpos_hivpos") ",") output-type (word ("number_smearneg_hivpos") ",") output-type (word ("number_treatment_hivpos") ",") output-type (word ("number_recovered_hivpos") ",") output-type (word ("number_sus_hivneg") ",") output-type (word ("number_early_hivneg") ",") output-type (word ("number_late_hivneg") ",") output-type (word ("number_extra_hivneg") ",") output-type (word ("number_smearpos_hivneg") ",") output-type (word ("number_smearneg_hivneg") ",") output-type (word ("number_treatment_hivneg") ",") output-type (word ("number_recovered_hivneg") ",") output-type (word ("selfcure_HIVneg") ",") output-type (word ("selfcure_HIVpos") ",") output-type (word ("treated_HIVneg") ",") output-type (word ("treated_HIVpos") ",") output-type (word ("died_HIVneg") ",") output-type (word ("died_HIVpos") ",") output-type (word ("died_HIVneg_ontreat") ",") output-type (word ("died_HIVpos_ontreat") ",") output-type (word ("treat_dropout_HIVneg") ",") output-type (word ("treat_dropout_HIVpos") ",") output-type (word ("treat_success_HIVneg") ",") output-type (word ("treat_success_HIVpos") ",") output-type (word ("first_treatment") ",") output-type (word ("second_treatment") ",") output-type (word ("thirdplus_treatment") ",") output-type (word ("output_pys") ",") output-type (word ("disease_time_HIVneg_time0_loc1") ",") output-type (word ("disease_time_HIVneg_time1_loc1") ",") output-type (word ("disease_time_HIVneg_time2_loc1") ",") output-type (word ("disease_time_HIVneg_time3_loc1") ",") output-type (word ("disease_time_HIVneg_time4_loc1") ",") output-type (word ("disease_time_HIVneg_time5_loc1") ",") output-type (word ("disease_time_HIVneg_time0_loc2") ",") output-type (word ("disease_time_HIVneg_time1_loc2") ",") output-type (word ("disease_time_HIVneg_time2_loc2") ",") output-type (word ("disease_time_HIVneg_time3_loc2") ",") output-type (word ("disease_time_HIVneg_time4_loc2") ",") output-type (word ("disease_time_HIVneg_time5_loc2") ",") output-type (word ("disease_time_HIVneg_time0_loc3") ",") output-type (word ("disease_time_HIVneg_time1_loc3") ",") output-type (word ("disease_time_HIVneg_time2_loc3") ",") output-type (word ("disease_time_HIVneg_time3_loc3") ",") output-type (word ("disease_time_HIVneg_time4_loc3") ",") output-type (word ("disease_time_HIVneg_time5_loc3") ",") output-type (word ("disease_time_HIVneg_time0_loc4") ",") output-type (word ("disease_time_HIVneg_time1_loc4") ",") output-type (word ("disease_time_HIVneg_time2_loc4") ",") output-type (word ("disease_time_HIVneg_time3_loc4") ",") output-type (word ("disease_time_HIVneg_time4_loc4") ",") output-type (word ("disease_time_HIVneg_time5_loc4") ",") output-type (word ("disease_time_HIVneg_time0_loc5") ",") output-type (word ("disease_time_HIVneg_time1_loc5") ",") output-type (word ("disease_time_HIVneg_time2_loc5") ",") output-type (word ("disease_time_HIVneg_time3_loc5") ",") output-type (word ("disease_time_HIVneg_time4_loc5") ",") output-type (word ("disease_time_HIVneg_time5_loc5") ",") output-type (word ("disease_time_HIVpos_time0_loc1") ",") output-type (word ("disease_time_HIVpos_time1_loc1") ",") output-type (word ("disease_time_HIVpos_time2_loc1") ",") output-type (word ("disease_time_HIVpos_time3_loc1") ",") output-type (word ("disease_time_HIVpos_time4_loc1") ",") output-type (word ("disease_time_HIVpos_time5_loc1") ",") output-type (word ("disease_time_HIVpos_time0_loc2") ",") output-type (word ("disease_time_HIVpos_time1_loc2") ",") output-type (word ("disease_time_HIVpos_time2_loc2") ",") output-type (word ("disease_time_HIVpos_time3_loc2") ",") output-type (word ("disease_time_HIVpos_time4_loc2") ",") output-type (word ("disease_time_HIVpos_time5_loc2") ",") output-type (word ("disease_time_HIVpos_time0_loc3") ",") output-type (word ("disease_time_HIVpos_time1_loc3") ",") output-type (word ("disease_time_HIVpos_time2_loc3") ",") output-type (word ("disease_time_HIVpos_time3_loc3") ",") output-type (word ("disease_time_HIVpos_time4_loc3") ",") output-type (word ("disease_time_HIVpos_time5_loc3") ",") output-type (word ("disease_time_HIVpos_time0_loc4") ",") output-type (word ("disease_time_HIVpos_time1_loc4") ",") output-type (word ("disease_time_HIVpos_time2_loc4") ",") output-type (word ("disease_time_HIVpos_time3_loc4") ",") output-type (word ("disease_time_HIVpos_time4_loc4") ",") output-type (word ("disease_time_HIVpos_time5_loc4") ",") output-type (word ("disease_time_HIVpos_time0_loc5") ",") output-type (word ("disease_time_HIVpos_time1_loc5") ",") output-type (word ("disease_time_HIVpos_time2_loc5") ",") output-type (word ("disease_time_HIVpos_time3_loc5") ",") output-type (word ("disease_time_HIVpos_time4_loc5") ",") output-type (word ("disease_time_HIVpos_time5_loc5") ",") output-type (word ("number_infected_list_summary") ",") output-print (word ("number_disease_list_summary") ",") output-type (word (input_number) ",") output-type (word (1 - count turtles with [infection_status = 0] / count turtles) ",") output-type (word (infection_location_infection_HIVpos_1st1) ",") output-type (word (infection_location_infection_HIVpos_1st2) ",") output-type (word (infection_location_infection_HIVpos_1st3) ",") output-type (word (infection_location_infection_HIVpos_1st4) ",") output-type (word (infection_location_infection_HIVpos_1st5) ",") output-type (word (infection_location_infection_HIVneg_1st1) ",") output-type (word (infection_location_infection_HIVneg_1st2) ",") output-type (word (infection_location_infection_HIVneg_1st3) ",") output-type (word (infection_location_infection_HIVneg_1st4) ",") output-type (word (infection_location_infection_HIVneg_1st5) ",") output-type (word (infection_location_infection_HIVpos_re1) ",") output-type (word (infection_location_infection_HIVpos_re2) ",") output-type (word (infection_location_infection_HIVpos_re3) ",") output-type (word (infection_location_infection_HIVpos_re4) ",") output-type (word (infection_location_infection_HIVpos_re5) ",") output-type (word (infection_location_infection_HIVneg_re1) ",") output-type (word (infection_location_infection_HIVneg_re2) ",") output-type (word (infection_location_infection_HIVneg_re3) ",") output-type (word (infection_location_infection_HIVneg_re4) ",") output-type (word (infection_location_infection_HIVneg_re5) ",") output-type (word (infection_location_disease_HIVpos_1st1) ",") output-type (word (infection_location_disease_HIVpos_1st2) ",") output-type (word (infection_location_disease_HIVpos_1st3) ",") output-type (word (infection_location_disease_HIVpos_1st4) ",") output-type (word (infection_location_disease_HIVpos_1st5) ",") output-type (word (infection_location_disease_HIVneg_1st1) ",") output-type (word (infection_location_disease_HIVneg_1st2) ",") output-type (word (infection_location_disease_HIVneg_1st3) ",") output-type (word (infection_location_disease_HIVneg_1st4) ",") output-type (word (infection_location_disease_HIVneg_1st5) ",") output-type (word (infection_location_disease_HIVpos_re1) ",") output-type (word (infection_location_disease_HIVpos_re2) ",") output-type (word (infection_location_disease_HIVpos_re3) ",") output-type (word (infection_location_disease_HIVpos_re4) ",") output-type (word (infection_location_disease_HIVpos_re5) ",") output-type (word (infection_location_disease_HIVneg_re1) ",") output-type (word (infection_location_disease_HIVneg_re2) ",") output-type (word (infection_location_disease_HIVneg_re3) ",") output-type (word (infection_location_disease_HIVneg_re4) ",") output-type (word (infection_location_disease_HIVneg_re5) ",") output-type (word (global-clustering-coefficient) ",") output-type (word (mean hhsize_person_weighted_list) ",") output-type (word (mean number_sus_hivpos) ",") output-type (word (mean number_early_hivpos) ",") output-type (word (mean number_late_hivpos) ",") output-type (word (mean number_extra_hivpos) ",") output-type (word (mean number_smearpos_hivpos) ",") output-type (word (mean number_smearneg_hivpos) ",") output-type (word (mean number_treatment_hivpos) ",") output-type (word (mean number_recovered_hivpos) ",") output-type (word (mean number_sus_hivneg) ",") output-type (word (mean number_early_hivneg) ",") output-type (word (mean number_late_hivneg) ",") output-type (word (mean number_extra_hivneg) ",") output-type (word (mean number_smearpos_hivneg) ",") output-type (word (mean number_smearneg_hivneg) ",") output-type (word (mean number_treatment_hivneg) ",") output-type (word (mean number_recovered_hivneg) ",") output-type (word (selfcure_HIVneg) ",") output-type (word (selfcure_HIVpos) ",") output-type (word (treated_HIVneg) ",") output-type (word (treated_HIVpos) ",") output-type (word (died_HIVneg) ",") output-type (word (died_HIVpos) ",") output-type (word (died_HIVneg_ontreat) ",") output-type (word (died_HIVpos_ontreat) ",") output-type (word (treat_dropout_HIVneg) ",") output-type (word (treat_dropout_HIVpos) ",") output-type (word (treat_success_HIVneg) ",") output-type (word (treat_success_HIVpos) ",") output-type (word (first_treatment) ",") output-type (word (second_treatment) ",") output-type (word (thirdplus_treatment) ",") output-type (word (pop_size * (end_time - run_in_length) / 12) ",") foreach (n-values 6 [?]) [ let i ? let val length(filter [? = i] develop_disease_time_HIVneg_1_list) output-type (word (val) ",") ] foreach (n-values 6 [?]) [ let i ? let val length(filter [? = i] develop_disease_time_HIVneg_2_list) output-type (word (val) ",") ] foreach (n-values 6 [?]) [ let i ? let val length(filter [? = i] develop_disease_time_HIVneg_3_list) output-type (word (val) ",") ] foreach (n-values 6 [?]) [ let i ? let val length(filter [? = i] develop_disease_time_HIVneg_4_list) output-type (word (val) ",") ] foreach (n-values 6 [?]) [ let i ? let val length(filter [? = i] develop_disease_time_HIVneg_5_list) output-type (word (val) ",") ] foreach (n-values 6 [?]) [ let i ? let val length(filter [? = i] develop_disease_time_HIVpos_1_list) output-type (word (val) ",") ] foreach (n-values 6 [?]) [ let i ? let val length(filter [? = i] develop_disease_time_HIVpos_2_list) output-type (word (val) ",") ] foreach (n-values 6 [?]) [ let i ? let val length(filter [? = i] develop_disease_time_HIVpos_3_list) output-type (word (val) ",") ] foreach (n-values 6 [?]) [ let i ? let val length(filter [? = i] develop_disease_time_HIVpos_4_list) output-type (word (val) ",") ] foreach (n-values 6 [?]) [ let i ? let val length(filter [? = i] develop_disease_time_HIVpos_5_list) output-type (word (val) ",") ] output-type (word (number_infected_list_summary) ",") output-type (word (number_disease_list_summary) ",") export-output (word "output_" input_number ".csv") end to create_number_infected_list foreach potential_infector_list [ let i ? set counted_infection_infections lput (length filter [? = i] infector_list_infection) counted_infection_infections ] foreach (n-values (max counted_infection_infections + 1) [?]) [ let i ? set number_infected_list_summary lput (length filter [? = i] counted_infection_infections) number_infected_list_summary ] end to create_number_infected_disease_list foreach potential_infector_list [ let i ? set counted_infection_disease lput (length filter [? = i] infector_list_disease) counted_infection_disease ] foreach (n-values (max counted_infection_disease + 1) [?]) [ let i ? set number_disease_list_summary lput (length filter [? = i] counted_infection_disease) number_disease_list_summary ] end @#$#@#$#@ GRAPHICS-WINDOW 121 406 1444 1750 -1 -1 13.0 1 10 1 1 1 0 1 1 1 0 100 0 100 0 0 1 ticks 30.0 BUTTON 60 55 123 88 NIL setup NIL 1 T OBSERVER NIL NIL NIL NIL 1 BUTTON 70 121 133 154 NIL go T 1 T OBSERVER NIL NIL NIL NIL 0 BUTTON 73 186 150 219 NIL go-once NIL 1 T OBSERVER NIL NIL NIL NIL 0 OUTPUT 727 114 980 415 11 INPUTBOX 194 42 349 102 input_number 1 1 0 Number BUTTON 118 251 189 284 profiler ;setup ;; set up the model\nprofiler:start ;; start profiling\n;repeat 1 [setup go] ;; run something you want to measure\nsetup\nrepeat (end_time + 1) [go]\n;while [count turtles with [infection_status = 1 or infection_status = 2] > 0] [go]\nprofiler:stop ;; stop profiling\nprint profiler:report ;; view the results\nprofiler:reset ;; clear the data\n NIL 1 T OBSERVER NIL NIL NIL NIL 1 @#$#@#$#@ ## WHAT IS IT? (a general understanding of what the model is trying to show or explain) ## HOW IT WORKS (what rules the agents use to create the overall behavior of the model) ## HOW TO USE IT (how to use the model, including a description of each of the items in the Interface tab) ## THINGS TO NOTICE (suggested things for the user to notice while running the model) ## THINGS TO TRY (suggested things for the user to try to do (move sliders, switches, etc.) with the model) ## EXTENDING THE MODEL (suggested things to add or change in the Code tab to make the model more complicated, detailed, accurate, etc.) ## NETLOGO FEATURES (interesting or unusual features of NetLogo that the model uses, particularly in the Code tab; or where workarounds were needed for missing features) ## RELATED MODELS (models in the NetLogo Models Library and elsewhere which are of related interest) ## CREDITS AND REFERENCES (a reference to the model's URL on the web if it has one, as well as any other necessary credits, citations, and links) @#$#@#$#@ 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 5.3.1 @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ setup go @#$#@#$#@ @#$#@#$#@ 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 @#$#@#$#@