Agent-based Modelling (ABM) · Introduction Netlogo, first ABM model ... • Stock market...
Transcript of Agent-based Modelling (ABM) · Introduction Netlogo, first ABM model ... • Stock market...
School of somethingFACULTY OF OTHER
Material Criticality
Sustainability Research InstituteFACULTY OF ENVIRONMENT
Agent-based Modelling (ABM) of socio-ecological-technical systems:
A practical introduction
SOEE 5582MTools and Techniques in Ecological Economics
Jonathan Busch, Christof KnoeriSchoolofEarthandEnvironment
1
GoalandObjectives
Goal:
Understandingthebasicconceptsofagent-basedmodellingofsocio-ecologicalsystems,andhavesomeexperienceinapplyingit.
Practice:
IntroductionNetlogo,firstABMmodel,andmodeltesting,experiments,analysis
2
Content
1st March2016i. IntroductiontoSimulationModellingii. IntroductiontoABMiii. PaperdiscussionMacal &North(2010)iv. IntroductiontoNetLogoandtutorialsv. NetLogo conceptsandelements
8th March2016i. DescribingandformulatingABMs;TheODDProtocolii. ImplementingafirstABM(ThePVdiffusionmodel)iii. PaperdiscussionGrimm,etal.(2005)iv. Fromanimationtoscience(Extendingthemodel)v. Assignmentvi. Wrap-up
3
SimulationModels
Analyticalmodelsvs.dynamicsimulationmodels
Analyticalmodels(EIOA,MFA)
• Purpose:Analyseanddescribethesystemindifferentsituations
• Attributes:systemstatechangestimeindependent(static)andfixedstructure(systemelementsandrelations)
Simulationmodels(SD,ABM,EIOA+econometrics)
• Purpose:Understand theunderlying(structural)dynamicsofasystemicchange
• Attributes:systemstatechangesasafunctionoftime(dynamic)andfixedstructure(SD)orflexiblestructure(ABM)
5
Simulationisthe
experimentaluseofmodels
6
WhatisSimulation?
“Weviewartificialsocietiesaslaboratories,whereweattemptto‘grow’certainsocialstructuresinthecomputer– orinsilico – theaimbeingtodiscoverfundamental localormicromechanismsthatare
sufficienttogeneratethemacroscopicsocialstructuresandcollectivebehaviours ofinterest.”
(EPSTEIN1996)
UtilityofsimulationWhendoweneedsimulations?
Whenexperimentsintherealsystem
• arenotethical,
• tooexpensive,
• tootimeintensive
orimpossiblebecause
• therealsystemisnotaccessible,
• therealsystemcannotbesteered,
• therealsystemdoesnotexistyet,
• Somethingistheoreticallyinterestingbutcannotbeanalysedinrealityyet.
7
Utilityofsimulationsinresearchprocess
• Systemunderstanding(understandingrelationshipbetweenindividualdecisionmakingandglobal/socialchange)
• Developandexploretheoriesconcernedwithsocialchange
• Hypothesisbuildinginthebeginningofaresearchproject
• Exanteanalysisofstrategiesandmeasures
• Diagnosis:determineparameterswhichleadtoproblematicchangeswithinthesocialsystem
• Training
8
Themodellingcycle:
Problementity
Computermodel
Simulationresults
Conceptualmodel
Interpretation
Implementation
Modeldesign
Simulation runs
Source:Sargent,1982;Page,19919
TheModelingCycle:ValidationandVerification
Problementity
Computermodel
Simulationresults
Conceptualmodel
Interpretation
Implementation
Modeldesign
Simulation runs
Source:Sargent,1982;Page,1991 10
Historyofsimulationsinsocialsciences
Source:Simulation fortheSocialScientistGilbert&Troitzsch,2005 11
Comparisonofsocialsciencesimulationtechniques
Source:Gilbert&Troitzsch,2005
12
Modellinglanguage
Deductive Computational
Analyticalfocus
Systemicvariables
Analyticalmodels(macroeconomics)
Macro-simulations(system dynamics)
Micromechanism
Rationalchoice(decision&gametheory) Agent-basedmodelling
SystemDynamics(SD)• systemofdifferenceanddifferentialequations• basedonstocks,flowsandfeedbackloops• restrictedtothemacrolevel(top-down)• targetthephenomena(invisiblewhole)
13
Literature:World dynamics (Forester 1969,1971,1980; Meadows etal, 1974, 1992)Business dynamics (Sterman, 2000)
Microsimulations“microanalyticalsimulations”
• Basedonindividuals(bottom-up)
• Complexbutfixedindividualcharacteristics
• Examples:Microeffectsofpopulationdynamics,taxesandtransferpolicies
• Literature:Harding(1996),Mitton,etal.(2000)
14
Cellularautomata(CA)
“CAarediscretedynamicalsystemsthatmodelcomplexbehaviourbasedonsimple,localrulesanimatedonalattice”(JohnvonNeumann&StanislawUlam)
15
GameofLife:FirstpracticalCA(late1960)byJohnConway(Gardner,M.1971)
CellularAutomata(CA)
„Incellularautomatamodelaworldinwhichspaceisrepresentedasauniformgrid,time advancesbysteps,andthe‘laws’oftheworldarerepresentedbyauniformsetofruleswhichcomputeeach cell’sstatefromitsownpreviousstateandthoseofitscloseneighbours.”Examples:• Conway’sGameofLife(Berlekamp etal.1982)(acellcanonly survive
ifthereareeithertwoorthreeotherlivingcellsinitsimmediateneighbourhood)
• Segregation/Migration(Schelling,1971)(Schellingsupposed thatpeoplehada‘threshold oftolerance’ofotherethnicgroups)
• Literature:Hegselmann R.(1996)WolframS.(1986,2002)https://www.youtube.com/watch?v=CgOcEZinQ2I
16
References(neitherexclusivenorcomprehensive)
Berlekamp, E.R.,Conway,J.H.,&Guy,R.K.(2004/1982).Winningwaysforyourmathematicalplays.4:Peters.Costanza,R.,Wainger, L.,Folke,C.,&Maler,K.G.(1993).Modeling complexecologicaleconomic-systems- towardsanevolutionary,dynamicunderstandingofpeopleandnature.Bioscience,43(8),545-555.Epstein,J.M.,&Axtell,R.(1996).Growingartificialsocieties:socialsciencefromthebottomup.Washington,D.C:BrookingsInstitutionPress.Forrester, J.W.(1999/69).UrbanDynamics:PegasusCommunications.Forrester, J.W.(1971).Worlddynamics:Wright-AllenPress.Forrester, J.W.(1990/68).Principlesofsystems:ProductivityPress.Gilbert,N.,&Troitzsch,K.G.(2005).Simulationforthesocialscientist. (2ed.).Berkshire,England:OpenUniversityPress,McGraw-Hill.Grimm,V.,&Railsback,S.F.(2005).Individual-basedModeling andEcology:PrincetonUniversityPress.Grimm,V.,&Railsback,S.F.(2011).Agent-BasedandIndividual-BasedModeling:APracticalIntroduction:PrincetonUniversityPress.Harding,A. (1996).Microsimulation&PublicPolicy:Elsevier.Hegselmann,R.,Mueller,U.,&Troitzsch,K.G.(1996).ModellingandSimulationintheSocialSciencesfromthePhilosophyofSciencePointofView:Springer.Holling,C.S.(1964).AnalysisofComplexPopulationProcesses.CanadianEntomologist,96(1-2).Janssen,M.A.(2002).Complexityandecosystemmanagement:thetheoryandpracticeofmulti-agentsystems.Cheltenham:Elgar.Knoeri,C.,Binder,C.R.,&Althaus,H.J.(2011).Anagentoperationalizationapproachforcontextspecificagent-basedmodeling.JASSSTheJournalofArtificialSocietiesandSocialSimulation,14(2).Levins,R.(1966).StrategyofModelBuildinginPopulationBiology.AmericanScientist,54(4).Meadows,D.H.,Meadows,D.L.,&Randers,J.(1992).Beyondthelimits:confrontingglobalcollapse,envisioningasustainablefuture:ChelseaGreenPub.Meadows,D.L.(1974).Dynamicsofgrowthinafiniteworld:Wright-AllenPress.Mitton,L.,Sutherland,H.,&Weeks,M.(2000).Microsimulation ModellingforPolicyAnalysis:ChallengesandInnovations:CambridgeUniversityPress.Minsky,M.(1968).THEORYOFCOMPUTATION.AmericanMathematicalMonthly,75(4).Sargent,R.G.(1982).VerificationandValidationofSimulationModels.InF.E.Cellier (Ed.),ProgressinModellingandSimulation (pp.159-169).London:AcademicPress.Schelling,T.(1978).Micromotives andMacrobehavior.NewYork:WW Norton&CoLtd.Stachowiak,H.(1973).AllgemeineModelltheorie [GeneralModellingTheory].Berlin:Springer.Sterman, J.D.(2000).Businessdynamics:systemsthinkingandmodeling foracomplexworld.Boston:IrwinMcGraw-Hill.Tesfatsion,L.,&Judd,K.L.(2006).Handbookofcomputationaleconomics:agent-basedcomputationaleconomics (Vol.2).Amsterdam:Elsevier.vanDam,K.H.,Nikolic,I.,&Lukszo,Z.(2013).Agent-BasedModellingofSocio-TechnicalSystems (Vol.9):Springer,Netherlands.Wolfram,S.(1986).TheoryandApplicationsofCellularAutomata:(includesSelectedPapers1983- 1986):WorldScientificPub.Wolfram,S.(2002).Anewkindofscience:WolframMedia.
AgentBasedModelling
Aclassicexample:schoolingandflockingbehavior
https://www.youtube.com/watch?v=ctMty7av0jc
19
Aclassicexample:schoolingandflockingbehavior
Tomake“Boids”looklikeaflockandavoidcollisions,theymust:• Swim/flytowardstheirneighbour
• Aligntheirdirectionwithneighbour
• Maintainaseparationdistance
(Reynolds,1987)
20
Acornucopiaoffancymodels,papers,grants...
Reynolds1998
“Boids”inspiredmanymodelsforresearchand“practical”applications...
Recentresults
Ballerinietal.2009:• Starlingflockmovement,responsetopredatorsisreproducedbestifmodel
assumeseachindividualinteractswith6-7nearestneighbors
Hildenbrandt,Carere,&Hemelrijk (2010):• Simulatedstarlingflockscanbeevenmorerealisticiftheyincludesimplified
aerodynamics,attractiontoroostingsites
What have ecological modelers learned?*
*Other than: follow your neighbor and stay together
Developingabodyoftheory
“Looks like a fish school” (Aoki 1982)
Collision avoidance (Reynolds 1987)
Realistic nearest-neighbor distance, polarization (Huth and Wissel 1992)
Flock shapes, response to predators, etc. (Ballerini et al. 2009; Hildenbrand et al. 2010)
WhatmakesanABM?
• Autonomy (nocentralcontrol)
• Activeagents:• pro-activeorgoal-directed
• reactive/perceptive
• boundedrational
• interactive/communicative
• mobile
• adaptation/learning
• Heterogeneity
25
OtherABMapplications
Ecology:• Landuseandlandusechange (Lambin etal.,2003;Parkeretal.,2003;Veldkamp &Verburg,2004;Berger etal.,
2006;Matthews et.al., 2007)
• Ecosystemmanagement (Jansen,2001;Parkeretal.,2003;Bousquet &LePage,2004)
Economics:• Stockmarket simulation(Arthuretal.,1997;LeBaron etal.,1999;LeBaron,2001)
• Computationaleconomics (Tesfatsion &Judd,2006)
Socialscience: (Gilbert&Troitzsch,1999/2005)• Competitionandcooperation(Axelrod,1997)• Groupbuilding(Dittrich etal.,2000)
• Socialnetworks(Liljeros etal.,2001;Dugundji &Gulyas,2004)• Developmentofsocieties (Holme etal.,2003;Newman, 2003)
• Epidemics&pandemics(Carley etal.2006,Epsteinetal.2007)
Politicalscience:• Policyandconflict research (L.-E.Cedermann,2003,2004;L.-E.Cedermann &Girardin,2005)
26
ABMinEcologicalEconomics
27
ModelstoInformPolicy?
“Itisdeeplydestructivetopursueausterityinadepression"
- PaulKrugman(NobelPrizewinner)
28
“Overthelongterm,debtreductioncanraiseoutputbybringingdownrealinterestratesandallowingtaxestobereduced"
- IMF,WorldEconomicOutlook2010
29
RethinkingEconomicModelling
• Manyeconomistshavecriticised economicmodelsinthewakeofthe2008financialcrisis.
• Models,inanattempttobemathematicallyrigorous,aretoodivorcedfromreality.
• Mainstreameconomicsmustengagewithheterodoxeconomicsandothersocialsciences.
30
OECD WEEK2 0 1 5
Meeting of the OECD Councilat Ministerial Level
Paris, 3-4 June 2015
www.oecd.org
OECD Paris2, rue André-Pascal, 75775 Paris Cedex 16
Tel.: +33 (0) 1 45 24 82 00
FINAL NAEC SYNTHESISNew Approaches to Economic Challenges
RethinkingEconomicModelling
Keyrecommendations:1. “…analysing theglobaleconomyasacomplexadaptivesystem.
Thiswillhelptotakeintoaccountuncertainty,spill-overs,systemicrisksandnetworkeffects.“
2. “… toreviewandimproveitsmodellingapproaches,takingamoreintegratedapproachwhilediversifyingthetypesofmodelsituses”
31
EcologicalEconomicsModelling
ABMConclusionsWhatisABM?• Abottomupsimulationmethod;wheretheinteractionofmany
componentsgeneratespatternsonahighersystemlevel.WhatisthepotentialofABM?• ABMmightfillthegapbetweenformal butrestrictivemodels
andwide-rangingbutimprecisequalitativeframeworks.• Allowstodevelop&testtheories(ofindividualbehaviours)
leadingtoemergentphenomena(systembehaviour)LimitationsofABM?• Empiricalfoundation(beyondproof-of-concept)• Rightlevelofdescription(purpose)• Computationalintensityforrobustresults
32
GeneralreadingonABM
• Axelrod,R.(1997).Thecomplexityofcooperation:Agent-basedmodelsofcompetitionandcollaboration.Princeton:PrincetonUniversityPress.
• Cedermann,L.-E.(1997).EmergentActorsinWorldPolitics:HowStatesandNationsDevelopandDissolve.Princeton:PrincetonUniversityPress.
• Epstein,J.M.,&Axtell,R.(1996).Growingartificialsocieties:socialsciencefromthebottomup.Washington,D.C:BrookingsInstitutionPress.
• Heppenstall,A.J.,Crooks,A.T.,&See,L.M.(2012).Agent-BasedModelsofGeographicalSystems:SpringerDordrecht.
• Holland,J.H.(1995).HiddenOrder:HowAdaptationBuildsComplexity.ReadingMA:Addison-Wesley.
• Janssen,M.A.(2002).Complexityandecosystemmanagement:thetheoryandpracticeofmulti-agentsystems.Cheltenham:Elgar.
• Tesfatsion,L.,&Judd,K.L.(2006).Handbookofcomputationaleconomics:agent-basedcomputationaleconomics (Vol.2).Amsterdam:Elsevier.
• Grimm,V.,&Railsback,S.F.(2005).Individual-basedModeling andEcology:PrincetonUniversityPress.
• vanDam,K.H.,Nikolic,I.,&Lukszo,Z.(2013).Agent-BasedModellingofSocio-TechnicalSystems (Vol.9):Springer,Netherlands.
• Miller,J.H.,&Page,S.E.(2007).ComplexAdaptiveSystems:AnIntroductiontoComputationalModelsofSocialLife.PrincetonandOxford:PrincetonUniversityPress.
33
Paperdiscussion
IntroductiontoABM:
Macal,C.M.,&North,M.J.(2010).Tutorialonagent-basedmodellingandsimulation.JournalofSimulation,4(3),151-162.
• WhatarethecharacteristicsofthetreetypicalABMelements?
• HowdoeconomicABMapplicationscontrastwithtraditionaleconomicmodels?
• WhentouseABM?
34
• When the problem has a natural representation as being comprised of agents• When there are decisions and behaviours that can be well-defined• When it is important that agents have behaviours that reflect how individuals actually
behave (if known) • When it is important that agents adapt and change their behaviours • When it is important that agents learn and engage in dynamic strategic interactions • When it is important that agents have a dynamic relationship with other agents, and
agent relationships form, change, and decay • When it is important to model the processes by which agents form organizations,
and adaptation and learning are important at the organization level • When it is important that agents have a spatial component to their behaviours and
interactions • When the past is no predictor of the future because the processes of growth and
change are dynamic • When scaling-up to arbitrary levels is important in terms of the number of agents,
agent interactions and agent states • When process structural change needs to be an endogenous result of the model,
rather than an input to the model 35
When to use ABM? (Axtell, 2000, Macal & North, 2008)
IntroducingNetLogo
ImplementingaConceptualModel
37Sargent,2008
§ All-purposeprogramminglanguages(C++,MatLab,Delphi,Java,etc.)§ Youcandoanythingyouwant(flexibility)§ Youhavetoimplementanythingyouwantyourself.Almostnothing
thatsupportsABMsisprovidedready-to-use§ Noobserverfacilities§ Platformsoftenproprietary
§ SoftwarelibrariesdesignedforABMs(Swarm,Repast,Mason)§ Youcandoanythingyouwant(flexibility)§ ManyABM-specificthingsprovided,includingobservertools§ Free(basedonObjectiveCorJava)§ Usercommunities§ Easiertosharecodewithothers(samedesignconcepts)§ Steeplearningcurve(unsuitableforbeginnerscourse)
HowtoimplementAgent-basedmodels?
38
Integratedsoftwareplatforms(NetLogo)§ Easytouseforbeginners(goodforcourses)§ ProvidesmanyABMthings§ Powerfulconcepts(patches,turtles,ask)§ Youcanprobablydo(almost)anythingyouwant,butthatmight
sometimesrequirework-arounds§ Veryeasytosharecode§ Verygooddocumentation§ Usercommunity§ Maintainedbyactivegroup(NorthwesternUniversity)§ Teachingsoftware§ ModellibrarygivesanincompleteideaofNetLogo§ Increasinglyusedfor„seriousscience“
NetLogo
39
Netlogo(Version5.0)
Downloadfrom:
http://ccl.northwestern.edu/netlogo/download.shtml
40
NetLogo:firststeps
• Threetabs:Interface,Information,Code• StartwithTutorials• ModelLibrary• CodeExamples• UserManualandDictionary• FourdifferenttypesofagentsinNetLogo
• Turtles,patches,links,observer(context)• Warning:usually,onlyturtleswouldbereferredtoasagents
• Primitives (commandsandreporters)
NetLogo (showinthesoftware)
41
Work through the NetLogo tutorials 2 and 3:
http://ccl.northwestern.edu/netlogo/5.0/docs/
42
Introduction to NetLogoTutorials
NetLogo Basics– Review*
1) Understandingcodestructure
2) ElementaryNetLogo Commands
43
Adaptedfrom:SteveRailsback andMarinBozic
*LookedatUserManual45timeswhilewritingthis
globals []turtles-own []breed[wolveswolf]
tosetupaskpatches[do-something]askturtles[do-something]
endtogo
askpatches[do-something]askturtles[do-something]tick
endtodo-something-special
endtodo-something-boringend
1. Declarationofvariablesandcollectives
2. ModelInitialization
3. Scheduledactions(tick)
4. Submodels
(scienceandcosmetics)
Input:FundamentalCodeParts
2.ModelInitialization(setup)
IncludeonlythingsDONEONCEtoinitializethemodel
tosetup
clear-all
setuppatchesvariables
paintpatches
createturtles
setupturtlevariables
reset-ticks
end45
3.Scheduledactions(GO)
“go”isrepeatedoverandover toexecutemodelIncludeONLY stufftobeexecutedEACHTIMESTEPKeepthe“go”proceduresimpleandneat(forcomplicatedstuffcallsubmodels)Includeterminationpoint
togo
tick
ifticks>500[stop]
askpatches[update]
askturtles[dosomething]
do-plots
end
46
Tickvs.ticks
tick– incrementstimebyoneperiod
ticks– measuresthetimelapsedsincethestart
Moretechnicalexplanation:• NetLogo hasainternalvariable- tickcounter
• “tick”isaprimitivethatsimplyincrementsthevalueoftickcounter
• “ticks”isareporterthatprovidesthecurrentvalueoftickcounter
47
ElementaryNetLogo commands
A. SearchingNetLogo Dictionary
B. Workingwithagentsets
C. Workingwithvariables
D. Codebranching(conditionalstatements)
E. Workingwithstochasticity
F. Workingwithgraphics
G. Howtomakeyourcodelegibletoothers(documentation,commentsandtabbing)
48
A.SearchingNetLogo Dictionary
NetLogo Dictionaryisawebpage
Use“Findonthispage”inyourwebbrowser
49
B.Workingwithagentsets (ASK)
“ask”tellsallmembersofanagentset*todothecodeinthefollowingbrackets
Allmembersoftheagentset dothecode,oneatatime
Becarefulnottoputanythinginthebracketsthatshouldnotberepeatedforeachmemberoftheagentset!
*Oroneagent
50
ASK:Howarethesedifferent?
askturtles[
buy
sellupdate-bank-account
]
askturtles[buy]askturtles[sell]
askturtles
[update-bank-account
]
51
B.Workingwithagentsets (WITH)
“with”isoneofmanyprimitivesthatsubsetanagentset:
askturtleswith[color=blue][move]
Usethedictionarytogetsyntaxcorrect!!
52
B.Workingwithagentsets (OF)
Whenappliedtoagentsets “of”providesalist ofvaluesofa-ownvariable:
sethappinessmin[happiness]ofneighbors
Moregenerally,“of”isaprimitiveforgettingavaluefromanotheragent:
sethappiness[happiness]ofa-neighbor-turtle
Usethedictionarytogetsyntaxcorrect!!
53
C.Workingwithvariables(=,SET)
Twofundamentalsetsofoperations• Updatingvalueofavariable
à “Assignment”operations
• Checkingifavaluesatisfiessomecondition
à “Conditional”operations
54
(equals ornoequals?)
“Assignment”statements
Wrong:happiness=([happiness]ofa-neighbor-turtle)
Right:sethappiness([happiness]ofa-neighbor-turtle)
55
“Conditional”statements(boolean;yes-or-no)
ifhappiness=3[stop]
ifhappiness<=3[stop]
ifhappiness!=5orticks>17[stop]
C.Workingwithvariables(SETvs.LET)
Global variables– knowntoallprocedures
Local variables– knownonlytooneprocedure
Uselet tocreate andset thevalueofanewlocalvariable:
letmean-neighbor-sizemean[size]ofturtles-onneighbors
Use“set”tochange thevalueofanexistingvariable
• global,turtle,patch...orlocalvariables
setmean-neighbor-sizemean-neighbor-size ^0.5
56
C.Workingwithvariables:Givingavaluetoanotheragent
Howdoesonepatch(turtle)giveitsvalueofavariabletootherpatches?
Therearetwowaystodothis:
1. askneighbors[setpcolor [pcolor]ofmyself]
2. letmy-colorpcoloraskneighbors[setpcolormy-color]
57
D.Codebranching(conditionalstatements)
Ifelse (boolean condition)
[
;Dothisifconditionistrue
]
[ ;else
;Dothisifconditionisfalse
]
58
E.Workingwithstochasticity
UniformdistributionU(a,b)
random(b-a)+a
NormaldistributionN(mean,variance)
random-normalmeanstd
Selectingrandompatches
askpatcheswith[random1<density]
Selectingrandomlyoneagentfromanagentset
askone-ofpatches[setpcolor green]59
F.Workingwithgraphics
ProgrammingGuideà Colors60
F.Workingwithgraphics
topaint-patch
ifelse own-stress-level>=100
[
setpcolor scale-colorredown-stress-level300100
]
[
ifown-stress-level>10
[
setpcolor scale-colorgreenown-stress-level0100
]
]
end61
G.Makingyourcodelegible(tootherpeople)
1) Comment,comment,comment• Variabledeclaration– purposeandrange
• Procedure– purposeanddescription
• Submodel equations– cite,explain
2) Indentthecodesothatitshowsclearcodeblocks(i.e.previousslide)
3) Oncedone,taketimetoprovidedetaileddocumentation(ODD)
62
Finally,whenindoubt,Usethis!!
63
Work through the Mushroom Hunt and Butterfly HilltoppingExercises – both are on the VLE.
64
NetLogo Practice
To do: Readings: Grimm, V., Revilla, E., Berger, U., Jeltsch, F., Mooij, W. M., Railsback, S. F., et al. (2005). Pattern-oriented modeling of agent-based complex systems: Lessons from ecology. Science, 310(5750), 987-991.Practice: Finish Netlogo Tutorials & Exercises, read through the PV diffusion ODD
65
Next week:
ReadtheODDofthePVdiffusionmodelbelow.
Purpose: Thepurposeofthemodelistosimulatethephotovoltaic(PV)solarpaneldiffusioninaregionwithdifferentsubsidyschemes.InspiredbytheslowuptakeofPVdespitetheshortpaybacktime.
Entities,statevariables:Themodelincludesthreetypesofagents;
(i) theobserverrepresentingthepoliticalandeconomicmarketenvironment, issettingpolicyspecificparameter(i.e.PVsubsidies),marketspecificparameters(i.e.PVlifetime,panel-cost,efficiency,andgridelectricitycosts),butaswellagentspecificparameter(i.e.sensingradius,neighbourthreshold, andinterestrate).
(ii) houseowners(turtles)livinginaparticularhousedecidingabouttheinstallationofaPVpanelontheirhouse,basedontheirsocialenvironment,andacost-benefitanalysis.
(iii) patcheshavedifferentsolarpowergenerationpotentialbasedontheirinsolation(afunctionofthelocationonthelandscape)andpatchquality(shadowfromotherbuildingsandrooforientation,randomfactorbetween30-100%) influencingtheoptimalyield.Ifthereisahouseonthepatch,thevaluesforpanelsize(roofsizeavailableforPVinstallation,randomvaluebetween10and40m2)andPVattributesareset.
Scales:Weuseanartificiallandscapeof100x100patches,thetimeresolutionisoneyears(onetickrepresentsoneyear)andwerunthemodelfor50years.
66
FirstNetlogomodel:ThePVdiffusionmodel (ODD)
Processoverviewandscheduling:
Agents(ownersofthehouses)developtheideaofinstallingPVifenoughoftheirneighbours(inacertainsensingradius)havePVinstalled,orinasmallpercentagetheywillcomeupwiththe ideaontheirown.OncetheydevelopedtheIdeaofinstallingaPV,agentscalculatethePVinvestmentanddecide.Thecalculationismadebasedontheagentscostestimationof“his”PVinstallation,consideringsubsidies,investmentcosts, interestrates,feed-intariffs,andtheexpectedelectricitypriceincrease.PVisinstalledifthegenerationcostsperkWhofelectricity(dependingonPVoutput,costs,subsidiesperm2,andinterestrate)arelowerthantheavoidedcosts(gridcostsexpectedtoincrease)plusthefeed-intariff(subsidiesperkWhexpected).
Initialization:
Landscape:Asimpleartificialtopographyofthelandscape(theelevationofeachpatch)isinitializedwhenthemodelstarts.Weassumemaximalonehouseoneachpatch.Patch-qualityisrandomlyassignedbetweenit’sextremevalues.Insolationvariesbetween300-1300W/m2dependingontheelevation(reducedby30%throughfogbelow50m)andtheorientationoftheslope(southmaximalifnofogandnorthminimal).
Agents:Theturtlesrepresentsthehouseownerandareinitializedbycreating5.000ofthemandsettingthemonarandomemptypatch.Roof-sizeandinterestratearerandomlyassignedbetweentheirextremevalues.PVinstallationsarerandomlyassignedto0.1%earlyadoptersandtheageoftheplantissettoarandomvaluebetween 0andPV-lifetime.
67
FirstNetlogomodel:ThePVdiffusionmodel (ODD)
Submodels:
DeterminetheideatoinstallPVpanels:OnlyhouseownerswithoutanexistingPVinstallationenterthissubmodel.Theysensetheirlocalneighbourhood inacertainsensingradiusandifenoughoftheirneighboursalreadyhaveaPVinstalledtheythinkabout installingoneaswell.Theownerssensingradius(defaultof4patches)andtherequired%ofPVinstalledintheneighbourhood tothinkaboutone(defaultof10%),arebothmodelledasglobalparameters.Inadditioneachyear0.1%ofallownerswithout PVthinkabout installingoneindependent oftheirneighbours.
CalculatePVinvestmentbalanceanddecide:PVisinstalledifthegenerationcostsperkWhofelectricity(dependingonPVoutput, costs,subsidiesperm2,andinterestrate)arelowerthantheavoidedcosts(gridcostsexpectedtoincrease)plusthefeed-intariff(subsidiesperkWhexpected).ThegenerationcostsareafunctionofthetotalcostsforthePVinstallationdividedbytheelectricityoutput ofthepanelsovertheirlifetime.Totalcostsdependonthe installationsize,PVcostsperm2,subsidiesperm2,scaledbyadiscountingfactorwhichis(1+interestrate)̂ PVlifetime.Thisincreasesthetotalcostwith increasinginterestrate,which issetasaglobalparameter.Theelectricityoutputoftheinstallationperyearisasimplemultiplicationofinsolation,patch-quality,PV-efficiency,roof-size,wherePV-efficiencyisdefinedasaglobalparameter.TheavoidedcostsperkWhequaltotheelectricitycostsfromthegrid,butsinceagentsexpectanincreaseinelectricityprice(annualgrowthrate),wecalculatesimplifiedmeangridcostsbytakingtheaverageofastartandanendvalue.
68
Section3.5Implementing afirstagent-basedmodelFirstNetlogomodel:ThePVdiffusionmodel (ODD)
Now, letusforthefirsttimewriteaNetLogo programbytranslatingtheODDformulation,forthePV-diffusionmodel.Thewaywearegoingtodothis ishierarchicalandstep-by-step,withmanyinterimtests.Westronglyrecommendyoualwaysdevelopprogramsinthisway:
1. Programtheoverallstructureofamodelfirst,beforestartinganyofthedetails.Thiskeepsyoufromgettinglostinthedetailsearly.Oncetheoverallstructureisinplace,addthedetailsoneatatime.
2. Beforeaddingeachnewelement(aprocedure,avariable,analgorithmrequiringcomplexcode),conductsomebasictestsoftheexistingcodeandsavethefile.Thisway,youalwaysproceedfrom‘firmground’: ifaproblemsuddenlyarises,itverylikely(althoughnotalways)wascausedbythe lastlittlechangeyoumade.
• First,letuscreateanewNetLogo program,saveit,andincludetheODDdescriptionofthemodelontheInformationtab.
• StartNetLogo anduseFile/NewtocreateanewNetLogo program.UseFile/Savetosavetheprogramunderthename“PV-diffusion-1.nlogo” inanappropriatefolder.
• CopytheODDdescriptionofthePVdiffusionmodel.GototheInformationtabinNetLogo,clicktheEditbutton, andpaste inthemodeldescriptionatthetop.ClicktheEditbutton again.
YounowseetheODDdescriptionoftheButterflymodelatthebeginningofthedocumentation.
69
Implementing afirstagent-basedmodelFirstNetlogomodel:ThePVdiffusionmodel