Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the...
Transcript of Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the...
![Page 1: Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the most widely used ABM environment. It’s the easiest to learn. The NetLogo Design](https://reader034.fdocuments.in/reader034/viewer/2022043019/5f3b9f4cee723e1b3d4f3d97/html5/thumbnails/1.jpg)
BillRand AssistantProfessorofBusinessManagement
PooleCollegeofManagementNorthCarolinaStateUniversity
Fundamentals of
NetLogo
![Page 2: Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the most widely used ABM environment. It’s the easiest to learn. The NetLogo Design](https://reader034.fdocuments.in/reader034/viewer/2022043019/5f3b9f4cee723e1b3d4f3d97/html5/thumbnails/2.jpg)
WhatisaModel?
Anabstracteddescriptionofaprocess,object,oreventExaggeratescertainaspectsattheexpenseofothers
“Essentially,allmodelsarewrong,butsomeareuseful” (GeorgeBox,1987)
![Page 3: Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the most widely used ABM environment. It’s the easiest to learn. The NetLogo Design](https://reader034.fdocuments.in/reader034/viewer/2022043019/5f3b9f4cee723e1b3d4f3d97/html5/thumbnails/3.jpg)
WhatisanAgent-BasedModel?Anagentisanautonomousindividualelementwithpropertiesandactionsinacomputersimulation
Agent-BasedModeling(ABM)istheideathattheworldcanbemodeledusingagents,anenvironment,andadescriptionofagent-agentandagent-environmentinteractions
![Page 4: Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the most widely used ABM environment. It’s the easiest to learn. The NetLogo Design](https://reader034.fdocuments.in/reader034/viewer/2022043019/5f3b9f4cee723e1b3d4f3d97/html5/thumbnails/4.jpg)
ToolkitsforABM
![Page 5: Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the most widely used ABM environment. It’s the easiest to learn. The NetLogo Design](https://reader034.fdocuments.in/reader034/viewer/2022043019/5f3b9f4cee723e1b3d4f3d97/html5/thumbnails/5.jpg)
WhyareweusingNetLogo?
NetLogoisapremieragent-basedmodelinglanguageanddevelopmentenvironment,designedbyUriWilenskyatNorthwesternUniversity.
ItisthemostwidelyusedABMenvironment.
It’stheeasiesttolearn.
![Page 6: Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the most widely used ABM environment. It’s the easiest to learn. The NetLogo Design](https://reader034.fdocuments.in/reader034/viewer/2022043019/5f3b9f4cee723e1b3d4f3d97/html5/thumbnails/6.jpg)
TheNetLogoDesignPrinciple• Lowthreshold
– Novicescanbuildsimplemodelsatfirstuse– Pre-collegiatecurriculumincludescomplexsystemsandmodeling– Universitycoursestoincludemodel-basedinquiry– NewsandMediatoincludemodelsasevidenceforarguments
• Highceiling– Languageshouldbeexpressiveenoughtoenablehighendcomplex
models– Researchersto“read/write”andpublishmodels– Narrow/eliminategapbetweenmodelerandprogrammer– Enableinteractivedevelopmentandresearch– Easytosharemodels– Easytoverifyand/orchallengemodels
![Page 7: Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the most widely used ABM environment. It’s the easiest to learn. The NetLogo Design](https://reader034.fdocuments.in/reader034/viewer/2022043019/5f3b9f4cee723e1b3d4f3d97/html5/thumbnails/7.jpg)
TheBirthoftheTurtle
Logowasfirstdevelopedin~1969bySeymourPapertandcolleagues
![Page 8: Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the most widely used ABM environment. It’s the easiest to learn. The NetLogo Design](https://reader034.fdocuments.in/reader034/viewer/2022043019/5f3b9f4cee723e1b3d4f3d97/html5/thumbnails/8.jpg)
ClimateandEarthModeling
![Page 9: Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the most widely used ABM environment. It’s the easiest to learn. The NetLogo Design](https://reader034.fdocuments.in/reader034/viewer/2022043019/5f3b9f4cee723e1b3d4f3d97/html5/thumbnails/9.jpg)
PoliticalScience
![Page 10: Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the most widely used ABM environment. It’s the easiest to learn. The NetLogo Design](https://reader034.fdocuments.in/reader034/viewer/2022043019/5f3b9f4cee723e1b3d4f3d97/html5/thumbnails/10.jpg)
RecommendedBook
• AnIntroductiontoAgent-BasedModeling• UriWilenskyandWilliamRand
• AvailableatMITPressandAmazon
https://mitpress.mit.edu/books/introduction-agent-based-modeling
http://www.intro-to-abm.com/
![Page 11: Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the most widely used ABM environment. It’s the easiest to learn. The NetLogo Design](https://reader034.fdocuments.in/reader034/viewer/2022043019/5f3b9f4cee723e1b3d4f3d97/html5/thumbnails/11.jpg)
TheTabs
• ThreeTabs• Interface• Info• Code
![Page 12: Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the most widely used ABM environment. It’s the easiest to learn. The NetLogo Design](https://reader034.fdocuments.in/reader034/viewer/2022043019/5f3b9f4cee723e1b3d4f3d97/html5/thumbnails/12.jpg)
InfoTab
• WhatisIt?• HowItWorks• HowtoUseIt• ThingtoNotice• ThingstoTry• ExtendingtheModel• NetLogoFeatures• RelatedModels• CreditsandReferences
![Page 13: Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the most widely used ABM environment. It’s the easiest to learn. The NetLogo Design](https://reader034.fdocuments.in/reader034/viewer/2022043019/5f3b9f4cee723e1b3d4f3d97/html5/thumbnails/13.jpg)
InterfaceElements
• Button• Slider• Chooser• Switch• Input• Monitor• Plot• Output• Note
![Page 14: Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the most widely used ABM environment. It’s the easiest to learn. The NetLogo Design](https://reader034.fdocuments.in/reader034/viewer/2022043019/5f3b9f4cee723e1b3d4f3d97/html5/thumbnails/14.jpg)
RunningAModel
• Setup• Go• SpeedSlider
![Page 15: Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the most widely used ABM environment. It’s the easiest to learn. The NetLogo Design](https://reader034.fdocuments.in/reader034/viewer/2022043019/5f3b9f4cee723e1b3d4f3d97/html5/thumbnails/15.jpg)
ModelSettings
• WorldSize• Wrapping
![Page 16: Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the most widely used ABM environment. It’s the easiest to learn. The NetLogo Design](https://reader034.fdocuments.in/reader034/viewer/2022043019/5f3b9f4cee723e1b3d4f3d97/html5/thumbnails/16.jpg)
TurtleRelevantCommands
• create-turtles(crt)• ask• forward(fd),backward(bk)• left(lt),right(rt)• repeat• color,size,xcor,ycor• pen-down(pd),pen-up(pu)• clear-all(ca)• monitor• die
![Page 17: Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the most widely used ABM environment. It’s the easiest to learn. The NetLogo Design](https://reader034.fdocuments.in/reader034/viewer/2022043019/5f3b9f4cee723e1b3d4f3d97/html5/thumbnails/17.jpg)
Patches
• Inspector• PatchColorispcolor• Turtlescandirectlyaccesspatches• RelevantCommands
• setxy,facexy• random-xcor(pxcor)andrandom-ycor(pycor)
![Page 18: Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the most widely used ABM environment. It’s the easiest to learn. The NetLogo Design](https://reader034.fdocuments.in/reader034/viewer/2022043019/5f3b9f4cee723e1b3d4f3d97/html5/thumbnails/18.jpg)
Links
• Creating-create-link(s)-with/to/from• Linkshavetheirownproperties
![Page 19: Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the most widely used ABM environment. It’s the easiest to learn. The NetLogo Design](https://reader034.fdocuments.in/reader034/viewer/2022043019/5f3b9f4cee723e1b3d4f3d97/html5/thumbnails/19.jpg)
CodeTab
• creatingaprocedure• toandend
• findingprocedures• indentation• checkingcode
![Page 20: Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the most widely used ABM environment. It’s the easiest to learn. The NetLogo Design](https://reader034.fdocuments.in/reader034/viewer/2022043019/5f3b9f4cee723e1b3d4f3d97/html5/thumbnails/20.jpg)
SavingandDocumentingYourCode
• SaveOften• Savemajorchangeswithanewname• EdittheInfoTabatthesametime
![Page 21: Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the most widely used ABM environment. It’s the easiest to learn. The NetLogo Design](https://reader034.fdocuments.in/reader034/viewer/2022043019/5f3b9f4cee723e1b3d4f3d97/html5/thumbnails/21.jpg)
CollectionsofAgents
• Built-InCollections• patches,turtles,links• turtles-here,in-link-neighbors
• AgentBreeds• influentials,imitators• canhavetheirownproperties
• Agentsets• with• turtles-on
![Page 22: Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the most widely used ABM environment. It’s the easiest to learn. The NetLogo Design](https://reader034.fdocuments.in/reader034/viewer/2022043019/5f3b9f4cee723e1b3d4f3d97/html5/thumbnails/22.jpg)
SimpleEconomy• In1996,JoshEpsteinandRobAxtellpublishedoneofthefirst
definitivebooksonagent-basedmodelingandsocialsciencecalled“GrowingArtificialSocieties”,whichwaspopulatedbyartificialeconomicagents
• Wearegoingtocreateasimplemodelofeconomicsagents,inspiredinpartbyEpsteinandAxtellandapaperbyDragulescuandYakovenko(2000)
• TheRules:• 500peoplestartoffwith$100each• Ateverytickeachpersongives$1toanotherpersonrandomly• Ifyourunoutofmoneyyoucan’tgiveanymoremoneyaway
untilsomeonegivesyoumoney• Whatwillthefinaldistributionofwealthbe?
![Page 23: Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the most widely used ABM environment. It’s the easiest to learn. The NetLogo Design](https://reader034.fdocuments.in/reader034/viewer/2022043019/5f3b9f4cee723e1b3d4f3d97/html5/thumbnails/23.jpg)
ControllingNetLogoCode
• setupandgoarenotrequired,butareNetLogostyle
• Othercommands:• tick• if,ifelse• repeat• while
![Page 24: Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the most widely used ABM environment. It’s the easiest to learn. The NetLogo Design](https://reader034.fdocuments.in/reader034/viewer/2022043019/5f3b9f4cee723e1b3d4f3d97/html5/thumbnails/24.jpg)
SettinguptheWorld
![Page 25: Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the most widely used ABM environment. It’s the easiest to learn. The NetLogo Design](https://reader034.fdocuments.in/reader034/viewer/2022043019/5f3b9f4cee723e1b3d4f3d97/html5/thumbnails/25.jpg)
Thesetupprocedureturtles-own[wealth]
tosetup
clear-all
create-turtles500[
setwealth100
setshape"circle"
setcolorgreen
setsize2
;;visualizetheturtlesfromlefttorightinascendingorderofwealth
setxywealthrandom-ycor
]
reset-ticks
end
![Page 26: Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the most widely used ABM environment. It’s the easiest to learn. The NetLogo Design](https://reader034.fdocuments.in/reader034/viewer/2022043019/5f3b9f4cee723e1b3d4f3d97/html5/thumbnails/26.jpg)
Thegoprocedure
togo;;transactandthenupdateyourlocationaskturtleswith[wealth>0][transact];;preventwealthyturtlesfrommovingtoofartotherightaskturtles[ifwealth<=max-pxcor[setxcorwealth]]tickend
![Page 27: Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the most widely used ABM environment. It’s the easiest to learn. The NetLogo Design](https://reader034.fdocuments.in/reader034/viewer/2022043019/5f3b9f4cee723e1b3d4f3d97/html5/thumbnails/27.jpg)
transact
totransact;;giveadollartoanotherturtlesetwealthwealth-1askone-ofotherturtles[setwealthwealth+1]end
![Page 28: Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the most widely used ABM environment. It’s the easiest to learn. The NetLogo Design](https://reader034.fdocuments.in/reader034/viewer/2022043019/5f3b9f4cee723e1b3d4f3d97/html5/thumbnails/28.jpg)
CreatingtheHistogram
![Page 29: Fundamentals of NetLogo · 2018-04-02 · Fundamentals of NetLogo. What is a Model? ... It is the most widely used ABM environment. It’s the easiest to learn. The NetLogo Design](https://reader034.fdocuments.in/reader034/viewer/2022043019/5f3b9f4cee723e1b3d4f3d97/html5/thumbnails/29.jpg)
Isthisananomaly?
• BehaviorSpacecanhelpwiththe
• Canalsohelpwithparametersweeps
• Theoutputisa.csvfilethatcanbepulledintoanyanalysissoftware