[Music]
hi and welcome back so in this unit
we're going to start working with trying
to add a network to the model right and
that was the challenge I left you with
at the end of the last video class model
so um there are a number of ways you can
do that so I mean you know right now if
you look at the model just to kind of
refresh your memory right it's actually
basically just adopting based upon the
overall pattern of Dobson that's not a
very personal it's not a very
agent-based model a thing to do thing we
usually to avoid global information
right but the other thing is you know we
know in reality people don't actually
look at like all the people who's
adopted and make a decision they look at
like their social neighbors and their
social network right so what we want to
build up that we want to start to build
with the code to help out with that
social network so the first thing we
have to do to do that is actually add a
network between the agent so if we go up
to the setup procedure right we can go
right below where we created the agents
and we have to do this after we create
the agents because we need the agents
out there they actually connect them
right we can add some code train network
of agents right we can add some code
that will actually create that Network
and what we're gonna do is we're all
each of the Turtles
to create a link with one of the other
turtles this one of the reasons why I
love net logos but all right left line
right there looks exactly like how you
would say it alright so the command is
crate length width and create length
width creates a generic non-directed
link between two agents right you can
also use Create link to or create link
from writing to the page directive link
you can also create a link breed links
our agents just like turtles and patches
are and so you could have you know
create friendship with right these have
to create that bridge ahead of time
right this case we're just going use a
standard default paid link with other
turtles other take a major set and
removes the current tourist agents from
the agent sets right so this is just
going to be turtles besides the turtle
is actually currently executing and then
one of us can choose one of them
randomly so it's going to be one of the
agencies not all right now let's see if
that actually work if we get set up hit
go all right setup go right you can see
the network right and one thing by the
way I get this just before we started
this but well if yours looks a little
different it might be because you have
world wrapping turned on so you can turn
that if that's the case and it's going
to look like this right and sometimes
the links are going to go around the
world but that makes it a little hard to
see well who the links are between so I
highly recommend for this model at least
turning world graphing off great and
once you do that the links will redirect
inside of them the world right it makes
much easier to see them
so what string will train the social
network correctly but what if we want to
verify that it's always important to try
and verify each of your steps so one of
the things we could do is we could check
to see how many links there are now
there's 50 agents the model each one is
created a link so we would expect there
to be 50 links right so let's take show
count links oh there's only 47 well you
know maybe something's going wrong we
can we can check again let's do it one
more time
oh and now there's 49 48 49 50 at least
that one got it right right so why do
sometimes we not have the whole 50 links
well this is to do with one of the
things that we're doing in this code
right in this code if you look at it
we're having each of the turtles create
a link with one of the other turtles now
it could be possible to two of the same
turtles choose each other right so let's
imagine turtles 0 create the link of
turtle 1 and then create a true one
decisive a link back of turtle 0 because
the way in that logo works rather than
creating two links because they're non
direction
it actually only the second time it
create link with column and it's called
it basically failed silently and doesn't
tell you that it's not going to create
that second one right in most cases is
what you wanted to do just fine
but it's something you should be aware
of it too you can see or if you're
expecting it to be exactly the right at
the same time every time right so that's
one way to easily kind of create a
random Network note but we're still not
adopting based upon the social network
right so that's the next step but now we
have to adopt based on the social
network so let's go down to where the
adoption code is and you know it's not
going to affect the broadcast influence
that happens regardless of the social
network but we wanted to affect the the
social influence right so this is not
based on social influence and we could
say from our you know based on a network
and the main code here is this count
Turtles with adopted / counters right so
rather than having based upon all of the
turtles our model now we want to base it
upon just our our link our neighbors
right and then in net logo there's an
easy way to do that well first of all we
can get how many neighbors we have by
just saying what total neighbors be
linked neighbors and link neighbors is
built in command that reports all of the
turtles who are connected to you by
links right there's also in Lake
neighbors and out link neighbors and all
those kind of things as well right -
gave that so now we want to replace
kernels with count total neighbors right
but we still to fix this top half the
numerator of our division right which is
currently calm Turtles with adopted so
what do I do we actually want to say let
neighbors adopt it these are neighbors
who have adopted be link neighbors with
adopted right so this will only return
those linked neighbors or adopt now it's
still an agent right Lincoln so we have
to in order to actually make it work we
have to say let's is we have to count
the number of neighbors
adoption and you know we could move this
up into this local variable up here and
just have the count to be there and not
have to count down here that's all fine
and good this is just the way I happen
to write this particular version in the
bottom right okay so now we should have
social influence working right let's see
if it does
and sure enough it seems to and it seems
to modify the pattern of adoptions right
we saw a more of an s-shaped curve
before now we see more of a linear curve
and that's the just the fact that
because we have a lot less influence
right it's taking it happens in a
different way right because we're only
influenced by our social neighbors not
the whole network right and so as a
result the the evolution is there's a
little bit different of the dynamics
I mean well we're seeing a little bit
longer to run to completion right like
in general we were seeing like 10 to 20
ticks before now we're seeing more like
20 to 30 in most cases or 45 in this
case right so that's kind of also
typical so it appears that our code is
working correctly I will mention you
know there's two things that if you
wanted to kind of do on your own over
useful disease model one would be you
know as I mentioned if you create the
links back and forth that's going to not
create one of the links one of the ways
you around that would be to add a check
that says don't create a link with a
turtle that you are a have is a member
of your link neighbors right and I'll
leave it to you to kind of write that
code it's not super complex is fairly if
they do but you might want to look into
that right and the other thing is like
even though we kind of think that this
social influence code is working
correctly based upon the fact that our
model changed a little bit we don't have
any real hard proof so if you want I
would suggest you know just seeing if
this social influence makes sense the
way it's being calculated you can do
that using the inspector the agents and
kind of going through how it what you
think would calculate it out and whether
or not actually populate cell okay well
that's it for now when I come back I
want to show you how to modify this for
the the next model and the next
what we're going to look at is solar
certainly hit set up now as the whole
network gets destroyed right what if we
want the network to remain constant
right so that we can experiment with the
same network with different effusions of
the signal so we're going to play around
with that in the next model and then the
model after that one of the things
that's kind of a limitation of this
model this is completely random Network
right and we know that's not realistic
the two even social networks are
different than random networks and so in
the Model S or that we're going to play
around is adding a more realistic social
okay thanks ok so here's your goal for a
modify and once you do trying to figure
out a way to add a new button to the
interface that will allow you to run the
different diffusions on the same network
multiple times right so this allows you
to keep the network constant and just
alter the diffusion properties and see
how that affects the patient process
right this is something you commonly do
an agent-based modeling right you want
to hold certain things constant while
you modify other things and so sometimes
you know you want that that you don't
want to completely destroy the world the
only one to destroy parts of the world
and so think about how you might do that
and when I come back I'll show you how I
did