Merge pull request #11 from karthikmurakonda/testing-kmeans

added kmeans2
This commit is contained in:
pavanvpatil 2022-11-01 22:50:41 +05:30 committed by GitHub
commit 3213347dcb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 10444 additions and 9 deletions

3
iPDC/inc/Kmeans2.h Normal file
View File

@ -0,0 +1,3 @@
int *getRandoms(int lower, int upper, int count);
long double distance(struct Point* A, struct Point* B);
void Kmeans2(struct data_frame *df);

500
iPDC/kmeans.csv Normal file
View File

@ -0,0 +1,500 @@
50.200001, 65454.000000, 0
50.200001, 65454.000000, 0
50.099998, 65469.000000, 2
50.099998, 65469.000000, 2
50.099998, 65469.000000, 2
50.099998, 65469.000000, 2
50.099998, 65469.000000, 2
50.099998, 65469.000000, 2
50.099998, 65469.000000, 2
50.099998, 65469.000000, 2
50.099998, 65469.000000, 2
50.099998, 65469.000000, 2
50.400002, 65467.000000, 2
50.400002, 65467.000000, 2
50.400002, 65467.000000, 2
50.400002, 65467.000000, 2
50.400002, 65467.000000, 2
50.400002, 65467.000000, 2
50.400002, 65467.000000, 2
50.400002, 65467.000000, 2
50.400002, 65467.000000, 2
50.400002, 65467.000000, 2
50.400002, 65442.000000, 0
50.400002, 65442.000000, 0
50.400002, 65442.000000, 0
50.400002, 65442.000000, 0
50.400002, 65442.000000, 0
50.400002, 65442.000000, 0
50.400002, 65442.000000, 0
50.400002, 65442.000000, 0
50.400002, 65442.000000, 0
50.500000, 65477.000000, 1
50.500000, 65477.000000, 1
50.500000, 65477.000000, 1
50.500000, 65477.000000, 1
50.500000, 65477.000000, 1
50.500000, 65477.000000, 1
50.500000, 65477.000000, 1
50.500000, 65477.000000, 1
50.500000, 65477.000000, 1
50.500000, 65477.000000, 1
50.099998, 65467.000000, 2
50.099998, 65467.000000, 2
50.099998, 65467.000000, 2
50.099998, 65467.000000, 2
50.099998, 65467.000000, 2
50.099998, 65467.000000, 2
50.099998, 65467.000000, 2
50.099998, 65467.000000, 2
50.099998, 65467.000000, 2
50.099998, 65467.000000, 2
50.500000, 65467.000000, 2
50.500000, 65467.000000, 2
50.500000, 65467.000000, 2
50.500000, 65467.000000, 2
50.500000, 65467.000000, 2
50.500000, 65467.000000, 2
50.500000, 65467.000000, 2
50.500000, 65467.000000, 2
50.500000, 65467.000000, 2
50.200001, 65449.000000, 0
50.200001, 65449.000000, 0
50.200001, 65449.000000, 0
50.200001, 65449.000000, 0
50.200001, 65449.000000, 0
50.200001, 65449.000000, 0
50.200001, 65449.000000, 0
50.200001, 65449.000000, 0
50.200001, 65449.000000, 0
50.200001, 65449.000000, 0
50.299999, 65475.000000, 1
50.299999, 65475.000000, 1
50.299999, 65475.000000, 1
50.299999, 65475.000000, 1
50.299999, 65475.000000, 1
50.299999, 65475.000000, 1
50.299999, 65475.000000, 1
50.299999, 65475.000000, 1
50.299999, 65475.000000, 1
50.299999, 65475.000000, 1
50.500000, 65467.000000, 2
50.500000, 65467.000000, 2
50.500000, 65467.000000, 2
50.500000, 65467.000000, 2
50.500000, 65467.000000, 2
50.500000, 65467.000000, 2
50.500000, 65467.000000, 2
50.500000, 65467.000000, 2
50.500000, 65467.000000, 2
50.500000, 65457.000000, 0
50.500000, 65457.000000, 0
50.500000, 65457.000000, 0
50.500000, 65457.000000, 0
50.500000, 65457.000000, 0
50.500000, 65457.000000, 0
50.500000, 65457.000000, 0
50.500000, 65457.000000, 0
50.500000, 65457.000000, 0
50.500000, 65457.000000, 0
50.500000, 65475.000000, 1
50.500000, 65475.000000, 1
50.500000, 65475.000000, 1
50.500000, 65475.000000, 1
50.500000, 65475.000000, 1
50.500000, 65475.000000, 1
50.500000, 65475.000000, 1
50.500000, 65475.000000, 1
50.500000, 65475.000000, 1
50.500000, 65475.000000, 1
50.099998, 65454.000000, 0
50.099998, 65454.000000, 0
50.099998, 65454.000000, 0
50.099998, 65454.000000, 0
50.099998, 65454.000000, 0
50.099998, 65454.000000, 0
50.099998, 65454.000000, 0
50.099998, 65454.000000, 0
50.099998, 65454.000000, 0
50.299999, 65446.000000, 0
50.299999, 65446.000000, 0
50.299999, 65446.000000, 0
50.299999, 65446.000000, 0
50.299999, 65446.000000, 0
50.299999, 65446.000000, 0
50.299999, 65446.000000, 0
50.299999, 65446.000000, 0
50.299999, 65446.000000, 0
50.299999, 65446.000000, 0
50.200001, 65454.000000, 0
50.200001, 65454.000000, 0
50.200001, 65454.000000, 0
50.200001, 65454.000000, 0
50.200001, 65454.000000, 0
50.200001, 65454.000000, 0
50.200001, 65454.000000, 0
50.200001, 65454.000000, 0
50.200001, 65454.000000, 0
50.200001, 65454.000000, 0
50.200001, 65454.000000, 0
50.200001, 65454.000000, 0
50.200001, 65454.000000, 0
50.200001, 65454.000000, 0
50.200001, 65454.000000, 0
50.200001, 65454.000000, 0
50.200001, 65454.000000, 0
50.200001, 65454.000000, 0
50.200001, 65454.000000, 0
50.400002, 65475.000000, 1
50.400002, 65475.000000, 1
50.400002, 65475.000000, 1
50.400002, 65475.000000, 1
50.400002, 65475.000000, 1
50.400002, 65475.000000, 1
50.400002, 65475.000000, 1
50.400002, 65475.000000, 1
50.400002, 65475.000000, 1
50.400002, 65475.000000, 1
50.400002, 65477.000000, 1
50.400002, 65477.000000, 1
50.400002, 65477.000000, 1
50.400002, 65477.000000, 1
50.400002, 65477.000000, 1
50.400002, 65477.000000, 1
50.400002, 65477.000000, 1
50.400002, 65477.000000, 1
50.400002, 65477.000000, 1
50.400002, 65477.000000, 1
50.299999, 65457.000000, 0
50.299999, 65457.000000, 0
50.299999, 65457.000000, 0
50.299999, 65457.000000, 0
50.299999, 65457.000000, 0
50.299999, 65457.000000, 0
50.299999, 65457.000000, 0
50.299999, 65457.000000, 0
50.299999, 65457.000000, 0
50.099998, 65463.000000, 2
50.099998, 65463.000000, 2
50.099998, 65463.000000, 2
50.099998, 65463.000000, 2
50.099998, 65463.000000, 2
50.099998, 65463.000000, 2
50.099998, 65463.000000, 2
50.099998, 65463.000000, 2
50.099998, 65463.000000, 2
50.099998, 65463.000000, 2
50.099998, 65465.000000, 2
50.099998, 65465.000000, 2
50.099998, 65465.000000, 2
50.099998, 65465.000000, 2
50.099998, 65465.000000, 2
50.099998, 65465.000000, 2
50.099998, 65465.000000, 2
50.099998, 65465.000000, 2
50.099998, 65465.000000, 2
50.099998, 65465.000000, 2
50.400002, 65446.000000, 0
50.400002, 65446.000000, 0
50.400002, 65446.000000, 0
50.400002, 65446.000000, 0
50.400002, 65446.000000, 0
50.400002, 65446.000000, 0
50.400002, 65446.000000, 0
50.400002, 65446.000000, 0
50.400002, 65446.000000, 0
50.200001, 65452.000000, 0
50.200001, 65452.000000, 0
50.200001, 65452.000000, 0
50.200001, 65452.000000, 0
50.200001, 65452.000000, 0
50.200001, 65452.000000, 0
50.200001, 65452.000000, 0
50.200001, 65452.000000, 0
50.200001, 65452.000000, 0
50.200001, 65452.000000, 0
50.400002, 65450.000000, 0
50.400002, 65450.000000, 0
50.400002, 65450.000000, 0
50.400002, 65450.000000, 0
50.400002, 65450.000000, 0
50.400002, 65450.000000, 0
50.400002, 65450.000000, 0
50.400002, 65450.000000, 0
50.400002, 65450.000000, 0
50.400002, 65450.000000, 0
50.400002, 65463.000000, 2
50.400002, 65463.000000, 2
50.400002, 65463.000000, 2
50.400002, 65463.000000, 2
50.400002, 65463.000000, 2
50.400002, 65463.000000, 2
50.400002, 65463.000000, 2
50.400002, 65463.000000, 2
50.400002, 65463.000000, 2
50.400002, 65463.000000, 2
50.500000, 65460.000000, 2
50.500000, 65460.000000, 2
50.500000, 65460.000000, 2
50.500000, 65460.000000, 2
50.500000, 65460.000000, 2
50.500000, 65460.000000, 2
50.500000, 65460.000000, 2
50.500000, 65460.000000, 2
50.500000, 65460.000000, 2
50.299999, 65476.000000, 1
50.299999, 65476.000000, 1
50.299999, 65476.000000, 1
50.299999, 65476.000000, 1
50.299999, 65476.000000, 1
50.299999, 65476.000000, 1
50.299999, 65476.000000, 1
50.299999, 65476.000000, 1
50.299999, 65476.000000, 1
50.299999, 65476.000000, 1
50.200001, 65455.000000, 0
50.200001, 65455.000000, 0
50.200001, 65455.000000, 0
50.200001, 65455.000000, 0
50.200001, 65455.000000, 0
50.200001, 65455.000000, 0
50.200001, 65455.000000, 0
50.200001, 65455.000000, 0
50.200001, 65455.000000, 0
50.200001, 65468.000000, 2
50.200001, 65468.000000, 2
50.200001, 65468.000000, 2
50.200001, 65468.000000, 2
50.200001, 65468.000000, 2
50.200001, 65468.000000, 2
50.200001, 65468.000000, 2
50.200001, 65468.000000, 2
50.200001, 65468.000000, 2
50.200001, 65468.000000, 2
50.299999, 65461.000000, 2
50.299999, 65461.000000, 2
50.299999, 65461.000000, 2
50.299999, 65461.000000, 2
50.299999, 65461.000000, 2
50.299999, 65461.000000, 2
50.299999, 65461.000000, 2
50.299999, 65461.000000, 2
50.299999, 65461.000000, 2
50.299999, 65461.000000, 2
50.400002, 65444.000000, 0
50.400002, 65444.000000, 0
50.400002, 65444.000000, 0
50.400002, 65444.000000, 0
50.400002, 65444.000000, 0
50.400002, 65444.000000, 0
50.400002, 65444.000000, 0
50.400002, 65444.000000, 0
50.400002, 65444.000000, 0
50.400002, 65444.000000, 0
50.400002, 65478.000000, 1
50.400002, 65478.000000, 1
50.400002, 65478.000000, 1
50.400002, 65478.000000, 1
50.400002, 65478.000000, 1
50.400002, 65478.000000, 1
50.400002, 65478.000000, 1
50.400002, 65478.000000, 1
50.400002, 65478.000000, 1
50.500000, 65462.000000, 2
50.500000, 65462.000000, 2
50.500000, 65462.000000, 2
50.500000, 65462.000000, 2
50.500000, 65462.000000, 2
50.500000, 65462.000000, 2
50.500000, 65462.000000, 2
50.500000, 65462.000000, 2
50.500000, 65462.000000, 2
50.500000, 65462.000000, 2
50.500000, 65455.000000, 0
50.500000, 65455.000000, 0
50.500000, 65455.000000, 0
50.500000, 65455.000000, 0
50.500000, 65455.000000, 0
50.500000, 65455.000000, 0
50.500000, 65455.000000, 0
50.500000, 65455.000000, 0
50.500000, 65455.000000, 0
50.500000, 65455.000000, 0
50.299999, 65459.000000, 2
50.299999, 65459.000000, 2
50.299999, 65459.000000, 2
50.299999, 65459.000000, 2
50.299999, 65459.000000, 2
50.299999, 65459.000000, 2
50.299999, 65459.000000, 2
50.299999, 65459.000000, 2
50.299999, 65459.000000, 2
50.299999, 65459.000000, 2
50.200001, 65452.000000, 0
50.200001, 65452.000000, 0
50.200001, 65452.000000, 0
50.200001, 65452.000000, 0
50.200001, 65452.000000, 0
50.200001, 65452.000000, 0
50.200001, 65452.000000, 0
50.200001, 65452.000000, 0
50.200001, 65452.000000, 0
50.299999, 65447.000000, 0
50.299999, 65447.000000, 0
50.299999, 65447.000000, 0
50.299999, 65447.000000, 0
50.299999, 65447.000000, 0
50.299999, 65447.000000, 0
50.299999, 65447.000000, 0
50.299999, 65447.000000, 0
50.299999, 65447.000000, 0
50.299999, 65447.000000, 0
50.500000, 65457.000000, 0
50.500000, 65457.000000, 0
50.500000, 65457.000000, 0
50.500000, 65457.000000, 0
50.500000, 65457.000000, 0
50.500000, 65457.000000, 0
50.500000, 65457.000000, 0
50.500000, 65457.000000, 0
50.500000, 65457.000000, 0
50.500000, 65457.000000, 0
50.400002, 65479.000000, 1
50.400002, 65479.000000, 1
50.400002, 65479.000000, 1
50.400002, 65479.000000, 1
50.400002, 65479.000000, 1
50.400002, 65479.000000, 1
50.400002, 65479.000000, 1
50.400002, 65479.000000, 1
50.400002, 65479.000000, 1
50.099998, 65452.000000, 0
50.099998, 65452.000000, 0
50.099998, 65452.000000, 0
50.099998, 65452.000000, 0
50.099998, 65452.000000, 0
50.099998, 65452.000000, 0
50.099998, 65452.000000, 0
50.099998, 65452.000000, 0
50.099998, 65452.000000, 0
50.099998, 65452.000000, 0
50.099998, 65451.000000, 0
50.099998, 65451.000000, 0
50.099998, 65451.000000, 0
50.099998, 65451.000000, 0
50.099998, 65451.000000, 0
50.099998, 65451.000000, 0
50.099998, 65451.000000, 0
50.099998, 65451.000000, 0
50.099998, 65451.000000, 0
50.099998, 65451.000000, 0
50.299999, 65475.000000, 1
50.299999, 65475.000000, 1
50.299999, 65475.000000, 1
50.299999, 65475.000000, 1
50.299999, 65475.000000, 1
50.299999, 65475.000000, 1
50.299999, 65475.000000, 1
50.299999, 65475.000000, 1
50.299999, 65475.000000, 1
50.500000, 65451.000000, 0
50.500000, 65451.000000, 0
50.500000, 65451.000000, 0
50.500000, 65451.000000, 0
50.500000, 65451.000000, 0
50.500000, 65451.000000, 0
50.500000, 65451.000000, 0
50.500000, 65451.000000, 0
50.500000, 65451.000000, 0
50.500000, 65451.000000, 0
50.200001, 65445.000000, 0
50.200001, 65445.000000, 0
50.200001, 65445.000000, 0
50.200001, 65445.000000, 0
50.200001, 65445.000000, 0
50.200001, 65445.000000, 0
50.200001, 65445.000000, 0
50.200001, 65445.000000, 0
50.200001, 65445.000000, 0
50.200001, 65445.000000, 0
50.200001, 65456.000000, 0
50.200001, 65456.000000, 0
50.200001, 65456.000000, 0
50.200001, 65456.000000, 0
50.200001, 65456.000000, 0
50.200001, 65456.000000, 0
50.200001, 65456.000000, 0
50.200001, 65456.000000, 0
50.200001, 65456.000000, 0
50.200001, 65456.000000, 0
50.299999, 65459.000000, 2
50.299999, 65459.000000, 2
50.299999, 65459.000000, 2
50.299999, 65459.000000, 2
50.299999, 65459.000000, 2
50.299999, 65459.000000, 2
50.299999, 65459.000000, 2
50.299999, 65459.000000, 2
50.299999, 65459.000000, 2
50.400002, 65454.000000, 0
50.400002, 65454.000000, 0
50.400002, 65454.000000, 0
50.400002, 65454.000000, 0
50.400002, 65454.000000, 0
50.400002, 65454.000000, 0
50.400002, 65454.000000, 0
50.400002, 65454.000000, 0
50.400002, 65454.000000, 0
50.400002, 65454.000000, 0
50.200001, 65475.000000, 1
50.200001, 65475.000000, 1
50.200001, 65475.000000, 1
50.200001, 65475.000000, 1
50.200001, 65475.000000, 1
50.200001, 65475.000000, 1
50.200001, 65475.000000, 1
50.200001, 65475.000000, 1
50.200001, 65475.000000, 1
50.200001, 65475.000000, 1
50.200001, 65446.000000, 0
50.200001, 65446.000000, 0
50.200001, 65446.000000, 0
50.200001, 65446.000000, 0
50.200001, 65446.000000, 0
50.200001, 65446.000000, 0
50.200001, 65446.000000, 0
50.200001, 65446.000000, 0
50.200001, 65446.000000, 0
50.099998, 65468.000000, 2
50.099998, 65468.000000, 2
50.099998, 65468.000000, 2
50.099998, 65468.000000, 2
50.099998, 65468.000000, 2
50.099998, 65468.000000, 2
50.099998, 65468.000000, 2
50.099998, 65468.000000, 2
50.099998, 65468.000000, 2
50.099998, 65468.000000, 2
50.500000, 65465.000000, 2
50.500000, 65465.000000, 2
50.500000, 65465.000000, 2
50.500000, 65465.000000, 2
50.500000, 65465.000000, 2
50.500000, 65465.000000, 2
50.500000, 65465.000000, 2
50.500000, 65465.000000, 2
50.500000, 65465.000000, 2
50.500000, 65465.000000, 2
50.099998, 65454.000000, 0
50.099998, 65454.000000, 0
50.099998, 65454.000000, 0
50.099998, 65454.000000, 0
50.099998, 65454.000000, 0
50.099998, 65454.000000, 0
50.099998, 65454.000000, 0
50.099998, 65454.000000, 0
50.099998, 65454.000000, 0
50.099998, 65454.000000, 0
50.299999, 65460.000000, 2
50.299999, 65460.000000, 2
50.299999, 65460.000000, 2
1 50.200001 65454.000000 0
2 50.200001 65454.000000 0
3 50.099998 65469.000000 2
4 50.099998 65469.000000 2
5 50.099998 65469.000000 2
6 50.099998 65469.000000 2
7 50.099998 65469.000000 2
8 50.099998 65469.000000 2
9 50.099998 65469.000000 2
10 50.099998 65469.000000 2
11 50.099998 65469.000000 2
12 50.099998 65469.000000 2
13 50.400002 65467.000000 2
14 50.400002 65467.000000 2
15 50.400002 65467.000000 2
16 50.400002 65467.000000 2
17 50.400002 65467.000000 2
18 50.400002 65467.000000 2
19 50.400002 65467.000000 2
20 50.400002 65467.000000 2
21 50.400002 65467.000000 2
22 50.400002 65467.000000 2
23 50.400002 65442.000000 0
24 50.400002 65442.000000 0
25 50.400002 65442.000000 0
26 50.400002 65442.000000 0
27 50.400002 65442.000000 0
28 50.400002 65442.000000 0
29 50.400002 65442.000000 0
30 50.400002 65442.000000 0
31 50.400002 65442.000000 0
32 50.500000 65477.000000 1
33 50.500000 65477.000000 1
34 50.500000 65477.000000 1
35 50.500000 65477.000000 1
36 50.500000 65477.000000 1
37 50.500000 65477.000000 1
38 50.500000 65477.000000 1
39 50.500000 65477.000000 1
40 50.500000 65477.000000 1
41 50.500000 65477.000000 1
42 50.099998 65467.000000 2
43 50.099998 65467.000000 2
44 50.099998 65467.000000 2
45 50.099998 65467.000000 2
46 50.099998 65467.000000 2
47 50.099998 65467.000000 2
48 50.099998 65467.000000 2
49 50.099998 65467.000000 2
50 50.099998 65467.000000 2
51 50.099998 65467.000000 2
52 50.500000 65467.000000 2
53 50.500000 65467.000000 2
54 50.500000 65467.000000 2
55 50.500000 65467.000000 2
56 50.500000 65467.000000 2
57 50.500000 65467.000000 2
58 50.500000 65467.000000 2
59 50.500000 65467.000000 2
60 50.500000 65467.000000 2
61 50.200001 65449.000000 0
62 50.200001 65449.000000 0
63 50.200001 65449.000000 0
64 50.200001 65449.000000 0
65 50.200001 65449.000000 0
66 50.200001 65449.000000 0
67 50.200001 65449.000000 0
68 50.200001 65449.000000 0
69 50.200001 65449.000000 0
70 50.200001 65449.000000 0
71 50.299999 65475.000000 1
72 50.299999 65475.000000 1
73 50.299999 65475.000000 1
74 50.299999 65475.000000 1
75 50.299999 65475.000000 1
76 50.299999 65475.000000 1
77 50.299999 65475.000000 1
78 50.299999 65475.000000 1
79 50.299999 65475.000000 1
80 50.299999 65475.000000 1
81 50.500000 65467.000000 2
82 50.500000 65467.000000 2
83 50.500000 65467.000000 2
84 50.500000 65467.000000 2
85 50.500000 65467.000000 2
86 50.500000 65467.000000 2
87 50.500000 65467.000000 2
88 50.500000 65467.000000 2
89 50.500000 65467.000000 2
90 50.500000 65457.000000 0
91 50.500000 65457.000000 0
92 50.500000 65457.000000 0
93 50.500000 65457.000000 0
94 50.500000 65457.000000 0
95 50.500000 65457.000000 0
96 50.500000 65457.000000 0
97 50.500000 65457.000000 0
98 50.500000 65457.000000 0
99 50.500000 65457.000000 0
100 50.500000 65475.000000 1
101 50.500000 65475.000000 1
102 50.500000 65475.000000 1
103 50.500000 65475.000000 1
104 50.500000 65475.000000 1
105 50.500000 65475.000000 1
106 50.500000 65475.000000 1
107 50.500000 65475.000000 1
108 50.500000 65475.000000 1
109 50.500000 65475.000000 1
110 50.099998 65454.000000 0
111 50.099998 65454.000000 0
112 50.099998 65454.000000 0
113 50.099998 65454.000000 0
114 50.099998 65454.000000 0
115 50.099998 65454.000000 0
116 50.099998 65454.000000 0
117 50.099998 65454.000000 0
118 50.099998 65454.000000 0
119 50.299999 65446.000000 0
120 50.299999 65446.000000 0
121 50.299999 65446.000000 0
122 50.299999 65446.000000 0
123 50.299999 65446.000000 0
124 50.299999 65446.000000 0
125 50.299999 65446.000000 0
126 50.299999 65446.000000 0
127 50.299999 65446.000000 0
128 50.299999 65446.000000 0
129 50.200001 65454.000000 0
130 50.200001 65454.000000 0
131 50.200001 65454.000000 0
132 50.200001 65454.000000 0
133 50.200001 65454.000000 0
134 50.200001 65454.000000 0
135 50.200001 65454.000000 0
136 50.200001 65454.000000 0
137 50.200001 65454.000000 0
138 50.200001 65454.000000 0
139 50.200001 65454.000000 0
140 50.200001 65454.000000 0
141 50.200001 65454.000000 0
142 50.200001 65454.000000 0
143 50.200001 65454.000000 0
144 50.200001 65454.000000 0
145 50.200001 65454.000000 0
146 50.200001 65454.000000 0
147 50.200001 65454.000000 0
148 50.400002 65475.000000 1
149 50.400002 65475.000000 1
150 50.400002 65475.000000 1
151 50.400002 65475.000000 1
152 50.400002 65475.000000 1
153 50.400002 65475.000000 1
154 50.400002 65475.000000 1
155 50.400002 65475.000000 1
156 50.400002 65475.000000 1
157 50.400002 65475.000000 1
158 50.400002 65477.000000 1
159 50.400002 65477.000000 1
160 50.400002 65477.000000 1
161 50.400002 65477.000000 1
162 50.400002 65477.000000 1
163 50.400002 65477.000000 1
164 50.400002 65477.000000 1
165 50.400002 65477.000000 1
166 50.400002 65477.000000 1
167 50.400002 65477.000000 1
168 50.299999 65457.000000 0
169 50.299999 65457.000000 0
170 50.299999 65457.000000 0
171 50.299999 65457.000000 0
172 50.299999 65457.000000 0
173 50.299999 65457.000000 0
174 50.299999 65457.000000 0
175 50.299999 65457.000000 0
176 50.299999 65457.000000 0
177 50.099998 65463.000000 2
178 50.099998 65463.000000 2
179 50.099998 65463.000000 2
180 50.099998 65463.000000 2
181 50.099998 65463.000000 2
182 50.099998 65463.000000 2
183 50.099998 65463.000000 2
184 50.099998 65463.000000 2
185 50.099998 65463.000000 2
186 50.099998 65463.000000 2
187 50.099998 65465.000000 2
188 50.099998 65465.000000 2
189 50.099998 65465.000000 2
190 50.099998 65465.000000 2
191 50.099998 65465.000000 2
192 50.099998 65465.000000 2
193 50.099998 65465.000000 2
194 50.099998 65465.000000 2
195 50.099998 65465.000000 2
196 50.099998 65465.000000 2
197 50.400002 65446.000000 0
198 50.400002 65446.000000 0
199 50.400002 65446.000000 0
200 50.400002 65446.000000 0
201 50.400002 65446.000000 0
202 50.400002 65446.000000 0
203 50.400002 65446.000000 0
204 50.400002 65446.000000 0
205 50.400002 65446.000000 0
206 50.200001 65452.000000 0
207 50.200001 65452.000000 0
208 50.200001 65452.000000 0
209 50.200001 65452.000000 0
210 50.200001 65452.000000 0
211 50.200001 65452.000000 0
212 50.200001 65452.000000 0
213 50.200001 65452.000000 0
214 50.200001 65452.000000 0
215 50.200001 65452.000000 0
216 50.400002 65450.000000 0
217 50.400002 65450.000000 0
218 50.400002 65450.000000 0
219 50.400002 65450.000000 0
220 50.400002 65450.000000 0
221 50.400002 65450.000000 0
222 50.400002 65450.000000 0
223 50.400002 65450.000000 0
224 50.400002 65450.000000 0
225 50.400002 65450.000000 0
226 50.400002 65463.000000 2
227 50.400002 65463.000000 2
228 50.400002 65463.000000 2
229 50.400002 65463.000000 2
230 50.400002 65463.000000 2
231 50.400002 65463.000000 2
232 50.400002 65463.000000 2
233 50.400002 65463.000000 2
234 50.400002 65463.000000 2
235 50.400002 65463.000000 2
236 50.500000 65460.000000 2
237 50.500000 65460.000000 2
238 50.500000 65460.000000 2
239 50.500000 65460.000000 2
240 50.500000 65460.000000 2
241 50.500000 65460.000000 2
242 50.500000 65460.000000 2
243 50.500000 65460.000000 2
244 50.500000 65460.000000 2
245 50.299999 65476.000000 1
246 50.299999 65476.000000 1
247 50.299999 65476.000000 1
248 50.299999 65476.000000 1
249 50.299999 65476.000000 1
250 50.299999 65476.000000 1
251 50.299999 65476.000000 1
252 50.299999 65476.000000 1
253 50.299999 65476.000000 1
254 50.299999 65476.000000 1
255 50.200001 65455.000000 0
256 50.200001 65455.000000 0
257 50.200001 65455.000000 0
258 50.200001 65455.000000 0
259 50.200001 65455.000000 0
260 50.200001 65455.000000 0
261 50.200001 65455.000000 0
262 50.200001 65455.000000 0
263 50.200001 65455.000000 0
264 50.200001 65468.000000 2
265 50.200001 65468.000000 2
266 50.200001 65468.000000 2
267 50.200001 65468.000000 2
268 50.200001 65468.000000 2
269 50.200001 65468.000000 2
270 50.200001 65468.000000 2
271 50.200001 65468.000000 2
272 50.200001 65468.000000 2
273 50.200001 65468.000000 2
274 50.299999 65461.000000 2
275 50.299999 65461.000000 2
276 50.299999 65461.000000 2
277 50.299999 65461.000000 2
278 50.299999 65461.000000 2
279 50.299999 65461.000000 2
280 50.299999 65461.000000 2
281 50.299999 65461.000000 2
282 50.299999 65461.000000 2
283 50.299999 65461.000000 2
284 50.400002 65444.000000 0
285 50.400002 65444.000000 0
286 50.400002 65444.000000 0
287 50.400002 65444.000000 0
288 50.400002 65444.000000 0
289 50.400002 65444.000000 0
290 50.400002 65444.000000 0
291 50.400002 65444.000000 0
292 50.400002 65444.000000 0
293 50.400002 65444.000000 0
294 50.400002 65478.000000 1
295 50.400002 65478.000000 1
296 50.400002 65478.000000 1
297 50.400002 65478.000000 1
298 50.400002 65478.000000 1
299 50.400002 65478.000000 1
300 50.400002 65478.000000 1
301 50.400002 65478.000000 1
302 50.400002 65478.000000 1
303 50.500000 65462.000000 2
304 50.500000 65462.000000 2
305 50.500000 65462.000000 2
306 50.500000 65462.000000 2
307 50.500000 65462.000000 2
308 50.500000 65462.000000 2
309 50.500000 65462.000000 2
310 50.500000 65462.000000 2
311 50.500000 65462.000000 2
312 50.500000 65462.000000 2
313 50.500000 65455.000000 0
314 50.500000 65455.000000 0
315 50.500000 65455.000000 0
316 50.500000 65455.000000 0
317 50.500000 65455.000000 0
318 50.500000 65455.000000 0
319 50.500000 65455.000000 0
320 50.500000 65455.000000 0
321 50.500000 65455.000000 0
322 50.500000 65455.000000 0
323 50.299999 65459.000000 2
324 50.299999 65459.000000 2
325 50.299999 65459.000000 2
326 50.299999 65459.000000 2
327 50.299999 65459.000000 2
328 50.299999 65459.000000 2
329 50.299999 65459.000000 2
330 50.299999 65459.000000 2
331 50.299999 65459.000000 2
332 50.299999 65459.000000 2
333 50.200001 65452.000000 0
334 50.200001 65452.000000 0
335 50.200001 65452.000000 0
336 50.200001 65452.000000 0
337 50.200001 65452.000000 0
338 50.200001 65452.000000 0
339 50.200001 65452.000000 0
340 50.200001 65452.000000 0
341 50.200001 65452.000000 0
342 50.299999 65447.000000 0
343 50.299999 65447.000000 0
344 50.299999 65447.000000 0
345 50.299999 65447.000000 0
346 50.299999 65447.000000 0
347 50.299999 65447.000000 0
348 50.299999 65447.000000 0
349 50.299999 65447.000000 0
350 50.299999 65447.000000 0
351 50.299999 65447.000000 0
352 50.500000 65457.000000 0
353 50.500000 65457.000000 0
354 50.500000 65457.000000 0
355 50.500000 65457.000000 0
356 50.500000 65457.000000 0
357 50.500000 65457.000000 0
358 50.500000 65457.000000 0
359 50.500000 65457.000000 0
360 50.500000 65457.000000 0
361 50.500000 65457.000000 0
362 50.400002 65479.000000 1
363 50.400002 65479.000000 1
364 50.400002 65479.000000 1
365 50.400002 65479.000000 1
366 50.400002 65479.000000 1
367 50.400002 65479.000000 1
368 50.400002 65479.000000 1
369 50.400002 65479.000000 1
370 50.400002 65479.000000 1
371 50.099998 65452.000000 0
372 50.099998 65452.000000 0
373 50.099998 65452.000000 0
374 50.099998 65452.000000 0
375 50.099998 65452.000000 0
376 50.099998 65452.000000 0
377 50.099998 65452.000000 0
378 50.099998 65452.000000 0
379 50.099998 65452.000000 0
380 50.099998 65452.000000 0
381 50.099998 65451.000000 0
382 50.099998 65451.000000 0
383 50.099998 65451.000000 0
384 50.099998 65451.000000 0
385 50.099998 65451.000000 0
386 50.099998 65451.000000 0
387 50.099998 65451.000000 0
388 50.099998 65451.000000 0
389 50.099998 65451.000000 0
390 50.099998 65451.000000 0
391 50.299999 65475.000000 1
392 50.299999 65475.000000 1
393 50.299999 65475.000000 1
394 50.299999 65475.000000 1
395 50.299999 65475.000000 1
396 50.299999 65475.000000 1
397 50.299999 65475.000000 1
398 50.299999 65475.000000 1
399 50.299999 65475.000000 1
400 50.500000 65451.000000 0
401 50.500000 65451.000000 0
402 50.500000 65451.000000 0
403 50.500000 65451.000000 0
404 50.500000 65451.000000 0
405 50.500000 65451.000000 0
406 50.500000 65451.000000 0
407 50.500000 65451.000000 0
408 50.500000 65451.000000 0
409 50.500000 65451.000000 0
410 50.200001 65445.000000 0
411 50.200001 65445.000000 0
412 50.200001 65445.000000 0
413 50.200001 65445.000000 0
414 50.200001 65445.000000 0
415 50.200001 65445.000000 0
416 50.200001 65445.000000 0
417 50.200001 65445.000000 0
418 50.200001 65445.000000 0
419 50.200001 65445.000000 0
420 50.200001 65456.000000 0
421 50.200001 65456.000000 0
422 50.200001 65456.000000 0
423 50.200001 65456.000000 0
424 50.200001 65456.000000 0
425 50.200001 65456.000000 0
426 50.200001 65456.000000 0
427 50.200001 65456.000000 0
428 50.200001 65456.000000 0
429 50.200001 65456.000000 0
430 50.299999 65459.000000 2
431 50.299999 65459.000000 2
432 50.299999 65459.000000 2
433 50.299999 65459.000000 2
434 50.299999 65459.000000 2
435 50.299999 65459.000000 2
436 50.299999 65459.000000 2
437 50.299999 65459.000000 2
438 50.299999 65459.000000 2
439 50.400002 65454.000000 0
440 50.400002 65454.000000 0
441 50.400002 65454.000000 0
442 50.400002 65454.000000 0
443 50.400002 65454.000000 0
444 50.400002 65454.000000 0
445 50.400002 65454.000000 0
446 50.400002 65454.000000 0
447 50.400002 65454.000000 0
448 50.400002 65454.000000 0
449 50.200001 65475.000000 1
450 50.200001 65475.000000 1
451 50.200001 65475.000000 1
452 50.200001 65475.000000 1
453 50.200001 65475.000000 1
454 50.200001 65475.000000 1
455 50.200001 65475.000000 1
456 50.200001 65475.000000 1
457 50.200001 65475.000000 1
458 50.200001 65475.000000 1
459 50.200001 65446.000000 0
460 50.200001 65446.000000 0
461 50.200001 65446.000000 0
462 50.200001 65446.000000 0
463 50.200001 65446.000000 0
464 50.200001 65446.000000 0
465 50.200001 65446.000000 0
466 50.200001 65446.000000 0
467 50.200001 65446.000000 0
468 50.099998 65468.000000 2
469 50.099998 65468.000000 2
470 50.099998 65468.000000 2
471 50.099998 65468.000000 2
472 50.099998 65468.000000 2
473 50.099998 65468.000000 2
474 50.099998 65468.000000 2
475 50.099998 65468.000000 2
476 50.099998 65468.000000 2
477 50.099998 65468.000000 2
478 50.500000 65465.000000 2
479 50.500000 65465.000000 2
480 50.500000 65465.000000 2
481 50.500000 65465.000000 2
482 50.500000 65465.000000 2
483 50.500000 65465.000000 2
484 50.500000 65465.000000 2
485 50.500000 65465.000000 2
486 50.500000 65465.000000 2
487 50.500000 65465.000000 2
488 50.099998 65454.000000 0
489 50.099998 65454.000000 0
490 50.099998 65454.000000 0
491 50.099998 65454.000000 0
492 50.099998 65454.000000 0
493 50.099998 65454.000000 0
494 50.099998 65454.000000 0
495 50.099998 65454.000000 0
496 50.099998 65454.000000 0
497 50.099998 65454.000000 0
498 50.299999 65460.000000 2
499 50.299999 65460.000000 2
500 50.299999 65460.000000 2

