确定每个出口 Netlgo 疏散模拟的幸运 PP(可能位置)。

huangapple go评论64阅读模式
英文:

Determine the Lucky PP (possible position) for each exit Netlgo evacuation simulation

问题

以下是您要翻译的内容:

"This problem occurred to me, the passengers move but do not go towards the exit in a smart way and remain in the centre moving around, they also move out of the edge of the room. How can I solve it?"

"I need to do this thing:

If a cell is a PP (possible position) of an exit, it may be occupied by the occupant at the next time step. Each exit may have more than one PP. On the other hand, each occupant can only stay in one cell within a time step. In the proposed CA model, the probability of an exit’s PP to be occupied within the next time step is assumed to be equal. The cell to be selected is termed the Lucky PP (LPP). Assuming the number of PP of an exit is M, the probability of each PP to be a LPP is Pu= 1/M"

"This error appear when press setup button:"

"breed [ passengers passenger]"
"breed [ fire-spots a-fire-spot]"
"breed [ smoke-spots a-smoke-spot]"

"globals [ exit1 ;; pID exit2 ;; pID exits-list ;; [ pID ... ] passenger_count ;; integer exit-probabilities ;; [probability ...]"

"passengers-own [ in-seat? ;; boolean safe? ;; boolean dead? ;; boolean panic? ;; boolean current-heading ;; turtleHDG target-exit ;; pID my-exits-list ;; [ pID ... ] item? ;; boolean]"

"patches-own [ accessible? ;; boolean fire? ;; boolean]"

"FUNZIONI SETUP"
"to setup"
"__clear-all-and-reset-ticks"
";;;;;; DEBUG"
"type '----------------------------[SETUP]\n'"
";;;;;; DEBUG"
"initialize-globals"
"initialize-train"
"initialize-exits"
"initialize-passengers"
"; initialize-fire"
"reset-ticks"
"end"

"initialize-globals"
"set exit1 patch 64 -13"
"set exit2 patch 13 -54"
"set exits-list ( list exit1 exit2 )"
"set exit-probabilities (list 0.5 0.5)"

"initialize-train"
"import-pcolors 'images/ambiente.png'"
"ask patches ["
"if pcolor = 86.6 [set pcolor cyan]"
"if pcolor = 0 [set pcolor black]"
"if pcolor = 64.3 [set pcolor green]"
"if pcolor = 9.9 [set pcolor white]"
"set fire? false"
"set accessible? false ; Imposta tutte le patch come inaccessibili di default"
"]"
"ask patches with [pcolor = white] ["
"set accessible? true ; Contrassegna le patch verdi come accessibili"
"]"
"end"

"initialize-exits"
"set exit1 patch 64 -13"
"set exit2 patch 13 -54"
"set exits-list (list exit1 exit2)"

"initialize-passengers"
"create-passengers passenger-count ["
"set shape 'person business'"
"set size 2"
"set color yellow"
"set in-seat? false ; Cambia da true a false"
"set safe? false"
"set dead? false"
"set panic? true"
"set current-heading 0"
"set my-exits-list [] ; SET here, it must assign a []-list to this property BEFORE next call to choose-exit"
"set target-exit nobody ; SET this as the initial target-exit"

"; Aggiungi il seguente blocco di codice per posizionare casualmente i passeggeri in patch accessibili"
"let target one-of patches with [accessible?]"
"move-to target"
"set target-exit choose-exit patch-here ; Aggiorna il target-exit dopo esserti spostato sulla patch iniziale"
"update-exit-probabilities self"
"]"

