# Programming for Geographical Information Analysis: Advanced Skills - PowerPoint PPT Presentation

PPT – Programming for Geographical Information Analysis: Advanced Skills PowerPoint presentation | free to download - id: 79eb5a-NzIyN

The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
Title:

## Programming for Geographical Information Analysis: Advanced Skills

Description:

### Programming for Geographical Information Analysis: Advanced Skills Lecture 12: Modelling IV: ABM Frameworks and Structure Dr Andy Evans With additions from Dr Nick ... – PowerPoint PPT presentation

Number of Views:74
Avg rating:3.0/5.0
Slides: 59
Provided by: StanO156
Category:
Tags:
Transcript and Presenter's Notes

Title: Programming for Geographical Information Analysis: Advanced Skills

1
Programming for Geographical Information
• Lecture 12 Modelling IV ABM Frameworks and
Structure
• Dr Andy Evans
• With additions from Dr Nick Malleson

2
Structuring a model
• Models generally comprise
• Objects.
• Environment.
• I/O code.
• Data reporting code.
• Some kind of time sequencing.
• Some kind of ordering of processing within a time
step.
• Some kind of decision making and/or rulesets.
• In agent models these are all relatively
explicit.

3
• Structural issues with modelling
• Model Construction Frameworks
• Decision making frameworks

4
• Structural issues with modelling
• Artefacts
• Timing
• Data
• Geography
• Model Construction Frameworks
• Decision making frameworks

5
Artefacts
• Say we had a time step in which cells became x
when a neighbour up and left was x.
• If we calculate from the top left corner and run
across each row, we get this
• We see that in one time step, the third cell
shouldnt be x.
• Wed get a different result if we ran from the
lower right.

6
Artefacts
• With CAs this seems simple.
• In the Excel CA a couple of practicals ago, we
saw that you generally copy the entire grid, then
put changes into another grid temporarily while
doing the calculations.
• This is then copied back into the CA array when
everything is complete.
• This prevents you acting on changed neighbours.
• However, with large agent models we dont want to
be copying the whole system each time.
• So, we might just wait until the end of a step
and update everything. This is certainly one
solution.

7
Synchronous scheduling
• In general models will have a global time
sequence of time-steps (sometimes called ticks in
Logo-based systems) maintained by a clock.
• The agents are told to enact their behaviour at
given time-steps by a scheduler.
• When there is one global time and all agents act
at this speed, none getting ahead in the
sequence, this is known as synchronisation. All
agents broadly see it as the same time.
• Synchronisation doesnt, however, need every
agent to do something each time-step this would
unnecessarily increase processing requirements.
• Different agents may run on different timescales
(every five ticks, for example).

8
Event-based scheduling
• Different agents may run based on event triggers.
• In general, these still work within a
synchronised time-series.
• Either way, as with our array problem, we need to
make sure updates of contacted agents are either
complete or stored for later depending on our
model.
• However, this is often a hard choice. Does a
housebuyer always arrive too late to put in an
offer? Sometimes they must arrive in time.
• In general, therefore, we randomise the order of
agent steps.

9
Parallel synchronisation
• As it is for agents, so it is for parallel models
only more so.
• Parallel developers think hard about
synchronisation.
• Most models adopt conservative synchronisation of
more or less strength, that is, there is some
central scheduler that coordinates jobs around
the global time.
• We need to avoid processes happening out of sync
for most systems.
• This is particularly the case in geographical
systems, which tend to be based on Markov
processes / causality.

10
• However, some processing can be done without
communication.
• It is also the case that events/processes can be
stacked and run through in sequence at whatever
speed a processor can until it needs to respond.
• The difference between now and the first
necessary communication out is known as the
lookahead. A lot of effort goes into working out
what this is and how much can be done in it.

11
Optimistic scheduling
• Optimistic scheduling plays fast and loose with
the amount that is done in this time, but then
recovers if a critical causal event needs to be
injected into a process.
• For example, in the Time Warp Algorithm,
processing is rolled-back if necessary, including
any messages sent.
• As you can imagine, this gets fairly complicated,
and these algorithms only really work where there
is history path-independence in the system.

12
Monte Carlo sampling
• It is also the case that if we have input data
repeatedly entering the model, this can lead to
harmonic artefacts.
• Data running through the system can lead to
internal dynamics that cycle at the same
periodicity producing artefacts this is
particularly problematic with self-adjusting
systems.
• We need some randomisation.
• In general we sample input data randomly, even if
we act to include certain periodicities (e.g.
seasonal). We sample weighted by distribution
so-called Monte Carlo sampling.
• The same thing happens with geographical
variation, so we randomly sample agents occurring
in space too (though more rarely based on a
distribution).

