I have a problem of how to make clustering in mobile adhoc network according to the number of hops. Such that there are clusterheads at fixed location and each mobile node belongs to the nearest clusterhead according to the smallest distance. Please help me to write the code.
> I have a problem of how to make clustering in mobile adhoc network
> according to the number of hops. Such that there are clusterheads at
> fixed location and each mobile node belongs to the nearest clusterhead
> according to the smallest distance. Please help me to write the code.
If you are just learning NetLogo, I recommend using it interactively
for a while to get the feeling for how it works -- before trying to
write much code. I don't know much about the problem you are working
on, but just to get an idea about it I started up NetLogo with a new
model and typed this into the Procedures:
breed [ bases base ]
breed [ mobiles mobile ]
set-default-shape bases "triangle"
set-default-shape mobiles "dot"
(I used the word "base" because it is easier to type than
"clusterhead".) Then I went to the Interface:
This just sets the default shapes for the breeds, so I don't have to do
it when making new turtles. Just a convenience for playing around.
observer> ask n-of 9 patches [ sprout-bases 1 [ set color blue ] ]
OK, there are some bases. If you don't like the layout, enter "ca" and
return and then use the up-arrow twice to recall the previous command
and press return again. Now for something to cruise around:
observer> create-mobiles 1 [ set color red ]
This makes one mobile at the origin. Now to find the closest base to it:
Sure enough, another link to the closer base. You might want to create
a second mobile and repeat the above commands. To modify the command to
break the first link before making the next, just edit it like this:
Well, this gives you some idea of what I mean by using NL
interactively. You'll have to explore the documentation and sample
models to discover all the possibilities. Then when you start writing
code, do a little at a time, first the setup procedure, then a simple
go procedure to get the mobiles moving, then the code that creates the
links as they move.