"to-report choose-exit [current-position]"
"let possible-exits []"
"let shortest-distance 10000"
"let nearest-exit nobody"
"foreach exits-list [ exitUnderTest ->"
"let exit-coords (list [pxcor] of exitUnderTest [pycor] of exitUnderTest) ;; Get exit coordinates as a list"
"let exit-distance distance exitUnderTest"
"if exit-distance < shortest-distance ["
"set shortest-distance exit-distance"
"set nearest-exit exitUnderTest"
"set possible-exits []"
"]"
"if exit-distance = shortest-distance ["
"set possible-exits lput exit-coords possible-exits ;; Use exit coordinates instead of the patch object"
"]"
"]"
"if length possible-exits = 0 ["
"print 'No exits found.'"
"report nobody"
"]"
"; Use the updated exit probabilities to choose the exit"
"let lucky-exit-coords one-of weighted-n-of 1 possible-exits exit-probabilities"
"let lucky-exit patch-at (item 0 lucky-exit-coords) (item 1 lucky-exit-coords) ;; Get the object using the coordinates"
"set target-exit lucky-exit"
"; Calculate the possible positions (PP) around the lucky exit"
"let pp-list (patch-set [neighbors4] of lucky-exit with [accessible?])"
"; Calculate the probability of each PP to be a LPP"
"let M count pp-list"
"let P 1 / M"
"; Select a LPP for the passenger"
"let lpp one-of pp-list"
"face lpp"
"set my-exits-list lput lucky-exit my-exits-list"
"report lpp"
"end"

"to update-exit-probabilities [passenger1]"
"let kie 1.5"
"let initial-exit [target-exit] of passenger"
"let initial-exit-index position initial-exit exits-list"
"let initial-exit-probability item initial-exit-index exit-probabilities"
"let pie kie * initial-exit-probability"
"if pie > 1 [ set pie 1 ]"
"let delta-pi pie - initial-exit-probability"
"let updated-exit-probabilities []"
"foreach exit-probabilities

