[Music]
okay so we're back on our model and this
time we're going to start to add in some
different network structures right so
you know the first thing to do is
probably to kind of go back over to the
new extensions pages just look at the
way that those structures are generated
right so if you look right let's see
let's go down to the generators 5 sound
source the bottom right so one thing we
can obviously want one is called
generate random that's something we're
already doing so let's take a look at
that one first just because then we can
recreate what we were already doing
right and if you look at it says NW
generate random is going to take a
turtle breeze a link breeze the number
of nodes right the connection
probability and then optional commune
block and an optional command block is
just you know the same thing is when you
need to create 100 or whatever one you
created and by the way you know for all
extensions you preface them with the
extension name so this one is called NW
right and so we have to preface it with
that extension and so then when we call
the command we do NW : generate random
in this case the turtle is linked 100
set color red right so let's see if we
can get this up and working since it's
basically the same thing that we were
already had going right so here we have
our network of our model again the first
thing before we can do anything for once
we're start working extensions we have
to call we have to tell them that logo
we wanted to load the extension so at
the very top we put the command
extension and then in the brackets we
put NW right and you can check to see if
it's loading correctly and it seems to
be fine alright because it's actually
finding it very and so now we want to
replace like we said the current network
generation with
so we have the network generation down
here we can comment out for now we
probably want to eventually delete it
the way we're doing before and what's
interesting right is that when you when
you use these sharing Network commands
they actually generate the whole network
with the nodes and everything right so
it's almost like you're doing the create
100 or whatever create in there in this
case the command is create num agents
right so we can get rid of this create
num agents now and yeah how good way to
do that it's just to comment everything
out just you know eventually will delete
it but for now we'll just comment out
and now we can go up and we can say NW
generate random which is the name of the
command that we're going work with and
these the turtle breed which can be
Turtles the link 3 which is going to be
links and then the the number of nodes
which is the number of agents right and
the density right there's a probability
of connection now before right we just
had it like one node here we actually
specify a probability so you can say
like point one and what that means that
roughly each agent will be connected to
10% of the other agents in the network
right so we can do that and then just
like any create 100 we can also add in
these brackets right and we can put all
of our standard commands in there right
so we can kind of go back to what we had
before and just cut and paste so we
could paste in our you know set the
adopted to false we can paste in the
[Music]
real the set X Y to a random coordinate
right and we can you know paste in our
I hear in setup that we have you can
take dispenser Hey and now let's profile
hit the check button which he makes sure
we brought everything looks like we did
so let's go ahead and hit setup and see
what happens
oh and it seems to work right now
nowaday now there's more notes than you
would expect right our sorry more links
than then we had before because the
density is a little higher than it was
before in fact we can say count Turtles
right there's 50 Turtles and you can
take count links and there's 121 links
right now if you think about it the wave
random networks worth right is that
there is if there's 10% means that 10%
of all the possible link exists right so
the number of links that can exist right
is 50 times 50 because every network
node can be connected to every other
node except for itself so 50 times 49
technically right which is 50 times 49
so that's 24 50 now 10% 2450 is
obviously 245 right not 121 so why do we
only have under 21 well if you think
about it the 50 times 49 is assuming
that the nodes the links are directed
right that you can have two-way link so
really what we need to find out the
number of undirected links is 50 times
49 which is the number of edges you can
have overall but then divided by two
because we can only have one edge
between any two nodes we can't have an
edge going one way and
the other way right and so the actual
number of edges is that the that we
would expect them if every node was
connected to every other node would be
1225 ten percent of that hopefully 121
right and again you know this is because
it is a random network so you can get
things going on it's okay
she'll count links again I need to get
121 right so right on the money seems to
be working right but this is just one
network this is just recreating what we
did before we want to be able to add in
another network structure so let's take
a look at our networks again and
actually we're in the right spot and one
easy one to work with it's a
preferential attachment network and a
preferential attachment network is one
in which of the probability of being
connected to a new whenever a note and
first the network was generated in our
the probability being texted and the
other node is dependent upon the number
of nodes is related to the number of
things that node RI has so in Kiryat
it's the rich get richer kind of network
right if one no it has a lot of links
that makes it a higher probably that's
going to have more links in the future
right so let's try that one out but
before we do that we need to add an
interface element that will allow us to
choose between these two different notes
right stones pull this down a little bit
and we will add in a chooser comment
that we're going to call they're going
to call network right and we're going to
two choices random and preferential
attachment product just call PA to make
it simpler but I'll expose these out
right so remove this one overload make
it nice and fit well right and so now we
can go over to the setup routine and
then first of all always good to comment
so create the agents based
on the shoes or our create the the
network based on the trees
so if net work equals random alright
then do what we could before okay and we
can always double check to make sure you
know like this should be literally doing
the same thing so we have it set the
random and looks like it's doing the
same thing right don't check check that
links right under a lot in this case
right so do exactly what it was before
right so it seems to be working now we
want to add in the new one before we do
that let's clean up our code a little
bit since we've got the network working
to delete all this
all right so now we can go in and we can
add in the preferential attachment one
so create the network now which take
raise the network base time chooser for
based on a random network for this one
right and in case the network based on a
preferential attachment
so if net work equals preferential
attachment
then do something cool right um in this
case do something cool is NW generate
preferential attachment and was quickly
reflection what is that mean it needs
turtle breed link breed num nodes and
then also pay online so so unlike the
random Network right the preferential
attachment network doesn't take a
density parameter right and so we don't
have that then this one actually there
is a there is a density parameter in
general in preferential attachment
networks usually described as K which is
the minimal number of connections that I
know it has but then at logo model
version doesn't implement that so if you
want to adventurous you could include
inflate yourself so it's going to look
very similar otherwise so it's going to
say Turtles links and known agents right
they just does have that point one that
is there in the in another in the
density area
let's just make a comment about that
always good to make a comment when you
have a set up this kind of different so
when I say ignores the density slider
that way if someone's looking at our
code later on they can see that we
didn't just forget it it actually just
isn't there and then other than that
right all the rest of this code it's
basically the same as it was before so
we could copy and paste and in fact if
we're really smart right and we want to
keep our code minimal we could just do
that once outside and we could just app
the turtles to set it out to the fall
set X Y etcetera etc after we had
generated all the networks but let's
double check this works for all looks
like it's grammatically correct or
syntactically correct
so now we have our random network right
and then let's see if we get a
preferential attachment it sure enough
you can see that you know obviously from
just looking at it right it's it's
slightly different and actually just
realized we have ever created our
density slider right we just have a
hard-coded in
you can tell the preferential attachment
network is different right because
because a random with the hard-coded
value of 0.1 it just looks like them got
your network so let's take all this
things and slide it down a little bit
then we're going to add in a density
slider so we can actually directly
control and we'll do it by point zero
five to one point Oh too much right now
right pointing up a little bit all right
so now right we can replace this point
one with density you know it's always
useful to double check to make sure it
does something similar so let's set it
to point one see if it looks on one it
does if we do this show count links
right it's roughly so that seems to be
working so now we have a random network
that has a density slider that allows
the controller density in network and
one other way to check it is if we
increase the density slider what do we
expect to expect there be a lot more
links and sure enough it looks like
there are and if we go down here and
verify it there are right now as I
mentioned you know when we built the
preferential attachment it's ignoring
that dense a slider so as you can see
even though the density is high we're
only getting 49 them right and so it's
kind of a quick way to double check to
make sure your code is all working
properly now you know one of the nice
things about a preferential attachment
network is it should be forming kind of
a hub-and-spoke type structure right
that's one that kind of hallmark so from
our slider well we can't see it right
now because our agents have had
scattered all over
so one thing you often want to do when
working with network structures is add
some code to kind of lay out the network
structure a little bit better and
there's a bunch of commands that are
built into net logo to work with Springs
these are part of the network extension
these are just standard commands and so
one of them for instance is called
layout spring so we can look it up in
you know Google
quit and you can see that it's going to
arrange the turtles where basically we
the kind of the idea is that the links
are Springs and it kind of positions
them accordingly
based upon that right and and there's
some detailed description exactly what
we mean by that but this is a standard
algorithm for laying out networks and
there's a bunch of other ones actually
if you go back if I've gone back right
we could go to just look at the layout
algorithms right and there's layout
radially out spring layout cuts as well
right so so anyway so layout spring
takes a turtle set a link set spring
constant of spring links in a very
polishing constant they're all kind of a
bunch of different parameters you know
what I tend to do I tend to just copy
and paste from the documentation in fact
I copy and paste this whole thing repeat
30 layout spring etcetera etcetera right
and so I can grab it and go over to my
other my model for me and just before I
do the tick's I can paste it in and this
will lay out the model the network a
little bit better if you hit setup now
you can see that we kind of can see a
little bit more of the structure alright
and it works for the random model to
write the random model is going to be
very tightly compacted do this very
little more open all right but you know
if you if you ever want to actually see
it kind of doing everything it's doing
all right you can also just copy and
paste again turn down the slider all
right and put it in the observer and you
can see them kind of move in
right in fact for this layout it looks
like maybe we would have wanted to lay
it out a little bit more often but
anyways what's the double check make
sure the diffusion is still working
correctly set up and go oh we speed that
up right set up and go set up and go
seems to be working and you know is
there a difference between the milk
maybe maybe you know I've got the
density roughly similar it's a little
bit slower for the when we can put the
jump seat down to random right oh so
this happens every now and then and
we'll talk about that but this is kind
of a nice little air dimension in this
particular case right it we actually
generated an agent there are some agents
who are not connected to the network
right and so we can either just ignore
that like I'm going to do now and just
we run the model again or a better way
to do it would be to have the social
influence go to zero if you were not
connected to a network and I will leave
that as a homework assignment for you to
work on okay okay that's it for this
model and when we come back I'm going to
talk about what I want you to do for
model seven here so in model seven I
want you to extend the model again and
this time I want you to create new types
of agents in the model right so in the
current model they're basically all
agents are the same in terms of their
behavior they do the same things but
what I want you to do in model seven is
to create a new type of agent called
that influential right now you can think
of you know there's a standard kind of
view that there are influentials and
imitators when it comes to diffusion
right especially innovation diffusion
and so what we're doing is we're kind of
adding in this influential notion right
but obviously influence tools have to be
different somehow than the other agents
right and the way the influential is are
going to be different is the
they're going to have a larger level of
influence over the other agents and
those other agents are going to have
potentially less influence over them
right so I want you to add a weight that
controls how influential influentials
are right and then the other thing we're
going to want to it's not taught the
adoption of each agent type separately
from each other all right so that's the
goal for model 7 you know you could
think about doing this in a in a number
of different ways and I recommend kind
of taking a look at maybe some of the
the code that is out there it allows you
to control different agents and in
particular something we haven't talked
about yet which is breeds and brings a
giving the ability to have classes of
agents besides just turtle so you're not
always talking about turtle so you can
have different types of breeds within
your Turtles right so take a look at the
breeds explanations and when we come
back I'll show you how I did