Top Banner
Bill Rand Assistant Professor of Business Management Poole College of Management North Carolina State University Fundamentals of NetLogo
30

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

Jul 11, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Isthisananomaly?

• BehaviorSpacecanhelpwiththe

• Canalsohelpwithparametersweeps

• Theoutputisa.csvfilethatcanbepulledintoanyanalysissoftware