["
"let pje p - (p / (1 - initial-exit-probability)) * delta-pi"
"set updated-exit-probabilities lput pje updated-exit-probabilities"
"]"
"]"
"set exit-probabilities updated-exit-probabilities"
"end"

"FUNZIONI GO"
"to go"
";;;;;; DEBUG"
"type '----------------------------[GO.tick]\n'"
";;;;;; DEBUG"
"ask passengers ["
"if panic? ["
"let target-to-exit choose-exit patch-here"
"face target-to-exit"
"]"
"move"
"]"
"tick"
"end"
";;;go()"

"to move"
"if panic? ["
"let next-patch patch-ahead 1"
"if [accessible?] of next-patch and not any? other passengers

英文:

This problem occurred to me, the passengers move but do not go towards the exit in a smart way and remain in the centre moving around, they also move out of the edge of the room. How can I solve it?

I need to do this thing:

If a cell is a PP (possible
position) of an exit, it may be occupied by the occupant at the next time step.
Each exit may have more than one PP. On the other hand, each occupant can only stay in one cell within a
time step. In the proposed CA model, the probability of an exit’s PP to be occupied within the next time
step is assumed to be equal. The cell to be selected is termed the Lucky PP (LPP). Assuming the number of
PP of an exit is M, the probability of each PP to be a LPP is Pu= 1/M

This error appear when press setup button:

WITH expected input to be an agentset but got the patch (patch 35 -7) instead.
error while passenger 22 running WITH
  called by procedure CHOOSE-EXIT
  called by procedure INITIALIZE-PASSENGERS
  called by procedure SETUP
  called by Button &#39;setup&#39;
breed [  passengers    passenger]
breed [  fire-spots  a-fire-spot]
breed [ smoke-spots a-smoke-spot]

globals [        exit1            ;;   pID
                 exit2            ;;   pID
                 exits-list       ;; [ pID ... ]
                 passenger_count  ;;   integer
                 exit-probabilities ;; [probability ...]
]

passengers-own [ in-seat?         ;; boolean
                 safe?            ;; boolean
                 dead?            ;; boolean
                 panic?           ;; boolean
                 current-heading  ;; turtleHDG
                 target-exit      ;;   pID
                 my-exits-list    ;; [ pID ... ]
                 item?            ;; boolean
]

patches-own [    accessible?      ;; boolean
                 fire?            ;; boolean
]

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FUNZIONI SETUP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to setup

   __clear-all-and-reset-ticks
     ;;;;;; DEBUG
            type &quot;----------------------------[SETUP]\n&quot;
     ;;;;;; DEBUG
     initialize-globals
     initialize-train
     initialize-exits
     initialize-passengers
   ; initialize-fire
     reset-ticks

end


to initialize-globals

   set exit1           patch 64 -13
   set exit2           patch 13 -54
   set exits-list    ( list exit1 exit2 )
   set exit-probabilities (list 0.5 0.5)

end


to initialize-train
   import-pcolors &quot;images/ambiente.png&quot;
   ask patches [
     if pcolor = 86.6 [set pcolor cyan]
     if pcolor =  0   [set pcolor black]
     if pcolor = 64.3 [set pcolor green]
     if pcolor =  9.9 [set pcolor white]

     set fire? false
     set accessible? false ; Imposta tutte le patch come inaccessibili di default
   ]

   ask patches with [pcolor = white] [
     set accessible? true ; Contrassegna le patch verdi come accessibili
   ]
end


to initialize-exits
  set exit1 patch 64 -13
  set exit2 patch 13 -54
  set exits-list (list exit1 exit2)
end


to initialize-passengers
  create-passengers passenger-count [
    set shape &quot;person business&quot;
    set size 2
    set color yellow
    set in-seat? false  ; Cambia da true a false
    set safe? false
    set dead? false
    set panic? true
    set current-heading 0
    set my-exits-list [] ; SET here, it must assign a []-list to this property BEFORE next call to choose-exit
    set target-exit nobody ; SET this as the initial target-exit

    ; Aggiungi il seguente blocco di codice per posizionare casualmente i passeggeri in patch accessibili
    let target one-of patches with [accessible?]
    move-to target
    set target-exit choose-exit patch-here ; Aggiorna il target-exit dopo esserti spostato sulla patch iniziale
    update-exit-probabilities self
  ]
end



to-report choose-exit [current-position]

   let possible-exits        []
   let shortest-distance 10000
   let nearest-exit          nobody

   foreach exits-list [ exitUnderTest -&gt;

           let exit-coords (list [pxcor] of exitUnderTest [pycor] of exitUnderTest) ;; Get exit coordinates as a list
           let exit-distance distance exitUnderTest

           if  exit-distance &lt; shortest-distance [
               set shortest-distance exit-distance
               set nearest-exit      exitUnderTest
               set possible-exits    []
           ]

           if  exit-distance = shortest-distance [

               set possible-exits lput exit-coords possible-exits ;; Use exit coordinates instead of the patch object

           ]
   ]

   if length possible-exits = 0 [
       print &quot;No exits found.&quot;
       report nobody
   ]

   ; Use the updated exit probabilities to choose the exit
   let lucky-exit-coords one-of weighted-n-of 1 possible-exits exit-probabilities
   let lucky-exit patch-at (item 0 lucky-exit-coords) (item 1 lucky-exit-coords) ;; Get the object using the coordinates
   set target-exit lucky-exit

   ; Calculate the possible positions (PP) around the lucky exit
   let pp-list (patch-set [neighbors4] of lucky-exit with [accessible?])

   ; Calculate the probability of each PP to be a LPP
   let M count pp-list
   let P 1 / M

   ; Select a LPP for the passenger
   let lpp one-of pp-list
   face lpp

   set my-exits-list   lput lucky-exit my-exits-list

   report lpp
end

to update-exit-probabilities [passenger1]
  let kie 1.5
  let initial-exit [target-exit] of passenger
  let initial-exit-index position initial-exit exits-list
  let initial-exit-probability item initial-exit-index exit-probabilities
  let pie kie * initial-exit-probability

  if pie &gt; 1 [ set pie 1 ]
  let delta-pi pie - initial-exit-probability

  let updated-exit-probabilities []
  foreach exit-probabilities 

[ let pje p - (p / (1 - initial-exit-probability)) * delta-pi set updated-exit-probabilities lput pje updated-exit-probabilities ] ] set exit-probabilities updated-exit-probabilities end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FUNZIONI GO ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to go ;;;;;; DEBUG type &quot;----------------------------[GO.tick]\n&quot; ;;;;;; DEBUG ask passengers [ if panic? [ let target-to-exit choose-exit patch-here face target-to-exit ] move ] tick end ;;;go() to move if panic? [ let next-patch patch-ahead 1 if [accessible?] of next-patch and not any? other passengers-here [ move-to next-patch if member? patch-here exits-list [ set safe? true set in-seat? false ] ] ] end

