okay so today we're going to start
talking
second major component of an HBase model
which is the environment of the model
right and there are a number of
different ways by the way that you can
represent the environment in an
agent-based model and you know
we highlight a couple of these and
they're kind of related or not related
to the actual structure of the
environment right and so for instance
you could have a discrete grid patches
right where the environment is composed
in the number of spaces and each of
those patches can have their own
properties right and that's kind of way
net logo doesn't right you could also
just imagine that the environment is a
uniform space right and that that
environment as a whole has its own
properties but that is and some modeling
environments do that some modeling
environments makes that decision and
that's perfectly OK or you could imagine
that the environment is actually drawn
from external data right that you have
GIS data you have social network data
you have something like that that you're
using to influence the model or maybe
you have a synthetic algorithm to
generate an environment or something
like that right and I just want to kind
of give this as an example as you're
thinking through this because some of
the environments you may have seen are
different than other ones in terms of
the way they're actually represented
within the modeling language now we're
going to talk about my environment
structures or interaction topologies
right upon which the model actually runs
and these are different than the way
that the model can add the environment
can actually be constructed but they're
related in many cases so you can have
spatial environments right which is the
way we've often been thinking about the
environment which is that this agent is
next to this agent meaning that they're
physically next to each other on some
spatial representation right you could
have a network-based environment right
so this is an environment in which the
the interaction topology is not
determined by physical location within
the environment but is instead
determined by the links or relationships
between entities within that network
right
you could have 3d worlds right so you
could have spatial environments that are
in three dimensions which we'll talk a
little bit about and you could have GIS
environments so this is geographic
information
right these are environments that are
drawn from real-world data about the way
our world actually exists right and so
we can use those as the environmental
representation
and I you know I label these aren't all
the possible environments that you can
have you can you know we've talked a
little bit about like feature spaces
which are kind of related to spatial
environments for instance and other
things along those lines but these are
some of the most popular types of
environments are often used within
agent-based models so let's talk a
little bit more about spatial
environments and essentially there are
two major types of spatial environments
you can have discrete spaces or you can
have continuous spaces right and
discrete spaces are often represented as
what's known as a lattice graph or a
mesh graph or a grid graph right where
you have these entities that are kind of
right next to each other and the kind of
one of the most common versions of that
is a square lattice now you don't have
to have a square lattice in fact we will
talk a little bit about how you can have
other types of lattices out there but
these are often defined as the
interaction rules that you have between
the neighbors on the entities so you can
imagine an individual at the middle of
both of these
small subsections of the graph right at
the zero zero coordinate right and they
could interact either with their four
neighbors up down left and right or
they're for neighbors plus the corner
neighbors right and in depending upon
the way you just described this describe
the interaction topology it changes the
kind of environment that the agent is
operating in right so in this particular
context this environment with four
neighbors is called the von Neumann in
neighborhood and actually in that logo
the command to get the four neighbors of
a grid is neighbors four and if they
have neighbors that's called the more
neighborhood right in that command and
that little adjust neighbors which pulls
in all of the eight commands right now
you know often people have say well how
how am I supposed to remember the
difference between those well the von
Neumann and by the way this is John von
Neumann also the when the major
architects of the modern computing
architecture
in this particular case the easiest way
to remember the difference between the
von neumann in the more neighborhood is
that the more neighborhood has more
there are more neighbors in the
neighborhood because they're eight
instead of four and it turns out that
choosing this lattice can greatly affect
the way that your model actually runs
moving from a four a five million
neighborhood to a more neighborhood can
have interesting effects on the overall
development of your model for instance
if you're using a cellular automata
model it can very quickly change how the
model runs
so you can also have a
hex grid and a hex grid as opposed to a
square lattice right is exactly as it
sounds where each know which each agent
each location in the grid is connected
to six other grid elements that are
located next to it the argument that is
often made to use a hex grid over R
square grid is that in the square grid
if you think about it if I am at the
center of that that grid location right
and I'm communicating with a neighbor
who is in the upper-right corner that
the distance between us is much farther
than if I'm communicating with a
neighbor who is directly above me on a
hex grid all of my neighbors are exactly
the same distance from me right and it's
a it's a it's a interesting property of
the X grid and why it's often used to
kind of represent a more uniform
structure right I got a pause and you
can actually so now look it doesn't have
hex grids it's like built-in elements
but you can do hex grids at night Logan
let me show you a couple examples
so here I have the hex cells example and
as you can see our standard net logo
space seems to have been replaced by a
hexagon grid instead right but in
reality the patches are still there in
fact I can show you that real quick
ass patches set a P color
equal to px score plus py core and you
can see that they're there they just
have these hexagons sitting on top of
them right so let's actually ask patches
fuoco they're back to black right and
and we get them back right so how are we
representing hexagons then if we still
have a square lattice underneath well it
turns out what we do to set up the grid
is
that we create a more calling a cell on
top of each patch in that cell is
essentially a turtle that is
representing a
hexagon grid location and what we can do
is we can basically tell it which of its
neighbors are the patches based upon
whether you're like in an even or an odd
location so we can have each agent in
this space be connected to six other
agents right six other agents on the
surrounding grid location so for
instance if you're an even agent right
then you're connected to the agent that
is directly above you directly to your
to your right to your
bottom right and so forth as you as you
go forward through the list right and if
you're odd you're connected to a
different set of patches right and so
this allows us to kind of if you will
fake a hexagon grid on top of a square
lattice
yeah so this is one example of how you
can build hexagon grids and even when
the environment defaults to a square
grid so besides discrete spaces you can
also have two continuous spaces right so
in the previous example right each of
the the grids essentially had discrete
grid elements you were either on or off
it right and but continuous space means
that you're always on a space somehow
and you can move anywhere now that logo
is interesting actually because it's a
continuous space with a discrete grid
laid on top of it right and so you could
either talk to the patches which are
essentially a discrete space or you can
just talk to for instance the XY
coordinates which are a continuous space
so that's kind of a nice advantage of
using that representation so you get the
benefits of both discrete grids and
continuous spaces right now
this is just a quick command I wrote
just to show you kind of what that grid
looks like and why it's actually
distinct but if what if you go to any of
these individual elements the turtle is
is actually not represented as just
being in the center of the patch but
it's representing its actual XY
coordinates with a mismatch so it's a
continuous space with a discrete grid
laid on top
now regardless of what your
what the environment you're using one
there's two discrete or continuous space
you need to think about the boundary
conditions for the model right and in
the the boundary conditions or what we
mean by that is how our agents
interacting with the boundaries of the
space that you have established and
there are three major ways to do that
there is a toroidal topology a bounded
topology or an infinite plane topology
right and the triangle topology which is
one you often see in agent based models
the top of the model is connected to the
bottom of the model and the right of the
model is connected to the left of them
all right and so this is often called
wrapping was what the room weights refer
to the world wrapping sometimes also
referred to as a pacman topology right
as when pac-man goes off the left it
comes back on the right and the boys
model actually is a great example as the
flocking model right so in the flocking
model if a bird goes off the top it
comes on the bottom if it goes off the
left it comes on the right and so forth
right and so this is one of the standard
ways to deal with
topologies and one of the nice reasons
why is because you don't get any
boundary effects right the kind of the
world is just what it is and then agents
can continue to move throughout it
without having to worry about what
happens at the boundaries now
alternatively you could do an explicitly
bounded topology where you actually had
borders on the world right and you know
this is kind of often describes
sometimes as being like a maze right
were you only you're restricted to what
you can do within those spaces right and
the ant's model actually uses this the
ant's model in the net logo models
library says that the ants can't move
off the world now the the way the rules
are written for the end so you don't
have to worry too much about what
happens when the interactive a boundary
because they're constantly kind of
jittering around and moving and so
they'll just move away from the boundary
eventually right but in other cases you
might actually have to have explicit
rules as to what happens when an animal
or an individual and agents and the
model hits the boundary in fact if in
the blocking model if you go back and
you turn off
wrapping basically all the birds wind up
hitting the wall and just stopping there
right and so as a result of that you'd
have to have a new special rule to tell
them okay if you are coming towards a
wall right and so if you think about
this in the case may be it's like birds
flying inside a room right if you're
coming towards a wall you should treat
that like another bird and avoid it
somewhere
the final a topology that's often used
to handle boundary connections is the
infinite plane right this is the simple
simple example of just let the agents go
anywhere right there are no boundaries
the world is infinite right and in fact
there is a and and this can be handled
in a number of different ways all right
you could actually kind of a constantly
rescale the world right or you could
simply allow the agents to go off the
world hide them from the other agents
and then keep track of where they are
assuming that the world view that you're
looking at is essentially a window into
that infinite plane a discreet window
incident into that plane and in fact
that's what the random walk 360 model is
so I'm gonna pause here to show you a
little bit of that particular model
because I think it's kind of interesting
so here we have the random walk 360
model right and we set up it sets these
rings out and really what it's trying to
show you is what's really interested in
looking at is if you take random walks
what's the distribution of the turtles
overall as you continue to run right so
it's not really meant to describe an
infinite plane but if we continue to let
it run right you'll see
these trails that go off and come back
on something to come back on right this
this space and so what it's really doing
is it has the
the the space that you're seeing is a
window into an infinite place right and
if you look at the code right you'll
notice they had Turtles none of these
extra properties which are XC and YC
which are the unwrapped x core and white
core these are the the actual distance
that they are because we have to if they
move off the space we can't still
continue to show them right and so
you can see that if the patch that they
would move to doesn't exist right in
other words it's outside the world then
we're gonna hide the turtle and we're
just gonna prevent it from showing up
but we're going to keep track of it not
using X corn y core instead we're gonna
keep track of it using this XC and YC
right which allows us to determine
whether or not where they are even when
they move out to the world and then
whenever they move back on we'll show
them again at those coordinates so only
use X core and like or when XC and YC
are actual spaces within the world so
that's an example of how to do an
infinite plane in net logo and in the
next lecture we're going to talk about
how to do Network topologies