;; An editor for Multi-Mediator Models: MMModel-editor.nlogo ;; Version b0.980 with changes to make it work under NetLogo Web; better way to move excites & inhibits; sliders instead of globes; no LevelSpace; ;; creating and moving boxes; time smoothing ;; Jim Levin ;; Education Studies, University of California, San Diego jalevin@ucsd.edu ;; Last updated: January 2024 ;; ;; This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 Unported License. ;; http://creativecommons.org/licenses/by-nc-sa/4.0/ ;extensions [ ls pathdir ] ;; see the ls (LevelSpace) extension section of the NetLogo User Manual at https://ccl.northwestern.edu/netlogo/docs/ ; ;; use the pathdir extensions, to get the name of this model for the export-world kludge breed [ nodes node ] nodes-own [ activity-level newactivity-level labelnode labeloffset commentnode commentoffset comments external-activity-level unique-id LS-id LS-name c-concept-id c-context-id parent-context-node ] breed [ contexts context ] contexts-own [ activity-level newactivity-level external-activity-level click-mode which-external commentnode commentoffset comments unique-id LS-id LS-name labelnode labeloffset c-concept-id c-context-id non-slider ] breed [ boxes box ] boxes-own [ box-name box-upper-left-x box-upper-left-y box-lower-right-x box-lower-right-y ] directed-link-breed [excites excite] ; excites-own [ ] ;; if excites ever need their own properties directed-link-breed [inhibits inhibit] ; inhibits-own [ ] ;; if inhibits ever need their own properties breed [ nodelabels nodelabel] ;; text label for a node nodelabels-own [xoffset yoffset] globals [ m_1 m_2 m_3 b_1 trashcan trashcanicon attenuation model-started? previous-concept selected-context? which-context placemarker which-concept link_expansion_threshold triad_completion_threshold deletion_probability expected? unexpected? file plotting? plotted-concept Y-plotted-concept concept_plotted Y_concept_plotted modenumber excite-shape inhibit-shape moving-excite? moving-inhibit? whichend olda oldb farend movewhichnode moving-concept? moving-external? mouse-back-up? moving-boxes? first-box-corner-selected? second-box-corner-selected? new-box-name creating-a-box? upper-left-prompt lower-right-prompt changed-external? previouslink selected_context_activity child-marker parent-marker child-concept child-conc-id child-cont-id own-name start-upper-left-x start-upper-left-y start-lower-right-x start-lower-right-y start-x start-y ] to startup ;; this is done when first loading this NetLogo file setup open-model end ;; startup to setup ; no-display ;; doesn't work with NetLogo Web clear-all setup-globals setup-patches setup-boxes ; display ;; doesn't work with NetLogo Web reset-ticks end ;; setup to setup-globals ;; set global variables ; set own-name pathdir:get-model-name ;; use the pathdir extension to get the name of this model, for use with levelSpace set attenuation 0.67 set model-started? false set-default-shape nodes "circle" ;; a circle set-default-shape contexts "slider0" ;; i.e. slider as the impact of context outside the model set previous-concept nobody set selected_slider_activity 50 set what "concepts" set expected? "" set unexpected? "" set concept_plotted "" set plotted-concept "" set y_concept_plotted "" set-current-plot "Concept activity" set file "" set child-marker "C:" set parent-marker "P:" ;; strings to mark which concepts and contexts have associated child or parent models set child-conc-id -1 set child-cont-id -1 set moving-excite? false set moving-inhibit? false set moving-concept? false set moving-external? false set moving-boxes? false set creating-a-box? false set first-box-corner-selected? false set second-box-corner-selected? false set new-box-name "" set mouse-back-up? false set changed-external? false set previouslink "" create-nodes 1 [ setxy -5 (min-pycor + 1) set shape "empty" ;; node where the "from" end of new links is located set m_1 self set LS-id -1] create-nodes 1 [ setxy 5 (min-pycor + 1) set shape "empty" ;; node where the "to" end of new links is located set m_2 self set LS-id -1] create-nodes 1 [ setxy 0 (min-pycor + 1) set shape "x" set size 1 set color black hide-turtle set m_3 self set LS-id -1] create-nodes 1 [ setxy (max-pxcor - 1.75) (min-pycor + 2) set shape "empty" set label-color white set label "" set trashcan self set LS-id -1] create-turtles 1 [ setxy (max-pxcor - 1.75) (min-pycor + 2) set shape "trashcan" set color gray set size 4 set label "Trash " set label-color black set trashcanicon self ] set selected-context? false set which-context nobody ifelse netlogo-web? [set modenumber 1 set excite-shape "net-excites" set inhibit-shape "net-inhibits"] [set modenumber 100 set excite-shape "excites" set inhibit-shape "inhibits"] ; ifelse netlogo-web? [ set modenumber 1 ] ; [ set modenumber 100 ] ; set excite-shape "excites" set inhibit-shape "inhibits" create-turtles 1 [ setxy 0 (min-pycor + 1) set shape "x" set size 1 set color blue hide-turtle set b_1 self ] create-turtles 1 [ set upper-left-prompt self set color blue set label-color blue set shape "X" set label "Click at the upper left corner of the box " hide-turtle ] create-turtles 1 [ set lower-right-prompt self set color blue set label-color blue set shape "X" set label "Click at the lower right corner of the box " hide-turtle ] end ;; setup-globals to setup-patches ask patches [set pcolor white] ;; make the background white end ;; setup-patches to setup-boxes ;; create named boxes to group parts of a model visually - has no effect on the model ;; no longer needed, as boxes are now drawn within the Interface mode ; draw-a-box "box name" -24.5 23 -2 4 end ;; setup-boxes to-report make-child-parent-name [prefix-string label-name] ;; to make the label name have "P:" or "C:" starting the name report (word prefix-string label-name) end ;; make-child-parent-name to-report delete-child-parent-name [prefix-string label-name ] if (length label-name - length prefix-string < 0) [report label-name] if substring label-name 0 length prefix-string = prefix-string [set label-name substring label-name length prefix-string (length label-name) ] report label-name end ;; delete-child-parent-name to delete-child-model ; ;; select the closest concept or external on mouse-down ; let t 0 ; if mouse-down? [ ; set t closest-xy mouse-xcor mouse-ycor (turtle-set nodes contexts) ;; find the closest concept or external context (slider) ; if (t = nobody) [stop] ; ;; then close the child model and mark that on the selected concept or external context ; ask t [ ; if (who > 3) ; [if (ls-id > -1) ; [ ; let lsid ls-id ; ask labelnode [ set label (delete-child-parent-name (word parent-marker lsid " ") label) set label-color black ] ; set label-color black ; if (shape = "non-slider")[set non-slider 0 rescale-external] ; ifelse ls:model-exists? ls-id ; [ ; ls:close ls-id ;; close the child model ; set ls-id -1 set c-concept-id -1 set c-context-id -1 ; ] ; [ set ls-id -1 set c-concept-id -1 set c-context-id -1 ; stop ] ; ; ;; delete the special context (slider) node associated with this parent concept ; if breed = nodes ; [ ; if not (parent-context-node = "") ;; only if there is a special parent context / slider ; [ ; ask parent-context-node ; [ ; if (which-context = self) [ set selected-context? false ] ;; if this external has been selected, unselect ; ask my-in-excites [die] ask my-out-excites [die] ;; delete any connected excites or inhibits ; ask my-in-inhibits [die] ask my-out-inhibits [die] ; ask labelnode [die] ; if (commentnode != 0) [ask commentnode [ die ]] ;; if comment node exists, trash it ; if ls-id > -1 [ls:close (list ls-id)] ;; if a child LS model, close it ; die ;; delete the context / slider node itself ; ] ; ] ; ] ; ; set model-started? true ; ]]] ; if ls:models = [] [ set modenumber 200 ] ;; if no more child models, restore the rate at which sliders automatically change ; ; stop ] ;; stop the forever "Select to delete a child model" button end ;; delete-child-model to-report netlogo-extension [name] ;; check if last 5 characters of the filename are ".nlogo" let thelength (length name) if (thelength < 6) [report false] report ((substring name (thelength - 6) thelength) = ".nlogo") end ;; netlogo-extension to select-add-child-model ; ;; select the closest concept or external on mouse-down ; let t 0 let oldlabel "" let child-context "" let isaconcept "" let stopnow false ; if mouse-down? [ ; set t closest-xy mouse-xcor mouse-ycor (turtle-set nodes contexts) ;; find the closest concept or external context (slider) ; if (t = nobody) [stop] ; ; ; ;; then ask the user for the name of a child model for that concept or external context (slider) and open it ; ask t [ ; if not (who > 3) [stop] ; set isaconcept (breed = nodes) ; ; let the-file user-file ;; have the user select a file ; if the-file = false [stop] ;; user selected "cancel" ; if (netlogo-extension the-file) = false ; [ user-message "Select a NetLogo model, a file with a .nlogo extension." ;; user selected a file that wasn't a NetLogo file ; stop ] ; ; create-a-child-model the-file ; ; set ls-id (last ls:models) ; ; if (ls:uses-level-space? ls-id) = false ; [ user-message "Select a NetLogo model that has the LevelSpace extension." ;; user selected a NetLogo file without the LevelSpace extension ; ls:close ls-id set ls-id -1 ; set stopnow true stop] ; ;;; then add the info to the concept or extenal context (slider) ; set ls-name the-file ; let lsid ls-id ; set label-color red ;; to indicate a parent concept or context ; ask labelnode [ set oldlabel label set label (make-child-parent-name (word parent-marker lsid " ") label) set label-color red ] ; ;;; create a special concept node in the child model, if one doesn't exist already ; if c-concept-id = -1 ;; no special node already linked ; [ ; ls:let oldlabel oldlabel ; ls:let alreadyfound false ; ls:ask ls-id ; [ ; ;; first look to see if the special concept node is already there; if so, just link it ; ;; look for labelnode label = (word child-marker ": " parent node label) ; ask nodes ; [ if who > 3 ; [ask labelnode [ ; if (label = (word child-marker " " oldlabel)) ; [ ; ;; found it, just link it ; set child-conc-id [who] of myself ; set alreadyfound true ; ]]]] ; ;; otherwise create it ; if alreadyfound = false ; [ ; set child-concept (create-a-node (word child-marker " " oldlabel) -5 5 1.5 -2.5 0 "" -1 "" -1 -1 ) ; ask child-concept [ set label-color violet ask labelnode [set label-color violet]] ; set child-conc-id [who] of child-concept ; save-model ; ] ; ] ; set child-conc-id [child-conc-id] ls:of ls-id ; set c-concept-id child-conc-id ;; store the number of the special child concept in the concept itself ; ] ; ;;; create a special context (slider) in the child model, if one doesn't exist aleady ; if c-context-id = -1 ; [ ; ls:let child-context child-context ; ls:let alreadyfound false ; ls:ask ls-id ; [ ; ;; first look to see if the special context (slider) node is already there; if so, just link it ; ask contexts ; [ask labelnode [ ; if (label = child-marker) ; [ ; ;; found it, just link it ; set child-cont-id [who] of myself ; set alreadyfound true ; ]]] ; ; ;; otherwise create it ; if alreadyfound = false ; [ ; set child-context (create-a-context child-marker 5 5 "" -1 "" -1 0 ) ; ask child-context [ set non-slider 1 set shape "non-slider" set label-color violet ask labelnode [set label-color violet]] ; set child-cont-id [who] of child-context ; save-model ; ]] ; set child-cont-id [child-cont-id] ls:of ls-id ; set c-context-id child-cont-id ;; store the number of the special child context (slider) in the concept itself ; ] ; ; set model-started? true ; set modenumber 40 ;; since child models slow things down, speed automatic slider change up to compensate ; ] ;; end of ask t [ ; ; if stopnow [stop] ; ; ;; if creating a child model for a concept, create a special slider in the parent model to receive the activity level of the special child concept ; ;; create a new context (slider) above this concept and store the turtle id parent-context-node in this concept ; ifelse (isaconcept = true) ; [ ; let pcn ( create-a-context parent-marker ([xcor] of t) (within-y (([ycor] of t) + 6)) "" -1 "" -1 -1 ) ;; let pcn ( create-a-context (word parent-marker [ls-id] of t) ([xcor] of t) (within-y (([ycor] of t) + 6)) "" -1 "" -1 -1 ) ; ; ask t [ ; set parent-context-node pcn ; ask pcn ; [ ; connect-excite t ; set label-color orange set non-slider 1 set shape "non-slider" ask labelnode [set label-color orange ] ; ] ; ] ; ] ; [ask t [set non-slider 1 set shape "non-slider"]] ;; if creating a child model for an external (slider), change the icon for the slider ; ; stop ;; stop the forever "Select to add a child model" button ; ] ;; end if mouse-down? end ;; select-add-child-model to create-a-child-model [ a-model-path ] ; if ls-id > -1 ;; already a child model - close it and unlink it first before creating a new one ; [ ;; close the child model ; let lsid ls-id ; ask labelnode [ set label (delete-child-parent-name (word parent-marker lsid " ") label) ; set label-color black ] ; ls:close ls-id ; ] ; carefully [ ls:create-interactive-models 1 a-model-path ] ;; takes a string and creates an interactive child model from that path ; [ ;; print out a warning if there is a problem with the model path ; user-message (word "No valid NetLogo model for this version of NetLogo was found at path: " a-model-path) ; ] end ;; create-a-child-model ;to wait-for-mouse-click ; loop [if mouse-down? [ stop ] ] ;end ;; wait-for-mouse-click ; ;to-report wait-for-mouse-click? ; loop [ if mouse-down? [ report true ] ] ;end ;; wait-for-mouse-click? to create let x 0 ;; let upper-left-x 0 let upper-left-y 0 let lower-right-x 0 let lower-right-y 0 set model-started? true if what = "concepts" [ set x (user-input "What is the label for the concept?") set x create-a-node x 0 0 (center x) -2.5 0 "" -1 "" -1 -1 stop] if what = "sliders" [ set x create-a-context " " 0 0 "" -1 "" -1 -1 stop] ;; external context impact set by a slider if what = "excites" [ ask m_1 [ connect-excite m_2 ] stop] if what = "inhibits" [ ask m_1 [ connect-inhibit m_2 ] stop ] if what = "boxes" [ if create-a-new-box [stop] ] ;; have to have Create button forever for this to work in NetLogo Web end ;; create to-report create-a-new-box ;; have to use globals because have to use forever button Create to do looping in NetLogo Web if new-box-name = "" [ set new-box-name (user-input "What is the label for the box?") ; user-message "Click OK, then click at the upper left of the box." set creating-a-box? true ] ; while [(not mouse-down?)] [ ] ;; "while" doesn't work in NetLogo Web with "mouse-down?" ; wait-for-mouse-click ;; "loop" doesn't work in NetLogo Web with "mouse-down?" ifelse (not first-box-corner-selected?) [ ask upper-left-prompt [ show-turtle setxy mouse-xcor mouse-ycor ] if mouse-down? [ set start-upper-left-x mouse-xcor set start-upper-left-y mouse-ycor ask b_1 [setxy mouse-xcor mouse-ycor show-turtle] set first-box-corner-selected? true ask upper-left-prompt [ hide-turtle ] ; user-message "Click OK, then click at the lower right of the box." ] ] ; while [(not mouse-down?)] [ ] ;; doesn't work in NetLogo Web ; wait-for-mouse-click ;; also doesn't work in NetLogo Web [ ;; get here if first-box-corner-selected? true if (not second-box-corner-selected?) [ ifelse not (mouse-down?) [ ask lower-right-prompt [ show-turtle setxy mouse-xcor mouse-ycor set mouse-back-up? true ] ] [ if mouse-down? and mouse-back-up? [ set start-lower-right-x mouse-xcor set start-lower-right-y mouse-ycor set second-box-corner-selected? true set mouse-back-up? false ask lower-right-prompt [ hide-turtle ] ] ] ] ] ; if (first-box-corner-selected? and second-box-corner-selected?) if (first-box-corner-selected? and second-box-corner-selected? and not mouse-down?) [ ask b_1 [ hide-turtle] create-a-box new-box-name start-upper-left-x start-upper-left-y start-lower-right-x start-lower-right-y set new-box-name "" set first-box-corner-selected? false set second-box-corner-selected? false set creating-a-box? false ; stop ;; stop only stops this procedure, not the forever create button report true ;; done creating the new box ] report false ;; not done creating the new box yet this time through end ;; create-a-new-box to-report create-a-node [ node-label xpos ypos x-label-offset y-label-offset external-activity unique lsid lsname cconceptid ccontextid ] let ms 0 let cs 0 create-nodelabels 1 [ ;; first create a text label set size 0 set color white setxy (xpos + x-label-offset) (ypos + y-label-offset) set label-color black set label node-label set xoffset x-label-offset set yoffset y-label-offset set ms self ] create-nodelabels 1 [ ;; next create a comment label set size 0 set color white setxy (xpos + x-label-offset) (ypos - y-label-offset) set label-color orange set label node-label set xoffset x-label-offset set yoffset y-label-offset hide-turtle ;; hidden except when mouseover when running model or when editing comment set cs self ] create-nodes 1 [ ;; now create the node set size 2 set color orange setxy xpos ypos set label-color black ifelse show_numeric_values? ;; set in a switch [set label (round activity-level)] [set label ""] set labelnode ms set commentnode cs set external-activity-level external-activity ifelse (unique = "") [ set unique-id date-and-time ][ set unique-id unique] set ls-id lsid set ls-name lsname set c-concept-id cconceptid set c-context-id ccontextid set ms self ] report ms end ;; create-a-node to-report create-a-context [ name xpos ypos unique lsid lsname cconceptid ccontextid] ;; an external context (slider) let ms 0 create-nodelabels 1 [ ;; first create a text label set size 0 set color white setxy (xpos ) ( ypos - 2 ) set label name set label-color black ; set label node-label ; set xoffset x-label-offset ; set yoffset y-label-offset set ms self ] create-contexts 1 ;; create the context [ set size 4 setxy xpos ypos set label-color black set activity-level 0 set newactivity-level 0 set non-slider 0 set shape "slider0" ifelse show_numeric_values? ;; set in a switch [set label (round activity-level)] [set label ""] set click-mode 0 ;; 0=normal ifelse (unique = "") [ set unique-id date-and-time ] [ set unique-id unique ] set labelnode ms set ls-id lsid set ls-name lsname set c-concept-id cconceptid set c-context-id ccontextid set ms self ] report ms end ;; create-a-context to connect-excite [other-node] ;; create an "excite" link between self and other create-excite-to other-node [set shape excite-shape set color green] end ;; connect-excite to connect-inhibit [other-node] ;; create an "inhibit" link between self and other create-inhibit-to other-node [set shape inhibit-shape set color red] end ;; connect-inhibit to move if what = "concepts" [move-concepts] if what = "sliders" [move-contexts] ;; external context slider if what = "excites" [move-excites] if what = "inhibits" [move-inhibits] if what = "boxes" [move-boxes] set model-started? true end ;; move to move-concepts ;; move a concept if (not moving-concept?) [ set movewhichnode closest-xy mouse-xcor mouse-ycor nodes ask movewhichnode [if (who > 3) [set moving-concept? true ]] ;; select just one concept per mouse down ] let l 0 let o 0 let x 0 let y 0 let c 0 let oc 0 let t movewhichnode ask t [ if (who > 3) ;; if a regular concept node [ set l labelnode set o labeloffset set c commentnode set oc commentoffset ifelse mouse-down? [ ;; allow for dragging of nodes to a new location when mouse is down ; while [mouse-down?] [ ;; "while" doesn't work in NetLogo Web with "mouse-down?" set x (within-x mouse-xcor) set y (within-y mouse-ycor) ; no-display ;; "no-display" not supported by NetLogo Web ask t [setxy x y ] ask l [setxy (within-x-left (x + xoffset) label) (within-y (y + yoffset))] if (c != 0) [ask c [setxy (within-x-left (x + xoffset ) label ) (within-y (y - yoffset))]] ; display ask t [ ifelse ( distance trashcan < 1 ) [ask trashcanicon [set label " "]] [ask trashcanicon [set label "Trash " ]] ] ] ;; end mouse-down? section ;; if concept node is on the same patch as trashcan, then ;; delete the links to and from, the label-node, the comment node, and the concept node itself [ ;; this is the not mouse-down? section - i.e. the mouse is now up set moving-concept? false ask trashcanicon [set label "Trash "] if (t = nobody) or (t = 0) [stop] ask t [ if ( distance trashcan < 1 ) [ ask my-in-excites [ die ] ask my-out-excites [die] ask my-in-inhibits [ die ] ask my-out-inhibits [die] ask l [ die ] ;; trash the label node for this concept if (commentnode != 0) [ask commentnode [ die ]] ;; if comment node exists, trash it ; if ls-id > -1 [ls:close (list ls-id)] ;; if a child LS model, close it die ;; delete the concept node itself ] ] ]]] end ;; move-concepts to move-contexts ;; move an external if (count contexts < 1) [stop] ;; no externals to move if (not moving-external?) [set movewhichnode closest-xy mouse-xcor mouse-ycor contexts set moving-external? true ] ;; select just one external per mouse down let c 0 let oc 0 let t movewhichnode if (t = nobody) or (t = 0) [stop] ifelse mouse-down? [ ;; allow for dragging of contexts to a new location ; while [mouse-down?] [ ;; "while" doesn't work in NetLogo Web with "mouse-down?" ; no-display ;; "no-display" not supported by NetLogo Web ask t [setxy (within-x mouse-xcor) (within-y mouse-ycor) ask labelnode [setxy (within-x-left mouse-xcor label) (within-y (mouse-ycor - 2))] set c commentnode set oc commentoffset] if (c != 0) [ask c [setxy (within-x-left (mouse-xcor + xoffset ) label ) (within-y (mouse-ycor - yoffset))]] ; display ask t [ ifelse ( distance trashcan < 1 ) [ask trashcanicon [set label " "]] [ask trashcanicon [set label "Trash "]] ] ] ;; end mouse-down? section ;; if context (aka external aka slider) node is on the same patch as trashcan and user has let up on mouse, ;; then delete any excite or inhibit links, then delete the context (aka external) node itself [ ;; this is the not mouse-down? section - i.e. mouse is now back up set moving-external? false ;; so we can pick another external on the next mouse down ask trashcanicon [set label "Trash "] ask t [ if ( distance trashcan < 1 ) ;; if the context external node is over the trash can [ if (which-context = self) [ set selected-context? false ] ;; if this external has been selected, unselect ask my-in-excites [die] ask my-out-excites [die] ;; delete any connected excites or inhibits ask my-in-inhibits [die] ask my-out-inhibits [die] ask labelnode [die] if (commentnode != 0) [ask commentnode [ die ]] ;; if comment node exists, trash it ; if ls-id > -1 [ls:close (list ls-id)] ;; if a child LS model, close it die ;; delete the context node itself ] ] ] ;; end not mouse-down? end ;; move-contexts to move-excites ;; move an excite link if (count excites < 1) [stop] let t 0 let c 0 let cx 0 let d 0 let dc 0 let tset 0 ; let whichend 0 let olda 0 let oldb 0 let farend 0 ;; had to make these globals to work with NetLogo Web if mouse-down? ;; allow for dragging of links to a new location [ if not moving-excite? ;; if just starting to move a link [ set c closest-xy mouse-xcor mouse-ycor nodes ;; find the closest concept node if (c = nobody) [stop] ;; pick one of the excite links to or from this concept node ask c [set tset (turtle-set out-excite-neighbors in-excite-neighbors)] ;; the set of all excite links in or out if tset = no-turtles [stop] ;; no excites to move ; set t closest-xy mouse-xcor mouse-ycor t ;; the closest connected node ;; old way to select an excite link set t one-of tset ;; one random connected node repeat 10 ;; "while" would be cleaner, but doesn't work in NetLogo Web [ if t = previouslink [set t one-of tset] ] ;; if the same link is selected a 2nd time in a row, pick another set previouslink t set t one-of (link-set (excite [who] of c [who] of t) (excite [who] of t [who] of c)) if (t = nobody) [stop] create-nodes 1 [set shape "x" set size 1 set color black set m_3 self setxy mouse-xcor mouse-ycor] ask t [set olda end1 set oldb end2 ifelse (c = end1 ) [set whichend 1] [set whichend 2] ] ;; figure out which end is closest ;; and temporarily make the current "marker node" the end point ask c [ask t [set farend other-end]] ;; end1 is the from end; end2 is the to end ask t [die] ifelse (whichend = 1) [ask farend [create-excite-from m_3 [set t self set shape excite-shape set color green]]] [ask farend [create-excite-to m_3 [set t self set shape excite-shape set color green]]] set moving-excite? true ] ;; end first time through move-excites ; while [mouse-down?] [ ;; not using "while" because it doesn't work in NetLogo Web with "mouse-down?" ask m_3 [ setxy mouse-xcor mouse-ycor ] ] ;; end mouse down if not mouse-down? ;; user has let mouse button up [ if not moving-excite? [stop] ;; if not in the process of moving a link, stop ;; kill current excite link and create new one from node at the other end and the marker ;; Then when the mouse is up; kill the current excite link, and create a new one from the node at the other ;; end and the closest node ask m_3 [ die ] ;; get rid of "marker" turtle set c closest-xy mouse-xcor mouse-ycor nodes ;; find the closest concept node if (c = (node 2)) [set moving-excite? false stop] ask c [set d distancexy mouse-xcor mouse-ycor] if (whichend = 1) [ ;;; if "from" end set cx closest-xy mouse-xcor mouse-ycor contexts ;; find the closest context node if (cx != nobody) [ask cx [set dc distancexy mouse-xcor mouse-ycor] if (d > dc) [set c cx]] ;; if the context node is closer, make it the new endpoint ] if (c != trashcan) [ ifelse (whichend = 1) ;; 1 is from end, 2 is to end [ifelse (c = oldb) [ask olda [connect-excite farend]] [ask c [connect-excite farend ]] ] [ifelse (c = olda) ;; whichend = 2 [ask farend [connect-excite oldb ]] [ask farend [connect-excite c ]] ] ] set moving-excite? false ] end ;; move-excites to move-inhibits ;; move an inhibit link if (count inhibits < 1) [stop] let t 0 let c 0 let cx 0 let d 0 let dc 0 let tset 0 ; let whichend 0 let olda 0 let oldb 0 let farend 0 ;; had to make these globals to work with NetLogo Web if mouse-down? ;; allow for dragging of links to a new location [ if not moving-inhibit? ;; if just starting to move a link [ set c closest-xy mouse-xcor mouse-ycor nodes ;; find the closest concept node if (c = nobody) [stop] ;; find the closest inhibit link ask c [set tset (turtle-set out-inhibit-neighbors in-inhibit-neighbors)] ;; the set of all inhibit links in or out if tset = no-turtles [stop] ;; no inhibits to move ; set t closest-xy mouse-xcor mouse-ycor tset ;; the closest connected node ;; old way set t one-of tset ;; one random connected node repeat 10 ;; "while" would be cleaner, but doesn't work in NetLogo Web [ if t = previouslink [set t one-of tset] ] ;; if the same link is selected a 2nd time in a row, pick another set previouslink t set t one-of (link-set (inhibit [who] of c [who] of t) (inhibit [who] of t [who] of c)) ; if (t = nobody) [stop] create-nodes 1 [set shape "x" set size 1 set color black set m_3 self setxy mouse-xcor mouse-ycor] ask t [set olda end1 set oldb end2 ifelse (c = end1 ) [set whichend 1] [set whichend 2] ] ;; figure out which end is closest ;; and temporarily make the current "marker node" the end point ask c [ask t [set farend other-end]] ;; end1 is the from end; end2 is the to end ask t [die] ifelse (whichend = 1) [ask farend [create-inhibit-from m_3 [set t self set shape inhibit-shape set color red]]] [ask farend [create-inhibit-to m_3 [set t self set shape inhibit-shape set color red]]] set moving-inhibit? true ] ;; end first time through move-excites ; while [mouse-down?] [ ;; not using "while" because it doesn't work in NetLogo Web with "mouse-down?" ask m_3 [ setxy mouse-xcor mouse-ycor ] ] ;; end mouse down if not mouse-down? ;; user has let mouse button up [ if not moving-inhibit? [stop] ;; if not in the process of moving a link, stop ;; kill current inhibit link and create new one from node at the other end and the marker ;; Then when the mouse is up; kill the current inhibit link, and create a new one from the node at the other ;; end and the closest node ask m_3 [ die ] ;; get rid of "marker" turtle set c closest-xy mouse-xcor mouse-ycor nodes ;; find the closest concept node if (c = (node 2)) [set moving-inhibit? false stop] ask c [set d distancexy mouse-xcor mouse-ycor] if (whichend = 1) [ ;;; if "from" end set cx closest-xy mouse-xcor mouse-ycor contexts ;; find the closest context node if (cx != nobody) [ask cx [set dc distancexy mouse-xcor mouse-ycor] if (d > dc) [set c cx]] ;; if the context node is closer, make it the new endpoint ] if (c != trashcan) [ ifelse (whichend = 1) ;; 1 is from end, 2 is to end [ifelse (c = oldb) [ask olda [connect-inhibit farend]] [ask c [connect-inhibit farend ]] ] [ifelse (c = olda) ;; whichend = 2 [ask farend [connect-inhibit oldb ]] [ask farend [connect-inhibit c ]] ] ] set moving-inhibit? false ] end ;; move-inhibits to move-boxes ;; move a box if (count boxes < 1) [stop] ;; no boxes to move if creating-a-box? [stop] ;; don't allow moving boxes when in the process of creating a new one ; let start-upper-left-x 0 let start-upper-left-y 0 let start-lower-right-x 0 let start-lower-right-y 0 ;; the above variable are globals to allow this to work in NetLogo Web let c 0 let oc 0 ;; let start-x 0 let start-y 0 ifelse mouse-down? [ ;; allow for dragging of boxes to a new location ; while [mouse-down?] [ ;; "while" not supported by NetLogo Web with "mouse-down?" ; no-display ;; "no-display" not supported by NetLogo Web if (not moving-boxes?) [ set movewhichnode closest-xy mouse-xcor mouse-ycor boxes ask movewhichnode [ erase-a-box (within-x box-upper-left-x) (within-y box-upper-left-y) (within-x box-lower-right-x) (within-y box-lower-right-y) set start-upper-left-x box-upper-left-x set start-upper-left-y box-upper-left-y set start-lower-right-x box-lower-right-x set start-lower-right-y box-lower-right-y set start-x xcor set start-y ycor ] set moving-boxes? true ] ;; select just one box per mouse down ask movewhichnode [ setxy (within-x mouse-xcor) (within-y mouse-ycor) ;; move the box when the mouse is down ifelse ( distance trashcan < 1 ) [ask trashcanicon [set label " "]] [ask trashcanicon [set label "Trash "]] ] ] ;; end mouse-down? section [ ;; this is the not mouse-down? section - i.e. mouse is now back up if moving-boxes? [ let changex (mouse-xcor - start-x) let changey (mouse-ycor - start-y) ask movewhichnode [ set box-upper-left-x (start-upper-left-x + changex) set box-upper-left-y (start-upper-left-y + changey) set box-lower-right-x (start-lower-right-x + changex) set box-lower-right-y (start-lower-right-y + changey) draw-a-box (within-x box-upper-left-x) (within-y box-upper-left-y) (within-x box-lower-right-x) (within-y box-lower-right-y) setxy xcor (within-y (box-upper-left-y + .75));; adjust the box's title turtle's height ] ;; if box is on the same patch as trashcan and user has let up on mouse, then delete the box ask trashcanicon [set label "Trash "] ask movewhichnode [ if ( distance trashcan < 1 ) ;; if the box is over the trash can [ erase-a-box (within-x box-upper-left-x) (within-y box-upper-left-y) (within-x box-lower-right-x) (within-y box-lower-right-y) die ;; delete the box ] ] redraw-boxes set moving-boxes? false ;; so we can pick another box on a future mouse-down? ] ] ;; end not mouse-down? end ;; move-boxes to redraw-boxes ask boxes [ draw-a-box (within-x box-upper-left-x) (within-y box-upper-left-y) (within-x box-lower-right-x) (within-y box-lower-right-y) ] end ;; redraw-boxes to go ;; The run procedure which makes the model progress one cycle step ;; this is where all the interaction between concepts occurs tick ;; advance the tick counter by one ; ls:ask ls:models [ go ] ;; ask any child models to go end ;; go to step ;; update activity levels let returned-activity 0 ; ask contexts [ ; if ls-id > -1 ;; for each child model of an external (slider), communicate with the special child concept and child context (slider) ; [ ; ls:let al activity-level ls:let ccontextid c-context-id ls:let cconceptid c-concept-id ; ls:let ra 0 ; ls:ask ls-id [ ; ask turtle ccontextid [set newactivity-level al] ;; set the new activity level of the associated special context (slider) in the child model ; ] ; set returned-activity [[activity-level] of turtle cconceptid ] ls:of ls-id ; set newactivity-level (returned-activity * attenuation) ;; impact the parent concept by the activity of the associated child concept ; rescale-external ; ] ; ; ifelse show_numeric_values? ;; set in a switch ; [set label (round activity-level)] ; [set label ""] ; ] ; ; ask nodes [ ; if ls-id > -1 ;; for each child model of a concept, communicate with the special child concept and child context (slider) ; [ ; ls:let al activity-level ls:let ccontextid c-context-id ls:let cconceptid c-concept-id ; ls:ask ls-id [ ; ask turtle ccontextid [set newactivity-level al] ;; set the new activity level of the associated special context (slider) in the child model ; ] ; set returned-activity [[activity-level] of turtle cconceptid ] ls:of ls-id ; ask parent-context-node ; [ set newactivity-level returned-activity ] ; ] ; ] ask excites [increment-activity-level ifelse show_connections? [show-link ][hide-link]] ;; distribute the impact of the "excite" links ask inhibits [decrement-activity-level ifelse show_connections? [ show-link ][hide-link]];; distribute the impact of the "inhibit" links show-comments ;; show any comments for the concept or external (slider) that the mouse is over if (selected-context? = true) [ask which-context [ set newactivity-level selected_slider_activity ]] ;; set to the slider value if (mouse-down? and (any? contexts) and (not changed-external?)) ;; when clicked and contexts exist [ ask closest-xy mouse-xcor mouse-ycor contexts ;; advance externals mode [ set click-mode ((click-mode + 1 ) mod 4 ) set changed-external? true if ( which-context = self) [ set selected-context? false ] ] ] if not mouse-down? [set changed-external? false] if ((ticks mod modenumber) = 0) ;; do this every modenumber ticks, which is different for desktop and web versions (and if running child models) [ ask contexts [ if (click-mode = 1) [set newactivity-level (max list 0 (min list 200 (newactivity-level + 1))) if (newactivity-level = activity-level) [set click-mode 2] ] if (click-mode = 3) [set newactivity-level (max list 0 (min list 200 (newactivity-level - 1))) if (newactivity-level = activity-level) [set click-mode 0] ] set activity-level newactivity-level rescale-external ] ] update-activity-levels ;; update all the activity levels after all the impacts have been made end ;; step to rescale-external if (non-slider = 0) [ifelse (activity-level < 25) [set shape "slider0"] [ifelse activity-level < 75 [set shape "slider25"] [ifelse activity-level < 125 [set shape "slider50"] [ifelse activity-level < 175 [set shape "slider75"] [set shape "slider100"]]]]] set size ( activity-level / 50 ) + 2 ifelse show_numeric_values? ;; set in a switch [set label (round activity-level)] [set label ""] end ;; rescale-external to update-activity-levels ask nodes [update-activity-level] ;; change activity levels to reflect the impact of all inputs this cycle ;; reset newactivity-level to external-activity-level and update display of activity level for each node end ;; update-activity-levels to update-activity-level set newactivity-level ((newactivity-level + activity-level) / 2) ;; time smoothing ; set activity-level max list 0 (min list 100 ([newactivity-level] of self)) ;; keep activity-level between 0 and 100 set activity-level max list 0 (min list 100 newactivity-level) ;; keep activity-level between 0 and 100 set newactivity-level external-activity-level ;; reset newactivity-level to the level set by external factors for next cycle set color 29 - (activity-level / 25) ;; set each node to a color to indicate its activity-level (29 is light orange; larger activity-level is darker) set size ( activity-level / 35 ) + 1 ifelse show_numeric_values? ;; set in a switch [set label (round activity-level)] [set label ""] end ;; update-activity-level to increment-activity-level ;; increment the new activity level of b by (attenuation * activity-level of a) let impact 0 ask end1 [set impact (attenuation * activity-level)] ask end2 [set newactivity-level ([newactivity-level] of self + impact)] ;; add the impact end ;; increment-activity-level to decrement-activity-level ;; decrement the new activity level of b by (attenuation * activity-level of a) let impact 0 ask end1 [set impact (attenuation * activity-level)] ask end2 [set newactivity-level ([newactivity-level] of self - impact)] ;; subtract the impact end ;; decrement-activity-level to click_context if (mouse-down?) ;; when clicked [ set which-context closest-xy mouse-xcor mouse-ycor contexts if (which-context = nobody) [stop] set selected-context? true ] if (selected-context? = true) [ask which-context [ set newactivity-level selected_slider_activity ;; set to the slider value set activity-level newactivity-level ifelse (activity-level < 25) [set shape "slider0"] [ifelse activity-level < 75 [set shape "slider25"] [ifelse activity-level < 125 [set shape "slider50"] [ifelse activity-level < 175 [set shape "slider75"] [set shape "slider100"]]]] set size ( activity-level / 50 ) + 2 ifelse show_numeric_values? ;; set in a switch [set label (round activity-level)] [set label ""] ] ] end ;; click_context to edit-labels if creating-a-box? [stop] ;; don't allow editing of labels when in the process of creating a new box let t 0 let x 0 ;; let oldxoffset 0 if mouse-down? [ ;; allow for editing of concept labels and box labels set t closest-xy mouse-xcor mouse-ycor (turtle-set nodes boxes) ;; find the closest concept node or box if (t = nobody ) [stop] ask t [if (who > 3) [ set x (user-input "New label?") ifelse (is-node? t) [ask t [ let cx xcor let cy ycor ask labelnode [ set label x set xoffset (center x) setxy (within-x-left (cx + xoffset) label) (within-y (cy + yoffset)) ] ] ] ;; else t is a box [ask t [ set label x set box-name x ] ] set model-started? true ]] ] end ;; edit-labels ;to edit-labels ; let t 0 let x 0 ;; let oldxoffset 0 ; if mouse-down? [ ;; allow for editing of concept labels ; set t closest-xy mouse-xcor mouse-ycor nodes ;; find the closest concept node ; if (t = nobody ) [stop] ; ask t [if (who > 3) ; [ ; set x (user-input "New label?") ; ask t [ ; let cx xcor let cy ycor ; ask labelnode ; [ ; set label x ; set xoffset (center x) ; setxy (within-x-left (cx + xoffset) label) (within-y (cy + yoffset)) ; ] ; ] ; set model-started? true ; ]] ; ] ;end ;; edit-labels to edit-comments if creating-a-box? [stop] ;; don't allow editing of comments when in the process of creating a new box let t 0 let what-comment 0 let oldxoffset 0 let cs 0 if mouse-down? [ ;; allow for creating or editing of concept or context "popup" comments set t closest-xy mouse-xcor mouse-ycor (turtle-set nodes contexts) ;; find the closest node or external context (slider) if (t = nobody) [stop] ask t [ if (who > 3) [ set what-comment (user-input "New comment?") create-comment t what-comment xcor ycor set model-started? true ]]] end ;; edit-comments to create-comment [ for-what which-comment x y ] let cs 0 ask for-what [set comments which-comment set commentoffset (center which-comment) if (commentnode = 0) ;; no commentnode? [ hatch-nodelabels 1 [ ;; then create one set color white set size 0 set xoffset (center which-comment) set yoffset -2.75 set label-color cyan ;; was turquoise hide-turtle set cs self ] set commentnode cs ] ask commentnode [ set label which-comment set xoffset (center which-comment) setxy (within-x-left (x + xoffset) which-comment) (within-y (y - yoffset )) ] ] end ;; create-comment to show-comments if (patch mouse-xcor mouse-ycor = nobody) [stop] ask patch mouse-xcor mouse-ycor [ let current-concept one-of nodes-here ; if current-concept = nobody [stop] if (not is-turtle? current-concept) [ set current-concept one-of contexts-here ] if (current-concept != previous-concept) [ ifelse (current-concept = nobody) [ask previous-concept [if (commentnode != 0) [ask commentnode [hide-turtle]]]] [ask current-concept [if (comments != 0) [ask commentnode [show-turtle]]]] set previous-concept current-concept ] ] end ;; show-comments to-report within-x-left [ x labeltext ] ;; to keep comments from being moved off the left edge of the world report within-x (max (list x (min-pxcor + ((length labeltext) * .4)))) end ;; within-x-left to select-a-concept if mouse-down? [ set plotted-concept closest-xy mouse-xcor mouse-ycor nodes ask plotted-concept [if (who < 4) [set plotted-concept ""] ] stop ] end ;; select-a-concept ;; Clearing, opening, and saving models to clear-model ;; start over with a clean slate if (model-started? = true) [if user-yes-or-no? "Your MM Model has changed. Do you want to save it first?" [save-model]] setup ; ls:reset ;; close any child models end ;; clear-model to open-model clear-model ; let model-file-name ( word own-name ".csv" ) ; ifelse file-exists? model-file-name ; [ import-world model-file-name ] ; [ run save-things ; ] ; open-child-models ;; if there are any LevelSpace child models, open them go go reset-ticks ;; this shows the model more accurately ; ls:ask ls:models [ reset-ticks set modenumber 50 ] ; if (not (ls:models = [])) [ set modenumber 50 ] end ;; open-model to open-child-models ; ls:reset ;; close any previously open child models ; ; ask contexts ; [if (LS-id > -1) ;; [ifelse (not (ls:model-exists? ls-id)) ;; [set LS-id -1] ;; there's no child model for this context (slider) ; [ifelse file-exists? LS-name ; [ls:create-interactive-models 1 LS-name ; set LS-id (last ls:models) ;; make sure LS-id number corresponds to this child model ; let lsid LS-id ; ask labelnode [ set label (word parent-marker lsid " " (clean-name label)) ]] ; [user-message (word "Child file " LS-name " couldn't be found.") ; let lsid LS-id ; ask labelnode [ set label (delete-child-parent-name (word parent-marker lsid " ") label) set label-color black ] ; set LS-id -1 set c-concept-id -1 set c-context-id -1 set label-color black set model-started? true ; ] ; ] ; ] ;; ] ; ; ask nodes [ ; if (LS-id > -1) ;; [ifelse (not (ls:model-exists? ls-id)) ;; [ ;; print (word "LS-id=" LS-id) ;; set LS-id -1 ] ;; there's no child model for this concept ; [ifelse file-exists? LS-name ; [ls:create-interactive-models 1 LS-name ; set LS-id (last ls:models) ;; make sure LS-id number corresponds to this child model ; let lsid LS-id ; ask labelnode [ set label (word parent-marker lsid " " (clean-name label)) ]] ; [user-message (word "Child file " LS-name " couldn't be found.") ; let lsid LS-id ; ask labelnode [ set label (delete-child-parent-name (word parent-marker lsid " ") label) set label-color black ] ; set LS-id -1 set c-concept-id -1 set c-context-id -1 set label-color black set model-started? true ; ] ; ] ; ] ;; ] ; ; ls:ask ls:models [ startup ] ;; get all the child models going end ;; open-child-models to-report clean-name [ name ] ;; delete the first word (parent-marker (i.e. "P:" or "C:") and LS-ID and space) let first-space (position " " name) ifelse (is-number? first-space) [report substring name (first-space + 1) (length name)] [report name] ;; no space in name end ;; clean-name to save-model let label_node "" let this-comment "" ; set own-name pathdir:get-model-name ;; use the pathdir extension to get the name of this model set save-things "" clear-hanging-links ask nodes [ if (who > 3) [ ;; don't save trashcan or link points ifelse (labelnode = 0) [set label_node ""][set label_node [label] of labelnode] ifelse comments = 0 [ set this-comment "" ] [ set this-comment comments ] set save-things (word save-things "re-create-a-node " "\"" (quote-string label_node) "\"" " " xcor " " ycor " \"" unique-id "\" \"" (quote-string this-comment) "\" " ls-id " \"" ls-name "\"" " " c-concept-id " " c-context-id "\n") ] ] ask contexts [ ifelse comments = 0 [ set this-comment "" ] [ set this-comment comments ] ifelse (labelnode = 0) [set label_node ""][set label_node [label] of labelnode] set save-things (word save-things "re-create-a-context " "\"" (quote-string label_node) "\"" " " xcor " " ycor " " newactivity-level " \"" unique-id "\" \"" (quote-string this-comment) "\" " ls-id " \"" ls-name "\"" " " c-concept-id " " c-context-id "\n")] ask excites [ set save-things (word save-things "connect-excite-id \"" [ unique-id ] of end1 "\" \"" [ unique-id ] of end2 "\"\n") ] ask inhibits [ set save-things (word save-things "connect-inhibit-id \"" [ unique-id ] of end1 "\" \"" [ unique-id ] of end2 "\"\n") ] ask boxes [set save-things (word save-things "create-a-box " "\"" (quote-string box-name) "\"" " " box-upper-left-x " " box-upper-left-y " " box-lower-right-x " " box-lower-right-y "\n")] ask trashcanicon [ show-turtle ] set model-started? false ; export-world ( word own-name ".csv" ) end ;; save-model to clear-hanging-links ask m_1 [ask my-in-excites [ die ] ask my-out-excites [die] ask my-in-inhibits [ die ] ask my-out-inhibits [die]] ask m_2 [ask my-in-excites [ die ] ask my-out-excites [die] ask my-in-inhibits [ die ] ask my-out-inhibits [die]] end ;; clear-hanging-links to re-create-a-node [ name x y unique-name any-comment lsid lsname cconceptid ccontextid ] let newnode create-a-node name x y (center name) -2.5 0 unique-name lsid lsname cconceptid ccontextid if any-comment != "" [create-comment newnode any-comment x y ] ;; recreate the comment for this node if lsid > -1 [ask newnode [set label-color red ;; to indicate a parent concept or context ask labelnode [set label-color red] ]] end ;; re-create-a-node to re-create-a-context [ name x y cactivity unique-name any-comment lsid lsname cconceptid ccontextid] let newcontext create-a-context name x y unique-name lsid lsname cconceptid ccontextid ask newcontext [ set newactivity-level cactivity if lsid > -1 [set label-color red ;; to indicate a parent concept or context ask labelnode [set label-color red] ] if any-comment != "" [create-comment newcontext any-comment x y ] ;; recreate the comment for this context ] end ;; re-create-a-context to connect-excite-id [ id-from id-to ] let from-node nobody let to-node nobody ask nodes [ if [unique-id] of self = id-from [set from-node self ] ] if from-node = nobody [ask contexts [ if [unique-id] of self = id-from [set from-node self ] ] ] ask nodes [ if [unique-id] of self = id-to [set to-node self] ] ask from-node [ connect-excite to-node] end ;; connect-excite-id to connect-inhibit-id [ id-from id-to ] let from-node nobody let to-node nobody ask nodes [ if [unique-id] of self = id-from [set from-node self ] ] if from-node = nobody [ask contexts [ if [unique-id] of self = id-from [set from-node self ] ] ] ask nodes [ if [unique-id] of self = id-to [set to-node self] ] ask from-node [ connect-inhibit to-node] end ;; connect-inhibit-id ;; Utilities to-report center [label-name] report ((length label-name) * .20 ) ;; centering labels and comments of concepts end ;; center to-report within-x [x] ;; make sure x is within the limits of the display report (max (list (min (list x max-pxcor)) min-pxcor)) end ;; within-x to-report within-y [y] ;; make sure y is within the limits of the display report (max (list (min (list y (max-pycor - 0.75))) ( min-pycor ))) end ;; within-y to-report closest-xy [x y agent-set] ;; Return closest agent to x, y report min-one-of agent-set [distancexy x y] end ;; closest-xy to-report backslash-string [which-string] let pos 0 loop [set pos (position "\\" which-string) if pos = false [report which-string] set which-string replace-item pos which-string "\" ] end ;; backslash-string to-report double-quote-string [which-string] let pos 0 loop [set pos (position "\"" which-string) if pos = false [report which-string] set which-string replace-item pos which-string """ ] end ;; double-quote-string to-report quote-string [which-string] ;; look for \ , replace with \ and look for " , replace with " set which-string backslash-string which-string set which-string double-quote-string which-string report un-quote-string which-string end ;; quote-string to-report un-backslash-string [which-string] let pos 0 loop [set pos (position "\" which-string) if pos = false [report which-string] set which-string (word (substring which-string 0 pos) "\\\\" (substring which-string (pos + 5) length which-string))] end ;; un-backslash-string to-report un-double-quote-string [which-string] let pos 0 loop [set pos (position """ which-string) if pos = false [report which-string] set which-string (word (substring which-string 0 pos) "\\\"" (substring which-string (pos + 5) length which-string))] end ;; un-double-quote-string to-report un-quote-string [which-string] ;; look for \ and replace with \ then look for " and replace with " set which-string un-backslash-string which-string report un-double-quote-string which-string end ;; un-quote-string to draw-a-box [ upper-left-x upper-left-y lower-right-x lower-right-y ] ask b_1 [ show-turtle set color blue setxy (within-x upper-left-x) (within-y upper-left-y) pendown facexy (xcor + 1) ycor ;; turn to the right forward (lower-right-x - upper-left-x) right 90 forward (upper-left-y - lower-right-y) right 90 forward (lower-right-x - upper-left-x) right 90 forward (upper-left-y - lower-right-y) penup hide-turtle setxy 0 (min-pycor + 1) ] end ;; draw-a-box to create-a-box [ title-text upper-left-x upper-left-y lower-right-x lower-right-y ] draw-a-box (within-x upper-left-x) (within-y upper-left-y) (within-x lower-right-x) (within-y lower-right-y) create-boxes 1 ;; title-text upper-left-x upper-left-y lower-right-x lower-right-y [ set label title-text set color white set label-color blue set box-name title-text set box-upper-left-x (within-x upper-left-x) set box-upper-left-y (within-y upper-left-y) set box-lower-right-x (within-x lower-right-x) set box-lower-right-y (within-y lower-right-y) setxy (within-x ( (lower-right-x + upper-left-x + ((length title-text) / 2.5)) / 2)) (within-y (upper-left-y + .75)) ] end ;; create-a-box to erase-a-box [ upper-left-x upper-left-y lower-right-x lower-right-y ] ask b_1 [ show-turtle set pen-size 3 ;; wider pen so erase works in NetLogo Web pen-erase ; set color white pendown setxy (within-x upper-left-x) (within-y upper-left-y) facexy (xcor + 1) ycor ;; turn to the right forward (lower-right-x - upper-left-x) right 90 forward (upper-left-y - lower-right-y) right 90 forward (lower-right-x - upper-left-x) right 90 forward (upper-left-y - lower-right-y) penup hide-turtle set pen-size 1 setxy 0 (min-pycor + 1) ] end ;; erase-a-box @#$#@#$#@ GRAPHICS-WINDOW 366 11 881 527 -1 -1 13.0 1 10 1 1 1 0 0 0 1 -19 19 -19 19 0 0 1 ticks 30.0 BUTTON 39 81 119 114 Clear Model clear-model NIL 1 T OBSERVER NIL NIL NIL NIL 1 BUTTON 8 10 71 43 NIL Go T 1 T OBSERVER NIL NIL NIL NIL 1 BUTTON 169 45 256 78 Move move T 1 T OBSERVER NIL NIL NIL NIL 1 CHOOSER 256 21 354 66 what what "concepts" "sliders" "excites" "inhibits" 0 BUTTON 2 46 80 79 Open Model Open-model NIL 1 T OBSERVER NIL NIL NIL NIL 1 BUTTON 81 46 160 79 Save Model Save-model NIL 1 T OBSERVER NIL NIL NIL NIL 1 BUTTON 169 10 256 43 Create create\n NIL 1 T OBSERVER NIL NIL NIL NIL 1 BUTTON 169 86 255 119 Edit labels edit-labels\n T 1 T OBSERVER NIL NIL NIL NIL 1 BUTTON 257 86 363 119 Edit comments edit-comments T 1 T OBSERVER NIL NIL NIL NIL 1 SLIDER 153 459 349 492 selected_slider_activity selected_slider_activity 0 100 50.0 1 1 NIL HORIZONTAL BUTTON 11 459 154 492 Click on a slider click_context T 1 T OBSERVER NIL NIL NIL NIL 1 PLOT 88 215 248 335 activity NIL NIL 0.0 10.0 0.0 10.0 true false "" "" PENS "default" 1.0 0 -16777216 true "" "" INPUTBOX 257 216 307 276 save-things re-create-a-node \"teacher's M.Ed. view of teaching\" 7.079055441478438 7.582135423613963 \"04:04:07.428 PM 24-Sep-2016\" \"\" -1 \"0\" 0 0\nre-create-a-node \"teacher's re-inspired view\" -10.241273100616016 -1.1858317221765944 \"04:04:40.099 PM 24-Sep-2016\" \"\" -1 \"0\" 0 0\nre-create-a-node \"teacher viewing own M.Ed. digital video\" -9.738193018480493 7.7258725899383975 \"04:03:41.414 PM 24-Sep-2016\" \"\" -1 \"0\" 0 0\nre-create-a-node \"teacher's burned-out view\" 6.791581108829568 -1.1858317221765944 \"04:04:24.333 PM 24-Sep-2016\" \"\" -1 \"0\" 0 0\nre-create-a-context \"\" -13.259753593429158 12.756673411293633 0 \"04:04:48.256 PM 24-Sep-2016\" \"\" -1 \"0\" 0 0\nre-create-a-context \"\" -12.972279260780287 -7.007186958316222 14 \"04:04:56.422 PM 24-Sep-2016\" \"\" -1 \"0\" 0 0\nre-create-a-context \"\" 12.109856262833674 12.037987579671457 11 \"04:04:52.853 PM 24-Sep-2016\" \"\" -1 \"0\" 0 0\nre-create-a-context \"\" 12.397330595482547 -7.222792707802878 75 \"04:05:00.338 PM 24-Sep-2016\" \"\" -1 \"0\" 0 0\nconnect-excite-id \"04:04:07.428 PM 24-Sep-2016\" \"04:03:41.414 PM 24-Sep-2016\"\nconnect-excite-id \"04:04:52.853 PM 24-Sep-2016\" \"04:04:07.428 PM 24-Sep-2016\"\nconnect-excite-id \"04:04:07.428 PM 24-Sep-2016\" \"04:04:40.099 PM 24-Sep-2016\"\nconnect-excite-id \"04:04:48.256 PM 24-Sep-2016\" \"04:03:41.414 PM 24-Sep-2016\"\nconnect-excite-id \"04:04:56.422 PM 24-Sep-2016\" \"04:04:40.099 PM 24-Sep-2016\"\nconnect-excite-id \"04:05:00.338 PM 24-Sep-2016\" \"04:04:24.333 PM 24-Sep-2016\"\nconnect-excite-id \"04:04:40.099 PM 24-Sep-2016\" \"04:04:07.428 PM 24-Sep-2016\"\nconnect-excite-id \"04:03:41.414 PM 24-Sep-2016\" \"04:04:07.428 PM 24-Sep-2016\"\nconnect-inhibit-id \"04:04:24.333 PM 24-Sep-2016\" \"04:04:40.099 PM 24-Sep-2016\"\nconnect-inhibit-id \"04:04:24.333 PM 24-Sep-2016\" \"04:04:07.428 PM 24-Sep-2016\"\nconnect-inhibit-id \"04:04:07.428 PM 24-Sep-2016\" \"04:04:24.333 PM 24-Sep-2016\"\nconnect-inhibit-id \"04:04:40.099 PM 24-Sep-2016\" \"04:04:24.333 PM 24-Sep-2016\"\n 1 1 String TEXTBOX 74 130 339 181 A multi-mediator model\nof learning through reminding\n 14 0.0 0 TEXTBOX 8 167 362 415 Select the Go button above to run this model.\n\nSelect any of the external context nodes (the slider icons in the model to the right) to increase or decrease the amount of impact that context has on the connected concept node. Select it again to stop the change.\n\nSelect the Open Model button to restore the model to its original state.\n\nSelect the Info tab to see more details about this model. 12 0.0 0 SWITCH 12 498 184 531 show_numeric_values? show_numeric_values? 1 1 -1000 PLOT 886 10 1086 194 Concept activity ticks activity level 0.0 10.0 0.0 100.0 true false "" "" PENS "current node" 1.0 0 -817084 true "" "if (not (plotted-concept = \"\")) [ask plotted-concept [plot activity-level]]" BUTTON 896 196 1082 229 Click on a concept to plot select-a-concept T 1 T OBSERVER NIL NIL NIL NIL 1 BUTTON 926 231 1040 264 Clear the plot clear-plot NIL 1 T OBSERVER NIL NIL NIL NIL 1 BUTTON 73 10 160 43 One step go NIL 1 T OBSERVER NIL NIL NIL NIL 1 SWITCH 188 499 349 532 show_connections? show_connections? 0 1 -1000 @#$#@#$#@ # A model of learning by reminding when viewing one's own self-reflective digital video years later **Jim Levin jalevin@ucsd.edu & Chris Halter chalter@ucsd.edu** Education Studies, UC San Diego February 2014; September 2016 ## WHAT IS IT? This is a model of the learning through reminding from viewing one own's self-reflective digital video years later. See the description of this model in the Halter & Levin (2013) paper in the References below. ## HOW IT WORKS Click on the slider icon in the model connected to the "teacher viewing own M.Ed. digital video" concept in the upper left of the model. Note that initially there is little change in the rest of the model, but that once a "tipping point" is reached, major changes occur throughout the model. ## THINGS TO NOTICE Once the "tipping point" is reached from creating the digital videos, the change persists even when the activity of viewing the video goes to zero. This persistent change is a hallmark of learning. You can see a variety of multi-mediator models of learning at: [http://mmm.ucsd.edu/mmm.html](http://mmm.ucsd.edu/mmm.html) ## REFERENCES ## Halter, C., & Levin, J. (2013). _Multi-mediator models of new teacher learning through creating multimedia._ Presented at the American Educational Research Association, San Francisco CA. Retrieved from [http://tinyurl.com/Halter-Levin-AERA2013-paper](http://tinyurl.com/Halter-Levin-AERA2013-paper) Halter, C., & Levin, J. (2014). Digital video projects of, by, and for new teachers: The multiple educational functions of creating multimedia. _Journal of Educational Multimedia and Hypermedia, 23_(1), 383-406. Available online at [https://pages.ucsd.edu/~jalevin/Halter-Levin-JEMH-2014-proof.pdf](https://pages.ucsd.edu/~jalevin/Halter-Levin-JEMH-2014-proof.pdf) ## Creative Commons This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 Unported License. [http://creativecommons.org/licenses/by-nc-sa/4.0/](http://creativecommons.org/licenses/by-nc-sa/4.0/) @#$#@#$#@ 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 empty true 0 excite true 0 Line -7500403 true 150 270 150 30 Line -7500403 true 143 44 150 30 Line -7500403 true 158 44 150 30 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 globe false 0 Circle -13345367 true false 0 0 300 Polygon -13840069 true false 60 30 60 45 90 60 105 60 120 90 135 105 135 120 150 135 165 135 165 150 150 165 150 195 165 210 180 225 180 255 180 270 210 225 225 210 240 180 240 165 225 150 210 150 180 135 165 120 165 90 180 75 195 75 210 75 210 90 225 90 210 60 210 45 225 30 225 15 180 0 globe-left false 0 Rectangle -2674135 true false 60 105 165 195 Circle -13345367 true false 150 0 300 Polygon -13840069 true false 195 45 195 60 225 75 240 75 255 105 270 120 270 135 285 150 300 150 300 165 285 180 285 210 300 225 315 240 315 270 315 285 345 240 360 225 375 195 375 180 360 165 345 165 315 150 300 135 300 105 315 90 330 90 345 90 345 105 360 105 345 75 345 60 360 45 360 30 315 15 Polygon -2674135 true false 60 45 60 255 0 150 60 45 globe-right false 0 Rectangle -2674135 true false 135 105 240 195 Circle -13345367 true false -150 0 300 Polygon -13840069 true false -90 30 -90 45 -60 60 -45 60 -30 90 -15 105 -15 120 0 135 15 135 15 150 0 165 0 195 15 210 30 225 30 255 30 270 60 225 75 210 90 180 90 165 75 150 60 150 30 135 15 120 15 90 30 75 45 75 60 75 60 90 75 90 60 60 60 45 75 30 75 15 30 0 Polygon -2674135 true false 240 45 240 255 300 150 240 45 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 inhibit true 0 Line -7500403 true 150 270 150 30 Line -7500403 true 142 30 158 30 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 link true 0 Line -7500403 true 150 0 150 300 link direction true 0 Line -7500403 true 150 150 30 225 Line -7500403 true 150 150 270 225 old-slider false 15 Rectangle -11221820 true false 105 225 300 300 Rectangle -7500403 true false 135 240 270 270 Rectangle -2674135 true false 195 240 210 270 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 ring false 0 Circle -7500403 false true 0 0 300 slider false 15 Rectangle -11221820 true false 11 149 300 300 Rectangle -7500403 true false 36 178 276 208 Rectangle -2674135 true false 150 168 165 212 slider0 false 15 Rectangle -11221820 true false 11 149 300 300 Rectangle -7500403 true false 36 178 276 208 Rectangle -2674135 true false 30 168 45 212 slider100 false 15 Rectangle -11221820 true false 11 149 300 300 Rectangle -7500403 true false 36 178 276 208 Rectangle -2674135 true false 267 168 282 212 slider25 false 15 Rectangle -11221820 true false 11 149 300 300 Rectangle -7500403 true false 36 178 276 208 Rectangle -2674135 true false 92 170 107 214 slider50 false 15 Rectangle -11221820 true false 11 149 300 300 Rectangle -7500403 true false 36 178 276 208 Rectangle -2674135 true false 151 167 166 211 slider75 false 15 Rectangle -11221820 true false 11 149 300 300 Rectangle -7500403 true false 36 178 276 208 Rectangle -2674135 true false 204 169 219 213 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 trashcan false 1 Polygon -7500403 true false 90 90 105 210 195 210 210 90 150 105 Circle -7500403 true false 105 150 90 Polygon -1 true false 90 90 150 60 210 90 150 105 90 90 Line -7500403 false 90 90 150 60 Line -7500403 false 150 60 210 90 Line -7500403 false 90 90 150 60 Line -7500403 false 90 90 150 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 x false 0 Polygon -7500403 true true 270 75 225 30 30 225 75 270 Polygon -7500403 true true 30 75 75 30 270 225 225 270 @#$#@#$#@ NetLogo 6.4.0 @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ go salience-of node_a go salience-of node_a @#$#@#$#@ @#$#@#$#@ 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 excites 0.0 -0.2 1 1.0 0.0 0.0 0 0.0 1.0 0.2 0 0.0 1.0 link direction true 0 Polygon -14835848 true false 188 105 128 180 248 180 inhibits 0.0 -0.2 1 1.0 0.0 0.0 0 0.0 1.0 0.2 0 0.0 1.0 link direction true 0 Rectangle -2674135 true false 142 120 232 150 net-excites 0.0 -0.2 1 1.0 0.0 0.0 0 0.0 1.0 0.2 0 0.0 1.0 link direction true 0 Polygon -14835848 true false 128 105 68 180 188 180 net-inhibits 0.0 -0.2 1 1.0 0.0 0.0 0 0.0 1.0 0.2 0 0.0 1.0 link direction true 0 Rectangle -2674135 true false 82 120 172 150 @#$#@#$#@ 0 @#$#@#$#@