9671
iPDC/kmeans.txt Normal file

File diff suppressed because it is too large Load Diff

56
iPDC/plot_kmeans2.py Normal file
View File

@ -0,0 +1,56 @@
# 0 : 50.284426, 65451.237705
# 1 : 50.370104, 65476.164948
# 2 : 50.302515, 65464.320755
import csv
import numpy as np
import matplotlib.pyplot as plt
from sklearn import preprocessing
x=[]
y=[]
x1=[]
y1=[]
x2=[]
y2=[]
with open('kmeans.csv', mode ='r') as file:
csvFile = csv.reader(file)
for lines in csvFile:
#print(lines)
if(int(lines[2])==0):
x.append(float(lines[0]))
y.append(float(lines[1]))
elif(int(lines[2])==1):
x1.append(float(lines[0]))
y1.append(float(lines[1]))
else:
x2.append(float(lines[0]))
y2.append(float(lines[1]))
x.append(50.284426)
y.append(65451.237705)
x1.append(50.370104)
y1.append(65476.164948)
x2.append(50.302515)
y2.append(65464.320755)
x_array = np.array(x+x1+x2)
y_array = np.array(y+y1+y2)
# x1_array = np.array(x1)
# y1_array = np.array(y1)
# x2_array = np.array(x2)
# y2_array = np.array(y2)
x_arr = preprocessing.normalize([x_array])
y_arr = preprocessing.normalize([y_array])
# x1_arr = preprocessing.normalize([x1_array])
# y1_arr = preprocessing.normalize([y1_array])
# x2_arr = preprocessing.normalize([x2_array])
# y2_arr = preprocessing.normalize([y2_array])
plt.scatter(x_arr, y_arr)
# plt.scatter(x1_arr, y1_arr)
# plt.scatter(x2_arr, y2_arr)
plt.show()

