Node's number in k-mean

9 次查看(过去 30 天)
I have a number of nodes that is expressed by 'X' and has the value of '98', number of cluster is '14', the code is working fine, but in this code, the number of nodes is not equal in all the clusters, and I need the number of node in each cluster to be '7'. Any help?
X = [A, B];
[idx,C,sumd] = kmeans(X,7,'Distance','cityblock','replicates',3);

采纳的回答

Walter Roberson
Walter Roberson 2018-1-26
If you need the number of nodes in each cluster to be the same, then you should not use kmeans.
  10 个评论
Walter Roberson
Walter Roberson 2018-1-28
编辑:Walter Roberson 2018-1-28
"BS" might possibly mean "Base Station"
Since the only way that different clusters talk is by way of the cluster heads (CH), if you want the same number of nodes in each cluster, just construct the set up that way. That is, construct the system cell by cell. It might possibly be important that the nodes in each cell know the positions of each other, in order for the nodes to send to each other within the one cell. The cluster heads might need to know the distance to each other. But the individual nodes in cluster "A" do not need to know the locations of the individual nodes in cluster "B".
So... generate cluster head nodes first, appropriate distances from each other. Then for each cluster head, generate positions of as many nodes as needed (same number for each cluster), but for any one cell, do not pay attention to the positions of the other cells. It might well be the case that if you were to do a full resolution of the coordinates of node 7 of cluster "A" that it would be practically on top of node 4 of cluster "B", but you don't care: all that matters is that the nodes in cluster "A" only talk to each other and the cluster head for "A", and that the cluster heads know how to find each other.
If you for some reason need a mathematical model of how such a geometry could be true, then just picture it as being in 3 or more dimensions: let the cluster heads all be at Z = 0, but node 7 of cluster "A" might have X and Y coordinates very nearly the same as the X and Y coordinates of node 4 of cluster "B" and yet clearly not be part of the same cluster because their Z coordinates might be very different. Mathematically you can add as many dimensions as you need to prevent conflict.
Because the system can be modeled this way, you do not need to use a clustering strategy that is able to allocate an equal number of nodes to each cluster: you just put as many nodes as you need into each cluster and do not let the different clusters talk to each other except through the CH. Each cluster only needs to be locally consistent.
Remember, you are only simulating clusters of the same size in order to compare efficiency. In real world WSN situations, clusters will not typically have the same number of nodes unless they have been carefully laid out... and if you are going to carefully lay them out to have that property then you might as well lay them out to optimize efficiency anyhow.
If you need to model nodes moving relative to each other then it is not very reasonable to keep forcing the clusters to be the same size. Consider possibilities such as close groups
(#1: 6 nodes) ............... (#2: 5 nodes) ............... (#3: 5 nodes) .......... (#4: 4 nodes)
Efficiency would obviously be optimized by having the clusters be of unequal size with the cluster heads talking as needed. If you force the clusters to be equal size then you would force
(#1: 5 nodes)(#2: 1 node) ............... (#2: 4 nodes)(#3: 1 node) ............... (#3: 4 nodes)(#4: 1 node) .......... (#4: 4 nodes)
The cluster head for node #2 is going to be in the second local clump, so the lone #2 node would have to communicate "long distance" to the main group in the second local clump, using nearly as much energy to talk to it as the cluster head for #1 would use in talking to the cluster head for #2. And if that lone #2 node was talking to its closest node in cluster #1, the cluster head for #2 would then have to send the message to the cluster head for #1 to send on to the node that might only be a short distance from the lone node #2 that was forced to be in the second cluster just to equalize the cluster sizes. This is not efficient!!
wejdan Albanna
wejdan Albanna 2018-1-28
Many thanks for your kind help, will take your advice and will be working on that.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Cluster Analysis and Anomaly Detection 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by