13
Stochastic models
• Deterministic models always end up with the same
answer for the same inputs.
• Stochastic models include some randomisation,
either of data or behaviour.
• As we have seen, these are usually quantified by
repeated runs.
• However, sometimes we want to run under the same
random conditions (e.g. to understand some
behaviour).
• Standard computers without external inputs never
generate truly random numbers they are
random-like sequences, adjusted by some random
seed.
• If we record the random seed, we can re-run the
random model exactly.

14
Space
• Boundary types
• Infinite.
• Bound.
• Torus.
• Other topologies.
• Organisation
• Continuous.
• Grid (square triangular hexagonal other)
• Irregular areas, or quad-tree.
• Network
• Neighbourhoods
• Moore
• Von Neumann
• Diagonal
• Euclidian
• Network

15
GIS and Agent Systems
• Problem is GIS inherently static
• GIS data model represents a single point in time
• Some work into a temporal GIS data model, but no
• But time essential in an ABM
• Need to link GIS and ABM
• Two approaches loose vs tight/close coupling

16
Tight Coupling
• GIS and ABM communicate directly.
• At each iteration the ABM updates GIS on new
system state.
• GIS can display model state dynamically.

17
Loose Coupling
• GIS prepare input for model and display/analyse
results.
• Model does not need to communicate with GIS
directly.
• Quick ABM not constrained by speed of GIS.

18
Issues
• Ideally, then, we need
• A clock/ scheduler, if were not calling each
agent every time-step (and/or some kind of
event-watching system).
• Some way of randomising sampling of agents/agent
locations.
• Some way of running Monte Carlo sampling of both
inputs and parameters.
• A variety of projections/space types/boundaries.

19
• Easy I/O.
• Saving model sequences as video.
• Connectivity to R, Excel, GISs etc.
• Options for distributing and describing models.
• Easy GUI production and visualisation of data.
• Given all this, the thought that someone might
build an agent framework that does all this for
you sounds increasingly good of them.

20
• Structural issues with modelling
• Model Construction Frameworks
• Decision making frameworks

21
ABM Frameworks
• What are they?
• Pieces of software to help people build ABMs.
• Often offer the functions outlined.
• Wide range of tools
• Pre-written functions.
• Entire graphical environment.
• Somewhere in the middle

22
Why use them?
• For non-programmers
• Graphical point-and-click model development.
• Easier than having to learn a programming
language.
• For programmers
• No need to write external functionality (e.g.
drawing graphs, scheduling events, creating
displays).
• Can concentrate on model logic.
• Save time (?)

23
Commonly Used Platforms
• Netlogo http//ccl.northwestern.edu/netlogo/
• Repast http//repast.sourceforge.net/
• MASON http//cs.gmu.edu/eclab/projects/mason/
• Ascape http//ascape.sourceforge.net/
• ABLE http//www.research.ibm.com/able/
• Modelling4All http//www.modelling4all.org/
• SecondLife http//secondlife.com/
• Agent Analyst http//www.spatial.redlands.edu/age
ntanalyst/

24
Recursive Porous Agent Simulation Toolkit (RePast)
• Argonne National Laboratory.
• Based on Swarm.
• Includes a Logo-based language, ReLogo and
graphical programming.
• Imports NetLogo.
• Largely Java programmed.
• Includes 3D GIS using GeoTools.
• Two main versions
• Simphony (Java etc.)
• RePast for HPC (C) (MPI based)
• Based on Eclipse.

25
Functionality
• Flexible scheduling including synchronised and
event-based scheduling.
• Randomisation toolkit.
• Monte Carlo simulation framework.
• Different spaces and boundaries, including
multiple spaces at once.

26
Functionality
• Links with R, Weka, GRASS, Pajek.
• Libraries for genetic algorithms, neural
networks, regression, random number generation,
and specialized mathematics
• http//repast.sourceforge.net/docs/RepastSimphonyF
AQ.pdf
• Exports model shapefiles.
• Exports applications.

27
Example Predictive Model Burglary Simulation
• GIS/ABM Crime Model
• Burglar agents situated in an environment that
mimics Leeds
• Agents use roads, railways and public transport
to travel around the city burgling real buildings

28
Why not use a framework?
• Overheads sometimes there are better ways of
doing the same job if thats all you have to do.
For example, RePasts watch timing is quite heavy
but makes sense as a general framework.
• Constraints sometimes it is hard to squeeze a
model into a Frameworks way of doing things, let
alone then move it to a different framework.

29
• Structural issues with modelling
• Model Construction Frameworks
• Decision making frameworks