答案1

得分: 0

以下是已翻译的部分:

"ABM" 模拟代码,在修复了 MCVE 可再现性问题后,仍然存在许多概念上的差距(即使没有进一步发布代码更新和想法的情况下 - 不要发布内容,这在这里被认为不正确)。由于原始代码是基于代理属性数据驱动的,但未能正确地检测代理在场景中的位置上下文以及一些与模拟目标一致和相关的自适应行为重新评估,因此执行会一直发生问题,直到进行适当的重构。

建议首先修订和重新设计所有数据驱动的分配,其中 !DIV0 和/或空的 list 实例、agentSet 对象或 NOBODY 对象的适当融合必须导致模拟语言(NetLogo)的语法期望崩溃。

您已经提供了工具、奖励和其他见解,以改进重新设计的方案,进一步开发全球模拟策略。

如果您需要更多翻译,请告诉我。

英文:

The ABM-simulation code as-was, after MCVE-reproducibility-GAPs fixed, experiences many further conceptual gaps ( even without further creeping of the posted code-updates and ideas - do not creep post-content, this is not considered correct here ). As the as-was code is being heavily (if not exclusively) Agents'-properties data-driven,

确定每个出口 Netlgo 疏散模拟的幸运 PP(可能位置)。

but not properly equipped with detecting the Agents' in-scene locality context and some Simulation-goal consistent and relevant self-adaptive behaviour re-evaluation, the execution keeps headbanging and will keep doing so into many further collisions, until properly re-factored.

