I'm working on an evacuation project where I'm assessing the likelihood of a passenger selecting one exit over another based on the proximity of people in the exit area. However, I'm encountering an issue where the sum of the two probabilities doesn't equal 1. Additionally, I'm unsure about the values to assign when there are no individuals near the exits. How to resolve this problem?
This is the environment: https://imgur.com/ZafKcNc
to go
;; Calcolo PP delle uscite nel vicinato di ogni passeggero
let sorted-turtles sort passengers
foreach sorted-turtles [ x -> ask x [
let cell_exit1 min-one-of exit1 [distance myself] ;;mi ritorna la cella dell'uscita 1 che è più vicina a me, sarà il mio riferimento dell'uscita 1 ; è anche Ri
let cell_exit2 min-one-of exit2 [distance myself] ;;mi ritorna la cella dell'uscita 2 che è più vicina a me, sarà il mio riferimento dell'uscita 2 ; è anche Ri
let dist1 [distance myself] of cell_exit1 ;distanza effettiva dall'uscita1
let dist2 [distance myself] of cell_exit2 ;distanza effettiva dall'uscita2
let sorted-neighbors sort neighbors
foreach sorted-neighbors [y -> ask y [
let dist11 [distance myself] of cell_exit1
let dist22 [distance myself] of cell_exit2
ifelse (dist11 < dist1) [
set pcolor pink
]
[
if (dist22 < dist2)[
set pcolor blue
]
]
]]
]]
;controllo se sono nell'uscita allora muori
ask turtles-on exit1 [die]
ask turtles-on exit2 [die]
let al-sicuro patches with [pcolor = cyan ]
ask turtles-on al-sicuro [die]
move
tick
end
to move
let sorted-turtles sort passengers
foreach sorted-turtles [ x -> ask x [
let cell_exit1 min-one-of exit1 [distance myself] ;;mi ritorna la cella dell'uscita 1 che è più vicina a me, sarà il mio riferimento dell'uscita 1 ; è anche Ri
let cell_exit2 min-one-of exit2 [distance myself] ;;mi ritorna la cella dell'uscita 2 che è più vicina a me, sarà il mio riferimento dell'uscita 2 ; è anche Ri
let dist1 [distance myself] of cell_exit1
let dist2 [distance myself] of cell_exit2
;;PS-DISTANZA in base alla distanza
let N 2
let r1 (dist1 ^ Kr)
let r2 (dist2 ^ Kr)
let R12 (r1 + r2)
let PSr1 (1 - (((N - 1) * r1) / R12) )
let PSr2 (1 - (((N - 1) * r2) / R12) )
;;PS-OD in base al numero di persone all'uscita
let d1 count turtles-on patches with [pcolor = magenta] ; HERE
let d2 count turtles-on patches with [pcolor = sky] ; HERE
let d1k (d1 ^ Kd)
let d2k (d2 ^ Kd)
let D12 (d1k + d2k)
let PSd1 0.5 ; HERE
let PSd2 0.5 ; HERE
;se ci sono persone dentro l'area1 calcolo PS-OD
if (d1 > 0) [ set PSd1 (1 - (((N - 1) * d1k) / D12) )] ; HERE
;se ci sono persone dentro l'area2 calcolo PS-OD
if (d2 > 0) [ set PSd2 (1 - (((N - 1) * d2k) / D12) )] ; HERE
;
;; CALCOLO PS finale in base a SD e OD
let alpha1 abs (1 - ((dist1 * N) / R12)) ^ Kr
let alpha2 abs (1 - ((dist2 * N) / R12)) ^ Kr
let alpha_tot (alpha1 + alpha2 ) / N
let beta1 0
let beta2 0
let beta_tot 0
if (D12 > 0)[
set beta1 abs (1 - ((d1 * N) / D12)) ^ Kd
set beta2 abs (1 - ((d2 * N) / D12)) ^ Kd
set beta_tot (beta1 + beta2 ) / N
]
let PS1 ((alpha_tot * PSr1) + (beta_tot * PSd1)) / (alpha_tot + beta_tot) ; HERE
let PS2 ((alpha_tot * PSr2) + (beta_tot * PSd2)) / (alpha_tot + beta_tot) ; HERE
show PS1 ;probabilità finale di scelgiere l'uscita1
show PS2 ;probabilità finale di scelgiere l'uscita2
;show (PS1 + PS2)
;;Scelgo verso quale PP spostarmi (PP più vicina all'uscita)
let PP1 neighbors with [pcolor = pink] ; HERE
let PP2 neighbors with [pcolor = blue] ; HERE
let LPP1 min-one-of PP1 [distance cell_exit1] ; HERE
let LPP2 min-one-of PP2 [distance cell_exit2] ; HERE
ifelse (PS1 > PS2)[ ; HERE
face cell_exit1
move-to LPP1
]
[
face cell_exit2
move-to LPP2
]
]
]
end