30
Thinking in AI
• Agent based systems and other AI can contain
standard maths etc.
• But their real power comes from replicating how
we act in the real world assessing situations,
reasoning about them, making decisions, and then
applying rules.
• Reasoning if a café contains food, and food
removes hunger, a café removes hunger
• Rules if my hunger is high, I should go to a
café

31
Reasoning
• Reasoning is the remit of brain in a box AI.
• Useful for
• Developing rulesets in AI.
• Interpreting requests from people (Natural
Language Processing).
• Developing new knowledge and replicating
sentience.

32
Reasoning
• Programming languages developed in the late 60s
/ early 70s offered the promise of logical
reasoning (Planner Prolog).
• These allow the manipulation of assertions about
the world
• man is mortal and
• Socrates is a man leads to
• Socrates is mortal
• Assertions are usually triples of
• subject-predicate relationship-object.
• There are interfaces for connecting Prolog and
Java
other_languages

33
Reasoning
• This led to SHRDLU (MIT), which could do basic
natural language parsing and responses, based on
a limited knowledge of the world.
• SHRDLU, however, was very limited.
• Need more knowledge about the world.
• Need, therefore, to get everyone involved in
• Led to projects like Cyc / OpenCyc (1984
306,000 facts) and Open Mind Common Sense (1999
1,000,000 facts).

34
Reasoning
• An obvious source for information is the web.
• However, parsing natural language is not easy a
lot of the semantic content (meaning) relies on
context.
• It would be easier if language was embedded in an
ontology (structured collection of knowledge).
For example death the event was marked up as
different from Death the medieval figure
• Obvious similarities to metadata standards for
which (eg Dublin Core) led to work on structuring
knowledge.

35
Semantic Web
• 1990s Tim Berners-Lee and others pushed for a
Semantic Web marked up for meaning in context.
• 1999 Resource Description Framework (RDF) way
of marking up web content so it relates to a
framework of triples defining the content. Very
general.
• Used to identify eg. initial Really Simple
Syndication (RSS) feeds (now not RDF).
• But, not very specific, needs another language to
extend it.

36
DARPA Agent Markup Language
• 1999 DARPA (US Military Research) wanted a
machine-readable knowledge format for agents,
that could be used over the web.
• Developed a RDF extension for this which led to
the Web Ontology Language (OWL).
• This can be used to build more specific RDF
ontologies.
• http//www.schemaweb.info/schema/BrowseSchema.aspx
• Example Friend of a Friend (FOAF)

37
Issues
• Easy to build self-contained ontologies, but what
happens when the same term is used by different
groups. How do we resolve conflicts?
• Automated reasoning about knowledge is still not
great because ontologies dont capture the
estimation and flexibility involved in real
reasoning (eg. accepting paradoxes).
• By concentrating on formal definitions rather
than experience they tend to be circular.
Alternative Folksonomies, but difficult in
modelling.
• Hard to move from knowledge to action. For this
we need rules for when to act, and behaviours.

38
Thinking for agents
• Building up rulesets is somewhat easier.
• Though it is harder to represent them in a
coherent fashion as theres an infinite number of
things one might do.
• While many standards for representing agents
states, few for representing rules, and most very
very limited.
• Usual for these to just be encoded into a
programming language.

39
Rulesets
• Most rules are condition-state-action like
• if hunger is high go to café
• Normally thered be a hunger state variable,
given some value, and a series of thresholds.
• A simple agent would look at the state variable
and implement or not-implement the associated
rule.

40
How do we decide actions?
• Ok to have condition-state-action rules like
• if hunger is high go to café
• And
• if tiredness is high go to bed
• But how do we decide which rule should be enacted
if we have both?
• How do real people choose?

41
Picking rules
• One simple decision making process is to randomly
choose.
• Another is to weight the rules and pick the rule
with the highest weight.
• Roulette Wheel picking weights rules then picks
probabilistically based on the weights using
Monte Carlo sampling.
• How do we pick the weights? Calibration? Do we
adjust them with experience? For example, with a
GA?
• We may try and model specific cognitive biases
• http//en.wikipedia.org/wiki/List_of_cognitive_bi
ases
• Anchoring and adjustment pick an educated or
constrained guess at likelihoods or behaviour and
adjust from that based on evidence.

42
Reality is fuzzy
• Alternatively we may wish to hedge our bets and
run several rules.
• This is especially the case as rules tend to be
binary (run / dont run) yet the world isnt
always like this.
• Say we have two rules
• if hot open window
• if cold close window
• How is hot? 30 degrees? 40 degrees?
• Language isnt usually precise
• We often mix rules (e.g. open the window
slightly).

