Master Student Needs help, Please

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Master Student Needs help, Please

saied salah
Dear All.
   
  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.
   
   
  Regards
   
  Saeed

       
Reply | Threaded
Open this post in threaded view
|

Re: Master Student Needs help, Please

Jim Lyons-2
On May 20, 2008, at 6:51 AM, saied salah wrote:

> 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.

Saeed,
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 ]

to set-shapes
   set-default-shape bases "triangle"
   set-default-shape mobiles "dot"
end

(I used the word "base" because it is easier to type than
"clusterhead".) Then I went to the Interface:

observer> set-shapes

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:

observer> ask mobiles [ create-link-with min-one-of bases [distance
myself] ]

Now what if it moves?

observer> ask mobiles [ jump 1 ]

I executed this repeatedly by using the up-arrow/return trick, until
the mobile was closer to another base. Then I used the up-arrow twice
to recall the create-link command and pressed return again.

observer> ask mobiles [ create-link-with min-one-of bases [distance
myself] ]

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:

observer> ask mobiles [ ask my-links [ die ] create-link-with
min-one-of bases [distance myself] ]

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.

Hope this helps. Good luck.

Jim Lyons