aaa---smartgam.nlogo
来自「NETLOGO」· NLOGO 代码 · 共 454 行 · 第 1/3 页
NLOGO
454 行
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Geographical Analysis Machine ;; (GAM, Opernshaw / Fotheringham and Zhan);; by Arnaud BANOS;; SET (CNRS, UMR 5603), Univeristy of Pau, France;; March, 29th;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;globals [file-listXcoordinates_listYcoordinates_listZcoordinates_listXminXmaxYminYmaxXpatch-coord ;; lists of X and Y coordinates translated into turtle coordinatesYpatch-coordproportion-at-risk ;; #at-risk / (# at-risk + # target)]breeds [ observations ;; observations moving-windows ;; moving windows clusters ;; clusters identified]observations-own [ Zvaluebelong-to-cluster?]moving-windows-own [number-at-risknumber-targetcomputed-probability]clusters-own [computed-probability]to load-dataca;show read-file user-choose-fileset-datacreate_pointsend;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Import files for at-risk and target populations;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;to-report read-file [file-name] set file-list (list) if (file-exists? file-name) [file-open file-name while [not file-at-end?] [set file-list (lput (read-from-string (word "["file-read-line"]")) file-list)] file-close ] report file-listend to create_pointsset Xcoordinates_list (list)set Ycoordinates_list (list)set Zcoordinates_list (list)set Xpatch-coord (list)set Ypatch-coord (list)compute_XYmin_maxcreate_target_XYcoordcreate_target_pointsendto compute_XYmin_maxlet tick 0while [tick < length file-list] [let line-i item tick file-list set Xcoordinates_list lput (item 0 line-i) Xcoordinates_list set Ycoordinates_list lput (item 1 line-i) Ycoordinates_list set Zcoordinates_list lput (item 2 line-i) Zcoordinates_list set tick tick + 1 ]set Xcoordinates_list reverse Xcoordinates_listset Ycoordinates_list reverse Ycoordinates_listset Zcoordinates_list reverse Zcoordinates_listset Xmin min Xcoordinates_listset Xmax max Xcoordinates_listset Ymin min Ycoordinates_listset Ymax max Ycoordinates_listendto create_target_XYcoordlet tick 0while [tick < length Xcoordinates_list] [ let Xi item tick Xcoordinates_list let Yi item tick Ycoordinates_list let Zi item tick Zcoordinates_list let rangeX (xmax - xmin) let rangeY (ymax - ymin) let Xi_patch_coord ((Xi - Xmin)/ rangeX) * (screen-size-x - 3) - (screen-edge-x - 1) let Yi_patch_coord ((Yi - Ymin)/ rangeY) * (screen-size-Y - 3) - (screen-edge-Y - 1) set Xpatch-coord lput Xi_patch_coord Xpatch-coord set Ypatch-coord lput Yi_patch_coord Ypatch-coord set tick tick + 1 ] set Xpatch-coord reverse Xpatch-coord set Ypatch-coord reverse Ypatch-coord endto create_target_pointslet tick 0while [tick < length Xpatch-coord] [ create-custom-observations 1 [ set xcor item tick Xpatch-coord set ycor item tick Ypatch-coord set Zvalue item tick Zcoordinates_list set shape "square" ifelse (zvalue = 0) [set color green set size 1] [set color red set size 3] ] set tick tick + 1 ]end;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Run GAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;to setup_GAM ask moving-windows [die] ask clusters [die] ask observations [reset] plot-pen-reset create-custom-moving-windows Number_Moving_Windows [ setxy random-float screen-size-x
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?