43
Fuzzy Sets and Logic
• Fuzzy Sets let us say something is 90 one
thing and 10 another, without being
illogical.
• Fuzzy Logic then lets us use this in rules
• E.g. its 90 right to do something, so Ill do
it 90 - opening a window, for example.

44
Fuzzy Sets
• We give things a degree of membership between 0
and 1 in several sets (to a combined total of 1).
• We then label these sets using human terms.
• Encapsulates terms with no consensus definition,
but we might use surveys to define them.

1
Membership function
Hot
Cold
Degree of membership
0.5
20
0
40
Degrees
17 15 cold 85 hot
45
Fuzzy Logic models
• We give our variables membership functions, and
express the variables as nouns (length,
temperature) or adjectives (long, hot).
• We can then build up linguistic equations (IF
length long, AND temperature hot, THEN
openWindow).
• Actions then based on conversion schemes for
converting from fuzzy percentages of inputs to
membership functions of outputs.

46
Bayesian Networks
• Of course, it may be that we see people in one
state, and their actions, but have no way of
replicating the rulesets in human language.
• In this case, we can generate a Bayesian Network.
• These gives probabilities that states will occur
together.
• This can be interpreted as if A then B.
• They allow you to update the probabilities on new
evidence.
• They allow you to chain these rules together to
make inferences.

47
Bayesian Networks
• In a Bayesian Network the states are linked by
probabilities, so
• If A then B if B then C if C then D
• Not only this, but this can be updated when an
event A happens, propagating the new
probabilities by using the new final probability
of B to recalculate the probability of C, etc.

48
Expert Systems
• All these elements may be brought together in an
Expert System.
• These are decision trees, in which rules and
• Forward chaining you input states and the system
runs through the rules to suggest a most scenario
of action.
• Backward chaining you input goals, and the
system tells you the states you need to achieve
to get there.
• Dont have to use Fuzzy Sets or Bayesian
probabilities, but often do.

49
How do we have confidence in our reasoning?
• Expert systems may allow you to assess how
confident you are that a rule should be applied,
though it isnt always clear how confidences add
up.
• For example
• Man is mortal (confidence 0.99)
• Socrates is a man (confidence 0.5)
• Final confidence that Socrates is mortal ?
• Dempster-Shafer theory allows us to deal with the
confidence in an event is happening (assigns a
confidence to each potential event totalling one
for all possible events, and allows us to assess
multiple groups of evidence.)

50
Picking rules
• However, ideally we want a cognitive framework to
embed rule-choice within.
• Something that embeds decision making within a
wider model of thought and existence.

51
Belief-Desire-Intention
• We need some kind of reasoning architecture that
allows the agents to decide or be driven to
decisions.
• Most famous is the Belief-Desire-Intention model.
• Beliefs facts about the world (which can be
rules).
• Desires things the agent wants to do / happen.
• Intentions actions the agent has chosen,
usually from a set of plans.
• Driven by Events, which cascade a series of
changes.

52
Decision making
• BDI decisions are usually made by assuming a
utility function. This might include
• whichever desire is most important wins
• whichever plan achieves most desires
• whichever plan is most likely to succeed
• whichever plan does the above, after testing in
multiple situations
• whichever a community of agents decide on (eg
by voting)
• Desires are goals, rather than more dynamic
drivers.

53
The PECS model
• Similar model is PECS more sophisticated as it
includes internal drivers
• Physis physical states
• Emotional emotional states
• Cognitive facts about the world
• Social status position within society etc.
• On the basis of these, the agent plans and picks
a behaviour.
• Ultimately, though, these are decided between by
a weighted utility function.

54
Thinking for agents
• Ultimately we have to trade off complexity of
reasoning against speed of processing.
• On the one hand, behaviour developed by a GA/GP
would be dumb, but fast (which is why it is used
to control agents in games).
• On the other, full cognitive architecture systems
like Soar, CLARION, and Adaptive Control of
ThoughtRational (ACT-R) are still not perfect,
and take a great deal of time to set up.

55
• Michael Wooldridge (2009) An Introduction to
MultiAgent Systems Wiley (2nd Edition)
• MAS architectures, BDI etc.
• Stuart Russell and Peter Norvig (2010)
Artificial Intelligence A Modern Approach
Prentice Hall (3rd Edition)
• Neural nets, Language Processing, etc.

56
Assessment 2
• 50 project, doing something useful.
• Make an analysis tool (input, analysis, output).
• Do some analysis for someone (string together
some analysis tools).
• Model a system (input, model, output).
• Must do something impossible without coding! Must
be a clear separation from other work.
• Marking will be on code quality.
• Deadline Wed 4th May.

57
Other ideas
• Tutorial on Processing for Kids.
• Spatial Interaction Modelling software.