204
iPDC/src/Kmeans2.c Normal file
View File

@ -0,0 +1,204 @@
#include "parser.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string.h>
#include <stdbool.h>
struct Point
{
long double x, y; // coordinates
int cluster; // no default cluster
long double minDist; // default infinite dist to nearest cluster
};
int count = 0;
struct Point *P;
long double distance(struct Point* A, struct Point* B)
{
return (((A->x - B->x) * (A->x - B->x)) + ((A->y - B->y) * (A->y - B->y)));
}
int *getRandoms(int lower, int upper, int count)
{
srand(time(0));
int *p = (int *)malloc(sizeof(int) * count);
int track = 0;
while (1)
{
if (track == count)
{
return p;
}
int num = (rand() % (upper - lower + 1)) + lower;
if (track == 0)
{
p[track] = num;
track++;
continue;
}
int flag = 0;
for (int j = 0; j <= track - 1; j++)
{
if (num == p[j])
{
flag = 1;
break;
}
}
if (flag == 0)
{
p[track] = num;
track++;
}
}
}
void Kmeans2(struct data_frame *df)
{
printf("count: %d\n",count);
if(count==0)
{
P = (struct Point *)malloc(sizeof(struct Point) * 500);
}
if (count != 500)
{
float CURR_FREQ;
if (df->dpmu[0]->fmt->freq == '0')
{
CURR_FREQ = 50 + to_intconvertor(df->dpmu[0]->freq) * 1e-3;
}
else
{
CURR_FREQ = decode_ieee_single(df->dpmu[0]->freq);
}
float CURR_vol;
if (df->dpmu[0]->fmt->phasor == '0')
{
if (df->dpmu[0]->fmt->polar == '0')
{
unsigned char s1[2];
unsigned char s2[2];
strncpy(s1, df->dpmu[0]->phasors[0], 2);
strncpy(s2, df->dpmu[0]->phasors[0] + 2, 2);
long double v1 = to_intconvertor(s1);
long double v2 = to_intconvertor(s2);
CURR_vol = sqrt((v1 * v1) + (v2 * v2));
}
else
{
unsigned char s1[2];
strncpy(s1, df->dpmu[0]->phasors[0], 2);
CURR_vol = to_intconvertor(s1);
}
}
else
{
if (df->dpmu[0]->fmt->polar == '0')
{
unsigned char s1[4];
unsigned char s2[4];
strncpy(s1, df->dpmu[0]->phasors[0], 4);
strncpy(s2, df->dpmu[0]->phasors[0] + 2, 4);
long double v1 = decode_ieee_single(s1);
long double v2 = decode_ieee_single(s2);
CURR_vol = sqrt((v1 * v1) + (v2 * v2));
}
else
{
unsigned char s1[4];
strncpy(s1, df->dpmu[0]->phasors[0], 4);
CURR_vol = decode_ieee_single(s1);
}
}
P[count].x = CURR_FREQ;
P[count].y = CURR_vol;
P[count].cluster = -1;
P[count].minDist = __DBL_MAX__;
count++;
}
else
{
int no_of_clusters = 5;
int epochs = 20;
int *c = getRandoms(0, 499, no_of_clusters);
struct Point *Centroids = (struct Point *)malloc(sizeof(struct Point) * no_of_clusters);
for (int i = 0; i < no_of_clusters; i++)
{
Centroids[i].x = P[c[i]].x;
Centroids[i].y = P[c[i]].y;
Centroids[i].minDist = __DBL_MAX__;
Centroids[i].cluster = -1;
}
free(c);
while (epochs--)
{
for (int i = 0; i < no_of_clusters; i++)
{
for (int j = 0; j < 500; j++)
{
long double dist = distance(&Centroids[i], &P[j]);
if (P[j].minDist > dist)
{
P[j].minDist = dist;
P[j].cluster = i;
}
}
}
int *nPoints = (int *)malloc(sizeof(int) * no_of_clusters);
long double *Sumx = (long double *)malloc(sizeof(long double) * no_of_clusters);
long double *Sumy = (long double *)malloc(sizeof(long double) * no_of_clusters);
for (int i = 0; i < no_of_clusters; i++)
{
nPoints[i] = 0;
Sumx[i] = 0;
Sumy[i] = 0;
}
for (int i = 0; i < 500; i++)
{
nPoints[P[i].cluster]++;
Sumx[P[i].cluster] += P[i].x;
Sumy[P[i].cluster] += P[i].y;
P[i].minDist = __DBL_MAX__;
}
for (int i = 0; i < no_of_clusters; i++)
{
Centroids[i].x = Sumx[i] / nPoints[i];
Centroids[i].y = Sumy[i] / nPoints[i];
}
free(nPoints);
free(Sumx);
free(Sumy);
}
count = 0;
FILE *fp;
fp = fopen("kmeans.txt","a");
for(int i=0;i<500;i++)
{
fprintf(fp,"%Lf, %Lf, %d\n",P[i].x,P[i].y,P[i].cluster);
}
fprintf(fp,"\n\n");
for(int i=0;i<no_of_clusters;i++)
{
fprintf(fp,"%d : %Lf, %Lf\n",i,Centroids[i].x,Centroids[i].y);
}
fprintf(fp,"\n\n");
fclose(fp);
free(Centroids);
free(P);
}
}