TRY let pp-list ( patch-set [neighbors4] of lucky-exit with [accessible?]
                                       WITH lucky-exit      : nobody
           WITH ( patch-set ...                           ) : (agentset, 0 patches) 

Zero Possible Positions for PNR(  15 ) at (  (patch 16 -37)  )

observer&gt; ask passenger 15 [ report-passenger-state who ]

PNR(  15 ) in-seat?  false safe?  false panic?  true dead?  false 
HDG( 305 ) current-heading  0 
LoX( nobody nobody ) target-exit  nobody

Best start with revision & re-design all data-driving assignments, where proper fusing for !DIV0 and/or empty list-instances, void agentSet-s or NOBODY objects result and must result in crashing the syntax-expectations of the simulation-language ( NetLogo ).

You have been provided both tools, bonuses and other insights to improve your re-factored design, to develop the global simulation strategy further on.

breed [  passengers    passenger]
breed [  fire-spots  a-fire-spot]
breed [ smoke-spots a-smoke-spot]
globals [        exit1            ;;   pID
exit2            ;;   pID
exits-list       ;; [ pID ... ]
; passenger_count  ;;   integer
passenger-count  ;;   integer  ;;; MCVE reproducibility GAP#2 ( UNDEFINED Var )
; comment : The number of passengers is set in the GUI via sliders, for the environment try this link: imgur.com/ZafKcNc.
; – accismns
; 39 mins ago
]
passengers-own [ in-seat?         ;; boolean
safe?            ;; boolean
dead?            ;; boolean
panic?           ;; boolean
current-heading  ;; turtleHDG
target-exit      ;;   pID
my-exits-list    ;; [ pID ... ]
item?            ;; boolean
]
patches-own [    accessible?      ;; boolean
fire?            ;; boolean
]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FUNZIONI SETUP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to setup
__clear-all-and-reset-ticks
;;;;;; DEBUG
type &quot;----------------------------[SETUP]\n&quot;
;;;;;; DEBUG
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MCVE reproducibility GAP#4
;;;;;;;;;;;;;;;;;;;;;; GUESSTIMATES derived from PNG
resize-world    0   ;; min-pxcor
69   ;; max-pxcor
-59   ;; min-pycor
0   ;; max-pycor
;;;;;; DEBUG
type &quot;----------------------------[SETUP] will initialize-globals() \n&quot;
initialize-globals
;;;;;; DEBUG
type &quot;----------------------------[SETUP] will initialize-train() \n&quot;
initialize-train
;;;;;; DEBUG
type &quot;----------------------------[SETUP] will initialize-exits() \n&quot;
initialize-exits
;;;;;; DEBUG
type &quot;----------------------------[SETUP] will initialize-passengers() \n&quot;
initialize-passengers
; initialize-fire
reset-ticks
;;;;;; DEBUG
type &quot;----------------------------[SETUP].done\n&quot;
;;;;;; DEBUG
end
;;;setup()
to initialize-globals
set exit1           patch 64 -13
set exit2           patch 13 -54
set exits-list    ( list exit1 exit2 )
set passenger-count 42 ;;   integer  ;;; MCVE reproducibility GAP#2 ( perhaps GUI injected Var setup )
end
;;;initialize-globals()
to initialize-train
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MCVE reproducibility GAP#1
; import-pcolors &quot;C:/Users/palli/OneDrive/Desktop/Modello_base/images/ambiente.png&quot;
; 
; Welcome as always @accismns
; Would you mind to actually post the whole, complete, reproducible MCVE code?
; Incompleteness prevents the code as-is from representing the as-is ( as-are )
; problem(s), so does not form a standard MCVE that Stack Overflow is working
; for decades on.
; Thank you for your kind reconsideration &amp; update
; -- inter alia still missing the hard-coded file to get imported
; -- &quot;C:/Users/palli/OneDrive/Desktop/Modello_base/images/ambiente.png&quot;
; -- so kindly try to do so, as otherwise your code moves nowhere near a standard MCVE-reproducibility.
; That is fair, isn&#39;t it?
; – user3666197
; 1 hour ago
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MCVE reproducibility GAP#4
; world was not initialised as a system-default,
;       but the import-pcolors matching setup has to de deducted and implemented ex-post
;
; GUESSTIMATE: a non-toroidal world (see move()-requirements below
; 70px &#215; 60px ( as was in https://i.imgur.com/ZafKcNc.png )
; ______________________________________________________________ IMPLEMENTED ABOVE
import-pcolors &quot;~projects/NetLogo 6.2.2/StackOverflow_accismns_ZafKcNc.png&quot; ;; PROXY for ambiente.png
ask patches [
if pcolor = 86.6 [set pcolor cyan]
if pcolor =  0   [set pcolor black]
if pcolor = 64.3 [set pcolor green]
if pcolor =  9.9 [set pcolor white]
set fire?       false
set accessible? false    ; Imposta tutte le patch come inaccessibili di default
]
ask patches with [pcolor = white] [
set accessible? true   ; Contrassegna le patch verdi come accessibili
]
end
;;;initialize-train()
to initialize-exits
set exit1 patch 64 -13
set exit2 patch 13 -54
set exits-list (list exit1 exit2)
end
;;;initialize-exits() -- why replicate already intialize-globals() setup globals again?
to initialize-passengers
create-passengers passenger-count [
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MCVE reproducibility GAP#5
; set shape          &quot;person business&quot;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;      observer: [&quot;default&quot; &quot;airplane&quot; &quot;arrow&quot; &quot;box&quot; &quot;bug&quot; &quot;butterfly&quot; &quot;car&quot; &quot;circle&quot; &quot;circle 2&quot; &quot;cow&quot; &quot;cylinder&quot; &quot;dot&quot; &quot;face happy&quot; &quot;face neutral&quot; &quot;face sad&quot; &quot;fish&quot; &quot;flag&quot; &quot;flower&quot; &quot;house&quot; &quot;leaf&quot; &quot;line&quot; &quot;line half&quot; &quot;pentagon&quot; &quot;person&quot; &quot;plant&quot; &quot;sheep&quot; &quot;square&quot; &quot;square 2&quot; &quot;star&quot; &quot;target&quot; &quot;tree&quot; &quot;triangle&quot; &quot;triangle 2&quot; &quot;truck&quot; &quot;turtle&quot; &quot;wheel&quot; &quot;wolf&quot; &quot;x&quot;]
set shape          &quot;person&quot;
set size            4      ; 2
set color           yellow
set in-seat?        false  ; Cambia da true a false
set safe?           false  ; yes, the life is dangerous
set dead?           false  ; hopefully will stay so ...
set panic?          true   ; why all when no fire and no smoke present?
set current-heading 0      ; why all HDG the same direction? not common in common trains
set my-exits-list   []     ; SET here, it must assign a []-list to this property BEFORE next call to choose-exit
set target-exit     nobody ; SET this as the initial target-exit
; Aggiungi il seguente blocco di codice per posizionare casualmente i passeggeri in patch accessibili
; let     target one-of patches with [accessible?]
; move-to target
move-to one-of patches with [ accessible? ]; Aggiungi il seguente blocco di codice per posizionare casualmente i passeggeri in patch accessibili
set     target-exit choose-exit patch-here ; Aggiorna il target-exit dopo esserti spostato sulla patch iniziale
]
;;;;;;;; DEBUG
ask passengers [ type ( sentence &quot;W: &quot; who
&quot;x:&quot;  xcor
&quot;y:&quot;  ycor
)
]
; [W:  28 x:  0 y:   0]  [W:  16 x: 0 y: 0]  [W:   4 x: 0 y: 0]
; [W:   2 x:  0 y:   0]  [W:  35 x: 0 y: 0]  [W:   7 x: 0 y: 0]
; [W:  32 x:  0 y:   0]  [W:   1 x: 0 y: 0]  [W:  10 x: 0 y: 0]
; [W:  13 x:  0 y:   0]  [W:  37 x: 0 y: 0]  [W:  15 x: 0 y: 0]
; [W:  27 x:  0 y:   0]  [W:  12 x: 0 y: 0]  [W:  19 x: 0 y: 0]
; [W:  17 x:  0 y:   0]  [W:  14 x: 0 y: 0]  [W:   5 x: 0 y: 0]
; [W:   9 x:  0 y:   0]  [W:  36 x: 0 y: 0]  [W:  30 x: 0 y: 0]
; [W:  29 x:  0 y:   0]  [W:  24 x: 0 y: 0]  [W:   8 x: 0 y: 0]
; [W:  31 x:  0 y:   0]  [W:  40 x: 0 y: 0]  [W:  11 x: 0 y: 0]
; [W:  21 x:  0 y:   0]  [W:   0 x: 0 y: 0]  [W:   3 x: 0 y: 0]
; [W:   6 x:  0 y:   0]  [W:  26 x: 0 y: 0]  [W:  18 x: 0 y: 0]
; [W:  39 x:  0 y:   0]  [W:  20 x: 0 y: 0]  [W:  38 x: 0 y: 0]
; [W:  33 x:  0 y:   0]  [W:  25 x: 0 y: 0]  [W:  22 x: 0 y: 0]
; [W:  41 x: 59 y: -31]  [W:  23 x: 0 y: 0]  [W:  34 x: 0 y: 0]
;       ^_x:_59 y:_-31 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; type count patches                        4200
; type count patches with [accessible?]     2784
; type count patches with [not accessible?] 1416
end
;;;initialize-passengers()
to-report choose-exit [current-position]
let possible-exits        []
let shortest-distance 10000
let nearest-exit          nobody
foreach exits-list [ exitUnderTest -&gt;
let exit-coords (list [pxcor] of exitUnderTest [pycor] of exitUnderTest) ;; Get exit coordinates as a list
let exit-distance distance exitUnderTest
if  exit-distance &lt; shortest-distance [
set shortest-distance exit-distance
set nearest-exit      exitUnderTest
set possible-exits    []
]
if  exit-distance = shortest-distance [
set possible-exits lput exit-coords possible-exits ;; Use exit coordinates instead of the patch object
]
]
if length possible-exits = 0 [
print &quot;No exits found.&quot;
report patch-here
; report nobody ;;------------------------------------------ JIT-exit --^ reporting NOBODY
]                 ;;                                                      ? WAS CALLER READY TO RECEIVE NOBODY as an answer ?
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DEBUG
type ( sentence &quot;TRY let lucky-exit-coords    one-of     possible-exits\n&quot;
&quot;WITH possible-exits  :&quot; possible-exits &quot;\n&quot;
)
let lucky-exit-coords    one-of     possible-exits
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DEBUG
type ( sentence &quot;TRY let lucky-exit      patch-at ( item 0 lucky-exit-coords ) ( item 1 lucky-exit-coords )\n&quot;
&quot;WITH patch-at  :&quot;       patch-at ( item 0 lucky-exit-coords ) ( item 1 lucky-exit-coords ) &quot;\n&quot;
)
let lucky-exit           patch-at ( item 0 lucky-exit-coords )
( item 1 lucky-exit-coords ) ;; Get the object using the coordinates
set target-exit          lucky-exit
; Calculate the possible positions (PP) around the lucky exit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DEBUG
type ( sentence &quot;TRY let pp-list ( patch-set [neighbors4] of lucky-exit with [accessible?]\n&quot;
&quot;WITH lucky-exit      :&quot; lucky-exit &quot;\n&quot;
)
; type ( sentence &quot;WITH lucky-exit with :&quot; lucky-exit with [accessible?] &quot;\n&quot;
;                 )
; type ( sentence &quot;WITH [neighbors4] of :&quot; [neighbors4] of lucky-exit with [accessible?] &quot;\n&quot;
;                 )
type ( sentence &quot;WITH ( patch-set ...):&quot; patch-set [neighbors4] of ( patch-set lucky-exit ) with [accessible?] &quot;\n&quot;
)
;                                   ;; PROTECT CASES WHERE possible-exits[] is empty
let pp-list            ( patch-set [neighbors4] of ( patch-set lucky-exit )
with [accessible?]
)
set my-exits-list lput lucky-exit my-exits-list
; Calculate the probability of each PP to be a LPP
; let  M   count pp-list
; let  P   1 / M                      ;; PROTECT !DIV0
ifelse count pp-list &gt; 0 [          ;; PROTECT from empty pp-list
;; IF   ::
let  M   count pp-list
let  P   1 / M        ;; PROTECT&#39;d from DIV0 as lengt
; Select a LPP for the passenger
let    lpp one-of pp-list
face   lpp
report lpp ;;------------------------------------ JIT-exit --^ reporting lpp
][ ;; ELSE ::
type ( sentence &quot;Zero Possible Positions for PNR( &quot; who &quot;) at ( &quot; patch-here &quot; )\n&quot; )
let    lpp patch-here
report lpp ;;------------------------------------ JIT-exit --^ reporting lpp
]
;;;a pair of MUTEX-JIT-exits --^ will cause the code-execution will never continue beyond this
end
;;;report choose-exit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FUNZIONI GO ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to go
;;;;;; DEBUG
type &quot;----------------------------[GO.tick]\n&quot;
;;;;;; DEBUG
ask passengers [
if panic? [
let  target-to-exit choose-exit patch-here
face target-to-exit
]
move
]
tick
end
;;;go()
to move ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MCVE reproducibility GAP#3
if panic? [
move-to target-exit                ;; PROTECT from empty - MOVE-TO expected input to be an agent but got NOBODY instead.
if  patch-here = target-exit [
set safe?    true
set in-seat? false
]
]
;;;
;;; MOVE-TO expected input to be an agent but got NOBODY instead.
;;;         error while passenger 34 running MOVE-TO
;;;         called by procedure MOVE
;;; 
;;; ask passenger 34 [ report-passenger-state ]
;;; ...
;;; WITH ( patch-set ...): (agentset, 0 patches)  
;;; Zero Possible Positions for PNR(  15 ) at (  (patch 16 -37)  )
;;; --post-mortem--
;;; observer&gt; ask passenger 15 [ report-passenger-state who ]
;;; [
;;;  PNR( 15 ) in-seat?  false safe?  false panic?  true dead?  false 
;;;  HDG( 305 ) current-heading  0 
;;;  LoX( nobody nobody ) target-exit  nobody
;;; ]
;;; --OBSERVAION:-current-code-relies-on-data-driven-behaviour-but-maintains-Agents&#39;-data-inconsistently-resulting-in-syntax-crashes--
;;; --SOLUTION:-revise-the-strategy-of-data-driven-Agents&#39;-behaviour-and-add-fuse-protected-code-that-does-not-run-Agents&#39;-behaviour-driving-data-out-of-expected-syntax
;;;
;;; aha:
;;;
;;; This problem occurred to me, the passengers move /// how? ^^^^
;;;      but do not go towards the exit in a smart way
;;;      and remain in the centre moving around,
;;; they also move out of the edge of the room.
;;;      How can I solve it?
;;;
;;; I need to do this thing:
;;;      If a cell is a PP (possible position) of an exit,
;;;                        it may be occupied by the occupant
;;;                        at the next time step.
;;;      Each exit may have more than one PP.
;;;                        On the other hand,
;;;      each occupant can only stay in one cell within a time step.
;;;
;;; In the proposed CA model, the probability of an exit’s
;;;                        PP to be occupied within the next time step
;;;                        is assumed to be equal.
;;;
;;; The cell to be selected is termed the Lucky PP (LPP).
;;;
;;; Assuming the number of PP of an exit is M, the probability of each
;;;                        PP to be a LPP is Pu = 1/M
end
;;;move()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MCVE reproducibility run outputs
;
;----------------------------[SETUP]
; TRY let lucky-exit-coords    one-of     possible-exits
; WITH possible-exits  : [13 -54] 
;
; TRY let lucky-exit      patch-at ( item 0 lucky-exit-coords ) ( item 1 lucky-exit-coords )
; WITH patch-at        : nobody 
;
; TRY let pp-list ( patch-set [neighbors4] of lucky-exit with [accessible?]
; WITH lucky-exit      : nobody 
to report-passenger-state [ PNR ]
set shape          &quot;arrow&quot; ; in-sim: &quot;person&quot;
set size            8      ; in-sim: 4        ; was 2
set color           red    ; in-sim  yellow
type ( sentence &quot;\nPNR(&quot; who &quot;) in-seat? &quot; in-seat?
&quot;safe? &quot;    safe?
&quot;panic? &quot;   panic?
&quot;dead? &quot;    dead?
&quot;\nHDG(&quot; heading   &quot;) current-heading &quot; current-heading
&quot;\nLoX(&quot; my-exits-list &quot;) target-exit &quot; target-exit
)
end
;;;report-passenger-state( who )
to reset-passenger-state [ PNR ]
set shape          &quot;person&quot;
set size            4        ; was 2
set color           yellow
type ( sentence &quot;\nPNR(&quot; who &quot;) state set back to in-sim&quot;
)
end
;;;reset-passenger-state( who )

<sub>( for previous release of the NetLogo code -- see post-revisions )</sub>

The original post went through review (naturally not reflecting the last minute changes, announced right now) and after obvious repairs of reproducibility GAPs, the code is reproducing some other kind of data-driven errors.

确定每个出口 Netlgo 疏散模拟的幸运 PP(可能位置)。

Feel free to to use the tools offered and continue debugging further on, also perhaps resolving some bonus-inlined remarks, that indicate future problems your ABM-simulation will sooner or later experience

huangapple
  • 本文由 发表于 2023年5月21日 05:16:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/76297376.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定