View File

@ -13,6 +13,7 @@
#include "connections.h" #include "connections.h"
#include "livechart.h" #include "livechart.h"
#include "utility_tools.h" #include "utility_tools.h"
#include "Kmeans2.h"
// debug // debug
@ -44,17 +45,17 @@ gboolean update_images(gpointer* pars){
float lat; float lat;
float lon; float lon;
loops++; loops++;
printf("loops: %d\n", loops); // printf("loops: %d\n", loops);
id = to_intconvertor(df->idcode); id = to_intconvertor(df->idcode);
printf("id = %d\n",id); // printf("id = %d\n",id);
pthread_mutex_lock(&mutex_cfg); pthread_mutex_lock(&mutex_cfg);
temp_cfg = cfgfirst; temp_cfg = cfgfirst;
// Check for the IDCODE in Configuration Frame // Check for the IDCODE in Configuration Frame
while(temp_cfg != NULL){ while(temp_cfg != NULL){
if(id == to_intconvertor(temp_cfg->idcode)){ if(id == to_intconvertor(temp_cfg->idcode)){
cfg_match = 1; cfg_match = 1;
printf("Matched - id : %d\n",id); // printf("Matched - id : %d\n",id);
freq_fmt = temp_cfg->pmu[0]->fmt->freq; freq_fmt = temp_cfg->pmu[0]->fmt->freq;
anal_fmt = temp_cfg->pmu[0]->fmt->analog; anal_fmt = temp_cfg->pmu[0]->fmt->analog;
phas_fmt = temp_cfg->pmu[0]->fmt->phasor; phas_fmt = temp_cfg->pmu[0]->fmt->phasor;
@ -69,7 +70,7 @@ gboolean update_images(gpointer* pars){
// get data from df. // get data from df.
if(freq_fmt == '1'){ if(freq_fmt == '1'){
freq = decode_ieee_single(df->dpmu[i]->freq); freq = decode_ieee_single(df->dpmu[i]->freq);
printf("freq = %f\n",freq); // printf("freq = %f\n",freq);
}else{ }else{
freq = to_intconvertor(df->dpmu[i]->freq)*1e-6+50; freq = to_intconvertor(df->dpmu[i]->freq)*1e-6+50;
} }
@ -80,15 +81,15 @@ gboolean update_images(gpointer* pars){
strncpy(last2bytes, df->dpmu[i]->phasors[0]+2, 2); strncpy(last2bytes, df->dpmu[i]->phasors[0]+2, 2);
vol_magnitude = to_intconvertor(first2bytes); vol_magnitude = to_intconvertor(first2bytes);
float imaginary = to_intconvertor(last2bytes); float imaginary = to_intconvertor(last2bytes);
printf("vol = %f imag = %f\n",vol_magnitude, imaginary); // printf("vol = %f imag = %f\n",vol_magnitude, imaginary);
vis_ptr = vis_data_head; vis_ptr = vis_data_head;
match = 0; match = 0;
while(vis_ptr != NULL){ while(vis_ptr != NULL){
printf("vis_ptr->id = %d\n",vis_ptr->id); // printf("vis_ptr->id = %d\n",vis_ptr->id);
if(vis_ptr->id == id){ if(vis_ptr->id == id){
match = 1; match = 1;
printf("Matched - id : %d\n",id); // printf("Matched - id : %d\n",id);
break; break;
} }
vis_ptr = vis_ptr->next; vis_ptr = vis_ptr->next;
@ -102,7 +103,7 @@ gboolean update_images(gpointer* pars){
live_chart_serie_add(vis_ptr->serie_dfreq, dfreq); live_chart_serie_add(vis_ptr->serie_dfreq, dfreq);
if(match == 1 && cfg_match == 1){ if(match == 1 && cfg_match == 1){
printf("lat = %f, lon = %f, freq = %f\n",lat,lon,freq); // printf("lat = %f, lon = %f, freq = %f\n",lat,lon,freq);
if(vis_ptr->last_image != 0){ if(vis_ptr->last_image != 0){
osm_gps_map_image_remove(parameters->util_map, vis_ptr->last_image); osm_gps_map_image_remove(parameters->util_map, vis_ptr->last_image);
} }
@ -153,7 +154,7 @@ gboolean update_images(gpointer* pars){
}else if (algorithm==1 && dimmension == 1){ }else if (algorithm==1 && dimmension == 1){
}else if (algorithm==1 && dimmension == 2){ }else if (algorithm==1 && dimmension == 2){
Kmeans2(df);
}else if (algorithm==2 && dimmension == 0){ }else if (algorithm==2 && dimmension == 0){
if(!DTWvolDistance(df)){ if(!DTWvolDistance(df)){
vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map,lat, lon, parameters->g_red_image); vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map,lat, lon, parameters->g_red_image);