fuzzy ants as a clustering concept
TRANSCRIPT
University of South FloridaScholar Commons
Graduate Theses and Dissertations Graduate School
6-17-2004
Fuzzy Ants as a Clustering ConceptParag M. KanadeUniversity of South Florida
Follow this and additional works at: https://scholarcommons.usf.edu/etdPart of the American Studies Commons
This Thesis is brought to you for free and open access by the Graduate School at Scholar Commons. It has been accepted for inclusion in GraduateTheses and Dissertations by an authorized administrator of Scholar Commons. For more information, please contact [email protected].
Scholar Commons CitationKanade, Parag M., "Fuzzy Ants as a Clustering Concept" (2004). Graduate Theses and Dissertations.https://scholarcommons.usf.edu/etd/1104
Fuzzy Ants as a Clustering Concept
by
Parag M. Kanade
A thesis submitted in partial fulfillmentof the requirements for the degree of
Master of Science in Computer ScienceDepartment of Computer Science and Engineering
College of EngineeringUniversity of South Florida
Major Professor: Lawrence O. Hall, Ph.D.Dmitry B. Goldgof, Ph.D.
Sudeep Sarkar, Ph.D.
Date of Approval:June 17, 2004
Keywords: Cluster Analysis, Swarm Intelligence, Ant Colony Optimization, Fuzzy C MeansAlgorithm, Hard C Means Algorithm
c© Copyright 2004, Parag M. Kanade
DEDICATION
To my parents and my loving sister Pallavi.
ACKNOWLEDGEMENTS
I would like to thank Dr. Lawrence O. Hall for giving me the opportunity to work with him. His
guidance and support was invaluable. I would like to thank Dr. Dmitry Goldgof, and Dr. Sudeep
Sarkar for taking the time and effort to ensure that my work was of quality. I am grateful to my
family, friends and colleagues who gave me inspiration and helped me in every step.
TABLE OF CONTENTS
LIST OF TABLES iii
LIST OF FIGURES vi
ABSTRACT viii
CHAPTER 1 INTRODUCTION 11.1 Clustering 1
1.1.1 Hard Clustering 21.1.2 Fuzzy Clustering 3
1.2 Swarm Intelligence 31.2.1 Self Organization in Social Insects 41.2.2 Stigmergy 51.2.3 Cemetery Organization and Brood Sorting in Ants 5
CHAPTER 2 DATASETS 72.1 Iris Plant Dataset 82.2 Wine Recognition Dataset 82.3 Glass Identification Dataset 132.4 Multiple Sclerosis Dataset 142.5 MRI and British Towns’ Datasets 142.6 Artificial Datasets 14
CHAPTER 3 FUZZY ANTS ALGORITHM 153.1 Picking up an Object 203.2 Dropping an Object 203.3 The Second Stage 213.4 Results 23
3.4.1 Iris Dataset 233.4.2 Wine Recognition Dataset 243.4.3 Glass Identification Dataset 253.4.4 Artificial Datasets 26
3.5 Effect of Parameter Variation 293.6 Variations in the Algorithm 293.7 Discussion 36
CHAPTER 4 AUTOMATICALLY SETTING THE PARAMETERS 384.1 New Metric for Merging Heaps 384.2 Results Using the New Metric 384.3 Fuzzy Hypervolume 40
i
CHAPTER 5 FUZZY ANT CLUSTERING WITH CENTROIDS 445.1 Introduction 445.2 Reformulation of Clustering Criteria for FCM and HCM 445.3 Algorithm 455.4 Results 495.5 Hard C Means 515.6 Execution Time 535.7 Conclusions 55
CHAPTER 6 CONCLUSIONS AND FUTURE WORK 576.1 Combined Algorithm 576.2 Contributions 596.3 Future Work 59
REFERENCES 60
APPENDICES 63Appendix A Datasets 64A.1 Parameters Used to Generate the Gaussian Datasets 64A.2 Plots of the Different Datasets 66
ii
LIST OF TABLES
Table 2.1 Datasets 7
Table 3.1 Values of the Parameters Used in the Fuzzy Ants Experiments 23
Table 3.2 Results from FCM 24
Table 3.3 Results for Iris Dataset 24
Table 3.4 Results for Iris Dataset (2 Class) 25
Table 3.5 Results for Wine Recognition Dataset 25
Table 3.6 Results for Glass Identification Dataset 25
Table 3.7 Results for Glass Identification Dataset (2 Class) 26
Table 3.8 Results for Gauss-1 Dataset 27
Table 3.9 Results for Gauss-2 Dataset 27
Table 3.10 Results for Gauss-3 Dataset 27
Table 3.11 Results for Gauss-4 Dataset 27
Table 3.12 Results for Gauss-5 Dataset 28
Table 3.13 Results for Gauss500-1 Dataset 28
Table 3.14 Results for Gauss500-2 Dataset 28
Table 3.15 Results for Gauss500-3 Dataset 28
Table 3.16 Results for Gauss500-4 Dataset 29
Table 3.17 Results for Gauss500-5 Dataset 29
Table 3.18 Effect of Variation of Iterations on Iris Dataset 30
Table 3.19 Effect of Variation of Iterations on Wine Dataset 30
Table 3.20 Results for the Iris Dataset (3D Board) 31
Table 3.21 Results for the Iris Dataset (2 Class) (3D board) 31
Table 3.22 Results for the Wine Dataset (3D Board) 32
Table 3.23 Results for the Glass Dataset (3D board) 32
iii
Table 3.24 Results for the Glass (2 Class) Dataset (3D Board) 33
Table 3.25 Results for the Gauss500-1 Dataset (3D Board) 34
Table 3.26 Results for the Gauss500-2 Dataset (3D Board) 34
Table 3.27 Results for the Gauss500-3 Dataset (3D Board) 35
Table 3.28 Results for the Gauss500-4 Dataset (3D Board) 35
Table 3.29 Results for the Gauss500-5 Dataset (3D Board) 36
Table 3.30 Typical Example of Variance in Data Partitions Obtained with the Wine Datasetwith Tcreateforheap = 0.09 and 3000 Iterations 37
Table 4.1 Results from the New Metric for Iris Dataset 39
Table 4.2 Results from the New Metric for Wine Dataset 39
Table 4.3 Effect of Variation of Iterations on Iris Dataset 40
Table 4.4 Effect of Variation of Iterations on Wine Dataset 40
Table 4.5 Tcreateforheap and Fuzzy Hypervolume 42
Table 5.1 Parameter Values 49
Table 5.2 Results for Fuzzy C Means 50
Table 5.3 New Parameters 50
Table 5.4 Results for FCM Obtained from Modified Parameters 51
Table 5.5 Results for Hard C Means 52
Table 5.6 Results for the British Towns Dataset 52
Table 5.7 Results for the Wine Dataset 53
Table 5.8 Results for the MRI Dataset 53
Table 5.9 Variation of Rm with the Number of Ants for Slice # 35 of MRI Dataset 53
Table 5.10 Execution Time 54
Table 5.11 Frequency of Different Extrema from FCM, for British Towns and MRI Datasets 55
Table 5.12 Frequency of Different Extrema from HCM, for Glass (2 Class) and Iris Datasets 56
Table 5.13 Frequency of Different Extrema from HCM, MRI Dataset 56
Table 6.1 Results from the Combined Algorithm 58
Table 6.2 Results from the Combined Algorithm (Errors) 58
Table A.1 Parameters Used to Generate the Gauss Datasets 64
iv
Table A.2 Parameters Used to Generate the Gauss-500 Datasets 65
v
LIST OF FIGURES
Figure 1.1 Fuzzy C Means Algorithm 4
Figure 2.1 Iris Dataset (Normalized)- First 2 Principal Components 9
Figure 2.2 Iris Dataset (Normalized)- First 3 Principal Components 10
Figure 2.3 Iris Dataset: 2 Classes (Normalized)- First 2 Principal Components 11
Figure 2.4 Iris Dataset: 2 Classes (Normalized)- First 3 Principal Components 12
Figure 3.1 The Ant Based Algorithm 16
Figure 3.2 Algorithm 18
Figure 3.3 Algorithm (cont...) 19
Figure 3.4 Algorithm to Pick up an Object 20
Figure 3.5 Algorithm for Dropping an Object 21
Figure 3.6 The Two-stage Algorithm 22
Figure 4.1 Tcreateforheap vs Fuzzy Hypervolume 42
Figure 4.2 Tcreateforheap vs Fuzzy Hypervolume (Log) 43
Figure 5.1 Pictorial View of the Algorithm 47
Figure 5.2 Fuzzy Ant Clustering with Centroids Algorithm 48
Figure A.1 Wine Dataset (Normalized)- First 2 Principal Components 66
Figure A.2 Wine Dataset (Normalized)- First 3 Principal Components 66
Figure A.3 Glass Dataset (Normalized)- First 2 Principal Components 67
Figure A.4 Glass Dataset (Normalized)- First 3 Principal Components 67
Figure A.5 Glass Dataset: 2 classes (Normalized)- First 2 Principal Components 68
Figure A.6 Glass Dataset: 2 classes (Normalized)- First 3 Principal Components 68
Figure A.7 Multiple Sclerosis Dataset (Normalized)- First 2 Principal Components 69
Figure A.8 Multiple Sclerosis Dataset (Normalized)- First 3 Principal Components 69
Figure A.9 Gauss-1 Dataset (Normalized) 70
vi
Figure A.10 Gauss-2 Dataset (Normalized) 70
Figure A.11 Gauss-3 Dataset (Normalized) 71
Figure A.12 Gauss-4 Dataset (Normalized) 71
Figure A.13 Gauss-5 Dataset (Normalized) 72
Figure A.14 Gauss500-1 Dataset (Normalized) 72
Figure A.15 Gauss500-2 Dataset (Normalized) 73
Figure A.16 Gauss500-3 Dataset (Normalized) 73
Figure A.17 Gauss500-4 Dataset (Normalized) 74
Figure A.18 Gauss500-5 Dataset (Normalized) 74
vii
FUZZY ANTS AS A CLUSTERING CONCEPT
Parag M. Kanade
ABSTRACT
We present two Swarm Intelligence based approaches for data clustering. The first algorithm,
Fuzzy Ants, presented in this thesis clusters data without the initial knowledge of the number of
clusters. It is a two stage algorithm. In the first stage the ants cluster data to initially create raw
clusters which are refined using the Fuzzy C Means algorithm. Initially, the ants move the individual
objects to form heaps. The centroids of these heaps are refined by the Fuzzy C Means algorithm.
In the second stage the objects obtained from the Fuzzy C Means algorithm are hardened according
to the maximum membership criteria to form new heaps. These new heaps are then moved by the
ants. The final clusters formed are refined by using the Fuzzy C Means algorithm. Results from
experiments with 13 datasets show that the partitions produced are competitive with those from
FCM. The second algorithm, Fuzzy ant clustering with centroids, is also a two stage algorithm, it
requires an initial knowledge of the number of clusters in the data. In the first stage of the algorithm
ants move the cluster centers in feature space. The cluster centers found by the ants are evaluated
using a reformulated Fuzzy C Means criterion. In the second stage the best cluster centers found
are used as the initial cluster centers for the Fuzzy C Means algorithm. Results on 18 datasets show
that the partitions found by FCM using the ant initialization are better than those from randomly
initialized FCM. Hard C Means was also used in the second stage and the partitions from the ant
algorithm are better than from randomly initialized Hard C Means. The Fuzzy Ants algorithm is
a novel method to find the number of clusters in the data and also provides good initializations for
the FCM and HCM algorithms. We performed sensitivity analysis on the controlling parameters
and found the Fuzzy Ants algorithm to be very sensitive to the Tcreateforheap parameter. The FCM
and HCM algorithms, with random initializations can get stuck in a bad extrema, the Fuzzy ant
clustering with centroids algorithm successfully avoids these bad extremas.
viii
CHAPTER 1
INTRODUCTION
Modern technology provides us with efficient and low-cost techniques for data collection. Raw
data, however, is of limited use for decision making and intelligent analysis. Machine learning aims
to create automatic or semiautomatic tools for the analysis of raw data to discover useful patterns
and rules. Clustering is one of the most important unsupervised learning techniques.
1.1 Clustering
The aim of cluster analysis is to find groupings or structures within unlabeled data [19]. The
partitions found should in general have the following properties
Homogeneity: The data that are assigned to the same cluster should be similar.
Heterogeneity: The data that are assigned to different clusters should be different.
In most cases the data is in the form of real-valued vectors. The euclidean distance is a suitable
measure of similarity for these datasets. The partitions should then be such that the intra-cluster
distance is minimized and the inter-cluster distance is maximized.
The clustering techniques can be broadly classified as follows [16]:
• Incomplete/Heuristic: Clusters are determined by heuristic methods based on visualization
after dimensionality reduction of the data. The dimensionality is reduced by using geometrical
methods (PCA) or projection techniques.
• Deterministic crisp: Each datum is assigned to one and only one cluster.
• Overlapping crisp: Each datum can be simultaneously assigned to several clusters.
• Probabilistic: A probability distribution specifies the probability of assignment of the datum
to a cluster.
1
• Possibilistic/Fuzzy: These are pure fuzzy clustering techniques. Degrees of membership indi-
cate the extent to which the datum belongs to the cluster. The sum of memberships of each
datum across all the clusters may not be 1 for possibilistic clustering.
• Hierarchical: These techniques are based on either dividing the data into more fine-grained
classes or combining small classes to more coarse-grained classes.
• Objective function based: These techniques are based on an objective or evaluation function
that assigns a quality or error value to each possible partition or group of clusters. The
partition that obtains the best evaluation is the chosen solution.
• Cluster estimation: These techniques use heuristic functions to build partitions and estimate
the cluster parameters.
1.1.1 Hard Clustering
Hard C Means (HCM) is one of the simplest unsupervised clustering algorithms to cluster data
into a fixed number of clusters. The basic idea of the algorithm is to initially guess the centroids
of the clusters and then refine them. Cluster initialization is very crucial because the algorithm is
very sensitive to this initialization. A good choice for the initial cluster centers is to place them as
far away from each other as possible. The nearest neighbor algorithm is then used to assign each
feature vector to a cluster. Using the clusters obtained, new cluster centroids are calculated. The
above steps are repeated until there is no significant change in the centroids.
The objective function minimized by the hard C Means algorithm is given in 1.1
J =c∑
i=1
n∑k=1
Dik(xk, βi) (1.1)
where
• c≥ 2: Number of clusters
• n: Number of data points
• βi: The ith cluster prototype
• Dik(xk, βi): Distance of xk from ith cluster center
2
1.1.2 Fuzzy Clustering
Hard clustering algorithms assign each datum to one and only one cluster. This model is
inappropriate for real datasets in which the boundaries between the clusters may be fuzzy. Fuzzy
algorithms can assign data to multiple clusters. Fuzzy algorithms are based on fuzzy logic which
was developed by Lotfi Zadeh [38]. Deterministic membership functions assign each datum to a
particular cluster, that is, the membership functions map the membership of the datum in a cluster
to either 0 or 1. Fuzzy membership functions, on the other hand, map the memberships to the real
interval [0.0 1.0]. The degree of membership in the cluster depends on the closeness of the datum
to the cluster center. High membership values indicate less distance between the datum and the
cluster center.
The Fuzzy C Means algorithm (FCM), developed by Bezdek [3], allows the datum to be a
partial member of more than one cluster. The FCM algorithm is based on minimizing the objective
function 1.2
Jm(U, β) =c∑
i=1
n∑k=1
Umik Dik(xk, βi) (1.2)
where
• c≥ 2: Number of clusters
• n: Number of data points
• βi: The ith cluster prototype
• Dik(xk, βi): Distance of xk from ith cluster center
• Uik: Membership of the kth object in the ith cluster
• m ≥ 1: The degree of fuzzification
The Fuzzy C Means algorithm is shown in Figure 1.1
The drawback of clustering algorithms like FCM and HCM, which are based on the hill climb-
ing heuristic is, prior knowledge of the number of clusters in the data is required and they have
significant sensitivity to cluster center initialization.
1.2 Swarm Intelligence
Research in using the social insect metaphor for solving problems is still in its infancy. The
systems developed using swarm intelligence principles emphasize distributiveness, direct or indirect
3
1. Initialize the initial cluster centers and calculate the U matrix U (0)
2. At the tth step, calculate the new cluster centers
βi =∑
n
k=1um
ik·xk∑n
k=1um
ik
3. Update the U matrix, U t, U (t−1)
uik = 1∑c
j=1
(Dik(xk,βi)Dij(xk,βj)
) 11−m
4.If |U t − U t−1| < ε then STOP; otherwise goto step 2
Figure 1.1. Fuzzy C Means Algorithm
interactions among relatively simple agents, flexibility and robustness [7]. Successful applications
have been developed in the communication networks, robotics and combinatorial optimization fields.
1.2.1 Self Organization in Social Insects
Self Organization is the mechanism of forming global structures from the interaction of lower-
level components. The rules specifying the interactions among lower-level components are based
on local information, without reference to global information. The global pattern is an emergent
property of the system. Self organization is based on four basic principles [7]:
• Positive feedback: It is the basis of morphogenesis. Examples of positive feedback are recruit-
ment and reinforcement.
• Negative feedback: It counterbalances positive feedback and is responsible for the stabilization
of the emergent pattern. Negative feedback may be in the form of saturation, exhaustion, or
competition.
• Amplification of fluctuations: Amplification of fluctuations is an important factor for self
organization. Randomness is crucial, since it enables discovery of new solutions. Fluctuations
can act as seeds for the growth of new structures.
• Multiple interactions: Self organization is a result of interactions within mutually tolerant
individuals. Individuals make use of their own activities as well as of others’ activities. For
4
examples the trails laid by ants appear to self-organize and be used collectively if individuals
use others’ pheromone.
The key characteristics of a self organized system are [7]:
• Structures: Self organized systems create spatiotemporal structures in an initially homoge-
neous medium. Nest architectures, foraging trails, and social organization are the examples
of spatiotemporal structures.
• Coexistence: Coexistence of several stable states is possible. The emergent system is the
result of amplification of random deviations, depending on the initial conditions the system
converges to one among several possible stable states.
• Bifurcations: Depending on the variation in the parameters, the system may bifurcate. The
behavior of the system changes drastically at bifurcations.
1.2.2 Stigmergy
Self-organization in social insects is the result of direct and indirect interactions. Examples of
direct interactions are visual contact, chemical contact, antennation, trophallaxis, and mandibular
contact [7]. Indirect interactions occur when one individual changes the environment and the others
respond to the new environment at a later time. This subtle interaction is an example of stigmergy.
Stigmergy helps in replacing coordination through direct communications by indirect interac-
tions, reducing the communication among agents. Stigmergy also allows the emergent system to
be flexible. The insects respond to an external perturbation as if it were a modification of the
environment caused by the colony’s activities. That is, the colony collectively responds to the per-
turbation [7]. Artificial agents designed using this principle can respond to a perturbation without
being reprogrammed to deal with that particular perturbation.
1.2.3 Cemetery Organization and Brood Sorting in Ants
Many species of ants cluster dead bodies to form cemeteries, and sort the larvae into several
piles. This behavior can be simulated using a simple model in which the agents move randomly in
space and pick up and deposit items on the basis of local information. The clustering and sorting
behavior of ants can be used as a metaphor for designing new algorithms for data analysis and
graph partitioning. The objects can be considered as items to be sorted. Objects placed next to
5
each other have similar attributes. This sorting takes place in two-dimensional space, offering a
low-dimensional representation of the objects.
The cemetery organization of the ant Lasius niger and Pheidole pallidula has been well studied
[7]. The ants form piles of corpses, cemeteries, to clean up their nests. It is observed that if corpses
are randomly distributed, the workers form cemetery clusters. If the area is not large or if there
are spatial heterogeneities, the clusters are formed along the edges or following the heterogeneities
[7]. This aggregation phenomenon is due to the attraction between the dead items mediated by the
worker ants. Small clusters of items grow by attracting workers to deposit more items, this positive
feedback leads to the formation of larger and larger clusters.
Brood sorting is also widespread in ants. It is observed in the ant Leptothorax unifasciatus
[7]. Worker ants gather larvae according to their size, all larvae of the same size tend to cluster
together. An item is dropped by the ant if it is surrounded by items similar to the item the ant is
carrying, an item is picked up by the ant when it perceives items in the neighborhood which are
dissimilar to the items to be picked up. In Leptothorax unifasciatus the small larvae are located in
the center and larger larvae are located toward the periphery. The amount of space allocated to a
brood item varies with the type of brood. Eggs and micro-larvae are clustered compactly at the
center, with each individual item given little individual space. Individual space tends to increase
toward the periphery. The largest larvae, which are located at the periphery, are allocated more
individual space [7].
6
CHAPTER 2
DATASETS
Six real datasets and ten artificial datasets were tested in this thesis. The datasets tested were
• Iris Plant Dataset
• Wine Recognition Dataset
• Glass Identif ication Dataset
• Multiple Sclerosis Dataset
• MRI Dataset
• British Towns’ Dataset
• Gauss 1-5 Datasets
• Gauss500 1-5 Datasets
The datasets are described in Table 2.1 and the following sections.
Table 2.1. Datasets
Number of Number of Number ofDataset
Examples Continuous Attributes Classes
Iris 150 4 3
Wine 178 13 3
Glass 214 9 6
MRI 65536 3 3
Multiple Sclerosis 98 5 2
British Towns 50 4 5
Gauss1-5 1000 2 5
Gauss500-1-5 500 2 5
7
2.1 Iris Plant Dataset
This is probably the most studied dataset in the field of pattern recognition. The dataset has
information about different types of Iris flowers [6].
The dataset contains 3 classes, Iris Setosa, Iris Versicolour, and Iris Virginica, with 50 instances
of each class. One class is linearly separable from the other two. The remaining classes are not
linearly separable from each other. There are four numeric predictive attributes for each instance,
they are
• Petal Length
• Petal Width
• Sepal Length
• Sepal Width
To visualize the dataset, the Principal Component Analysis (PCA) algorithm [11] is used to
project the data points to a 2D and 3D space. Figures 2.1 and 2.2 show the scatter of the points,
after PCA, in 2D and 3D respectively. One class is linearly separable from the other two. For
clustering purposes, the iris dataset can be considered having only 2 clusters. The dataset with 2
clusters is shown in Figures 2.3 and 2.4.
2.2 Wine Recognition Dataset
The data are the results of a chemical analysis of wines grown in the same region in Italy but
derived from three different cultivars. Quantities of 13 different constituents found in each of the
three types of wines was measured [6]. The constituents are:
• Alcohol
• Malic acid
• Ash
• Alcalinity of ash
• Magnesium
• Total phenols
8
−0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1−0.8
−0.6
−0.4
−0.2
0
0.2
0.4
0.6
1st Principal Component
2nd
Prin
cipa
l Com
pone
nt
Iris−setosaIris−versicolorIris−virginica
Figure 2.1. Iris Dataset (Normalized)- First 2 Principal Components
Note: All values are in generic units
9
−1
−0.5
0
0.5
1
−1
−0.5
0
0.5
1−0.4
−0.3
−0.2
−0.1
0
0.1
0.2
0.3
1st Principal Component2nd Principal Component
3rd
Prin
cipa
l Com
pone
nt
Iris−setosaIris−versicolorIris−virginica
Figure 2.2. Iris Dataset (Normalized)- First 3 Principal Components
Note: All values are in generic units
10
−0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1−0.8
−0.6
−0.4
−0.2
0
0.2
0.4
0.6
1st Principal Component
2nd
Prin
cipa
l Com
pone
nt
Iris−setosaIris−versicolor & Iris−virginica
Figure 2.3. Iris Dataset: 2 Classes (Normalized)- First 2 Principal Components
Note: All values are in generic units
11
−1
−0.5
0
0.5
1
−1
−0.5
0
0.5
1−0.4
−0.3
−0.2
−0.1
0
0.1
0.2
0.3
1st Principal Component2nd Principal Component
3rd
Prin
cipa
l Com
pone
nt
Iris−setosaIris−versicolor & Iris−virginica
Figure 2.4. Iris Dataset: 2 Classes (Normalized)- First 3 Principal Components
Note: All values are in generic units
12
• Flavanoids
• Nonflavanoid phenols
• Proanthocyanins
• Color intensity
• Hue
• OD280/OD315 of diluted wines
• Proline
The class distribution is class 1: 59 class 2: 71 and class 3: 48. The projection of the data
points in 2D and 3D space is shown in appendix A, in Figures A.1 and A.2 respectively.
2.3 Glass Identif ication Dataset
The study of types of glass was motivated by its immense potential in criminology. The glass at
the scene of crime, if identified correctly, can be used as evidence. The dataset has 214 examples of
six different types of glass. Each example has 9 attributes, giving the quantity of different chemical
elements present in the glass [6]. The attributes are:
• Refractive Index
• Na: Sodium
• Mg: Magnesium
• Al: Aluminum
• Si: Silicon
• K: Potassium
• Ca: Calcium
• Ba: Barium
• Fe: Iron
13
The projection of the data points in 2D and 3D space is shown in Figures A.3 and A.4 respectively.
The glass dataset can be considered as having two classes window glass and non-window glass. The
projection of the data considering two classes is shown in Figures A.5 and A.6.
2.4 Multiple Sclerosis Dataset
The Multiple Sclerosis dataset has 98 instances each having 5 numeric continuous attributes.
The projection of the data points in 2D and 3D space is shown in Figures A.7 and A.8 respectively.
2.5 MRI and British Towns’ Datasets
The MRI dataset has 65,536 instances, each with 3 numeric continuous attributes, from 3 classes.
The British Towns’ dataset has 50 instances, each with 4 numeric continuous attributes, from 5
classes.
2.6 Artif icial Datasets
Ten artificial datasets were generated using Gaussian distributions. A mixture of five Gaussians
was used to generate the data. The probability distribution across all the datasets is the same but
the means and standard deviations of the Gaussians are different. Of the ten datasets, five datasets
had 500 instances each and the remaining five datasets had 1000 instances each. Each example had
two attributes. The datasets are shown in Figures A.9–A.18. The parameters used to generate the
datasets are shown in the Appendix A.1.
14
CHAPTER 3
FUZZY ANTS ALGORITHM
The Fuzzy Ants algorithm is based on Swarm Intelligence principles applied to cluster data.
Data is clustered without the initial knowledge of the number of clusters. We use ant based
clustering to initially create raw clusters and then these clusters are refined using the Fuzzy C
Means algorithm. Initially the ants move the individual objects to form heaps. The centroids of
these heaps are taken as the initial cluster centers and the Fuzzy C Means algorithm is used to
refine these clusters. In the second stage the objects obtained from the Fuzzy C Means algorithm
are hardened according to the maximum membership criterion to form new heaps. These new heaps
are then sometimes moved and merged by the ants. The final clusters formed are refined by using
the Fuzzy C Means algorithm.
In past research the K means clustering algorithm has been used on the centers obtained from
the ant based algorithm as introduced in [26]; here we study the effect of using the Fuzzy C means
approach on the cluster centers obtained from the ant based algorithm. In [26] the Fuzzy K-means
algorithm was used to refine the clusters found by the ants. In [4] the ant system and the K-means
algorithm were used for document clustering.
The general outline of the ant based algorithm used in this study was proposed in [26]. Initially
the objects are scattered randomly on a discrete 2D board. The board can be considered a matrix
of m × m cells. The matrix is toroidal which allows the ants to travel from one end to another
easily. The size of the board is dependent on the number of objects. We have used a board of
m × m such that m2 = 4n where n is the total number of objects to be clustered. Initially the ants
are randomly scattered throughout the board. There are n3 ants, where n is the total number of
objects to be clustered.
The ants cluster the objects to form heaps. A heap is defined as a collection of 2 or more
objects. A heap is spatially located in a single cell.
15
Consider a heap H with nH objects, then we define the following parameters:
• The maximum distance between two s-dimensional objects in the heap
Dmax(H) = maxXi,XjεHD(Xi, Xj)
Where D is the euclidean distance between the objects.
• The center of mass of all the objects in the heap
Ocenter(H) =1
nH
∑OiεH
Oi
• The most dissimilar object in the heap Odissim(H ) : It is the object which is the farthest from
the center of the heap.
• The mean distance between the objects of H and the center of the mass of the heap
Dmean(H) =1
nH
∑OiεH
D (Oi, Ocenter(H))
The main ant based clustering algorithm is presented in Figure 3.1 [26].
1. Randomly place the ants on the board. Randomly place objects on the board at
most one per cell
2. Repeat
3. For each ant Do
3.1 Move the ant
3.2 If the ant does not carry any object then if there is an object in the 8 neigh-
boring cells of the ant, the ant possibly picks up the object,
3.3 Else the ant possibly drops a carried object, by looking at the 8 neighboring
cells around it.
4. Until stopping criteria.
Figure 3.1. The Ant Based Algorithm
Initially the ants are scattered randomly on the 2D board. The ant moves on the board and
possibly picks up an object or drops an object. The movement of the ant is not completely random.
Initially the ant picks a direction randomly, then the ant continues in the same direction with a
16
probability Pdirection , otherwise it generates a new random direction. On reaching the new location
on the board the ant may possibly pick up an object or drop an object, if it is carrying one. The
heuristics and the exact mechanism for picking up or dropping an object are explained below. The
stopping criterion for the ants, here, is the upper limit on number of times through the repeat loop.
The different steps of the algorithm are shown in Figures 3.2 and 3.3.
17
Figure 3.2. Algorithm
18
Figure 3.3. Algorithm (cont...)
19
3.1 Picking up an Object
When the ant is not carrying any object, it searches for possible objects to pick up by examining
the eight neighboring cells around its current position. If an object or heap is found then the ant
possibly picks up an object. The heuristic for picking up an object depends on the number of
objects in the heap. Three cases are considered: only one object, a heap of two objects and a heap
of more than two objects. If a single object is present then the ant has a fixed probability of picking
it up. If there is a heap of two objects then with a probability Pdestroy the ant destroys the heap
by picking a random object from the heap. In the third case the ant picks up the most dissimilar
object from the heap if the dissimilarity is above a given threshold Tremove . The algorithm for
picking up an object is given in Figure 3.4 [26].
1. Mark the 8 neighboring cells around the ant as ‘unexplored’
2. Repeat
2.1 Consider the next unexplored cell around the ant
2.2 If the cell is not empty then
2.2.1 If the cell contains a single object X, then the object X is picked up with
a probability Pload , else
2.2.2 If the cell contains a heap of two objects, then the heap is destroyed by
picking up a random object with a probability Pdestroy else
2.2.3 If the cell contains a heap H of more than 2 objects, then the most
dissimilar object, Odissim (H ), of H is removed only ifD (Odissim(H), Ocenter(H))
Dmean(H)> Tremove
2.3 Label the cell as ‘explored’
3. Until all the neighboring cells have been explored or one object has been picked
up.
Figure 3.4. Algorithm to Pick up an Object
3.2 Dropping an Object
When the ant is carrying an object, it examines the 8 cells surrounding its current location.
Three cases are considered: the cell is empty, the cell contains one object only, and the cell contains
20
a heap. In the first case the ant has a constant probability of dropping the object. In the second
case a heap is created if the object carried is sufficiently similar to the one already in the cell. In
the third case the ant will add its object to the heap if the object is closer to H ’s center than the
most dissimilar object of H. The algorithm for dropping the object is given in Figure 3.5 [26].
1. Mark the 8 neighboring cells around the ant as ‘unexplored’
2. Repeat
2.1 Consider the next unexplored cell around the ant
2.1.1 If the cell is empty then the object carried by the ant, X, is dropped with
a probability Pdrop else
2.1.2 If the cell contains a single object X’ then a heap of two objects is created
by dropping X on X’ only if D(X,X′)Dmax
< Tcreate else
2.1.3 If the cell contains a heap H then X is dropped on H only if
D(X, Ocenter(H)) < D(Odissim(H), Ocenter(H))
2.2 Label c as ‘explored’
3. Until all the neighboring cells have been explored or the carried object has been
dropped.
Figure 3.5. Algorithm for Dropping an Object
3.3 The Second Stage
The ant based algorithm provides a partition of the data without any knowledge of the initial
cluster centers. In the ant based algorithm if an object is a poor fit to a heap then it can take a long
amount of time for it to be transported to a better heap/cluster. So in the past researchers have
used ant based algorithms which are based on stochastic principles in combination with the K-means
algorithm which is based on deterministic principles. We have used the Fuzzy C means algorithm
as the deterministic algorithm. The fuzzy C means algorithm requires good initializations, which
can be provided by the ant based algorithm.
One problem with the ant based algorithm not fixed by the FCM algorithm is that the number
of classes is always overestimated. Many small homogeneous heaps are formed. We use these heaps
as the building blocks to build large heaps.
21
In the second stage we consider the heaps formed by the first stage and move the entire heap
on the 2D board. The ants carry an entire heap of objects. The algorithm for picking up a heap
is the same as that for the objects. Ants will pick the heap with the same probability Pload . Ants
drop a heap H1 onto another heap H2 provided that:
D (Ocenter(H1), Ocenter(H2))Dmax
< Tcreateforheap
When two heaps H1 and H2 are clustered together, they form only one heap H3 . They cannot
be separated any more. The number of heaps either decrease or remain constant as the number of
iterations increase.
The Fuzzy C Means algorithm is then used to cluster the data using the cluster centers obtained
from the second stage of the ant based algorithm as an initialization. The algorithm used in the
study is given in Figure 3.6.
1. Scatter the objects randomly on the board
2. Initialize the ants with random position, and random direction
3. For Niterations iterations Do
3.1 For each ant Do
3.1.1 Move the ant
3.1.2 If the ant is carrying an object X then possibly drop the object X else
3.1.3 Possibly pick up an object X
4. Use the cluster centers obtained in step 3 to initialize cluster centers for the Fuzzy
C Means algorithm
5. Cluster the data using the Fuzzy C Means algorithm
6. Harden the data obtained from the Fuzzy C means algorithm, using the maximum
membership criterion, to form new heaps
7. Repeat steps 1-6 by considering each heap as a single object
Figure 3.6. The Two-stage Algorithm
The values of the various parameters as used here are shown in Table 3.1.
22
Table 3.1. Values of the Parameters Used in the Experiments
Parameter Value
Niterations 1000
Tcreate 0.5
Pdrop 0.2
Pdestroy 0.3
Pload 0.3
Tremove (Iris) 1.5
Tremove (Wine) 3.0
Tremove (Glass) 2.0
Tremove (Gauss) 1.5
3.4 Results
The reported results are averaged for 50 runs of the experiments. In each run, the ants and
the objects were initially randomly placed at different positions on the board. The movement of
ants and the picking and dropping of the objects also had a stochastic component. We performed
experiments using different parameter values. By varying the parameters we could control the
number of heaps obtained. In the experiments all but one parameter is fixed. The parameter
Tcreateforheap is varied. This parameter is the threshold for the maximum dissimilarity allowed
while merging the heaps. The original parameters are shown in Table 3.1, the results for different
parameter values are shown below. The average results for 50 runs of the FCM algorithm with
random initializations are in Table 3.2. We report errors which may not be the fairest measure
given the algorithm is optimizing a function which indirectly relates to errors.
3.4.1 Iris Dataset
Results for the Iris Data set are shown in Table 3.3. As Tcreateforheap is increased fewer clusters
are found. Every time two clusters are found, which is 3 times with the value of 0.12, 19 times
with the value of 0.14, and 41 times with the value of 0.18, at least 50 errors are observed. This is
because the separable class is almost always correctly split off with the other cluster consisting of
a mixture of the other two clusters.
In the Iris dataset feature space one class is linearly separable from the other two, so strictly
speaking one could come to the determination that there are only two clusters. Hence, the results
23
Table 3.2. Results for FCM Algorithm (Avg. from 50 random initializations)
Dataset Classes Errors
Iris 3 16
Iris 2 3
Wine 3 9
Glass 6 96
Glass 2 20
Gauss 1 5 0
Gauss 2 5 0
Gauss 3 5 0
Gauss 4 5 25.32
Gauss 5 5 7
Gauss 500-1 5 1
Gauss 500-2 5 0
Gauss 500-3 5 1
Gauss 500-4 5 1.94
Gauss 500-5 5 0
for the Iris dataset considering 2 classes are shown in Table 3.4. In this case if we allow up to four
classes to be found, while over clustering is done, we always get homogeneous clusters.
Table 3.3. Results for the Iris Dataset
Classes Errors after Errors afterTcreateforheap
found ant stage FCM
0.18 2.18 49.76 43.88
0.14 2.76 45.92 29.42
0.12 3.74 36.34 19.42
0.10 5.12 25.56 15.16
3.4.2 Wine Recognition Dataset
The results for the Wine Recognition dataset are shown in Table 3.5. We get more errors than
randomly initialized FCM because the ants sometimes find only 2 clusters and the errors increase
dramatically because of this under clustering. Also, when more than 4 clusters are found the errors
shoot up.
24
Table 3.4. Results for the Iris Dataset Considering 2 Classes
Classes Errors after Errors afterTcreateforheap found ant stage FCM
0.20 2.02 3.74 2.94
0.18 2.14 1.16 2.58
0.12 3.74 0 0.18
Table 3.5. Results for the Wine Recognition Dataset
Classes Errors after Errors afterTcreateforheap found ant stage FCM
0.085 4.46 13.94 9.36
0.09 3.9 14.3 9.02
0.1 3.76 23.08 10.4
3.4.3 Glass Identif ication Dataset
This is perhaps the most difficult dataset to cluster. The results for the Glass Identification
dataset are shown in Table 3.6. If we allow over clustering then the errors are a little better than
the randomly initialized FCM, but as we close in on the correct number of clusters, sometimes
under clustering occurs and the errors shoot up.
The glass dataset can be considered as a two cluster dataset, window glass and non-window
glass. The results for this modified dataset are shown in Table 3.7. For this dataset both over
clustering and under clustering increase the errors, for this reason the errors for the ant algorithm
are always greater than for randomly initialized FCM.
Table 3.6. Results for the Glass Identification Dataset
Classes Errors after Errors afterTcreateforheap
found ant stage FCM
0.075 9.36 102.38 88.2
0.085 8.08 103.76 93.34
0.105 5.04 111.52 99.72
0.12 4.54 115.72 102.9
0.16 2.56 136.82 118.94
25
Table 3.7. Results for the Glass Identification Dataset Considering 2 Classes
Classes Errors after Errors afterTcreateforheap found ant stage FCM
0.12 4.54 22.52 21.26
0.135 2.62 40.64 25.36
0.15 2.22 49.7 27.3
0.16 2.56 49.84 26.22
0.18 2.16 49.96 28.04
0.20 1.78 50.12 31.58
3.4.4 Artif icial Datasets
Ten artificial datasets, each with 2 attributes, were generated using a Gaussian distribution.
The results for the datasets are shown in Tables 3.8–3.17.
For the Gauss-1, Gauss-2 and Gauss-3 datasets, over clustering and exact clustering gives us
perfect clustering, that is there are no errors. But the errors increase dramatically on under clus-
tering.
The Gauss-4 dataset, with 5 clusters has two extrema one with 0 errors and one with 211 errors.
When over clustering occurs we sometimes get 211 errors, because of this we don’t get perfect
clustering for this dataset.
The Gauss-5 dataset, with 5 clusters has 7 errors. Over clustering results in comparable errors,
but under clustering dramatically increases the errors.
For the Gauss500-1 dataset over clustering and exact clustering results in 1 error, but because
of under clustering the errors shoot up.
For the Gauss500-2 dataset we get perfect clustering if we over cluster or get an exact clustering,
but under clustering increases the errors.
For the Gauss500-3 dataset, over clustering doesn’t dramatically increase the errors, but under
clustering does. Also, we don’t get perfect clustering for this dataset.
For the Gauss500-4 and Gauss500-5 datasets we get perfect clustering if we over cluster or get
an exact clustering, but because of under clustering the errors shoot up.
26
Table 3.8. Results for the Gauss-1 Dataset
Classes Errors after Errors afterTcreateforheap found ant stage FCM
0.19 8.26 130.26 0
0.22 7.44 181.14 9.5
0.235 6.56 268.16 2.64
0.25 5.84 348.58 25.34
Table 3.9. Results for the Gauss-2 Dataset
Classes Errors after Errors afterTcreateforheap
found ant stage FCM
0.19 9.76 27.08 0
0.225 7.96 136.92 0
0.25 6.96 212.68 5.28
0.28 5.86 369.68 15.84
0.295 4.60 492.08 118.14
0.30 4.48 560.24 136.08
Table 3.10. Results for the Gauss-3 Dataset
Classes Errors after Errors afterTcreateforheap found ant stage FCM
0.25 7.44 191.9 0
0.265 6.56 276.18 13.2
0.28 5.66 380.96 46.98
Table 3.11. Results for the Gauss-4 Dataset
Classes Errors after Errors afterTcreateforheap
found ant stage FCM
0.19 6.32 318.3 32.18
0.225 6.1 327.08 40.62
0.25 6.42 328.04 27.96
0.27 6.24 327.42 33.76
0.28 5.86 327.96 37.98
27
Table 3.12. Results for the Gauss-5 Dataset
Classes Errors after Errors afterTcreateforheap
found ant stage FCM
0.19 8.1 188.42 8.06
0.205 6.8 252.96 10.34
0.215 6.3 329.4 20.56
0.22 5.94 375.28 58.22
0.25 4.4 552 119.84
Table 3.13. Results for the Gauss500-1 Dataset
Classes Errors after Errors afterTcreateforheap found ant stage FCM
0.185 5.7 54.3 13.04
0.19 5.68 63.28 8.56
0.20 5 79.38 25
Table 3.14. Results for the Gauss500-2 Dataset
Classes Errors after Errors afterTcreateforheap
found ant stage FCM
0.17 6.1 9.76 0
0.19 5.64 37.36 7.6
0.21 5.04 75.68 30.4
Table 3.15. Results for the Gauss500-3 Dataset
Classes Errors after Errors afterTcreateforheap
found ant stage FCM
0.155 5.96 17.98 3.82
0.17 5.42 50.48 12.92
0.185 5.10 72.22 20.46
0.19 5.02 72.9 21.96
28
Table 3.16. Results for the Gauss500-4 Dataset
Classes Errors after Errors afterTcreateforheap found ant stage FCM
0.19 6.36 1.48 0
0.195 6.34 3.62 0
0.22 5.18 62.3 32.14
0.25 4.02 153.18 90.8
0.28 3.94 175.16 97.3
Table 3.17. Results for the Gauss500-5 Dataset
Classes Errors after Errors afterTcreateforheap
found ant stage FCM
0.19 5.86 11.84 3.04
0.195 5.78 20.96 6.08
0.20 5.96 23.32 4.56
3.5 Effect of Parameter Variation
The above results show the sensitivity of the algorithm to the Tcreateforheap parameter. The
algorithm is not very sensitive to the other parameters. We show the results for the sensitivity of
the algorithm to the number of iterations in Tables 3.18 – 3.19.
For the Iris dataset, the number of clusters found increases for two values of Tcreateforheap and
decreases for one value of Tcreateforheap. The number of clusters differ because the ants get more
time to move and create new heaps or dump objects to existing heaps in the first stage, and merge
heaps in the second stage. For the Wine dataset the number of clusters found decreases for all the
different values of Tcreateforheap .
3.6 Variations in the Algorithm
The merging and creation of new heaps depend on the number of neighbors of the ant. If the
number of neighbors increases then the ant has a higher probability of finding a heap among its
neighbors. If we consider a 3D board, instead of a 2D board, the number of neighbors increases
from 8 to 26, this gives the ant a higher probability of finding a heap.
29
Table 3.18. Effect of Variation of Iterations on Iris Dataset
Classes Errors after Errors afterTcreateforheap Iterations
found ant stage FCM
0.10 1000 5.12 25.56 15.16
0.10 2000 5.14 26.10 14.26
0.10 3000 5.30 26.56 13.68
0.12 1000 3.74 36.34 19.42
0.12 2000 3.64 35.76 17.68
0.12 3000 3.78 36.50 18.50
0.14 1000 2.76 45.92 29.42
0.14 2000 2.82 46.54 33.36
0.14 3000 2.92 45.14 27.76
0.18 1000 2.18 49.76 43.88
0.18 2000 2.12 49.90 46.24
0.18 3000 2.10 49.92 46.92
Table 3.19. Effect of Variation of Iterations on Wine Dataset
Classes Errors after Errors afterTcreateforheap Iterations
found ant stage FCM
0.085 1000 4.46 13.94 9.36
0.085 2000 4.38 13.88 9.52
0.085 3000 4.22 14.88 9.38
0.09 1000 3.9 14.3 9.02
0.09 2000 3.8 15.48 10.32
0.09 3000 3.54 15.84 8.86
0.10 1000 3.76 23.08 10.04
0.10 2000 3.56 25.52 11.52
0.10 3000 3.46 26.76 10.16
We tried two approaches for the 3D board, in the first approach, we considered a 3D board with
z=3, that is the 3D board can be considered as three separate 2D boards. The ants can move from
one 2D board to the other. In the second approach, all the three dimensions are equal. A point to
be noted is that as the z-dimension increases, the size of the corresponding 2D board decreases.
The results are shown in Tables 3.20 – 3.29. The values of all the parameters, except the board
dimension, are the same as the original 2D board. For all the datasets, except Iris (2 class), the
30
number of clusters found by using the 3D board is less than that found by using the 2D board.
This is to be expected, because as the dimension increases, the number of neighbors increase, which
in turn increases the probability of finding a heap. For the Gauss500 datasets, except Gauss500-3
dataset, the 3D board based algorithm always finds perfect clustering, which was not possible with
the 2D board.
For 5 out of the 10 datasets, the 3D board with z=3 found fewer clusters than the 3D board
with equal dimensions. For the remaining 5 datasets, most of the time the the 3D board with z=3
found fewer clusters. For the Gauss500-3 and the Gauss500-5 datasets the 3D board with equal
dimensions found fewer clusters than the 3D board with z=3.
Table 3.20. Results for the Iris Dataset (3D Board)
Board Classes Errors after Errors after
typeTcreateforheap
found ant stage FCM
2D 0.12 3.74 36.34 19.42
3D(z=3) 0.12 3.38 36.38 22.56
3D(x=y=z) 0.12 3.46 36.92 20.4
2D 0.14 2.76 45.92 29.42
3D(z=3) 0.14 2.72 45.78 30
3D(x=y=z) 0.14 2.72 46.92 30.08
3D(z=3) 0.13 2.84 43.14 31.32
3D(x=y=z) 0.13 3.06 43.16 25.28
Table 3.21. Results for the Iris Dataset (2 Class) (3D Board)
Board Classes Errors after Errors after
typeTcreateforheap found ant stage FCM
2D 0.12 3.74 0 0.18
3D(z=3) 0.12 3.38 0 0.42
3D(x=y=z) 0.12 3.46 0 0.24
2D 0.18 2.14 1.16 2.58
3D(z=3) 0.18 2.06 0.74 2.82
3D(x=y=z) 0.18 2.1 0.7 2.7
2D 0.2 2.02 3.74 2.94
3D(z=3) 0.2 2.02 4.44 3.82
3D(x=y=z) 0.2 2.12 3.78 2.64
31
Table 3.22. Results for the Wine Dataset (3D Board)
Board Classes Errors after Errors after
typeTcreateforheap
found ant stage FCM
2D 0.085 4.46 13.94 9.36
3D(z=3) 0.085 3.68 14.26 8.78
3D(x=y=z) 0.085 3.8 16.00 8.76
2D 0.09 3.9 14.30 9.02
3D(z=3) 0.09 3.2 15.26 8.86
3D(x=y=z) 0.09 3.24 16.44 8.76
2D 0.1 3.76 23.08 10.04
3D(z=3) 0.1 3.16 25.02 12.58
3D(x=y=z) 0.1 3.12 26.66 10.12
Table 3.23. Results for the Glass Dataset (3D Board)
Board Classes Errors after Errors after
typeTcreateforheap
found ant stage FCM
2D 0.075 9.36 102.38 88.2
3D(z=3) 0.075 8.7 104.22 90.98
3D(x=y=z) 0.075 8.92 103.82 89.58
2D 0.08 8.08 103.76 93.34
3D(z=3) 0.085 6.42 106.46 95.36
3D(x=y=z) 0.085 6.44 106.44 95.74
2D 0.105 5.04 111.52 99.72
3D(z=3) 0.105 3.9 112.6 107.42
3D(x=y=z) 0.105 3.96 112.56 107.12
32
Table 3.24. Results for the Glass (2 Class) Dataset (3D Board)
Board Classes Errors after Errors after
typeTcreateforheap
found ant stage FCM
2D 0.12 4.54 22.52 21.26
3D(z=3) 0.13 2.92 33.7 23.36
3D(x=y=z) 0.13 2.84 32.56 23.46
3D(z=3) 0.135 2.48 40.36 23.74
3D(x=y=z) 0.135 2.6 38.36 24.22
3D(z=3) 0.14 2.1 47.3 28.96
3D(x=y=z) 0.14 2.26 46.14 29.22
2D 0.15 2.22 49.7 27.3
3D(z=3) 0.15 1.64 50.5 33.76
3D(x=y=z) 0.15 1.86 50.28 31.7
2D 0.16 2.56 49.84 26.22
3D(z=3) 0.16 1.56 50.86 35
3D(x=y=z) 0.16 1.84 50.42 32.32
2D 0.18 2.16 49.96 28.04
3D(z=3) 0.18 1.24 50.88 44.92
3D(x=y=z) 0.18 1.3 50.62 44.42
33
Table 3.25. Results for the Gauss500-1 Dataset (3D Board)
Board Classes Errors after Errors after
typeTcreateforheap
found ant stage FCM
3D(z=3) 0.17 4.98 26.76 2.5
3D(x=y=z) 0.17 5 23.66 1
3D(z=3) 0.175 4.94 31.24 5.5
3D(x=y=z) 0.175 4.98 30.72 4
3D(z=3) 0.18 4.8 43.18 16
3D(x=y=z) 0.18 4.9 39.44 8.5
2D 0.185 5.7 54.3 13.04
3D(z=3) 0.185 4.66 51.92 28
3D(x=y=z) 0.185 4.86 45 11.5
2D 0.19 5.68 63.28 8.56
3D(z=3) 0.19 4.62 59.42 29.5
3D(x=y=z) 0.19 4.64 56.52 28
2D 0.2 5 79.38 25
3D(z=3) 0.2 4.26 76.94 56.5
3D(x=y=z) 0.2 4.24 77.84 58
Table 3.26. Results for the Gauss500-2 Dataset (3D Board)
Board Classes Errors after Errors after
typeTcreateforheap
found ant stage FCM
2D 0.17 6.1 9.76 0
3D(z=3) 0.17 5 9.58 0
3D(x=y=z) 0.17 5 8.18 0
2D 0.19 5.64 37.36 7.6
3D(z=3) 0.19 4.7 37.42 22.8
3D(x=y=z) 0.19 4.76 35.44 19.76
2D 0.21 5.04 75.68 30.4
3D(z=3) 0.21 4.1 74.72 70.36
3D(x=y=z) 0.21 4.18 74.46 63.84
34
Table 3.27. Results for the Gauss500-3 Dataset (3D Board)
Board Classes Errors after Errors after
typeTcreateforheap
found ant stage FCM
3D(z=3) 0.155 4.92 15.98 7
3D(x=y=z) 0.155 4.92 16.5 7
3D(z=3) 0.16 4.84 23.88 13
3D(x=y=z) 0.16 4.8 27.1 16
3D(z=3) 0.165 4.66 32.62 26.5
3D(x=y=z) 0.165 4.58 40.12 32.5
2D 0.17 5.42 50.48 12.92
3D(z=3) 0.17 4.48 46.08 40
3D(x=y=z) 0.17 4.48 48.9 40
2D 0.185 5.1 72.22 20.46
3D(z=3) 0.185 4.08 73.2 70
3D(x=y=z) 0.185 4.06 73.22 71.5
2D 0.19 5.02 72.9 21.96
3D(z=3) 0.19 4 76.08 76
3D(x=y=z) 0.19 4.06 75.82 71.5
Table 3.28. Results for the Gauss500-4 Dataset (3D Board)
Board Classes Errors after Errors after
typeTcreateforheap
found ant stage FCM
2D 0.195 6.34 3.62 0
3D(z=3) 0.195 5 4.1 0
3D(x=y=z) 0.195 5 3.66 0
2D 0.22 5.18 62.3 32.14
3D(z=3) 0.22 4.38 66.74 59.72
3D(x=y=z) 0.22 4.62 42.44 36.02
3D(z=3) 0.235 3.8 116.28 110.52
3D(x=y=z) 0.235 4 101.72 94.48
2D 0.25 4.02 153.18 90.8
35
Table 3.29. Results for the Gauss500-5 Dataset (3D Board)
Board Classes Errors after Errors after
typeTcreateforheap
found ant stage FCM
3D(z=3) 0.18 5.02 2.4 0
3D(x=y=z) 0.18 5 4.32 0
3D(z=3) 0.185 4.98 6.6 3.04
3D(x=y=z) 0.185 4.98 7.3 1.52
2D 0.19 5.86 11.84 3.04
3D(z=3) 0.19 4.96 10.46 4.56
3D(x=y=z) 0.19 4.92 11.88 7.6
2D 0.195 5.78 20.96 6.08
2D 0.2 5.96 23.32 4.56
3D(z=3) 0.2 4.7 29.64 22.8
3D(x=y=z) 0.2 4.78 23.84 16.72
3D(z=3) 0.215 4.1 79.3 70.5
3D(x=y=z) 0.215 4.1 85.08 70.5
3.7 Discussion
The use of ants for the clustering process is one way to determine the number of clusters.
However, the ants are clearly sensitive to the threshold for deciding when to merge heaps. The
original work in this area provided values, but no justification or way to set them. We have
explored a range of values (albeit for one parameter) and shown how the results differ. We have
not yet found a systematic way to set the values of the parameters. The final partition found with
3 classes for the Iris dataset is always equivalent to what we get with FCM.
Essentially, the ants are finding the number of clusters and an initialization for FCM. They
are not really producing a final partition. A difficulty with taking what they produce as a final
partition is that nothing can be removed from a heap when heaps are being combined. This can be
problematic.
For comparison purposes, Table 3.30 shows the number of times a partition of each class size
was found for particular setting of parameters for the wine data set. It can be seen that the second
application of FCM usually, but not always improves the partition.
36
The results for the Iris dataset, when considered as a two cluster dataset, were better than the
randomly initialized FCM algorithm because sometimes over clustering occurs and we get perfect
clustering. Also the ants find a better partition than FCM, because the ants are able to split off
the linearly separable clusters.
Also, we found that the clustering was highly sensitive to Tcreateforheap . Tcreateforheap clearly
has a strong influence on how many final clusters are obtained.
In [4], a simpler approach than the one we discuss is used to cluster documents. The authors
utilize k-means after the ants find the initial cluster centers and find the number of centers. It
was startling to us that, over 10 runs, the ants find on average a non-fractional number of cluster
centers. Utilizing the ant based initialization, the accuracy of the final cluster partition was better
than just using K-means. They indicated that their implementation of k-means was sensitive to
the order of data, which suggests a nonstandard implementation.
Another avenue we have pursued is to allow the ants to relocate clusters centroids in features
space. The formulation is the same at a very high-level as was done in [14], but ants are utilized
rather than a genetic approach.
Table 3.30. Typical Example of Variance in Data Partitions Obtained with the Wine Dataset withTcreateforheap = 0.09 and 3000 Iterations
Clusters Errors after Errors after
FoundFrequency
Ant stage FCM
3 13 8.9230 9.00
4 18 14.6111 8.00
5 15 17.3333 11.00
6 3 24.00 11.00
7 1 33.00 10.00
37
CHAPTER 4
AUTOMATICALLY SETTING THE PARAMETERS
The ant algorithm is very sensitive to the threshold for deciding when to merge heaps and
remove the items from the heap. Results from the previous chapter show the sensitivity of the
algorithm to the Tcreateforheap parameter. The algorithm is less sensitive to the other parameters.
4.1 New Metric for Merging Heaps
We tried different approaches to automatically set the Tcreateforheap parameter.
The original approach for merging heaps is
If the distance between the centroid of the heap carried by the ant and the centroid of the heap on
the board is less than a constant Tcreateforheap then the heaps are merged.
Ants drop a heap H1 onto another heap H2 provided that:
D (Ocenter(H1), Ocenter(H2))Dmax
< Tcreateforheap
The drawback of this metric is that there is no heuristic to set the value of Tcreateforheap, the
value is determined empirically.
The new metric for merging heaps is
If the distance between the centroid of the heap carried and the centroid of the heap on the board is
less than a f ixed percent of the mean distance of all the objects in the heap from the center of the
heap on the board then the heaps are merged.
Ants merge a heap H1 onto another heap H2 provided that:
D (Ocenter(H1), Ocenter(H2)) < percent × Dmean(H2)
The aim is to get a percentage value which is uniform across all the data sets.
4.2 Results Using the New Metric
The new metric was applied to the Iris plant dataset and the Wine recognition dataset. The
results are shown in Tables 4.1 and 4.2. The results are encouraging on individual datasets but
38
the same percentage value doesn’t work across the datasets. For the Iris dataset, 2.40 is the best
percentage value. But for the wine dataset the value of 2.40 is too high, it results in only one cluster.
The value of 1.25 is the best for the wine dataset.
Table 4.1. Results from the New Metric for Iris Dataset
Classes Errors after Errors afterPercent Iterations
found Ant Stage FCM
2.25 1000 4.18 47.16 21.14
2.30 1000 3.72 47.02 22.08
2.35 1000 3.56 47.64 21.68
2.40 1000 3.28 49.22 25.12
2.45 1000 2.88 49.70 29.90
Table 4.2. Results from the New Metric for Wine Dataset
Classes Errors after Errors afterPercent Iterations
found Ant Stage FCM
2.40 1000 1 107 107
2.00 1000 1 107 107
1.25 1000 3.44 31.18 22.06
1.00 1000 4.62 13.12 9.42
The effect of varying the number of iterations, using the new metric, is shown in Tables 4.3 and
4.4. For both the Iris and Wine datasets as the number of iterations increase, the clusters found
decrease. This is to be expected, because as the number of iterations increase the ants get more
time to search the board and merge the heaps.
39
Table 4.3. Effect of Variation of Iterations on Iris Dataset
Classes Errors after Errors afterPercent Iterations
found Ant Stage FCM
2.25 1000 4.18 47.16 21.14
2.25 4000 3.48 48.94 21.60
2.30 1000 3.72 47.02 22.08
2.30 4000 3.22 49.16 23.42
2.35 1000 3.56 47.64 21.68
2.35 4000 3.12 49.28 28.20
2.40 1000 3.28 49.22 25.12
2.40 3000 2.90 49.52 29.36
2.40 4000 2.94 49.40 29.40
2.45 1000 2.88 49.70 29.90
2.45 4000 2.60 51.00 33.42
Table 4.4. Effect of Variation of Iterations on Wine Dataset
Classes Errors after Errors afterPercent Iterations
found Ant Stage FCM
2.45 1000 1.00 107.00 107
2.45 3000 1.00 107.00 107
2.00 1000 1.00 107.00 107
2.00 3000 1.00 107.00 107
1.25 1000 3.44 31.18 22.06
1.25 3000 3.04 37.24 28.28
1.00 1000 4.62 13.12 9.42
1.00 3000 4.32 14.40 9.26
4.3 Fuzzy Hypervolume
Traditional algorithms for determining the number and structure of clusters incorporate some
form of Partition Entropy [9, 13, 25, 32, 21, 22, 24, 33]. The membership matrix U is used to
compute the entropy of the partition. The membership of the object in cluster uij is interpreted
as the probability for the object j to be in cluster i [25]. The number of clusters is varied and the
40
partition entropy is computed. The optimum number of clusters is the one corresponding to the
minimum partition entropy.
In [12] the authors have used the Fuzzy Hypervolume and density criteria to find the number of
clusters. The exponential distance measure, d2e (Xj ,Vi), based on the maximum likelihood estima-
tion is used. The exponential distance is used in calculation of the posterior probability of selecting
the ith cluster given the jth feature vector h(i |Xj ).
h(i|Xj) =1
d2e(Xj ,Vi)∑K
k=11
d2e(Xj ,Vk)
(4.1)
d2e(Xj , Vi) =
[det(Fi)]12
Piexp
[(Xj − Vi)T F−1
i (Xj − Vi)2
](4.2)
where
• Fi: Fuzzy covariance matrix of the ith cluster
• Pi:a prior probability of selecting the ith cluster
The fuzzy covariance matrix of the ith cluster is computed as:
Fi =
∑Nj=1 h(i|Xj)(Xj − Vi)(Xj − Vi)T∑N
j=1 h(i|Xj)(4.3)
The Fuzzy Hypervolume is defined as:
FHV =K∑
i=1
[det(Fi)]12 (4.4)
The fuzzy hypervolume of the datasets, assuming uniform prior probabilities, was computed to
find a basis of setting the Tcreateforheap parameter. The hypothesis is that there is a correlation
between Tcreateforheap and the fuzzy hypervolume. Tcreateforheap could be modeled as a function
of the hypervolume and could be automatically set at run time. The fuzzy hypervolume for the
datasets with the best value found for Tcreateforheap is shown in Table 4.5.
41
Table 4.5. Tcreateforheap and Fuzzy Hypervolume
Dataset Tcreateforheap Fuzzy Hypervolume Fuzzy Hypervolume(log)
Iris 0.12 3.5186E-04 -3.453633681
Wine 0.09 1.5980E-11 -10.79641912
Glass 0.085 5.7413E-10 -9.240991303
Gauss-1 0.235 9.4408E-02 -1.024993149
Gauss-2 0.25 1.0947E-01 -0.960688101
Gauss-3 0.265 1.0682E-01 0.971361128
Gauss-4 0.25 1.0775E-01 -0.967596587
Gauss-5 0.21 7.1804E-02 -1.143849094
Gauss500-1 0.2 7.8007E-02 -1.107865773
Gauss500-2 0.19 9.0652E-02 -1.0426242
Gauss500-3 0.185 8.5193E-02 -1.069593575
Gauss500-4 0.195 8.6286E-02 -1.064060967
Gauss500-5 0.195 7.9956E-02 -1.097149734
The plots of Tcreateforheap vs Fuzzy Hypervolume and Tcreateforheap vs Fuzzy Hypervolume
(log) are shown in Figure 4.1 and 4.2. From the above results we can conclude that the two
parameters are not correlated.
0.08 0.1 0.12 0.14 0.16 0.18 0.2 0.22 0.24 0.26 0.280
0.02
0.04
0.06
0.08
0.1
0.12
Tcreateforheap
Fuz
zy H
yper
volu
me
Figure 4.1. Tcreateforheap vs Fuzzy Hypervolume
42
0.08 0.1 0.12 0.14 0.16 0.18 0.2 0.22 0.24 0.26 0.28−12
−10
−8
−6
−4
−2
0
Tcreateforheap
Fuz
zy H
yper
volu
me
(log)
Figure 4.2. Tcreateforheap vs Fuzzy Hypervolume (Log)
43
CHAPTER 5
FUZZY ANT CLUSTERING WITH CENTROIDS
5.1 Introduction
Previous ant based clustering algorithms cluster data by moving the objects in a 2D space and
merging them to form clusters. Similar objects tend to merge together to form heaps. This merging
is controlled by a threshold which dictates the permissible dissimilarity between the objects in a
cluster. The ant based clustering algorithms are very sensitive to this threshold [19]. The algorithm
presented in Chapter 3 finds the number of cluster centers and good initial cluster centers for the
Fuzzy C Means algorithm. The algorithm is very sensitive to the Tcreateforheap parameter.
In the proposed algorithm the stochastic property of ants was simulated to obtain good cluster
centers. The ants move randomly in the feature space carrying a feature of a cluster center with
them. After a fixed number of iterations the cluster centers are evaluated using the reformulation
of FCM which leaves out the membership matrix [15]. After the ant stage the best cluster centers
obtained are used as the initial cluster centers for the Fuzzy C Means and Hard C Means algorithms.
5.2 Reformulation of Clustering Criteria for FCM and HCM
In [15] the authors have proposed a reformulation of the optimization criteria used in a couple
of common clustering objective functions. The original clustering functions minimize the objective
function 5.1 to find good clusters.
Jm(U, β) =c∑
i=1
n∑k=1
Umik Dik(xk, βi) (5.1)
where
• c≥ 2: Number of clusters
• n: Number of data points
• βi: The ith cluster prototype
• Dik(xk, βi): Distance of xk from ith cluster center
44
• Uik: Membership of the kth object in the ith cluster
• m ≥ 1: The degree of fuzzification
The reformulation replaces the membership matrix U with the necessary conditions which are
satisfied by U. The reformulated version of Jm is denoted as Rm.
For the Hard clustering case the U optimization is over a crisp membership matrix. The
necessary condition for U is given in equation 5.2. Equation 5.3 gives the the necessary conditions
for U, for the fuzzy case. The distance Dik(xk, βi) is denoted as Dik.
Uik = 0 if Dik > min (D1k, D2k, D3k, · · · , Dck)
= 1 otherwise (5.2)
Uik =
(D
11−m
ik
)(∑c
j=1 D1
1−m
jk
) (5.3)
The reformulations for hard and fuzzy optimization functions are given in equations 5.4 and
5.5 respectively. The function R depends only on the cluster prototype and not on the U ma-
trix, whereas J depends on both the cluster prototype and the U matrix. The U matrix for the
reformulated criterion can be easily computed using equation 5.2 or 5.3.
R1(β) =n∑
k=1
min (D1k, D2k, · · · , Dck) (5.4)
Rm(β) =n∑
k=1
(c∑
i=1
D1
1−m
ik
)1−m
(5.5)
5.3 Algorithm
The ants co-ordinate to move cluster centers in feature space to search for optimal cluster centers.
Initially the feature values are normalized between 0 and 1. Each ant is assigned to a particular
feature of a cluster in a partition. The ants never change the feature, cluster or partition assigned
to them. A pictorial view is given in Figure 5.1 where each vertical line is a dimension in parallel
coordinates [17, 2]. After randomly moving the cluster centers for a fixed number of iterations,
45
called an epoch, the quality of the partition is evaluated by using the reformulated criterion 5.4
or 5.5. If the current partition is better than any of the previous partitions’ in the ant’s memory
then the ant remembers this partition else the ant, with a given probability goes back to a better
partition or continues from the current partition. This ensures that the ants do not remember a
bad partition and erase a previously known good partition. Even if the ants change good cluster
centers to unreasonable cluster centers, the ants can go back to the good cluster centers as the ants
have a finite memory in which they keep the currently best known cluster centers. There are two
directions for the random movement of the ant. The positive direction is when the ant is moving in
the feature space from 0 to 1, and the negative direction is when the ant is moving in the feature
space from 1 to 0. If during the random movement the ant reaches the end of the feature space the
ant reverses direction. After a fixed number of epochs the ants stop.
The data is partitioned using the centroids obtained from the best known Rm value. The nearest
neighbor algorithm is used for assignment to a cluster. The cluster centers so obtained are then
used as the initial cluster centers for the Fuzzy C Means or the Hard C Means algorithm. The ant
based algorithm is presented in Figure 5.2.
46
Figure 5.1. Pictorial View of the Algorithm
47
1. Normalize the feature values between 0 and 1. The normalization is linear. The minimum
value of a particular feature is mapped to 0 and the maximum value of the feature is
mapped to 1.
2. Initialize the ants with random initial values and with random direction. There are two
directions, positive and negative. The positive direction means the ant is moving in the
feature space from 0 to 1. The negative direction means the ant is moving in the feature
space from 1 to 0. Clear the initial memory. The ants are initially assigned to a particular
feature within a particular cluster of a particular partition. The ants never change the
feature, cluster or the partition assigned to them.
3. Repeat
3.1 For one epoch /* One epoch is n iterations of random ant movement */
3.1.1 For all ants
3.1.1.1 With a probability Prest the ant rests for this epoch
3.1.1.2 If the ant is not resting then with a probability Pcontinue the ant continues
in the same direction, else it changes direction
3.1.1.3 With a value between Dmin and Dmax the ant moves in the selected direction
3.2 The new Rm value is calculated using the new cluster centers
3.2.1 If the partition is better than any of the old partitions in memory then the worst
partition is removed from the memory and this new partition is copied to the
memories of the ants making up the partition
3.2.2 If the partition is not better than any of the old partitions in memory
Then
With a probability PContinueCurrent the ant continues with the current partition
Else
With a probability 0.6 the ant chooses to go back to the best known partition,
with a probability 0.2 the ant goes back to the second best known partition,
with a probability 0.1 the ant goes to the third best known partition, with a
probability 0.075 the ant goes to the fourth best known partition and with a
probability 0.025 the ant goes to the worst known partition
Until Stopping criteria
The stopping criterion is the number of epochs.
Figure 5.2. Fuzzy Ant Clustering with Centroids Algorithm
48
The values of the parameters used in the algorithm are shown in Table 5.1.
Table 5.1. Parameter Values
Parameter Value
Number of ants 30 Partitions 1
Memory per ant 5
Iterations per epoch 50
Epochs 1000
Prest 0.01
Pcontinue 0.75
PContinueCurrent 0.20
Dmin 0.001
Dmax 0.01
5.4 Results
The algorithm was applied to six real datasets and ten artificial datasets: the Iris Plant dataset,
Glass Identification dataset, Wine Recognition dataset, MRI dataset, Multiple Sclerosis dataset,
the British Towns dataset and the 10 Gaussian datasets.
The results obtained for the datasets are shown in Table 5.2. All results are an average from 50
random initializations. The results for the FCM and HCM are the average results from 50 random
initializations. The glass dataset has been simplified to have just 2 classes window glass and non-
window glass. The results for this modified dataset are also shown in Table 5.2. The age factor
plays an important role in the Multiple Sclerosis dataset; the results considering the age feature
and ignoring the age feature are also shown. Note, the Rm value is always less than or equal to that
from randomly initialized FCM except for Glass (6 classes).Thirteen datasets have a single extrema
for the FCM algorithm. They converge to the same extrema, for all initializations tried here. This
is reflected in Table 5.2 where we have the same values in columns 3 and 4 for the thirteen datasets.
The parameters Number of epochs, Dmin and Dmax play an important role in determining
the quality of the clusters found. By performing manual search, new parameters, which gave
better results, were found. The values of the new parameters are shown in Table 5.3 and the
results obtained by using these modified parameters are shown in Table 5.4. Clear improvements
were observed for 3 datasets. For the British Towns dataset the average value for Rm after FCM11 partition = number of clusters × number of features per cluster
49
Table 5.2. Results for Fuzzy C Means
Min Rm Rm from FCM, Rm from FCM,Dataset
found by Ants Ant Initialization Random Initialization
British Towns 1.6828 1.6033 1.6039
Iris 5.4271 5.2330 5.2330
Wine 33.0834 28.7158 28.7158
Glass (6 classes) 11.3827 7.2937 7.2917
Glass (2 classes) 25.8531 24.3932 24.3932
Multiple Sclerosis (with age) 6.9456 6.8538 6.8538
Multiple Sclerosis (ignoring age) 3.5704 3.5319 3.5319
MRI 311.2397 302.1302 303.289
Gauss-1 6.1588 5.5481 5.5481
Gauss-2 4.6786 4.0646 4.0646
Gauss-3 4.8764 4.2120 4.2120
Gauss-4 2.5536 1.9156 2.7458
Gauss-5 8.6553 8.2035 8.2035
Gauss500-1 4.4866 4.2559 4.2559
Gauss500-2 3.6328 3.3681 3.3681
Gauss500-3 2.3564 2.0560 2.0560
Gauss500-4 1.9937 1.6880 1.7834
Gauss500-5 1.9031 1.5848 1.5848
decreased to 1.5999 from 1.6033, similarly for the Glass (6 classes) dataset the average value for Rm
after FCM decreased to 7.2897 from 7.2937. This average value is better than that obtained from
randomly initialized FCM. The average value for Rm after FCM for the MRI dataset decreased to
301.9198 from 302.1302.
Table 5.3. New Parameters
Parameter Old Value New Value
Epochs 1000 2000
Dmin 0.001 0.0001
Dmax 0.01 0.001
50
Table 5.4. Results for FCM Obtained from Modified Parameters
Min Rm Rm from FCM, Rm from FCM,Dataset
found by Ants Ant Initialization Random Initialization
British Towns 1.6051 1.5999 1.6039
Glass (6 classes) 9.2284 7.2897 7.2917
MRI 302.1188 301.9189 303.2894
5.5 Hard C Means
The ant algorithm was applied together with the Hard C Means algorithm. The ants find the
cluster centers and these centers are used as the initial centers for the Hard C Means algorithm.
The parameter values are those shown in Table 5.1.
From Table 5.5 we see that the algorithm gives better results than randomly initialized HCM for
15 of the 18 datasets tested. Changing the parameter values can improve the results. By performing
a search in the parameter space we got parameter values that resulted in better partitions. Tables
5.6 and 5.7 show the variation in the results obtained by changing the number of ants per partition
and epochs for the British Towns’ and Wine datasets. From the tables we see that as the number
of epochs increase, the minimum Rm found by the ants decreases, this is to be expected because
as the number of epochs increase, the ants get more time to refine the centroids found. Also as
the number of ants increase, better Rm values are found. Table 5.8 shows the results obtained for
different MRI slices, the parameter values used for the MRI dataset are tabulated in Table 5.3 and
the ants per partition were 50. We can see the partitions all have lower Rm values.
51
Table 5.5. Results for Hard C Means
Min Rm Rm from HCM, Rm from HCM,Dataset
found by Ants Ant Initialization Random Initialization
British Towns 5.5202 3.6260 3.4339
Iris 7.0055 6.9981 8.2516
Wine 52.8098 50.4573 48.9792
Glass (6 classes) 28.1317 24.3770 21.1165
Glass (2 classes) 34.2488 34.1352 36.9132
Multiple Sclerosis (with age) 10.2201 10.2016 10.3548
Multiple Sclerosis (ignoring age) 4.6406 4.6381 4.7759
MRI 433.2752 432.7499 452.384
Gauss-1 7.1391 6.4856 11.0962
Gauss-2 5.1055 4.4725 11.0645
Gauss-3 5.2625 4.6624 12.7167
Gauss-4 2.7273 2.0386 12.4133
Gauss-5 11.6107 10.9422 11.9558
Gauss500-1 5.8333 5.4921 6.0718
Gauss500-2 4.3405 4.0029 7.7512
Gauss500-3 2.6558 2.3140 6.3784
Gauss500-4 2.1678 1.8465 7.3442
Gauss500-5 2.0758 1.7314 7.0953
Table 5.6. Results for the British Towns Dataset
Ants per Min Rm Rm from HCM, Rm from HCM,
partitionEpochs
found by Ants Ant Initialization Random Initialization
50 2000 5.3658 3.5812
50 4000 4.5048 3.5701
75 2000 5.1691 3.61343.4339
100 2000 3.0835 3.0661
52
Table 5.7. Results for the Wine Dataset
Ants per Min Rm Rm from HCM, Rm from HCM,
partitionEpochs
found by Ants Ant Initialization Random Initialization
50 2000 52.8003 49.2405
50 4000 51.0631 49.2604
75 2000 50.1879 49.2604
75 3000 49.9230 48.974848.9792
100 2000 49.6415 48.9716
100 4000 49.2076 48.9697
Table 5.8. Results for the MRI Dataset
Slice Min Rm Rm from HCM, Rm from HCM,
# found by Ants Ant Initialization Random Initialization
20 853.7991 851.8342 882.5732
35 919.8082 917.6636 927.6961
45 839.1622 838.0175 851.3756
46 842.5583 841.3414 847.0730
47 796.8415 795.6057 834.1028
5.6 Execution Time
The variation of the minimum Rm found by the ants by changing the ants per partition for MR
slice # 35 is shown in Table 5.9. As the number of ants increases the minimum Rm found decreases,
but at the cost of increased execution time. As the number of ants increase, more search space is
explored and we get better Rm values.
Table 5.9. Variation of Rm with the Number of Ants for Slice # 35 of MRI Dataset
Ants per Min Rm Rm from HCM, Rm from HCM,
partition found by Ants Ant Initialization Random Initialization
50 919.8082 917.6636
75 912.0365 909.9324 927.6961
100 910.0054 907.9996
53
The execution time for the British Towns and the MRI dataset is shown in Table 5.10. These
two datasets were chosen because British Towns’ dataset is the smallest (in terms of number of
examples) dataset and the MRI dataset is the largest dataset used in the study. The values are
an average from 20000 epochs and 5 experiments for the British Towns’ dataset and from 6000
epochs and 3 experiments for the MRI dataset. One experiment consists of the ant stage and the
following Fuzzy C Means or the Hard C Means stage. The time required for one epoch for the
British towns dataset was more than that for the MRI dataset as there are more classes, and hence
more ants, in the British towns dataset. The time required for the entire experiment was more
for the MRI dataset as there are more examples in the MRI dataset. The time required for the
FCM algorithm is also shown in Table 5.10. From Table 5.10 we see that, for the British Towns’
dataset, approximately 9100 random FCM initializations can be performed in the time required for
one ant experiment. Similarly approximately 225 random FCM initializations can be performed for
the MRI dataset.
We performed 11300 (≈ 225 × 50) random initalizations for the MRI dataset and averaged the
best 50 Rm values. The average Rm value was 301.9189 and the average Rm value found by ants
from 50 random initalizations was 301.9189. Similarly for the British Towns’, dataset the average
of best 50 Rm values over 20000 iterations was 1.5999 and the average Rm value found by ants,
from 50 random initalizations, was 1.5999.
The experiments were performed on an Intel Pentium 4 2.53 GHz processor with 512 KB cache
and 2 GB of main memory.
Table 5.10. Execution Time
Ants Time for Time for Time for
Dataset per one Epoch one Experiment FCM
Partition (milliseconds) (seconds) (seconds)
50 14.9645 97
British Towns 75 22.2210 108.8380 0.01318
100 29.7060 120.896
50 6.7333 540.72MRI
75 10.1117 811.01332.3929
54
5.7 Conclusions
The algorithm is based on relocating the cluster centroids in the feature space. The ants move
the cluster centers, not the objects, in feature space to find a good partition for the data. The
algorithm does not use the object merging criterion, which makes it independent of the threshold
for merging the objects. Also there are less controlling parameters than the previous ant based
clustering algorithms [19].
Results from 18 datasets show the superiority of our algorithm over the randomly initialized FCM
and HCM algorithms. For comparison purposes, Tables 5.11, 5.12 and 5.13 show the frequency of
occurrence of different extrema for the ant initialized FCM and HCM algorithms and the randomly
initialized FCM and HCM algorithms. The ant initialized FCM algorithm always finds the better
extrema for the MRI dataset and for the British Towns’ dataset the ant initialized algorithm finds
the better extrema 49 out of 50 times. The ant initialized HCM algorithm finds the better extrema
for the Iris dataset all the time and for the Glass (2 class) dataset majority of the time. For the
different MRI slices, the ant initialized HCM algorithm finds the better extrema most of the time.
In [14], a Genetic programing approach was used to optimize the clustering criteria, the genetic
approach for Hard C Means, found better extrema 64% of the time for the Iris dataset. The ant
initialized HCM finds better extrema all the time.
The number of ants per partition is an important parameter of the algorithm. The quality of
the partition improves as number of ants increase, but the improvement comes at the expense of
increased execution time. Future work should focus on automatically finding the number of ants
per partition and the number of clusters. In this direction the algorithm proposed in [19] can be
used to find the number of clusters.
Table 5.11. Frequency of Different Extrema from FCM, for British Towns and MRI Datasets
Frequency FCM, Frequency FCMDataset Extrema
Ant Initialization Random Initialization
1.5999 49 16British
1.6037 1 18Towns
1.6081 0 16
301.9195 50 37MRI
307.1898 0 13
55
Table 5.12. Frequency of Different Extrema from HCM, for Glass (2 Class) and Iris Datasets
Frequency HCM, Frequency HCMDataset Extrema
Ant Initialization Random Initialization
34.1320 19 3
34.1343 11 19Glass
34.1372 19 15(2 class)
34.1658 1 5
6.9981 50 23
7.1386 0 14Iris
10.9083 0 5
12.1437 0 8
Table 5.13. Frequency of Different Extrema from HCM, MRI Dataset
Frequency HCM, Frequency HCMSlice # Extrema
Ant Initialization Random Initialization
841.3414 50 4420
889.1043 0 6
930.1677 45 30
35 951.4871 5 15
1003.492 0 5
838.0175 50 4145
912.2289 0 9
841.3414 50 4546
889.1043 0 5
795.3043 35 27
47 796.2459 15 13
970.5483 0 10
56
CHAPTER 6
CONCLUSIONS AND FUTURE WORK
6.1 Combined Algorithm
The Fuzzy ants algorithm automatically finds the number of clusters and good initial cluster
centers. The drawback of the algorithm is the large number of controlling parameters and the
absence of good methods to set those parameters.
The Fuzzy ant clustering with centroids algorithms has less controlling parameters and less
sensitivity to the parameters. The drawback of the algorithm is it requires the initial knowledge of
the number of clusters in data. The results are generally better then with FCM/HCM. One would
need a large number of random initialization to be competitive. Also, a parallel version of the ants
algorithm could operate much faster than the current sequential implementation, thereby making
it a clear choice for minimizing the chance of finding a poor extrema.
The Fuzzy ants algorithm can be used to find the number of clusters in the data and the results
of the algorithm can be given to the Fuzzy ant clustering with centroids algorithm.
We implemented the above idea and the results are promising. Tables 6.1 and 6.2 show the
results from the combined algorithm. The analysis can be performed using two metrics: Number of
errors and minimum Rm . For comparison, the results from randomly initialized FCM algorithm,
with known number of clusters, are also given.
In the second ant stage the ants optimize the Rm criteria, this can be observed in Table 6.1 .
The Rm value for the Iris dataset after the 1st stage FCM is 4.5220 and after the final FCM stage
the value is 4.4738. But the minimum Rm value sometimes doesn’t correspond to the minimum
errors, this is observed in the Iris dataset, the errors after FCM 1st stage are 15.92 and those after
the final FCM stage are 18.52.
57
Table 6.1. Results from the Combined Algorithm
Classes Rm after Rm found by Rm from Rm fromDataset
found FCM 1ststage Ants (2nd stage) FCM (final) FCM (random)
Iris 3.64 4.5220 4.7658 4.4738 5.2330
Wine 4.46 20.5878 22.9632 20.5878 28.7158
Glass 5.5 8.4098 9.9975 8.4098 7.2917
British Towns 6.74 1.1452 1.2429 1.1453 1.6039
Multiple Sclerosis 2.76 4.6844 4.8632 4.6844 6.8538
Gauss-1 5.84 6.2395 6.6336 6.1234 5.5481
Gauss-2 5.86 4.4591 5.1016 4.3724 4.0646
Gauss-3 6.34 4.1108 4.7385 4.1313 4.2120
Gauss-4 6.16 2.0323 2.7307 2.0462 2.7458
Gauss-5 6.30 7.1248 7.5398 7.0827 8.2035
Gauss500-1 5.68 4.0874 4.2854 4.0554 4.2559
Gauss500-2 5.64 3.3677 3.7338 3.3395 3.3681
Gauss500-3 5.02 2.6648 2.8838 2.6754 2.05560
Gauss500-4 5.18 2.7631 3.0501 2.7611 1.7834
Gauss500-5 5.78 1.6849 1.9576 1.6513 1.5848
Table 6.2. Results from the Combined Algorithm (Errors)
Classes Errors after Errors after Errors after Errors afterDataset
found Ants 1ststage FCM (1st stage) FCM (final) FCM (Random)
Iris 3.64 35.76 15.92 18.52 16
Wine 4.46 13.94 9.36 9.36 9
Glass 5.5 109.8 98.02 98.02 96
Multiple Sclerosis 2.76 20.86 17.86 17.86 17
Gauss-1 5.84 348.58 25.34 29.08 0
Gauss-2 5.86 369.68 15.84 15.84 0
Gauss-3 6.34 318.44 10.56 18.24 0
Gauss-4 6.16 328.98 7.92 7.92 25.32
Gauss-5 6.30 329.40 19.64 20.12 7
Gauss500-1 5.68 63.28 8.5 16.22 1
Gauss500-2 5.64 37.36 7.6 11.48 0
Gauss500-3 5.02 72.9 19 18.98 1
Gauss500-4 5.18 62.3 22.12 29.88 1.94
Gauss500-5 5.78 20.96 6.08 6.08 0
58
6.2 Contributions
The Fuzzy Ants algorithm is a novel method to find the number of clusters in the data and
also provides good initializations for the FCM and HCM algorithms. We performed sensitivity
analysis on the controlling parameters and found the Fuzzy Ants algorithm to be very sensitive to
the Tcreateforheap parameter.
The Fuzzy ant clustering with centroids algorithms has less controlling parameters and less
sensitivity to the parameters. The drawback of the algorithm is it requires the initial knowledge of
the number of clusters in data. The results are generally better then with FCM/HCM. One would
need a large number of random initialization to be competitive. Also, a parallel version of the ants
algorithm could operate much faster than the current sequential implementation, thereby making it
a clear choice for minimizing the chance of finding a poor extrema. The combined algorithm finds
the number of clusters in data and good partition for the data.
6.3 Future Work
The future work should focus on setting the Tcreateforheap parameter automatically. The algo-
rithm is very sensitive to this parameter. We have tried a couple of approaches to set the parameter
automatically, but the results were not encouraging.
In the Fuzzy ant clustering with centroids algorithm, the number of ants is an important pa-
rameter, and also the initial number of clusters in the data is required. Future work should focus
on setting these values automatically. We compare the results from the algorithms with randomly
initialized FCM and HCM. In future the results can be compared with cleverly initialized FCM
and HCM algorithms. The initial placement of the ants is also random, future work should focus
on giving clever initializations to the ants. The stopping criteria is currently based on the number
of iterations, future work should concentrate on automatically stopping the ants based on their
progress. Trails can be used to guide the movement of the ants, future work should concentrate on
incorporating trails in the algorithm.
59
REFERENCES
[1] A. Abraham, J. R. del Solar, and M. Köppen, editors. Soft Computing Systems - Design,Management and Applications,HIS 2002, volume 87 of Frontiers in Artificial Intelligence andApplications, Santiago, Chile, Dec 2002. IOS Press.
[2] M. Berthold and L. Hall. Visualizing fuzzy points in parallel coordinates. IEEE Transactionson Fuzzy Systems, 11(3):369–374, June 2003.
[3] J. C. Bezdek. Pattern recognition with fuzzy ojective functions algorithms. Plenum press,1981.
[4] W. Bin, Z. Yi, L. Shaohui, and S. Zhongzhi. Csim: a document clustering algorithm basedon swarm intelligence. Evolutionary Computation, 2002. CEC ’02. Proceedings of the 2002Congress on, 1:477–482, May 2002.
[5] W. Bin and S. Zhongzhi. A clustering algorithm based on swarm intelligence. Info-tech andInfo-net, 2001 Proceedings. ICII 2001, 3:58–66, 2001.
[6] C. Blake and C. Merz. UCI repository of machine learning databases, 1998.
[7] E. Bonabeau, M. Dorigo, and G. Theraulaz. Swarm Intellignece From Natural to ArtificialSystems. Oxford University Press, New York, NewYork, 1999.
[8] E. Bonabeau, A. Sobkowski, G. Theraulaz, and J.-L. Deneubourg. Adaptive task alloca-tion inspired by a model of division of labor in social insects. In D. Lundh, B. Olsson, andA. Narayanan, editors, Biocomputing and Emergent Computation, pages 36–45. World Scien-tific, 1997.
[9] C.-H. Cheng. Entropy Based Subspace Clustering for Mining Numerical Data. PhD thesis,Chinese University of Hong Kong, 1999.
[10] M. Doriga, V. Maniezzo, and A. Colorni. Ant system: Optimization by a colony of cooperatingagents. IEEE Transactions on Systems, Man, and Cybernetics-Part B: Cybernetics, 26(1):29–41, Feb 1996.
[11] R. Duda and P. Hart. Pattern Classification and Scene Analysis. John Wiley and Sons, NewYork, 1973.
[12] Gath and A.B.Geva. Unsupervised optimal fuzzy clustering. IEEE Transactions on PatternAnalysis and Machine Intelligence, 11(7):773–781, Jul 1989.
[13] F. Golchin and K. Paliwal. Minimum-entropy clustering and its application to lossless imagecoding. Proc. IEEE International Conference on Image Processing, Oct 1997.
[14] L. O. Hall, I. B. Özyurt, and J. C. Bezdek. Clustering with a genetically optimized approach.IEEE Trans. on Evolutionary Computation, 3(2):103–112, 1999.
[15] R. J. Hathway and J. C. Bezdek. Optimization of clustering criteria by reformulation. IEEETransactions on Fuzzy Systems, 3(2):241–245, May 1995.
60
[16] F. Höppner, F. Klawonn, R. Kruse, and T. Runkler. Fuzzy Cluster Analysis. John Wiley, WestSussex, England, 1999.
[17] A. Inselberg. The plane with parallel coordinates. Special Issue on Computational Geometry,The Visual Computer, (1):69–97, 1985.
[18] K. Jajuga, A. Soko�lowski, and H.-H. Bock, editors. International Federation of ClassificationSocieties, number 8th in Studies in Classification, Data Analysis, and Knowledge Organization,Carcow, Poland, Jul 2002. Springer–Verlag.
[19] P. M. Kanade and L. O. Hall. Fuzzy ants as a clustering concept. North American FuzzyInformation Processing Society, NAFIPS 2003, 22nd International Conference of the, pages227–232, 2003.
[20] P. M. Kanade and L. O. Hall. Fuzzy ants clustering with centroids. accepted for publicationin FUZZ–IEEE 2004 conference, 2004.
[21] N. Karayiannis. Maximum entropy clustering algorithms and their application in image com-pression. Systems, Man, and Cybernetics, 1994. ’Humans, Information and Technology’., 1994IEEE International Conference on, 1:337–342, Oct 1994.
[22] N. Karayiannis. Meca: maximum entropy clustering algorithm. Fuzzy Systems, 1994. IEEEWorld Congress on Computational Intelligence., Proceedings of the Third IEEE Conferenceon, 1:630–635, Jun 1994.
[23] J. Kennedy and R. C. Eberhart. Swarm Intelligence. Morgan Kaufmann, San Diego, California,2001.
[24] R.-P. Li and M. Mukaidono. A maximum-entropy approach to fuzzy clustering. Fuzzy Systems,1995. International Joint Conference of the Fourth IEEE International Conference on FuzzySystems and The Second International Fuzzy Engineering Symposium., Proceedings of 1995IEEE International Conference on, 4:2227–2232, Mar 1995.
[25] A. Lorette, X. Descombes, and J. Zerubia. Fully unsupervised fuzzy clustering with entropycriterion. Pattern Recognition, 2000. Proceedings. 15th International Conference on, 3:986–989,Sep 2000.
[26] N. Monmarché, M. Slimane, and G. Venturini. Antclass: discovery of clusters in numeric databy an hybridization of an ant colony with the kmeans algorithm, Jan 1999.
[27] N. Monmarché, M. Slimane, and G. Venturini. On improving clustering in numerical databaseswith artificial ants. In D. Floreano, J. Nicoud, and F. Mondala, editors, 5th European Confer-ence on Artificial Life (ECAL’99), Lecture Notes in Artificial Intelligence, volume 1674, pages626–635, Lausanne, Switzerland, Sep 1999. Springer-Verlag.
[28] S. Ouadfel and M. Batouche. Mrf-based image segmentation using ant colony system. ElectronicLetters on Computer Vision and Image Analysis, 2(2):12–24, 2003.
[29] R. S. Parpinelli, H. S. Lopes, and A. A. Freitas. Data mining with an ant colony optimizationalgorithm. IEEE Transactions on Evolutionary Computing, 6(4):321–332, Aug 2002.
[30] V. Ramos and F. Almeida. Artificial ant colonies in digital image habitats - a mass behavioureffect study on pattern recognition. Proc. of ANTS’2000 - 2 nd Int. Workshop on Ant Algo-rithms (From Ant Colonies to Artificial Ants), pages 133–116, 2000.
[31] V. Ramos and J. J. Merelo. Self-organized stigmergic document maps: Environment as mech-anism for context learning. Procs. of AEB02 - Spanish Conference on Evolutionary and BioIn-spired Algorithms, pages 284–293, 2002.
61
[32] S. Roberts, R. Everson, and I. Rezek. Minimum entropy data partitioning. Proc. of 9thInternational Conference on Articial Neural Networks, pages 844–849, 1999.
[33] D. Tran and M. Wagner. Fuzzy entropy clustering. Fuzzy Systems, 2000. FUZZ IEEE 2000.The Ninth IEEE International Conference on, 4:152–157, May 2000.
[34] C.-F. Tsai, H.-C. Wu, and C.-W. Tsai. A new data clustering aproach for data mining in largedatabases. Parallel Architectures, Algorithms and Networks, 2002. I-SPAN ’02 Proceedings.International Symposium on, pages 278–283, 2002.
[35] G. Weiss, editor. Multiagent Systems A mordern Approach to Distributed Artificial Intelligence.MIT Press, Massachusetts, 1999.
[36] T. White, B. Pagurek, and F. Oppacher. ASGA: Improving the ant system by integrationwith genetic algorithms. In J. R. Koza, W. Banzhaf, K. Chellapilla, K. Deb, M. Dorigo, D. B.Fogel, M. H. Garzon, D. E. Goldberg, H. Iba, and R. Riolo, editors, Genetic Programming1998: Proceedings of the Third Annual Conference, pages 610–617, Madison, Wisconsin, 1998.Morgan Kaufmann.
[37] M. Wilson, C. Melhuish, and A. Sendova-Franks. Creating annular structures inspired byant colony behaviour using minimalist robots. Systems, Man and Cybernetics, 2002 IEEEInternational Conference on, 2:53–58, Oct 2002.
[38] L. Zadeh. Fuzzy sets. Information and Control, pages 338–353, 1965.
62
APPENDICES
63
Appendix A Datasets
A.1 Parameters Used to Generate the Gaussian Datasets
Table A.1. Parameters Used to Generate the Gauss Datasets
Dataset Mean Std. Dev
2 2 1 1
8 8 1 1
Gauss-1 2 16 1 1
19 3 1 1
14 14 1 1
2 2 1 1
10 10 1 1
Gauss-2 3 20 1 1
22 5 2 2
18 18 1 1
2 4 1 1
11 11 1 1
Gauss-3 5 20 1 1
22 5 2 2
20 20 1 1
3 3 1 1
11 11 1 1
Gauss-4 10 30 1 1
32 5 1 1
20 33 1 1
2 2 1 1
6 6 1 1
Gauss-5 2 10 1 1
12 4 2 2
11 11 1 1
64
Parag Kanade/fuzzy ants/Gauss2/gauss02.data
Gauss Data | |
# | |
-0.46551197 | 1.3396181 |
-0.14154019 | 1.6467355 |
-0.06147374 | 1.910021 |
-0.00960664 | 1.6959237 |
0.13522751 | 2.3371545 |
0.15816343 | 1.74101 |
0.16902868 | 1.7145902 |
0.20321506 | 1.3230994 |
0.24094079 | 1.3069846 |
0.25245225 | 2.1839526 |
0.26993324 | 2.5483323 |
0.28680391 | 1.6052432 |
0.3192367 | 2.2276855 |
0.36114833 | 2.8009784 |
0.4244067 | 1.8634449 |
0.46037797 | 1.4532789 |
0.46098959 | 2.3555875 |
0.48936047 | 1.8126198 |
0.493417 | 0.52432961 |
0.5579586 | 2.0069093 |
0.59517099 | 0.74266104 |
0.601286 | 2.447746 |
0.64249205 | 0.22137058 |
0.64603926 | 2.098612 |
0.68936857 | 2.3436606 |
0.70125847 | 1.9881431 |
0.70954162 | 1.8340884 |
0.71271143 | 1.1911658 |
0.73828501 | 2.9157625 |
0.76121259 | 2.887774 |
0.76300537 | 3.36236 |
0.78715506 | 1.7998882 |
0.79603202 | 1.3837631 |
0.81552587 | 0.7659359 |
0.81671088 | 2.0235945 |
0.83646559 | 1.7292928 |
0.84905869 | 0.90959966 |
0.87280583 | 1.9185033 |
0.93911004 | 2.2377149 |
0.94658989 | 1.8099329 |
0.95071896 | 3.3593771 |
0.95477185 | 0.82422933 |
1.0475351 | 3.7358953 |
1.0483555 | 2.6222619 |
1.0663274 | 2.0772458 |
1.0719789 | 2.3051114 |
1.0841659 | 2.8982847 |
1.0917331 | 1.4965835 |
1.1268271 | 1.7541776 |
1.1308673 | 2.1353612 |
1.1428466 | 2.0972579 |
1.1493513 | 1.8227118 |
1.1819349 | 1.8738619 |
1.1900377 | 1.5835831 |
1.2101874 | 1.8796963 |
1.2181118 | 3.0111068 |
1.2277972 | 2.0808183 |
1.2335498 | 2.9573163 |
1.2448562 | 1.6017201 |
1.2555436 | 1.9472067 |
1.2597352 | 0.95874592 |
1.2601195 | 0.81798378 |
1.2715242 | 0.46185734 |
1.2749423 | 3.2592336 |
1.2888759 | 2.4162943 |
1.319464 | 2.1180977 |
1.3266557 | 1.9249356 |
1.3269461 | 2.8783508 |
1.3458998 | 1.6047048 |
1.3471548 | 2.0660325 |
1.3753515 | 2.4089999 |
1.3793406 | 2.1089793 |
1.3872928 | 3.3455047 |
1.3979966 | 2.3829163 |
1.4001717 | 3.0482038 |
1.4054732 | 1.6215221 |
1.4312392 | 0.79191521 |
1.4354818 | 3.0271297 |
1.4410139 | 2.7986203 |
1.4641202 | 0.58155858 |
1.4646153 | 3.9791516 |
1.5055329 | 1.0990125 |
1.5286615 | 2.6943944 |
1.5534019 | 3.741445 |
1.5735908 | 1.5571016 |
1.5856639 | 0.99127551 |
1.6083411 | 2.3154722 |
1.6167515 | 3.4641362 |
1.6315791 | 2.9447703 |
1.6485825 | 1.9459715 |
1.6558902 | 1.1154736 |
1.6603318 | 2.4801616 |
1.6657018 | 1.9762646 |
1.6740867 | 2.9751515 |
1.7109312 | 1.5716093 |
1.7172934 | 1.9542265 |
1.7245997 | 2.387059 |
1.7280016 | 3.2168608 |
1.7407356 | 1.6770587 |
1.7446611 | 3.8440441 |
1.7479167 | 1.3913499 |
1.7507312 | 2.769599 |
1.7567404 | 1.4447784 |
1.7591262 | 3.9952283 |
1.7610234 | 3.5877581 |
1.7736913 | 1.4399875 |
1.7826518 | 3.1827802 |
1.7882331 | 2.7558682 |
1.8048077 | 1.4894358 |
1.806578 | 2.2980184 |
1.8105734 | 3.0728863 |
1.8132452 | 0.11900227 |
1.8581162 | 2.3816176 |
1.8735926 | 2.1120087 |
1.8771577 | 1.9606585 |
1.8791867 | 0.81713304 |
1.8866894 | 1.5761363 |
1.8881009 | 0.12698201 |
1.8980516 | 2.4640572 |
1.911659 | 0.92031474 |
1.9163593 | 2.2659011 |
1.9217044 | 1.9429349 |
1.9240625 | 1.2683148 |
1.933498 | 0.99443935 |
1.9366692 | 3.0426166 |
1.9572064 | 3.2689621 |
1.987931 | 4.1287767 |
1.9907116 | 1.6489055 |
1.9930155 | 2.6846483 |
2.0011578 | 2.3236036 |
2.0107086 | 2.1802041 |
2.0650972 | 0.62687304 |
2.0760993 | 1.8564104 |
2.076595 | 3.141211 |
2.0797088 | 2.6444816 |
2.0828643 | 2.4026682 |
2.0948837 | 1.8648059 |
2.0985622 | 3.7026465 |
2.0994979 | 4.0382142 |
2.1023642 | 3.2814187 |
2.1102441 | 3.3805769 |
2.1522589 | 1.6625872 |
2.1613626 | 2.6416719 |
2.1760954 | 0.66759943 |
2.1805424 | 2.0442384 |
2.1842685 | 2.5954692 |
2.1891405 | 2.9582391 |
2.1963915 | 2.0430046 |
2.2020264 | 2.176707 |
2.204684 | 0.83693931 |
2.2052541 | 1.7499996 |
2.2066926 | 2.7208274 |
2.2109871 | 0.60017807 |
2.2146996 | 1.399128 |
2.2174554 | 0.72364346 |
2.2304159 | 0.82961734 |
2.2473506 | 1.2875368 |
2.2490397 | 2.1734422 |
2.2519844 | 1.2969987 |
2.2604619 | 0.7826934 |
2.2688021 | 2.0460717 |
2.3082186 | 3.4655713 |
2.337285 | 2.3586476 |
2.3616657 | 2.9431843 |
2.372691 | 1.7305975 |
2.3783937 | 1.3535819 |
2.3816021 | 1.9007384 |
2.3967371 | 1.1569486 |
2.409683 | 2.3595594 |
2.4193469 | 1.0856312 |
2.4234583 | 0.51782552 |
2.4392568 | 3.1463499 |
2.440037 | 3.2618835 |
2.4499319 | 0.4923003 |
2.4582683 | 1.3588849 |
2.4769531 | 3.5814207 |
2.4844316 | 1.9984511 |
2.4845173 | 1.8737064 |
2.4932187 | 1.66146 |
2.5161047 | 2.2298843 |
2.5216744 | 2.9607432 |
2.5229139 | 1.492989 |
2.5270772 | -0.06387469 |
2.5353904 | 0.28615059 |
2.5781225 | 2.5085023 |
2.5789043 | 2.6564247 |
2.5913078 | 3.4678316 |
2.6017795 | 2.3329228 |
2.6083691 | 1.7219107 |
2.609068 | 2.4104897 |
2.6328854 | 1.4587599 |
2.6469687 | 1.7014709 |
2.6920039 | 1.295654 |
2.6979838 | 2.9314267 |
2.7126542 | 2.1619493 |
2.7176177 | 2.6184841 |
2.720342 | 2.7590754 |
2.7288016 | 1.8601606 |
2.7729759 | 2.3649024 |
2.8041777 | 1.8947211 |
2.8297566 | 2.1058471 |
2.8568165 | 3.2398304 |
2.8708006 | 2.5365312 |
2.8884565 | 2.4983996 |
2.8940135 | 0.80718637 |
2.9270099 | 1.4705192 |
2.933241 | 0.61062 |
2.9722306 | 1.9105811 |
2.9772854 | 0.05260017 |
2.9773797 | 2.4382292 |
2.980513 | 0.98434561 |
3.005612 | 2.8833924 |
3.0089706 | 0.48283347 |
3.0261818 | 2.8696189 |
3.0400688 | 2.2351968 |
3.0647613 | 1.3867858 |
3.0958156 | 4.7977043 |
3.0974361 | 0.61238889 |
3.123407 | 3.2756611 |
3.140026 | 1.9104996 |
3.1401996 | 3.0088845 |
3.1743328 | 2.9899578 |
3.1808794 | 2.408549 |
3.1832203 | 1.0703815 |
3.2276428 | 2.180782 |
3.2372055 | 1.4413745 |
3.2952069 | 2.9016304 |
3.3387983 | 3.2365316 |
3.3562441 | 3.3595853 |
3.4416423 | 4.7357497 |
3.521928 | 2.8651324 |
3.5249241 | 2.4056552 |
3.6396121 | 0.74341452 |
3.6525806 | 4.0596418 |
3.6773415 | 0.65264229 |
3.7089812 | 3.4749576 |
3.7570425 | 2.2789297 |
3.7990812 | 1.8031089 |
3.8079212 | 3.2604948 |
3.8635523 | 3.3065351 |
3.8826769 | 2.4434805 |
3.9105801 | 0.0730681 |
4.0275824 | 2.9110729 |
4.2610977 | 3.5150765 |
4.2654032 | 2.5862794 |
4.3772226 | 3.6939538 |
4.3862929 | 1.8272327 |
4.6736332 | 1.4853571 |
7.9435583 | 9.4739571 |
7.9739184 | 7.87866 |
8.187397 | 9.348852 |
8.2407109 | 8.5518535 |
8.2436521 | 9.4541242 |
8.2551838 | 7.5564442 |
8.285243 | 10.2071673 |
8.3299446 | 9.0000361 |
8.3319237 | 10.0936765 |
8.373557 | 9.8826912 |
8.464094 | 9.0581829 |
8.4906742 | 9.3292611 |
8.5115338 | 9.8535287 |
8.5659971 | 10.0486414 |
8.6023175 | 7.9585361 |
8.6234813 | 8.3907157 |
8.6445082 | 9.6998504 |
8.649045 | 9.8849591 |
8.6584125 | 9.0152807 |
8.6665508 | 9.4282592 |
8.6730605 | 10.5942431 |
8.763729 | 8.2835604 |
8.7755229 | 10.407463 |
8.8076254 | 9.658945 |
8.8276345 | 8.4644596 |
8.8479234 | 7.756862 |
8.856574 | 8.503814 |
8.8622591 | 9.9170009 |
8.9363758 | 7.2319598 |
8.943909 | 8.4875439 |
8.9889206 | 10.611449 |
9.0165059 | 9.5475354 |
9.0419705 | 10.8528666 |
9.102277 | 11.0164613 |
9.1288555 | 8.7255618 |
9.1296474 | 9.9023458 |
9.1553296 | 10.365873 |
9.1730311 | 8.742746 |
9.1820635 | 8.0384904 |
9.2560427 | 10.2301575 |
9.2981906 | 11.2181469 |
9.3011218 | 5.9657148 |
9.301961 | 9.6504424 |
9.3145947 | 8.2175059 |
9.3361955 | 11.0435696 |
9.3803912 | 9.9176344 |
9.4078596 | 9.5672229 |
9.40994 | 9.6915476 |
9.4850186 | 8.672043 |
9.4965347 | 10.4085449 |
9.5192183 | 9.1697117 |
9.5647357 | 10.0321895 |
9.5648727 | 10.5589759 |
9.6015189 | 6.0994906 |
9.603581 | 10.3790253 |
9.6099817 | 7.1638026 |
9.6206807 | 9.6087325 |
9.6345994 | 9.1531639 |
9.6429483 | 10.3542054 |
9.6724078 | 8.4637002 |
9.7092349 | 8.7151763 |
9.714601 | 7.8089865 |
9.7182087 | 7.8359403 |
9.7245 | 8.2597278 |
9.7385045 | 8.4247141 |
9.770265 | 9.7400903 |
9.8110738 | 8.4712292 |
9.8312662 | 7.5418477 |
9.8319838 | 8.9931978 |
9.8578799 | 9.0934209 |
9.8853276 | 9.0234515 |
9.913638 | 9.5415647 |
9.9267408 | 8.7133325 |
10.018074 | 9.6140025 |
10.0184744 | 9.045611 |
10.0412225 | 8.2239493 |
10.0485496 | 9.0632895 |
10.0518117 | 8.0080764 |
10.0664894 | 9.1414022 |
10.0949584 | 9.125697 |
10.101395 | 9.8750952 |
10.1235131 | 8.6977035 |
10.1394266 | 8.110125 |
10.1673507 | 8.731084 |
10.1958179 | 9.1986208 |
10.2270168 | 10.334217 |
10.2319251 | 9.5158861 |
10.2327407 | 9.0726365 |
10.2746275 | 8.693953 |
10.2802248 | 6.3492874 |
10.307973 | 8.5744575 |
10.4089124 | 8.1652054 |
10.4206061 | 7.1979654 |
10.4332237 | 9.4580566 |
10.4413669 | 8.0914636 |
10.4696749 | 8.8581128 |
10.4830634 | 11.2508174 |
10.4864111 | 7.7290216 |
10.4928201 | 10.746028 |
10.4952661 | 7.12129 |
10.4990939 | 10.0108213 |
10.5146056 | 9.6430751 |
10.5521972 | 8.328596 |
10.574167 | 9.0679398 |
10.5811656 | 7.0079888 |
10.5818258 | 9.1019273 |
10.6091367 | 8.5752111 |
10.6246849 | 8.5365028 |
10.6642143 | 8.4458003 |
10.6691018 | 10.7915455 |
10.7002922 | 10.6383879 |
10.7120615 | 8.794039 |
10.7644048 | 8.8808288 |
10.7934826 | 7.4950836 |
10.9684594 | 10.0053487 |
10.9714406 | 7.2756851 |
10.9788712 | 9.9465767 |
11.0029676 | 7.9771513 |
11.024769 | 6.9830776 |
11.108955 | 10.0022074 |
11.1667502 | 7.1966235 |
11.2008513 | 11.2806987 |
11.2237865 | 9.3287031 |
11.3157701 | 7.5950945 |
11.3606768 | 12.1086731 |
11.5844491 | 9.865713 |
11.6733525 | 7.6230164 |
11.682216 | 9.4233843 |
11.6856208 | 9.310157 |
11.6906946 | 7.328908 |
11.7297457 | 10.1547281 |
14.382204 | 9.6953397 |
-0.53802474 | 19.8670258 |
-0.50977026 | 19.5352805 |
-0.43584458 | 20.831295 |
-0.04882059 | 18.9503718 |
0.05835481 | 20.557332 |
0.10288324 | 19.5935174 |
0.17447523 | 18.0540215 |
0.19810974 | 19.12201 |
0.21934452 | 19.0784394 |
0.23439904 | 19.844791 |
0.26788561 | 20.209558 |
0.47250581 | 18.6123102 |
0.5142698 | 18.4614009 |
0.54996643 | 19.2768358 |
0.55418227 | 18.884939 |
0.60602417 | 20.936468 |
0.63375978 | 20.206995 |
0.63673117 | 18.7844843 |
0.7274187 | 19.0976652 |
0.78672127 | 18.6171725 |
0.84069897 | 18.7650607 |
0.885701 | 20.137431 |
0.91613686 | 20.233336 |
0.92942006 | 18.5713626 |
0.95596944 | 20.535309 |
0.96854857 | 19.8038184 |
1.0145628 | 18.2879164 |
1.0177927 | 20.84433 |
1.0215634 | 20.765331 |
1.0319656 | 19.6683734 |
1.0682963 | 19.1762061 |
1.0797411 | 20.497518 |
1.0890363 | 19.7297415 |
1.1020139 | 19.1104753 |
1.1111965 | 20.974068 |
1.1118762 | 20.730051 |
1.1190241 | 20.626021 |
1.1290053 | 20.708113 |
1.1567038 | 18.9859388 |
1.1642717 | 20.86776 |
1.1877287 | 19.0277225 |
1.2417761 | 19.9239422 |
1.2697233 | 20.58267 |
1.2805359 | 20.839587 |
1.315033 | 17.800678 |
1.3374848 | 19.8847305 |
1.3436787 | 21.160946 |
1.3601605 | 19.9220547 |
1.3804341 | 19.5464206 |
1.419576 | 18.5611838 |
1.44766 | 19.7976419 |
1.4497856 | 20.992422 |
1.4515913 | 19.246366 |
1.462917 | 19.0683491 |
1.469379 | 21.277371 |
1.476635 | 19.7049207 |
1.4789768 | 18.7587035 |
1.4864838 | 17.8367824 |
1.494347 | 18.4188009 |
1.4977578 | 20.235316 |
1.5150408 | 21.469438 |
1.5465376 | 20.102797 |
1.5481756 | 20.500124 |
1.5623819 | 21.11233 |
1.5657523 | 19.8653065 |
1.5680518 | 19.7992902 |
1.5787906 | 19.4795982 |
1.580711 | 20.634115 |
1.5882776 | 21.154661 |
1.6154553 | 19.5561227 |
1.6240277 | 18.1513374 |
1.6271007 | 19.9594745 |
1.6423654 | 19.5207591 |
1.6532214 | 18.9213972 |
1.6708971 | 19.0647823 |
1.6816109 | 20.307332 |
1.6831495 | 20.753881 |
1.6909234 | 18.3056743 |
1.694486 | 18.4031309 |
1.7029568 | 18.7852089 |
1.7209245 | 21.160009 |
1.7554475 | 19.5635625 |
1.7561105 | 19.1486694 |
1.7591644 | 21.053899 |
1.7816041 | 21.754704 |
1.7876631 | 20.692215 |
1.8234422 | 19.7212479 |
1.8262062 | 20.727142 |
1.8288627 | 20.673864 |
1.8297793 | 20.458916 |
1.832603 | 21.074711 |
1.8353628 | 19.0803144 |
1.8556235 | 19.6185811 |
1.8563045 | 20.950317 |
1.8567533 | 20.230949 |
1.8755811 | 19.7954 |
1.8808773 | 21.261579 |
1.8832988 | 18.9781784 |
1.8843075 | 19.8027541 |
1.8905587 | 22.469766 |
1.8975282 | 20.28635 |
1.9109833 | 20.301225 |
1.9144448 | 18.974059 |
1.9165083 | 21.676352 |
1.9209176 | 19.7131755 |
1.9781659 | 21.664901 |
1.9788063 | 17.9605311 |
1.9795792 | 20.604285 |
1.9988977 | 19.3873 |
2.0085747 | 20.703644 |
2.0196867 | 22.969208 |
2.025619 | 20.081437 |
2.0534619 | 20.705229 |
2.0547586 | 20.305228 |
2.0547586 | 20.816871 |
2.0755392 | 18.3552001 |
2.075569 | 19.5328423 |
2.1066715 | 18.9310227 |
2.1219421 | 18.0786952 |
2.1325375 | 20.278667 |
2.1346469 | 19.7929784 |
2.1377228 | 19.3141014 |
2.1424518 | 19.0621782 |
2.163728 | 18.0126414 |
2.1789909 | 21.545179 |
2.1910496 | 22.74184 |
2.192648 | 21.567828 |
2.2120042 | 19.5149355 |
2.2236802 | 19.7026045 |
2.235359 | 21.291386 |
2.2504888 | 20.255275 |
2.2849944 | 19.6670767 |
2.2936236 | 20.04094 |
2.2943962 | 18.6098342 |
2.2972952 | 21.044405 |
2.3159775 | 18.8025205 |
2.3183388 | 19.7124052 |
2.3312717 | 19.1945021 |
2.3332788 | 19.858556 |
2.3436751 | 20.278825 |
2.3510198 | 19.4443378 |
2.3536828 | 19.6918611 |
2.3762487 | 20.001178 |
2.3873331 | 19.944966 |
2.4018079 | 21.336344 |
2.4049931 | 20.354974 |
2.4069312 | 20.229606 |
2.4145946 | 21.865367 |
2.4298175 | 20.177013 |
2.4304013 | 21.295831 |
2.4350526 | 19.2814343 |
2.4365224 | 20.607422 |
2.4385972 | 20.113629 |
2.4395695 | 20.287594 |
2.4433867 | 19.5672236 |
2.4581051 | 19.3005269 |
2.484958 | 19.6122817 |
2.4855137 | 19.7430907 |
2.4961756 | 19.0852748 |
2.4961815 | 19.9774792 |
2.5060367 | 20.626502 |
2.5111277 | 20.048125 |
2.5353022 | 21.006037 |
2.5477455 | 19.5218191 |
2.5646723 | 18.5753288 |
2.6069566 | 19.4928334 |
2.610661 | 19.2333245 |
2.6110635 | 21.161409 |
2.6156599 | 22.24306 |
2.6157363 | 19.6247648 |
2.6231143 | 21.467851 |
2.6303499 | 21.166585 |
2.6479363 | 19.4927011 |
2.649848 | 19.9999997 |
2.6726846 | 21.196404 |
2.6956556 | 21.338031 |
2.7507975 | 21.35678 |
2.8039113 | 20.381728 |
2.8669884 | 21.926908 |
2.8952958 | 19.2367016 |
2.9323323 | 19.425336 |
2.9469818 | 20.622926 |
2.9524754 | 19.5783952 |
2.9781864 | 20.542842 |
2.9871194 | 18.4396185 |
3.0319823 | 20.890154 |
3.0549366 | 19.0793781 |
3.0848657 | 20.441317 |
3.0908691 | 20.080454 |
3.1299154 | 19.4593151 |
3.1662752 | 21.241106 |
3.1816155 | 18.5673625 |
3.2062795 | 19.3081385 |
3.2424753 | 20.28896 |
3.2425295 | 20.158123 |
3.2906467 | 21.072758 |
3.297312 | 19.8472714 |
3.2975145 | 20.757499 |
3.3062086 | 20.421346 |
3.3323506 | 20.513092 |
3.3448124 | 19.1347046 |
3.3474952 | 20.536695 |
3.4494709 | 21.900892 |
3.4986571 | 20.600885 |
3.5130076 | 21.136178 |
3.5275875 | 21.167535 |
3.5458203 | 20.827132 |
3.6357217 | 21.777843 |
3.6418671 | 20.280765 |
3.642627 | 19.750893 |
3.766496 | 20.256047 |
3.8495488 | 18.0793218 |
4.1037454 | 20.818065 |
4.2250822 | 22.607042 |
4.3813155 | 20.092317 |
4.634051 | 21.15266 |
5.0207123 | 20.895823 |
17.2951741 | 5.950383 |
17.6426889 | 4.026425 |
18.3783284 | 2.6677586 |
18.6610826 | 2.2858431 |
18.7658667 | 2.2502372 |
18.8735189 | 4.0070031 |
18.9202878 | 3.3794615 |
19.2157376 | 5.0456349 |
19.2828371 | 5.7614267 |
19.3416173 | 5.7342967 |
19.372867 | 5.071573 |
19.3793344 | 4.4288482 |
19.4471513 | 2.0290971 |
19.5507429 | 4.1520108 |
19.5796525 | 3.3137553 |
19.6592429 | 2.9047836 |
19.7027051 | 3.391466 |
19.7066826 | 3.8575872 |
19.7665198 | 4.6534996 |
19.8166826 | 5.0681208 |
19.8309236 | 4.4234537 |
19.8705837 | 1.95144045 |
19.8706565 | 2.4984245 |
19.8761654 | 4.5287529 |
19.9085948 | 1.91336718 |
19.9163915 | 5.4980526 |
19.9321293 | 5.6884465 |
19.9635774 | 5.1519153 |
19.9774131 | 1.71576669 |
20.005386 | 4.9725339 |
20.03108 | 3.1899709 |
20.031303 | 5.3222825 |
20.03259 | 5.1497509 |
20.03428 | 5.0453932 |
20.080447 | 4.3698057 |
20.083517 | 6.3154411 |
20.109498 | 1.6949377 |
20.12784 | 3.1077324 |
20.143328 | 5.2932866 |
20.153527 | 1.14745808 |
20.185165 | 5.6840752 |
20.186108 | 3.0095029 |
20.218486 | 1.86943064 |
20.225788 | 4.6446198 |
20.230586 | 3.5665214 |
20.242446 | 3.0842829 |
20.250058 | 4.6674981 |
20.256518 | 5.1025102 |
20.265683 | 2.0045272 |
20.282189 | 3.5401449 |
20.302099 | 3.6052738 |
20.308668 | 6.0612829 |
20.351454 | 4.9648817 |
20.353287 | 2.9206918 |
20.36641 | 2.0461857 |
20.372119 | 4.0134533 |
20.373874 | 4.3479411 |
20.385863 | 5.8749841 |
20.409758 | 2.4770249 |
20.429302 | 4.1856019 |
20.584737 | 5.5193866 |
20.607137 | 3.7815047 |
20.612883 | 1.24133727 |
20.62282 | 3.8538072 |
20.626709 | 5.3176161 |
20.631416 | 4.6234233 |
20.637825 | 1.13733134 |
20.650459 | 5.6764957 |
20.65138 | 5.4412149 |
20.663191 | 5.1562683 |
20.671364 | 3.1726842 |
20.676551 | 3.3428428 |
20.689668 | 1.11834644 |
20.693096 | 5.0325472 |
20.696343 | 4.5175537 |
20.699593 | 2.8767087 |
20.703645 | 4.631295 |
20.795686 | 2.7721686 |
20.809542 | 6.5642634 |
20.825847 | 3.1371149 |
20.842786 | 4.3904774 |
20.84874 | 6.3513859 |
20.860288 | 6.4784907 |
20.86037 | 2.8584966 |
20.869171 | 5.2307423 |
20.872055 | 4.0749112 |
20.87257 | 1.23464118 |
20.910788 | 5.2690191 |
20.928634 | 3.6359366 |
20.970335 | 3.8242789 |
21.036661 | 2.7005158 |
21.049342 | 3.7664064 |
21.060166 | 4.2008833 |
21.060814 | 4.9944114 |
21.068511 | 4.9511485 |
21.075475 | 3.162381 |
21.121069 | 4.024253 |
21.135204 | 4.2472877 |
21.137853 | 3.0020879 |
21.173174 | 4.1480361 |
21.186386 | 7.2251656 |
21.200991 | 2.1901514 |
21.208839 | 4.4279441 |
21.218948 | 3.7864309 |
21.221807 | 3.0719514 |
21.246152 | 5.4355796 |
21.262461 | 2.9578559 |
21.268682 | 3.628921 |
21.290465 | 3.2874838 |
21.293326 | 4.106079 |
21.301133 | 4.1777477 |
21.302882 | 3.2121843 |
21.307465 | 6.3794084 |
21.310338 | 3.0792017 |
21.377903 | 3.5628289 |
21.432628 | 3.2225798 |
21.439473 | 3.385765 |
21.467547 | 4.7781926 |
21.477121 | 3.6562905 |
21.501194 | 2.3480532 |
21.533824 | 4.9138983 |
21.54175 | 2.9172603 |
21.548589 | 4.4224972 |
21.551281 | 5.034822 |
21.580005 | 2.4249323 |
21.622936 | 2.6350977 |
21.635703 | 5.0811729 |
21.635766 | 0.6839693 |
21.636906 | 5.1485335 |
21.640693 | 5.0050765 |
21.644646 | 2.6398355 |
21.659895 | 3.7598802 |
21.6671 | 3.0851933 |
21.672122 | 1.82188274 |
21.790655 | 3.9990614 |
21.791466 | 3.9976649 |
21.823915 | 5.5021609 |
21.836958 | 2.770455 |
21.849023 | 5.0410794 |
21.875795 | 3.4999431 |
21.906133 | 5.8123412 |
21.929987 | 6.0171549 |
21.943218 | 4.5029935 |
21.944168 | 4.8880596 |
21.973628 | 5.3975676 |
21.977883 | 3.6668553 |
21.986891 | 3.3156703 |
21.990816 | 6.0919267 |
21.998018 | 5.5690895 |
22.002982 | 2.9423729 |
22.003167 | 3.1783848 |
22.02293 | 3.7394457 |
22.048313 | 5.7878447 |
22.04935 | 3.9196468 |
22.102964 | 6.9353623 |
22.104117 | 2.3553044 |
22.112408 | 4.44293 |
22.116913 | 5.7040627 |
22.117363 | 5.4379922 |
22.132975 | 4.7215931 |
22.148421 | 3.8419177 |
22.157023 | 3.3189264 |
22.209926 | 6.0647142 |
22.231745 | 4.1059839 |
22.243242 | 5.6659826 |
22.275244 | 3.4509242 |
22.283633 | 3.0655829 |
22.31873 | 3.5765372 |
22.360228 | 1.30690857 |
22.390107 | 5.4824678 |
22.391019 | 5.1110448 |
22.418397 | 3.6016607 |
22.438045 | 5.2962146 |
22.502628 | 2.9129491 |
22.530678 | 5.270917 |
22.531774 | 3.510775 |
22.535484 | 6.3496156 |
22.555906 | 2.8812822 |
22.574879 | 4.1483826 |
22.577047 | 6.5748674 |
22.698119 | 5.5684472 |
22.712666 | 2.8698348 |
22.754716 | 2.8842441 |
22.840546 | 5.1758951 |
22.875637 | 5.5823763 |
22.913839 | 4.7236013 |
22.921435 | 4.992112 |
22.95051 | 5.507263 |
22.968837 | 3.8102658 |
23.372123 | 5.1056244 |
23.570015 | 7.3520417 |
23.871862 | 2.2839561 |
13.776254 | 15.9332623 |
13.828535 | 17.754768 |
13.9985099 | 19.006255 |
14.0332013 | 19.171739 |
14.3495864 | 18.344629 |
14.3643301 | 17.307221 |
14.6308644 | 18.729308 |
14.6742915 | 18.422276 |
14.6765912 | 18.957163 |
14.7242125 | 18.603576 |
14.7309358 | 18.287858 |
14.8201135 | 17.317803 |
15.04405 | 18.326776 |
15.2843895 | 19.224467 |
15.3338087 | 20.315561 |
15.3864874 | 19.430293 |
15.391851 | 16.6688446 |
15.4134342 | 19.813134 |
15.4887595 | 18.338325 |
15.4927375 | 18.033762 |
15.5616717 | 19.041559 |
15.679285 | 18.295844 |
15.6980917 | 16.8332204 |
15.7248246 | 17.813209 |
15.738379 | 20.513935 |
15.7447018 | 20.612144 |
15.759245 | 20.425581 |
15.8174379 | 17.387096 |
15.8318274 | 20.132314 |
15.8411981 | 18.775724 |
15.8657639 | 15.18619 |
15.9045035 | 16.6292852 |
15.9060549 | 17.432955 |
15.9236652 | 16.5085818 |
15.9246185 | 18.501414 |
15.9371979 | 18.538343 |
15.9424162 | 17.669786 |
15.9436611 | 17.422198 |
15.954384 | 16.6210745 |
16.0048745 | 18.647301 |
16.0093275 | 18.155081 |
16.0495475 | 18.4833 |
16.0627556 | 18.23776 |
16.0848806 | 18.073719 |
16.0988263 | 18.650373 |
16.1219141 | 17.029351 |
16.1366616 | 19.971848 |
16.1485928 | 18.236786 |
16.1559942 | 16.9274005 |
16.1784265 | 16.6347077 |
16.2007163 | 20.458792 |
16.2067843 | 18.878027 |
16.2126233 | 17.627478 |
16.27771 | 18.301138 |
16.339495 | 22.147247 |
16.3421613 | 18.489292 |
16.3577314 | 17.460453 |
16.3724251 | 17.838472 |
16.3996649 | 15.71695 |
16.4002773 | 14.6913483 |
16.4324959 | 15.5923088 |
16.4391638 | 18.273311 |
16.474673 | 16.1187519 |
16.4783074 | 16.7469574 |
16.4828174 | 18.835584 |
16.5082782 | 17.96041 |
16.5131746 | 16.1271108 |
16.5226118 | 20.37399 |
16.5411115 | 18.970615 |
16.5478529 | 20.084663 |
16.5593776 | 18.467168 |
16.5604301 | 16.6251063 |
16.5621066 | 15.6151074 |
16.5639823 | 15.6570201 |
16.5727543 | 16.2284542 |
16.5999234 | 19.382793 |
16.6097383 | 16.6748319 |
16.6335421 | 17.659876 |
16.6346179 | 19.120215 |
16.6394592 | 14.6308142 |
16.6442026 | 19.402978 |
16.6624146 | 18.518399 |
16.6824201 | 19.045062 |
16.6933922 | 18.000639 |
16.6988315 | 18.716886 |
16.7180367 | 18.103054 |
16.7549039 | 16.4974324 |
16.7672336 | 18.161612 |
16.7675093 | 19.396513 |
16.7926923 | 18.684571 |
16.8061956 | 18.138528 |
16.8161585 | 17.744709 |
16.8442842 | 16.5564664 |
16.8517083 | 18.048076 |
16.8798602 | 18.078834 |
16.894805 | 17.364323 |
16.897217 | 16.2556095 |
16.9274089 | 17.295782 |
16.9540314 | 17.790538 |
16.9833606 | 17.01958 |
17.010122 | 16.2967178 |
17.011117 | 17.84965 |
17.02912 | 18.488563 |
17.036761 | 16.4478485 |
17.037256 | 18.574155 |
17.063049 | 18.151774 |
17.090068 | 18.56643 |
17.094963 | 18.018778 |
17.10096 | 15.8177448 |
17.122916 | 17.674656 |
17.129248 | 18.158393 |
17.13386 | 14.7555909 |
17.149812 | 16.2079389 |
17.152682 | 20.011784 |
17.176491 | 19.079545 |
17.178535 | 17.691873 |
17.183269 | 18.910638 |
17.215687 | 15.8817595 |
17.235729 | 15.7945041 |
17.259081 | 17.087312 |
17.264561 | 17.029223 |
17.274332 | 15.8333249 |
17.330272 | 16.7431158 |
17.368219 | 16.0200739 |
17.379084 | 19.194089 |
17.379872 | 18.124247 |
17.385792 | 18.179336 |
17.398364 | 19.606996 |
17.409342 | 17.693611 |
17.437678 | 17.926307 |
17.455588 | 19.845492 |
17.475238 | 18.791697 |
17.508271 | 16.4602961 |
17.527687 | 19.682064 |
17.536628 | 17.831121 |
17.542094 | 17.563114 |
17.545504 | 17.37607 |
17.547878 | 17.319933 |
17.553336 | 19.569272 |
17.557667 | 15.180909 |
17.582784 | 19.483361 |
17.590279 | 17.149325 |
17.634664 | 18.86855 |
17.639971 | 21.681327 |
17.643215 | 16.5278489 |
17.650616 | 18.021068 |
17.659338 | 19.160969 |
17.664585 | 17.421214 |
17.67864 | 13.6651535 |
17.706178 | 19.788597 |
17.743804 | 18.332319 |
17.754485 | 17.600224 |
17.776854 | 18.299507 |
17.788332 | 18.461131 |
17.797314 | 14.9900939 |
17.812277 | 16.7877808 |
17.818708 | 17.767132 |
17.825362 | 17.998126 |
17.827257 | 17.411798 |
17.855049 | 20.06313 |
17.895247 | 15.6882882 |
17.89677 | 18.241082 |
17.90694 | 16.3827126 |
17.931778 | 19.185287 |
17.935962 | 17.947167 |
17.936954 | 19.25114 |
17.958115 | 18.59757 |
18.026628 | 19.205066 |
18.037261 | 17.780271 |
18.061187 | 19.016911 |
18.097614 | 18.740769 |
18.099027 | 18.797805 |
18.1145 | 17.767203 |
18.131498 | 17.562132 |
18.170495 | 18.460691 |
18.188678 | 19.321407 |
18.191673 | 15.5556509 |
18.201821 | 18.442701 |
18.237079 | 15.6778069 |
18.25179 | 18.030541 |
18.270079 | 19.044006 |
18.333913 | 15.3620963 |
18.35918 | 17.033823 |
18.361986 | 17.354937 |
18.365055 | 19.033464 |
18.365386 | 16.7474302 |
18.367864 | 18.965754 |
18.432841 | 19.920374 |
18.455325 | 17.293297 |
18.457648 | 18.584263 |
18.482073 | 16.4698072 |
18.495794 | 15.2869317 |
18.520868 | 17.981305 |
18.601644 | 15.5475595 |
18.626402 | 17.237819 |
18.639048 | 17.63884 |
18.664319 | 18.12114 |
18.678355 | 18.234852 |
18.706041 | 19.347441 |
18.946172 | 18.768173 |
18.954228 | 17.480191 |
19.016013 | 20.799353 |
19.025227 | 18.322595 |
19.065571 | 19.06146 |
19.080158 | 17.622466 |
19.260129 | 17.286994 |
19.385613 | 19.526589 |
19.591116 | 20.438186 |
19.774989 | 19.963467 |
19.973478 | 18.539765 |
20.657494 | 15.7015363 |
Parag Kanade/fuzzy ants/Gauss2/gauss02Full.data
1 | -0.46551197 | 1.3396181 |
1 | -0.14154019 | 1.6467355 |
1 | -0.06147374 | 1.910021 |
1 | -0.00960664 | 1.6959237 |
1 | 0.13522751 | 2.3371545 |
1 | 0.15816343 | 1.74101 |
1 | 0.16902868 | 1.7145902 |
1 | 0.20321506 | 1.3230994 |
1 | 0.24094079 | 1.3069846 |
1 | 0.25245225 | 2.1839526 |
1 | 0.26993324 | 2.5483323 |
1 | 0.28680391 | 1.6052432 |
1 | 0.3192367 | 2.2276855 |
1 | 0.36114833 | 2.8009784 |
1 | 0.4244067 | 1.8634449 |
1 | 0.46037797 | 1.4532789 |
1 | 0.46098959 | 2.3555875 |
1 | 0.48936047 | 1.8126198 |
1 | 0.493417 | 0.52432961 |
1 | 0.5579586 | 2.0069093 |
1 | 0.59517099 | 0.74266104 |
1 | 0.601286 | 2.447746 |
1 | 0.64249205 | 0.22137058 |
1 | 0.64603926 | 2.098612 |
1 | 0.68936857 | 2.3436606 |
1 | 0.70125847 | 1.9881431 |
1 | 0.70954162 | 1.8340884 |
1 | 0.71271143 | 1.1911658 |
1 | 0.73828501 | 2.9157625 |
1 | 0.76121259 | 2.887774 |
1 | 0.76300537 | 3.36236 |
1 | 0.78715506 | 1.7998882 |
1 | 0.79603202 | 1.3837631 |
1 | 0.81552587 | 0.7659359 |
1 | 0.81671088 | 2.0235945 |
1 | 0.83646559 | 1.7292928 |
1 | 0.84905869 | 0.90959966 |
1 | 0.87280583 | 1.9185033 |
1 | 0.93911004 | 2.2377149 |
1 | 0.94658989 | 1.8099329 |
1 | 0.95071896 | 3.3593771 |
1 | 0.95477185 | 0.82422933 |
1 | 1.0475351 | 3.7358953 |
1 | 1.0483555 | 2.6222619 |
1 | 1.0663274 | 2.0772458 |
1 | 1.0719789 | 2.3051114 |
1 | 1.0841659 | 2.8982847 |
1 | 1.0917331 | 1.4965835 |
1 | 1.1268271 | 1.7541776 |
1 | 1.1308673 | 2.1353612 |
1 | 1.1428466 | 2.0972579 |
1 | 1.1493513 | 1.8227118 |
1 | 1.1819349 | 1.8738619 |
1 | 1.1900377 | 1.5835831 |
1 | 1.2101874 | 1.8796963 |
1 | 1.2181118 | 3.0111068 |
1 | 1.2277972 | 2.0808183 |
1 | 1.2335498 | 2.9573163 |
1 | 1.2448562 | 1.6017201 |
1 | 1.2555436 | 1.9472067 |
1 | 1.2597352 | 0.95874592 |
1 | 1.2601195 | 0.81798378 |
1 | 1.2715242 | 0.46185734 |
1 | 1.2749423 | 3.2592336 |
1 | 1.2888759 | 2.4162943 |
1 | 1.319464 | 2.1180977 |
1 | 1.3266557 | 1.9249356 |
1 | 1.3269461 | 2.8783508 |
1 | 1.3458998 | 1.6047048 |
1 | 1.3471548 | 2.0660325 |
1 | 1.3753515 | 2.4089999 |
1 | 1.3793406 | 2.1089793 |
1 | 1.3872928 | 3.3455047 |
1 | 1.3979966 | 2.3829163 |
1 | 1.4001717 | 3.0482038 |
1 | 1.4054732 | 1.6215221 |
1 | 1.4312392 | 0.79191521 |
1 | 1.4354818 | 3.0271297 |
1 | 1.4410139 | 2.7986203 |
1 | 1.4641202 | 0.58155858 |
1 | 1.4646153 | 3.9791516 |
1 | 1.5055329 | 1.0990125 |
1 | 1.5286615 | 2.6943944 |
1 | 1.5534019 | 3.741445 |
1 | 1.5735908 | 1.5571016 |
1 | 1.5856639 | 0.99127551 |
1 | 1.6083411 | 2.3154722 |
1 | 1.6167515 | 3.4641362 |
1 | 1.6315791 | 2.9447703 |
1 | 1.6485825 | 1.9459715 |
1 | 1.6558902 | 1.1154736 |
1 | 1.6603318 | 2.4801616 |
1 | 1.6657018 | 1.9762646 |
1 | 1.6740867 | 2.9751515 |
1 | 1.7109312 | 1.5716093 |
1 | 1.7172934 | 1.9542265 |
1 | 1.7245997 | 2.387059 |
1 | 1.7280016 | 3.2168608 |
1 | 1.7407356 | 1.6770587 |
1 | 1.7446611 | 3.8440441 |
1 | 1.7479167 | 1.3913499 |
1 | 1.7507312 | 2.769599 |
1 | 1.7567404 | 1.4447784 |
1 | 1.7591262 | 3.9952283 |
1 | 1.7610234 | 3.5877581 |
1 | 1.7736913 | 1.4399875 |
1 | 1.7826518 | 3.1827802 |
1 | 1.7882331 | 2.7558682 |
1 | 1.8048077 | 1.4894358 |
1 | 1.806578 | 2.2980184 |
1 | 1.8105734 | 3.0728863 |
1 | 1.8132452 | 0.11900227 |
1 | 1.8581162 | 2.3816176 |
1 | 1.8735926 | 2.1120087 |
1 | 1.8771577 | 1.9606585 |
1 | 1.8791867 | 0.81713304 |
1 | 1.8866894 | 1.5761363 |
1 | 1.8881009 | 0.12698201 |
1 | 1.8980516 | 2.4640572 |
1 | 1.911659 | 0.92031474 |
1 | 1.9163593 | 2.2659011 |
1 | 1.9217044 | 1.9429349 |
1 | 1.9240625 | 1.2683148 |
1 | 1.933498 | 0.99443935 |
1 | 1.9366692 | 3.0426166 |
1 | 1.9572064 | 3.2689621 |
1 | 1.987931 | 4.1287767 |
1 | 1.9907116 | 1.6489055 |
1 | 1.9930155 | 2.6846483 |
1 | 2.0011578 | 2.3236036 |
1 | 2.0107086 | 2.1802041 |
1 | 2.0650972 | 0.62687304 |
1 | 2.0760993 | 1.8564104 |
1 | 2.076595 | 3.141211 |
1 | 2.0797088 | 2.6444816 |
1 | 2.0828643 | 2.4026682 |
1 | 2.0948837 | 1.8648059 |
1 | 2.0985622 | 3.7026465 |
1 | 2.0994979 | 4.0382142 |
1 | 2.1023642 | 3.2814187 |
1 | 2.1102441 | 3.3805769 |
1 | 2.1522589 | 1.6625872 |
1 | 2.1613626 | 2.6416719 |
1 | 2.1760954 | 0.66759943 |
1 | 2.1805424 | 2.0442384 |
1 | 2.1842685 | 2.5954692 |
1 | 2.1891405 | 2.9582391 |
1 | 2.1963915 | 2.0430046 |
1 | 2.2020264 | 2.176707 |
1 | 2.204684 | 0.83693931 |
1 | 2.2052541 | 1.7499996 |
1 | 2.2066926 | 2.7208274 |
1 | 2.2109871 | 0.60017807 |
1 | 2.2146996 | 1.399128 |
1 | 2.2174554 | 0.72364346 |
1 | 2.2304159 | 0.82961734 |
1 | 2.2473506 | 1.2875368 |
1 | 2.2490397 | 2.1734422 |
1 | 2.2519844 | 1.2969987 |
1 | 2.2604619 | 0.7826934 |
1 | 2.2688021 | 2.0460717 |
1 | 2.3082186 | 3.4655713 |
1 | 2.337285 | 2.3586476 |
1 | 2.3616657 | 2.9431843 |
1 | 2.372691 | 1.7305975 |
1 | 2.3783937 | 1.3535819 |
1 | 2.3816021 | 1.9007384 |
1 | 2.3967371 | 1.1569486 |
1 | 2.409683 | 2.3595594 |
1 | 2.4193469 | 1.0856312 |
1 | 2.4234583 | 0.51782552 |
1 | 2.4392568 | 3.1463499 |
1 | 2.440037 | 3.2618835 |
1 | 2.4499319 | 0.4923003 |
1 | 2.4582683 | 1.3588849 |
1 | 2.4769531 | 3.5814207 |
1 | 2.4844316 | 1.9984511 |
1 | 2.4845173 | 1.8737064 |
1 | 2.4932187 | 1.66146 |
1 | 2.5161047 | 2.2298843 |
1 | 2.5216744 | 2.9607432 |
1 | 2.5229139 | 1.492989 |
1 | 2.5270772 | -0.06387469 |
1 | 2.5353904 | 0.28615059 |
1 | 2.5781225 | 2.5085023 |
1 | 2.5789043 | 2.6564247 |
1 | 2.5913078 | 3.4678316 |
1 | 2.6017795 | 2.3329228 |
1 | 2.6083691 | 1.7219107 |
1 | 2.609068 | 2.4104897 |
1 | 2.6328854 | 1.4587599 |
1 | 2.6469687 | 1.7014709 |
1 | 2.6920039 | 1.295654 |
1 | 2.6979838 | 2.9314267 |
1 | 2.7126542 | 2.1619493 |
1 | 2.7176177 | 2.6184841 |
1 | 2.720342 | 2.7590754 |
1 | 2.7288016 | 1.8601606 |
1 | 2.7729759 | 2.3649024 |
1 | 2.8041777 | 1.8947211 |
1 | 2.8297566 | 2.1058471 |
1 | 2.8568165 | 3.2398304 |
1 | 2.8708006 | 2.5365312 |
1 | 2.8884565 | 2.4983996 |
1 | 2.8940135 | 0.80718637 |
1 | 2.9270099 | 1.4705192 |
1 | 2.933241 | 0.61062 |
1 | 2.9722306 | 1.9105811 |
1 | 2.9772854 | 0.05260017 |
1 | 2.9773797 | 2.4382292 |
1 | 2.980513 | 0.98434561 |
1 | 3.005612 | 2.8833924 |
1 | 3.0089706 | 0.48283347 |
1 | 3.0261818 | 2.8696189 |
1 | 3.0400688 | 2.2351968 |
1 | 3.0647613 | 1.3867858 |
1 | 3.0958156 | 4.7977043 |
1 | 3.0974361 | 0.61238889 |
1 | 3.123407 | 3.2756611 |
1 | 3.140026 | 1.9104996 |
1 | 3.1401996 | 3.0088845 |
1 | 3.1743328 | 2.9899578 |
1 | 3.1808794 | 2.408549 |
1 | 3.1832203 | 1.0703815 |
1 | 3.2276428 | 2.180782 |
1 | 3.2372055 | 1.4413745 |
1 | 3.2952069 | 2.9016304 |
1 | 3.3387983 | 3.2365316 |
1 | 3.3562441 | 3.3595853 |
1 | 3.4416423 | 4.7357497 |
1 | 3.521928 | 2.8651324 |
1 | 3.5249241 | 2.4056552 |
1 | 3.6396121 | 0.74341452 |
1 | 3.6525806 | 4.0596418 |
1 | 3.6773415 | 0.65264229 |
1 | 3.7089812 | 3.4749576 |
1 | 3.7570425 | 2.2789297 |
1 | 3.7990812 | 1.8031089 |
1 | 3.8079212 | 3.2604948 |
1 | 3.8635523 | 3.3065351 |
1 | 3.8826769 | 2.4434805 |
1 | 3.9105801 | 0.0730681 |
1 | 4.0275824 | 2.9110729 |
1 | 4.2610977 | 3.5150765 |
1 | 4.2654032 | 2.5862794 |
1 | 4.3772226 | 3.6939538 |
1 | 4.3862929 | 1.8272327 |
1 | 4.6736332 | 1.4853571 |
2 | 7.9435583 | 9.4739571 |
2 | 7.9739184 | 7.87866 |
2 | 8.187397 | 9.348852 |
2 | 8.2407109 | 8.5518535 |
2 | 8.2436521 | 9.4541242 |
2 | 8.2551838 | 7.5564442 |
2 | 8.285243 | 10.2071673 |
2 | 8.3299446 | 9.0000361 |
2 | 8.3319237 | 10.0936765 |
2 | 8.373557 | 9.8826912 |
2 | 8.464094 | 9.0581829 |
2 | 8.4906742 | 9.3292611 |
2 | 8.5115338 | 9.8535287 |
2 | 8.5659971 | 10.0486414 |
2 | 8.6023175 | 7.9585361 |
2 | 8.6234813 | 8.3907157 |
2 | 8.6445082 | 9.6998504 |
2 | 8.649045 | 9.8849591 |
2 | 8.6584125 | 9.0152807 |
2 | 8.6665508 | 9.4282592 |
2 | 8.6730605 | 10.5942431 |
2 | 8.763729 | 8.2835604 |
2 | 8.7755229 | 10.407463 |
2 | 8.8076254 | 9.658945 |
2 | 8.8276345 | 8.4644596 |
2 | 8.8479234 | 7.756862 |
2 | 8.856574 | 8.503814 |
2 | 8.8622591 | 9.9170009 |
2 | 8.9363758 | 7.2319598 |
2 | 8.943909 | 8.4875439 |
2 | 8.9889206 | 10.611449 |
2 | 9.0165059 | 9.5475354 |
2 | 9.0419705 | 10.8528666 |
2 | 9.102277 | 11.0164613 |
2 | 9.1288555 | 8.7255618 |
2 | 9.1296474 | 9.9023458 |
2 | 9.1553296 | 10.365873 |
2 | 9.1730311 | 8.742746 |
2 | 9.1820635 | 8.0384904 |
2 | 9.2560427 | 10.2301575 |
2 | 9.2981906 | 11.2181469 |
2 | 9.3011218 | 5.9657148 |
2 | 9.301961 | 9.6504424 |
2 | 9.3145947 | 8.2175059 |
2 | 9.3361955 | 11.0435696 |
2 | 9.3803912 | 9.9176344 |
2 | 9.4078596 | 9.5672229 |
2 | 9.40994 | 9.6915476 |
2 | 9.4850186 | 8.672043 |
2 | 9.4965347 | 10.4085449 |
2 | 9.5192183 | 9.1697117 |
2 | 9.5647357 | 10.0321895 |
2 | 9.5648727 | 10.5589759 |
2 | 9.6015189 | 6.0994906 |
2 | 9.603581 | 10.3790253 |
2 | 9.6099817 | 7.1638026 |
2 | 9.6206807 | 9.6087325 |
2 | 9.6345994 | 9.1531639 |
2 | 9.6429483 | 10.3542054 |
2 | 9.6724078 | 8.4637002 |
2 | 9.7092349 | 8.7151763 |
2 | 9.714601 | 7.8089865 |
2 | 9.7182087 | 7.8359403 |
2 | 9.7245 | 8.2597278 |
2 | 9.7385045 | 8.4247141 |
2 | 9.770265 | 9.7400903 |
2 | 9.8110738 | 8.4712292 |
2 | 9.8312662 | 7.5418477 |
2 | 9.8319838 | 8.9931978 |
2 | 9.8578799 | 9.0934209 |
2 | 9.8853276 | 9.0234515 |
2 | 9.913638 | 9.5415647 |
2 | 9.9267408 | 8.7133325 |
2 | 10.018074 | 9.6140025 |
2 | 10.0184744 | 9.045611 |
2 | 10.0412225 | 8.2239493 |
2 | 10.0485496 | 9.0632895 |
2 | 10.0518117 | 8.0080764 |
2 | 10.0664894 | 9.1414022 |
2 | 10.0949584 | 9.125697 |
2 | 10.101395 | 9.8750952 |
2 | 10.1235131 | 8.6977035 |
2 | 10.1394266 | 8.110125 |
2 | 10.1673507 | 8.731084 |
2 | 10.1958179 | 9.1986208 |
2 | 10.2270168 | 10.334217 |
2 | 10.2319251 | 9.5158861 |
2 | 10.2327407 | 9.0726365 |
2 | 10.2746275 | 8.693953 |
2 | 10.2802248 | 6.3492874 |
2 | 10.307973 | 8.5744575 |
2 | 10.4089124 | 8.1652054 |
2 | 10.4206061 | 7.1979654 |
2 | 10.4332237 | 9.4580566 |
2 | 10.4413669 | 8.0914636 |
2 | 10.4696749 | 8.8581128 |
2 | 10.4830634 | 11.2508174 |
2 | 10.4864111 | 7.7290216 |
2 | 10.4928201 | 10.746028 |
2 | 10.4952661 | 7.12129 |
2 | 10.4990939 | 10.0108213 |
2 | 10.5146056 | 9.6430751 |
2 | 10.5521972 | 8.328596 |
2 | 10.574167 | 9.0679398 |
2 | 10.5811656 | 7.0079888 |
2 | 10.5818258 | 9.1019273 |
2 | 10.6091367 | 8.5752111 |
2 | 10.6246849 | 8.5365028 |
2 | 10.6642143 | 8.4458003 |
2 | 10.6691018 | 10.7915455 |
2 | 10.7002922 | 10.6383879 |
2 | 10.7120615 | 8.794039 |
2 | 10.7644048 | 8.8808288 |
2 | 10.7934826 | 7.4950836 |
2 | 10.9684594 | 10.0053487 |
2 | 10.9714406 | 7.2756851 |
2 | 10.9788712 | 9.9465767 |
2 | 11.0029676 | 7.9771513 |
2 | 11.024769 | 6.9830776 |
2 | 11.108955 | 10.0022074 |
2 | 11.1667502 | 7.1966235 |
2 | 11.2008513 | 11.2806987 |
2 | 11.2237865 | 9.3287031 |
2 | 11.3157701 | 7.5950945 |
2 | 11.3606768 | 12.1086731 |
2 | 11.5844491 | 9.865713 |
2 | 11.6733525 | 7.6230164 |
2 | 11.682216 | 9.4233843 |
2 | 11.6856208 | 9.310157 |
2 | 11.6906946 | 7.328908 |
2 | 11.7297457 | 10.1547281 |
2 | 14.382204 | 9.6953397 |
3 | -0.53802474 | 19.8670258 |
3 | -0.50977026 | 19.5352805 |
3 | -0.43584458 | 20.831295 |
3 | -0.04882059 | 18.9503718 |
3 | 0.05835481 | 20.557332 |
3 | 0.10288324 | 19.5935174 |
3 | 0.17447523 | 18.0540215 |
3 | 0.19810974 | 19.12201 |
3 | 0.21934452 | 19.0784394 |
3 | 0.23439904 | 19.844791 |
3 | 0.26788561 | 20.209558 |
3 | 0.47250581 | 18.6123102 |
3 | 0.5142698 | 18.4614009 |
3 | 0.54996643 | 19.2768358 |
3 | 0.55418227 | 18.884939 |
3 | 0.60602417 | 20.936468 |
3 | 0.63375978 | 20.206995 |
3 | 0.63673117 | 18.7844843 |
3 | 0.7274187 | 19.0976652 |
3 | 0.78672127 | 18.6171725 |
3 | 0.84069897 | 18.7650607 |
3 | 0.885701 | 20.137431 |
3 | 0.91613686 | 20.233336 |
3 | 0.92942006 | 18.5713626 |
3 | 0.95596944 | 20.535309 |
3 | 0.96854857 | 19.8038184 |
3 | 1.0145628 | 18.2879164 |
3 | 1.0177927 | 20.84433 |
3 | 1.0215634 | 20.765331 |
3 | 1.0319656 | 19.6683734 |
3 | 1.0682963 | 19.1762061 |
3 | 1.0797411 | 20.497518 |
3 | 1.0890363 | 19.7297415 |
3 | 1.1020139 | 19.1104753 |
3 | 1.1111965 | 20.974068 |
3 | 1.1118762 | 20.730051 |
3 | 1.1190241 | 20.626021 |
3 | 1.1290053 | 20.708113 |
3 | 1.1567038 | 18.9859388 |
3 | 1.1642717 | 20.86776 |
3 | 1.1877287 | 19.0277225 |
3 | 1.2417761 | 19.9239422 |
3 | 1.2697233 | 20.58267 |
3 | 1.2805359 | 20.839587 |
3 | 1.315033 | 17.800678 |
3 | 1.3374848 | 19.8847305 |
3 | 1.3436787 | 21.160946 |
3 | 1.3601605 | 19.9220547 |
3 | 1.3804341 | 19.5464206 |
3 | 1.419576 | 18.5611838 |
3 | 1.44766 | 19.7976419 |
3 | 1.4497856 | 20.992422 |
3 | 1.4515913 | 19.246366 |
3 | 1.462917 | 19.0683491 |
3 | 1.469379 | 21.277371 |
3 | 1.476635 | 19.7049207 |
3 | 1.4789768 | 18.7587035 |
3 | 1.4864838 | 17.8367824 |
3 | 1.494347 | 18.4188009 |
3 | 1.4977578 | 20.235316 |
3 | 1.5150408 | 21.469438 |
3 | 1.5465376 | 20.102797 |
3 | 1.5481756 | 20.500124 |
3 | 1.5623819 | 21.11233 |
3 | 1.5657523 | 19.8653065 |
3 | 1.5680518 | 19.7992902 |
3 | 1.5787906 | 19.4795982 |
3 | 1.580711 | 20.634115 |
3 | 1.5882776 | 21.154661 |
3 | 1.6154553 | 19.5561227 |
3 | 1.6240277 | 18.1513374 |
3 | 1.6271007 | 19.9594745 |
3 | 1.6423654 | 19.5207591 |
3 | 1.6532214 | 18.9213972 |
3 | 1.6708971 | 19.0647823 |
3 | 1.6816109 | 20.307332 |
3 | 1.6831495 | 20.753881 |
3 | 1.6909234 | 18.3056743 |
3 | 1.694486 | 18.4031309 |
3 | 1.7029568 | 18.7852089 |
3 | 1.7209245 | 21.160009 |
3 | 1.7554475 | 19.5635625 |
3 | 1.7561105 | 19.1486694 |
3 | 1.7591644 | 21.053899 |
3 | 1.7816041 | 21.754704 |
3 | 1.7876631 | 20.692215 |
3 | 1.8234422 | 19.7212479 |
3 | 1.8262062 | 20.727142 |
3 | 1.8288627 | 20.673864 |
3 | 1.8297793 | 20.458916 |
3 | 1.832603 | 21.074711 |
3 | 1.8353628 | 19.0803144 |
3 | 1.8556235 | 19.6185811 |
3 | 1.8563045 | 20.950317 |
3 | 1.8567533 | 20.230949 |
3 | 1.8755811 | 19.7954 |
3 | 1.8808773 | 21.261579 |
3 | 1.8832988 | 18.9781784 |
3 | 1.8843075 | 19.8027541 |
3 | 1.8905587 | 22.469766 |
3 | 1.8975282 | 20.28635 |
3 | 1.9109833 | 20.301225 |
3 | 1.9144448 | 18.974059 |
3 | 1.9165083 | 21.676352 |
3 | 1.9209176 | 19.7131755 |
3 | 1.9781659 | 21.664901 |
3 | 1.9788063 | 17.9605311 |
3 | 1.9795792 | 20.604285 |
3 | 1.9988977 | 19.3873 |
3 | 2.0085747 | 20.703644 |
3 | 2.0196867 | 22.969208 |
3 | 2.025619 | 20.081437 |
3 | 2.0534619 | 20.705229 |
3 | 2.0547586 | 20.305228 |
3 | 2.0547586 | 20.816871 |
3 | 2.0755392 | 18.3552001 |
3 | 2.075569 | 19.5328423 |
3 | 2.1066715 | 18.9310227 |
3 | 2.1219421 | 18.0786952 |
3 | 2.1325375 | 20.278667 |
3 | 2.1346469 | 19.7929784 |
3 | 2.1377228 | 19.3141014 |
3 | 2.1424518 | 19.0621782 |
3 | 2.163728 | 18.0126414 |
3 | 2.1789909 | 21.545179 |
3 | 2.1910496 | 22.74184 |
3 | 2.192648 | 21.567828 |
3 | 2.2120042 | 19.5149355 |
3 | 2.2236802 | 19.7026045 |
3 | 2.235359 | 21.291386 |
3 | 2.2504888 | 20.255275 |
3 | 2.2849944 | 19.6670767 |
3 | 2.2936236 | 20.04094 |
3 | 2.2943962 | 18.6098342 |
3 | 2.2972952 | 21.044405 |
3 | 2.3159775 | 18.8025205 |
3 | 2.3183388 | 19.7124052 |
3 | 2.3312717 | 19.1945021 |
3 | 2.3332788 | 19.858556 |
3 | 2.3436751 | 20.278825 |
3 | 2.3510198 | 19.4443378 |
3 | 2.3536828 | 19.6918611 |
3 | 2.3762487 | 20.001178 |
3 | 2.3873331 | 19.944966 |
3 | 2.4018079 | 21.336344 |
3 | 2.4049931 | 20.354974 |
3 | 2.4069312 | 20.229606 |
3 | 2.4145946 | 21.865367 |
3 | 2.4298175 | 20.177013 |
3 | 2.4304013 | 21.295831 |
3 | 2.4350526 | 19.2814343 |
3 | 2.4365224 | 20.607422 |
3 | 2.4385972 | 20.113629 |
3 | 2.4395695 | 20.287594 |
3 | 2.4433867 | 19.5672236 |
3 | 2.4581051 | 19.3005269 |
3 | 2.484958 | 19.6122817 |
3 | 2.4855137 | 19.7430907 |
3 | 2.4961756 | 19.0852748 |
3 | 2.4961815 | 19.9774792 |
3 | 2.5060367 | 20.626502 |
3 | 2.5111277 | 20.048125 |
3 | 2.5353022 | 21.006037 |
3 | 2.5477455 | 19.5218191 |
3 | 2.5646723 | 18.5753288 |
3 | 2.6069566 | 19.4928334 |
3 | 2.610661 | 19.2333245 |
3 | 2.6110635 | 21.161409 |
3 | 2.6156599 | 22.24306 |
3 | 2.6157363 | 19.6247648 |
3 | 2.6231143 | 21.467851 |
3 | 2.6303499 | 21.166585 |
3 | 2.6479363 | 19.4927011 |
3 | 2.649848 | 19.9999997 |
3 | 2.6726846 | 21.196404 |
3 | 2.6956556 | 21.338031 |
3 | 2.7507975 | 21.35678 |
3 | 2.8039113 | 20.381728 |
3 | 2.8669884 | 21.926908 |
3 | 2.8952958 | 19.2367016 |
3 | 2.9323323 | 19.425336 |
3 | 2.9469818 | 20.622926 |
3 | 2.9524754 | 19.5783952 |
3 | 2.9781864 | 20.542842 |
3 | 2.9871194 | 18.4396185 |
3 | 3.0319823 | 20.890154 |
3 | 3.0549366 | 19.0793781 |
3 | 3.0848657 | 20.441317 |
3 | 3.0908691 | 20.080454 |
3 | 3.1299154 | 19.4593151 |
3 | 3.1662752 | 21.241106 |
3 | 3.1816155 | 18.5673625 |
3 | 3.2062795 | 19.3081385 |
3 | 3.2424753 | 20.28896 |
3 | 3.2425295 | 20.158123 |
3 | 3.2906467 | 21.072758 |
3 | 3.297312 | 19.8472714 |
3 | 3.2975145 | 20.757499 |
3 | 3.3062086 | 20.421346 |
3 | 3.3323506 | 20.513092 |
3 | 3.3448124 | 19.1347046 |
3 | 3.3474952 | 20.536695 |
3 | 3.4494709 | 21.900892 |
3 | 3.4986571 | 20.600885 |
3 | 3.5130076 | 21.136178 |
3 | 3.5275875 | 21.167535 |
3 | 3.5458203 | 20.827132 |
3 | 3.6357217 | 21.777843 |
3 | 3.6418671 | 20.280765 |
3 | 3.642627 | 19.750893 |
3 | 3.766496 | 20.256047 |
3 | 3.8495488 | 18.0793218 |
3 | 4.1037454 | 20.818065 |
3 | 4.2250822 | 22.607042 |
3 | 4.3813155 | 20.092317 |
3 | 4.634051 | 21.15266 |
3 | 5.0207123 | 20.895823 |
4 | 17.2951741 | 5.950383 |
4 | 17.6426889 | 4.026425 |
4 | 18.3783284 | 2.6677586 |
4 | 18.6610826 | 2.2858431 |
4 | 18.7658667 | 2.2502372 |
4 | 18.8735189 | 4.0070031 |
4 | 18.9202878 | 3.3794615 |
4 | 19.2157376 | 5.0456349 |
4 | 19.2828371 | 5.7614267 |
4 | 19.3416173 | 5.7342967 |
4 | 19.372867 | 5.071573 |
4 | 19.3793344 | 4.4288482 |
4 | 19.4471513 | 2.0290971 |
4 | 19.5507429 | 4.1520108 |
4 | 19.5796525 | 3.3137553 |
4 | 19.6592429 | 2.9047836 |
4 | 19.7027051 | 3.391466 |
4 | 19.7066826 | 3.8575872 |
4 | 19.7665198 | 4.6534996 |
4 | 19.8166826 | 5.0681208 |
4 | 19.8309236 | 4.4234537 |
4 | 19.8705837 | 1.95144045 |
4 | 19.8706565 | 2.4984245 |
4 | 19.8761654 | 4.5287529 |
4 | 19.9085948 | 1.91336718 |
4 | 19.9163915 | 5.4980526 |
4 | 19.9321293 | 5.6884465 |
4 | 19.9635774 | 5.1519153 |
4 | 19.9774131 | 1.71576669 |
4 | 20.005386 | 4.9725339 |
4 | 20.03108 | 3.1899709 |
4 | 20.031303 | 5.3222825 |
4 | 20.03259 | 5.1497509 |
4 | 20.03428 | 5.0453932 |
4 | 20.080447 | 4.3698057 |
4 | 20.083517 | 6.3154411 |
4 | 20.109498 | 1.6949377 |
4 | 20.12784 | 3.1077324 |
4 | 20.143328 | 5.2932866 |
4 | 20.153527 | 1.14745808 |
4 | 20.185165 | 5.6840752 |
4 | 20.186108 | 3.0095029 |
4 | 20.218486 | 1.86943064 |
4 | 20.225788 | 4.6446198 |
4 | 20.230586 | 3.5665214 |
4 | 20.242446 | 3.0842829 |
4 | 20.250058 | 4.6674981 |
4 | 20.256518 | 5.1025102 |
4 | 20.265683 | 2.0045272 |
4 | 20.282189 | 3.5401449 |
4 | 20.302099 | 3.6052738 |
4 | 20.308668 | 6.0612829 |
4 | 20.351454 | 4.9648817 |
4 | 20.353287 | 2.9206918 |
4 | 20.36641 | 2.0461857 |
4 | 20.372119 | 4.0134533 |
4 | 20.373874 | 4.3479411 |
4 | 20.385863 | 5.8749841 |
4 | 20.409758 | 2.4770249 |
4 | 20.429302 | 4.1856019 |
4 | 20.584737 | 5.5193866 |
4 | 20.607137 | 3.7815047 |
4 | 20.612883 | 1.24133727 |
4 | 20.62282 | 3.8538072 |
4 | 20.626709 | 5.3176161 |
4 | 20.631416 | 4.6234233 |
4 | 20.637825 | 1.13733134 |
4 | 20.650459 | 5.6764957 |
4 | 20.65138 | 5.4412149 |
4 | 20.663191 | 5.1562683 |
4 | 20.671364 | 3.1726842 |
4 | 20.676551 | 3.3428428 |
4 | 20.689668 | 1.11834644 |
4 | 20.693096 | 5.0325472 |
4 | 20.696343 | 4.5175537 |
4 | 20.699593 | 2.8767087 |
4 | 20.703645 | 4.631295 |
4 | 20.795686 | 2.7721686 |
4 | 20.809542 | 6.5642634 |
4 | 20.825847 | 3.1371149 |
4 | 20.842786 | 4.3904774 |
4 | 20.84874 | 6.3513859 |
4 | 20.860288 | 6.4784907 |
4 | 20.86037 | 2.8584966 |
4 | 20.869171 | 5.2307423 |
4 | 20.872055 | 4.0749112 |
4 | 20.87257 | 1.23464118 |
4 | 20.910788 | 5.2690191 |
4 | 20.928634 | 3.6359366 |
4 | 20.970335 | 3.8242789 |
4 | 21.036661 | 2.7005158 |
4 | 21.049342 | 3.7664064 |
4 | 21.060166 | 4.2008833 |
4 | 21.060814 | 4.9944114 |
4 | 21.068511 | 4.9511485 |
4 | 21.075475 | 3.162381 |
4 | 21.121069 | 4.024253 |
4 | 21.135204 | 4.2472877 |
4 | 21.137853 | 3.0020879 |
4 | 21.173174 | 4.1480361 |
4 | 21.186386 | 7.2251656 |
4 | 21.200991 | 2.1901514 |
4 | 21.208839 | 4.4279441 |
4 | 21.218948 | 3.7864309 |
4 | 21.221807 | 3.0719514 |
4 | 21.246152 | 5.4355796 |
4 | 21.262461 | 2.9578559 |
4 | 21.268682 | 3.628921 |
4 | 21.290465 | 3.2874838 |
4 | 21.293326 | 4.106079 |
4 | 21.301133 | 4.1777477 |
4 | 21.302882 | 3.2121843 |
4 | 21.307465 | 6.3794084 |
4 | 21.310338 | 3.0792017 |
4 | 21.377903 | 3.5628289 |
4 | 21.432628 | 3.2225798 |
4 | 21.439473 | 3.385765 |
4 | 21.467547 | 4.7781926 |
4 | 21.477121 | 3.6562905 |
4 | 21.501194 | 2.3480532 |
4 | 21.533824 | 4.9138983 |
4 | 21.54175 | 2.9172603 |
4 | 21.548589 | 4.4224972 |
4 | 21.551281 | 5.034822 |
4 | 21.580005 | 2.4249323 |
4 | 21.622936 | 2.6350977 |
4 | 21.635703 | 5.0811729 |
4 | 21.635766 | 0.6839693 |
4 | 21.636906 | 5.1485335 |
4 | 21.640693 | 5.0050765 |
4 | 21.644646 | 2.6398355 |
4 | 21.659895 | 3.7598802 |
4 | 21.6671 | 3.0851933 |
4 | 21.672122 | 1.82188274 |
4 | 21.790655 | 3.9990614 |
4 | 21.791466 | 3.9976649 |
4 | 21.823915 | 5.5021609 |
4 | 21.836958 | 2.770455 |
4 | 21.849023 | 5.0410794 |
4 | 21.875795 | 3.4999431 |
4 | 21.906133 | 5.8123412 |
4 | 21.929987 | 6.0171549 |
4 | 21.943218 | 4.5029935 |
4 | 21.944168 | 4.8880596 |
4 | 21.973628 | 5.3975676 |
4 | 21.977883 | 3.6668553 |
4 | 21.986891 | 3.3156703 |
4 | 21.990816 | 6.0919267 |
4 | 21.998018 | 5.5690895 |
4 | 22.002982 | 2.9423729 |
4 | 22.003167 | 3.1783848 |
4 | 22.02293 | 3.7394457 |
4 | 22.048313 | 5.7878447 |
4 | 22.04935 | 3.9196468 |
4 | 22.102964 | 6.9353623 |
4 | 22.104117 | 2.3553044 |
4 | 22.112408 | 4.44293 |
4 | 22.116913 | 5.7040627 |
4 | 22.117363 | 5.4379922 |
4 | 22.132975 | 4.7215931 |
4 | 22.148421 | 3.8419177 |
4 | 22.157023 | 3.3189264 |
4 | 22.209926 | 6.0647142 |
4 | 22.231745 | 4.1059839 |
4 | 22.243242 | 5.6659826 |
4 | 22.275244 | 3.4509242 |
4 | 22.283633 | 3.0655829 |
4 | 22.31873 | 3.5765372 |
4 | 22.360228 | 1.30690857 |
4 | 22.390107 | 5.4824678 |
4 | 22.391019 | 5.1110448 |
4 | 22.418397 | 3.6016607 |
4 | 22.438045 | 5.2962146 |
4 | 22.502628 | 2.9129491 |
4 | 22.530678 | 5.270917 |
4 | 22.531774 | 3.510775 |
4 | 22.535484 | 6.3496156 |
4 | 22.555906 | 2.8812822 |
4 | 22.574879 | 4.1483826 |
4 | 22.577047 | 6.5748674 |
4 | 22.698119 | 5.5684472 |
4 | 22.712666 | 2.8698348 |
4 | 22.754716 | 2.8842441 |
4 | 22.840546 | 5.1758951 |
4 | 22.875637 | 5.5823763 |
4 | 22.913839 | 4.7236013 |
4 | 22.921435 | 4.992112 |
4 | 22.95051 | 5.507263 |
4 | 22.968837 | 3.8102658 |
4 | 23.372123 | 5.1056244 |
4 | 23.570015 | 7.3520417 |
4 | 23.871862 | 2.2839561 |
5 | 13.776254 | 15.9332623 |
5 | 13.828535 | 17.754768 |
5 | 13.9985099 | 19.006255 |
5 | 14.0332013 | 19.171739 |
5 | 14.3495864 | 18.344629 |
5 | 14.3643301 | 17.307221 |
5 | 14.6308644 | 18.729308 |
5 | 14.6742915 | 18.422276 |
5 | 14.6765912 | 18.957163 |
5 | 14.7242125 | 18.603576 |
5 | 14.7309358 | 18.287858 |
5 | 14.8201135 | 17.317803 |
5 | 15.04405 | 18.326776 |
5 | 15.2843895 | 19.224467 |
5 | 15.3338087 | 20.315561 |
5 | 15.3864874 | 19.430293 |
5 | 15.391851 | 16.6688446 |
5 | 15.4134342 | 19.813134 |
5 | 15.4887595 | 18.338325 |
5 | 15.4927375 | 18.033762 |
5 | 15.5616717 | 19.041559 |
5 | 15.679285 | 18.295844 |
5 | 15.6980917 | 16.8332204 |
5 | 15.7248246 | 17.813209 |
5 | 15.738379 | 20.513935 |
5 | 15.7447018 | 20.612144 |
5 | 15.759245 | 20.425581 |
5 | 15.8174379 | 17.387096 |
5 | 15.8318274 | 20.132314 |
5 | 15.8411981 | 18.775724 |
5 | 15.8657639 | 15.18619 |
5 | 15.9045035 | 16.6292852 |
5 | 15.9060549 | 17.432955 |
5 | 15.9236652 | 16.5085818 |
5 | 15.9246185 | 18.501414 |
5 | 15.9371979 | 18.538343 |
5 | 15.9424162 | 17.669786 |
5 | 15.9436611 | 17.422198 |
5 | 15.954384 | 16.6210745 |
5 | 16.0048745 | 18.647301 |
5 | 16.0093275 | 18.155081 |
5 | 16.0495475 | 18.4833 |
5 | 16.0627556 | 18.23776 |
5 | 16.0848806 | 18.073719 |
5 | 16.0988263 | 18.650373 |
5 | 16.1219141 | 17.029351 |
5 | 16.1366616 | 19.971848 |
5 | 16.1485928 | 18.236786 |
5 | 16.1559942 | 16.9274005 |
5 | 16.1784265 | 16.6347077 |
5 | 16.2007163 | 20.458792 |
5 | 16.2067843 | 18.878027 |
5 | 16.2126233 | 17.627478 |
5 | 16.27771 | 18.301138 |
5 | 16.339495 | 22.147247 |
5 | 16.3421613 | 18.489292 |
5 | 16.3577314 | 17.460453 |
5 | 16.3724251 | 17.838472 |
5 | 16.3996649 | 15.71695 |
5 | 16.4002773 | 14.6913483 |
5 | 16.4324959 | 15.5923088 |
5 | 16.4391638 | 18.273311 |
5 | 16.474673 | 16.1187519 |
5 | 16.4783074 | 16.7469574 |
5 | 16.4828174 | 18.835584 |
5 | 16.5082782 | 17.96041 |
5 | 16.5131746 | 16.1271108 |
5 | 16.5226118 | 20.37399 |
5 | 16.5411115 | 18.970615 |
5 | 16.5478529 | 20.084663 |
5 | 16.5593776 | 18.467168 |
5 | 16.5604301 | 16.6251063 |
5 | 16.5621066 | 15.6151074 |
5 | 16.5639823 | 15.6570201 |
5 | 16.5727543 | 16.2284542 |
5 | 16.5999234 | 19.382793 |
5 | 16.6097383 | 16.6748319 |
5 | 16.6335421 | 17.659876 |
5 | 16.6346179 | 19.120215 |
5 | 16.6394592 | 14.6308142 |
5 | 16.6442026 | 19.402978 |
5 | 16.6624146 | 18.518399 |
5 | 16.6824201 | 19.045062 |
5 | 16.6933922 | 18.000639 |
5 | 16.6988315 | 18.716886 |
5 | 16.7180367 | 18.103054 |
5 | 16.7549039 | 16.4974324 |
5 | 16.7672336 | 18.161612 |
5 | 16.7675093 | 19.396513 |
5 | 16.7926923 | 18.684571 |
5 | 16.8061956 | 18.138528 |
5 | 16.8161585 | 17.744709 |
5 | 16.8442842 | 16.5564664 |
5 | 16.8517083 | 18.048076 |
5 | 16.8798602 | 18.078834 |
5 | 16.894805 | 17.364323 |
5 | 16.897217 | 16.2556095 |
5 | 16.9274089 | 17.295782 |
5 | 16.9540314 | 17.790538 |
5 | 16.9833606 | 17.01958 |
5 | 17.010122 | 16.2967178 |
5 | 17.011117 | 17.84965 |
5 | 17.02912 | 18.488563 |
5 | 17.036761 | 16.4478485 |
5 | 17.037256 | 18.574155 |
5 | 17.063049 | 18.151774 |
5 | 17.090068 | 18.56643 |
5 | 17.094963 | 18.018778 |
5 | 17.10096 | 15.8177448 |
5 | 17.122916 | 17.674656 |
5 | 17.129248 | 18.158393 |
5 | 17.13386 | 14.7555909 |
5 | 17.149812 | 16.2079389 |
5 | 17.152682 | 20.011784 |
5 | 17.176491 | 19.079545 |
5 | 17.178535 | 17.691873 |
5 | 17.183269 | 18.910638 |
5 | 17.215687 | 15.8817595 |
5 | 17.235729 | 15.7945041 |
5 | 17.259081 | 17.087312 |
5 | 17.264561 | 17.029223 |
5 | 17.274332 | 15.8333249 |
5 | 17.330272 | 16.7431158 |
5 | 17.368219 | 16.0200739 |
5 | 17.379084 | 19.194089 |
5 | 17.379872 | 18.124247 |
5 | 17.385792 | 18.179336 |
5 | 17.398364 | 19.606996 |
5 | 17.409342 | 17.693611 |
5 | 17.437678 | 17.926307 |
5 | 17.455588 | 19.845492 |
5 | 17.475238 | 18.791697 |
5 | 17.508271 | 16.4602961 |
5 | 17.527687 | 19.682064 |
5 | 17.536628 | 17.831121 |
5 | 17.542094 | 17.563114 |
5 | 17.545504 | 17.37607 |
5 | 17.547878 | 17.319933 |
5 | 17.553336 | 19.569272 |
5 | 17.557667 | 15.180909 |
5 | 17.582784 | 19.483361 |
5 | 17.590279 | 17.149325 |
5 | 17.634664 | 18.86855 |
5 | 17.639971 | 21.681327 |
5 | 17.643215 | 16.5278489 |
5 | 17.650616 | 18.021068 |
5 | 17.659338 | 19.160969 |
5 | 17.664585 | 17.421214 |
5 | 17.67864 | 13.6651535 |
5 | 17.706178 | 19.788597 |
5 | 17.743804 | 18.332319 |
5 | 17.754485 | 17.600224 |
5 | 17.776854 | 18.299507 |
5 | 17.788332 | 18.461131 |
5 | 17.797314 | 14.9900939 |
5 | 17.812277 | 16.7877808 |
5 | 17.818708 | 17.767132 |
5 | 17.825362 | 17.998126 |
5 | 17.827257 | 17.411798 |
5 | 17.855049 | 20.06313 |
5 | 17.895247 | 15.6882882 |
5 | 17.89677 | 18.241082 |
5 | 17.90694 | 16.3827126 |
5 | 17.931778 | 19.185287 |
5 | 17.935962 | 17.947167 |
5 | 17.936954 | 19.25114 |
5 | 17.958115 | 18.59757 |
5 | 18.026628 | 19.205066 |
5 | 18.037261 | 17.780271 |
5 | 18.061187 | 19.016911 |
5 | 18.097614 | 18.740769 |
5 | 18.099027 | 18.797805 |
5 | 18.1145 | 17.767203 |
5 | 18.131498 | 17.562132 |
5 | 18.170495 | 18.460691 |
5 | 18.188678 | 19.321407 |
5 | 18.191673 | 15.5556509 |
5 | 18.201821 | 18.442701 |
5 | 18.237079 | 15.6778069 |
5 | 18.25179 | 18.030541 |
5 | 18.270079 | 19.044006 |
5 | 18.333913 | 15.3620963 |
5 | 18.35918 | 17.033823 |
5 | 18.361986 | 17.354937 |
5 | 18.365055 | 19.033464 |
5 | 18.365386 | 16.7474302 |
5 | 18.367864 | 18.965754 |
5 | 18.432841 | 19.920374 |
5 | 18.455325 | 17.293297 |
5 | 18.457648 | 18.584263 |
5 | 18.482073 | 16.4698072 |
5 | 18.495794 | 15.2869317 |
5 | 18.520868 | 17.981305 |
5 | 18.601644 | 15.5475595 |
5 | 18.626402 | 17.237819 |
5 | 18.639048 | 17.63884 |
5 | 18.664319 | 18.12114 |
5 | 18.678355 | 18.234852 |
5 | 18.706041 | 19.347441 |
5 | 18.946172 | 18.768173 |
5 | 18.954228 | 17.480191 |
5 | 19.016013 | 20.799353 |
5 | 19.025227 | 18.322595 |
5 | 19.065571 | 19.06146 |
5 | 19.080158 | 17.622466 |
5 | 19.260129 | 17.286994 |
5 | 19.385613 | 19.526589 |
5 | 19.591116 | 20.438186 |
5 | 19.774989 | 19.963467 |
5 | 19.973478 | 18.539765 |
5 | 20.657494 | 15.7015363 |
Parag Kanade/fuzzy ants/Gauss2/gauss.c
#include "headerStatic.h" /*******************************************************************/ /*** Global Variables ***/ irisData data[MAXDATA]; //To hold the data read from the file int count=0; //Count of the total number of data elements int heapCount=0; // Total number of heaps int heapRow=0; // Rows for the second iteration with heaps int newHeapCount=0; // Count of the heaps for the second iteration heap heaps[MAXDATA]; // Data structure to hold the heap information heap newHeaps[MAXDATA]; // Data Structure to hold the new heap information // For the second iteration int board[MAXROWS][MAXCOLS]; // Board on which the objects are located ant ants[MAXANTS]; // Data structure to hold the ants float Dmax=0; // Distance of the most dissimilar object pair int minHeapCount=100000; // Counter to hold the minimum heap count, used only for academic purpose // no use in the algorithm int minPosition; // the minimum heap iteration , only for academic purpose // no use in the algorithm float clsCen[MAXDATA][MAXDATA][s];//to hold the objects after hardening int cenCount[MAXDATA];//to hold the number of objects after hardening /********************************************************************/ /*** Varaibles to normalize the features between 0 and 1 */ float minInput[features], maxInput[features],scale[features],minForHeaps[features],maxForHeaps[features],scaleForHeaps[features]; /********************************************************************/ /** Variables for the FCM algorithm */ int temp[200]; /* for square matrix tests */ float eps,m; matrix U, U1; BOOLEAN stop; center V; objects X; char fname[80]; FILE *fp; int run; float inv_cov[s+1][s+1]; /* inverse of covariance matrix Y */ float Y[s][s]; long rand_index, Random_seed; long state1[52] = { 9347, 3835, 5194, 8310, 346, 535, 5297, 6711, 77, 3834, 668, 4175, 6868, 5890, 9304, 8462, 5269, 920, 65392, 41600, 70119, 91032, 76220, 26245, 4746, 73608, 32823, 63264, 75641, 99104, 36534, 24704, 98255, 72266, 75336, 65152, 7269, 63163, 88471, 27271, 43641, 76649, 47773, 23777, 27491, 35926, 16651, 48652, 89766, 90921, 6056 }; int z; int mins=0; int aveit =0; float mintab[200]; int mincount[200]; long start,end,total; int lCount;//added by parag /********************************************************************/ /********************************************************************//*int lrand48(){return(rand());}void srand48(int a){return;}*//********************************************************************/ /********************************************************************/ /* Function to read the input data set */ /* The file name is assumed to be itest.data */ /* Status: Tested */ /* Output: Data from the file into the "data" (Global) data structure */ /* Output: Count (Global), the count of the number of objects */ /********************************************************************/ void readInput() { FILE *fp; char fname[80]; int i=0,j=0; char ch; sprintf(fname,"%s.data",filename); /* Check if the input file is opened */ if((fp=fopen(fname,"r"))==NULL) { printf("\n Unable to open input file \n"); exit(0); } /*initialise the minimum maximum and the scale */ for(i=0;i<features;i++) { minInput[i]=1000; maxInput[i]=0; minForHeaps[i]=1000; maxForHeaps[i]=0; scale[i]=0; scaleForHeaps[i]=0; } /* Discard leading comments */ ch = 'c'; while (ch != '#') fscanf (fp, "%c", &ch); i=0; /* Parse the file and populate the data structure */ while(!feof(fp)) { for(j=0;j<features;j++) { fscanf(fp,"%f ",&data[i][j]); } fscanf(fp,"\n"); for(j=0;j<features;j++) { if(data[i][j]<minInput[j]) minInput[j]=data[i][j]; if(data[i][j]>maxInput[j]) maxInput[j]=data[i][j]; } i++; } count=i; /* Normailze the feature values in between 0 and 1 */ for(j=0;j<features;j++) { if(minInput[j]!=maxInput[j]) scale[j]=1.0/(maxInput[j]-minInput[j]); else scale[j]=1.0; } for(i=0;i<count;i++) { for(j=0;j<features;j++) data[i][j]=(data[i][j]-minInput[j])*scale[j]; } fclose(fp); return; }//end of function /********************************************************************/ /*Function to compute the eucldiean distance for all input data set */ /* Output : an array conatining the distance of each object with the other */ /********************************************************************/ float computeDistance() { float distance,dist=0; int i=0,j=0,k=0; distance=0; for(j=0;j<count;j++) for(i=0;i<count;i++) { for(k=0;k<features;k++) dist+=sqrt((data[j][k]-data[i][k])*(data[j][k]-data[i][k])); if(distance<dist)distance=dist; dist=0; } return(distance); } /********************************************************************/ /* Function to compute the distance between two objects */ /* Output : Euclidean d istance between the two input objects */ /********************************************************************/ float computeDistanceBetween2(irisData a,irisData b) { float temp=0; int i=0; for(i=0;i<features;i++) temp+=(a[i]-b[i])*(a[i]-b[i]); temp=sqrt(temp); return(temp); } /********************************************************************/ /* Function to find the maximum distance between the input objects*/ /* Output: the maximum distance */ /* Input : The array of distances between objects */ /********************************************************************/ /*float findMax(float *distance) { int i=0,j=0; float max=distance[0]; for(i=0;i<count;i++) for(j=0;j<count;j++) { if(max<distance[i*count+j]) max=distance[i*count+j]; } return(max); }*/ /********************************************************************/ /* Function to compute the value of an object */ /********************************************************************/ float value(irisData a) { int i=0; float temp=0; for(i=0;i<features;i++) temp+=a[i]*a[i]; return(sqrt(temp)); } /********************************************************************/ /* Function to find the object in the data structure */ /* Output : The position of the object in the data */ /* Input : The object */ /********************************************************************/ int findInData(irisData object,int iFlag) { int i=0,lastCount=0,j,position=-1,flag[features],flg;if(iFlag==1)lastCount=MAXDATA;else{}for(i=0;i<lastCount;i++){ for(j=0;j<features;j++) if(fabs(object[j]-data[i][j])<0.00001) flag[j]=1; else { flag[j]=0; break;} flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /* Function to find whether there is an object on the board at a,b */ /* Output : a flag indicating whether an object is found or not */ /* Input : The row and column indicating the board position */ /********************************************************************/ int found(int a , int b) { if(board[a][b]==9) return 1; else return 0; } /********************************************************************/ /* Function to initialize the initial board */ /* Output : None */ /* Global Structures modified : heaps */ /* Input : Flag indicating the iteration 1: First 0: Second */ /********************************************************************/ void initialise(int flag) { int a,b,i=0,k=0; int loopCount,rowCount,colCount; /* Initialize the row, column and number of heaps */ if(flag==1) { loopCount=count; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=lCount; rowCount=heapRow; colCount=heapRow; } /* Initialize the heaps */ for(i=0;i<loopCount;i++) { heaps[i].count=0; heaps[i].x=0; heaps[i].y=0; heaps[i].disPosition=0; heaps[i].Dmax=0; heaps[i].Dmean=0; } for(i=0;i<loopCount;i++) { /*find a board position which is empty*/ do { a=lrand48()%rowCount; b=lrand48()%colCount; } while(found(a,b)); /*Allocate the object to that place and assign a heap to it*/ heaps[i].x=a; heaps[i].y=b; heaps[i].count=1; heaps[i].Dmax=0; heaps[i].Dmean=0; if(flag==1) { heaps[i].objects[0]=i; for(k=0;k<features;k++)heaps[i].Ocenter[k]=data[i][k]; } else { for(k=0;k<features;k++) heaps[i].Ocenter[k]=newHeaps[i].Ocenter[k]; } heaps[i].disPosition=0; board[a][b]=9; if((debugLevel>0)&&(flag==1))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],data[heaps[i].objects[0]][0]); if((debugLevel>0)&&(flag==0))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],newHeaps[i].Ocenter[0]); } /*initialise the initial heap count*/ heapCount=loopCount; currentRow=rowCount; } /********************************************************************/ /* Function to find whether an heap is present at the location a b */ /* Output : Flag indicating the presencs of the heap */ /* Input : Roe and column indicating the board position */ /********************************************************************/ int findObject(int a,int b) { int i; int position=-1; for(i=0;i<heapCount;i++) { if((heaps[i].x==a)&&(heaps[i].y==b)) { position=i; break; } } return(position); } /********************************************************************/ /* Function initialize the ants */ /* Output : None */ /* Input : Flag indicating the iteration */ /* Global Variables Modified : ant, heapCount, heaps, board */ /********************************************************************/ void initialiseAnts(int flag) { int i=0,a=0,b=0,position,j=0,loopCount=0,rowCount,colCount,k=0; if(flag==1) { loopCount=MAXANTS; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=MAXANTSFORHEAPS; rowCount=heapRow; colCount=heapRow; } for(i=0;i<loopCount;i++) { /*generate random positions for the ants*/ a=lrand48()%rowCount; b=lrand48()%colCount; ants[i].x=a; ants[i].y=b; /*Find if an object is present at that position or not*/ if(board[a][b]==9) { ants[i].carrying=1; /*find the heap at that location*/ position=findObject(a,b); if(position==-1) { printf("\n Error in logic: Ant init \n"); //getchar(); break; } else { /*Assign the heap data to the ant data and decrement the heap count*/ if(flag==1){ for(k=0;k<features;k++)ants[i].data[k]=data[heaps[position].objects[0]][k]; }else{for(k=0;k<features;k++)ants[i].data[k]=heaps[position].Ocenter[k];} for(j=position;j<heapCount-1;j++) heaps[j]=heaps[j+1]; heapCount--; } /*Clear the board position */ board[a][b]=-9; } else ants[i].carrying=-1; ants[i].speed=0; ants[i].dir=lrand48()%8; printf("\n Ant %2d X: %2d Y: %2d Carying : %2d ",i,ants[i].x,ants[i].y,ants[i].carrying); } currentAntCount=loopCount; } /********************************************************************/ /* Function to move the ant */ /* Output: None */ /* Input: Ant to be moved and the flag indicating the iteration */ /********************************************************************/ void moveNext(ant* a,int flag) { int rowCount,colCount; /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; } else { rowCount=heapRow; colCount=heapRow; }*/rowCount=currentRow;colCount=currentRow; /*Depending upon the direction move the ant*/ switch (a->dir) { case 0: a->y++; if(a->y>=colCount)a->y=0; break; case 1: a->x--; a->y++;; if(a->x<0)a->x=rowCount-1; if(a->y>=colCount)a->y=0; break; case 2: a->x--; if(a->x<0)a->x=rowCount-1; break; case 3: a->x--; a->y--; if(a->x<0)a->x=rowCount-1; if(a->y<0)a->y=colCount-1; break; case 4: a->y--; if(a->y<0)a->y=colCount-1; break; case 5: a->x++; a->y--; if(a->x>=rowCount)a->x=0; if(a->y<0)a->y=colCount-1; break; case 6: a->x++; if(a->x>=rowCount) a->x=0; break; case 7: a->x++; a->y++; if(a->x>=rowCount)a->x=0; if(a->y>=colCount)a->y=0; break; } }//end of function /********************************************************************/ /* Function to compute the parameters of the heap */ /* Output: None */ /* Input: The heap whose parameters are to be computed iteration flag*/ /********************************************************************/ void computeHeapParameters(heap* heapData,int flag) { int i=0,j=0,k=0,position=0; float distance=0; float Dmean=0.0; float *dis; float featureSum[features]; float max=0; float sum=0; /* init*/ for(k=0;k<features;k++) featureSum[k]=0; /*Compute the distance of each object and find the maximum distance*/ max=0; if(flag==1){ for(j=0;j<heapData->count;j++) for(i=0;i<heapData->count;i++) { for(k=0;k<features;k++) sum+= (data[heapData->objects[j]][k]-data[heapData->objects[i]][k])*(data[heapData->objects[j]][k]-data[heapData->objects[i]][k]); distance=sqrt(sum); if(max<distance) max=distance; sum=0; } /* Assign the maximum distance to the heap */ heapData->Dmax=max;/*Compute the centre object*/for(i=0;i<heapData->count;i++)for(k=0;k<features;k++) featureSum[k]+=data[heapData->objects[i]][k];for(k=0;k<features;k++)heapData->Ocenter[k]=featureSum[k]*1.0/heapData->count; /* Find the mean distance */if((dis=(float *) calloc(heapData->count,sizeof(float)))==NULL){printf("\nUnable to allocate memory in the compute heap parameters procedure\n");exit(0);} for(i=0;i<heapData->count;i++) { Dmean+=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); dis[i]=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); } heapData->Dmean=Dmean*1.0/heapData->count; /*Compute the most dissimilar object*/ max=dis[0]; for(i=1;i<heapData->count;i++) if(max<dis[i]) { max=dis[i]; position=i; } /*Assign the most dissimilar object to the heap variable*/ for(k=0;k<features;k++) heapData->Odissim[k]=data[heapData->objects[position]][k]; heapData->disPosition=position;free(dis); } else{/* Heap Parameters for the second stage */for(k=0;k<features;k++){ heapData->Odissim[k]=heapData->Ocenter[k];}heapData->disPosition=0;heapData->Dmean=0;heapData->Dmax=0;} }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a single object*/ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject1(ant *a,int position,int flag) { int i,k=0; /*Clear the board*/ board[heaps[position].x][heaps[position].y]=-9; /* Assign the data to the ant*/if(flag==1){ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[0]][k];}else {for(k=0;k<features;k++) a->data[k]=heaps[position].Ocenter[k];} a->carrying=1; /*Copy all the heaps remaining heaps in the structure*/ for(i=position;i<heapCount-1;i++) heaps[i]=heaps[i+1]; /*Decrement the heap count*/ heapCount--; }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a two objects */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject2(ant *a , int position,int flag) { float Pdestroy1=-1; int i=0,k=0; /*Compute the probability to destroy the heap*/ Pdestroy1=lrand48()%13*1.0/12.0; /*If the probability is more than Pdestroy then destroy the heap */ if(Pdestroy1<Pdestroy) { /*pick the object randomly*/ i=lrand48()%2; /* Assign the data to the ant */ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[i]][k]; a->carrying=1; /*Correct the heap parameters*/ heaps[position].count=1; heaps[position].objects[0]=heaps[position].objects[1-i]; computeHeapParameters(&heaps[position],flag); } }//end of function /********************************************************************/ /*Function to pick a object from a heap consisting of more than two object */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /********************************************************************/ void pickObjectn(ant *a,int position,int flag) { int i=0,k=0; /*If the criteria is satsfied then pick the object*/ if((computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)*1.0/heaps[position].Dmean)>Tremove) { a->carrying=1; for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[heaps[position].disPosition]][k]; for(i=heaps[position].disPosition;i<heaps[position].count-1;i++) heaps[position].objects[i]=heaps[position].objects[i+1]; heaps[position].count--; computeHeapParameters(&heaps[position],1); } }//end of function /********************************************************************/ /* Function to pick a object */ /********************************************************************/ void pick(ant *a,int flag) { int position=-1,i=0; float Pload1=-1.0; for(i=0;i<heapCount;i++) { /*Check if a heap is present in the eight neighbouring cells*/ if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if Heap is found*/ if(position!=-1) { /* heap or object found.*/ /*Depending upon the number present in the heap call the corresponding routine*/ switch(heaps[i].count) { case 1: Pload1 = lrand48()%151*1.0/150.0; if(Pload1<Pload) { pickObject1(a,position,flag); } break; case 2: pickObject2(a,position,flag); break; default: pickObjectn(a,position,flag); break; } } } /********************************************************************/ /* Function to drop a object to form a new heap */ /* Output: None */ /* Input: Ant, iteration flag */ /* Global Structure modified : heap, heapCount */ /********************************************************************/ void dropObject(ant* a,int flag) { /*Create a new heap*/ int k=0; heaps[heapCount].count=1; heaps[heapCount].x=a->x; heaps[heapCount].y=a->y; heaps[heapCount].Dmax=0; heaps[heapCount].Dmean=0; heaps[heapCount].disPosition=0; for(k=0;k<features;k++) { heaps[heapCount].Odissim[k]=a->data[k]; heaps[heapCount].Ocenter[k]=a->data[k]; } if(flag==1) {heaps[heapCount].objects[0]=findInData(a->data,flag); /*computeHeapParameters(&heaps[heapCount],flag);*/ } computeHeapParameters(&heaps[heapCount],flag); heapCount++; a->carrying=-1; board[a->x][a->y]=9; }//end of function /********************************************************************/ /* Function to find the heap position during the second iteration */ /* Output: position of the heap */ /* Input: object center of the heap that the ant is carrying */ /* Global Structure modified : none */ /********************************************************************/ int findInNewheaps(irisData object) { int position=-1,i,j=0,flag[features],flg; for(i=0;i<newHeapCount;i++) { for(j=0;j<features;j++) { if(fabs(object[j]-newHeaps[i].Ocenter[j])<0.00001) flag[j]=1; else {flag[j]=0;break;} } flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /*Function to drop a object to a heap consisting of a one or more object */ /* Output: none */ /* Input: Ant, position of the heap , iteration flag */ /* Global Structure modified: heaps,newHeaps */ /********************************************************************/ void dropObject1(ant* a, int position,int flag) { int heapPosition=-1,heapPosition1=-1,i,j,k=0; irisData newData,temp; if(flag==1) { /*Add the object to the heap and compute the heap parameters*/ /*if(heaps[position].count==heaps[position].objCount) {if((junk=(int *)realloc(heaps[position].objects,((heaps[position].objCount+OBJINC)*sizeof(int))))==NULL){printf("\n Cannot Allocate memory to the new object for %d heap",position);exit(0);}heaps[position].objects=junk;heaps[position].objCount+=OBJINC;free(junk); }*/ heaps[position].objects[heaps[position].count]=findInData(a->data,flag); heaps[position].count++; computeHeapParameters(&heaps[position],flag); } else { for(k=0;k<features;k++)temp[k]=heaps[position].Ocenter[k]; heapPosition=findInNewheaps(a->data); heapPosition1=findInNewheaps(heaps[position].Ocenter); if(heapPosition==-1||heapPosition1==-1) { printf("\n error in logic:new heaps\n"); //getchar(); return; } for(k=0;k<features;k++) {newData[k]=(newHeaps[heapPosition].Ocenter[k]*newHeaps[heapPosition].count+newHeaps[heapPosition1].Ocenter[k]*newHeaps[heapPosition1].count)*1.0/(newHeaps[heapPosition].count+newHeaps[heapPosition1].count);newHeaps[heapPosition].Ocenter[k]=newData[k];heaps[position].Ocenter[k]=newData[k]; } computeHeapParameters(&heaps[position],flag); for(i=newHeaps[heapPosition].count,j=0;j<newHeaps[heapPosition1].count;i++,j++) { newHeaps[heapPosition].objects[i]=newHeaps[heapPosition1].objects[j]; } newHeaps[heapPosition].count+=newHeaps[heapPosition1].count; for(i=heapPosition1;i<newHeapCount-1;i++) newHeaps[i]=newHeaps[i+1]; newHeapCount--; } a->carrying=-1; }//end of function /********************************************************************/ /* Function to drop a object */ /* Output: None */ /* Input: Ant, iteration flag */ /********************************************************************/ void drop(ant* a,int flag) { int i, position=-1; float Pdrop1=0.0; /*Find whether we have a heap in the neighbourhood of the cell*/ for(i=0;i<heapCount;i++) { if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if a heap is found*/ if(position!=-1) { /*heap or object found.*/ /*Depending on the number of objects present take action*/ switch(heaps[position].count) { /*If criteria is satisfied then drop the object*/ case 1: if(flag==1) { if((computeDistanceBetween2(a->data,data[heaps[position].objects[0]])*1.0/Dmax)<Tcreate) dropObject1(a,position,flag); } else { if((computeDistanceBetween2(a->data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) dropObject1(a,position,flag); } break; default: if(computeDistanceBetween2(a->data,heaps[position].Ocenter)<computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)) dropObject1(a,position,flag); break; } } else { /*Compute the probability to drop the object*/ Pdrop1 = lrand48()%151*1.0/150; if(Pdrop1<Pdrop) dropObject(a,flag); } }//end of function /********************************************************************/ /* Function to move the ant */ /* Output: none */ /* Input: Ant, iteration flag */ /********************************************************************/ void move(ant* a,int flag) { float pDir; /*Check the speed */ if (a->speed!=0) { /*move in the same direction*/ a->speed--; moveNext(a,flag); } else { /*generate the new direction*/ pDir=lrand48()%17*1.0/16.0; if(pDir<.85) { a->dir=lrand48()%8; } else if(pDir>.95) { a->speed=2; } moveNext(a,flag); } } /********************************************************************/ /* Function to simulate the movement of the ants */ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified: minHeapCount, minHeapPosition */ /********************************************************************/ void iterate(int flag) { int i=0,j=0,k=0,loopCount=0; if (flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS; while (i<MAXITERATIONS) { i++; for(j=0;j<loopCount;j++) { move(&ants[j],flag); if(ants[j].carrying==1) { drop(&ants[j],flag); } else { pick(&ants[j],flag); } } if(debugLevel>0){ for(k=0;k<heapCount;k++) for(j=0;j<heapCount;j++) if((k!=j)&&(heaps[k].x==heaps[j].x)&&(heaps[k].y==heaps[j].y)) { printf("\nerror two heaps with same co ordinates %d %d ",k,j); //getchar(); } k=0; for(j=0;j<heapCount;j++) k+=heaps[j].count; } if(heapCount<minHeapCount) { minHeapCount=heapCount; minPosition=i; } if(debugLevel>0) printf("\n i:%d Heap count %d sum %d",i,heapCount,k); else printf("\n i:%d Heap count %d",i,heapCount); heapSum+=heapCount; /*if(i%updateAfter==0) {adjustBoard(flag); writeIncremental(i,flag);heapSum=0;loopCount=currentAntCount; }*/ } }//end of function /********************************************************************/ /*Function to drop the objects carried by the ants after all the iterations*/ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified:none */ /********************************************************************/ void dropFinal(int flag) { int i=0,j=0,position=-1,loopCount=0; /*if(flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS;*/ loopCount=currentAntCount; for(i=0;i<loopCount;i++) { if(ants[i].carrying==1) { if(flag==1) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position,flag); } } else { /*Find if a heap is present */ do { position=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position,flag); position=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position!=-1); } } } }//end of function /********************************************************************/ /* Function for the implementation of QuickSort */ /* Output: none */ /* Input: data structure, low and high indices */ /* Global structure modified:none */ /********************************************************************/ void quickSort( heap A[], int low,int high ) { int mid=0; if(low<high) { mid=partition(A,low,high); quickSort(A,low,mid); quickSort(A,mid+1,high); } } /********************************************************************/ /* Partition routine used by quick sort */ /* Output: partition location */ /* Input: data , low, high */ /* Global structure modified:none */ /********************************************************************/ int partition(heap a[], int low,int high) { heap temp; int x=0,i=0,j=0; i=low; j=high; x=a[low].count; while (1) { while (a[j].count<x) j=j-1; while (a[i].count>x) i=i+1; if(i<j) { temp=a[i]; a[i]=a[j]; a[j--]=temp; } else return(j); } } /********************************************************************/ /* Function used to write the cluster information */ /* Output: none */ /* Input:iteration flag */ /* Global structure modified:none */ /********************************************************************/ void writeClusterInformation(int flag) { FILE *fp=fopen("center.clt","w"); FILE *fp1; FILE *fp2; FILE *fp3; char temp[80]; int i=0,j=0,k=0; int lastCount=0; int rowCount,colCount,antCount; strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp3=fopen(temp,"a"); if(dataDump) {strcpy(temp,"");sprintf(temp,"%sTot.out",filename);fp1=fopen(temp,"a");strcpy(temp,"");sprintf(temp,"%sObj.out",filename);fp2=fopen(temp,"a");if(fp1==NULL||fp2==NULL)printf("\n Error in opening file in the writer Cluster Information routine\n"); } /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; antCount=MAXANTS; } else { rowCount=heapRow; colCount=heapRow; antCount=MAXANTSFORHEAPS; }*/ rowCount=currentRow; colCount=currentRow; antCount=currentAntCount; if(fp==NULL) { printf("\n Unable to open cluster center output file \n"); /*return;*/ exit(0); } /*sort the array according to the count value and write the value of the top three elements*/ if((flag==1)&&(!EntireHeaps)) quickSort(heaps,0,heapCount); if(EntireHeaps) {if(flag==1) lastCount=heapCount;else lastCount=newHeapCount; } else lastCount=c; for(i=0;i<lastCount;i++) { if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",newHeaps[i].Ocenter[k]); fprintf(fp,"\n"); } else { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); fprintf(fp,"\n"); } } if(dataDump) { fprintf(fp1,"\n Information from the Ant Based Algorithm \n"); fprintf(fp1,"\n Important Parameters : Board %d X %d Ants : %d Iterations %d Total Heaps %d ",rowCount,colCount,antCount,MAXITERATIONS,lastCount); } if(flag==0) { if(dataDump) { fprintf(fp1," TCreateForHeaps %f \n",TcreateForHeaps); fprintf(fp2,"\nTotal Heaps : %d\n",heapCount); fprintf(fp2,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); } fprintf(fp3,"\n@ %d\n",lastCount); } else if(dataDump) fprintf(fp1,"\n");if(dataDump) { fprintf(fp1,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); for(i=0;i<lastCount;i++) if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp2,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); } fprintf(fp1," %5d\n",newHeaps[i].count); fprintf(fp2," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp1," %5d\n",heaps[i].count); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]); fprintf(fp1," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]); fprintf(fp1," %5d\n",heaps[i].count); }} if(flag==0) { if(dataDump) fprintf(fp1,"\n Objects in the heaps \n");for(i=0;i<newHeapCount;i++) { if(dataDump) fprintf(fp1,"\n\n Heap %d\n \n",i+1);fprintf(fp3,"# %d %d\n",i ,newHeaps[i].count); for(j=0;j<newHeaps[i].count;j++){ for(k=0;k<features;k++){ fprintf(fp3,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]); if(dataDump) fprintf(fp1,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]);} if(dataDump) fprintf(fp1,"\n"); fprintf(fp3,"\n"); } } } fclose(fp); fclose(fp3); if(dataDump) { fclose(fp1);fclose(fp2); }}//end of flie /********************************************************************/ /* Function to initialise the new heaps */ /* Output: none */ /* Input:new Heap structure */ /* Global structure modified:none */ /********************************************************************/ void initialiseNewHeaps(heap newHeaps[]) { int i=0,j=0; for(i=0;i<lCount;i++) { newHeaps[i].count=0; for(j=0;j<features;j++) newHeaps[i].Ocenter[j]=V[i][j]; newHeaps[i].x=heaps[i].x; newHeaps[i].y=heaps[i].y; } }//end of function /********************************************************************/ /* Function to initialise the new heaps */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ int findPosition(int i) { int j,position=0; for(j=1;j<lCount;j++) { if(U[j][i]>U[position][i]) position=j; } printf("\n Position %d ",position); return(position); }//end of function find position /********************************************************************/ /* Function to add object */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ void addObject(int object,heap * heapPosition) { heapPosition->objects[heapPosition->count]=object; heapPosition->count++; }//end of function add object /********************************************************************/ /* Function to harden the outputs obtained from fcm */ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/ void harden(heap newHeaps[]) { int i,heapPosition=-1,sum=0,j=0; /*initialise the new heaps*/ initialiseNewHeaps(newHeaps); for(i=0;i<count;i++) { heapPosition=findPosition(i); addObject(i,&newHeaps[heapPosition]); } /* To check for degenerate partitions*/ for(i=0;i<lCount;i++) { if(newHeaps[i].count==0){for(j=i;j<lCount-1;j++){newHeaps[j]=newHeaps[j+1];}lCount--;i--;} } newHeapCount=lCount; for(i=0;i<lCount;i++) computeHeapParameters(&newHeaps[i],1); if(debugLevel>0) { for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\n sum = %d",sum);} }//end of function/********************************************************************/ /* Function to initialize the initial parameters for the ant algorithm*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void init() { int i=0,j=0; for(i=0;i<MAXROWS;i++) for(j=0;j<MAXCOLS;j++) board[i][j]=-9; heapCount=0; newHeapCount=0; heapRow=0; minPosition=-1; minHeapCount=100000; for(i=0;i<MAXANTS;i++) { ants[i].carrying=-1; ants[i].x=-1; ants[i].y=-1; ants[i].speed=-1; ants[i].dir=-1; } } /********************************************************************/ /* Function to initialize the initial board */ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void initialiseBoard() { int i,j; for(i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; }/********************************************************************/ /* Function to harden the outputs obtained from fcm(2nd stage)*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: Cluster center , cluster center count*/ /********************************************************************/void harden1() { int i=0,heapPosition=-1; for(i=0;i<heapCount;i++) cenCount[i]=0; for(i=0;i<n;i++) { heapPosition=findPosition1(i); addObject1(i,heapPosition); } writeInfo(); }//end of function/********************************************************************/ /* Function to find to which class the object belongs */ /* Output: Class number */ /* Input: object position */ /* Global Structure Modified: None */ /********************************************************************/int findPosition1(int i) { int j,position=0; for(j=1;j<heapCount;j++) { if(U[j][i]>U[position][i]) position=j; } return(position); }//end of function find position/********************************************************************/ /* Function to Write the output of the hardened objects to file*/ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/void writeInfo(){int i=0,j=0,k=0;FILE *fp=fopen("fcm.out","a");if(fp==NULL){printf("\n Unable to open fcm output file \n");return;}fprintf(fp,"\n@ %d\n",heapCount);for(i=0;i<heapCount;i++){fprintf(fp,"# %d %d\n",i,cenCount[i]);for(j=0;j<cenCount[i];j++){for(k=0;k<s;k++)fprintf(fp,"%8.2f ",clsCen[i][j][k]/scale[k]+minInput[k]);fprintf(fp,"\n");}}fclose(fp);return;}/********************************************************************/ /* Function to add a object to a cluster (2nd stage) */ /* Output: none */ /* Input: object poistion , cluster position */ /* Global Structure Modified: Cluster object and cluster count*/ /*******************************************************************/void addObject1(int object,int heapPosition) { int k=0; for(k=0;k<features;k++) clsCen[heapPosition][cenCount[heapPosition]][k]=X[object][k]; cenCount[heapPosition]++; return; }//end of function add object/********************************************************************/ /* Function to read the original classification of objects */ /* Output: none */ /* Input: none */ /* Global Structure Modified: None */ /*******************************************************************/void readOrg(){int i=0,k=0;char temp[80];FILE *fp;//= fopen(dataname,"r");strcpy(temp,"");sprintf(temp,"%sFull.data",filename);fp=fopen(temp,"r");if(fp==NULL){printf("\n Unable to open full data input file ");exit(0);}for(i=0;i<n;i++){fscanf(fp,"%f ",&orgData[i][0]);for(k=1;k<s+1;k++)fscanf(fp,"%f ",&orgData[i][k]);}return;}// end of function/********************************************************************/ /* Function to classify the objects in different clusters */ /* Output: none */ /* Input: the cluster objects, the original classification, */ /* number of objects in the cluster,file to write the data */ /* Global Structure Modified: None *//********************************************************************/int analysisData(float data[][s],float orgData[n][s+1],int count,FILE * fp){int i=0,j=0,k=0,type=1,max=0;heapInfo info;for(i=0;i<c;i++){info.classObj[i]=0;}info.total=0;info.total=count;for(i=0;i<count;i++)for(j=0;j<n;j++){type=1;for(k=0;k<s;k++)if(fabs(data[i][k]-orgData[j][k+1])>errThresh){type=-1;break;}if(type!=-1){info.classObj[(int)orgData[j][0]-1]++;break;}}max=0;for(k=0;k<c;k++){if(info.classObj[k]>info.classObj[max])max=k;fprintf(fp,"\nClass %d Objects % d ",k+1,info.classObj[k]);}j=0;for(k=0;k<c;k++){if(k!=max)j+=info.classObj[k];}fprintf(fp,"\n Total errors : %d \n",j);return(j);}//end of analyse/********************************************************************/ /* Function to read the cluster information */ /* Output: none */ /* Input: input file pointer , output file pointer */ /* Global Structure Modified: None *//********************************************************************/void readFCM(FILE* fp,FILE *fp1){int i=0,j=0,k=0,l=0;int totalRuns=0,heapCount=0,junk=0,sum=0;char ch;FILE *fp2=fopen("errors.out","a");ch = 'c'; while (ch != '$') fscanf (fp, "%c", &ch);fscanf(fp,"%d\n",&totalRuns);printf("\n total runs %d ",totalRuns);for(l=0;l<totalRuns;l++){fscanf(fp,"%c",&ch);fscanf(fp,"%d\n",&heapCount);fprintf(fp1,"\n \nExperiment %d \n ",l+1);sum=0;for(i=0;i<heapCount;i++){fscanf(fp,"%c",&ch);fscanf(fp," %d %d\n",&junk,&clsCenCount[i]);for(j=0;j<clsCenCount[i];j++)for(k=0;k<s;k++)fscanf(fp,"%f",&fcmData[i][j][k]);fscanf(fp,"\n");fprintf(fp1,"\n\n Heap %d Total Objects %d \n",i+1,clsCenCount[i]);sum+=analysisData(fcmData[i],orgData,clsCenCount[i],fp1);}fprintf(fp2," %3d %3d %3d \n",l,sum,heapCount);}fprintf(fp2,"\n --------------------------\n");fclose(fp2);return;}//end of function/********************************************************************/ /* Function to update the board parameters */ /* Output: none */ /* Input: none */ /* Global Structure Modified: board size, ant count *//********************************************************************/void adjustBoard(int flag){int newRow=0,newAnt=0,antDiff=0,antsKilled=0,i=0,position[MAXANTS],position1=-1,j=0,k=0,a,b; newRow= (int)ceil(sqrt(4.0*heapSum/updateAfter)); newAnt= (int)ceil((heapSum*1.0/updateAfter)*1.0/3.0); if(newAnt<minAnts)newAnt=minAnts; if(newRow<rowMin)newRow=rowMin;antDiff=currentAntCount-newAnt; if((antDiff>0)&&(newAnt>=minAnts)) {for(i=0;i<currentAntCount;i++){if(ants[i].carrying==-1){position[antsKilled++]=i;}} if(antsKilled>=antDiff){for(i=0;i<antDiff;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1];for(k=i+1;k<antsKilled;k++)position[k]--; } currentAntCount=newAnt; }else {for(i=0;i<antsKilled;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1]; for(k=i+1;k<antsKilled;k++)position[k]--; }if(flag==1) { for(i=currentAntCount-1,k=0;k<antDiff-antsKilled;k++,i--) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position1,flag); }else { dropObject(&ants[i],flag); } } } else { //flag is zero 2nd stage /*Find if a heap is present */ do { position1=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position1].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position1,flag); position1=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position1!=-1); }//end else currentAntCount=newAnt;}//end elsecurrentAntCount=newAnt;}//end iffor(i=0;i<newAnt;i++){if((ants[i].x>=newRow)||(ants[i].y>=newRow)) { a=lrand48()%newRow; b=lrand48()%newRow; ants[i].x=a; ants[i].y=b; }} //Done with ants, now adjust the boardif((currentRow>newRow)&&(newRow>=rowMin)){for(i=0;i<heapCount;i++){if((heaps[i].x>=newRow)||(heaps[i].y>=newRow)) {do { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionheaps[i].x=a;heaps[i].y=b;board[a][b]=9;}//end if}//end for for(i=0;i<currentAntCount;i++){if((ants[i].carrying==1)&&((ants[i].x>=newRow)||(ants[i].y>=newRow))){//adjust the ant locationdo { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionants[i].x=a;ants[i].y=b;}//end if}//end for currentRow=newRow;}//end if }//end of function void writeIncremental(int iteration,int flag){FILE *fp=fopen("dump.txt","w");int i=0,j=0,k=0;fprintf(fp,"Stage %d\n",flag);fprintf(fp,"Board %d\n",currentRow);fprintf(fp,"Ants %d\n",currentAntCount);fprintf(fp,"Iteration %d\n",iteration);fprintf(fp,"Heaps %d\n",heapCount); if(flag==0)fprintf(fp,"NewHeapCount %d\n",newHeapCount); fprintf(fp,"Ants\n");for(i=0;i<currentAntCount;i++){fprintf(fp,"%d %d %d %d %d ",ants[i].x,ants[i].y,ants[i].carrying,ants[i].speed,ants[i].dir);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",ants[i].data[k]);fprintf(fp,"\n");}fprintf(fp,"Heaps\n");for(i=0;i<heapCount;i++){fprintf(fp,"%d %d %d %d %8.2f %8.2f \n",heaps[i].x,heaps[i].y,heaps[i].count,heaps[i].disPosition,heaps[i].Dmax,heaps[i].Dmean);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Ocenter[k]);fprintf(fp,"\n");for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Odissim[k]);fprintf(fp,"\n");if(flag==1){for(j=0;j<heaps[i].count;j++)fprintf(fp,"%d ",heaps[i].objects[j]);fprintf(fp,"\n");}}if(flag==0){fprintf(fp,"newHeaps\n");for(i=0;i<newHeapCount;i++){fprintf(fp,"%d\n",newHeaps[i].count);for(j=0;j<newHeaps[i].count;j++)fprintf(fp,"%d ",newHeaps[i].objects[j]);fprintf(fp,"\n");}}fclose(fp);}//end of function/********************************************************************/ /* Function Main */ /********************************************************************/ int main(int argc ,char** argv) { int sum=0,k=0,i=0,j=0; char temp[80]; FILE *fp=fopen("fcm.out","w"); FILE *fp1; FILE *fp2=fopen("antAnalysis.out","a"); FILE *fp3=fopen("fcmAnalysis.out","a"); FILE *fp4=fopen("errors.out","w"); FILE *fp5; fclose(fp4); sprintf(temp,"%sObj.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sTot.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp1=fopen(temp,"w"); fprintf(fp,"\n$%d",EXPRUN); fprintf(fp1,"\n$%d",EXPRUN); fclose(fp); fclose(fp1); if(argc==2)sscanf(argv[1],"%d",&debugLevel); printf("\n Debug level %d\n",debugLevel); for( i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; //Read from the file readInput(); //Compute the distance of all the points if(maxDist) { Dmax=computeDistance(); //Compute the maximum distance fp5=fopen("maxData.txt","w");fprintf(fp5,"%f",Dmax);fclose(fp5); } else {fp5=fopen("maxData.txt","r");fscanf(fp5,"%f",&Dmax);fclose(fp5); } printf("\n %f \n",Dmax); //Initialise the board for(k=0;k<EXPRUN;k++) { init(); sum=0; srand48(state1[k]); initialiseBoard(); initialise(1); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(1); printf("\n %d \n",heapCount); //Simulate the working of ants iterate(1); //drop the objects after all the iterations dropFinal(1); //to verify the correctness for(i=0;i<heapCount;i++) sum+=heaps[i].count; //write the cluster centers to the file writeClusterInformation(1); printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); //getchar(); //Run FCM // heapCount=2973;/* To be commented */ printf("\n\n k %d \n\n",k); Fcm(data); //compute new board size. lCount=heapCount; heapRow=(int)ceil(sqrt(4*heapCount)); newHeapCount=lCount; printf("\n LCount %d newHeapCount %d heap Row %d \n",lCount,newHeapCount,heapRow); //harden the objects harden(newHeaps); //iterate with the heaps as the objects. initialiseBoard(); initialise(0); for(i=0;i<lCount;i++) computeHeapParameters(&heaps[i],0); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(0); printf("\n %d \n",heapCount); //getchar(); //Simulate the working of ants iterate(0); dropFinal(0); writeClusterInformation(0); sum=0; for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); // getchar(); Fcm(data); harden1(); } fp=fopen("fcm.out","a"); fp1=fopen(temp,"a"); fprintf(fp,"\n"); fprintf(fp1,"\n"); fclose(fp); fclose(fp1); fp=fopen("fcm.out","r"); fp1=fopen(temp,"r");printf("\n Before read org\n");readOrg();printf("\nafter read org\n");readFCM(fp1,fp2);printf("\n After 1st read fcm\n");readFCM(fp,fp3);printf("\n After 2 fcm read \n");return(1); }//end of main /****************************************************************/ float NORM(feature , feature); void find_covar(); void Fcm (irisData Data[MAXDATA]) { int i,j,l; FILE *ofile; char temp[80]; int flag=0;//added by parag FILE *iniClsCen=fopen("center.clt","a+"); if(iniClsCen==NULL) { printf("\n Unable to open the initial cluster center file\n"); printf("\n choosing random cluster centers....\n"); flag=1; } strcpy(temp,""); sprintf(temp,"%s.data",filename); strcpy (fname,temp); /* Read from this file */ m=2.0; /* The exponent */ /*GET_INPUTS1(fname);*/ /* read in feature vectors */ for (j=0; j<n ; j++) /* Read File in row-major */ for (i=0; i<s ; i++) /* format */ X[j][i]=Data[j][i]; Random_seed=state1[run];/*randseed*/ srand48(Random_seed); for (run=0;run<TOTRUNS;run++) { //flag=1;//for testing random values if (EntireHeaps) lCount=heapCount; else lCount=c; for(i=0;i<lCount;i++) for(j=0;j<s;j++) V[i][j]=0; for(i=0;i<lCount;i++) { for(l=0;l<s;l++) { if(flag==1) { rand_index = lrand48() % n; V[i][l] = X[rand_index][l]; } else { fscanf(iniClsCen,"%f ",&V[i][l]); } }//end for } eps=0.001; stop = FALSE; /* This loop finds the final cluster center and the corresponding U values */ z = 0; while (stop == FALSE) { z++; UMAT(U,V,X); /** Update the U matrix **/ stop = FINISHED(U1,eps); CLUSTER(U,X); /** Get new cluster center **/ printf("Iteration: %d\n\n", z); } /* end while */ printf("Number of iterations: %d\n\n", z);strcpy(temp,""); sprintf(temp,"%sFCM.out",filename);if(dataDump) Output(temp); /* output the results */ }/*end for*/ if(dataDump) { ofile=fopen(temp,"a"); for (i=0; i <= mins; i++) fprintf(ofile, "Min %d of %10.3f occurred %d times\n", i, mintab[i], mincount[i]); fprintf(ofile, "Average iterations %f\n", (float)aveit/(float)TOTRUNS); fclose(ofile); } }/* end Main */ /* The GET_INPUTS1 procedure opens an input file, reads the number of input vectors, the number of features per vector, the number of clusters, and epsilon, then it reads the input values */ void GET_INPUTS1(char fname[]) //char fname[]; { /* Parameters: fname -- name of file containing input info. */ FILE *infile ;//*fopen(); //char junk[10][80]; char realfname[80]; char ch; char fileName1[80]; //int temp[10], i, j, inputs, outputs, count; int i,j; sprintf (realfname, "%s", fname); /* open input file */ if(normalize==1) strcpy(fileName1,"gtest1.data"); else strcpy(fileName1,fname); if((infile = fopen (fileName1, "r")) == NULL) printf("\n CAN'T OPEN %s\n",realfname); else { ch = 'c'; /* Discard leading comments */ while (ch != '#') fscanf (infile, "%c", &ch); for (j=0; j<n ; j++) /* Read File in row-major */ { /* format */ for (i=0; i<s ; i++) fscanf (infile, "%f", &X[j][i]); /* fscanf (infile, "%d", &temp[1]); */ /* end for */ } /* end for */ fclose(infile); /* close input file */ }/* end else */ } /* end GET_INPUTS1 */ /* The NORM function computes the norm of two vectors, x and v, of dimension s. This gives an indication of the distance between them */ float NORM( feature x, feature v) //feature x, v; { /* Parameters : x -- a local copy of an input vector v -- a local copy of a cluster center */ int i,j; /* loop variable */ double sum; /* the square root of sum is the norm; sum is the sum of the differences squared */ float mat1[s]; float mat2[s]; if (maha) { for (i=0; i<s; i++) mat1[i]=x[i]-v[i]; for(i=0;i<s;i++) { sum =0; for(j=0;j<s;j++) sum += mat1[j] * inv_cov[j][i]; mat2[i] = sum; } sum =0; for(j=0;j<s;j++) sum += mat1[j]*mat2[j]; } else { sum = 0; for(j=0;j<s;j++) sum += (x[j] - v[j])* (x[j] - v[j]); } return (float)(sqrt(sum)); } /* end NORM */ /* The UMAT procedure calculates the updated U matrix according to Bezdek's formula. Its side-effect is the update of the global array U1 */ void UMAT( matrix U,center V, objects X) /*matrix U; center V; objects X;*/ { /* Parameters: U, V, and X: same as in main program */ int i, j, k,l ;/* loop variables *///, class /* class whose cluster center //is closest to pattern k */; float d1,d2,d; float sum; int exact; for (k=0;k<n;k++) { /*printf("\n k %d ",k);*/ exact=false; for (i=0;i<lCount;i++) { sum=0; for (j=0;j<lCount;j++) { d1=NORM(X[k],V[i]); d2=NORM(X[k],V[j]); if(d2!=0) { d= d1/d2; d= d * d;/* pow(d1/d2,2.0/(m-1.0)); */ sum+=d; } else { exact = true; for(l=0;l<lCount;l++) if (l==j) U1[l][k]=1.0; else U1[l][k]=0.0; break; } } if (exact!=true) U1[i][k]=1.0/sum; } } } /* end UMAT */ /* The function FINISHED determines if a termination occurs. If not it updates U with U1, so its side-effect is the potential modification of U */ BOOLEAN FINISHED( matrix U1,float eps) //matrix U1; float eps; { /* Parameters: U1, eps-- same as in main */ float sum; /* sum of squared differences between corresponding elements of U and U1 */ int i,k; /* loop control variabes */ BOOLEAN finished; /* set to true if all corresponding elements are within epsilon */ finished = TRUE; sum = 0; for (i=0; i<lCount; i++) for (k=0; k<n; k++) sum += (U[i][k] - U1[i][k])*(U[i][k]-U1[i][k]); if (sqrt(sum) > eps) { finished = FALSE; for (i=0; i<lCount; i++) for (k=0; k<n; k++) U[i][k] = U1[i][k]; } /* end if */ return finished; } /* end FINISHED */ /* The CLUSTER procedure determines cluster centers in V for the c classes being searched for. The global array V is updated */ void CLUSTER( matrix U, objects X) //matrix U; objects X; { /* Parameters: U, X -- as in main */ int i, j, k; /* loop control variables */ feature num; /* numerator in the cluster center computation formula presented by Bezdek */ float denum; /* denumenator in the obove formula */ for (i=0; i<lCount; i++) { denum = 0; for (j=0; j<s; j++) { num[j] = 0; for (k=0; k<n; k++) num[j] += U[i][k] * U[i][k] * X[k][j]; /* pow(U[i][k],m) * X[k][j]; */ } /* end for */ for (k=0; k<n; k++) denum += U[i][k] * U[i][k]; /* pow(U[i][k],m); */ for (j=0; j<s; j++) V[i][j] = num[j] / denum; } /* end for */ } /* end CLUSTER */ float Compute_Jm(center V, objects X) //center V; //objects X; { int i, k,found; double Jm_value; float u,dik; Jm_value = 0; for (k=0; k<n; k++) { found = FALSE; for (i=0; i<lCount; i++) { dik=NORM(X[k],V[i]); dik=dik*dik; if (dik==0.0) { if (found == FALSE) { u=1.0; found = TRUE; printf("found the case with dik=0\n"); } else { printf("\n cant proceed with this initialization"); exit(1); } } else { if (found != TRUE) u=U1[i][k]; /* get_Uvalue(V,X,dik,k); */ else u=0.0; } Jm_value += u * u * dik;/* pow(u, m) * dik; */ } } return (Jm_value); } /* end Compute_Jm */ /* The Output procedure outputs the U matrix which gives the fuzzy measure of each feature belonging to a cluster center. It also outputs the cluster center for each class */ void Output(char fname[]) //char fname[80]; /* Parameters: U, V -- same as in main */ { int i, j, found; /* loop control variables */ float J2c; if ((fp=fopen(fname,"a"))==NULL) printf("\n CAN'T OPEN %s\n",fname); else { fprintf(fp,"\n The cluster centers are: \n"); fprintf(fp,"\n \n"); for (i=0; i<lCount; i++) { fprintf(fp,"\nCluster center %d: ",i+1); fprintf(fp,"\n"); for (j=0; j<s; j++) fprintf(fp,"%8.7f ",V[i][j]); } /* end for */ fprintf(fp,"\nThe membership grades for the feature vectors are:\n"); for (j=0; j<n; j++) { fprintf(fp,"\n"); for (i=0; i<lCount; i++) fprintf(fp," %8.7f",U[i][j]); } /* end for */ } /* end if */ J2c= Compute_Jm(V,X); found =0; for (i=0;i<= mins; i++){ if ((found == 0) && ((J2c - mintab[i]) < .001) && ((J2c - mintab[i]) > -.001)){ mincount[i]++; found = 1; } } if (found == 0){ mins++; mintab[mins]=J2c; mincount[mins]=1; } fprintf(fp,"\nJ%3.1f = %f", m,J2c); fprintf(fp, "Number of iterations: %d\n\n", z); aveit=aveit + z; fclose(fp); } /***************************************************************/ void find_covar(int m) //int m; { int i,j,k; float mean[s],sum; for (i=0;i<s;i++) mean[i]=0; for (i=0;i<s;i++) for (j=0;j<m;j++) mean[i]+=X[j][i]; for (i=0;i<s;i++) mean[i]/=m; for (i=0;i<s;i++) for (j=0;j<s;j++) { sum=0; for (k=0;k<m;k++) sum+=(X[k][i]-mean[i])*(X[k][j]-mean[j]); Y[i][j]=sum/m; } }
Parag Kanade/fuzzy ants/Gauss2/headerStatic.h
/********************************************************************//* Ant Class parameters *//* SPEED # amplitude of moves [1,10] *//* P direction Probability to move in the same direction [.5,1] *//* Max carry : Maximum object carrying time [20,200] *//* P load Probability to pick up a single object [0.4,0.8] *//* P destroy probability to destroy a heap of two objects [0,0.6] *//* T remove min. dissimilarity necessary for removing an object *//* from a heap [.1,.2] *//* T create max dissimilarity permitted for creating a heap[.05,.2]*//********************************************************************/ #include <stdio.h>#include <math.h>#include <string.h>#include<stdlib.h>#include <ctype.h>#include <time.h>#define MAXANTS 334#define MAXDATA 1000#define MAXANTSFORHEAPS 90#define MAXITERATIONS 1000#define MAXROWS 64#define MAXCOLS 64#define EXPRUN 10#define Tremove 1.50#define Tcreate 0.5#define Pdrop 0.2#define Pdestroy 0.3#define Pload 0.3#define normalize 0#define EntireHeaps 1#define TcreateForHeaps 0.19#define features 2#define filename "gauss02"#define errThresh 0.1#define dataDump 1#define maxDist 1#define INITIALOBJECTS 75#define OBJINC 10/* some type definitions to make C code a little more readable */#define TRUE 1#define FALSE 0#define n MAXDATA /* number of input vectors */#define s features /* number of features */#define c 5 /* number of clusters */#define TOTRUNS 1 /* number of V's to write out */#define false 0#define true 1#define maha 0#define square 0extern int count;int debugLevel=0;/* To debug the code and verify the correctness of algorithms*/int currHeapCount=0;typedef int BOOLEAN;typedef short TYPE_IN_DATA; /* Type of input binary data */typedef float feature[s]; /* Type of each input; made up of input features */typedef float irisData[s];typedef feature objects[MAXDATA]; /* Type of array holding all inputs */typedef feature center[MAXDATA]; /* Type of array holding cluster centers */typedef float matrix[MAXDATA][MAXDATA];/* Type of the matrix containing membership grades */typedef struct Heap {float Dmax;//maximum dissimilar distanceirisData Ocenter;//center objectfloat Dmean;//mean of the distance between the center and all the objectsirisData Odissim;//most dissimilar objectint x;//x position on the boardint y;//y position on the boardint count;//number of objects in the heapsint disPosition;//most dissimilar objectint objects[MAXDATA];int objCount;}heap;typedef struct Ant{int x;int y;int carrying;int speed;int dir;irisData data;}ant;float orgData[n][s+1];float fcmData[MAXDATA][n][s];int clsCenCount[MAXDATA];int currentRow=0;int currentAntCount=0;int updateAfter=50;int heapSum=0;int minAnts=3;int rowMin=5;typedef struct HeapInfo{int total;int classObj[c];} heapInfo;/*heapInfo info[MAXDATA];*//********************************************************************//***Function decelarations*//********************************************************************//***For ant based algorithm*/void readInput();float computeDistance();float computeDistanceBetween2(irisData a,irisData b);float findMax(float *distance);float value(irisData a);int found(int a , int b);void initialise(int flag);int findObject(int a,int b);void initialiseAnts(int flag);void moveNext(ant* a,int flag);void computeHeapParameters(heap* data,int flag);void pickObject1(ant *a,int position,int flag);void pickObject2(ant *a , int position,int flag);void pickObjectn(ant *a,int position,int flag);void pick(ant *a,int flag);void dropObject(ant* a,int flag);int findInNewheaps(irisData object);void dropObject1(ant* a, int position,int flag);void drop(ant* a,int flag);void move(ant* a,int flag);void iterate(int flag);void dropFinal(int flag);int partition(heap a[], int low,int high);void quickSort( heap A[], int low,int high ) ;void writeClusterInformation(int flag);void initialiseNewHeaps(heap newHeaps[]);int findPosition(int i);void harden(heap newHeaps[]);void harden1();int findPosition1(int );void writeInfo();void addObject1(int ,int);void readFCM(FILE *,FILE *);void readOrg();int findInData(irisData input,int iflag);void adjustBoard(int flag);void writeIncremental(int iteration,int flag);/********************************************************************//***For FCM algorithm*/void GET_INPUTS1(char []);void UMAT( matrix,center,objects);BOOLEAN FINISHED(matrix, float);void CLUSTER( matrix, objects);void Output(char[]);void Fcm();/********************************************************************/
Parag Kanade/fuzzy ants/Gauss2/maxData.txt
1.801062
Parag Kanade/fuzzy ants/Iris/iris.c
#include "headerStatic.h" /*******************************************************************/ /*** Global Variables ***/ irisData data[MAXDATA]; //To hold the data read from the file int count=0; //Count of the total number of data elements int heapCount=0; // Total number of heaps int heapRow=0; // Rows for the second iteration with heaps int newHeapCount=0; // Count of the heaps for the second iteration heap heaps[MAXDATA]; // Data structure to hold the heap information heap newHeaps[MAXDATA]; // Data Structure to hold the new heap information // For the second iteration int board[MAXROWS][MAXCOLS]; // Board on which the objects are located ant ants[MAXANTS]; // Data structure to hold the ants float Dmax=0; // Distance of the most dissimilar object pair int minHeapCount=100000; // Counter to hold the minimum heap count, used only for academic purpose // no use in the algorithm int minPosition; // the minimum heap iteration , only for academic purpose // no use in the algorithm float clsCen[MAXDATA][MAXDATA][s];//to hold the objects after hardening int cenCount[MAXDATA];//to hold the number of objects after hardening /********************************************************************/ /*** Varaibles to normalize the features between 0 and 1 */ float minInput[features], maxInput[features],scale[features],minForHeaps[features],maxForHeaps[features],scaleForHeaps[features]; /********************************************************************/ /** Variables for the FCM algorithm */ int temp[200]; /* for square matrix tests */ float eps,m; matrix U, U1; BOOLEAN stop; center V; objects X; char fname[80]; FILE *fp; int run; float inv_cov[s+1][s+1]; /* inverse of covariance matrix Y */ float Y[s][s]; long rand_index, Random_seed; long state1[52] = { 9347, 3835, 5194, 8310, 346, 535, 5297, 6711, 77, 3834, 668, 4175, 6868, 5890, 9304, 8462, 5269, 920, 65392, 41600, 70119, 91032, 76220, 26245, 4746, 73608, 32823, 63264, 75641, 99104, 36534, 24704, 98255, 72266, 75336, 65152, 7269, 63163, 88471, 27271, 43641, 76649, 47773, 23777, 27491, 35926, 16651, 48652, 89766, 90921, 6056 }; int z; int mins=0; int aveit =0; float mintab[200]; int mincount[200]; long start,end,total; int lCount;//added by parag /********************************************************************/ /********************************************************************//*int lrand48(){return(rand());}void srand48(int a){return;}*//********************************************************************/ /********************************************************************/ /* Function to read the input data set */ /* The file name is assumed to be itest.data */ /* Status: Tested */ /* Output: Data from the file into the "data" (Global) data structure */ /* Output: Count (Global), the count of the number of objects */ /********************************************************************/ void readInput() { FILE *fp; char fname[80]; int i=0,j=0; char ch; sprintf(fname,"%s.data",filename); /* Check if the input file is opened */ if((fp=fopen(fname,"r"))==NULL) { printf("\n Unable to open input file \n"); exit(0); } /*initialise the minimum maximum and the scale */ for(i=0;i<features;i++) { minInput[i]=1000; maxInput[i]=0; minForHeaps[i]=1000; maxForHeaps[i]=0; scale[i]=0; scaleForHeaps[i]=0; } /* Discard leading comments */ ch = 'c'; while (ch != '#') fscanf (fp, "%c", &ch); i=0; /* Parse the file and populate the data structure */ while(!feof(fp)) { for(j=0;j<features;j++) { fscanf(fp,"%f ",&data[i][j]); } fscanf(fp,"\n"); for(j=0;j<features;j++) { if(data[i][j]<minInput[j]) minInput[j]=data[i][j]; if(data[i][j]>maxInput[j]) maxInput[j]=data[i][j]; } i++; } count=i; /* Normailze the feature values in between 0 and 1 */ for(j=0;j<features;j++) { if(minInput[j]!=maxInput[j]) scale[j]=1.0/(maxInput[j]-minInput[j]); else scale[j]=1.0; } for(i=0;i<count;i++) { for(j=0;j<features;j++) data[i][j]=(data[i][j]-minInput[j])*scale[j]; } fclose(fp); return; }//end of function /********************************************************************/ /*Function to compute the eucldiean distance for all input data set */ /* Output : an array conatining the distance of each object with the other */ /********************************************************************/ float computeDistance() { float distance,dist=0; int i=0,j=0,k=0; distance=0; for(j=0;j<count;j++) for(i=0;i<count;i++) { for(k=0;k<features;k++) dist+=sqrt((data[j][k]-data[i][k])*(data[j][k]-data[i][k])); if(distance<dist)distance=dist; dist=0; } return(distance); } /********************************************************************/ /* Function to compute the distance between two objects */ /* Output : Euclidean d istance between the two input objects */ /********************************************************************/ float computeDistanceBetween2(irisData a,irisData b) { float temp=0; int i=0; for(i=0;i<features;i++) temp+=(a[i]-b[i])*(a[i]-b[i]); temp=sqrt(temp); return(temp); } /********************************************************************/ /* Function to find the maximum distance between the input objects*/ /* Output: the maximum distance */ /* Input : The array of distances between objects */ /********************************************************************/ /*float findMax(float *distance) { int i=0,j=0; float max=distance[0]; for(i=0;i<count;i++) for(j=0;j<count;j++) { if(max<distance[i*count+j]) max=distance[i*count+j]; } return(max); }*/ /********************************************************************/ /* Function to compute the value of an object */ /********************************************************************/ float value(irisData a) { int i=0; float temp=0; for(i=0;i<features;i++) temp+=a[i]*a[i]; return(sqrt(temp)); } /********************************************************************/ /* Function to find the object in the data structure */ /* Output : The position of the object in the data */ /* Input : The object */ /********************************************************************/ int findInData(irisData object,int iFlag) { int i=0,lastCount=0,j,position=-1,flag[features],flg;if(iFlag==1)lastCount=MAXDATA;else{}for(i=0;i<lastCount;i++){ for(j=0;j<features;j++) if(fabs(object[j]-data[i][j])<0.00001) flag[j]=1; else { flag[j]=0; break;} flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /* Function to find whether there is an object on the board at a,b */ /* Output : a flag indicating whether an object is found or not */ /* Input : The row and column indicating the board position */ /********************************************************************/ int found(int a , int b) { if(board[a][b]==9) return 1; else return 0; } /********************************************************************/ /* Function to initialize the initial board */ /* Output : None */ /* Global Structures modified : heaps */ /* Input : Flag indicating the iteration 1: First 0: Second */ /********************************************************************/ void initialise(int flag) { int a,b,i=0,k=0; int loopCount,rowCount,colCount; /* Initialize the row, column and number of heaps */ if(flag==1) { loopCount=count; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=lCount; rowCount=heapRow; colCount=heapRow; } /* Initialize the heaps */ for(i=0;i<loopCount;i++) { heaps[i].count=0; heaps[i].x=0; heaps[i].y=0; heaps[i].disPosition=0; heaps[i].Dmax=0; heaps[i].Dmean=0; } for(i=0;i<loopCount;i++) { /*find a board position which is empty*/ do { a=lrand48()%rowCount; b=lrand48()%colCount; } while(found(a,b)); /*Allocate the object to that place and assign a heap to it*/ heaps[i].x=a; heaps[i].y=b; heaps[i].count=1; heaps[i].Dmax=0; heaps[i].Dmean=0; if(flag==1) { heaps[i].objects[0]=i; for(k=0;k<features;k++)heaps[i].Ocenter[k]=data[i][k]; } else { for(k=0;k<features;k++) heaps[i].Ocenter[k]=newHeaps[i].Ocenter[k]; } heaps[i].disPosition=0; board[a][b]=9; if((debugLevel>0)&&(flag==1))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],data[heaps[i].objects[0]][0]); if((debugLevel>0)&&(flag==0))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],newHeaps[i].Ocenter[0]); } /*initialise the initial heap count*/ heapCount=loopCount; currentRow=rowCount; } /********************************************************************/ /* Function to find whether an heap is present at the location a b */ /* Output : Flag indicating the presencs of the heap */ /* Input : Roe and column indicating the board position */ /********************************************************************/ int findObject(int a,int b) { int i; int position=-1; for(i=0;i<heapCount;i++) { if((heaps[i].x==a)&&(heaps[i].y==b)) { position=i; break; } } return(position); } /********************************************************************/ /* Function initialize the ants */ /* Output : None */ /* Input : Flag indicating the iteration */ /* Global Variables Modified : ant, heapCount, heaps, board */ /********************************************************************/ void initialiseAnts(int flag) { int i=0,a=0,b=0,position,j=0,loopCount=0,rowCount,colCount,k=0; if(flag==1) { loopCount=MAXANTS; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=MAXANTSFORHEAPS; rowCount=heapRow; colCount=heapRow; } for(i=0;i<loopCount;i++) { /*generate random positions for the ants*/ a=lrand48()%rowCount; b=lrand48()%colCount; ants[i].x=a; ants[i].y=b; /*Find if an object is present at that position or not*/ if(board[a][b]==9) { ants[i].carrying=1; /*find the heap at that location*/ position=findObject(a,b); if(position==-1) { printf("\n Error in logic: Ant init \n"); //getchar(); break; } else { /*Assign the heap data to the ant data and decrement the heap count*/ if(flag==1){ for(k=0;k<features;k++)ants[i].data[k]=data[heaps[position].objects[0]][k]; }else{for(k=0;k<features;k++)ants[i].data[k]=heaps[position].Ocenter[k];} for(j=position;j<heapCount-1;j++) heaps[j]=heaps[j+1]; heapCount--; } /*Clear the board position */ board[a][b]=-9; } else ants[i].carrying=-1; ants[i].speed=0; ants[i].dir=lrand48()%8; printf("\n Ant %2d X: %2d Y: %2d Carying : %2d ",i,ants[i].x,ants[i].y,ants[i].carrying); } currentAntCount=loopCount; } /********************************************************************/ /* Function to move the ant */ /* Output: None */ /* Input: Ant to be moved and the flag indicating the iteration */ /********************************************************************/ void moveNext(ant* a,int flag) { int rowCount,colCount; /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; } else { rowCount=heapRow; colCount=heapRow; }*/rowCount=currentRow;colCount=currentRow; /*Depending upon the direction move the ant*/ switch (a->dir) { case 0: a->y++; if(a->y>=colCount)a->y=0; break; case 1: a->x--; a->y++;; if(a->x<0)a->x=rowCount-1; if(a->y>=colCount)a->y=0; break; case 2: a->x--; if(a->x<0)a->x=rowCount-1; break; case 3: a->x--; a->y--; if(a->x<0)a->x=rowCount-1; if(a->y<0)a->y=colCount-1; break; case 4: a->y--; if(a->y<0)a->y=colCount-1; break; case 5: a->x++; a->y--; if(a->x>=rowCount)a->x=0; if(a->y<0)a->y=colCount-1; break; case 6: a->x++; if(a->x>=rowCount) a->x=0; break; case 7: a->x++; a->y++; if(a->x>=rowCount)a->x=0; if(a->y>=colCount)a->y=0; break; } }//end of function /********************************************************************/ /* Function to compute the parameters of the heap */ /* Output: None */ /* Input: The heap whose parameters are to be computed iteration flag*/ /********************************************************************/ void computeHeapParameters(heap* heapData,int flag) { int i=0,j=0,k=0,position=0; float distance=0; float Dmean=0.0; float *dis; float featureSum[features]; float max=0; float sum=0; /* init*/ for(k=0;k<features;k++) featureSum[k]=0; /*Compute the distance of each object and find the maximum distance*/ max=0; if(flag==1){ for(j=0;j<heapData->count;j++) for(i=0;i<heapData->count;i++) { for(k=0;k<features;k++) sum+= (data[heapData->objects[j]][k]-data[heapData->objects[i]][k])*(data[heapData->objects[j]][k]-data[heapData->objects[i]][k]); distance=sqrt(sum); if(max<distance) max=distance; sum=0; } /* Assign the maximum distance to the heap */ heapData->Dmax=max;/*Compute the centre object*/for(i=0;i<heapData->count;i++)for(k=0;k<features;k++) featureSum[k]+=data[heapData->objects[i]][k];for(k=0;k<features;k++)heapData->Ocenter[k]=featureSum[k]*1.0/heapData->count; /* Find the mean distance */if((dis=(float *) calloc(heapData->count,sizeof(float)))==NULL){printf("\nUnable to allocate memory in the compute heap parameters procedure\n");exit(0);} for(i=0;i<heapData->count;i++) { Dmean+=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); dis[i]=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); } heapData->Dmean=Dmean*1.0/heapData->count; /*Compute the most dissimilar object*/ max=dis[0]; for(i=1;i<heapData->count;i++) if(max<dis[i]) { max=dis[i]; position=i; } /*Assign the most dissimilar object to the heap variable*/ for(k=0;k<features;k++) heapData->Odissim[k]=data[heapData->objects[position]][k]; heapData->disPosition=position;free(dis); } else{/* Heap Parameters for the second stage */for(k=0;k<features;k++){ heapData->Odissim[k]=heapData->Ocenter[k];}heapData->disPosition=0;heapData->Dmean=0;heapData->Dmax=0;} }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a single object*/ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject1(ant *a,int position,int flag) { int i,k=0; /*Clear the board*/ board[heaps[position].x][heaps[position].y]=-9; /* Assign the data to the ant*/if(flag==1){ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[0]][k];}else {for(k=0;k<features;k++) a->data[k]=heaps[position].Ocenter[k];} a->carrying=1; /*Copy all the heaps remaining heaps in the structure*/ for(i=position;i<heapCount-1;i++) heaps[i]=heaps[i+1]; /*Decrement the heap count*/ heapCount--; }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a two objects */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject2(ant *a , int position,int flag) { float Pdestroy1=-1; int i=0,k=0; /*Compute the probability to destroy the heap*/ Pdestroy1=lrand48()%13*1.0/12.0; /*If the probability is more than Pdestroy then destroy the heap */ if(Pdestroy1<Pdestroy) { /*pick the object randomly*/ i=lrand48()%2; /* Assign the data to the ant */ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[i]][k]; a->carrying=1; /*Correct the heap parameters*/ heaps[position].count=1; heaps[position].objects[0]=heaps[position].objects[1-i]; computeHeapParameters(&heaps[position],flag); } }//end of function /********************************************************************/ /*Function to pick a object from a heap consisting of more than two object */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /********************************************************************/ void pickObjectn(ant *a,int position,int flag) { int i=0,k=0; /*If the criteria is satsfied then pick the object*/ if((computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)*1.0/heaps[position].Dmean)>Tremove) { a->carrying=1; for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[heaps[position].disPosition]][k]; for(i=heaps[position].disPosition;i<heaps[position].count-1;i++) heaps[position].objects[i]=heaps[position].objects[i+1]; heaps[position].count--; computeHeapParameters(&heaps[position],1); } }//end of function /********************************************************************/ /* Function to pick a object */ /********************************************************************/ void pick(ant *a,int flag) { int position=-1,i=0; float Pload1=-1.0; for(i=0;i<heapCount;i++) { /*Check if a heap is present in the eight neighbouring cells*/ if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if Heap is found*/ if(position!=-1) { /* heap or object found.*/ /*Depending upon the number present in the heap call the corresponding routine*/ switch(heaps[i].count) { case 1: Pload1 = lrand48()%151*1.0/150.0; if(Pload1<Pload) { pickObject1(a,position,flag); } break; case 2: pickObject2(a,position,flag); break; default: pickObjectn(a,position,flag); break; } } } /********************************************************************/ /* Function to drop a object to form a new heap */ /* Output: None */ /* Input: Ant, iteration flag */ /* Global Structure modified : heap, heapCount */ /********************************************************************/ void dropObject(ant* a,int flag) { /*Create a new heap*/ int k=0; heaps[heapCount].count=1; heaps[heapCount].x=a->x; heaps[heapCount].y=a->y; heaps[heapCount].Dmax=0; heaps[heapCount].Dmean=0; heaps[heapCount].disPosition=0; for(k=0;k<features;k++) { heaps[heapCount].Odissim[k]=a->data[k]; heaps[heapCount].Ocenter[k]=a->data[k]; } if(flag==1) {heaps[heapCount].objects[0]=findInData(a->data,flag); /*computeHeapParameters(&heaps[heapCount],flag);*/ } computeHeapParameters(&heaps[heapCount],flag); heapCount++; a->carrying=-1; board[a->x][a->y]=9; }//end of function /********************************************************************/ /* Function to find the heap position during the second iteration */ /* Output: position of the heap */ /* Input: object center of the heap that the ant is carrying */ /* Global Structure modified : none */ /********************************************************************/ int findInNewheaps(irisData object) { int position=-1,i,j=0,flag[features],flg; for(i=0;i<newHeapCount;i++) { for(j=0;j<features;j++) { if(fabs(object[j]-newHeaps[i].Ocenter[j])<0.00001) flag[j]=1; else {flag[j]=0;break;} } flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /*Function to drop a object to a heap consisting of a one or more object */ /* Output: none */ /* Input: Ant, position of the heap , iteration flag */ /* Global Structure modified: heaps,newHeaps */ /********************************************************************/ void dropObject1(ant* a, int position,int flag) { int heapPosition=-1,heapPosition1=-1,i,j,k=0; irisData newData,temp; if(flag==1) { /*Add the object to the heap and compute the heap parameters*/ /*if(heaps[position].count==heaps[position].objCount) {if((junk=(int *)realloc(heaps[position].objects,((heaps[position].objCount+OBJINC)*sizeof(int))))==NULL){printf("\n Cannot Allocate memory to the new object for %d heap",position);exit(0);}heaps[position].objects=junk;heaps[position].objCount+=OBJINC;free(junk); }*/ heaps[position].objects[heaps[position].count]=findInData(a->data,flag); heaps[position].count++; computeHeapParameters(&heaps[position],flag); } else { for(k=0;k<features;k++)temp[k]=heaps[position].Ocenter[k]; heapPosition=findInNewheaps(a->data); heapPosition1=findInNewheaps(heaps[position].Ocenter); if(heapPosition==-1||heapPosition1==-1) { printf("\n error in logic:new heaps\n"); //getchar(); return; } for(k=0;k<features;k++) {newData[k]=(newHeaps[heapPosition].Ocenter[k]*newHeaps[heapPosition].count+newHeaps[heapPosition1].Ocenter[k]*newHeaps[heapPosition1].count)*1.0/(newHeaps[heapPosition].count+newHeaps[heapPosition1].count);newHeaps[heapPosition].Ocenter[k]=newData[k];heaps[position].Ocenter[k]=newData[k]; } computeHeapParameters(&heaps[position],flag); for(i=newHeaps[heapPosition].count,j=0;j<newHeaps[heapPosition1].count;i++,j++) { newHeaps[heapPosition].objects[i]=newHeaps[heapPosition1].objects[j]; } newHeaps[heapPosition].count+=newHeaps[heapPosition1].count; for(i=heapPosition1;i<newHeapCount-1;i++) newHeaps[i]=newHeaps[i+1]; newHeapCount--; } a->carrying=-1; }//end of function /********************************************************************/ /* Function to drop a object */ /* Output: None */ /* Input: Ant, iteration flag */ /********************************************************************/ void drop(ant* a,int flag) { int i, position=-1; float Pdrop1=0.0; /*Find whether we have a heap in the neighbourhood of the cell*/ for(i=0;i<heapCount;i++) { if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if a heap is found*/ if(position!=-1) { /*heap or object found.*/ /*Depending on the number of objects present take action*/ switch(heaps[position].count) { /*If criteria is satisfied then drop the object*/ case 1: if(flag==1) { if((computeDistanceBetween2(a->data,data[heaps[position].objects[0]])*1.0/Dmax)<Tcreate) dropObject1(a,position,flag); } else { if((computeDistanceBetween2(a->data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) dropObject1(a,position,flag); } break; default: if(computeDistanceBetween2(a->data,heaps[position].Ocenter)<computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)) dropObject1(a,position,flag); break; } } else { /*Compute the probability to drop the object*/ Pdrop1 = lrand48()%151*1.0/150; if(Pdrop1<Pdrop) dropObject(a,flag); } }//end of function /********************************************************************/ /* Function to move the ant */ /* Output: none */ /* Input: Ant, iteration flag */ /********************************************************************/ void move(ant* a,int flag) { float pDir; /*Check the speed */ if (a->speed!=0) { /*move in the same direction*/ a->speed--; moveNext(a,flag); } else { /*generate the new direction*/ pDir=lrand48()%17*1.0/16.0; if(pDir<.85) { a->dir=lrand48()%8; } else if(pDir>.95) { a->speed=2; } moveNext(a,flag); } } /********************************************************************/ /* Function to simulate the movement of the ants */ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified: minHeapCount, minHeapPosition */ /********************************************************************/ void iterate(int flag) { int i=0,j=0,k=0,loopCount=0; if (flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS; while (i<MAXITERATIONS) { i++; for(j=0;j<loopCount;j++) { move(&ants[j],flag); if(ants[j].carrying==1) { drop(&ants[j],flag); } else { pick(&ants[j],flag); } } if(debugLevel>0){ for(k=0;k<heapCount;k++) for(j=0;j<heapCount;j++) if((k!=j)&&(heaps[k].x==heaps[j].x)&&(heaps[k].y==heaps[j].y)) { printf("\nerror two heaps with same co ordinates %d %d ",k,j); //getchar(); } k=0; for(j=0;j<heapCount;j++) k+=heaps[j].count; } if(heapCount<minHeapCount) { minHeapCount=heapCount; minPosition=i; } if(debugLevel>0) printf("\n i:%d Heap count %d sum %d",i,heapCount,k); else printf("\n i:%d Heap count %d",i,heapCount); heapSum+=heapCount; /*if(i%updateAfter==0) {adjustBoard(flag); writeIncremental(i,flag);heapSum=0;loopCount=currentAntCount; }*/ } }//end of function /********************************************************************/ /*Function to drop the objects carried by the ants after all the iterations*/ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified:none */ /********************************************************************/ void dropFinal(int flag) { int i=0,j=0,position=-1,loopCount=0; /*if(flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS;*/ loopCount=currentAntCount; for(i=0;i<loopCount;i++) { if(ants[i].carrying==1) { if(flag==1) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position,flag); } } else { /*Find if a heap is present */ do { position=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position,flag); position=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position!=-1); } } } }//end of function /********************************************************************/ /* Function for the implementation of QuickSort */ /* Output: none */ /* Input: data structure, low and high indices */ /* Global structure modified:none */ /********************************************************************/ void quickSort( heap A[], int low,int high ) { int mid=0; if(low<high) { mid=partition(A,low,high); quickSort(A,low,mid); quickSort(A,mid+1,high); } } /********************************************************************/ /* Partition routine used by quick sort */ /* Output: partition location */ /* Input: data , low, high */ /* Global structure modified:none */ /********************************************************************/ int partition(heap a[], int low,int high) { heap temp; int x=0,i=0,j=0; i=low; j=high; x=a[low].count; while (1) { while (a[j].count<x) j=j-1; while (a[i].count>x) i=i+1; if(i<j) { temp=a[i]; a[i]=a[j]; a[j--]=temp; } else return(j); } } /********************************************************************/ /* Function used to write the cluster information */ /* Output: none */ /* Input:iteration flag */ /* Global structure modified:none */ /********************************************************************/ void writeClusterInformation(int flag) { FILE *fp=fopen("center.clt","w"); FILE *fp1; FILE *fp2; FILE *fp3; char temp[80]; int i=0,j=0,k=0; int lastCount=0; int rowCount,colCount,antCount; strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp3=fopen(temp,"a"); if(dataDump) {strcpy(temp,"");sprintf(temp,"%sTot.out",filename);fp1=fopen(temp,"a");strcpy(temp,"");sprintf(temp,"%sObj.out",filename);fp2=fopen(temp,"a");if(fp1==NULL||fp2==NULL)printf("\n Error in opening file in the writer Cluster Information routine\n"); } /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; antCount=MAXANTS; } else { rowCount=heapRow; colCount=heapRow; antCount=MAXANTSFORHEAPS; }*/ rowCount=currentRow; colCount=currentRow; antCount=currentAntCount; if(fp==NULL) { printf("\n Unable to open cluster center output file \n"); /*return;*/ exit(0); } /*sort the array according to the count value and write the value of the top three elements*/ if((flag==1)&&(!EntireHeaps)) quickSort(heaps,0,heapCount); if(EntireHeaps) {if(flag==1) lastCount=heapCount;else lastCount=newHeapCount; } else lastCount=c; for(i=0;i<lastCount;i++) { if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",newHeaps[i].Ocenter[k]); fprintf(fp,"\n"); } else { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); fprintf(fp,"\n"); } } if(dataDump) { fprintf(fp1,"\n Information from the Ant Based Algorithm \n"); fprintf(fp1,"\n Important Parameters : Board %d X %d Ants : %d Iterations %d Total Heaps %d ",rowCount,colCount,antCount,MAXITERATIONS,lastCount); } if(flag==0) { if(dataDump) { fprintf(fp1," TCreateForHeaps %f \n",TcreateForHeaps); fprintf(fp2,"\nTotal Heaps : %d\n",heapCount); fprintf(fp2,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); } fprintf(fp3,"\n@ %d\n",lastCount); } else if(dataDump) fprintf(fp1,"\n");if(dataDump) { fprintf(fp1,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); for(i=0;i<lastCount;i++) if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp2,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); } fprintf(fp1," %5d\n",newHeaps[i].count); fprintf(fp2," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp1," %5d\n",heaps[i].count); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]); fprintf(fp1," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]); fprintf(fp1," %5d\n",heaps[i].count); }} if(flag==0) { if(dataDump) fprintf(fp1,"\n Objects in the heaps \n");for(i=0;i<newHeapCount;i++) { if(dataDump) fprintf(fp1,"\n\n Heap %d\n \n",i+1);fprintf(fp3,"# %d %d\n",i ,newHeaps[i].count); for(j=0;j<newHeaps[i].count;j++){ for(k=0;k<features;k++){ fprintf(fp3,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]); if(dataDump) fprintf(fp1,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]);} if(dataDump) fprintf(fp1,"\n"); fprintf(fp3,"\n"); } } } fclose(fp); fclose(fp3); if(dataDump) { fclose(fp1);fclose(fp2); }}//end of flie /********************************************************************/ /* Function to initialise the new heaps */ /* Output: none */ /* Input:new Heap structure */ /* Global structure modified:none */ /********************************************************************/ void initialiseNewHeaps(heap newHeaps[]) { int i=0,j=0; for(i=0;i<lCount;i++) { newHeaps[i].count=0; for(j=0;j<features;j++) newHeaps[i].Ocenter[j]=V[i][j]; newHeaps[i].x=heaps[i].x; newHeaps[i].y=heaps[i].y; } }//end of function /********************************************************************/ /* Function to initialise the new heaps */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ int findPosition(int i) { int j,position=0; for(j=1;j<lCount;j++) { if(U[j][i]>U[position][i]) position=j; } printf("\n Position %d ",position); return(position); }//end of function find position /********************************************************************/ /* Function to add object */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ void addObject(int object,heap * heapPosition) { heapPosition->objects[heapPosition->count]=object; heapPosition->count++; }//end of function add object /********************************************************************/ /* Function to harden the outputs obtained from fcm */ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/ void harden(heap newHeaps[]) { int i,heapPosition=-1,sum=0,j=0; /*initialise the new heaps*/ initialiseNewHeaps(newHeaps); for(i=0;i<count;i++) { heapPosition=findPosition(i); addObject(i,&newHeaps[heapPosition]); } /* To check for degenerate partitions*/ for(i=0;i<lCount;i++) { if(newHeaps[i].count==0){for(j=i;j<lCount-1;j++){newHeaps[j]=newHeaps[j+1];}lCount--;i--;} } newHeapCount=lCount; for(i=0;i<lCount;i++) computeHeapParameters(&newHeaps[i],1); if(debugLevel>0) { for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\n sum = %d",sum);} }//end of function/********************************************************************/ /* Function to initialize the initial parameters for the ant algorithm*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void init() { int i=0,j=0; for(i=0;i<MAXROWS;i++) for(j=0;j<MAXCOLS;j++) board[i][j]=-9; heapCount=0; newHeapCount=0; heapRow=0; minPosition=-1; minHeapCount=100000; for(i=0;i<MAXANTS;i++) { ants[i].carrying=-1; ants[i].x=-1; ants[i].y=-1; ants[i].speed=-1; ants[i].dir=-1; } } /********************************************************************/ /* Function to initialize the initial board */ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void initialiseBoard() { int i,j; for(i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; }/********************************************************************/ /* Function to harden the outputs obtained from fcm(2nd stage)*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: Cluster center , cluster center count*/ /********************************************************************/void harden1() { int i=0,heapPosition=-1; for(i=0;i<heapCount;i++) cenCount[i]=0; for(i=0;i<n;i++) { heapPosition=findPosition1(i); addObject1(i,heapPosition); } writeInfo(); }//end of function/********************************************************************/ /* Function to find to which class the object belongs */ /* Output: Class number */ /* Input: object position */ /* Global Structure Modified: None */ /********************************************************************/int findPosition1(int i) { int j,position=0; for(j=1;j<heapCount;j++) { if(U[j][i]>U[position][i]) position=j; } return(position); }//end of function find position/********************************************************************/ /* Function to Write the output of the hardened objects to file*/ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/void writeInfo(){int i=0,j=0,k=0;FILE *fp=fopen("fcm.out","a");if(fp==NULL){printf("\n Unable to open fcm output file \n");return;}fprintf(fp,"\n@ %d\n",heapCount);for(i=0;i<heapCount;i++){fprintf(fp,"# %d %d\n",i,cenCount[i]);for(j=0;j<cenCount[i];j++){for(k=0;k<s;k++)fprintf(fp,"%8.2f ",clsCen[i][j][k]/scale[k]+minInput[k]);fprintf(fp,"\n");}}fclose(fp);return;}/********************************************************************/ /* Function to add a object to a cluster (2nd stage) */ /* Output: none */ /* Input: object poistion , cluster position */ /* Global Structure Modified: Cluster object and cluster count*/ /*******************************************************************/void addObject1(int object,int heapPosition) { int k=0; for(k=0;k<features;k++) clsCen[heapPosition][cenCount[heapPosition]][k]=X[object][k]; cenCount[heapPosition]++; return; }//end of function add object/********************************************************************/ /* Function to read the original classification of objects */ /* Output: none */ /* Input: none */ /* Global Structure Modified: None */ /*******************************************************************/void readOrg(){int i=0,k=0;char temp[80];FILE *fp;//= fopen(dataname,"r");strcpy(temp,"");sprintf(temp,"%sFull.data",filename);fp=fopen(temp,"r");if(fp==NULL){printf("\n Unable to open full data input file ");exit(0);}for(i=0;i<n;i++){fscanf(fp,"%f ",&orgData[i][0]);for(k=1;k<s+1;k++)fscanf(fp,"%f ",&orgData[i][k]);}return;}// end of function/********************************************************************/ /* Function to classify the objects in different clusters */ /* Output: none */ /* Input: the cluster objects, the original classification, */ /* number of objects in the cluster,file to write the data */ /* Global Structure Modified: None *//********************************************************************/int analysisData(float data[][s],float orgData[n][s+1],int count,FILE * fp){int i=0,j=0,k=0,type=1,max=0;heapInfo info;for(i=0;i<c;i++){info.classObj[i]=0;}info.total=0;info.total=count;for(i=0;i<count;i++)for(j=0;j<n;j++){type=1;for(k=0;k<s;k++)if(fabs(data[i][k]-orgData[j][k+1])>errThresh){type=-1;break;}if(type!=-1){info.classObj[(int)orgData[j][0]-1]++;break;}}max=0;for(k=0;k<c;k++){if(info.classObj[k]>info.classObj[max])max=k;fprintf(fp,"\nClass %d Objects % d ",k+1,info.classObj[k]);}j=0;for(k=0;k<c;k++){if(k!=max)j+=info.classObj[k];}fprintf(fp,"\n Total errors : %d \n",j);return(j);}//end of analyse/********************************************************************/ /* Function to read the cluster information */ /* Output: none */ /* Input: input file pointer , output file pointer */ /* Global Structure Modified: None *//********************************************************************/void readFCM(FILE* fp,FILE *fp1){int i=0,j=0,k=0,l=0;int totalRuns=0,heapCount=0,junk=0,sum=0;char ch;FILE *fp2=fopen("errors.out","a");ch = 'c'; while (ch != '$') fscanf (fp, "%c", &ch);fscanf(fp,"%d\n",&totalRuns);printf("\n total runs %d ",totalRuns);for(l=0;l<totalRuns;l++){fscanf(fp,"%c",&ch);fscanf(fp,"%d\n",&heapCount);fprintf(fp1,"\n \nExperiment %d \n ",l+1);sum=0;for(i=0;i<heapCount;i++){fscanf(fp,"%c",&ch);fscanf(fp," %d %d\n",&junk,&clsCenCount[i]);for(j=0;j<clsCenCount[i];j++)for(k=0;k<s;k++)fscanf(fp,"%f",&fcmData[i][j][k]);fscanf(fp,"\n");fprintf(fp1,"\n\n Heap %d Total Objects %d \n",i+1,clsCenCount[i]);sum+=analysisData(fcmData[i],orgData,clsCenCount[i],fp1);}fprintf(fp2," %3d %3d %3d \n",l,sum,heapCount);}fprintf(fp2,"\n --------------------------\n");fclose(fp2);return;}//end of function/********************************************************************/ /* Function to update the board parameters */ /* Output: none */ /* Input: none */ /* Global Structure Modified: board size, ant count *//********************************************************************/void adjustBoard(int flag){int newRow=0,newAnt=0,antDiff=0,antsKilled=0,i=0,position[MAXANTS],position1=-1,j=0,k=0,a,b; newRow= (int)ceil(sqrt(4.0*heapSum/updateAfter)); newAnt= (int)ceil((heapSum*1.0/updateAfter)*1.0/3.0); if(newAnt<minAnts)newAnt=minAnts; if(newRow<rowMin)newRow=rowMin;antDiff=currentAntCount-newAnt; if((antDiff>0)&&(newAnt>=minAnts)) {for(i=0;i<currentAntCount;i++){if(ants[i].carrying==-1){position[antsKilled++]=i;}} if(antsKilled>=antDiff){for(i=0;i<antDiff;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1];for(k=i+1;k<antsKilled;k++)position[k]--; } currentAntCount=newAnt; }else {for(i=0;i<antsKilled;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1]; for(k=i+1;k<antsKilled;k++)position[k]--; }if(flag==1) { for(i=currentAntCount-1,k=0;k<antDiff-antsKilled;k++,i--) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position1,flag); }else { dropObject(&ants[i],flag); } } } else { //flag is zero 2nd stage /*Find if a heap is present */ do { position1=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position1].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position1,flag); position1=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position1!=-1); }//end else currentAntCount=newAnt;}//end elsecurrentAntCount=newAnt;}//end iffor(i=0;i<newAnt;i++){if((ants[i].x>=newRow)||(ants[i].y>=newRow)) { a=lrand48()%newRow; b=lrand48()%newRow; ants[i].x=a; ants[i].y=b; }} //Done with ants, now adjust the boardif((currentRow>newRow)&&(newRow>=rowMin)){for(i=0;i<heapCount;i++){if((heaps[i].x>=newRow)||(heaps[i].y>=newRow)) {do { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionheaps[i].x=a;heaps[i].y=b;board[a][b]=9;}//end if}//end for for(i=0;i<currentAntCount;i++){if((ants[i].carrying==1)&&((ants[i].x>=newRow)||(ants[i].y>=newRow))){//adjust the ant locationdo { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionants[i].x=a;ants[i].y=b;}//end if}//end for currentRow=newRow;}//end if }//end of function void writeIncremental(int iteration,int flag){FILE *fp=fopen("dump.txt","w");int i=0,j=0,k=0;fprintf(fp,"Stage %d\n",flag);fprintf(fp,"Board %d\n",currentRow);fprintf(fp,"Ants %d\n",currentAntCount);fprintf(fp,"Iteration %d\n",iteration);fprintf(fp,"Heaps %d\n",heapCount); if(flag==0)fprintf(fp,"NewHeapCount %d\n",newHeapCount); fprintf(fp,"Ants\n");for(i=0;i<currentAntCount;i++){fprintf(fp,"%d %d %d %d %d ",ants[i].x,ants[i].y,ants[i].carrying,ants[i].speed,ants[i].dir);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",ants[i].data[k]);fprintf(fp,"\n");}fprintf(fp,"Heaps\n");for(i=0;i<heapCount;i++){fprintf(fp,"%d %d %d %d %8.2f %8.2f \n",heaps[i].x,heaps[i].y,heaps[i].count,heaps[i].disPosition,heaps[i].Dmax,heaps[i].Dmean);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Ocenter[k]);fprintf(fp,"\n");for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Odissim[k]);fprintf(fp,"\n");if(flag==1){for(j=0;j<heaps[i].count;j++)fprintf(fp,"%d ",heaps[i].objects[j]);fprintf(fp,"\n");}}if(flag==0){fprintf(fp,"newHeaps\n");for(i=0;i<newHeapCount;i++){fprintf(fp,"%d\n",newHeaps[i].count);for(j=0;j<newHeaps[i].count;j++)fprintf(fp,"%d ",newHeaps[i].objects[j]);fprintf(fp,"\n");}}fclose(fp);}//end of function/********************************************************************/ /* Function Main */ /********************************************************************/ int main(int argc ,char** argv) { int sum=0,k=0,i=0,j=0; char temp[80]; FILE *fp=fopen("fcm.out","w"); FILE *fp1; FILE *fp2=fopen("antAnalysis.out","a"); FILE *fp3=fopen("fcmAnalysis.out","a"); FILE *fp4=fopen("errors.out","w"); FILE *fp5; fclose(fp4); sprintf(temp,"%sObj.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sTot.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp1=fopen(temp,"w"); fprintf(fp,"\n$%d",EXPRUN); fprintf(fp1,"\n$%d",EXPRUN); fclose(fp); fclose(fp1); if(argc==2)sscanf(argv[1],"%d",&debugLevel); printf("\n Debug level %d\n",debugLevel); for( i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; //Read from the file readInput(); //Compute the distance of all the points if(maxDist) { Dmax=computeDistance(); //Compute the maximum distance fp5=fopen("maxData.txt","w");fprintf(fp5,"%f",Dmax);fclose(fp5); } else {fp5=fopen("maxData.txt","r");fscanf(fp5,"%f",&Dmax);fclose(fp5); } printf("\n %f \n",Dmax); //Initialise the board for(k=0;k<EXPRUN;k++) { init(); sum=0; srand48(state1[k]); initialiseBoard(); initialise(1); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(1); printf("\n %d \n",heapCount); //Simulate the working of ants iterate(1); //drop the objects after all the iterations dropFinal(1); //to verify the correctness for(i=0;i<heapCount;i++) sum+=heaps[i].count; //write the cluster centers to the file writeClusterInformation(1); printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); //getchar(); //Run FCM // heapCount=2973;/* To be commented */ printf("\n\n k %d \n\n",k); Fcm(data); //compute new board size. lCount=heapCount; heapRow=(int)ceil(sqrt(4*heapCount)); newHeapCount=lCount; printf("\n LCount %d newHeapCount %d heap Row %d \n",lCount,newHeapCount,heapRow); //harden the objects harden(newHeaps); //iterate with the heaps as the objects. initialiseBoard(); initialise(0); for(i=0;i<lCount;i++) computeHeapParameters(&heaps[i],0); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(0); printf("\n %d \n",heapCount); //getchar(); //Simulate the working of ants iterate(0); dropFinal(0); writeClusterInformation(0); sum=0; for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); // getchar(); Fcm(data); harden1(); } fp=fopen("fcm.out","a"); fp1=fopen(temp,"a"); fprintf(fp,"\n"); fprintf(fp1,"\n"); fclose(fp); fclose(fp1); fp=fopen("fcm.out","r"); fp1=fopen(temp,"r");printf("\n Before read org\n");readOrg();printf("\nafter read org\n");readFCM(fp1,fp2);printf("\n After 1st read fcm\n");readFCM(fp,fp3);printf("\n After 2 fcm read \n");return(1); }//end of main /****************************************************************/ float NORM(feature , feature); void find_covar(); void Fcm (irisData Data[MAXDATA]) { int i,j,l; FILE *ofile; char temp[80]; int flag=0;//added by parag FILE *iniClsCen=fopen("center.clt","a+"); if(iniClsCen==NULL) { printf("\n Unable to open the initial cluster center file\n"); printf("\n choosing random cluster centers....\n"); flag=1; } strcpy(temp,""); sprintf(temp,"%s.data",filename); strcpy (fname,temp); /* Read from this file */ m=2.0; /* The exponent */ /*GET_INPUTS1(fname);*/ /* read in feature vectors */ for (j=0; j<n ; j++) /* Read File in row-major */ for (i=0; i<s ; i++) /* format */ X[j][i]=Data[j][i]; Random_seed=state1[run];/*randseed*/ srand48(Random_seed); for (run=0;run<TOTRUNS;run++) { //flag=1;//for testing random values if (EntireHeaps) lCount=heapCount; else lCount=c; for(i=0;i<lCount;i++) for(j=0;j<s;j++) V[i][j]=0; for(i=0;i<lCount;i++) { for(l=0;l<s;l++) { if(flag==1) { rand_index = lrand48() % n; V[i][l] = X[rand_index][l]; } else { fscanf(iniClsCen,"%f ",&V[i][l]); } }//end for } eps=0.001; stop = FALSE; /* This loop finds the final cluster center and the corresponding U values */ z = 0; while (stop == FALSE) { z++; UMAT(U,V,X); /** Update the U matrix **/ stop = FINISHED(U1,eps); CLUSTER(U,X); /** Get new cluster center **/ printf("Iteration: %d\n\n", z); } /* end while */ printf("Number of iterations: %d\n\n", z);strcpy(temp,""); sprintf(temp,"%sFCM.out",filename);if(dataDump) Output(temp); /* output the results */ }/*end for*/ if(dataDump) { ofile=fopen(temp,"a"); for (i=0; i <= mins; i++) fprintf(ofile, "Min %d of %10.3f occurred %d times\n", i, mintab[i], mincount[i]); fprintf(ofile, "Average iterations %f\n", (float)aveit/(float)TOTRUNS); fclose(ofile); } }/* end Main */ /* The GET_INPUTS1 procedure opens an input file, reads the number of input vectors, the number of features per vector, the number of clusters, and epsilon, then it reads the input values */ void GET_INPUTS1(char fname[]) //char fname[]; { /* Parameters: fname -- name of file containing input info. */ FILE *infile ;//*fopen(); //char junk[10][80]; char realfname[80]; char ch; char fileName1[80]; //int temp[10], i, j, inputs, outputs, count; int i,j; sprintf (realfname, "%s", fname); /* open input file */ if(normalize==1) strcpy(fileName1,"gtest1.data"); else strcpy(fileName1,fname); if((infile = fopen (fileName1, "r")) == NULL) printf("\n CAN'T OPEN %s\n",realfname); else { ch = 'c'; /* Discard leading comments */ while (ch != '#') fscanf (infile, "%c", &ch); for (j=0; j<n ; j++) /* Read File in row-major */ { /* format */ for (i=0; i<s ; i++) fscanf (infile, "%f", &X[j][i]); /* fscanf (infile, "%d", &temp[1]); */ /* end for */ } /* end for */ fclose(infile); /* close input file */ }/* end else */ } /* end GET_INPUTS1 */ /* The NORM function computes the norm of two vectors, x and v, of dimension s. This gives an indication of the distance between them */ float NORM( feature x, feature v) //feature x, v; { /* Parameters : x -- a local copy of an input vector v -- a local copy of a cluster center */ int i,j; /* loop variable */ double sum; /* the square root of sum is the norm; sum is the sum of the differences squared */ float mat1[s]; float mat2[s]; if (maha) { for (i=0; i<s; i++) mat1[i]=x[i]-v[i]; for(i=0;i<s;i++) { sum =0; for(j=0;j<s;j++) sum += mat1[j] * inv_cov[j][i]; mat2[i] = sum; } sum =0; for(j=0;j<s;j++) sum += mat1[j]*mat2[j]; } else { sum = 0; for(j=0;j<s;j++) sum += (x[j] - v[j])* (x[j] - v[j]); } return (float)(sqrt(sum)); } /* end NORM */ /* The UMAT procedure calculates the updated U matrix according to Bezdek's formula. Its side-effect is the update of the global array U1 */ void UMAT( matrix U,center V, objects X) /*matrix U; center V; objects X;*/ { /* Parameters: U, V, and X: same as in main program */ int i, j, k,l ;/* loop variables *///, class /* class whose cluster center //is closest to pattern k */; float d1,d2,d; float sum; int exact; for (k=0;k<n;k++) { /*printf("\n k %d ",k);*/ exact=false; for (i=0;i<lCount;i++) { sum=0; for (j=0;j<lCount;j++) { d1=NORM(X[k],V[i]); d2=NORM(X[k],V[j]); if(d2!=0) { d= d1/d2; d= d * d;/* pow(d1/d2,2.0/(m-1.0)); */ sum+=d; } else { exact = true; for(l=0;l<lCount;l++) if (l==j) U1[l][k]=1.0; else U1[l][k]=0.0; break; } } if (exact!=true) U1[i][k]=1.0/sum; } } } /* end UMAT */ /* The function FINISHED determines if a termination occurs. If not it updates U with U1, so its side-effect is the potential modification of U */ BOOLEAN FINISHED( matrix U1,float eps) //matrix U1; float eps; { /* Parameters: U1, eps-- same as in main */ float sum; /* sum of squared differences between corresponding elements of U and U1 */ int i,k; /* loop control variabes */ BOOLEAN finished; /* set to true if all corresponding elements are within epsilon */ finished = TRUE; sum = 0; for (i=0; i<lCount; i++) for (k=0; k<n; k++) sum += (U[i][k] - U1[i][k])*(U[i][k]-U1[i][k]); if (sqrt(sum) > eps) { finished = FALSE; for (i=0; i<lCount; i++) for (k=0; k<n; k++) U[i][k] = U1[i][k]; } /* end if */ return finished; } /* end FINISHED */ /* The CLUSTER procedure determines cluster centers in V for the c classes being searched for. The global array V is updated */ void CLUSTER( matrix U, objects X) //matrix U; objects X; { /* Parameters: U, X -- as in main */ int i, j, k; /* loop control variables */ feature num; /* numerator in the cluster center computation formula presented by Bezdek */ float denum; /* denumenator in the obove formula */ for (i=0; i<lCount; i++) { denum = 0; for (j=0; j<s; j++) { num[j] = 0; for (k=0; k<n; k++) num[j] += U[i][k] * U[i][k] * X[k][j]; /* pow(U[i][k],m) * X[k][j]; */ } /* end for */ for (k=0; k<n; k++) denum += U[i][k] * U[i][k]; /* pow(U[i][k],m); */ for (j=0; j<s; j++) V[i][j] = num[j] / denum; } /* end for */ } /* end CLUSTER */ float Compute_Jm(center V, objects X) //center V; //objects X; { int i, k,found; double Jm_value; float u,dik; Jm_value = 0; for (k=0; k<n; k++) { found = FALSE; for (i=0; i<lCount; i++) { dik=NORM(X[k],V[i]); dik=dik*dik; if (dik==0.0) { if (found == FALSE) { u=1.0; found = TRUE; printf("found the case with dik=0\n"); } else { printf("\n cant proceed with this initialization"); exit(1); } } else { if (found != TRUE) u=U1[i][k]; /* get_Uvalue(V,X,dik,k); */ else u=0.0; } Jm_value += u * u * dik;/* pow(u, m) * dik; */ } } return (Jm_value); } /* end Compute_Jm */ /* The Output procedure outputs the U matrix which gives the fuzzy measure of each feature belonging to a cluster center. It also outputs the cluster center for each class */ void Output(char fname[]) //char fname[80]; /* Parameters: U, V -- same as in main */ { int i, j, found; /* loop control variables */ float J2c; if ((fp=fopen(fname,"a"))==NULL) printf("\n CAN'T OPEN %s\n",fname); else { fprintf(fp,"\n The cluster centers are: \n"); fprintf(fp,"\n \n"); for (i=0; i<lCount; i++) { fprintf(fp,"\nCluster center %d: ",i+1); fprintf(fp,"\n"); for (j=0; j<s; j++) fprintf(fp,"%8.7f ",V[i][j]); } /* end for */ fprintf(fp,"\nThe membership grades for the feature vectors are:\n"); for (j=0; j<n; j++) { fprintf(fp,"\n"); for (i=0; i<lCount; i++) fprintf(fp," %8.7f",U[i][j]); } /* end for */ } /* end if */ J2c= Compute_Jm(V,X); found =0; for (i=0;i<= mins; i++){ if ((found == 0) && ((J2c - mintab[i]) < .001) && ((J2c - mintab[i]) > -.001)){ mincount[i]++; found = 1; } } if (found == 0){ mins++; mintab[mins]=J2c; mincount[mins]=1; } fprintf(fp,"\nJ%3.1f = %f", m,J2c); fprintf(fp, "Number of iterations: %d\n\n", z); aveit=aveit + z; fclose(fp); } /***************************************************************/ void find_covar(int m) //int m; { int i,j,k; float mean[s],sum; for (i=0;i<s;i++) mean[i]=0; for (i=0;i<s;i++) for (j=0;j<m;j++) mean[i]+=X[j][i]; for (i=0;i<s;i++) mean[i]/=m; for (i=0;i<s;i++) for (j=0;j<s;j++) { sum=0; for (k=0;k<m;k++) sum+=(X[k][i]-mean[i])*(X[k][j]-mean[j]); Y[i][j]=sum/m; } }
Parag Kanade/fuzzy ants/Iris/iris.data
Iris Data # 5.1 3.5 1.4 0.2 4.9 3.0 1.4 0.2 4.7 3.2 1.3 0.2 4.6 3.1 1.5 0.2 5.0 3.6 1.4 0.2 5.4 3.9 1.7 0.4 4.6 3.4 1.4 0.3 5.0 3.4 1.5 0.2 4.4 2.9 1.4 0.2 4.9 3.1 1.5 0.1 5.4 3.7 1.5 0.2 4.8 3.4 1.6 0.2 4.8 3.0 1.4 0.1 4.3 3.0 1.1 0.1 5.8 4.0 1.2 0.2 5.7 4.4 1.5 0.4 5.4 3.9 1.3 0.4 5.1 3.5 1.4 0.3 5.7 3.8 1.7 0.3 5.1 3.8 1.5 0.3 5.4 3.4 1.7 0.2 5.1 3.7 1.5 0.4 4.6 3.6 1.0 0.2 5.1 3.3 1.7 0.5 4.8 3.4 1.9 0.2 5.0 3.0 1.6 0.2 5.0 3.4 1.6 0.4 5.2 3.5 1.5 0.2 5.2 3.4 1.4 0.2 4.7 3.2 1.6 0.2 4.8 3.1 1.6 0.2 5.4 3.4 1.5 0.4 5.2 4.1 1.5 0.1 5.5 4.2 1.4 0.2 4.9 3.1 1.5 0.1 5.0 3.2 1.2 0.2 5.5 3.5 1.3 0.2 4.9 3.1 1.5 0.1 4.4 3.0 1.3 0.2 5.1 3.4 1.5 0.2 5.0 3.5 1.3 0.3 4.5 2.3 1.3 0.3 4.4 3.2 1.3 0.2 5.0 3.5 1.6 0.6 5.1 3.8 1.9 0.4 4.8 3.0 1.4 0.3 5.1 3.8 1.6 0.2 4.6 3.2 1.4 0.2 5.3 3.7 1.5 0.2 5.0 3.3 1.4 0.2 7.0 3.2 4.7 1.4 6.4 3.2 4.5 1.5 6.9 3.1 4.9 1.5 5.5 2.3 4.0 1.3 6.5 2.8 4.6 1.5 5.7 2.8 4.5 1.3 6.3 3.3 4.7 1.6 4.9 2.4 3.3 1.0 6.6 2.9 4.6 1.3 5.2 2.7 3.9 1.4 5.0 2.0 3.5 1.0 5.9 3.0 4.2 1.5 6.0 2.2 4.0 1.0 6.1 2.9 4.7 1.4 5.6 2.9 3.6 1.3 6.7 3.1 4.4 1.4 5.6 3.0 4.5 1.5 5.8 2.7 4.1 1.0 6.2 2.2 4.5 1.5 5.6 2.5 3.9 1.1 5.9 3.2 4.8 1.8 6.1 2.8 4.0 1.3 6.3 2.5 4.9 1.5 6.1 2.8 4.7 1.2 6.4 2.9 4.3 1.3 6.6 3.0 4.4 1.4 6.8 2.8 4.8 1.4 6.7 3.0 5.0 1.7 6.0 2.9 4.5 1.5 5.7 2.6 3.5 1.0 5.5 2.4 3.8 1.1 5.5 2.4 3.7 1.0 5.8 2.7 3.9 1.2 6.0 2.7 5.1 1.6 5.4 3.0 4.5 1.5 6.0 3.4 4.5 1.6 6.7 3.1 4.7 1.5 6.3 2.3 4.4 1.3 5.6 3.0 4.1 1.3 5.5 2.5 4.0 1.3 5.5 2.6 4.4 1.2 6.1 3.0 4.6 1.4 5.8 2.6 4.0 1.2 5.0 2.3 3.3 1.0 5.6 2.7 4.2 1.3 5.7 3.0 4.2 1.2 5.7 2.9 4.2 1.3 6.2 2.9 4.3 1.3 5.1 2.5 3.0 1.1 5.7 2.8 4.1 1.3 6.3 3.3 6.0 2.5 5.8 2.7 5.1 1.9 7.1 3.0 5.9 2.1 6.3 2.9 5.6 1.8 6.5 3.0 5.8 2.2 7.6 3.0 6.6 2.1 4.9 2.5 4.5 1.7 7.3 2.9 6.3 1.8 6.7 2.5 5.8 1.8 7.2 3.6 6.1 2.5 6.5 3.2 5.1 2.0 6.4 2.7 5.3 1.9 6.8 3.0 5.5 2.1 5.7 2.5 5.0 2.0 5.8 2.8 5.1 2.4 6.4 3.2 5.3 2.3 6.5 3.0 5.5 1.8 7.7 3.8 6.7 2.2 7.7 2.6 6.9 2.3 6.0 2.2 5.0 1.5 6.9 3.2 5.7 2.3 5.6 2.8 4.9 2.0 7.7 2.8 6.7 2.0 6.3 2.7 4.9 1.8 6.7 3.3 5.7 2.1 7.2 3.2 6.0 1.8 6.2 2.8 4.8 1.8 6.1 3.0 4.9 1.8 6.4 2.8 5.6 2.1 7.2 3.0 5.8 1.6 7.4 2.8 6.1 1.9 7.9 3.8 6.4 2.0 6.4 2.8 5.6 2.2 6.3 2.8 5.1 1.5 6.1 2.6 5.6 1.4 7.7 3.0 6.1 2.3 6.3 3.4 5.6 2.4 6.4 3.1 5.5 1.8 6.0 3.0 4.8 1.8 6.9 3.1 5.4 2.1 6.7 3.1 5.6 2.4 6.9 3.1 5.1 2.3 5.8 2.7 5.1 1.9 6.8 3.2 5.9 2.3 6.7 3.3 5.7 2.5 6.7 3.0 5.2 2.3 6.3 2.5 5.0 1.9 6.5 3.0 5.2 2.0 6.2 3.4 5.4 2.3 5.9 3.0 5.1 1.8
Parag Kanade/fuzzy ants/Iris/irisFull.data
1 | 5.1 | 3.5 | 1.4 | 0.2 |
1 | 4.9 | 3 | 1.4 | 0.2 |
1 | 4.7 | 3.2 | 1.3 | 0.2 |
1 | 4.6 | 3.1 | 1.5 | 0.2 |
1 | 5 | 3.6 | 1.4 | 0.2 |
1 | 5.4 | 3.9 | 1.7 | 0.4 |
1 | 4.6 | 3.4 | 1.4 | 0.3 |
1 | 5 | 3.4 | 1.5 | 0.2 |
1 | 4.4 | 2.9 | 1.4 | 0.2 |
1 | 4.9 | 3.1 | 1.5 | 0.1 |
1 | 5.4 | 3.7 | 1.5 | 0.2 |
1 | 4.8 | 3.4 | 1.6 | 0.2 |
1 | 4.8 | 3 | 1.4 | 0.1 |
1 | 4.3 | 3 | 1.1 | 0.1 |
1 | 5.8 | 4 | 1.2 | 0.2 |
1 | 5.7 | 4.4 | 1.5 | 0.4 |
1 | 5.4 | 3.9 | 1.3 | 0.4 |
1 | 5.1 | 3.5 | 1.4 | 0.3 |
1 | 5.7 | 3.8 | 1.7 | 0.3 |
1 | 5.1 | 3.8 | 1.5 | 0.3 |
1 | 5.4 | 3.4 | 1.7 | 0.2 |
1 | 5.1 | 3.7 | 1.5 | 0.4 |
1 | 4.6 | 3.6 | 1 | 0.2 |
1 | 5.1 | 3.3 | 1.7 | 0.5 |
1 | 4.8 | 3.4 | 1.9 | 0.2 |
1 | 5 | 3 | 1.6 | 0.2 |
1 | 5 | 3.4 | 1.6 | 0.4 |
1 | 5.2 | 3.5 | 1.5 | 0.2 |
1 | 5.2 | 3.4 | 1.4 | 0.2 |
1 | 4.7 | 3.2 | 1.6 | 0.2 |
1 | 4.8 | 3.1 | 1.6 | 0.2 |
1 | 5.4 | 3.4 | 1.5 | 0.4 |
1 | 5.2 | 4.1 | 1.5 | 0.1 |
1 | 5.5 | 4.2 | 1.4 | 0.2 |
1 | 4.9 | 3.1 | 1.5 | 0.1 |
1 | 5 | 3.2 | 1.2 | 0.2 |
1 | 5.5 | 3.5 | 1.3 | 0.2 |
1 | 4.9 | 3.1 | 1.5 | 0.1 |
1 | 4.4 | 3 | 1.3 | 0.2 |
1 | 5.1 | 3.4 | 1.5 | 0.2 |
1 | 5 | 3.5 | 1.3 | 0.3 |
1 | 4.5 | 2.3 | 1.3 | 0.3 |
1 | 4.4 | 3.2 | 1.3 | 0.2 |
1 | 5 | 3.5 | 1.6 | 0.6 |
1 | 5.1 | 3.8 | 1.9 | 0.4 |
1 | 4.8 | 3 | 1.4 | 0.3 |
1 | 5.1 | 3.8 | 1.6 | 0.2 |
1 | 4.6 | 3.2 | 1.4 | 0.2 |
1 | 5.3 | 3.7 | 1.5 | 0.2 |
1 | 5 | 3.3 | 1.4 | 0.2 |
2 | 7 | 3.2 | 4.7 | 1.4 |
2 | 6.4 | 3.2 | 4.5 | 1.5 |
2 | 6.9 | 3.1 | 4.9 | 1.5 |
2 | 5.5 | 2.3 | 4 | 1.3 |
2 | 6.5 | 2.8 | 4.6 | 1.5 |
2 | 5.7 | 2.8 | 4.5 | 1.3 |
2 | 6.3 | 3.3 | 4.7 | 1.6 |
2 | 4.9 | 2.4 | 3.3 | 1 |
2 | 6.6 | 2.9 | 4.6 | 1.3 |
2 | 5.2 | 2.7 | 3.9 | 1.4 |
2 | 5 | 2 | 3.5 | 1 |
2 | 5.9 | 3 | 4.2 | 1.5 |
2 | 6 | 2.2 | 4 | 1 |
2 | 6.1 | 2.9 | 4.7 | 1.4 |
2 | 5.6 | 2.9 | 3.6 | 1.3 |
2 | 6.7 | 3.1 | 4.4 | 1.4 |
2 | 5.6 | 3 | 4.5 | 1.5 |
2 | 5.8 | 2.7 | 4.1 | 1 |
2 | 6.2 | 2.2 | 4.5 | 1.5 |
2 | 5.6 | 2.5 | 3.9 | 1.1 |
2 | 5.9 | 3.2 | 4.8 | 1.8 |
2 | 6.1 | 2.8 | 4 | 1.3 |
2 | 6.3 | 2.5 | 4.9 | 1.5 |
2 | 6.1 | 2.8 | 4.7 | 1.2 |
2 | 6.4 | 2.9 | 4.3 | 1.3 |
2 | 6.6 | 3 | 4.4 | 1.4 |
2 | 6.8 | 2.8 | 4.8 | 1.4 |
2 | 6.7 | 3 | 5 | 1.7 |
2 | 6 | 2.9 | 4.5 | 1.5 |
2 | 5.7 | 2.6 | 3.5 | 1 |
2 | 5.5 | 2.4 | 3.8 | 1.1 |
2 | 5.5 | 2.4 | 3.7 | 1 |
2 | 5.8 | 2.7 | 3.9 | 1.2 |
2 | 6 | 2.7 | 5.1 | 1.6 |
2 | 5.4 | 3 | 4.5 | 1.5 |
2 | 6 | 3.4 | 4.5 | 1.6 |
2 | 6.7 | 3.1 | 4.7 | 1.5 |
2 | 6.3 | 2.3 | 4.4 | 1.3 |
2 | 5.6 | 3 | 4.1 | 1.3 |
2 | 5.5 | 2.5 | 4 | 1.3 |
2 | 5.5 | 2.6 | 4.4 | 1.2 |
2 | 6.1 | 3 | 4.6 | 1.4 |
2 | 5.8 | 2.6 | 4 | 1.2 |
2 | 5 | 2.3 | 3.3 | 1 |
2 | 5.6 | 2.7 | 4.2 | 1.3 |
2 | 5.7 | 3 | 4.2 | 1.2 |
2 | 5.7 | 2.9 | 4.2 | 1.3 |
2 | 6.2 | 2.9 | 4.3 | 1.3 |
2 | 5.1 | 2.5 | 3 | 1.1 |
2 | 5.7 | 2.8 | 4.1 | 1.3 |
3 | 6.3 | 3.3 | 6 | 2.5 |
3 | 5.8 | 2.7 | 5.1 | 1.9 |
3 | 7.1 | 3 | 5.9 | 2.1 |
3 | 6.3 | 2.9 | 5.6 | 1.8 |
3 | 6.5 | 3 | 5.8 | 2.2 |
3 | 7.6 | 3 | 6.6 | 2.1 |
3 | 4.9 | 2.5 | 4.5 | 1.7 |
3 | 7.3 | 2.9 | 6.3 | 1.8 |
3 | 6.7 | 2.5 | 5.8 | 1.8 |
3 | 7.2 | 3.6 | 6.1 | 2.5 |
3 | 6.5 | 3.2 | 5.1 | 2 |
3 | 6.4 | 2.7 | 5.3 | 1.9 |
3 | 6.8 | 3 | 5.5 | 2.1 |
3 | 5.7 | 2.5 | 5 | 2 |
3 | 5.8 | 2.8 | 5.1 | 2.4 |
3 | 6.4 | 3.2 | 5.3 | 2.3 |
3 | 6.5 | 3 | 5.5 | 1.8 |
3 | 7.7 | 3.8 | 6.7 | 2.2 |
3 | 7.7 | 2.6 | 6.9 | 2.3 |
3 | 6 | 2.2 | 5 | 1.5 |
3 | 6.9 | 3.2 | 5.7 | 2.3 |
3 | 5.6 | 2.8 | 4.9 | 2 |
3 | 7.7 | 2.8 | 6.7 | 2 |
3 | 6.3 | 2.7 | 4.9 | 1.8 |
3 | 6.7 | 3.3 | 5.7 | 2.1 |
3 | 7.2 | 3.2 | 6 | 1.8 |
3 | 6.2 | 2.8 | 4.8 | 1.8 |
3 | 6.1 | 3 | 4.9 | 1.8 |
3 | 6.4 | 2.8 | 5.6 | 2.1 |
3 | 7.2 | 3 | 5.8 | 1.6 |
3 | 7.4 | 2.8 | 6.1 | 1.9 |
3 | 7.9 | 3.8 | 6.4 | 2 |
3 | 6.4 | 2.8 | 5.6 | 2.2 |
3 | 6.3 | 2.8 | 5.1 | 1.5 |
3 | 6.1 | 2.6 | 5.6 | 1.4 |
3 | 7.7 | 3 | 6.1 | 2.3 |
3 | 6.3 | 3.4 | 5.6 | 2.4 |
3 | 6.4 | 3.1 | 5.5 | 1.8 |
3 | 6 | 3 | 4.8 | 1.8 |
3 | 6.9 | 3.1 | 5.4 | 2.1 |
3 | 6.7 | 3.1 | 5.6 | 2.4 |
3 | 6.9 | 3.1 | 5.1 | 2.3 |
3 | 5.8 | 2.7 | 5.1 | 1.9 |
3 | 6.8 | 3.2 | 5.9 | 2.3 |
3 | 6.7 | 3.3 | 5.7 | 2.5 |
3 | 6.7 | 3 | 5.2 | 2.3 |
3 | 6.3 | 2.5 | 5 | 1.9 |
3 | 6.5 | 3 | 5.2 | 2 |
3 | 6.2 | 3.4 | 5.4 | 2.3 |
3 | 5.9 | 3 | 5.1 | 1.8 |
Parag Kanade/fuzzy ants/Iris/2class/iris.c
#include "headerStatic.h" /*******************************************************************/ /*** Global Variables ***/ irisData data[MAXDATA]; //To hold the data read from the file int count=0; //Count of the total number of data elements int heapCount=0; // Total number of heaps int heapRow=0; // Rows for the second iteration with heaps int newHeapCount=0; // Count of the heaps for the second iteration heap heaps[MAXDATA]; // Data structure to hold the heap information heap newHeaps[MAXDATA]; // Data Structure to hold the new heap information // For the second iteration int board[MAXROWS][MAXCOLS]; // Board on which the objects are located ant ants[MAXANTS]; // Data structure to hold the ants float Dmax=0; // Distance of the most dissimilar object pair int minHeapCount=100000; // Counter to hold the minimum heap count, used only for academic purpose // no use in the algorithm int minPosition; // the minimum heap iteration , only for academic purpose // no use in the algorithm float clsCen[MAXDATA][MAXDATA][s];//to hold the objects after hardening int cenCount[MAXDATA];//to hold the number of objects after hardening /********************************************************************/ /*** Varaibles to normalize the features between 0 and 1 */ float minInput[features], maxInput[features],scale[features],minForHeaps[features],maxForHeaps[features],scaleForHeaps[features]; /********************************************************************/ /** Variables for the FCM algorithm */ int temp[200]; /* for square matrix tests */ float eps,m; matrix U, U1; BOOLEAN stop; center V; objects X; char fname[80]; FILE *fp; int run; float inv_cov[s+1][s+1]; /* inverse of covariance matrix Y */ float Y[s][s]; long rand_index, Random_seed; long state1[52] = { 9347, 3835, 5194, 8310, 346, 535, 5297, 6711, 77, 3834, 668, 4175, 6868, 5890, 9304, 8462, 5269, 920, 65392, 41600, 70119, 91032, 76220, 26245, 4746, 73608, 32823, 63264, 75641, 99104, 36534, 24704, 98255, 72266, 75336, 65152, 7269, 63163, 88471, 27271, 43641, 76649, 47773, 23777, 27491, 35926, 16651, 48652, 89766, 90921, 6056 }; int z; int mins=0; int aveit =0; float mintab[200]; int mincount[200]; long start,end,total; int lCount;//added by parag /********************************************************************/ /********************************************************************//*int lrand48(){return(rand());}void srand48(int a){return;}*//********************************************************************/ /********************************************************************/ /* Function to read the input data set */ /* The file name is assumed to be itest.data */ /* Status: Tested */ /* Output: Data from the file into the "data" (Global) data structure */ /* Output: Count (Global), the count of the number of objects */ /********************************************************************/ void readInput() { FILE *fp; char fname[80]; int i=0,j=0; char ch; sprintf(fname,"%s.data",filename); /* Check if the input file is opened */ if((fp=fopen(fname,"r"))==NULL) { printf("\n Unable to open input file \n"); exit(0); } /*initialise the minimum maximum and the scale */ for(i=0;i<features;i++) { minInput[i]=1000; maxInput[i]=0; minForHeaps[i]=1000; maxForHeaps[i]=0; scale[i]=0; scaleForHeaps[i]=0; } /* Discard leading comments */ ch = 'c'; while (ch != '#') fscanf (fp, "%c", &ch); i=0; /* Parse the file and populate the data structure */ while(!feof(fp)) { for(j=0;j<features;j++) { fscanf(fp,"%f ",&data[i][j]); } fscanf(fp,"\n"); for(j=0;j<features;j++) { if(data[i][j]<minInput[j]) minInput[j]=data[i][j]; if(data[i][j]>maxInput[j]) maxInput[j]=data[i][j]; } i++; } count=i; /* Normailze the feature values in between 0 and 1 */ for(j=0;j<features;j++) { if(minInput[j]!=maxInput[j]) scale[j]=1.0/(maxInput[j]-minInput[j]); else scale[j]=1.0; } for(i=0;i<count;i++) { for(j=0;j<features;j++) data[i][j]=(data[i][j]-minInput[j])*scale[j]; } fclose(fp); return; }//end of function /********************************************************************/ /*Function to compute the eucldiean distance for all input data set */ /* Output : an array conatining the distance of each object with the other */ /********************************************************************/ float computeDistance() { float distance,dist=0; int i=0,j=0,k=0; distance=0; for(j=0;j<count;j++) for(i=0;i<count;i++) { for(k=0;k<features;k++) dist+=sqrt((data[j][k]-data[i][k])*(data[j][k]-data[i][k])); if(distance<dist)distance=dist; dist=0; } return(distance); } /********************************************************************/ /* Function to compute the distance between two objects */ /* Output : Euclidean d istance between the two input objects */ /********************************************************************/ float computeDistanceBetween2(irisData a,irisData b) { float temp=0; int i=0; for(i=0;i<features;i++) temp+=(a[i]-b[i])*(a[i]-b[i]); temp=sqrt(temp); return(temp); } /********************************************************************/ /* Function to find the maximum distance between the input objects*/ /* Output: the maximum distance */ /* Input : The array of distances between objects */ /********************************************************************/ /*float findMax(float *distance) { int i=0,j=0; float max=distance[0]; for(i=0;i<count;i++) for(j=0;j<count;j++) { if(max<distance[i*count+j]) max=distance[i*count+j]; } return(max); }*/ /********************************************************************/ /* Function to compute the value of an object */ /********************************************************************/ float value(irisData a) { int i=0; float temp=0; for(i=0;i<features;i++) temp+=a[i]*a[i]; return(sqrt(temp)); } /********************************************************************/ /* Function to find the object in the data structure */ /* Output : The position of the object in the data */ /* Input : The object */ /********************************************************************/ int findInData(irisData object,int iFlag) { int i=0,lastCount=0,j,position=-1,flag[features],flg;if(iFlag==1)lastCount=MAXDATA;else{}for(i=0;i<lastCount;i++){ for(j=0;j<features;j++) if(fabs(object[j]-data[i][j])<0.00001) flag[j]=1; else { flag[j]=0; break;} flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /* Function to find whether there is an object on the board at a,b */ /* Output : a flag indicating whether an object is found or not */ /* Input : The row and column indicating the board position */ /********************************************************************/ int found(int a , int b) { if(board[a][b]==9) return 1; else return 0; } /********************************************************************/ /* Function to initialize the initial board */ /* Output : None */ /* Global Structures modified : heaps */ /* Input : Flag indicating the iteration 1: First 0: Second */ /********************************************************************/ void initialise(int flag) { int a,b,i=0,k=0; int loopCount,rowCount,colCount; /* Initialize the row, column and number of heaps */ if(flag==1) { loopCount=count; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=lCount; rowCount=heapRow; colCount=heapRow; } /* Initialize the heaps */ for(i=0;i<loopCount;i++) { heaps[i].count=0; heaps[i].x=0; heaps[i].y=0; heaps[i].disPosition=0; heaps[i].Dmax=0; heaps[i].Dmean=0; } for(i=0;i<loopCount;i++) { /*find a board position which is empty*/ do { a=lrand48()%rowCount; b=lrand48()%colCount; } while(found(a,b)); /*Allocate the object to that place and assign a heap to it*/ heaps[i].x=a; heaps[i].y=b; heaps[i].count=1; heaps[i].Dmax=0; heaps[i].Dmean=0; if(flag==1) { heaps[i].objects[0]=i; for(k=0;k<features;k++)heaps[i].Ocenter[k]=data[i][k]; } else { for(k=0;k<features;k++) heaps[i].Ocenter[k]=newHeaps[i].Ocenter[k]; } heaps[i].disPosition=0; board[a][b]=9; if((debugLevel>0)&&(flag==1))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],data[heaps[i].objects[0]][0]); if((debugLevel>0)&&(flag==0))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],newHeaps[i].Ocenter[0]); } /*initialise the initial heap count*/ heapCount=loopCount; currentRow=rowCount; } /********************************************************************/ /* Function to find whether an heap is present at the location a b */ /* Output : Flag indicating the presencs of the heap */ /* Input : Roe and column indicating the board position */ /********************************************************************/ int findObject(int a,int b) { int i; int position=-1; for(i=0;i<heapCount;i++) { if((heaps[i].x==a)&&(heaps[i].y==b)) { position=i; break; } } return(position); } /********************************************************************/ /* Function initialize the ants */ /* Output : None */ /* Input : Flag indicating the iteration */ /* Global Variables Modified : ant, heapCount, heaps, board */ /********************************************************************/ void initialiseAnts(int flag) { int i=0,a=0,b=0,position,j=0,loopCount=0,rowCount,colCount,k=0; if(flag==1) { loopCount=MAXANTS; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=MAXANTSFORHEAPS; rowCount=heapRow; colCount=heapRow; } for(i=0;i<loopCount;i++) { /*generate random positions for the ants*/ a=lrand48()%rowCount; b=lrand48()%colCount; ants[i].x=a; ants[i].y=b; /*Find if an object is present at that position or not*/ if(board[a][b]==9) { ants[i].carrying=1; /*find the heap at that location*/ position=findObject(a,b); if(position==-1) { printf("\n Error in logic: Ant init \n"); //getchar(); break; } else { /*Assign the heap data to the ant data and decrement the heap count*/ if(flag==1){ for(k=0;k<features;k++)ants[i].data[k]=data[heaps[position].objects[0]][k]; }else{for(k=0;k<features;k++)ants[i].data[k]=heaps[position].Ocenter[k];} for(j=position;j<heapCount-1;j++) heaps[j]=heaps[j+1]; heapCount--; } /*Clear the board position */ board[a][b]=-9; } else ants[i].carrying=-1; ants[i].speed=0; ants[i].dir=lrand48()%8; printf("\n Ant %2d X: %2d Y: %2d Carying : %2d ",i,ants[i].x,ants[i].y,ants[i].carrying); } currentAntCount=loopCount; } /********************************************************************/ /* Function to move the ant */ /* Output: None */ /* Input: Ant to be moved and the flag indicating the iteration */ /********************************************************************/ void moveNext(ant* a,int flag) { int rowCount,colCount; /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; } else { rowCount=heapRow; colCount=heapRow; }*/rowCount=currentRow;colCount=currentRow; /*Depending upon the direction move the ant*/ switch (a->dir) { case 0: a->y++; if(a->y>=colCount)a->y=0; break; case 1: a->x--; a->y++;; if(a->x<0)a->x=rowCount-1; if(a->y>=colCount)a->y=0; break; case 2: a->x--; if(a->x<0)a->x=rowCount-1; break; case 3: a->x--; a->y--; if(a->x<0)a->x=rowCount-1; if(a->y<0)a->y=colCount-1; break; case 4: a->y--; if(a->y<0)a->y=colCount-1; break; case 5: a->x++; a->y--; if(a->x>=rowCount)a->x=0; if(a->y<0)a->y=colCount-1; break; case 6: a->x++; if(a->x>=rowCount) a->x=0; break; case 7: a->x++; a->y++; if(a->x>=rowCount)a->x=0; if(a->y>=colCount)a->y=0; break; } }//end of function /********************************************************************/ /* Function to compute the parameters of the heap */ /* Output: None */ /* Input: The heap whose parameters are to be computed iteration flag*/ /********************************************************************/ void computeHeapParameters(heap* heapData,int flag) { int i=0,j=0,k=0,position=0; float distance=0; float Dmean=0.0; float *dis; float featureSum[features]; float max=0; float sum=0; /* init*/ for(k=0;k<features;k++) featureSum[k]=0; /*Compute the distance of each object and find the maximum distance*/ max=0; if(flag==1){ for(j=0;j<heapData->count;j++) for(i=0;i<heapData->count;i++) { for(k=0;k<features;k++) sum+= (data[heapData->objects[j]][k]-data[heapData->objects[i]][k])*(data[heapData->objects[j]][k]-data[heapData->objects[i]][k]); distance=sqrt(sum); if(max<distance) max=distance; sum=0; } /* Assign the maximum distance to the heap */ heapData->Dmax=max;/*Compute the centre object*/for(i=0;i<heapData->count;i++)for(k=0;k<features;k++) featureSum[k]+=data[heapData->objects[i]][k];for(k=0;k<features;k++)heapData->Ocenter[k]=featureSum[k]*1.0/heapData->count; /* Find the mean distance */if((dis=(float *) calloc(heapData->count,sizeof(float)))==NULL){printf("\nUnable to allocate memory in the compute heap parameters procedure\n");exit(0);} for(i=0;i<heapData->count;i++) { Dmean+=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); dis[i]=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); } heapData->Dmean=Dmean*1.0/heapData->count; /*Compute the most dissimilar object*/ max=dis[0]; for(i=1;i<heapData->count;i++) if(max<dis[i]) { max=dis[i]; position=i; } /*Assign the most dissimilar object to the heap variable*/ for(k=0;k<features;k++) heapData->Odissim[k]=data[heapData->objects[position]][k]; heapData->disPosition=position;free(dis); } else{/* Heap Parameters for the second stage */for(k=0;k<features;k++){ heapData->Odissim[k]=heapData->Ocenter[k];}heapData->disPosition=0;heapData->Dmean=0;heapData->Dmax=0;} }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a single object*/ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject1(ant *a,int position,int flag) { int i,k=0; /*Clear the board*/ board[heaps[position].x][heaps[position].y]=-9; /* Assign the data to the ant*/if(flag==1){ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[0]][k];}else {for(k=0;k<features;k++) a->data[k]=heaps[position].Ocenter[k];} a->carrying=1; /*Copy all the heaps remaining heaps in the structure*/ for(i=position;i<heapCount-1;i++) heaps[i]=heaps[i+1]; /*Decrement the heap count*/ heapCount--; }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a two objects */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject2(ant *a , int position,int flag) { float Pdestroy1=-1; int i=0,k=0; /*Compute the probability to destroy the heap*/ Pdestroy1=lrand48()%13*1.0/12.0; /*If the probability is more than Pdestroy then destroy the heap */ if(Pdestroy1<Pdestroy) { /*pick the object randomly*/ i=lrand48()%2; /* Assign the data to the ant */ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[i]][k]; a->carrying=1; /*Correct the heap parameters*/ heaps[position].count=1; heaps[position].objects[0]=heaps[position].objects[1-i]; computeHeapParameters(&heaps[position],flag); } }//end of function /********************************************************************/ /*Function to pick a object from a heap consisting of more than two object */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /********************************************************************/ void pickObjectn(ant *a,int position,int flag) { int i=0,k=0; /*If the criteria is satsfied then pick the object*/ if((computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)*1.0/heaps[position].Dmean)>Tremove) { a->carrying=1; for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[heaps[position].disPosition]][k]; for(i=heaps[position].disPosition;i<heaps[position].count-1;i++) heaps[position].objects[i]=heaps[position].objects[i+1]; heaps[position].count--; computeHeapParameters(&heaps[position],1); } }//end of function /********************************************************************/ /* Function to pick a object */ /********************************************************************/ void pick(ant *a,int flag) { int position=-1,i=0; float Pload1=-1.0; for(i=0;i<heapCount;i++) { /*Check if a heap is present in the eight neighbouring cells*/ if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if Heap is found*/ if(position!=-1) { /* heap or object found.*/ /*Depending upon the number present in the heap call the corresponding routine*/ switch(heaps[i].count) { case 1: Pload1 = lrand48()%151*1.0/150.0; if(Pload1<Pload) { pickObject1(a,position,flag); } break; case 2: pickObject2(a,position,flag); break; default: pickObjectn(a,position,flag); break; } } } /********************************************************************/ /* Function to drop a object to form a new heap */ /* Output: None */ /* Input: Ant, iteration flag */ /* Global Structure modified : heap, heapCount */ /********************************************************************/ void dropObject(ant* a,int flag) { /*Create a new heap*/ int k=0; heaps[heapCount].count=1; heaps[heapCount].x=a->x; heaps[heapCount].y=a->y; heaps[heapCount].Dmax=0; heaps[heapCount].Dmean=0; heaps[heapCount].disPosition=0; for(k=0;k<features;k++) { heaps[heapCount].Odissim[k]=a->data[k]; heaps[heapCount].Ocenter[k]=a->data[k]; } if(flag==1) {heaps[heapCount].objects[0]=findInData(a->data,flag); /*computeHeapParameters(&heaps[heapCount],flag);*/ } computeHeapParameters(&heaps[heapCount],flag); heapCount++; a->carrying=-1; board[a->x][a->y]=9; }//end of function /********************************************************************/ /* Function to find the heap position during the second iteration */ /* Output: position of the heap */ /* Input: object center of the heap that the ant is carrying */ /* Global Structure modified : none */ /********************************************************************/ int findInNewheaps(irisData object) { int position=-1,i,j=0,flag[features],flg; for(i=0;i<newHeapCount;i++) { for(j=0;j<features;j++) { if(fabs(object[j]-newHeaps[i].Ocenter[j])<0.00001) flag[j]=1; else {flag[j]=0;break;} } flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /*Function to drop a object to a heap consisting of a one or more object */ /* Output: none */ /* Input: Ant, position of the heap , iteration flag */ /* Global Structure modified: heaps,newHeaps */ /********************************************************************/ void dropObject1(ant* a, int position,int flag) { int heapPosition=-1,heapPosition1=-1,i,j,k=0; irisData newData,temp; if(flag==1) { /*Add the object to the heap and compute the heap parameters*/ /*if(heaps[position].count==heaps[position].objCount) {if((junk=(int *)realloc(heaps[position].objects,((heaps[position].objCount+OBJINC)*sizeof(int))))==NULL){printf("\n Cannot Allocate memory to the new object for %d heap",position);exit(0);}heaps[position].objects=junk;heaps[position].objCount+=OBJINC;free(junk); }*/ heaps[position].objects[heaps[position].count]=findInData(a->data,flag); heaps[position].count++; computeHeapParameters(&heaps[position],flag); } else { for(k=0;k<features;k++)temp[k]=heaps[position].Ocenter[k]; heapPosition=findInNewheaps(a->data); heapPosition1=findInNewheaps(heaps[position].Ocenter); if(heapPosition==-1||heapPosition1==-1) { printf("\n error in logic:new heaps\n"); //getchar(); return; } for(k=0;k<features;k++) {newData[k]=(newHeaps[heapPosition].Ocenter[k]*newHeaps[heapPosition].count+newHeaps[heapPosition1].Ocenter[k]*newHeaps[heapPosition1].count)*1.0/(newHeaps[heapPosition].count+newHeaps[heapPosition1].count);newHeaps[heapPosition].Ocenter[k]=newData[k];heaps[position].Ocenter[k]=newData[k]; } computeHeapParameters(&heaps[position],flag); for(i=newHeaps[heapPosition].count,j=0;j<newHeaps[heapPosition1].count;i++,j++) { newHeaps[heapPosition].objects[i]=newHeaps[heapPosition1].objects[j]; } newHeaps[heapPosition].count+=newHeaps[heapPosition1].count; for(i=heapPosition1;i<newHeapCount-1;i++) newHeaps[i]=newHeaps[i+1]; newHeapCount--; } a->carrying=-1; }//end of function /********************************************************************/ /* Function to drop a object */ /* Output: None */ /* Input: Ant, iteration flag */ /********************************************************************/ void drop(ant* a,int flag) { int i, position=-1; float Pdrop1=0.0; /*Find whether we have a heap in the neighbourhood of the cell*/ for(i=0;i<heapCount;i++) { if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if a heap is found*/ if(position!=-1) { /*heap or object found.*/ /*Depending on the number of objects present take action*/ switch(heaps[position].count) { /*If criteria is satisfied then drop the object*/ case 1: if(flag==1) { if((computeDistanceBetween2(a->data,data[heaps[position].objects[0]])*1.0/Dmax)<Tcreate) dropObject1(a,position,flag); } else { if((computeDistanceBetween2(a->data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) dropObject1(a,position,flag); } break; default: if(computeDistanceBetween2(a->data,heaps[position].Ocenter)<computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)) dropObject1(a,position,flag); break; } } else { /*Compute the probability to drop the object*/ Pdrop1 = lrand48()%151*1.0/150; if(Pdrop1<Pdrop) dropObject(a,flag); } }//end of function /********************************************************************/ /* Function to move the ant */ /* Output: none */ /* Input: Ant, iteration flag */ /********************************************************************/ void move(ant* a,int flag) { float pDir; /*Check the speed */ if (a->speed!=0) { /*move in the same direction*/ a->speed--; moveNext(a,flag); } else { /*generate the new direction*/ pDir=lrand48()%17*1.0/16.0; if(pDir<.85) { a->dir=lrand48()%8; } else if(pDir>.95) { a->speed=2; } moveNext(a,flag); } } /********************************************************************/ /* Function to simulate the movement of the ants */ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified: minHeapCount, minHeapPosition */ /********************************************************************/ void iterate(int flag) { int i=0,j=0,k=0,loopCount=0; if (flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS; while (i<MAXITERATIONS) { i++; for(j=0;j<loopCount;j++) { move(&ants[j],flag); if(ants[j].carrying==1) { drop(&ants[j],flag); } else { pick(&ants[j],flag); } } if(debugLevel>0){ for(k=0;k<heapCount;k++) for(j=0;j<heapCount;j++) if((k!=j)&&(heaps[k].x==heaps[j].x)&&(heaps[k].y==heaps[j].y)) { printf("\nerror two heaps with same co ordinates %d %d ",k,j); //getchar(); } k=0; for(j=0;j<heapCount;j++) k+=heaps[j].count; } if(heapCount<minHeapCount) { minHeapCount=heapCount; minPosition=i; } if(debugLevel>0) printf("\n i:%d Heap count %d sum %d",i,heapCount,k); else printf("\n i:%d Heap count %d",i,heapCount); heapSum+=heapCount; /*if(i%updateAfter==0) {adjustBoard(flag); writeIncremental(i,flag);heapSum=0;loopCount=currentAntCount; }*/ } }//end of function /********************************************************************/ /*Function to drop the objects carried by the ants after all the iterations*/ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified:none */ /********************************************************************/ void dropFinal(int flag) { int i=0,j=0,position=-1,loopCount=0; /*if(flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS;*/ loopCount=currentAntCount; for(i=0;i<loopCount;i++) { if(ants[i].carrying==1) { if(flag==1) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position,flag); } } else { /*Find if a heap is present */ do { position=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position,flag); position=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position!=-1); } } } }//end of function /********************************************************************/ /* Function for the implementation of QuickSort */ /* Output: none */ /* Input: data structure, low and high indices */ /* Global structure modified:none */ /********************************************************************/ void quickSort( heap A[], int low,int high ) { int mid=0; if(low<high) { mid=partition(A,low,high); quickSort(A,low,mid); quickSort(A,mid+1,high); } } /********************************************************************/ /* Partition routine used by quick sort */ /* Output: partition location */ /* Input: data , low, high */ /* Global structure modified:none */ /********************************************************************/ int partition(heap a[], int low,int high) { heap temp; int x=0,i=0,j=0; i=low; j=high; x=a[low].count; while (1) { while (a[j].count<x) j=j-1; while (a[i].count>x) i=i+1; if(i<j) { temp=a[i]; a[i]=a[j]; a[j--]=temp; } else return(j); } } /********************************************************************/ /* Function used to write the cluster information */ /* Output: none */ /* Input:iteration flag */ /* Global structure modified:none */ /********************************************************************/ void writeClusterInformation(int flag) { FILE *fp=fopen("center.clt","w"); FILE *fp1; FILE *fp2; FILE *fp3; char temp[80]; int i=0,j=0,k=0; int lastCount=0; int rowCount,colCount,antCount; strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp3=fopen(temp,"a"); if(dataDump) {strcpy(temp,"");sprintf(temp,"%sTot.out",filename);fp1=fopen(temp,"a");strcpy(temp,"");sprintf(temp,"%sObj.out",filename);fp2=fopen(temp,"a");if(fp1==NULL||fp2==NULL)printf("\n Error in opening file in the writer Cluster Information routine\n"); } /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; antCount=MAXANTS; } else { rowCount=heapRow; colCount=heapRow; antCount=MAXANTSFORHEAPS; }*/ rowCount=currentRow; colCount=currentRow; antCount=currentAntCount; if(fp==NULL) { printf("\n Unable to open cluster center output file \n"); /*return;*/ exit(0); } /*sort the array according to the count value and write the value of the top three elements*/ if((flag==1)&&(!EntireHeaps)) quickSort(heaps,0,heapCount); if(EntireHeaps) {if(flag==1) lastCount=heapCount;else lastCount=newHeapCount; } else lastCount=c; for(i=0;i<lastCount;i++) { if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",newHeaps[i].Ocenter[k]); fprintf(fp,"\n"); } else { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); fprintf(fp,"\n"); } } if(dataDump) { fprintf(fp1,"\n Information from the Ant Based Algorithm \n"); fprintf(fp1,"\n Important Parameters : Board %d X %d Ants : %d Iterations %d Total Heaps %d ",rowCount,colCount,antCount,MAXITERATIONS,lastCount); } if(flag==0) { if(dataDump) { fprintf(fp1," TCreateForHeaps %f \n",TcreateForHeaps); fprintf(fp2,"\nTotal Heaps : %d\n",heapCount); fprintf(fp2,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); } fprintf(fp3,"\n@ %d\n",lastCount); } else if(dataDump) fprintf(fp1,"\n");if(dataDump) { fprintf(fp1,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); for(i=0;i<lastCount;i++) if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp2,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); } fprintf(fp1," %5d\n",newHeaps[i].count); fprintf(fp2," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp1," %5d\n",heaps[i].count); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]); fprintf(fp1," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]); fprintf(fp1," %5d\n",heaps[i].count); }} if(flag==0) { if(dataDump) fprintf(fp1,"\n Objects in the heaps \n");for(i=0;i<newHeapCount;i++) { if(dataDump) fprintf(fp1,"\n\n Heap %d\n \n",i+1);fprintf(fp3,"# %d %d\n",i ,newHeaps[i].count); for(j=0;j<newHeaps[i].count;j++){ for(k=0;k<features;k++){ fprintf(fp3,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]); if(dataDump) fprintf(fp1,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]);} if(dataDump) fprintf(fp1,"\n"); fprintf(fp3,"\n"); } } } fclose(fp); fclose(fp3); if(dataDump) { fclose(fp1);fclose(fp2); }}//end of flie /********************************************************************/ /* Function to initialise the new heaps */ /* Output: none */ /* Input:new Heap structure */ /* Global structure modified:none */ /********************************************************************/ void initialiseNewHeaps(heap newHeaps[]) { int i=0,j=0; for(i=0;i<lCount;i++) { newHeaps[i].count=0; for(j=0;j<features;j++) newHeaps[i].Ocenter[j]=V[i][j]; newHeaps[i].x=heaps[i].x; newHeaps[i].y=heaps[i].y; } }//end of function /********************************************************************/ /* Function to initialise the new heaps */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ int findPosition(int i) { int j,position=0; for(j=1;j<lCount;j++) { if(U[j][i]>U[position][i]) position=j; } printf("\n Position %d ",position); return(position); }//end of function find position /********************************************************************/ /* Function to add object */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ void addObject(int object,heap * heapPosition) { heapPosition->objects[heapPosition->count]=object; heapPosition->count++; }//end of function add object /********************************************************************/ /* Function to harden the outputs obtained from fcm */ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/ void harden(heap newHeaps[]) { int i,heapPosition=-1,sum=0,j=0; /*initialise the new heaps*/ initialiseNewHeaps(newHeaps); for(i=0;i<count;i++) { heapPosition=findPosition(i); addObject(i,&newHeaps[heapPosition]); } /* To check for degenerate partitions*/ for(i=0;i<lCount;i++) { if(newHeaps[i].count==0){for(j=i;j<lCount-1;j++){newHeaps[j]=newHeaps[j+1];}lCount--;i--;} } newHeapCount=lCount; for(i=0;i<lCount;i++) computeHeapParameters(&newHeaps[i],1); if(debugLevel>0) { for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\n sum = %d",sum);} }//end of function/********************************************************************/ /* Function to initialize the initial parameters for the ant algorithm*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void init() { int i=0,j=0; for(i=0;i<MAXROWS;i++) for(j=0;j<MAXCOLS;j++) board[i][j]=-9; heapCount=0; newHeapCount=0; heapRow=0; minPosition=-1; minHeapCount=100000; for(i=0;i<MAXANTS;i++) { ants[i].carrying=-1; ants[i].x=-1; ants[i].y=-1; ants[i].speed=-1; ants[i].dir=-1; } } /********************************************************************/ /* Function to initialize the initial board */ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void initialiseBoard() { int i,j; for(i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; }/********************************************************************/ /* Function to harden the outputs obtained from fcm(2nd stage)*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: Cluster center , cluster center count*/ /********************************************************************/void harden1() { int i=0,heapPosition=-1; for(i=0;i<heapCount;i++) cenCount[i]=0; for(i=0;i<n;i++) { heapPosition=findPosition1(i); addObject1(i,heapPosition); } writeInfo(); }//end of function/********************************************************************/ /* Function to find to which class the object belongs */ /* Output: Class number */ /* Input: object position */ /* Global Structure Modified: None */ /********************************************************************/int findPosition1(int i) { int j,position=0; for(j=1;j<heapCount;j++) { if(U[j][i]>U[position][i]) position=j; } return(position); }//end of function find position/********************************************************************/ /* Function to Write the output of the hardened objects to file*/ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/void writeInfo(){int i=0,j=0,k=0;FILE *fp=fopen("fcm.out","a");if(fp==NULL){printf("\n Unable to open fcm output file \n");return;}fprintf(fp,"\n@ %d\n",heapCount);for(i=0;i<heapCount;i++){fprintf(fp,"# %d %d\n",i,cenCount[i]);for(j=0;j<cenCount[i];j++){for(k=0;k<s;k++)fprintf(fp,"%8.2f ",clsCen[i][j][k]/scale[k]+minInput[k]);fprintf(fp,"\n");}}fclose(fp);return;}/********************************************************************/ /* Function to add a object to a cluster (2nd stage) */ /* Output: none */ /* Input: object poistion , cluster position */ /* Global Structure Modified: Cluster object and cluster count*/ /*******************************************************************/void addObject1(int object,int heapPosition) { int k=0; for(k=0;k<features;k++) clsCen[heapPosition][cenCount[heapPosition]][k]=X[object][k]; cenCount[heapPosition]++; return; }//end of function add object/********************************************************************/ /* Function to read the original classification of objects */ /* Output: none */ /* Input: none */ /* Global Structure Modified: None */ /*******************************************************************/void readOrg(){int i=0,k=0;char temp[80];FILE *fp;//= fopen(dataname,"r");strcpy(temp,"");sprintf(temp,"%sFull.data",filename);fp=fopen(temp,"r");if(fp==NULL){printf("\n Unable to open full data input file ");exit(0);}for(i=0;i<n;i++){fscanf(fp,"%f ",&orgData[i][0]);for(k=1;k<s+1;k++)fscanf(fp,"%f ",&orgData[i][k]);}return;}// end of function/********************************************************************/ /* Function to classify the objects in different clusters */ /* Output: none */ /* Input: the cluster objects, the original classification, */ /* number of objects in the cluster,file to write the data */ /* Global Structure Modified: None *//********************************************************************/int analysisData(float data[][s],float orgData[n][s+1],int count,FILE * fp){int i=0,j=0,k=0,type=1,max=0;heapInfo info;for(i=0;i<c;i++){info.classObj[i]=0;}info.total=0;info.total=count;for(i=0;i<count;i++)for(j=0;j<n;j++){type=1;for(k=0;k<s;k++)if(fabs(data[i][k]-orgData[j][k+1])>errThresh){type=-1;break;}if(type!=-1){info.classObj[(int)orgData[j][0]-1]++;break;}}max=0;for(k=0;k<c;k++){if(info.classObj[k]>info.classObj[max])max=k;fprintf(fp,"\nClass %d Objects % d ",k+1,info.classObj[k]);}j=0;for(k=0;k<c;k++){if(k!=max)j+=info.classObj[k];}fprintf(fp,"\n Total errors : %d \n",j);return(j);}//end of analyse/********************************************************************/ /* Function to read the cluster information */ /* Output: none */ /* Input: input file pointer , output file pointer */ /* Global Structure Modified: None *//********************************************************************/void readFCM(FILE* fp,FILE *fp1){int i=0,j=0,k=0,l=0;int totalRuns=0,heapCount=0,junk=0,sum=0;char ch;FILE *fp2=fopen("errors.out","a");ch = 'c'; while (ch != '$') fscanf (fp, "%c", &ch);fscanf(fp,"%d\n",&totalRuns);printf("\n total runs %d ",totalRuns);for(l=0;l<totalRuns;l++){fscanf(fp,"%c",&ch);fscanf(fp,"%d\n",&heapCount);fprintf(fp1,"\n \nExperiment %d \n ",l+1);sum=0;for(i=0;i<heapCount;i++){fscanf(fp,"%c",&ch);fscanf(fp," %d %d\n",&junk,&clsCenCount[i]);for(j=0;j<clsCenCount[i];j++)for(k=0;k<s;k++)fscanf(fp,"%f",&fcmData[i][j][k]);fscanf(fp,"\n");fprintf(fp1,"\n\n Heap %d Total Objects %d \n",i+1,clsCenCount[i]);sum+=analysisData(fcmData[i],orgData,clsCenCount[i],fp1);}fprintf(fp2," %3d %3d %3d \n",l,sum,heapCount);}fprintf(fp2,"\n --------------------------\n");fclose(fp2);return;}//end of function/********************************************************************/ /* Function to update the board parameters */ /* Output: none */ /* Input: none */ /* Global Structure Modified: board size, ant count *//********************************************************************/void adjustBoard(int flag){int newRow=0,newAnt=0,antDiff=0,antsKilled=0,i=0,position[MAXANTS],position1=-1,j=0,k=0,a,b; newRow= (int)ceil(sqrt(4.0*heapSum/updateAfter)); newAnt= (int)ceil((heapSum*1.0/updateAfter)*1.0/3.0); if(newAnt<minAnts)newAnt=minAnts; if(newRow<rowMin)newRow=rowMin;antDiff=currentAntCount-newAnt; if((antDiff>0)&&(newAnt>=minAnts)) {for(i=0;i<currentAntCount;i++){if(ants[i].carrying==-1){position[antsKilled++]=i;}} if(antsKilled>=antDiff){for(i=0;i<antDiff;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1];for(k=i+1;k<antsKilled;k++)position[k]--; } currentAntCount=newAnt; }else {for(i=0;i<antsKilled;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1]; for(k=i+1;k<antsKilled;k++)position[k]--; }if(flag==1) { for(i=currentAntCount-1,k=0;k<antDiff-antsKilled;k++,i--) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position1,flag); }else { dropObject(&ants[i],flag); } } } else { //flag is zero 2nd stage /*Find if a heap is present */ do { position1=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position1].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position1,flag); position1=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position1!=-1); }//end else currentAntCount=newAnt;}//end elsecurrentAntCount=newAnt;}//end iffor(i=0;i<newAnt;i++){if((ants[i].x>=newRow)||(ants[i].y>=newRow)) { a=lrand48()%newRow; b=lrand48()%newRow; ants[i].x=a; ants[i].y=b; }} //Done with ants, now adjust the boardif((currentRow>newRow)&&(newRow>=rowMin)){for(i=0;i<heapCount;i++){if((heaps[i].x>=newRow)||(heaps[i].y>=newRow)) {do { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionheaps[i].x=a;heaps[i].y=b;board[a][b]=9;}//end if}//end for for(i=0;i<currentAntCount;i++){if((ants[i].carrying==1)&&((ants[i].x>=newRow)||(ants[i].y>=newRow))){//adjust the ant locationdo { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionants[i].x=a;ants[i].y=b;}//end if}//end for currentRow=newRow;}//end if }//end of function void writeIncremental(int iteration,int flag){FILE *fp=fopen("dump.txt","w");int i=0,j=0,k=0;fprintf(fp,"Stage %d\n",flag);fprintf(fp,"Board %d\n",currentRow);fprintf(fp,"Ants %d\n",currentAntCount);fprintf(fp,"Iteration %d\n",iteration);fprintf(fp,"Heaps %d\n",heapCount); if(flag==0)fprintf(fp,"NewHeapCount %d\n",newHeapCount); fprintf(fp,"Ants\n");for(i=0;i<currentAntCount;i++){fprintf(fp,"%d %d %d %d %d ",ants[i].x,ants[i].y,ants[i].carrying,ants[i].speed,ants[i].dir);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",ants[i].data[k]);fprintf(fp,"\n");}fprintf(fp,"Heaps\n");for(i=0;i<heapCount;i++){fprintf(fp,"%d %d %d %d %8.2f %8.2f \n",heaps[i].x,heaps[i].y,heaps[i].count,heaps[i].disPosition,heaps[i].Dmax,heaps[i].Dmean);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Ocenter[k]);fprintf(fp,"\n");for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Odissim[k]);fprintf(fp,"\n");if(flag==1){for(j=0;j<heaps[i].count;j++)fprintf(fp,"%d ",heaps[i].objects[j]);fprintf(fp,"\n");}}if(flag==0){fprintf(fp,"newHeaps\n");for(i=0;i<newHeapCount;i++){fprintf(fp,"%d\n",newHeaps[i].count);for(j=0;j<newHeaps[i].count;j++)fprintf(fp,"%d ",newHeaps[i].objects[j]);fprintf(fp,"\n");}}fclose(fp);}//end of function/********************************************************************/ /* Function Main */ /********************************************************************/ int main(int argc ,char** argv) { int sum=0,k=0,i=0,j=0; char temp[80]; FILE *fp=fopen("fcm.out","w"); FILE *fp1; FILE *fp2=fopen("antAnalysis.out","a"); FILE *fp3=fopen("fcmAnalysis.out","a"); FILE *fp4=fopen("errors.out","w"); FILE *fp5; fclose(fp4); sprintf(temp,"%sObj.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sTot.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp1=fopen(temp,"w"); fprintf(fp,"\n$%d",EXPRUN); fprintf(fp1,"\n$%d",EXPRUN); fclose(fp); fclose(fp1); if(argc==2)sscanf(argv[1],"%d",&debugLevel); printf("\n Debug level %d\n",debugLevel); for( i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; //Read from the file readInput(); //Compute the distance of all the points if(maxDist) { Dmax=computeDistance(); //Compute the maximum distance fp5=fopen("maxData.txt","w");fprintf(fp5,"%f",Dmax);fclose(fp5); } else {fp5=fopen("maxData.txt","r");fscanf(fp5,"%f",&Dmax);fclose(fp5); } printf("\n %f \n",Dmax); //Initialise the board for(k=0;k<EXPRUN;k++) { init(); sum=0; srand48(state1[k]); initialiseBoard(); initialise(1); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(1); printf("\n %d \n",heapCount); //Simulate the working of ants iterate(1); //drop the objects after all the iterations dropFinal(1); //to verify the correctness for(i=0;i<heapCount;i++) sum+=heaps[i].count; //write the cluster centers to the file writeClusterInformation(1); printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); //getchar(); //Run FCM // heapCount=2973;/* To be commented */ printf("\n\n k %d \n\n",k); Fcm(data); //compute new board size. lCount=heapCount; heapRow=(int)ceil(sqrt(4*heapCount)); newHeapCount=lCount; printf("\n LCount %d newHeapCount %d heap Row %d \n",lCount,newHeapCount,heapRow); //harden the objects harden(newHeaps); //iterate with the heaps as the objects. initialiseBoard(); initialise(0); for(i=0;i<lCount;i++) computeHeapParameters(&heaps[i],0); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(0); printf("\n %d \n",heapCount); //getchar(); //Simulate the working of ants iterate(0); dropFinal(0); writeClusterInformation(0); sum=0; for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); // getchar(); Fcm(data); harden1(); } fp=fopen("fcm.out","a"); fp1=fopen(temp,"a"); fprintf(fp,"\n"); fprintf(fp1,"\n"); fclose(fp); fclose(fp1); fp=fopen("fcm.out","r"); fp1=fopen(temp,"r");printf("\n Before read org\n");readOrg();printf("\nafter read org\n");readFCM(fp1,fp2);printf("\n After 1st read fcm\n");readFCM(fp,fp3);printf("\n After 2 fcm read \n");return(1); }//end of main /****************************************************************/ float NORM(feature , feature); void find_covar(); void Fcm (irisData Data[MAXDATA]) { int i,j,l; FILE *ofile; char temp[80]; int flag=0;//added by parag FILE *iniClsCen=fopen("center.clt","a+"); if(iniClsCen==NULL) { printf("\n Unable to open the initial cluster center file\n"); printf("\n choosing random cluster centers....\n"); flag=1; } strcpy(temp,""); sprintf(temp,"%s.data",filename); strcpy (fname,temp); /* Read from this file */ m=2.0; /* The exponent */ /*GET_INPUTS1(fname);*/ /* read in feature vectors */ for (j=0; j<n ; j++) /* Read File in row-major */ for (i=0; i<s ; i++) /* format */ X[j][i]=Data[j][i]; Random_seed=state1[run];/*randseed*/ srand48(Random_seed); for (run=0;run<TOTRUNS;run++) { //flag=1;//for testing random values if (EntireHeaps) lCount=heapCount; else lCount=c; for(i=0;i<lCount;i++) for(j=0;j<s;j++) V[i][j]=0; for(i=0;i<lCount;i++) { for(l=0;l<s;l++) { if(flag==1) { rand_index = lrand48() % n; V[i][l] = X[rand_index][l]; } else { fscanf(iniClsCen,"%f ",&V[i][l]); } }//end for } eps=0.001; stop = FALSE; /* This loop finds the final cluster center and the corresponding U values */ z = 0; while (stop == FALSE) { z++; UMAT(U,V,X); /** Update the U matrix **/ stop = FINISHED(U1,eps); CLUSTER(U,X); /** Get new cluster center **/ printf("Iteration: %d\n\n", z); } /* end while */ printf("Number of iterations: %d\n\n", z);strcpy(temp,""); sprintf(temp,"%sFCM.out",filename);if(dataDump) Output(temp); /* output the results */ }/*end for*/ if(dataDump) { ofile=fopen(temp,"a"); for (i=0; i <= mins; i++) fprintf(ofile, "Min %d of %10.3f occurred %d times\n", i, mintab[i], mincount[i]); fprintf(ofile, "Average iterations %f\n", (float)aveit/(float)TOTRUNS); fclose(ofile); } }/* end Main */ /* The GET_INPUTS1 procedure opens an input file, reads the number of input vectors, the number of features per vector, the number of clusters, and epsilon, then it reads the input values */ void GET_INPUTS1(char fname[]) //char fname[]; { /* Parameters: fname -- name of file containing input info. */ FILE *infile ;//*fopen(); //char junk[10][80]; char realfname[80]; char ch; char fileName1[80]; //int temp[10], i, j, inputs, outputs, count; int i,j; sprintf (realfname, "%s", fname); /* open input file */ if(normalize==1) strcpy(fileName1,"gtest1.data"); else strcpy(fileName1,fname); if((infile = fopen (fileName1, "r")) == NULL) printf("\n CAN'T OPEN %s\n",realfname); else { ch = 'c'; /* Discard leading comments */ while (ch != '#') fscanf (infile, "%c", &ch); for (j=0; j<n ; j++) /* Read File in row-major */ { /* format */ for (i=0; i<s ; i++) fscanf (infile, "%f", &X[j][i]); /* fscanf (infile, "%d", &temp[1]); */ /* end for */ } /* end for */ fclose(infile); /* close input file */ }/* end else */ } /* end GET_INPUTS1 */ /* The NORM function computes the norm of two vectors, x and v, of dimension s. This gives an indication of the distance between them */ float NORM( feature x, feature v) //feature x, v; { /* Parameters : x -- a local copy of an input vector v -- a local copy of a cluster center */ int i,j; /* loop variable */ double sum; /* the square root of sum is the norm; sum is the sum of the differences squared */ float mat1[s]; float mat2[s]; if (maha) { for (i=0; i<s; i++) mat1[i]=x[i]-v[i]; for(i=0;i<s;i++) { sum =0; for(j=0;j<s;j++) sum += mat1[j] * inv_cov[j][i]; mat2[i] = sum; } sum =0; for(j=0;j<s;j++) sum += mat1[j]*mat2[j]; } else { sum = 0; for(j=0;j<s;j++) sum += (x[j] - v[j])* (x[j] - v[j]); } return (float)(sqrt(sum)); } /* end NORM */ /* The UMAT procedure calculates the updated U matrix according to Bezdek's formula. Its side-effect is the update of the global array U1 */ void UMAT( matrix U,center V, objects X) /*matrix U; center V; objects X;*/ { /* Parameters: U, V, and X: same as in main program */ int i, j, k,l ;/* loop variables *///, class /* class whose cluster center //is closest to pattern k */; float d1,d2,d; float sum; int exact; for (k=0;k<n;k++) { /*printf("\n k %d ",k);*/ exact=false; for (i=0;i<lCount;i++) { sum=0; for (j=0;j<lCount;j++) { d1=NORM(X[k],V[i]); d2=NORM(X[k],V[j]); if(d2!=0) { d= d1/d2; d= d * d;/* pow(d1/d2,2.0/(m-1.0)); */ sum+=d; } else { exact = true; for(l=0;l<lCount;l++) if (l==j) U1[l][k]=1.0; else U1[l][k]=0.0; break; } } if (exact!=true) U1[i][k]=1.0/sum; } } } /* end UMAT */ /* The function FINISHED determines if a termination occurs. If not it updates U with U1, so its side-effect is the potential modification of U */ BOOLEAN FINISHED( matrix U1,float eps) //matrix U1; float eps; { /* Parameters: U1, eps-- same as in main */ float sum; /* sum of squared differences between corresponding elements of U and U1 */ int i,k; /* loop control variabes */ BOOLEAN finished; /* set to true if all corresponding elements are within epsilon */ finished = TRUE; sum = 0; for (i=0; i<lCount; i++) for (k=0; k<n; k++) sum += (U[i][k] - U1[i][k])*(U[i][k]-U1[i][k]); if (sqrt(sum) > eps) { finished = FALSE; for (i=0; i<lCount; i++) for (k=0; k<n; k++) U[i][k] = U1[i][k]; } /* end if */ return finished; } /* end FINISHED */ /* The CLUSTER procedure determines cluster centers in V for the c classes being searched for. The global array V is updated */ void CLUSTER( matrix U, objects X) //matrix U; objects X; { /* Parameters: U, X -- as in main */ int i, j, k; /* loop control variables */ feature num; /* numerator in the cluster center computation formula presented by Bezdek */ float denum; /* denumenator in the obove formula */ for (i=0; i<lCount; i++) { denum = 0; for (j=0; j<s; j++) { num[j] = 0; for (k=0; k<n; k++) num[j] += U[i][k] * U[i][k] * X[k][j]; /* pow(U[i][k],m) * X[k][j]; */ } /* end for */ for (k=0; k<n; k++) denum += U[i][k] * U[i][k]; /* pow(U[i][k],m); */ for (j=0; j<s; j++) V[i][j] = num[j] / denum; } /* end for */ } /* end CLUSTER */ float Compute_Jm(center V, objects X) //center V; //objects X; { int i, k,found; double Jm_value; float u,dik; Jm_value = 0; for (k=0; k<n; k++) { found = FALSE; for (i=0; i<lCount; i++) { dik=NORM(X[k],V[i]); dik=dik*dik; if (dik==0.0) { if (found == FALSE) { u=1.0; found = TRUE; printf("found the case with dik=0\n"); } else { printf("\n cant proceed with this initialization"); exit(1); } } else { if (found != TRUE) u=U1[i][k]; /* get_Uvalue(V,X,dik,k); */ else u=0.0; } Jm_value += u * u * dik;/* pow(u, m) * dik; */ } } return (Jm_value); } /* end Compute_Jm */ /* The Output procedure outputs the U matrix which gives the fuzzy measure of each feature belonging to a cluster center. It also outputs the cluster center for each class */ void Output(char fname[]) //char fname[80]; /* Parameters: U, V -- same as in main */ { int i, j, found; /* loop control variables */ float J2c; if ((fp=fopen(fname,"a"))==NULL) printf("\n CAN'T OPEN %s\n",fname); else { fprintf(fp,"\n The cluster centers are: \n"); fprintf(fp,"\n \n"); for (i=0; i<lCount; i++) { fprintf(fp,"\nCluster center %d: ",i+1); fprintf(fp,"\n"); for (j=0; j<s; j++) fprintf(fp,"%8.7f ",V[i][j]); } /* end for */ fprintf(fp,"\nThe membership grades for the feature vectors are:\n"); for (j=0; j<n; j++) { fprintf(fp,"\n"); for (i=0; i<lCount; i++) fprintf(fp," %8.7f",U[i][j]); } /* end for */ } /* end if */ J2c= Compute_Jm(V,X); found =0; for (i=0;i<= mins; i++){ if ((found == 0) && ((J2c - mintab[i]) < .001) && ((J2c - mintab[i]) > -.001)){ mincount[i]++; found = 1; } } if (found == 0){ mins++; mintab[mins]=J2c; mincount[mins]=1; } fprintf(fp,"\nJ%3.1f = %f", m,J2c); fprintf(fp, "Number of iterations: %d\n\n", z); aveit=aveit + z; fclose(fp); } /***************************************************************/ void find_covar(int m) //int m; { int i,j,k; float mean[s],sum; for (i=0;i<s;i++) mean[i]=0; for (i=0;i<s;i++) for (j=0;j<m;j++) mean[i]+=X[j][i]; for (i=0;i<s;i++) mean[i]/=m; for (i=0;i<s;i++) for (j=0;j<s;j++) { sum=0; for (k=0;k<m;k++) sum+=(X[k][i]-mean[i])*(X[k][j]-mean[j]); Y[i][j]=sum/m; } }
Parag Kanade/fuzzy ants/Iris/2class/maxData.txt
3.220810
Parag Kanade/fuzzy ants/Iris/2class/iris.data
Iris Data # 5.1 3.5 1.4 0.2 4.9 3.0 1.4 0.2 4.7 3.2 1.3 0.2 4.6 3.1 1.5 0.2 5.0 3.6 1.4 0.2 5.4 3.9 1.7 0.4 4.6 3.4 1.4 0.3 5.0 3.4 1.5 0.2 4.4 2.9 1.4 0.2 4.9 3.1 1.5 0.1 5.4 3.7 1.5 0.2 4.8 3.4 1.6 0.2 4.8 3.0 1.4 0.1 4.3 3.0 1.1 0.1 5.8 4.0 1.2 0.2 5.7 4.4 1.5 0.4 5.4 3.9 1.3 0.4 5.1 3.5 1.4 0.3 5.7 3.8 1.7 0.3 5.1 3.8 1.5 0.3 5.4 3.4 1.7 0.2 5.1 3.7 1.5 0.4 4.6 3.6 1.0 0.2 5.1 3.3 1.7 0.5 4.8 3.4 1.9 0.2 5.0 3.0 1.6 0.2 5.0 3.4 1.6 0.4 5.2 3.5 1.5 0.2 5.2 3.4 1.4 0.2 4.7 3.2 1.6 0.2 4.8 3.1 1.6 0.2 5.4 3.4 1.5 0.4 5.2 4.1 1.5 0.1 5.5 4.2 1.4 0.2 4.9 3.1 1.5 0.1 5.0 3.2 1.2 0.2 5.5 3.5 1.3 0.2 4.9 3.1 1.5 0.1 4.4 3.0 1.3 0.2 5.1 3.4 1.5 0.2 5.0 3.5 1.3 0.3 4.5 2.3 1.3 0.3 4.4 3.2 1.3 0.2 5.0 3.5 1.6 0.6 5.1 3.8 1.9 0.4 4.8 3.0 1.4 0.3 5.1 3.8 1.6 0.2 4.6 3.2 1.4 0.2 5.3 3.7 1.5 0.2 5.0 3.3 1.4 0.2 7.0 3.2 4.7 1.4 6.4 3.2 4.5 1.5 6.9 3.1 4.9 1.5 5.5 2.3 4.0 1.3 6.5 2.8 4.6 1.5 5.7 2.8 4.5 1.3 6.3 3.3 4.7 1.6 4.9 2.4 3.3 1.0 6.6 2.9 4.6 1.3 5.2 2.7 3.9 1.4 5.0 2.0 3.5 1.0 5.9 3.0 4.2 1.5 6.0 2.2 4.0 1.0 6.1 2.9 4.7 1.4 5.6 2.9 3.6 1.3 6.7 3.1 4.4 1.4 5.6 3.0 4.5 1.5 5.8 2.7 4.1 1.0 6.2 2.2 4.5 1.5 5.6 2.5 3.9 1.1 5.9 3.2 4.8 1.8 6.1 2.8 4.0 1.3 6.3 2.5 4.9 1.5 6.1 2.8 4.7 1.2 6.4 2.9 4.3 1.3 6.6 3.0 4.4 1.4 6.8 2.8 4.8 1.4 6.7 3.0 5.0 1.7 6.0 2.9 4.5 1.5 5.7 2.6 3.5 1.0 5.5 2.4 3.8 1.1 5.5 2.4 3.7 1.0 5.8 2.7 3.9 1.2 6.0 2.7 5.1 1.6 5.4 3.0 4.5 1.5 6.0 3.4 4.5 1.6 6.7 3.1 4.7 1.5 6.3 2.3 4.4 1.3 5.6 3.0 4.1 1.3 5.5 2.5 4.0 1.3 5.5 2.6 4.4 1.2 6.1 3.0 4.6 1.4 5.8 2.6 4.0 1.2 5.0 2.3 3.3 1.0 5.6 2.7 4.2 1.3 5.7 3.0 4.2 1.2 5.7 2.9 4.2 1.3 6.2 2.9 4.3 1.3 5.1 2.5 3.0 1.1 5.7 2.8 4.1 1.3 6.3 3.3 6.0 2.5 5.8 2.7 5.1 1.9 7.1 3.0 5.9 2.1 6.3 2.9 5.6 1.8 6.5 3.0 5.8 2.2 7.6 3.0 6.6 2.1 4.9 2.5 4.5 1.7 7.3 2.9 6.3 1.8 6.7 2.5 5.8 1.8 7.2 3.6 6.1 2.5 6.5 3.2 5.1 2.0 6.4 2.7 5.3 1.9 6.8 3.0 5.5 2.1 5.7 2.5 5.0 2.0 5.8 2.8 5.1 2.4 6.4 3.2 5.3 2.3 6.5 3.0 5.5 1.8 7.7 3.8 6.7 2.2 7.7 2.6 6.9 2.3 6.0 2.2 5.0 1.5 6.9 3.2 5.7 2.3 5.6 2.8 4.9 2.0 7.7 2.8 6.7 2.0 6.3 2.7 4.9 1.8 6.7 3.3 5.7 2.1 7.2 3.2 6.0 1.8 6.2 2.8 4.8 1.8 6.1 3.0 4.9 1.8 6.4 2.8 5.6 2.1 7.2 3.0 5.8 1.6 7.4 2.8 6.1 1.9 7.9 3.8 6.4 2.0 6.4 2.8 5.6 2.2 6.3 2.8 5.1 1.5 6.1 2.6 5.6 1.4 7.7 3.0 6.1 2.3 6.3 3.4 5.6 2.4 6.4 3.1 5.5 1.8 6.0 3.0 4.8 1.8 6.9 3.1 5.4 2.1 6.7 3.1 5.6 2.4 6.9 3.1 5.1 2.3 5.8 2.7 5.1 1.9 6.8 3.2 5.9 2.3 6.7 3.3 5.7 2.5 6.7 3.0 5.2 2.3 6.3 2.5 5.0 1.9 6.5 3.0 5.2 2.0 6.2 3.4 5.4 2.3 5.9 3.0 5.1 1.8
Parag Kanade/fuzzy ants/Iris/2class/irisFull.data
1 | 5.1 | 3.5 | 1.4 | 0.2 |
1 | 4.9 | 3 | 1.4 | 0.2 |
1 | 4.7 | 3.2 | 1.3 | 0.2 |
1 | 4.6 | 3.1 | 1.5 | 0.2 |
1 | 5 | 3.6 | 1.4 | 0.2 |
1 | 5.4 | 3.9 | 1.7 | 0.4 |
1 | 4.6 | 3.4 | 1.4 | 0.3 |
1 | 5 | 3.4 | 1.5 | 0.2 |
1 | 4.4 | 2.9 | 1.4 | 0.2 |
1 | 4.9 | 3.1 | 1.5 | 0.1 |
1 | 5.4 | 3.7 | 1.5 | 0.2 |
1 | 4.8 | 3.4 | 1.6 | 0.2 |
1 | 4.8 | 3 | 1.4 | 0.1 |
1 | 4.3 | 3 | 1.1 | 0.1 |
1 | 5.8 | 4 | 1.2 | 0.2 |
1 | 5.7 | 4.4 | 1.5 | 0.4 |
1 | 5.4 | 3.9 | 1.3 | 0.4 |
1 | 5.1 | 3.5 | 1.4 | 0.3 |
1 | 5.7 | 3.8 | 1.7 | 0.3 |
1 | 5.1 | 3.8 | 1.5 | 0.3 |
1 | 5.4 | 3.4 | 1.7 | 0.2 |
1 | 5.1 | 3.7 | 1.5 | 0.4 |
1 | 4.6 | 3.6 | 1 | 0.2 |
1 | 5.1 | 3.3 | 1.7 | 0.5 |
1 | 4.8 | 3.4 | 1.9 | 0.2 |
1 | 5 | 3 | 1.6 | 0.2 |
1 | 5 | 3.4 | 1.6 | 0.4 |
1 | 5.2 | 3.5 | 1.5 | 0.2 |
1 | 5.2 | 3.4 | 1.4 | 0.2 |
1 | 4.7 | 3.2 | 1.6 | 0.2 |
1 | 4.8 | 3.1 | 1.6 | 0.2 |
1 | 5.4 | 3.4 | 1.5 | 0.4 |
1 | 5.2 | 4.1 | 1.5 | 0.1 |
1 | 5.5 | 4.2 | 1.4 | 0.2 |
1 | 4.9 | 3.1 | 1.5 | 0.1 |
1 | 5 | 3.2 | 1.2 | 0.2 |
1 | 5.5 | 3.5 | 1.3 | 0.2 |
1 | 4.9 | 3.1 | 1.5 | 0.1 |
1 | 4.4 | 3 | 1.3 | 0.2 |
1 | 5.1 | 3.4 | 1.5 | 0.2 |
1 | 5 | 3.5 | 1.3 | 0.3 |
1 | 4.5 | 2.3 | 1.3 | 0.3 |
1 | 4.4 | 3.2 | 1.3 | 0.2 |
1 | 5 | 3.5 | 1.6 | 0.6 |
1 | 5.1 | 3.8 | 1.9 | 0.4 |
1 | 4.8 | 3 | 1.4 | 0.3 |
1 | 5.1 | 3.8 | 1.6 | 0.2 |
1 | 4.6 | 3.2 | 1.4 | 0.2 |
1 | 5.3 | 3.7 | 1.5 | 0.2 |
1 | 5 | 3.3 | 1.4 | 0.2 |
2 | 7 | 3.2 | 4.7 | 1.4 |
2 | 6.4 | 3.2 | 4.5 | 1.5 |
2 | 6.9 | 3.1 | 4.9 | 1.5 |
2 | 5.5 | 2.3 | 4 | 1.3 |
2 | 6.5 | 2.8 | 4.6 | 1.5 |
2 | 5.7 | 2.8 | 4.5 | 1.3 |
2 | 6.3 | 3.3 | 4.7 | 1.6 |
2 | 4.9 | 2.4 | 3.3 | 1 |
2 | 6.6 | 2.9 | 4.6 | 1.3 |
2 | 5.2 | 2.7 | 3.9 | 1.4 |
2 | 5 | 2 | 3.5 | 1 |
2 | 5.9 | 3 | 4.2 | 1.5 |
2 | 6 | 2.2 | 4 | 1 |
2 | 6.1 | 2.9 | 4.7 | 1.4 |
2 | 5.6 | 2.9 | 3.6 | 1.3 |
2 | 6.7 | 3.1 | 4.4 | 1.4 |
2 | 5.6 | 3 | 4.5 | 1.5 |
2 | 5.8 | 2.7 | 4.1 | 1 |
2 | 6.2 | 2.2 | 4.5 | 1.5 |
2 | 5.6 | 2.5 | 3.9 | 1.1 |
2 | 5.9 | 3.2 | 4.8 | 1.8 |
2 | 6.1 | 2.8 | 4 | 1.3 |
2 | 6.3 | 2.5 | 4.9 | 1.5 |
2 | 6.1 | 2.8 | 4.7 | 1.2 |
2 | 6.4 | 2.9 | 4.3 | 1.3 |
2 | 6.6 | 3 | 4.4 | 1.4 |
2 | 6.8 | 2.8 | 4.8 | 1.4 |
2 | 6.7 | 3 | 5 | 1.7 |
2 | 6 | 2.9 | 4.5 | 1.5 |
2 | 5.7 | 2.6 | 3.5 | 1 |
2 | 5.5 | 2.4 | 3.8 | 1.1 |
2 | 5.5 | 2.4 | 3.7 | 1 |
2 | 5.8 | 2.7 | 3.9 | 1.2 |
2 | 6 | 2.7 | 5.1 | 1.6 |
2 | 5.4 | 3 | 4.5 | 1.5 |
2 | 6 | 3.4 | 4.5 | 1.6 |
2 | 6.7 | 3.1 | 4.7 | 1.5 |
2 | 6.3 | 2.3 | 4.4 | 1.3 |
2 | 5.6 | 3 | 4.1 | 1.3 |
2 | 5.5 | 2.5 | 4 | 1.3 |
2 | 5.5 | 2.6 | 4.4 | 1.2 |
2 | 6.1 | 3 | 4.6 | 1.4 |
2 | 5.8 | 2.6 | 4 | 1.2 |
2 | 5 | 2.3 | 3.3 | 1 |
2 | 5.6 | 2.7 | 4.2 | 1.3 |
2 | 5.7 | 3 | 4.2 | 1.2 |
2 | 5.7 | 2.9 | 4.2 | 1.3 |
2 | 6.2 | 2.9 | 4.3 | 1.3 |
2 | 5.1 | 2.5 | 3 | 1.1 |
2 | 5.7 | 2.8 | 4.1 | 1.3 |
2 | 6.3 | 3.3 | 6 | 2.5 |
2 | 5.8 | 2.7 | 5.1 | 1.9 |
2 | 7.1 | 3 | 5.9 | 2.1 |
2 | 6.3 | 2.9 | 5.6 | 1.8 |
2 | 6.5 | 3 | 5.8 | 2.2 |
2 | 7.6 | 3 | 6.6 | 2.1 |
2 | 4.9 | 2.5 | 4.5 | 1.7 |
2 | 7.3 | 2.9 | 6.3 | 1.8 |
2 | 6.7 | 2.5 | 5.8 | 1.8 |
2 | 7.2 | 3.6 | 6.1 | 2.5 |
2 | 6.5 | 3.2 | 5.1 | 2 |
2 | 6.4 | 2.7 | 5.3 | 1.9 |
2 | 6.8 | 3 | 5.5 | 2.1 |
2 | 5.7 | 2.5 | 5 | 2 |
2 | 5.8 | 2.8 | 5.1 | 2.4 |
2 | 6.4 | 3.2 | 5.3 | 2.3 |
2 | 6.5 | 3 | 5.5 | 1.8 |
2 | 7.7 | 3.8 | 6.7 | 2.2 |
2 | 7.7 | 2.6 | 6.9 | 2.3 |
2 | 6 | 2.2 | 5 | 1.5 |
2 | 6.9 | 3.2 | 5.7 | 2.3 |
2 | 5.6 | 2.8 | 4.9 | 2 |
2 | 7.7 | 2.8 | 6.7 | 2 |
2 | 6.3 | 2.7 | 4.9 | 1.8 |
2 | 6.7 | 3.3 | 5.7 | 2.1 |
2 | 7.2 | 3.2 | 6 | 1.8 |
2 | 6.2 | 2.8 | 4.8 | 1.8 |
2 | 6.1 | 3 | 4.9 | 1.8 |
2 | 6.4 | 2.8 | 5.6 | 2.1 |
2 | 7.2 | 3 | 5.8 | 1.6 |
2 | 7.4 | 2.8 | 6.1 | 1.9 |
2 | 7.9 | 3.8 | 6.4 | 2 |
2 | 6.4 | 2.8 | 5.6 | 2.2 |
2 | 6.3 | 2.8 | 5.1 | 1.5 |
2 | 6.1 | 2.6 | 5.6 | 1.4 |
2 | 7.7 | 3 | 6.1 | 2.3 |
2 | 6.3 | 3.4 | 5.6 | 2.4 |
2 | 6.4 | 3.1 | 5.5 | 1.8 |
2 | 6 | 3 | 4.8 | 1.8 |
2 | 6.9 | 3.1 | 5.4 | 2.1 |
2 | 6.7 | 3.1 | 5.6 | 2.4 |
2 | 6.9 | 3.1 | 5.1 | 2.3 |
2 | 5.8 | 2.7 | 5.1 | 1.9 |
2 | 6.8 | 3.2 | 5.9 | 2.3 |
2 | 6.7 | 3.3 | 5.7 | 2.5 |
2 | 6.7 | 3 | 5.2 | 2.3 |
2 | 6.3 | 2.5 | 5 | 1.9 |
2 | 6.5 | 3 | 5.2 | 2 |
2 | 6.2 | 3.4 | 5.4 | 2.3 |
2 | 5.9 | 3 | 5.1 | 1.8 |
Parag Kanade/fuzzy ants/Iris/2class/headerStatic.h
/********************************************************************//* Ant Class parameters *//* SPEED # amplitude of moves [1,10] *//* P direction Probability to move in the same direction [.5,1] *//* Max carry : Maximum object carrying time [20,200] *//* P load Probability to pick up a single object [0.4,0.8] *//* P destroy probability to destroy a heap of two objects [0,0.6] *//* T remove min. dissimilarity necessary for removing an object *//* from a heap [.1,.2] *//* T create max dissimilarity permitted for creating a heap[.05,.2]*//********************************************************************/ #include <stdio.h>#include <math.h>#include <string.h>#include<stdlib.h>#include <ctype.h>#include <time.h>#define MAXANTS 50#define MAXDATA 150#define MAXANTSFORHEAPS 10#define MAXITERATIONS 1000#define MAXROWS 30#define MAXCOLS 30#define EXPRUN 50#define Tremove 1.50#define Tcreate 0.5#define Pdrop 0.2#define Pdestroy 0.3#define Pload 0.3#define normalize 0#define EntireHeaps 1#define TcreateForHeaps 0.12#define features 4#define filename "iris"#define errThresh 0.1#define dataDump 1#define maxDist 1#define INITIALOBJECTS 75#define OBJINC 10/* some type definitions to make C code a little more readable */#define TRUE 1#define FALSE 0#define n MAXDATA /* number of input vectors */#define s features /* number of features */#define c 2 /* number of clusters */#define TOTRUNS 1 /* number of V's to write out */#define false 0#define true 1#define maha 0#define square 0extern int count;int debugLevel=0;/* To debug the code and verify the correctness of algorithms*/int currHeapCount=0;typedef int BOOLEAN;typedef short TYPE_IN_DATA; /* Type of input binary data */typedef float feature[s]; /* Type of each input; made up of input features */typedef float irisData[s];typedef feature objects[MAXDATA]; /* Type of array holding all inputs */typedef feature center[MAXDATA]; /* Type of array holding cluster centers */typedef float matrix[MAXDATA][MAXDATA];/* Type of the matrix containing membership grades */typedef struct Heap {float Dmax;//maximum dissimilar distanceirisData Ocenter;//center objectfloat Dmean;//mean of the distance between the center and all the objectsirisData Odissim;//most dissimilar objectint x;//x position on the boardint y;//y position on the boardint count;//number of objects in the heapsint disPosition;//most dissimilar objectint objects[MAXDATA];int objCount;}heap;typedef struct Ant{int x;int y;int carrying;int speed;int dir;irisData data;}ant;float orgData[n][s+1];float fcmData[260][n][s];int clsCenCount[260];int currentRow=0;int currentAntCount=0;int updateAfter=50;int heapSum=0;int minAnts=3;int rowMin=5;typedef struct HeapInfo{int total;int classObj[c];} heapInfo;/*heapInfo info[MAXDATA];*//********************************************************************//***Function decelarations*//********************************************************************//***For ant based algorithm*/void readInput();float computeDistance();float computeDistanceBetween2(irisData a,irisData b);float findMax(float *distance);float value(irisData a);int found(int a , int b);void initialise(int flag);int findObject(int a,int b);void initialiseAnts(int flag);void moveNext(ant* a,int flag);void computeHeapParameters(heap* data,int flag);void pickObject1(ant *a,int position,int flag);void pickObject2(ant *a , int position,int flag);void pickObjectn(ant *a,int position,int flag);void pick(ant *a,int flag);void dropObject(ant* a,int flag);int findInNewheaps(irisData object);void dropObject1(ant* a, int position,int flag);void drop(ant* a,int flag);void move(ant* a,int flag);void iterate(int flag);void dropFinal(int flag);int partition(heap a[], int low,int high);void quickSort( heap A[], int low,int high ) ;void writeClusterInformation(int flag);void initialiseNewHeaps(heap newHeaps[]);int findPosition(int i);void harden(heap newHeaps[]);void harden1();int findPosition1(int );void writeInfo();void addObject1(int ,int);void readFCM(FILE *,FILE *);void readOrg();int findInData(irisData input,int iflag);void adjustBoard(int flag);void writeIncremental(int iteration,int flag);/********************************************************************//***For FCM algorithm*/void GET_INPUTS1(char []);void UMAT( matrix,center,objects);BOOLEAN FINISHED(matrix, float);void CLUSTER( matrix, objects);void Output(char[]);void Fcm();/********************************************************************/
Parag Kanade/fuzzy ants/Iris/headerStatic.h
/********************************************************************//* Ant Class parameters *//* SPEED # amplitude of moves [1,10] *//* P direction Probability to move in the same direction [.5,1] *//* Max carry : Maximum object carrying time [20,200] *//* P load Probability to pick up a single object [0.4,0.8] *//* P destroy probability to destroy a heap of two objects [0,0.6] *//* T remove min. dissimilarity necessary for removing an object *//* from a heap [.1,.2] *//* T create max dissimilarity permitted for creating a heap[.05,.2]*//********************************************************************/ #include <stdio.h>#include <math.h>#include <string.h>#include<stdlib.h>#include <ctype.h>#include <time.h>#define MAXANTS 50#define MAXDATA 150#define MAXANTSFORHEAPS 10#define MAXITERATIONS 1000#define MAXROWS 30#define MAXCOLS 30#define EXPRUN 50#define Tremove 1.50#define Tcreate 0.5#define Pdrop 0.2#define Pdestroy 0.3#define Pload 0.3#define normalize 0#define EntireHeaps 1#define TcreateForHeaps 0.14#define features 4#define filename "iris"#define errThresh 0.1#define dataDump 1#define maxDist 0#define INITIALOBJECTS 75#define OBJINC 10/* some type definitions to make C code a little more readable */#define TRUE 1#define FALSE 0#define n MAXDATA /* number of input vectors */#define s features /* number of features */#define c 3 /* number of clusters */#define TOTRUNS 1 /* number of V's to write out */#define false 0#define true 1#define maha 0#define square 0extern int count;int debugLevel=0;/* To debug the code and verify the correctness of algorithms*/int currHeapCount=0;typedef int BOOLEAN;typedef short TYPE_IN_DATA; /* Type of input binary data */typedef float feature[s]; /* Type of each input; made up of input features */typedef float irisData[s];typedef feature objects[MAXDATA]; /* Type of array holding all inputs */typedef feature center[MAXDATA]; /* Type of array holding cluster centers */typedef float matrix[MAXDATA][MAXDATA];/* Type of the matrix containing membership grades */typedef struct Heap {float Dmax;//maximum dissimilar distanceirisData Ocenter;//center objectfloat Dmean;//mean of the distance between the center and all the objectsirisData Odissim;//most dissimilar objectint x;//x position on the boardint y;//y position on the boardint count;//number of objects in the heapsint disPosition;//most dissimilar objectint objects[MAXDATA];int objCount;}heap;typedef struct Ant{int x;int y;int carrying;int speed;int dir;irisData data;}ant;float orgData[n][s+1];float fcmData[260][n][s];int clsCenCount[260];int currentRow=0;int currentAntCount=0;int updateAfter=50;int heapSum=0;int minAnts=3;int rowMin=5;typedef struct HeapInfo{int total;int classObj[c];} heapInfo;/*heapInfo info[MAXDATA];*//********************************************************************//***Function decelarations*//********************************************************************//***For ant based algorithm*/void readInput();float computeDistance();float computeDistanceBetween2(irisData a,irisData b);float findMax(float *distance);float value(irisData a);int found(int a , int b);void initialise(int flag);int findObject(int a,int b);void initialiseAnts(int flag);void moveNext(ant* a,int flag);void computeHeapParameters(heap* data,int flag);void pickObject1(ant *a,int position,int flag);void pickObject2(ant *a , int position,int flag);void pickObjectn(ant *a,int position,int flag);void pick(ant *a,int flag);void dropObject(ant* a,int flag);int findInNewheaps(irisData object);void dropObject1(ant* a, int position,int flag);void drop(ant* a,int flag);void move(ant* a,int flag);void iterate(int flag);void dropFinal(int flag);int partition(heap a[], int low,int high);void quickSort( heap A[], int low,int high ) ;void writeClusterInformation(int flag);void initialiseNewHeaps(heap newHeaps[]);int findPosition(int i);void harden(heap newHeaps[]);void harden1();int findPosition1(int );void writeInfo();void addObject1(int ,int);void readFCM(FILE *,FILE *);void readOrg();int findInData(irisData input,int iflag);void adjustBoard(int flag);void writeIncremental(int iteration,int flag);/********************************************************************//***For FCM algorithm*/void GET_INPUTS1(char []);void UMAT( matrix,center,objects);BOOLEAN FINISHED(matrix, float);void CLUSTER( matrix, objects);void Output(char[]);void Fcm();/********************************************************************/
Parag Kanade/fuzzy ants/Iris/maxData.txt
3.220810
Parag Kanade/fuzzy ants/Glass/headerStatic.h
/********************************************************************/ /* Ant Class parameters */ /* SPEED # amplitude of moves [1,10] */ /* P direction Probability to move in the same direction [.5,1] */ /* Max carry : Maximum object carrying time [20,200] */ /* P load Probability to pick up a single object [0.4,0.8] */ /* P destroy probability to destroy a heap of two objects [0,0.6] */ /* T remove min. dissimilarity necessary for removing an object */ /* from a heap [.1,.2] */ /* T create max dissimilarity permitted for creating a heap[.05,.2]*/ /********************************************************************/ #include <stdio.h> #include <math.h> #include <string.h> #include<stdlib.h> #include <ctype.h> #include <time.h> #define MAXANTS 72 #define MAXDATA 214 #define MAXANTSFORHEAPS 10 #define MAXITERATIONS 1000 #define MAXROWS 30 #define MAXCOLS 30 #define EXPRUN 50 #define Tremove 2.0 #define Tcreate 0.5 #define Pdrop 0.2 #define Pdestroy 0.3 #define Pload 0.3 #define normalize 0 #define EntireHeaps 1 #define TcreateForHeaps 0.105 #define features 9 #define filename "glass" #define errThresh 0.01 #define dataDump 1 #define maxDist 0 #define INITIALOBJECTS 75 #define OBJINC 10 /* some type definitions to make C code a little more readable */ #define TRUE 1 #define FALSE 0 #define n MAXDATA /* number of input vectors */ #define s features /* number of features */ #define c 6 /* number of clusters */ #define TOTRUNS 1 /* number of V's to write out */ #define false 0 #define true 1 #define maha 0 #define square 0 extern int count; int debugLevel=0;/* To debug the code and verify the correctness of algorithms*/ int currHeapCount=0; typedef int BOOLEAN; typedef short TYPE_IN_DATA; /* Type of input binary data */ typedef float feature[s]; /* Type of each input; made up of input features */ typedef float irisData[s]; typedef feature objects[MAXDATA]; /* Type of array holding all inputs */ typedef feature center[MAXDATA]; /* Type of array holding cluster centers */ typedef float matrix[MAXDATA][MAXDATA];/* Type of the matrix containing membership grades */ typedef struct Heap { float Dmax;//maximum dissimilar distance irisData Ocenter;//center object float Dmean;//mean of the distance between the center and all the objects irisData Odissim;//most dissimilar object int x;//x position on the board int y;//y position on the board int count;//number of objects in the heaps int disPosition;//most dissimilar object int objects[MAXDATA]; int objCount; }heap; typedef struct Ant { int x; int y; int carrying; int speed; int dir; irisData data; }ant; float orgData[n][s+1]; float fcmData[260][n][s]; int clsCenCount[260]; int currentRow=0; int currentAntCount=0; int updateAfter=50; int heapSum=0; int minAnts=3; int rowMin=5; typedef struct HeapInfo { int total; int classObj[c]; } heapInfo; /*heapInfo info[MAXDATA];*/ /********************************************************************/ /***Function decelarations*/ /********************************************************************/ /***For ant based algorithm*/ void readInput(); float computeDistance(); float computeDistanceBetween2(irisData a,irisData b); float findMax(float *distance); float value(irisData a); int found(int a , int b); void initialise(int flag); int findObject(int a,int b); void initialiseAnts(int flag); void moveNext(ant* a,int flag); void computeHeapParameters(heap* data,int flag); void pickObject1(ant *a,int position,int flag); void pickObject2(ant *a , int position,int flag); void pickObjectn(ant *a,int position,int flag); void pick(ant *a,int flag); void dropObject(ant* a,int flag); int findInNewheaps(irisData object); void dropObject1(ant* a, int position,int flag); void drop(ant* a,int flag); void move(ant* a,int flag); void iterate(int flag); void dropFinal(int flag); int partition(heap a[], int low,int high); void quickSort( heap A[], int low,int high ) ; void writeClusterInformation(int flag); void initialiseNewHeaps(heap newHeaps[]); int findPosition(int i); void harden(heap newHeaps[]); void harden1(); int findPosition1(int ); void writeInfo(); void addObject1(int ,int); void readFCM(FILE *,FILE *); void readOrg(); int findInData(irisData input,int iflag); void adjustBoard(int flag); void writeIncremental(int iteration,int flag); /********************************************************************/ /***For FCM algorithm*/ void GET_INPUTS1(char []); void UMAT( matrix,center,objects); BOOLEAN FINISHED(matrix, float); void CLUSTER( matrix, objects); void Output(char[]); void Fcm(); /********************************************************************/
Parag Kanade/fuzzy ants/Glass/maxData.txt
5.691089
Parag Kanade/fuzzy ants/Glass/glass.data
Glass Data # 1.52101 13.64 4.49 1.1 71.78 0.06 8.75 0 0 1.51761 13.89 3.6 1.36 72.73 0.48 7.83 0 0 1.51618 13.53 3.55 1.54 72.99 0.39 7.78 0 0 1.51766 13.21 3.69 1.29 72.61 0.57 8.22 0 0 1.51742 13.27 3.62 1.24 73.08 0.55 8.07 0 0 1.51596 12.79 3.61 1.62 72.97 0.64 8.07 0 0.26 1.51743 13.3 3.6 1.14 73.09 0.58 8.17 0 0 1.51756 13.15 3.61 1.05 73.24 0.57 8.24 0 0 1.51918 14.04 3.58 1.37 72.08 0.56 8.3 0 0 1.51755 13 3.6 1.36 72.99 0.57 8.4 0 0.11 1.51571 12.72 3.46 1.56 73.2 0.67 8.09 0 0.24 1.51763 12.8 3.66 1.27 73.01 0.6 8.56 0 0 1.51589 12.88 3.43 1.4 73.28 0.69 8.05 0 0.24 1.51748 12.86 3.56 1.27 73.21 0.54 8.38 0 0.17 1.51763 12.61 3.59 1.31 73.29 0.58 8.5 0 0 1.51761 12.81 3.54 1.23 73.24 0.58 8.39 0 0 1.51784 12.68 3.67 1.16 73.11 0.61 8.7 0 0 1.52196 14.36 3.85 0.89 71.36 0.15 9.15 0 0 1.51911 13.9 3.73 1.18 72.12 0.06 8.89 0 0 1.51735 13.02 3.54 1.69 72.73 0.54 8.44 0 0.07 1.5175 12.82 3.55 1.49 72.75 0.54 8.52 0 0.19 1.51966 14.77 3.75 0.29 72.02 0.03 9 0 0 1.51736 12.78 3.62 1.29 72.79 0.59 8.7 0 0 1.51751 12.81 3.57 1.35 73.02 0.62 8.59 0 0 1.5172 13.38 3.5 1.15 72.85 0.5 8.43 0 0 1.51764 12.98 3.54 1.21 73 0.65 8.53 0 0 1.51793 13.21 3.48 1.41 72.64 0.59 8.43 0 0 1.51721 12.87 3.48 1.33 73.04 0.56 8.43 0 0 1.51768 12.56 3.52 1.43 73.15 0.57 8.54 0 0 1.51784 13.08 3.49 1.28 72.86 0.6 8.49 0 0 1.51768 12.65 3.56 1.3 73.08 0.61 8.69 0 0.14 1.51747 12.84 3.5 1.14 73.27 0.56 8.55 0 0 1.51775 12.85 3.48 1.23 72.97 0.61 8.56 0.09 0.22 1.51753 12.57 3.47 1.38 73.39 0.6 8.55 0 0.06 1.51783 12.69 3.54 1.34 72.95 0.57 8.75 0 0 1.51567 13.29 3.45 1.21 72.74 0.56 8.57 0 0 1.51909 13.89 3.53 1.32 71.81 0.51 8.78 0.11 0 1.51797 12.74 3.48 1.35 72.96 0.64 8.68 0 0 1.52213 14.21 3.82 0.47 71.77 0.11 9.57 0 0 1.52213 14.21 3.82 0.47 71.77 0.11 9.57 0 0 1.51793 12.79 3.5 1.12 73.03 0.64 8.77 0 0 1.51755 12.71 3.42 1.2 73.2 0.59 8.64 0 0 1.51779 13.21 3.39 1.33 72.76 0.59 8.59 0 0 1.5221 13.73 3.84 0.72 71.76 0.17 9.74 0 0 1.51786 12.73 3.43 1.19 72.95 0.62 8.76 0 0.3 1.519 13.49 3.48 1.35 71.95 0.55 9 0 0 1.51869 13.19 3.37 1.18 72.72 0.57 8.83 0 0.16 1.52667 13.99 3.7 0.71 71.57 0.02 9.82 0 0.1 1.52223 13.21 3.77 0.79 71.99 0.13 10.02 0 0 1.51898 13.58 3.35 1.23 72.08 0.59 8.91 0 0 1.5232 13.72 3.72 0.51 71.75 0.09 10.06 0 0.16 1.51926 13.2 3.33 1.28 72.36 0.6 9.14 0 0.11 1.51808 13.43 2.87 1.19 72.84 0.55 9.03 0 0 1.51837 13.14 2.84 1.28 72.85 0.55 9.07 0 0 1.51778 13.21 2.81 1.29 72.98 0.51 9.02 0 0.09 1.51769 12.45 2.71 1.29 73.7 0.56 9.06 0 0.24 1.51215 12.99 3.47 1.12 72.98 0.62 8.35 0 0.31 1.51824 12.87 3.48 1.29 72.95 0.6 8.43 0 0 1.51754 13.48 3.74 1.17 72.99 0.59 8.03 0 0 1.51754 13.39 3.66 1.19 72.79 0.57 8.27 0 0.11 1.51905 13.6 3.62 1.11 72.64 0.14 8.76 0 0 1.51977 13.81 3.58 1.32 71.72 0.12 8.67 0.69 0 1.52172 13.51 3.86 0.88 71.79 0.23 9.54 0 0.11 1.52227 14.17 3.81 0.78 71.35 0 9.69 0 0 1.52172 13.48 3.74 0.9 72.01 0.18 9.61 0 0.07 1.52099 13.69 3.59 1.12 71.96 0.09 9.4 0 0 1.52152 13.05 3.65 0.87 72.22 0.19 9.85 0 0.17 1.52152 13.05 3.65 0.87 72.32 0.19 9.85 0 0.17 1.52152 13.12 3.58 0.9 72.2 0.23 9.82 0 0.16 1.523 13.31 3.58 0.82 71.99 0.12 10.17 0 0.03 1.51574 14.86 3.67 1.74 71.87 0.16 7.36 0 0.12 1.51848 13.64 3.87 1.27 71.96 0.54 8.32 0 0.32 1.51593 13.09 3.59 1.52 73.1 0.67 7.83 0 0 1.51631 13.34 3.57 1.57 72.87 0.61 7.89 0 0 1.51596 13.02 3.56 1.54 73.11 0.72 7.9 0 0 1.5159 13.02 3.58 1.51 73.12 0.69 7.96 0 0 1.51645 13.44 3.61 1.54 72.39 0.66 8.03 0 0 1.51627 13 3.58 1.54 72.83 0.61 8.04 0 0 1.51613 13.92 3.52 1.25 72.88 0.37 7.94 0 0.14 1.5159 12.82 3.52 1.9 72.86 0.69 7.97 0 0 1.51592 12.86 3.52 2.12 72.66 0.69 7.97 0 0 1.51593 13.25 3.45 1.43 73.17 0.61 7.86 0 0 1.51646 13.41 3.55 1.25 72.81 0.68 8.1 0 0 1.51594 13.09 3.52 1.55 72.87 0.68 8.05 0 0.09 1.51409 14.25 3.09 2.08 72.28 1.1 7.08 0 0 1.51625 13.36 3.58 1.49 72.72 0.45 8.21 0 0 1.51569 13.24 3.49 1.47 73.25 0.38 8.03 0 0 1.51645 13.4 3.49 1.52 72.65 0.67 8.08 0 0.1 1.51618 13.01 3.5 1.48 72.89 0.6 8.12 0 0 1.5164 12.55 3.48 1.87 73.23 0.63 8.08 0 0.09 1.51841 12.93 3.74 1.11 72.28 0.64 8.96 0 0.22 1.51605 12.9 3.44 1.45 73.06 0.44 8.27 0 0 1.51588 13.12 3.41 1.58 73.26 0.07 8.39 0 0.19 1.5159 13.24 3.34 1.47 73.1 0.39 8.22 0 0 1.51629 12.71 3.33 1.49 73.28 0.67 8.24 0 0 1.5186 13.36 3.43 1.43 72.26 0.51 8.6 0 0 1.51841 13.02 3.62 1.06 72.34 0.64 9.13 0 0.15 1.51743 12.2 3.25 1.16 73.55 0.62 8.9 0 0.24 1.51689 12.67 2.88 1.71 73.21 0.73 8.54 0 0 1.51811 12.96 2.96 1.43 72.92 0.6 8.79 0.14 0 1.51655 12.75 2.85 1.44 73.27 0.57 8.79 0.11 0.22 1.5173 12.35 2.72 1.63 72.87 0.7 9.23 0 0 1.5182 12.62 2.76 0.83 73.81 0.35 9.42 0 0.2 1.52725 13.8 3.15 0.66 70.57 0.08 11.64 0 0 1.5241 13.83 2.9 1.17 71.15 0.08 10.79 0 0 1.52475 11.45 0 1.88 72.19 0.81 13.24 0 0.34 1.53125 10.73 0 2.1 69.81 0.58 13.3 3.15 0.28 1.53393 12.3 0 1 70.16 0.12 16.19 0 0.24 1.52222 14.43 0 1 72.67 0.1 11.52 0 0.08 1.51818 13.72 0 0.56 74.45 0 10.99 0 0 1.52664 11.23 0 0.77 73.21 0 14.68 0 0 1.52739 11.02 0 0.75 73.08 0 14.96 0 0 1.52777 12.64 0 0.67 72.02 0.06 14.4 0 0 1.51892 13.46 3.83 1.26 72.55 0.57 8.21 0 0.14 1.51847 13.1 3.97 1.19 72.44 0.6 8.43 0 0 1.51846 13.41 3.89 1.33 72.38 0.51 8.28 0 0 1.51829 13.24 3.9 1.41 72.33 0.55 8.31 0 0.1 1.51708 13.72 3.68 1.81 72.06 0.64 7.88 0 0 1.51673 13.3 3.64 1.53 72.53 0.65 8.03 0 0.29 1.51652 13.56 3.57 1.47 72.45 0.64 7.96 0 0 1.51844 13.25 3.76 1.32 72.4 0.58 8.42 0 0 1.51663 12.93 3.54 1.62 72.96 0.64 8.03 0 0.21 1.51687 13.23 3.54 1.48 72.84 0.56 8.1 0 0 1.51707 13.48 3.48 1.71 72.52 0.62 7.99 0 0 1.52177 13.2 3.68 1.15 72.75 0.54 8.52 0 0 1.51872 12.93 3.66 1.56 72.51 0.58 8.55 0 0.12 1.51667 12.94 3.61 1.26 72.75 0.56 8.6 0 0 1.52081 13.78 2.28 1.43 71.99 0.49 9.85 0 0.17 1.52068 13.55 2.09 1.67 72.18 0.53 9.57 0.27 0.17 1.5202 13.98 1.35 1.63 71.76 0.39 10.56 0 0.18 1.52177 13.75 1.01 1.36 72.19 0.33 11.14 0 0 1.52614 13.7 0 1.36 71.24 0.19 13.44 0 0.1 1.51813 13.43 3.98 1.18 72.49 0.58 8.15 0 0 1.518 13.71 3.93 1.54 71.81 0.54 8.21 0 0.15 1.51811 13.33 3.85 1.25 72.78 0.52 8.12 0 0 1.51789 13.19 3.9 1.3 72.33 0.55 8.44 0 0.28 1.51806 13 3.8 1.08 73.07 0.56 8.38 0 0.12 1.51711 12.89 3.62 1.57 72.96 0.61 8.11 0 0 1.51674 12.79 3.52 1.54 73.36 0.66 7.9 0 0 1.51674 12.87 3.56 1.64 73.14 0.65 7.99 0 0 1.5169 13.33 3.54 1.61 72.54 0.68 8.11 0 0 1.51851 13.2 3.63 1.07 72.83 0.57 8.41 0.09 0.17 1.51662 12.85 3.51 1.44 73.01 0.68 8.23 0.06 0.25 1.51709 13 3.47 1.79 72.72 0.66 8.18 0 0 1.5166 12.99 3.18 1.23 72.97 0.58 8.81 0 0.24 1.51839 12.85 3.67 1.24 72.57 0.62 8.68 0 0.35 1.51769 13.65 3.66 1.11 72.77 0.11 8.6 0 0 1.5161 13.33 3.53 1.34 72.67 0.56 8.33 0 0 1.5167 13.24 3.57 1.38 72.7 0.56 8.44 0 0.1 1.51643 12.16 3.52 1.35 72.89 0.57 8.53 0 0 1.51665 13.14 3.45 1.76 72.48 0.6 8.38 0 0.17 1.52127 14.32 3.9 0.83 71.5 0 9.49 0 0 1.51779 13.64 3.65 0.65 73 0.06 8.93 0 0 1.5161 13.42 3.4 1.22 72.69 0.59 8.32 0 0 1.51694 12.86 3.58 1.31 72.61 0.61 8.79 0 0 1.51646 13.04 3.4 1.26 73.01 0.52 8.58 0 0 1.51655 13.41 3.39 1.28 72.64 0.52 8.65 0 0 1.52121 14.03 3.76 0.58 71.79 0.11 9.65 0 0 1.51776 13.53 3.41 1.52 72.04 0.58 8.79 0 0 1.51796 13.5 3.36 1.63 71.94 0.57 8.81 0 0.09 1.51832 13.33 3.34 1.54 72.14 0.56 8.99 0 0 1.51934 13.64 3.54 0.75 72.65 0.16 8.89 0.15 0.24 1.52211 14.19 3.78 0.91 71.36 0.23 9.14 0 0.37 1.51514 14.01 2.68 3.5 69.89 1.68 5.87 2.2 0 1.51915 12.73 1.85 1.86 72.69 0.6 10.09 0 0 1.52171 11.56 1.88 1.56 72.86 0.47 11.41 0 0 1.52151 11.03 1.71 1.56 73.44 0.58 11.62 0 0 1.51969 12.64 0 1.65 73.75 0.38 11.53 0 0 1.51666 12.86 0 1.83 73.88 0.97 10.17 0 0 1.51994 13.27 0 1.76 73.03 0.47 11.32 0 0 1.52369 13.44 0 1.58 72.22 0.32 12.24 0 0 1.51316 13.02 0 3.04 70.48 6.21 6.96 0 0 1.51321 13 0 3.02 70.7 6.21 6.93 0 0 1.52043 13.38 0 1.4 72.25 0.33 12.5 0 0 1.52058 12.85 1.61 2.17 72.18 0.76 9.7 0.24 0.51 1.52119 12.97 0.33 1.51 73.39 0.13 11.27 0 0.28 1.51905 14 2.39 1.56 72.37 0 9.57 0 0 1.51937 13.79 2.41 1.19 72.76 0 9.77 0 0 1.51829 14.46 2.24 1.62 72.38 0 9.26 0 0 1.51852 14.09 2.19 1.66 72.67 0 9.32 0 0 1.51299 14.4 1.74 1.54 74.55 0 7.59 0 0 1.51888 14.99 0.78 1.74 72.5 0 9.95 0 0 1.51916 14.15 0 2.09 72.74 0 10.88 0 0 1.51969 14.56 0 0.56 73.48 0 11.22 0 0 1.51115 17.38 0 0.34 75.41 0 6.65 0 0 1.51131 13.69 3.2 1.81 72.81 1.76 5.43 1.19 0 1.51838 14.32 3.26 2.22 71.25 1.46 5.79 1.63 0 1.52315 13.44 3.34 1.23 72.38 0.6 8.83 0 0 1.52247 14.86 2.2 2.06 70.26 0.76 9.76 0 0 1.52365 15.79 1.83 1.31 70.43 0.31 8.61 1.68 0 1.51613 13.88 1.78 1.79 73.1 0 8.67 0.76 0 1.51602 14.85 0 2.38 73.28 0 8.76 0.64 0.09 1.51623 14.2 0 2.79 73.46 0.04 9.04 0.4 0.09 1.51719 14.75 0 2 73.02 0 8.53 1.59 0.08 1.51683 14.56 0 1.98 73.29 0 8.52 1.57 0.07 1.51545 14.14 0 2.68 73.39 0.08 9.07 0.61 0.05 1.51556 13.87 0 2.54 73.23 0.14 9.41 0.81 0.01 1.51727 14.7 0 2.34 73.28 0 8.95 0.66 0 1.51531 14.38 0 2.66 73.1 0.04 9.08 0.64 0 1.51609 15.01 0 2.51 73.05 0.05 8.83 0.53 0 1.51508 15.15 0 2.25 73.5 0 8.34 0.63 0 1.51653 11.95 0 1.19 75.18 2.7 8.93 0 0 1.51514 14.85 0 2.42 73.72 0 8.39 0.56 0 1.51658 14.8 0 1.99 73.11 0 8.28 1.71 0 1.51617 14.95 0 2.27 73.3 0 8.71 0.67 0 1.51732 14.95 0 1.8 72.99 0 8.61 1.55 0 1.51645 14.94 0 1.87 73.11 0 8.67 1.38 0 1.51831 14.39 0 1.82 72.86 1.41 6.47 2.88 0 1.5164 14.37 0 2.74 72.85 0 9.45 0.54 0 1.51623 14.14 0 2.88 72.61 0.08 9.18 1.06 0 1.51685 14.92 0 1.99 73.06 0 8.4 1.59 0 1.52065 14.36 0 2.02 73.42 0 8.44 1.64 0 1.51651 14.38 0 1.94 73.61 0 8.48 1.57 0 1.51711 14.23 0 2.08 73.36 0 8.62 1.67 0
Parag Kanade/fuzzy ants/Glass/glassFull.data
1 | 1.52101 | 13.64 | 4.49 | 1.1 | 71.78 | 0.06 | 8.75 | 0 | 0 | |
1 | 1.51761 | 13.89 | 3.6 | 1.36 | 72.73 | 0.48 | 7.83 | 0 | 0 | |
1 | 1.51618 | 13.53 | 3.55 | 1.54 | 72.99 | 0.39 | 7.78 | 0 | 0 | |
1 | 1.51766 | 13.21 | 3.69 | 1.29 | 72.61 | 0.57 | 8.22 | 0 | 0 | |
1 | 1.51742 | 13.27 | 3.62 | 1.24 | 73.08 | 0.55 | 8.07 | 0 | 0 | |
1 | 1.51596 | 12.79 | 3.61 | 1.62 | 72.97 | 0.64 | 8.07 | 0 | 0.26 | |
1 | 1.51743 | 13.3 | 3.6 | 1.14 | 73.09 | 0.58 | 8.17 | 0 | 0 | |
1 | 1.51756 | 13.15 | 3.61 | 1.05 | 73.24 | 0.57 | 8.24 | 0 | 0 | |
1 | 1.51918 | 14.04 | 3.58 | 1.37 | 72.08 | 0.56 | 8.3 | 0 | 0 | |
1 | 1.51755 | 13 | 3.6 | 1.36 | 72.99 | 0.57 | 8.4 | 0 | 0.11 | |
1 | 1.51571 | 12.72 | 3.46 | 1.56 | 73.2 | 0.67 | 8.09 | 0 | 0.24 | |
1 | 1.51763 | 12.8 | 3.66 | 1.27 | 73.01 | 0.6 | 8.56 | 0 | 0 | |
1 | 1.51589 | 12.88 | 3.43 | 1.4 | 73.28 | 0.69 | 8.05 | 0 | 0.24 | |
1 | 1.51748 | 12.86 | 3.56 | 1.27 | 73.21 | 0.54 | 8.38 | 0 | 0.17 | |
1 | 1.51763 | 12.61 | 3.59 | 1.31 | 73.29 | 0.58 | 8.5 | 0 | 0 | |
1 | 1.51761 | 12.81 | 3.54 | 1.23 | 73.24 | 0.58 | 8.39 | 0 | 0 | |
1 | 1.51784 | 12.68 | 3.67 | 1.16 | 73.11 | 0.61 | 8.7 | 0 | 0 | |
1 | 1.52196 | 14.36 | 3.85 | 0.89 | 71.36 | 0.15 | 9.15 | 0 | 0 | |
1 | 1.51911 | 13.9 | 3.73 | 1.18 | 72.12 | 0.06 | 8.89 | 0 | 0 | |
1 | 1.51735 | 13.02 | 3.54 | 1.69 | 72.73 | 0.54 | 8.44 | 0 | 0.07 | |
1 | 1.5175 | 12.82 | 3.55 | 1.49 | 72.75 | 0.54 | 8.52 | 0 | 0.19 | |
1 | 1.51966 | 14.77 | 3.75 | 0.29 | 72.02 | 0.03 | 9 | 0 | 0 | |
1 | 1.51736 | 12.78 | 3.62 | 1.29 | 72.79 | 0.59 | 8.7 | 0 | 0 | |
1 | 1.51751 | 12.81 | 3.57 | 1.35 | 73.02 | 0.62 | 8.59 | 0 | 0 | |
1 | 1.5172 | 13.38 | 3.5 | 1.15 | 72.85 | 0.5 | 8.43 | 0 | 0 | |
1 | 1.51764 | 12.98 | 3.54 | 1.21 | 73 | 0.65 | 8.53 | 0 | 0 | |
1 | 1.51793 | 13.21 | 3.48 | 1.41 | 72.64 | 0.59 | 8.43 | 0 | 0 | |
1 | 1.51721 | 12.87 | 3.48 | 1.33 | 73.04 | 0.56 | 8.43 | 0 | 0 | |
1 | 1.51768 | 12.56 | 3.52 | 1.43 | 73.15 | 0.57 | 8.54 | 0 | 0 | |
1 | 1.51784 | 13.08 | 3.49 | 1.28 | 72.86 | 0.6 | 8.49 | 0 | 0 | |
1 | 1.51768 | 12.65 | 3.56 | 1.3 | 73.08 | 0.61 | 8.69 | 0 | 0.14 | |
1 | 1.51747 | 12.84 | 3.5 | 1.14 | 73.27 | 0.56 | 8.55 | 0 | 0 | |
1 | 1.51775 | 12.85 | 3.48 | 1.23 | 72.97 | 0.61 | 8.56 | 0.09 | 0.22 | |
1 | 1.51753 | 12.57 | 3.47 | 1.38 | 73.39 | 0.6 | 8.55 | 0 | 0.06 | |
1 | 1.51783 | 12.69 | 3.54 | 1.34 | 72.95 | 0.57 | 8.75 | 0 | 0 | |
1 | 1.51567 | 13.29 | 3.45 | 1.21 | 72.74 | 0.56 | 8.57 | 0 | 0 | |
1 | 1.51909 | 13.89 | 3.53 | 1.32 | 71.81 | 0.51 | 8.78 | 0.11 | 0 | |
1 | 1.51797 | 12.74 | 3.48 | 1.35 | 72.96 | 0.64 | 8.68 | 0 | 0 | |
1 | 1.52213 | 14.21 | 3.82 | 0.47 | 71.77 | 0.11 | 9.57 | 0 | 0 | |
1 | 1.52213 | 14.21 | 3.82 | 0.47 | 71.77 | 0.11 | 9.57 | 0 | 0 | |
1 | 1.51793 | 12.79 | 3.5 | 1.12 | 73.03 | 0.64 | 8.77 | 0 | 0 | |
1 | 1.51755 | 12.71 | 3.42 | 1.2 | 73.2 | 0.59 | 8.64 | 0 | 0 | |
1 | 1.51779 | 13.21 | 3.39 | 1.33 | 72.76 | 0.59 | 8.59 | 0 | 0 | |
1 | 1.5221 | 13.73 | 3.84 | 0.72 | 71.76 | 0.17 | 9.74 | 0 | 0 | |
1 | 1.51786 | 12.73 | 3.43 | 1.19 | 72.95 | 0.62 | 8.76 | 0 | 0.3 | |
1 | 1.519 | 13.49 | 3.48 | 1.35 | 71.95 | 0.55 | 9 | 0 | 0 | |
1 | 1.51869 | 13.19 | 3.37 | 1.18 | 72.72 | 0.57 | 8.83 | 0 | 0.16 | |
1 | 1.52667 | 13.99 | 3.7 | 0.71 | 71.57 | 0.02 | 9.82 | 0 | 0.1 | |
1 | 1.52223 | 13.21 | 3.77 | 0.79 | 71.99 | 0.13 | 10.02 | 0 | 0 | |
1 | 1.51898 | 13.58 | 3.35 | 1.23 | 72.08 | 0.59 | 8.91 | 0 | 0 | |
1 | 1.5232 | 13.72 | 3.72 | 0.51 | 71.75 | 0.09 | 10.06 | 0 | 0.16 | |
1 | 1.51926 | 13.2 | 3.33 | 1.28 | 72.36 | 0.6 | 9.14 | 0 | 0.11 | |
1 | 1.51808 | 13.43 | 2.87 | 1.19 | 72.84 | 0.55 | 9.03 | 0 | 0 | |
1 | 1.51837 | 13.14 | 2.84 | 1.28 | 72.85 | 0.55 | 9.07 | 0 | 0 | |
1 | 1.51778 | 13.21 | 2.81 | 1.29 | 72.98 | 0.51 | 9.02 | 0 | 0.09 | |
1 | 1.51769 | 12.45 | 2.71 | 1.29 | 73.7 | 0.56 | 9.06 | 0 | 0.24 | |
1 | 1.51215 | 12.99 | 3.47 | 1.12 | 72.98 | 0.62 | 8.35 | 0 | 0.31 | |
1 | 1.51824 | 12.87 | 3.48 | 1.29 | 72.95 | 0.6 | 8.43 | 0 | 0 | |
1 | 1.51754 | 13.48 | 3.74 | 1.17 | 72.99 | 0.59 | 8.03 | 0 | 0 | |
1 | 1.51754 | 13.39 | 3.66 | 1.19 | 72.79 | 0.57 | 8.27 | 0 | 0.11 | |
1 | 1.51905 | 13.6 | 3.62 | 1.11 | 72.64 | 0.14 | 8.76 | 0 | 0 | |
1 | 1.51977 | 13.81 | 3.58 | 1.32 | 71.72 | 0.12 | 8.67 | 0.69 | 0 | |
1 | 1.52172 | 13.51 | 3.86 | 0.88 | 71.79 | 0.23 | 9.54 | 0 | 0.11 | |
1 | 1.52227 | 14.17 | 3.81 | 0.78 | 71.35 | 0 | 9.69 | 0 | 0 | |
1 | 1.52172 | 13.48 | 3.74 | 0.9 | 72.01 | 0.18 | 9.61 | 0 | 0.07 | |
1 | 1.52099 | 13.69 | 3.59 | 1.12 | 71.96 | 0.09 | 9.4 | 0 | 0 | |
1 | 1.52152 | 13.05 | 3.65 | 0.87 | 72.22 | 0.19 | 9.85 | 0 | 0.17 | |
1 | 1.52152 | 13.05 | 3.65 | 0.87 | 72.32 | 0.19 | 9.85 | 0 | 0.17 | |
1 | 1.52152 | 13.12 | 3.58 | 0.9 | 72.2 | 0.23 | 9.82 | 0 | 0.16 | |
1 | 1.523 | 13.31 | 3.58 | 0.82 | 71.99 | 0.12 | 10.17 | 0 | 0.03 | |
2 | 1.51574 | 14.86 | 3.67 | 1.74 | 71.87 | 0.16 | 7.36 | 0 | 0.12 | |
2 | 1.51848 | 13.64 | 3.87 | 1.27 | 71.96 | 0.54 | 8.32 | 0 | 0.32 | |
2 | 1.51593 | 13.09 | 3.59 | 1.52 | 73.1 | 0.67 | 7.83 | 0 | 0 | |
2 | 1.51631 | 13.34 | 3.57 | 1.57 | 72.87 | 0.61 | 7.89 | 0 | 0 | |
2 | 1.51596 | 13.02 | 3.56 | 1.54 | 73.11 | 0.72 | 7.9 | 0 | 0 | |
2 | 1.5159 | 13.02 | 3.58 | 1.51 | 73.12 | 0.69 | 7.96 | 0 | 0 | |
2 | 1.51645 | 13.44 | 3.61 | 1.54 | 72.39 | 0.66 | 8.03 | 0 | 0 | |
2 | 1.51627 | 13 | 3.58 | 1.54 | 72.83 | 0.61 | 8.04 | 0 | 0 | |
2 | 1.51613 | 13.92 | 3.52 | 1.25 | 72.88 | 0.37 | 7.94 | 0 | 0.14 | |
2 | 1.5159 | 12.82 | 3.52 | 1.9 | 72.86 | 0.69 | 7.97 | 0 | 0 | |
2 | 1.51592 | 12.86 | 3.52 | 2.12 | 72.66 | 0.69 | 7.97 | 0 | 0 | |
2 | 1.51593 | 13.25 | 3.45 | 1.43 | 73.17 | 0.61 | 7.86 | 0 | 0 | |
2 | 1.51646 | 13.41 | 3.55 | 1.25 | 72.81 | 0.68 | 8.1 | 0 | 0 | |
2 | 1.51594 | 13.09 | 3.52 | 1.55 | 72.87 | 0.68 | 8.05 | 0 | 0.09 | |
2 | 1.51409 | 14.25 | 3.09 | 2.08 | 72.28 | 1.1 | 7.08 | 0 | 0 | |
2 | 1.51625 | 13.36 | 3.58 | 1.49 | 72.72 | 0.45 | 8.21 | 0 | 0 | |
2 | 1.51569 | 13.24 | 3.49 | 1.47 | 73.25 | 0.38 | 8.03 | 0 | 0 | |
2 | 1.51645 | 13.4 | 3.49 | 1.52 | 72.65 | 0.67 | 8.08 | 0 | 0.1 | |
2 | 1.51618 | 13.01 | 3.5 | 1.48 | 72.89 | 0.6 | 8.12 | 0 | 0 | |
2 | 1.5164 | 12.55 | 3.48 | 1.87 | 73.23 | 0.63 | 8.08 | 0 | 0.09 | |
2 | 1.51841 | 12.93 | 3.74 | 1.11 | 72.28 | 0.64 | 8.96 | 0 | 0.22 | |
2 | 1.51605 | 12.9 | 3.44 | 1.45 | 73.06 | 0.44 | 8.27 | 0 | 0 | |
2 | 1.51588 | 13.12 | 3.41 | 1.58 | 73.26 | 0.07 | 8.39 | 0 | 0.19 | |
2 | 1.5159 | 13.24 | 3.34 | 1.47 | 73.1 | 0.39 | 8.22 | 0 | 0 | |
2 | 1.51629 | 12.71 | 3.33 | 1.49 | 73.28 | 0.67 | 8.24 | 0 | 0 | |
2 | 1.5186 | 13.36 | 3.43 | 1.43 | 72.26 | 0.51 | 8.6 | 0 | 0 | |
2 | 1.51841 | 13.02 | 3.62 | 1.06 | 72.34 | 0.64 | 9.13 | 0 | 0.15 | |
2 | 1.51743 | 12.2 | 3.25 | 1.16 | 73.55 | 0.62 | 8.9 | 0 | 0.24 | |
2 | 1.51689 | 12.67 | 2.88 | 1.71 | 73.21 | 0.73 | 8.54 | 0 | 0 | |
2 | 1.51811 | 12.96 | 2.96 | 1.43 | 72.92 | 0.6 | 8.79 | 0.14 | 0 | |
2 | 1.51655 | 12.75 | 2.85 | 1.44 | 73.27 | 0.57 | 8.79 | 0.11 | 0.22 | |
2 | 1.5173 | 12.35 | 2.72 | 1.63 | 72.87 | 0.7 | 9.23 | 0 | 0 | |
2 | 1.5182 | 12.62 | 2.76 | 0.83 | 73.81 | 0.35 | 9.42 | 0 | 0.2 | |
2 | 1.52725 | 13.8 | 3.15 | 0.66 | 70.57 | 0.08 | 11.64 | 0 | 0 | |
2 | 1.5241 | 13.83 | 2.9 | 1.17 | 71.15 | 0.08 | 10.79 | 0 | 0 | |
2 | 1.52475 | 11.45 | 0 | 1.88 | 72.19 | 0.81 | 13.24 | 0 | 0.34 | |
2 | 1.53125 | 10.73 | 0 | 2.1 | 69.81 | 0.58 | 13.3 | 3.15 | 0.28 | |
2 | 1.53393 | 12.3 | 0 | 1 | 70.16 | 0.12 | 16.19 | 0 | 0.24 | |
2 | 1.52222 | 14.43 | 0 | 1 | 72.67 | 0.1 | 11.52 | 0 | 0.08 | |
2 | 1.51818 | 13.72 | 0 | 0.56 | 74.45 | 0 | 10.99 | 0 | 0 | |
2 | 1.52664 | 11.23 | 0 | 0.77 | 73.21 | 0 | 14.68 | 0 | 0 | |
2 | 1.52739 | 11.02 | 0 | 0.75 | 73.08 | 0 | 14.96 | 0 | 0 | |
2 | 1.52777 | 12.64 | 0 | 0.67 | 72.02 | 0.06 | 14.4 | 0 | 0 | |
2 | 1.51892 | 13.46 | 3.83 | 1.26 | 72.55 | 0.57 | 8.21 | 0 | 0.14 | |
2 | 1.51847 | 13.1 | 3.97 | 1.19 | 72.44 | 0.6 | 8.43 | 0 | 0 | |
2 | 1.51846 | 13.41 | 3.89 | 1.33 | 72.38 | 0.51 | 8.28 | 0 | 0 | |
2 | 1.51829 | 13.24 | 3.9 | 1.41 | 72.33 | 0.55 | 8.31 | 0 | 0.1 | |
2 | 1.51708 | 13.72 | 3.68 | 1.81 | 72.06 | 0.64 | 7.88 | 0 | 0 | |
2 | 1.51673 | 13.3 | 3.64 | 1.53 | 72.53 | 0.65 | 8.03 | 0 | 0.29 | |
2 | 1.51652 | 13.56 | 3.57 | 1.47 | 72.45 | 0.64 | 7.96 | 0 | 0 | |
2 | 1.51844 | 13.25 | 3.76 | 1.32 | 72.4 | 0.58 | 8.42 | 0 | 0 | |
2 | 1.51663 | 12.93 | 3.54 | 1.62 | 72.96 | 0.64 | 8.03 | 0 | 0.21 | |
2 | 1.51687 | 13.23 | 3.54 | 1.48 | 72.84 | 0.56 | 8.1 | 0 | 0 | |
2 | 1.51707 | 13.48 | 3.48 | 1.71 | 72.52 | 0.62 | 7.99 | 0 | 0 | |
2 | 1.52177 | 13.2 | 3.68 | 1.15 | 72.75 | 0.54 | 8.52 | 0 | 0 | |
2 | 1.51872 | 12.93 | 3.66 | 1.56 | 72.51 | 0.58 | 8.55 | 0 | 0.12 | |
2 | 1.51667 | 12.94 | 3.61 | 1.26 | 72.75 | 0.56 | 8.6 | 0 | 0 | |
2 | 1.52081 | 13.78 | 2.28 | 1.43 | 71.99 | 0.49 | 9.85 | 0 | 0.17 | |
2 | 1.52068 | 13.55 | 2.09 | 1.67 | 72.18 | 0.53 | 9.57 | 0.27 | 0.17 | |
2 | 1.5202 | 13.98 | 1.35 | 1.63 | 71.76 | 0.39 | 10.56 | 0 | 0.18 | |
2 | 1.52177 | 13.75 | 1.01 | 1.36 | 72.19 | 0.33 | 11.14 | 0 | 0 | |
2 | 1.52614 | 13.7 | 0 | 1.36 | 71.24 | 0.19 | 13.44 | 0 | 0.1 | |
2 | 1.51813 | 13.43 | 3.98 | 1.18 | 72.49 | 0.58 | 8.15 | 0 | 0 | |
2 | 1.518 | 13.71 | 3.93 | 1.54 | 71.81 | 0.54 | 8.21 | 0 | 0.15 | |
2 | 1.51811 | 13.33 | 3.85 | 1.25 | 72.78 | 0.52 | 8.12 | 0 | 0 | |
2 | 1.51789 | 13.19 | 3.9 | 1.3 | 72.33 | 0.55 | 8.44 | 0 | 0.28 | |
2 | 1.51806 | 13 | 3.8 | 1.08 | 73.07 | 0.56 | 8.38 | 0 | 0.12 | |
2 | 1.51711 | 12.89 | 3.62 | 1.57 | 72.96 | 0.61 | 8.11 | 0 | 0 | |
2 | 1.51674 | 12.79 | 3.52 | 1.54 | 73.36 | 0.66 | 7.9 | 0 | 0 | |
2 | 1.51674 | 12.87 | 3.56 | 1.64 | 73.14 | 0.65 | 7.99 | 0 | 0 | |
2 | 1.5169 | 13.33 | 3.54 | 1.61 | 72.54 | 0.68 | 8.11 | 0 | 0 | |
2 | 1.51851 | 13.2 | 3.63 | 1.07 | 72.83 | 0.57 | 8.41 | 0.09 | 0.17 | |
2 | 1.51662 | 12.85 | 3.51 | 1.44 | 73.01 | 0.68 | 8.23 | 0.06 | 0.25 | |
2 | 1.51709 | 13 | 3.47 | 1.79 | 72.72 | 0.66 | 8.18 | 0 | 0 | |
2 | 1.5166 | 12.99 | 3.18 | 1.23 | 72.97 | 0.58 | 8.81 | 0 | 0.24 | |
2 | 1.51839 | 12.85 | 3.67 | 1.24 | 72.57 | 0.62 | 8.68 | 0 | 0.35 | |
3 | 1.51769 | 13.65 | 3.66 | 1.11 | 72.77 | 0.11 | 8.6 | 0 | 0 | |
3 | 1.5161 | 13.33 | 3.53 | 1.34 | 72.67 | 0.56 | 8.33 | 0 | 0 | |
3 | 1.5167 | 13.24 | 3.57 | 1.38 | 72.7 | 0.56 | 8.44 | 0 | 0.1 | |
3 | 1.51643 | 12.16 | 3.52 | 1.35 | 72.89 | 0.57 | 8.53 | 0 | 0 | |
3 | 1.51665 | 13.14 | 3.45 | 1.76 | 72.48 | 0.6 | 8.38 | 0 | 0.17 | |
3 | 1.52127 | 14.32 | 3.9 | 0.83 | 71.5 | 0 | 9.49 | 0 | 0 | |
3 | 1.51779 | 13.64 | 3.65 | 0.65 | 73 | 0.06 | 8.93 | 0 | 0 | |
3 | 1.5161 | 13.42 | 3.4 | 1.22 | 72.69 | 0.59 | 8.32 | 0 | 0 | |
3 | 1.51694 | 12.86 | 3.58 | 1.31 | 72.61 | 0.61 | 8.79 | 0 | 0 | |
3 | 1.51646 | 13.04 | 3.4 | 1.26 | 73.01 | 0.52 | 8.58 | 0 | 0 | |
3 | 1.51655 | 13.41 | 3.39 | 1.28 | 72.64 | 0.52 | 8.65 | 0 | 0 | |
3 | 1.52121 | 14.03 | 3.76 | 0.58 | 71.79 | 0.11 | 9.65 | 0 | 0 | |
3 | 1.51776 | 13.53 | 3.41 | 1.52 | 72.04 | 0.58 | 8.79 | 0 | 0 | |
3 | 1.51796 | 13.5 | 3.36 | 1.63 | 71.94 | 0.57 | 8.81 | 0 | 0.09 | |
3 | 1.51832 | 13.33 | 3.34 | 1.54 | 72.14 | 0.56 | 8.99 | 0 | 0 | |
3 | 1.51934 | 13.64 | 3.54 | 0.75 | 72.65 | 0.16 | 8.89 | 0.15 | 0.24 | |
3 | 1.52211 | 14.19 | 3.78 | 0.91 | 71.36 | 0.23 | 9.14 | 0 | 0.37 | |
4 | 1.51514 | 14.01 | 2.68 | 3.5 | 69.89 | 1.68 | 5.87 | 2.2 | 0 | |
4 | 1.51915 | 12.73 | 1.85 | 1.86 | 72.69 | 0.6 | 10.09 | 0 | 0 | |
4 | 1.52171 | 11.56 | 1.88 | 1.56 | 72.86 | 0.47 | 11.41 | 0 | 0 | |
4 | 1.52151 | 11.03 | 1.71 | 1.56 | 73.44 | 0.58 | 11.62 | 0 | 0 | |
4 | 1.51969 | 12.64 | 0 | 1.65 | 73.75 | 0.38 | 11.53 | 0 | 0 | |
4 | 1.51666 | 12.86 | 0 | 1.83 | 73.88 | 0.97 | 10.17 | 0 | 0 | |
4 | 1.51994 | 13.27 | 0 | 1.76 | 73.03 | 0.47 | 11.32 | 0 | 0 | |
4 | 1.52369 | 13.44 | 0 | 1.58 | 72.22 | 0.32 | 12.24 | 0 | 0 | |
4 | 1.51316 | 13.02 | 0 | 3.04 | 70.48 | 6.21 | 6.96 | 0 | 0 | |
4 | 1.51321 | 13 | 0 | 3.02 | 70.7 | 6.21 | 6.93 | 0 | 0 | |
4 | 1.52043 | 13.38 | 0 | 1.4 | 72.25 | 0.33 | 12.5 | 0 | 0 | |
4 | 1.52058 | 12.85 | 1.61 | 2.17 | 72.18 | 0.76 | 9.7 | 0.24 | 0.51 | |
4 | 1.52119 | 12.97 | 0.33 | 1.51 | 73.39 | 0.13 | 11.27 | 0 | 0.28 | |
5 | 1.51905 | 14 | 2.39 | 1.56 | 72.37 | 0 | 9.57 | 0 | 0 | |
5 | 1.51937 | 13.79 | 2.41 | 1.19 | 72.76 | 0 | 9.77 | 0 | 0 | |
5 | 1.51829 | 14.46 | 2.24 | 1.62 | 72.38 | 0 | 9.26 | 0 | 0 | |
5 | 1.51852 | 14.09 | 2.19 | 1.66 | 72.67 | 0 | 9.32 | 0 | 0 | |
5 | 1.51299 | 14.4 | 1.74 | 1.54 | 74.55 | 0 | 7.59 | 0 | 0 | |
5 | 1.51888 | 14.99 | 0.78 | 1.74 | 72.5 | 0 | 9.95 | 0 | 0 | |
5 | 1.51916 | 14.15 | 0 | 2.09 | 72.74 | 0 | 10.88 | 0 | 0 | |
5 | 1.51969 | 14.56 | 0 | 0.56 | 73.48 | 0 | 11.22 | 0 | 0 | |
5 | 1.51115 | 17.38 | 0 | 0.34 | 75.41 | 0 | 6.65 | 0 | 0 | |
6 | 1.51131 | 13.69 | 3.2 | 1.81 | 72.81 | 1.76 | 5.43 | 1.19 | 0 | |
6 | 1.51838 | 14.32 | 3.26 | 2.22 | 71.25 | 1.46 | 5.79 | 1.63 | 0 | |
6 | 1.52315 | 13.44 | 3.34 | 1.23 | 72.38 | 0.6 | 8.83 | 0 | 0 | |
6 | 1.52247 | 14.86 | 2.2 | 2.06 | 70.26 | 0.76 | 9.76 | 0 | 0 | |
6 | 1.52365 | 15.79 | 1.83 | 1.31 | 70.43 | 0.31 | 8.61 | 1.68 | 0 | |
6 | 1.51613 | 13.88 | 1.78 | 1.79 | 73.1 | 0 | 8.67 | 0.76 | 0 | |
6 | 1.51602 | 14.85 | 0 | 2.38 | 73.28 | 0 | 8.76 | 0.64 | 0.09 | |
6 | 1.51623 | 14.2 | 0 | 2.79 | 73.46 | 0.04 | 9.04 | 0.4 | 0.09 | |
6 | 1.51719 | 14.75 | 0 | 2 | 73.02 | 0 | 8.53 | 1.59 | 0.08 | |
6 | 1.51683 | 14.56 | 0 | 1.98 | 73.29 | 0 | 8.52 | 1.57 | 0.07 | |
6 | 1.51545 | 14.14 | 0 | 2.68 | 73.39 | 0.08 | 9.07 | 0.61 | 0.05 | |
6 | 1.51556 | 13.87 | 0 | 2.54 | 73.23 | 0.14 | 9.41 | 0.81 | 0.01 | |
6 | 1.51727 | 14.7 | 0 | 2.34 | 73.28 | 0 | 8.95 | 0.66 | 0 | |
6 | 1.51531 | 14.38 | 0 | 2.66 | 73.1 | 0.04 | 9.08 | 0.64 | 0 | |
6 | 1.51609 | 15.01 | 0 | 2.51 | 73.05 | 0.05 | 8.83 | 0.53 | 0 | |
6 | 1.51508 | 15.15 | 0 | 2.25 | 73.5 | 0 | 8.34 | 0.63 | 0 | |
6 | 1.51653 | 11.95 | 0 | 1.19 | 75.18 | 2.7 | 8.93 | 0 | 0 | |
6 | 1.51514 | 14.85 | 0 | 2.42 | 73.72 | 0 | 8.39 | 0.56 | 0 | |
6 | 1.51658 | 14.8 | 0 | 1.99 | 73.11 | 0 | 8.28 | 1.71 | 0 | |
6 | 1.51617 | 14.95 | 0 | 2.27 | 73.3 | 0 | 8.71 | 0.67 | 0 | |
6 | 1.51732 | 14.95 | 0 | 1.8 | 72.99 | 0 | 8.61 | 1.55 | 0 | |
6 | 1.51645 | 14.94 | 0 | 1.87 | 73.11 | 0 | 8.67 | 1.38 | 0 | |
6 | 1.51831 | 14.39 | 0 | 1.82 | 72.86 | 1.41 | 6.47 | 2.88 | 0 | |
6 | 1.5164 | 14.37 | 0 | 2.74 | 72.85 | 0 | 9.45 | 0.54 | 0 | |
6 | 1.51623 | 14.14 | 0 | 2.88 | 72.61 | 0.08 | 9.18 | 1.06 | 0 | |
6 | 1.51685 | 14.92 | 0 | 1.99 | 73.06 | 0 | 8.4 | 1.59 | 0 | |
6 | 1.52065 | 14.36 | 0 | 2.02 | 73.42 | 0 | 8.44 | 1.64 | 0 | |
6 | 1.51651 | 14.38 | 0 | 1.94 | 73.61 | 0 | 8.48 | 1.57 | 0 | |
6 | 1.51711 | 14.23 | 0 | 2.08 | 73.36 | 0 | 8.62 | 1.67 | 0 |
Parag Kanade/fuzzy ants/Glass/2class/maxData.txt
5.691089
Parag Kanade/fuzzy ants/Glass/2class/glassFull.data
1 1.52101 13.64 4.49 1.1 71.78 0.06 8.75 0 01 1.51761 13.89 3.6 1.36 72.73 0.48 7.83 0 01 1.51618 13.53 3.55 1.54 72.99 0.39 7.78 0 01 1.51766 13.21 3.69 1.29 72.61 0.57 8.22 0 01 1.51742 13.27 3.62 1.24 73.08 0.55 8.07 0 01 1.51596 12.79 3.61 1.62 72.97 0.64 8.07 0 0.261 1.51743 13.3 3.6 1.14 73.09 0.58 8.17 0 01 1.51756 13.15 3.61 1.05 73.24 0.57 8.24 0 01 1.51918 14.04 3.58 1.37 72.08 0.56 8.3 0 01 1.51755 13 3.6 1.36 72.99 0.57 8.4 0 0.111 1.51571 12.72 3.46 1.56 73.2 0.67 8.09 0 0.241 1.51763 12.8 3.66 1.27 73.01 0.6 8.56 0 01 1.51589 12.88 3.43 1.4 73.28 0.69 8.05 0 0.241 1.51748 12.86 3.56 1.27 73.21 0.54 8.38 0 0.171 1.51763 12.61 3.59 1.31 73.29 0.58 8.5 0 01 1.51761 12.81 3.54 1.23 73.24 0.58 8.39 0 01 1.51784 12.68 3.67 1.16 73.11 0.61 8.7 0 01 1.52196 14.36 3.85 0.89 71.36 0.15 9.15 0 01 1.51911 13.9 3.73 1.18 72.12 0.06 8.89 0 01 1.51735 13.02 3.54 1.69 72.73 0.54 8.44 0 0.071 1.5175 12.82 3.55 1.49 72.75 0.54 8.52 0 0.191 1.51966 14.77 3.75 0.29 72.02 0.03 9 0 01 1.51736 12.78 3.62 1.29 72.79 0.59 8.7 0 01 1.51751 12.81 3.57 1.35 73.02 0.62 8.59 0 01 1.5172 13.38 3.5 1.15 72.85 0.5 8.43 0 01 1.51764 12.98 3.54 1.21 73 0.65 8.53 0 01 1.51793 13.21 3.48 1.41 72.64 0.59 8.43 0 01 1.51721 12.87 3.48 1.33 73.04 0.56 8.43 0 01 1.51768 12.56 3.52 1.43 73.15 0.57 8.54 0 01 1.51784 13.08 3.49 1.28 72.86 0.6 8.49 0 01 1.51768 12.65 3.56 1.3 73.08 0.61 8.69 0 0.141 1.51747 12.84 3.5 1.14 73.27 0.56 8.55 0 01 1.51775 12.85 3.48 1.23 72.97 0.61 8.56 0.09 0.221 1.51753 12.57 3.47 1.38 73.39 0.6 8.55 0 0.061 1.51783 12.69 3.54 1.34 72.95 0.57 8.75 0 01 1.51567 13.29 3.45 1.21 72.74 0.56 8.57 0 01 1.51909 13.89 3.53 1.32 71.81 0.51 8.78 0.11 01 1.51797 12.74 3.48 1.35 72.96 0.64 8.68 0 01 1.52213 14.21 3.82 0.47 71.77 0.11 9.57 0 01 1.52213 14.21 3.82 0.47 71.77 0.11 9.57 0 01 1.51793 12.79 3.5 1.12 73.03 0.64 8.77 0 01 1.51755 12.71 3.42 1.2 73.2 0.59 8.64 0 01 1.51779 13.21 3.39 1.33 72.76 0.59 8.59 0 01 1.5221 13.73 3.84 0.72 71.76 0.17 9.74 0 01 1.51786 12.73 3.43 1.19 72.95 0.62 8.76 0 0.31 1.519 13.49 3.48 1.35 71.95 0.55 9 0 01 1.51869 13.19 3.37 1.18 72.72 0.57 8.83 0 0.161 1.52667 13.99 3.7 0.71 71.57 0.02 9.82 0 0.11 1.52223 13.21 3.77 0.79 71.99 0.13 10.02 0 01 1.51898 13.58 3.35 1.23 72.08 0.59 8.91 0 01 1.5232 13.72 3.72 0.51 71.75 0.09 10.06 0 0.161 1.51926 13.2 3.33 1.28 72.36 0.6 9.14 0 0.111 1.51808 13.43 2.87 1.19 72.84 0.55 9.03 0 01 1.51837 13.14 2.84 1.28 72.85 0.55 9.07 0 01 1.51778 13.21 2.81 1.29 72.98 0.51 9.02 0 0.091 1.51769 12.45 2.71 1.29 73.7 0.56 9.06 0 0.241 1.51215 12.99 3.47 1.12 72.98 0.62 8.35 0 0.311 1.51824 12.87 3.48 1.29 72.95 0.6 8.43 0 01 1.51754 13.48 3.74 1.17 72.99 0.59 8.03 0 01 1.51754 13.39 3.66 1.19 72.79 0.57 8.27 0 0.111 1.51905 13.6 3.62 1.11 72.64 0.14 8.76 0 01 1.51977 13.81 3.58 1.32 71.72 0.12 8.67 0.69 01 1.52172 13.51 3.86 0.88 71.79 0.23 9.54 0 0.111 1.52227 14.17 3.81 0.78 71.35 0 9.69 0 01 1.52172 13.48 3.74 0.9 72.01 0.18 9.61 0 0.071 1.52099 13.69 3.59 1.12 71.96 0.09 9.4 0 01 1.52152 13.05 3.65 0.87 72.22 0.19 9.85 0 0.171 1.52152 13.05 3.65 0.87 72.32 0.19 9.85 0 0.171 1.52152 13.12 3.58 0.9 72.2 0.23 9.82 0 0.161 1.523 13.31 3.58 0.82 71.99 0.12 10.17 0 0.031 1.51574 14.86 3.67 1.74 71.87 0.16 7.36 0 0.121 1.51848 13.64 3.87 1.27 71.96 0.54 8.32 0 0.321 1.51593 13.09 3.59 1.52 73.1 0.67 7.83 0 01 1.51631 13.34 3.57 1.57 72.87 0.61 7.89 0 01 1.51596 13.02 3.56 1.54 73.11 0.72 7.9 0 01 1.5159 13.02 3.58 1.51 73.12 0.69 7.96 0 01 1.51645 13.44 3.61 1.54 72.39 0.66 8.03 0 01 1.51627 13 3.58 1.54 72.83 0.61 8.04 0 01 1.51613 13.92 3.52 1.25 72.88 0.37 7.94 0 0.141 1.5159 12.82 3.52 1.9 72.86 0.69 7.97 0 01 1.51592 12.86 3.52 2.12 72.66 0.69 7.97 0 01 1.51593 13.25 3.45 1.43 73.17 0.61 7.86 0 01 1.51646 13.41 3.55 1.25 72.81 0.68 8.1 0 01 1.51594 13.09 3.52 1.55 72.87 0.68 8.05 0 0.091 1.51409 14.25 3.09 2.08 72.28 1.1 7.08 0 01 1.51625 13.36 3.58 1.49 72.72 0.45 8.21 0 01 1.51569 13.24 3.49 1.47 73.25 0.38 8.03 0 01 1.51645 13.4 3.49 1.52 72.65 0.67 8.08 0 0.11 1.51618 13.01 3.5 1.48 72.89 0.6 8.12 0 01 1.5164 12.55 3.48 1.87 73.23 0.63 8.08 0 0.091 1.51841 12.93 3.74 1.11 72.28 0.64 8.96 0 0.221 1.51605 12.9 3.44 1.45 73.06 0.44 8.27 0 01 1.51588 13.12 3.41 1.58 73.26 0.07 8.39 0 0.191 1.5159 13.24 3.34 1.47 73.1 0.39 8.22 0 01 1.51629 12.71 3.33 1.49 73.28 0.67 8.24 0 01 1.5186 13.36 3.43 1.43 72.26 0.51 8.6 0 01 1.51841 13.02 3.62 1.06 72.34 0.64 9.13 0 0.151 1.51743 12.2 3.25 1.16 73.55 0.62 8.9 0 0.241 1.51689 12.67 2.88 1.71 73.21 0.73 8.54 0 01 1.51811 12.96 2.96 1.43 72.92 0.6 8.79 0.14 01 1.51655 12.75 2.85 1.44 73.27 0.57 8.79 0.11 0.221 1.5173 12.35 2.72 1.63 72.87 0.7 9.23 0 01 1.5182 12.62 2.76 0.83 73.81 0.35 9.42 0 0.21 1.52725 13.8 3.15 0.66 70.57 0.08 11.64 0 01 1.5241 13.83 2.9 1.17 71.15 0.08 10.79 0 01 1.52475 11.45 0 1.88 72.19 0.81 13.24 0 0.341 1.53125 10.73 0 2.1 69.81 0.58 13.3 3.15 0.281 1.53393 12.3 0 1 70.16 0.12 16.19 0 0.241 1.52222 14.43 0 1 72.67 0.1 11.52 0 0.081 1.51818 13.72 0 0.56 74.45 0 10.99 0 01 1.52664 11.23 0 0.77 73.21 0 14.68 0 01 1.52739 11.02 0 0.75 73.08 0 14.96 0 01 1.52777 12.64 0 0.67 72.02 0.06 14.4 0 01 1.51892 13.46 3.83 1.26 72.55 0.57 8.21 0 0.141 1.51847 13.1 3.97 1.19 72.44 0.6 8.43 0 01 1.51846 13.41 3.89 1.33 72.38 0.51 8.28 0 01 1.51829 13.24 3.9 1.41 72.33 0.55 8.31 0 0.11 1.51708 13.72 3.68 1.81 72.06 0.64 7.88 0 01 1.51673 13.3 3.64 1.53 72.53 0.65 8.03 0 0.291 1.51652 13.56 3.57 1.47 72.45 0.64 7.96 0 01 1.51844 13.25 3.76 1.32 72.4 0.58 8.42 0 01 1.51663 12.93 3.54 1.62 72.96 0.64 8.03 0 0.211 1.51687 13.23 3.54 1.48 72.84 0.56 8.1 0 01 1.51707 13.48 3.48 1.71 72.52 0.62 7.99 0 01 1.52177 13.2 3.68 1.15 72.75 0.54 8.52 0 01 1.51872 12.93 3.66 1.56 72.51 0.58 8.55 0 0.121 1.51667 12.94 3.61 1.26 72.75 0.56 8.6 0 01 1.52081 13.78 2.28 1.43 71.99 0.49 9.85 0 0.171 1.52068 13.55 2.09 1.67 72.18 0.53 9.57 0.27 0.171 1.5202 13.98 1.35 1.63 71.76 0.39 10.56 0 0.181 1.52177 13.75 1.01 1.36 72.19 0.33 11.14 0 01 1.52614 13.7 0 1.36 71.24 0.19 13.44 0 0.11 1.51813 13.43 3.98 1.18 72.49 0.58 8.15 0 01 1.518 13.71 3.93 1.54 71.81 0.54 8.21 0 0.151 1.51811 13.33 3.85 1.25 72.78 0.52 8.12 0 01 1.51789 13.19 3.9 1.3 72.33 0.55 8.44 0 0.281 1.51806 13 3.8 1.08 73.07 0.56 8.38 0 0.121 1.51711 12.89 3.62 1.57 72.96 0.61 8.11 0 01 1.51674 12.79 3.52 1.54 73.36 0.66 7.9 0 01 1.51674 12.87 3.56 1.64 73.14 0.65 7.99 0 01 1.5169 13.33 3.54 1.61 72.54 0.68 8.11 0 01 1.51851 13.2 3.63 1.07 72.83 0.57 8.41 0.09 0.171 1.51662 12.85 3.51 1.44 73.01 0.68 8.23 0.06 0.251 1.51709 13 3.47 1.79 72.72 0.66 8.18 0 01 1.5166 12.99 3.18 1.23 72.97 0.58 8.81 0 0.241 1.51839 12.85 3.67 1.24 72.57 0.62 8.68 0 0.351 1.51769 13.65 3.66 1.11 72.77 0.11 8.6 0 01 1.5161 13.33 3.53 1.34 72.67 0.56 8.33 0 01 1.5167 13.24 3.57 1.38 72.7 0.56 8.44 0 0.11 1.51643 12.16 3.52 1.35 72.89 0.57 8.53 0 01 1.51665 13.14 3.45 1.76 72.48 0.6 8.38 0 0.171 1.52127 14.32 3.9 0.83 71.5 0 9.49 0 01 1.51779 13.64 3.65 0.65 73 0.06 8.93 0 01 1.5161 13.42 3.4 1.22 72.69 0.59 8.32 0 01 1.51694 12.86 3.58 1.31 72.61 0.61 8.79 0 01 1.51646 13.04 3.4 1.26 73.01 0.52 8.58 0 01 1.51655 13.41 3.39 1.28 72.64 0.52 8.65 0 01 1.52121 14.03 3.76 0.58 71.79 0.11 9.65 0 01 1.51776 13.53 3.41 1.52 72.04 0.58 8.79 0 01 1.51796 13.5 3.36 1.63 71.94 0.57 8.81 0 0.091 1.51832 13.33 3.34 1.54 72.14 0.56 8.99 0 01 1.51934 13.64 3.54 0.75 72.65 0.16 8.89 0.15 0.241 1.52211 14.19 3.78 0.91 71.36 0.23 9.14 0 0.372 1.51514 14.01 2.68 3.5 69.89 1.68 5.87 2.2 02 1.51915 12.73 1.85 1.86 72.69 0.6 10.09 0 02 1.52171 11.56 1.88 1.56 72.86 0.47 11.41 0 02 1.52151 11.03 1.71 1.56 73.44 0.58 11.62 0 02 1.51969 12.64 0 1.65 73.75 0.38 11.53 0 02 1.51666 12.86 0 1.83 73.88 0.97 10.17 0 02 1.51994 13.27 0 1.76 73.03 0.47 11.32 0 02 1.52369 13.44 0 1.58 72.22 0.32 12.24 0 02 1.51316 13.02 0 3.04 70.48 6.21 6.96 0 02 1.51321 13 0 3.02 70.7 6.21 6.93 0 02 1.52043 13.38 0 1.4 72.25 0.33 12.5 0 02 1.52058 12.85 1.61 2.17 72.18 0.76 9.7 0.24 0.512 1.52119 12.97 0.33 1.51 73.39 0.13 11.27 0 0.282 1.51905 14 2.39 1.56 72.37 0 9.57 0 02 1.51937 13.79 2.41 1.19 72.76 0 9.77 0 02 1.51829 14.46 2.24 1.62 72.38 0 9.26 0 02 1.51852 14.09 2.19 1.66 72.67 0 9.32 0 02 1.51299 14.4 1.74 1.54 74.55 0 7.59 0 02 1.51888 14.99 0.78 1.74 72.5 0 9.95 0 02 1.51916 14.15 0 2.09 72.74 0 10.88 0 02 1.51969 14.56 0 0.56 73.48 0 11.22 0 02 1.51115 17.38 0 0.34 75.41 0 6.65 0 02 1.51131 13.69 3.2 1.81 72.81 1.76 5.43 1.19 02 1.51838 14.32 3.26 2.22 71.25 1.46 5.79 1.63 02 1.52315 13.44 3.34 1.23 72.38 0.6 8.83 0 02 1.52247 14.86 2.2 2.06 70.26 0.76 9.76 0 02 1.52365 15.79 1.83 1.31 70.43 0.31 8.61 1.68 02 1.51613 13.88 1.78 1.79 73.1 0 8.67 0.76 02 1.51602 14.85 0 2.38 73.28 0 8.76 0.64 0.092 1.51623 14.2 0 2.79 73.46 0.04 9.04 0.4 0.092 1.51719 14.75 0 2 73.02 0 8.53 1.59 0.082 1.51683 14.56 0 1.98 73.29 0 8.52 1.57 0.072 1.51545 14.14 0 2.68 73.39 0.08 9.07 0.61 0.052 1.51556 13.87 0 2.54 73.23 0.14 9.41 0.81 0.012 1.51727 14.7 0 2.34 73.28 0 8.95 0.66 02 1.51531 14.38 0 2.66 73.1 0.04 9.08 0.64 02 1.51609 15.01 0 2.51 73.05 0.05 8.83 0.53 02 1.51508 15.15 0 2.25 73.5 0 8.34 0.63 02 1.51653 11.95 0 1.19 75.18 2.7 8.93 0 02 1.51514 14.85 0 2.42 73.72 0 8.39 0.56 02 1.51658 14.8 0 1.99 73.11 0 8.28 1.71 02 1.51617 14.95 0 2.27 73.3 0 8.71 0.67 02 1.51732 14.95 0 1.8 72.99 0 8.61 1.55 02 1.51645 14.94 0 1.87 73.11 0 8.67 1.38 02 1.51831 14.39 0 1.82 72.86 1.41 6.47 2.88 02 1.5164 14.37 0 2.74 72.85 0 9.45 0.54 02 1.51623 14.14 0 2.88 72.61 0.08 9.18 1.06 02 1.51685 14.92 0 1.99 73.06 0 8.4 1.59 02 1.52065 14.36 0 2.02 73.42 0 8.44 1.64 02 1.51651 14.38 0 1.94 73.61 0 8.48 1.57 02 1.51711 14.23 0 2.08 73.36 0 8.62 1.67 0
Parag Kanade/fuzzy ants/Glass/2class/headerStatic.h
/********************************************************************/ /* Ant Class parameters */ /* SPEED # amplitude of moves [1,10] */ /* P direction Probability to move in the same direction [.5,1] */ /* Max carry : Maximum object carrying time [20,200] */ /* P load Probability to pick up a single object [0.4,0.8] */ /* P destroy probability to destroy a heap of two objects [0,0.6] */ /* T remove min. dissimilarity necessary for removing an object */ /* from a heap [.1,.2] */ /* T create max dissimilarity permitted for creating a heap[.05,.2]*/ /********************************************************************/ #include <stdio.h> #include <math.h> #include <string.h> #include<stdlib.h> #include <ctype.h> #include <time.h> #define MAXANTS 72 #define MAXDATA 214 #define MAXANTSFORHEAPS 10 #define MAXITERATIONS 1000 #define MAXROWS 30 #define MAXCOLS 30 #define EXPRUN 50 #define Tremove 4.0 #define Tcreate 0.5 #define Pdrop 0.2 #define Pdestroy 0.3 #define Pload 0.3 #define normalize 0 #define EntireHeaps 1 #define TcreateForHeaps 0.135 #define features 9 #define filename "glass" #define errThresh 0.01 #define dataDump 1 #define maxDist 0 #define INITIALOBJECTS 75 #define OBJINC 10 /* some type definitions to make C code a little more readable */ #define TRUE 1 #define FALSE 0 #define n MAXDATA /* number of input vectors */ #define s features /* number of features */ #define c 2 /* number of clusters */ #define TOTRUNS 1 /* number of V's to write out */ #define false 0 #define true 1 #define maha 0 #define square 0 extern int count; int debugLevel=0;/* To debug the code and verify the correctness of algorithms*/ int currHeapCount=0; typedef int BOOLEAN; typedef short TYPE_IN_DATA; /* Type of input binary data */ typedef float feature[s]; /* Type of each input; made up of input features */ typedef float irisData[s]; typedef feature objects[MAXDATA]; /* Type of array holding all inputs */ typedef feature center[MAXDATA]; /* Type of array holding cluster centers */ typedef float matrix[MAXDATA][MAXDATA];/* Type of the matrix containing membership grades */ typedef struct Heap { float Dmax;//maximum dissimilar distance irisData Ocenter;//center object float Dmean;//mean of the distance between the center and all the objects irisData Odissim;//most dissimilar object int x;//x position on the board int y;//y position on the board int count;//number of objects in the heaps int disPosition;//most dissimilar object int objects[MAXDATA]; int objCount; }heap; typedef struct Ant { int x; int y; int carrying; int speed; int dir; irisData data; }ant; float orgData[n][s+1]; float fcmData[260][n][s]; int clsCenCount[260]; int currentRow=0; int currentAntCount=0; int updateAfter=50; int heapSum=0; int minAnts=3; int rowMin=5; typedef struct HeapInfo { int total; int classObj[c]; } heapInfo; /*heapInfo info[MAXDATA];*/ /********************************************************************/ /***Function decelarations*/ /********************************************************************/ /***For ant based algorithm*/ void readInput(); float computeDistance(); float computeDistanceBetween2(irisData a,irisData b); float findMax(float *distance); float value(irisData a); int found(int a , int b); void initialise(int flag); int findObject(int a,int b); void initialiseAnts(int flag); void moveNext(ant* a,int flag); void computeHeapParameters(heap* data,int flag); void pickObject1(ant *a,int position,int flag); void pickObject2(ant *a , int position,int flag); void pickObjectn(ant *a,int position,int flag); void pick(ant *a,int flag); void dropObject(ant* a,int flag); int findInNewheaps(irisData object); void dropObject1(ant* a, int position,int flag); void drop(ant* a,int flag); void move(ant* a,int flag); void iterate(int flag); void dropFinal(int flag); int partition(heap a[], int low,int high); void quickSort( heap A[], int low,int high ) ; void writeClusterInformation(int flag); void initialiseNewHeaps(heap newHeaps[]); int findPosition(int i); void harden(heap newHeaps[]); void harden1(); int findPosition1(int ); void writeInfo(); void addObject1(int ,int); void readFCM(FILE *,FILE *); void readOrg(); int findInData(irisData input,int iflag); void adjustBoard(int flag); void writeIncremental(int iteration,int flag); /********************************************************************/ /***For FCM algorithm*/ void GET_INPUTS1(char []); void UMAT( matrix,center,objects); BOOLEAN FINISHED(matrix, float); void CLUSTER( matrix, objects); void Output(char[]); void Fcm(); /********************************************************************/
Parag Kanade/fuzzy ants/Glass/2class/glass.data
Glass Data # 1.52101 13.64 4.49 1.1 71.78 0.06 8.75 0 0 1.51761 13.89 3.6 1.36 72.73 0.48 7.83 0 0 1.51618 13.53 3.55 1.54 72.99 0.39 7.78 0 0 1.51766 13.21 3.69 1.29 72.61 0.57 8.22 0 0 1.51742 13.27 3.62 1.24 73.08 0.55 8.07 0 0 1.51596 12.79 3.61 1.62 72.97 0.64 8.07 0 0.26 1.51743 13.3 3.6 1.14 73.09 0.58 8.17 0 0 1.51756 13.15 3.61 1.05 73.24 0.57 8.24 0 0 1.51918 14.04 3.58 1.37 72.08 0.56 8.3 0 0 1.51755 13 3.6 1.36 72.99 0.57 8.4 0 0.11 1.51571 12.72 3.46 1.56 73.2 0.67 8.09 0 0.24 1.51763 12.8 3.66 1.27 73.01 0.6 8.56 0 0 1.51589 12.88 3.43 1.4 73.28 0.69 8.05 0 0.24 1.51748 12.86 3.56 1.27 73.21 0.54 8.38 0 0.17 1.51763 12.61 3.59 1.31 73.29 0.58 8.5 0 0 1.51761 12.81 3.54 1.23 73.24 0.58 8.39 0 0 1.51784 12.68 3.67 1.16 73.11 0.61 8.7 0 0 1.52196 14.36 3.85 0.89 71.36 0.15 9.15 0 0 1.51911 13.9 3.73 1.18 72.12 0.06 8.89 0 0 1.51735 13.02 3.54 1.69 72.73 0.54 8.44 0 0.07 1.5175 12.82 3.55 1.49 72.75 0.54 8.52 0 0.19 1.51966 14.77 3.75 0.29 72.02 0.03 9 0 0 1.51736 12.78 3.62 1.29 72.79 0.59 8.7 0 0 1.51751 12.81 3.57 1.35 73.02 0.62 8.59 0 0 1.5172 13.38 3.5 1.15 72.85 0.5 8.43 0 0 1.51764 12.98 3.54 1.21 73 0.65 8.53 0 0 1.51793 13.21 3.48 1.41 72.64 0.59 8.43 0 0 1.51721 12.87 3.48 1.33 73.04 0.56 8.43 0 0 1.51768 12.56 3.52 1.43 73.15 0.57 8.54 0 0 1.51784 13.08 3.49 1.28 72.86 0.6 8.49 0 0 1.51768 12.65 3.56 1.3 73.08 0.61 8.69 0 0.14 1.51747 12.84 3.5 1.14 73.27 0.56 8.55 0 0 1.51775 12.85 3.48 1.23 72.97 0.61 8.56 0.09 0.22 1.51753 12.57 3.47 1.38 73.39 0.6 8.55 0 0.06 1.51783 12.69 3.54 1.34 72.95 0.57 8.75 0 0 1.51567 13.29 3.45 1.21 72.74 0.56 8.57 0 0 1.51909 13.89 3.53 1.32 71.81 0.51 8.78 0.11 0 1.51797 12.74 3.48 1.35 72.96 0.64 8.68 0 0 1.52213 14.21 3.82 0.47 71.77 0.11 9.57 0 0 1.52213 14.21 3.82 0.47 71.77 0.11 9.57 0 0 1.51793 12.79 3.5 1.12 73.03 0.64 8.77 0 0 1.51755 12.71 3.42 1.2 73.2 0.59 8.64 0 0 1.51779 13.21 3.39 1.33 72.76 0.59 8.59 0 0 1.5221 13.73 3.84 0.72 71.76 0.17 9.74 0 0 1.51786 12.73 3.43 1.19 72.95 0.62 8.76 0 0.3 1.519 13.49 3.48 1.35 71.95 0.55 9 0 0 1.51869 13.19 3.37 1.18 72.72 0.57 8.83 0 0.16 1.52667 13.99 3.7 0.71 71.57 0.02 9.82 0 0.1 1.52223 13.21 3.77 0.79 71.99 0.13 10.02 0 0 1.51898 13.58 3.35 1.23 72.08 0.59 8.91 0 0 1.5232 13.72 3.72 0.51 71.75 0.09 10.06 0 0.16 1.51926 13.2 3.33 1.28 72.36 0.6 9.14 0 0.11 1.51808 13.43 2.87 1.19 72.84 0.55 9.03 0 0 1.51837 13.14 2.84 1.28 72.85 0.55 9.07 0 0 1.51778 13.21 2.81 1.29 72.98 0.51 9.02 0 0.09 1.51769 12.45 2.71 1.29 73.7 0.56 9.06 0 0.24 1.51215 12.99 3.47 1.12 72.98 0.62 8.35 0 0.31 1.51824 12.87 3.48 1.29 72.95 0.6 8.43 0 0 1.51754 13.48 3.74 1.17 72.99 0.59 8.03 0 0 1.51754 13.39 3.66 1.19 72.79 0.57 8.27 0 0.11 1.51905 13.6 3.62 1.11 72.64 0.14 8.76 0 0 1.51977 13.81 3.58 1.32 71.72 0.12 8.67 0.69 0 1.52172 13.51 3.86 0.88 71.79 0.23 9.54 0 0.11 1.52227 14.17 3.81 0.78 71.35 0 9.69 0 0 1.52172 13.48 3.74 0.9 72.01 0.18 9.61 0 0.07 1.52099 13.69 3.59 1.12 71.96 0.09 9.4 0 0 1.52152 13.05 3.65 0.87 72.22 0.19 9.85 0 0.17 1.52152 13.05 3.65 0.87 72.32 0.19 9.85 0 0.17 1.52152 13.12 3.58 0.9 72.2 0.23 9.82 0 0.16 1.523 13.31 3.58 0.82 71.99 0.12 10.17 0 0.03 1.51574 14.86 3.67 1.74 71.87 0.16 7.36 0 0.12 1.51848 13.64 3.87 1.27 71.96 0.54 8.32 0 0.32 1.51593 13.09 3.59 1.52 73.1 0.67 7.83 0 0 1.51631 13.34 3.57 1.57 72.87 0.61 7.89 0 0 1.51596 13.02 3.56 1.54 73.11 0.72 7.9 0 0 1.5159 13.02 3.58 1.51 73.12 0.69 7.96 0 0 1.51645 13.44 3.61 1.54 72.39 0.66 8.03 0 0 1.51627 13 3.58 1.54 72.83 0.61 8.04 0 0 1.51613 13.92 3.52 1.25 72.88 0.37 7.94 0 0.14 1.5159 12.82 3.52 1.9 72.86 0.69 7.97 0 0 1.51592 12.86 3.52 2.12 72.66 0.69 7.97 0 0 1.51593 13.25 3.45 1.43 73.17 0.61 7.86 0 0 1.51646 13.41 3.55 1.25 72.81 0.68 8.1 0 0 1.51594 13.09 3.52 1.55 72.87 0.68 8.05 0 0.09 1.51409 14.25 3.09 2.08 72.28 1.1 7.08 0 0 1.51625 13.36 3.58 1.49 72.72 0.45 8.21 0 0 1.51569 13.24 3.49 1.47 73.25 0.38 8.03 0 0 1.51645 13.4 3.49 1.52 72.65 0.67 8.08 0 0.1 1.51618 13.01 3.5 1.48 72.89 0.6 8.12 0 0 1.5164 12.55 3.48 1.87 73.23 0.63 8.08 0 0.09 1.51841 12.93 3.74 1.11 72.28 0.64 8.96 0 0.22 1.51605 12.9 3.44 1.45 73.06 0.44 8.27 0 0 1.51588 13.12 3.41 1.58 73.26 0.07 8.39 0 0.19 1.5159 13.24 3.34 1.47 73.1 0.39 8.22 0 0 1.51629 12.71 3.33 1.49 73.28 0.67 8.24 0 0 1.5186 13.36 3.43 1.43 72.26 0.51 8.6 0 0 1.51841 13.02 3.62 1.06 72.34 0.64 9.13 0 0.15 1.51743 12.2 3.25 1.16 73.55 0.62 8.9 0 0.24 1.51689 12.67 2.88 1.71 73.21 0.73 8.54 0 0 1.51811 12.96 2.96 1.43 72.92 0.6 8.79 0.14 0 1.51655 12.75 2.85 1.44 73.27 0.57 8.79 0.11 0.22 1.5173 12.35 2.72 1.63 72.87 0.7 9.23 0 0 1.5182 12.62 2.76 0.83 73.81 0.35 9.42 0 0.2 1.52725 13.8 3.15 0.66 70.57 0.08 11.64 0 0 1.5241 13.83 2.9 1.17 71.15 0.08 10.79 0 0 1.52475 11.45 0 1.88 72.19 0.81 13.24 0 0.34 1.53125 10.73 0 2.1 69.81 0.58 13.3 3.15 0.28 1.53393 12.3 0 1 70.16 0.12 16.19 0 0.24 1.52222 14.43 0 1 72.67 0.1 11.52 0 0.08 1.51818 13.72 0 0.56 74.45 0 10.99 0 0 1.52664 11.23 0 0.77 73.21 0 14.68 0 0 1.52739 11.02 0 0.75 73.08 0 14.96 0 0 1.52777 12.64 0 0.67 72.02 0.06 14.4 0 0 1.51892 13.46 3.83 1.26 72.55 0.57 8.21 0 0.14 1.51847 13.1 3.97 1.19 72.44 0.6 8.43 0 0 1.51846 13.41 3.89 1.33 72.38 0.51 8.28 0 0 1.51829 13.24 3.9 1.41 72.33 0.55 8.31 0 0.1 1.51708 13.72 3.68 1.81 72.06 0.64 7.88 0 0 1.51673 13.3 3.64 1.53 72.53 0.65 8.03 0 0.29 1.51652 13.56 3.57 1.47 72.45 0.64 7.96 0 0 1.51844 13.25 3.76 1.32 72.4 0.58 8.42 0 0 1.51663 12.93 3.54 1.62 72.96 0.64 8.03 0 0.21 1.51687 13.23 3.54 1.48 72.84 0.56 8.1 0 0 1.51707 13.48 3.48 1.71 72.52 0.62 7.99 0 0 1.52177 13.2 3.68 1.15 72.75 0.54 8.52 0 0 1.51872 12.93 3.66 1.56 72.51 0.58 8.55 0 0.12 1.51667 12.94 3.61 1.26 72.75 0.56 8.6 0 0 1.52081 13.78 2.28 1.43 71.99 0.49 9.85 0 0.17 1.52068 13.55 2.09 1.67 72.18 0.53 9.57 0.27 0.17 1.5202 13.98 1.35 1.63 71.76 0.39 10.56 0 0.18 1.52177 13.75 1.01 1.36 72.19 0.33 11.14 0 0 1.52614 13.7 0 1.36 71.24 0.19 13.44 0 0.1 1.51813 13.43 3.98 1.18 72.49 0.58 8.15 0 0 1.518 13.71 3.93 1.54 71.81 0.54 8.21 0 0.15 1.51811 13.33 3.85 1.25 72.78 0.52 8.12 0 0 1.51789 13.19 3.9 1.3 72.33 0.55 8.44 0 0.28 1.51806 13 3.8 1.08 73.07 0.56 8.38 0 0.12 1.51711 12.89 3.62 1.57 72.96 0.61 8.11 0 0 1.51674 12.79 3.52 1.54 73.36 0.66 7.9 0 0 1.51674 12.87 3.56 1.64 73.14 0.65 7.99 0 0 1.5169 13.33 3.54 1.61 72.54 0.68 8.11 0 0 1.51851 13.2 3.63 1.07 72.83 0.57 8.41 0.09 0.17 1.51662 12.85 3.51 1.44 73.01 0.68 8.23 0.06 0.25 1.51709 13 3.47 1.79 72.72 0.66 8.18 0 0 1.5166 12.99 3.18 1.23 72.97 0.58 8.81 0 0.24 1.51839 12.85 3.67 1.24 72.57 0.62 8.68 0 0.35 1.51769 13.65 3.66 1.11 72.77 0.11 8.6 0 0 1.5161 13.33 3.53 1.34 72.67 0.56 8.33 0 0 1.5167 13.24 3.57 1.38 72.7 0.56 8.44 0 0.1 1.51643 12.16 3.52 1.35 72.89 0.57 8.53 0 0 1.51665 13.14 3.45 1.76 72.48 0.6 8.38 0 0.17 1.52127 14.32 3.9 0.83 71.5 0 9.49 0 0 1.51779 13.64 3.65 0.65 73 0.06 8.93 0 0 1.5161 13.42 3.4 1.22 72.69 0.59 8.32 0 0 1.51694 12.86 3.58 1.31 72.61 0.61 8.79 0 0 1.51646 13.04 3.4 1.26 73.01 0.52 8.58 0 0 1.51655 13.41 3.39 1.28 72.64 0.52 8.65 0 0 1.52121 14.03 3.76 0.58 71.79 0.11 9.65 0 0 1.51776 13.53 3.41 1.52 72.04 0.58 8.79 0 0 1.51796 13.5 3.36 1.63 71.94 0.57 8.81 0 0.09 1.51832 13.33 3.34 1.54 72.14 0.56 8.99 0 0 1.51934 13.64 3.54 0.75 72.65 0.16 8.89 0.15 0.24 1.52211 14.19 3.78 0.91 71.36 0.23 9.14 0 0.37 1.51514 14.01 2.68 3.5 69.89 1.68 5.87 2.2 0 1.51915 12.73 1.85 1.86 72.69 0.6 10.09 0 0 1.52171 11.56 1.88 1.56 72.86 0.47 11.41 0 0 1.52151 11.03 1.71 1.56 73.44 0.58 11.62 0 0 1.51969 12.64 0 1.65 73.75 0.38 11.53 0 0 1.51666 12.86 0 1.83 73.88 0.97 10.17 0 0 1.51994 13.27 0 1.76 73.03 0.47 11.32 0 0 1.52369 13.44 0 1.58 72.22 0.32 12.24 0 0 1.51316 13.02 0 3.04 70.48 6.21 6.96 0 0 1.51321 13 0 3.02 70.7 6.21 6.93 0 0 1.52043 13.38 0 1.4 72.25 0.33 12.5 0 0 1.52058 12.85 1.61 2.17 72.18 0.76 9.7 0.24 0.51 1.52119 12.97 0.33 1.51 73.39 0.13 11.27 0 0.28 1.51905 14 2.39 1.56 72.37 0 9.57 0 0 1.51937 13.79 2.41 1.19 72.76 0 9.77 0 0 1.51829 14.46 2.24 1.62 72.38 0 9.26 0 0 1.51852 14.09 2.19 1.66 72.67 0 9.32 0 0 1.51299 14.4 1.74 1.54 74.55 0 7.59 0 0 1.51888 14.99 0.78 1.74 72.5 0 9.95 0 0 1.51916 14.15 0 2.09 72.74 0 10.88 0 0 1.51969 14.56 0 0.56 73.48 0 11.22 0 0 1.51115 17.38 0 0.34 75.41 0 6.65 0 0 1.51131 13.69 3.2 1.81 72.81 1.76 5.43 1.19 0 1.51838 14.32 3.26 2.22 71.25 1.46 5.79 1.63 0 1.52315 13.44 3.34 1.23 72.38 0.6 8.83 0 0 1.52247 14.86 2.2 2.06 70.26 0.76 9.76 0 0 1.52365 15.79 1.83 1.31 70.43 0.31 8.61 1.68 0 1.51613 13.88 1.78 1.79 73.1 0 8.67 0.76 0 1.51602 14.85 0 2.38 73.28 0 8.76 0.64 0.09 1.51623 14.2 0 2.79 73.46 0.04 9.04 0.4 0.09 1.51719 14.75 0 2 73.02 0 8.53 1.59 0.08 1.51683 14.56 0 1.98 73.29 0 8.52 1.57 0.07 1.51545 14.14 0 2.68 73.39 0.08 9.07 0.61 0.05 1.51556 13.87 0 2.54 73.23 0.14 9.41 0.81 0.01 1.51727 14.7 0 2.34 73.28 0 8.95 0.66 0 1.51531 14.38 0 2.66 73.1 0.04 9.08 0.64 0 1.51609 15.01 0 2.51 73.05 0.05 8.83 0.53 0 1.51508 15.15 0 2.25 73.5 0 8.34 0.63 0 1.51653 11.95 0 1.19 75.18 2.7 8.93 0 0 1.51514 14.85 0 2.42 73.72 0 8.39 0.56 0 1.51658 14.8 0 1.99 73.11 0 8.28 1.71 0 1.51617 14.95 0 2.27 73.3 0 8.71 0.67 0 1.51732 14.95 0 1.8 72.99 0 8.61 1.55 0 1.51645 14.94 0 1.87 73.11 0 8.67 1.38 0 1.51831 14.39 0 1.82 72.86 1.41 6.47 2.88 0 1.5164 14.37 0 2.74 72.85 0 9.45 0.54 0 1.51623 14.14 0 2.88 72.61 0.08 9.18 1.06 0 1.51685 14.92 0 1.99 73.06 0 8.4 1.59 0 1.52065 14.36 0 2.02 73.42 0 8.44 1.64 0 1.51651 14.38 0 1.94 73.61 0 8.48 1.57 0 1.51711 14.23 0 2.08 73.36 0 8.62 1.67 0
Parag Kanade/fuzzy ants/Glass/2class/glass.c
#include "headerStatic.h" /*******************************************************************/ /*** Global Variables ***/ irisData data[MAXDATA]; //To hold the data read from the file int count=0; //Count of the total number of data elements int heapCount=0; // Total number of heaps int heapRow=0; // Rows for the second iteration with heaps int newHeapCount=0; // Count of the heaps for the second iteration heap heaps[MAXDATA]; // Data structure to hold the heap information heap newHeaps[MAXDATA]; // Data Structure to hold the new heap information // For the second iteration int board[MAXROWS][MAXCOLS]; // Board on which the objects are located ant ants[MAXANTS]; // Data structure to hold the ants float Dmax=0; // Distance of the most dissimilar object pair int minHeapCount=100000; // Counter to hold the minimum heap count, used only for academic purpose // no use in the algorithm int minPosition; // the minimum heap iteration , only for academic purpose // no use in the algorithm float clsCen[MAXDATA][MAXDATA][s];//to hold the objects after hardening int cenCount[MAXDATA];//to hold the number of objects after hardening /********************************************************************/ /*** Varaibles to normalize the features between 0 and 1 */ float minInput[features], maxInput[features],scale[features],minForHeaps[features],maxForHeaps[features],scaleForHeaps[features]; /********************************************************************/ /** Variables for the FCM algorithm */ int temp[200]; /* for square matrix tests */ float eps,m; matrix U, U1; BOOLEAN stop; center V; objects X; char fname[80]; FILE *fp; int run; float inv_cov[s+1][s+1]; /* inverse of covariance matrix Y */ float Y[s][s]; long rand_index, Random_seed; long state1[52] = { 9347, 3835, 5194, 8310, 346, 535, 5297, 6711, 77, 3834, 668, 4175, 6868, 5890, 9304, 8462, 5269, 920, 65392, 41600, 70119, 91032, 76220, 26245, 4746, 73608, 32823, 63264, 75641, 99104, 36534, 24704, 98255, 72266, 75336, 65152, 7269, 63163, 88471, 27271, 43641, 76649, 47773, 23777, 27491, 35926, 16651, 48652, 89766, 90921, 6056 }; int z; int mins=0; int aveit =0; float mintab[200]; int mincount[200]; long start,end,total; int lCount;//added by parag /********************************************************************/ /********************************************************************//*int lrand48(){return(rand());}void srand48(int a){return;}*//********************************************************************/ /********************************************************************/ /* Function to read the input data set */ /* The file name is assumed to be itest.data */ /* Status: Tested */ /* Output: Data from the file into the "data" (Global) data structure */ /* Output: Count (Global), the count of the number of objects */ /********************************************************************/ void readInput() { FILE *fp; char fname[80]; int i=0,j=0; char ch; sprintf(fname,"%s.data",filename); /* Check if the input file is opened */ if((fp=fopen(fname,"r"))==NULL) { printf("\n Unable to open input file \n"); exit(0); } /*initialise the minimum maximum and the scale */ for(i=0;i<features;i++) { minInput[i]=1000; maxInput[i]=0; minForHeaps[i]=1000; maxForHeaps[i]=0; scale[i]=0; scaleForHeaps[i]=0; } /* Discard leading comments */ ch = 'c'; while (ch != '#') fscanf (fp, "%c", &ch); i=0; /* Parse the file and populate the data structure */ while(!feof(fp)) { for(j=0;j<features;j++) { fscanf(fp,"%f ",&data[i][j]); } fscanf(fp,"\n"); for(j=0;j<features;j++) { if(data[i][j]<minInput[j]) minInput[j]=data[i][j]; if(data[i][j]>maxInput[j]) maxInput[j]=data[i][j]; } i++; } count=i; /* Normailze the feature values in between 0 and 1 */ for(j=0;j<features;j++) { if(minInput[j]!=maxInput[j]) scale[j]=1.0/(maxInput[j]-minInput[j]); else scale[j]=1.0; } for(i=0;i<count;i++) { for(j=0;j<features;j++) data[i][j]=(data[i][j]-minInput[j])*scale[j]; } fclose(fp); return; }//end of function /********************************************************************/ /*Function to compute the eucldiean distance for all input data set */ /* Output : an array conatining the distance of each object with the other */ /********************************************************************/ float computeDistance() { float distance,dist=0; int i=0,j=0,k=0; distance=0; for(j=0;j<count;j++) for(i=0;i<count;i++) { for(k=0;k<features;k++) dist+=sqrt((data[j][k]-data[i][k])*(data[j][k]-data[i][k])); if(distance<dist)distance=dist; dist=0; } return(distance); } /********************************************************************/ /* Function to compute the distance between two objects */ /* Output : Euclidean d istance between the two input objects */ /********************************************************************/ float computeDistanceBetween2(irisData a,irisData b) { float temp=0; int i=0; for(i=0;i<features;i++) temp+=(a[i]-b[i])*(a[i]-b[i]); temp=sqrt(temp); return(temp); } /********************************************************************/ /* Function to find the maximum distance between the input objects*/ /* Output: the maximum distance */ /* Input : The array of distances between objects */ /********************************************************************/ /*float findMax(float *distance) { int i=0,j=0; float max=distance[0]; for(i=0;i<count;i++) for(j=0;j<count;j++) { if(max<distance[i*count+j]) max=distance[i*count+j]; } return(max); }*/ /********************************************************************/ /* Function to compute the value of an object */ /********************************************************************/ float value(irisData a) { int i=0; float temp=0; for(i=0;i<features;i++) temp+=a[i]*a[i]; return(sqrt(temp)); } /********************************************************************/ /* Function to find the object in the data structure */ /* Output : The position of the object in the data */ /* Input : The object */ /********************************************************************/ int findInData(irisData object,int iFlag) { int i=0,lastCount=0,j,position=-1,flag[features],flg;if(iFlag==1)lastCount=MAXDATA;else{}for(i=0;i<lastCount;i++){ for(j=0;j<features;j++) if(fabs(object[j]-data[i][j])<0.00001) flag[j]=1; else { flag[j]=0; break;} flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /* Function to find whether there is an object on the board at a,b */ /* Output : a flag indicating whether an object is found or not */ /* Input : The row and column indicating the board position */ /********************************************************************/ int found(int a , int b) { if(board[a][b]==9) return 1; else return 0; } /********************************************************************/ /* Function to initialize the initial board */ /* Output : None */ /* Global Structures modified : heaps */ /* Input : Flag indicating the iteration 1: First 0: Second */ /********************************************************************/ void initialise(int flag) { int a,b,i=0,k=0; int loopCount,rowCount,colCount; /* Initialize the row, column and number of heaps */ if(flag==1) { loopCount=count; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=lCount; rowCount=heapRow; colCount=heapRow; } /* Initialize the heaps */ for(i=0;i<loopCount;i++) { heaps[i].count=0; heaps[i].x=0; heaps[i].y=0; heaps[i].disPosition=0; heaps[i].Dmax=0; heaps[i].Dmean=0; } for(i=0;i<loopCount;i++) { /*find a board position which is empty*/ do { a=lrand48()%rowCount; b=lrand48()%colCount; } while(found(a,b)); /*Allocate the object to that place and assign a heap to it*/ heaps[i].x=a; heaps[i].y=b; heaps[i].count=1; heaps[i].Dmax=0; heaps[i].Dmean=0; if(flag==1) { heaps[i].objects[0]=i; for(k=0;k<features;k++)heaps[i].Ocenter[k]=data[i][k]; } else { for(k=0;k<features;k++) heaps[i].Ocenter[k]=newHeaps[i].Ocenter[k]; } heaps[i].disPosition=0; board[a][b]=9; if((debugLevel>0)&&(flag==1))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],data[heaps[i].objects[0]][0]); if((debugLevel>0)&&(flag==0))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],newHeaps[i].Ocenter[0]); } /*initialise the initial heap count*/ heapCount=loopCount; currentRow=rowCount; } /********************************************************************/ /* Function to find whether an heap is present at the location a b */ /* Output : Flag indicating the presencs of the heap */ /* Input : Roe and column indicating the board position */ /********************************************************************/ int findObject(int a,int b) { int i; int position=-1; for(i=0;i<heapCount;i++) { if((heaps[i].x==a)&&(heaps[i].y==b)) { position=i; break; } } return(position); } /********************************************************************/ /* Function initialize the ants */ /* Output : None */ /* Input : Flag indicating the iteration */ /* Global Variables Modified : ant, heapCount, heaps, board */ /********************************************************************/ void initialiseAnts(int flag) { int i=0,a=0,b=0,position,j=0,loopCount=0,rowCount,colCount,k=0; if(flag==1) { loopCount=MAXANTS; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=MAXANTSFORHEAPS; rowCount=heapRow; colCount=heapRow; } for(i=0;i<loopCount;i++) { /*generate random positions for the ants*/ a=lrand48()%rowCount; b=lrand48()%colCount; ants[i].x=a; ants[i].y=b; /*Find if an object is present at that position or not*/ if(board[a][b]==9) { ants[i].carrying=1; /*find the heap at that location*/ position=findObject(a,b); if(position==-1) { printf("\n Error in logic: Ant init \n"); //getchar(); break; } else { /*Assign the heap data to the ant data and decrement the heap count*/ if(flag==1){ for(k=0;k<features;k++)ants[i].data[k]=data[heaps[position].objects[0]][k]; }else{for(k=0;k<features;k++)ants[i].data[k]=heaps[position].Ocenter[k];} for(j=position;j<heapCount-1;j++) heaps[j]=heaps[j+1]; heapCount--; } /*Clear the board position */ board[a][b]=-9; } else ants[i].carrying=-1; ants[i].speed=0; ants[i].dir=lrand48()%8; printf("\n Ant %2d X: %2d Y: %2d Carying : %2d ",i,ants[i].x,ants[i].y,ants[i].carrying); } currentAntCount=loopCount; } /********************************************************************/ /* Function to move the ant */ /* Output: None */ /* Input: Ant to be moved and the flag indicating the iteration */ /********************************************************************/ void moveNext(ant* a,int flag) { int rowCount,colCount; /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; } else { rowCount=heapRow; colCount=heapRow; }*/rowCount=currentRow;colCount=currentRow; /*Depending upon the direction move the ant*/ switch (a->dir) { case 0: a->y++; if(a->y>=colCount)a->y=0; break; case 1: a->x--; a->y++;; if(a->x<0)a->x=rowCount-1; if(a->y>=colCount)a->y=0; break; case 2: a->x--; if(a->x<0)a->x=rowCount-1; break; case 3: a->x--; a->y--; if(a->x<0)a->x=rowCount-1; if(a->y<0)a->y=colCount-1; break; case 4: a->y--; if(a->y<0)a->y=colCount-1; break; case 5: a->x++; a->y--; if(a->x>=rowCount)a->x=0; if(a->y<0)a->y=colCount-1; break; case 6: a->x++; if(a->x>=rowCount) a->x=0; break; case 7: a->x++; a->y++; if(a->x>=rowCount)a->x=0; if(a->y>=colCount)a->y=0; break; } }//end of function /********************************************************************/ /* Function to compute the parameters of the heap */ /* Output: None */ /* Input: The heap whose parameters are to be computed iteration flag*/ /********************************************************************/ void computeHeapParameters(heap* heapData,int flag) { int i=0,j=0,k=0,position=0; float distance=0; float Dmean=0.0; float *dis; float featureSum[features]; float max=0; float sum=0; /* init*/ for(k=0;k<features;k++) featureSum[k]=0; /*Compute the distance of each object and find the maximum distance*/ max=0; if(flag==1){ for(j=0;j<heapData->count;j++) for(i=0;i<heapData->count;i++) { for(k=0;k<features;k++) sum+= (data[heapData->objects[j]][k]-data[heapData->objects[i]][k])*(data[heapData->objects[j]][k]-data[heapData->objects[i]][k]); distance=sqrt(sum); if(max<distance) max=distance; sum=0; } /* Assign the maximum distance to the heap */ heapData->Dmax=max;/*Compute the centre object*/for(i=0;i<heapData->count;i++)for(k=0;k<features;k++) featureSum[k]+=data[heapData->objects[i]][k];for(k=0;k<features;k++)heapData->Ocenter[k]=featureSum[k]*1.0/heapData->count; /* Find the mean distance */if((dis=(float *) calloc(heapData->count,sizeof(float)))==NULL){printf("\nUnable to allocate memory in the compute heap parameters procedure\n");exit(0);} for(i=0;i<heapData->count;i++) { Dmean+=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); dis[i]=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); } heapData->Dmean=Dmean*1.0/heapData->count; /*Compute the most dissimilar object*/ max=dis[0]; for(i=1;i<heapData->count;i++) if(max<dis[i]) { max=dis[i]; position=i; } /*Assign the most dissimilar object to the heap variable*/ for(k=0;k<features;k++) heapData->Odissim[k]=data[heapData->objects[position]][k]; heapData->disPosition=position;free(dis); } else{/* Heap Parameters for the second stage */for(k=0;k<features;k++){ heapData->Odissim[k]=heapData->Ocenter[k];}heapData->disPosition=0;heapData->Dmean=0;heapData->Dmax=0;} }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a single object*/ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject1(ant *a,int position,int flag) { int i,k=0; /*Clear the board*/ board[heaps[position].x][heaps[position].y]=-9; /* Assign the data to the ant*/if(flag==1){ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[0]][k];}else {for(k=0;k<features;k++) a->data[k]=heaps[position].Ocenter[k];} a->carrying=1; /*Copy all the heaps remaining heaps in the structure*/ for(i=position;i<heapCount-1;i++) heaps[i]=heaps[i+1]; /*Decrement the heap count*/ heapCount--; }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a two objects */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject2(ant *a , int position,int flag) { float Pdestroy1=-1; int i=0,k=0; /*Compute the probability to destroy the heap*/ Pdestroy1=lrand48()%13*1.0/12.0; /*If the probability is more than Pdestroy then destroy the heap */ if(Pdestroy1<Pdestroy) { /*pick the object randomly*/ i=lrand48()%2; /* Assign the data to the ant */ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[i]][k]; a->carrying=1; /*Correct the heap parameters*/ heaps[position].count=1; heaps[position].objects[0]=heaps[position].objects[1-i]; computeHeapParameters(&heaps[position],flag); } }//end of function /********************************************************************/ /*Function to pick a object from a heap consisting of more than two object */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /********************************************************************/ void pickObjectn(ant *a,int position,int flag) { int i=0,k=0; /*If the criteria is satsfied then pick the object*/ if((computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)*1.0/heaps[position].Dmean)>Tremove) { a->carrying=1; for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[heaps[position].disPosition]][k]; for(i=heaps[position].disPosition;i<heaps[position].count-1;i++) heaps[position].objects[i]=heaps[position].objects[i+1]; heaps[position].count--; computeHeapParameters(&heaps[position],1); } }//end of function /********************************************************************/ /* Function to pick a object */ /********************************************************************/ void pick(ant *a,int flag) { int position=-1,i=0; float Pload1=-1.0; for(i=0;i<heapCount;i++) { /*Check if a heap is present in the eight neighbouring cells*/ if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if Heap is found*/ if(position!=-1) { /* heap or object found.*/ /*Depending upon the number present in the heap call the corresponding routine*/ switch(heaps[i].count) { case 1: Pload1 = lrand48()%151*1.0/150.0; if(Pload1<Pload) { pickObject1(a,position,flag); } break; case 2: pickObject2(a,position,flag); break; default: pickObjectn(a,position,flag); break; } } } /********************************************************************/ /* Function to drop a object to form a new heap */ /* Output: None */ /* Input: Ant, iteration flag */ /* Global Structure modified : heap, heapCount */ /********************************************************************/ void dropObject(ant* a,int flag) { /*Create a new heap*/ int k=0; heaps[heapCount].count=1; heaps[heapCount].x=a->x; heaps[heapCount].y=a->y; heaps[heapCount].Dmax=0; heaps[heapCount].Dmean=0; heaps[heapCount].disPosition=0; for(k=0;k<features;k++) { heaps[heapCount].Odissim[k]=a->data[k]; heaps[heapCount].Ocenter[k]=a->data[k]; } if(flag==1) {heaps[heapCount].objects[0]=findInData(a->data,flag); /*computeHeapParameters(&heaps[heapCount],flag);*/ } computeHeapParameters(&heaps[heapCount],flag); heapCount++; a->carrying=-1; board[a->x][a->y]=9; }//end of function /********************************************************************/ /* Function to find the heap position during the second iteration */ /* Output: position of the heap */ /* Input: object center of the heap that the ant is carrying */ /* Global Structure modified : none */ /********************************************************************/ int findInNewheaps(irisData object) { int position=-1,i,j=0,flag[features],flg; for(i=0;i<newHeapCount;i++) { for(j=0;j<features;j++) { if(fabs(object[j]-newHeaps[i].Ocenter[j])<0.00001) flag[j]=1; else {flag[j]=0;break;} } flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /*Function to drop a object to a heap consisting of a one or more object */ /* Output: none */ /* Input: Ant, position of the heap , iteration flag */ /* Global Structure modified: heaps,newHeaps */ /********************************************************************/ void dropObject1(ant* a, int position,int flag) { int heapPosition=-1,heapPosition1=-1,i,j,k=0; irisData newData,temp; if(flag==1) { /*Add the object to the heap and compute the heap parameters*/ /*if(heaps[position].count==heaps[position].objCount) {if((junk=(int *)realloc(heaps[position].objects,((heaps[position].objCount+OBJINC)*sizeof(int))))==NULL){printf("\n Cannot Allocate memory to the new object for %d heap",position);exit(0);}heaps[position].objects=junk;heaps[position].objCount+=OBJINC;free(junk); }*/ heaps[position].objects[heaps[position].count]=findInData(a->data,flag); heaps[position].count++; computeHeapParameters(&heaps[position],flag); } else { for(k=0;k<features;k++)temp[k]=heaps[position].Ocenter[k]; heapPosition=findInNewheaps(a->data); heapPosition1=findInNewheaps(heaps[position].Ocenter); if(heapPosition==-1||heapPosition1==-1) { printf("\n error in logic:new heaps\n"); //getchar(); return; } for(k=0;k<features;k++) {newData[k]=(newHeaps[heapPosition].Ocenter[k]*newHeaps[heapPosition].count+newHeaps[heapPosition1].Ocenter[k]*newHeaps[heapPosition1].count)*1.0/(newHeaps[heapPosition].count+newHeaps[heapPosition1].count);newHeaps[heapPosition].Ocenter[k]=newData[k];heaps[position].Ocenter[k]=newData[k]; } computeHeapParameters(&heaps[position],flag); for(i=newHeaps[heapPosition].count,j=0;j<newHeaps[heapPosition1].count;i++,j++) { newHeaps[heapPosition].objects[i]=newHeaps[heapPosition1].objects[j]; } newHeaps[heapPosition].count+=newHeaps[heapPosition1].count; for(i=heapPosition1;i<newHeapCount-1;i++) newHeaps[i]=newHeaps[i+1]; newHeapCount--; } a->carrying=-1; }//end of function /********************************************************************/ /* Function to drop a object */ /* Output: None */ /* Input: Ant, iteration flag */ /********************************************************************/ void drop(ant* a,int flag) { int i, position=-1; float Pdrop1=0.0; /*Find whether we have a heap in the neighbourhood of the cell*/ for(i=0;i<heapCount;i++) { if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if a heap is found*/ if(position!=-1) { /*heap or object found.*/ /*Depending on the number of objects present take action*/ switch(heaps[position].count) { /*If criteria is satisfied then drop the object*/ case 1: if(flag==1) { if((computeDistanceBetween2(a->data,data[heaps[position].objects[0]])*1.0/Dmax)<Tcreate) dropObject1(a,position,flag); } else { if((computeDistanceBetween2(a->data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) dropObject1(a,position,flag); } break; default: if(computeDistanceBetween2(a->data,heaps[position].Ocenter)<computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)) dropObject1(a,position,flag); break; } } else { /*Compute the probability to drop the object*/ Pdrop1 = lrand48()%151*1.0/150; if(Pdrop1<Pdrop) dropObject(a,flag); } }//end of function /********************************************************************/ /* Function to move the ant */ /* Output: none */ /* Input: Ant, iteration flag */ /********************************************************************/ void move(ant* a,int flag) { float pDir; /*Check the speed */ if (a->speed!=0) { /*move in the same direction*/ a->speed--; moveNext(a,flag); } else { /*generate the new direction*/ pDir=lrand48()%17*1.0/16.0; if(pDir<.85) { a->dir=lrand48()%8; } else if(pDir>.95) { a->speed=2; } moveNext(a,flag); } } /********************************************************************/ /* Function to simulate the movement of the ants */ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified: minHeapCount, minHeapPosition */ /********************************************************************/ void iterate(int flag) { int i=0,j=0,k=0,loopCount=0; if (flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS; while (i<MAXITERATIONS) { i++; for(j=0;j<loopCount;j++) { move(&ants[j],flag); if(ants[j].carrying==1) { drop(&ants[j],flag); } else { pick(&ants[j],flag); } } if(debugLevel>0){ for(k=0;k<heapCount;k++) for(j=0;j<heapCount;j++) if((k!=j)&&(heaps[k].x==heaps[j].x)&&(heaps[k].y==heaps[j].y)) { printf("\nerror two heaps with same co ordinates %d %d ",k,j); //getchar(); } k=0; for(j=0;j<heapCount;j++) k+=heaps[j].count; } if(heapCount<minHeapCount) { minHeapCount=heapCount; minPosition=i; } if(debugLevel>0) printf("\n i:%d Heap count %d sum %d",i,heapCount,k); else printf("\n i:%d Heap count %d",i,heapCount); heapSum+=heapCount; /*if(i%updateAfter==0) {adjustBoard(flag); writeIncremental(i,flag);heapSum=0;loopCount=currentAntCount; }*/ } }//end of function /********************************************************************/ /*Function to drop the objects carried by the ants after all the iterations*/ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified:none */ /********************************************************************/ void dropFinal(int flag) { int i=0,j=0,position=-1,loopCount=0; /*if(flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS;*/ loopCount=currentAntCount; for(i=0;i<loopCount;i++) { if(ants[i].carrying==1) { if(flag==1) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position,flag); } } else { /*Find if a heap is present */ do { position=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position,flag); position=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position!=-1); } } } }//end of function /********************************************************************/ /* Function for the implementation of QuickSort */ /* Output: none */ /* Input: data structure, low and high indices */ /* Global structure modified:none */ /********************************************************************/ void quickSort( heap A[], int low,int high ) { int mid=0; if(low<high) { mid=partition(A,low,high); quickSort(A,low,mid); quickSort(A,mid+1,high); } } /********************************************************************/ /* Partition routine used by quick sort */ /* Output: partition location */ /* Input: data , low, high */ /* Global structure modified:none */ /********************************************************************/ int partition(heap a[], int low,int high) { heap temp; int x=0,i=0,j=0; i=low; j=high; x=a[low].count; while (1) { while (a[j].count<x) j=j-1; while (a[i].count>x) i=i+1; if(i<j) { temp=a[i]; a[i]=a[j]; a[j--]=temp; } else return(j); } } /********************************************************************/ /* Function used to write the cluster information */ /* Output: none */ /* Input:iteration flag */ /* Global structure modified:none */ /********************************************************************/ void writeClusterInformation(int flag) { FILE *fp=fopen("center.clt","w"); FILE *fp1; FILE *fp2; FILE *fp3; char temp[80]; int i=0,j=0,k=0; int lastCount=0; int rowCount,colCount,antCount; strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp3=fopen(temp,"a"); if(dataDump) {strcpy(temp,"");sprintf(temp,"%sTot.out",filename);fp1=fopen(temp,"a");strcpy(temp,"");sprintf(temp,"%sObj.out",filename);fp2=fopen(temp,"a");if(fp1==NULL||fp2==NULL)printf("\n Error in opening file in the writer Cluster Information routine\n"); } /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; antCount=MAXANTS; } else { rowCount=heapRow; colCount=heapRow; antCount=MAXANTSFORHEAPS; }*/ rowCount=currentRow; colCount=currentRow; antCount=currentAntCount; if(fp==NULL) { printf("\n Unable to open cluster center output file \n"); /*return;*/ exit(0); } /*sort the array according to the count value and write the value of the top three elements*/ if((flag==1)&&(!EntireHeaps)) quickSort(heaps,0,heapCount); if(EntireHeaps) {if(flag==1) lastCount=heapCount;else lastCount=newHeapCount; } else lastCount=c; for(i=0;i<lastCount;i++) { if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",newHeaps[i].Ocenter[k]); fprintf(fp,"\n"); } else { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); fprintf(fp,"\n"); } } if(dataDump) { fprintf(fp1,"\n Information from the Ant Based Algorithm \n"); fprintf(fp1,"\n Important Parameters : Board %d X %d Ants : %d Iterations %d Total Heaps %d ",rowCount,colCount,antCount,MAXITERATIONS,lastCount); } if(flag==0) { if(dataDump) { fprintf(fp1," TCreateForHeaps %f \n",TcreateForHeaps); fprintf(fp2,"\nTotal Heaps : %d\n",heapCount); fprintf(fp2,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); } fprintf(fp3,"\n@ %d\n",lastCount); } else if(dataDump) fprintf(fp1,"\n");if(dataDump) { fprintf(fp1,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); for(i=0;i<lastCount;i++) if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp2,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); } fprintf(fp1," %5d\n",newHeaps[i].count); fprintf(fp2," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp1," %5d\n",heaps[i].count); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]); fprintf(fp1," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]); fprintf(fp1," %5d\n",heaps[i].count); }} if(flag==0) { if(dataDump) fprintf(fp1,"\n Objects in the heaps \n");for(i=0;i<newHeapCount;i++) { if(dataDump) fprintf(fp1,"\n\n Heap %d\n \n",i+1);fprintf(fp3,"# %d %d\n",i ,newHeaps[i].count); for(j=0;j<newHeaps[i].count;j++){ for(k=0;k<features;k++){ fprintf(fp3,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]); if(dataDump) fprintf(fp1,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]);} if(dataDump) fprintf(fp1,"\n"); fprintf(fp3,"\n"); } } } fclose(fp); fclose(fp3); if(dataDump) { fclose(fp1);fclose(fp2); }}//end of flie /********************************************************************/ /* Function to initialise the new heaps */ /* Output: none */ /* Input:new Heap structure */ /* Global structure modified:none */ /********************************************************************/ void initialiseNewHeaps(heap newHeaps[]) { int i=0,j=0; for(i=0;i<lCount;i++) { newHeaps[i].count=0; for(j=0;j<features;j++) newHeaps[i].Ocenter[j]=V[i][j]; newHeaps[i].x=heaps[i].x; newHeaps[i].y=heaps[i].y; } }//end of function /********************************************************************/ /* Function to initialise the new heaps */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ int findPosition(int i) { int j,position=0; for(j=1;j<lCount;j++) { if(U[j][i]>U[position][i]) position=j; } printf("\n Position %d ",position); return(position); }//end of function find position /********************************************************************/ /* Function to add object */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ void addObject(int object,heap * heapPosition) { heapPosition->objects[heapPosition->count]=object; heapPosition->count++; }//end of function add object /********************************************************************/ /* Function to harden the outputs obtained from fcm */ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/ void harden(heap newHeaps[]) { int i,heapPosition=-1,sum=0,j=0; /*initialise the new heaps*/ initialiseNewHeaps(newHeaps); for(i=0;i<count;i++) { heapPosition=findPosition(i); addObject(i,&newHeaps[heapPosition]); } /* To check for degenerate partitions*/ for(i=0;i<lCount;i++) { if(newHeaps[i].count==0){for(j=i;j<lCount-1;j++){newHeaps[j]=newHeaps[j+1];}lCount--;i--;} } newHeapCount=lCount; for(i=0;i<lCount;i++) computeHeapParameters(&newHeaps[i],1); if(debugLevel>0) { for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\n sum = %d",sum);} }//end of function/********************************************************************/ /* Function to initialize the initial parameters for the ant algorithm*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void init() { int i=0,j=0; for(i=0;i<MAXROWS;i++) for(j=0;j<MAXCOLS;j++) board[i][j]=-9; heapCount=0; newHeapCount=0; heapRow=0; minPosition=-1; minHeapCount=100000; for(i=0;i<MAXANTS;i++) { ants[i].carrying=-1; ants[i].x=-1; ants[i].y=-1; ants[i].speed=-1; ants[i].dir=-1; } } /********************************************************************/ /* Function to initialize the initial board */ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void initialiseBoard() { int i,j; for(i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; }/********************************************************************/ /* Function to harden the outputs obtained from fcm(2nd stage)*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: Cluster center , cluster center count*/ /********************************************************************/void harden1() { int i=0,heapPosition=-1; for(i=0;i<heapCount;i++) cenCount[i]=0; for(i=0;i<n;i++) { heapPosition=findPosition1(i); addObject1(i,heapPosition); } writeInfo(); }//end of function/********************************************************************/ /* Function to find to which class the object belongs */ /* Output: Class number */ /* Input: object position */ /* Global Structure Modified: None */ /********************************************************************/int findPosition1(int i) { int j,position=0; for(j=1;j<heapCount;j++) { if(U[j][i]>U[position][i]) position=j; } return(position); }//end of function find position/********************************************************************/ /* Function to Write the output of the hardened objects to file*/ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/void writeInfo(){int i=0,j=0,k=0;FILE *fp=fopen("fcm.out","a");if(fp==NULL){printf("\n Unable to open fcm output file \n");return;}fprintf(fp,"\n@ %d\n",heapCount);for(i=0;i<heapCount;i++){fprintf(fp,"# %d %d\n",i,cenCount[i]);for(j=0;j<cenCount[i];j++){for(k=0;k<s;k++)fprintf(fp,"%8.2f ",clsCen[i][j][k]/scale[k]+minInput[k]);fprintf(fp,"\n");}}fclose(fp);return;}/********************************************************************/ /* Function to add a object to a cluster (2nd stage) */ /* Output: none */ /* Input: object poistion , cluster position */ /* Global Structure Modified: Cluster object and cluster count*/ /*******************************************************************/void addObject1(int object,int heapPosition) { int k=0; for(k=0;k<features;k++) clsCen[heapPosition][cenCount[heapPosition]][k]=X[object][k]; cenCount[heapPosition]++; return; }//end of function add object/********************************************************************/ /* Function to read the original classification of objects */ /* Output: none */ /* Input: none */ /* Global Structure Modified: None */ /*******************************************************************/void readOrg(){int i=0,k=0;char temp[80];FILE *fp;//= fopen(dataname,"r");strcpy(temp,"");sprintf(temp,"%sFull.data",filename);fp=fopen(temp,"r");if(fp==NULL){printf("\n Unable to open full data input file ");exit(0);}for(i=0;i<n;i++){fscanf(fp,"%f ",&orgData[i][0]);for(k=1;k<s+1;k++)fscanf(fp,"%f ",&orgData[i][k]);}return;}// end of function/********************************************************************/ /* Function to classify the objects in different clusters */ /* Output: none */ /* Input: the cluster objects, the original classification, */ /* number of objects in the cluster,file to write the data */ /* Global Structure Modified: None *//********************************************************************/int analysisData(float data[][s],float orgData[n][s+1],int count,FILE * fp){int i=0,j=0,k=0,type=1,max=0;heapInfo info;for(i=0;i<c;i++){info.classObj[i]=0;}info.total=0;info.total=count;for(i=0;i<count;i++)for(j=0;j<n;j++){type=1;for(k=0;k<s;k++)if(fabs(data[i][k]-orgData[j][k+1])>errThresh){type=-1;break;}if(type!=-1){info.classObj[(int)orgData[j][0]-1]++;break;}}max=0;for(k=0;k<c;k++){if(info.classObj[k]>info.classObj[max])max=k;fprintf(fp,"\nClass %d Objects % d ",k+1,info.classObj[k]);}j=0;for(k=0;k<c;k++){if(k!=max)j+=info.classObj[k];}fprintf(fp,"\n Total errors : %d \n",j);return(j);}//end of analyse/********************************************************************/ /* Function to read the cluster information */ /* Output: none */ /* Input: input file pointer , output file pointer */ /* Global Structure Modified: None *//********************************************************************/void readFCM(FILE* fp,FILE *fp1){int i=0,j=0,k=0,l=0;int totalRuns=0,heapCount=0,junk=0,sum=0;char ch;FILE *fp2=fopen("errors.out","a");ch = 'c'; while (ch != '$') fscanf (fp, "%c", &ch);fscanf(fp,"%d\n",&totalRuns);printf("\n total runs %d ",totalRuns);for(l=0;l<totalRuns;l++){fscanf(fp,"%c",&ch);fscanf(fp,"%d\n",&heapCount);fprintf(fp1,"\n \nExperiment %d \n ",l+1);sum=0;for(i=0;i<heapCount;i++){fscanf(fp,"%c",&ch);fscanf(fp," %d %d\n",&junk,&clsCenCount[i]);for(j=0;j<clsCenCount[i];j++)for(k=0;k<s;k++)fscanf(fp,"%f",&fcmData[i][j][k]);fscanf(fp,"\n");fprintf(fp1,"\n\n Heap %d Total Objects %d \n",i+1,clsCenCount[i]);sum+=analysisData(fcmData[i],orgData,clsCenCount[i],fp1);}fprintf(fp2," %3d %3d %3d \n",l,sum,heapCount);}fprintf(fp2,"\n --------------------------\n");fclose(fp2);return;}//end of function/********************************************************************/ /* Function to update the board parameters */ /* Output: none */ /* Input: none */ /* Global Structure Modified: board size, ant count *//********************************************************************/void adjustBoard(int flag){int newRow=0,newAnt=0,antDiff=0,antsKilled=0,i=0,position[MAXANTS],position1=-1,j=0,k=0,a,b; newRow= (int)ceil(sqrt(4.0*heapSum/updateAfter)); newAnt= (int)ceil((heapSum*1.0/updateAfter)*1.0/3.0); if(newAnt<minAnts)newAnt=minAnts; if(newRow<rowMin)newRow=rowMin;antDiff=currentAntCount-newAnt; if((antDiff>0)&&(newAnt>=minAnts)) {for(i=0;i<currentAntCount;i++){if(ants[i].carrying==-1){position[antsKilled++]=i;}} if(antsKilled>=antDiff){for(i=0;i<antDiff;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1];for(k=i+1;k<antsKilled;k++)position[k]--; } currentAntCount=newAnt; }else {for(i=0;i<antsKilled;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1]; for(k=i+1;k<antsKilled;k++)position[k]--; }if(flag==1) { for(i=currentAntCount-1,k=0;k<antDiff-antsKilled;k++,i--) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position1,flag); }else { dropObject(&ants[i],flag); } } } else { //flag is zero 2nd stage /*Find if a heap is present */ do { position1=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position1].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position1,flag); position1=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position1!=-1); }//end else currentAntCount=newAnt;}//end elsecurrentAntCount=newAnt;}//end iffor(i=0;i<newAnt;i++){if((ants[i].x>=newRow)||(ants[i].y>=newRow)) { a=lrand48()%newRow; b=lrand48()%newRow; ants[i].x=a; ants[i].y=b; }} //Done with ants, now adjust the boardif((currentRow>newRow)&&(newRow>=rowMin)){for(i=0;i<heapCount;i++){if((heaps[i].x>=newRow)||(heaps[i].y>=newRow)) {do { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionheaps[i].x=a;heaps[i].y=b;board[a][b]=9;}//end if}//end for for(i=0;i<currentAntCount;i++){if((ants[i].carrying==1)&&((ants[i].x>=newRow)||(ants[i].y>=newRow))){//adjust the ant locationdo { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionants[i].x=a;ants[i].y=b;}//end if}//end for currentRow=newRow;}//end if }//end of function void writeIncremental(int iteration,int flag){FILE *fp=fopen("dump.txt","w");int i=0,j=0,k=0;fprintf(fp,"Stage %d\n",flag);fprintf(fp,"Board %d\n",currentRow);fprintf(fp,"Ants %d\n",currentAntCount);fprintf(fp,"Iteration %d\n",iteration);fprintf(fp,"Heaps %d\n",heapCount); if(flag==0)fprintf(fp,"NewHeapCount %d\n",newHeapCount); fprintf(fp,"Ants\n");for(i=0;i<currentAntCount;i++){fprintf(fp,"%d %d %d %d %d ",ants[i].x,ants[i].y,ants[i].carrying,ants[i].speed,ants[i].dir);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",ants[i].data[k]);fprintf(fp,"\n");}fprintf(fp,"Heaps\n");for(i=0;i<heapCount;i++){fprintf(fp,"%d %d %d %d %8.2f %8.2f \n",heaps[i].x,heaps[i].y,heaps[i].count,heaps[i].disPosition,heaps[i].Dmax,heaps[i].Dmean);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Ocenter[k]);fprintf(fp,"\n");for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Odissim[k]);fprintf(fp,"\n");if(flag==1){for(j=0;j<heaps[i].count;j++)fprintf(fp,"%d ",heaps[i].objects[j]);fprintf(fp,"\n");}}if(flag==0){fprintf(fp,"newHeaps\n");for(i=0;i<newHeapCount;i++){fprintf(fp,"%d\n",newHeaps[i].count);for(j=0;j<newHeaps[i].count;j++)fprintf(fp,"%d ",newHeaps[i].objects[j]);fprintf(fp,"\n");}}fclose(fp);}//end of function/********************************************************************/ /* Function Main */ /********************************************************************/ int main(int argc ,char** argv) { int sum=0,k=0,i=0,j=0; char temp[80]; FILE *fp=fopen("fcm.out","w"); FILE *fp1; FILE *fp2=fopen("antAnalysis.out","a"); FILE *fp3=fopen("fcmAnalysis.out","a"); FILE *fp4=fopen("errors.out","w"); FILE *fp5; fclose(fp4); sprintf(temp,"%sObj.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sTot.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp1=fopen(temp,"w"); fprintf(fp,"\n$%d",EXPRUN); fprintf(fp1,"\n$%d",EXPRUN); fclose(fp); fclose(fp1); if(argc==2)sscanf(argv[1],"%d",&debugLevel); printf("\n Debug level %d\n",debugLevel); for( i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; //Read from the file readInput(); //Compute the distance of all the points if(maxDist) { Dmax=computeDistance(); //Compute the maximum distance fp5=fopen("maxData.txt","w");fprintf(fp5,"%f",Dmax);fclose(fp5); } else {fp5=fopen("maxData.txt","r");fscanf(fp5,"%f",&Dmax);fclose(fp5); } printf("\n %f \n",Dmax); //Initialise the board for(k=0;k<EXPRUN;k++) { init(); sum=0; srand48(state1[k]); initialiseBoard(); initialise(1); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(1); printf("\n %d \n",heapCount); //Simulate the working of ants iterate(1); //drop the objects after all the iterations dropFinal(1); //to verify the correctness for(i=0;i<heapCount;i++) sum+=heaps[i].count; //write the cluster centers to the file writeClusterInformation(1); printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); //getchar(); //Run FCM // heapCount=2973;/* To be commented */ printf("\n\n k %d \n\n",k); Fcm(data); //compute new board size. lCount=heapCount; heapRow=(int)ceil(sqrt(4*heapCount)); newHeapCount=lCount; printf("\n LCount %d newHeapCount %d heap Row %d \n",lCount,newHeapCount,heapRow); //harden the objects harden(newHeaps); //iterate with the heaps as the objects. initialiseBoard(); initialise(0); for(i=0;i<lCount;i++) computeHeapParameters(&heaps[i],0); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(0); printf("\n %d \n",heapCount); //getchar(); //Simulate the working of ants iterate(0); dropFinal(0); writeClusterInformation(0); sum=0; for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); // getchar(); Fcm(data); harden1(); } fp=fopen("fcm.out","a"); fp1=fopen(temp,"a"); fprintf(fp,"\n"); fprintf(fp1,"\n"); fclose(fp); fclose(fp1); fp=fopen("fcm.out","r"); fp1=fopen(temp,"r");printf("\n Before read org\n");readOrg();printf("\nafter read org\n");readFCM(fp1,fp2);printf("\n After 1st read fcm\n");readFCM(fp,fp3);printf("\n After 2 fcm read \n");return(1); }//end of main /****************************************************************/ float NORM(feature , feature); void find_covar(); void Fcm (irisData Data[MAXDATA]) { int i,j,l; FILE *ofile; char temp[80]; int flag=0;//added by parag FILE *iniClsCen=fopen("center.clt","a+"); if(iniClsCen==NULL) { printf("\n Unable to open the initial cluster center file\n"); printf("\n choosing random cluster centers....\n"); flag=1; } strcpy(temp,""); sprintf(temp,"%s.data",filename); strcpy (fname,temp); /* Read from this file */ m=2.0; /* The exponent */ /*GET_INPUTS1(fname);*/ /* read in feature vectors */ for (j=0; j<n ; j++) /* Read File in row-major */ for (i=0; i<s ; i++) /* format */ X[j][i]=Data[j][i]; Random_seed=state1[run];/*randseed*/ srand48(Random_seed); for (run=0;run<TOTRUNS;run++) { //flag=1;//for testing random values if (EntireHeaps) lCount=heapCount; else lCount=c; for(i=0;i<lCount;i++) for(j=0;j<s;j++) V[i][j]=0; for(i=0;i<lCount;i++) { for(l=0;l<s;l++) { if(flag==1) { rand_index = lrand48() % n; V[i][l] = X[rand_index][l]; } else { fscanf(iniClsCen,"%f ",&V[i][l]); } }//end for } eps=0.001; stop = FALSE; /* This loop finds the final cluster center and the corresponding U values */ z = 0; while (stop == FALSE) { z++; UMAT(U,V,X); /** Update the U matrix **/ stop = FINISHED(U1,eps); CLUSTER(U,X); /** Get new cluster center **/ printf("Iteration: %d\n\n", z); } /* end while */ printf("Number of iterations: %d\n\n", z);strcpy(temp,""); sprintf(temp,"%sFCM.out",filename);if(dataDump) Output(temp); /* output the results */ }/*end for*/ if(dataDump) { ofile=fopen(temp,"a"); for (i=0; i <= mins; i++) fprintf(ofile, "Min %d of %10.3f occurred %d times\n", i, mintab[i], mincount[i]); fprintf(ofile, "Average iterations %f\n", (float)aveit/(float)TOTRUNS); fclose(ofile); } }/* end Main */ /* The GET_INPUTS1 procedure opens an input file, reads the number of input vectors, the number of features per vector, the number of clusters, and epsilon, then it reads the input values */ void GET_INPUTS1(char fname[]) //char fname[]; { /* Parameters: fname -- name of file containing input info. */ FILE *infile ;//*fopen(); //char junk[10][80]; char realfname[80]; char ch; char fileName1[80]; //int temp[10], i, j, inputs, outputs, count; int i,j; sprintf (realfname, "%s", fname); /* open input file */ if(normalize==1) strcpy(fileName1,"gtest1.data"); else strcpy(fileName1,fname); if((infile = fopen (fileName1, "r")) == NULL) printf("\n CAN'T OPEN %s\n",realfname); else { ch = 'c'; /* Discard leading comments */ while (ch != '#') fscanf (infile, "%c", &ch); for (j=0; j<n ; j++) /* Read File in row-major */ { /* format */ for (i=0; i<s ; i++) fscanf (infile, "%f", &X[j][i]); /* fscanf (infile, "%d", &temp[1]); */ /* end for */ } /* end for */ fclose(infile); /* close input file */ }/* end else */ } /* end GET_INPUTS1 */ /* The NORM function computes the norm of two vectors, x and v, of dimension s. This gives an indication of the distance between them */ float NORM( feature x, feature v) //feature x, v; { /* Parameters : x -- a local copy of an input vector v -- a local copy of a cluster center */ int i,j; /* loop variable */ double sum; /* the square root of sum is the norm; sum is the sum of the differences squared */ float mat1[s]; float mat2[s]; if (maha) { for (i=0; i<s; i++) mat1[i]=x[i]-v[i]; for(i=0;i<s;i++) { sum =0; for(j=0;j<s;j++) sum += mat1[j] * inv_cov[j][i]; mat2[i] = sum; } sum =0; for(j=0;j<s;j++) sum += mat1[j]*mat2[j]; } else { sum = 0; for(j=0;j<s;j++) sum += (x[j] - v[j])* (x[j] - v[j]); } return (float)(sqrt(sum)); } /* end NORM */ /* The UMAT procedure calculates the updated U matrix according to Bezdek's formula. Its side-effect is the update of the global array U1 */ void UMAT( matrix U,center V, objects X) /*matrix U; center V; objects X;*/ { /* Parameters: U, V, and X: same as in main program */ int i, j, k,l ;/* loop variables *///, class /* class whose cluster center //is closest to pattern k */; float d1,d2,d; float sum; int exact; for (k=0;k<n;k++) { /*printf("\n k %d ",k);*/ exact=false; for (i=0;i<lCount;i++) { sum=0; for (j=0;j<lCount;j++) { d1=NORM(X[k],V[i]); d2=NORM(X[k],V[j]); if(d2!=0) { d= d1/d2; d= d * d;/* pow(d1/d2,2.0/(m-1.0)); */ sum+=d; } else { exact = true; for(l=0;l<lCount;l++) if (l==j) U1[l][k]=1.0; else U1[l][k]=0.0; break; } } if (exact!=true) U1[i][k]=1.0/sum; } } } /* end UMAT */ /* The function FINISHED determines if a termination occurs. If not it updates U with U1, so its side-effect is the potential modification of U */ BOOLEAN FINISHED( matrix U1,float eps) //matrix U1; float eps; { /* Parameters: U1, eps-- same as in main */ float sum; /* sum of squared differences between corresponding elements of U and U1 */ int i,k; /* loop control variabes */ BOOLEAN finished; /* set to true if all corresponding elements are within epsilon */ finished = TRUE; sum = 0; for (i=0; i<lCount; i++) for (k=0; k<n; k++) sum += (U[i][k] - U1[i][k])*(U[i][k]-U1[i][k]); if (sqrt(sum) > eps) { finished = FALSE; for (i=0; i<lCount; i++) for (k=0; k<n; k++) U[i][k] = U1[i][k]; } /* end if */ return finished; } /* end FINISHED */ /* The CLUSTER procedure determines cluster centers in V for the c classes being searched for. The global array V is updated */ void CLUSTER( matrix U, objects X) //matrix U; objects X; { /* Parameters: U, X -- as in main */ int i, j, k; /* loop control variables */ feature num; /* numerator in the cluster center computation formula presented by Bezdek */ float denum; /* denumenator in the obove formula */ for (i=0; i<lCount; i++) { denum = 0; for (j=0; j<s; j++) { num[j] = 0; for (k=0; k<n; k++) num[j] += U[i][k] * U[i][k] * X[k][j]; /* pow(U[i][k],m) * X[k][j]; */ } /* end for */ for (k=0; k<n; k++) denum += U[i][k] * U[i][k]; /* pow(U[i][k],m); */ for (j=0; j<s; j++) V[i][j] = num[j] / denum; } /* end for */ } /* end CLUSTER */ float Compute_Jm(center V, objects X) //center V; //objects X; { int i, k,found; double Jm_value; float u,dik; Jm_value = 0; for (k=0; k<n; k++) { found = FALSE; for (i=0; i<lCount; i++) { dik=NORM(X[k],V[i]); dik=dik*dik; if (dik==0.0) { if (found == FALSE) { u=1.0; found = TRUE; printf("found the case with dik=0\n"); } else { printf("\n cant proceed with this initialization"); exit(1); } } else { if (found != TRUE) u=U1[i][k]; /* get_Uvalue(V,X,dik,k); */ else u=0.0; } Jm_value += u * u * dik;/* pow(u, m) * dik; */ } } return (Jm_value); } /* end Compute_Jm */ /* The Output procedure outputs the U matrix which gives the fuzzy measure of each feature belonging to a cluster center. It also outputs the cluster center for each class */ void Output(char fname[]) //char fname[80]; /* Parameters: U, V -- same as in main */ { int i, j, found; /* loop control variables */ float J2c; if ((fp=fopen(fname,"a"))==NULL) printf("\n CAN'T OPEN %s\n",fname); else { fprintf(fp,"\n The cluster centers are: \n"); fprintf(fp,"\n \n"); for (i=0; i<lCount; i++) { fprintf(fp,"\nCluster center %d: ",i+1); fprintf(fp,"\n"); for (j=0; j<s; j++) fprintf(fp,"%8.7f ",V[i][j]); } /* end for */ fprintf(fp,"\nThe membership grades for the feature vectors are:\n"); for (j=0; j<n; j++) { fprintf(fp,"\n"); for (i=0; i<lCount; i++) fprintf(fp," %8.7f",U[i][j]); } /* end for */ } /* end if */ J2c= Compute_Jm(V,X); found =0; for (i=0;i<= mins; i++){ if ((found == 0) && ((J2c - mintab[i]) < .001) && ((J2c - mintab[i]) > -.001)){ mincount[i]++; found = 1; } } if (found == 0){ mins++; mintab[mins]=J2c; mincount[mins]=1; } fprintf(fp,"\nJ%3.1f = %f", m,J2c); fprintf(fp, "Number of iterations: %d\n\n", z); aveit=aveit + z; fclose(fp); } /***************************************************************/ void find_covar(int m) //int m; { int i,j,k; float mean[s],sum; for (i=0;i<s;i++) mean[i]=0; for (i=0;i<s;i++) for (j=0;j<m;j++) mean[i]+=X[j][i]; for (i=0;i<s;i++) mean[i]/=m; for (i=0;i<s;i++) for (j=0;j<s;j++) { sum=0; for (k=0;k<m;k++) sum+=(X[k][i]-mean[i])*(X[k][j]-mean[j]); Y[i][j]=sum/m; } }
Parag Kanade/fuzzy ants/Glass/glass.c
#include "headerStatic.h" /*******************************************************************/ /*** Global Variables ***/ irisData data[MAXDATA]; //To hold the data read from the file int count=0; //Count of the total number of data elements int heapCount=0; // Total number of heaps int heapRow=0; // Rows for the second iteration with heaps int newHeapCount=0; // Count of the heaps for the second iteration heap heaps[MAXDATA]; // Data structure to hold the heap information heap newHeaps[MAXDATA]; // Data Structure to hold the new heap information // For the second iteration int board[MAXROWS][MAXCOLS]; // Board on which the objects are located ant ants[MAXANTS]; // Data structure to hold the ants float Dmax=0; // Distance of the most dissimilar object pair int minHeapCount=100000; // Counter to hold the minimum heap count, used only for academic purpose // no use in the algorithm int minPosition; // the minimum heap iteration , only for academic purpose // no use in the algorithm float clsCen[MAXDATA][MAXDATA][s];//to hold the objects after hardening int cenCount[MAXDATA];//to hold the number of objects after hardening /********************************************************************/ /*** Varaibles to normalize the features between 0 and 1 */ float minInput[features], maxInput[features],scale[features],minForHeaps[features],maxForHeaps[features],scaleForHeaps[features]; /********************************************************************/ /** Variables for the FCM algorithm */ int temp[200]; /* for square matrix tests */ float eps,m; matrix U, U1; BOOLEAN stop; center V; objects X; char fname[80]; FILE *fp; int run; float inv_cov[s+1][s+1]; /* inverse of covariance matrix Y */ float Y[s][s]; long rand_index, Random_seed; long state1[52] = { 9347, 3835, 5194, 8310, 346, 535, 5297, 6711, 77, 3834, 668, 4175, 6868, 5890, 9304, 8462, 5269, 920, 65392, 41600, 70119, 91032, 76220, 26245, 4746, 73608, 32823, 63264, 75641, 99104, 36534, 24704, 98255, 72266, 75336, 65152, 7269, 63163, 88471, 27271, 43641, 76649, 47773, 23777, 27491, 35926, 16651, 48652, 89766, 90921, 6056 }; int z; int mins=0; int aveit =0; float mintab[200]; int mincount[200]; long start,end,total; int lCount;//added by parag /********************************************************************/ /********************************************************************//*int lrand48(){return(rand());}void srand48(int a){return;}*//********************************************************************/ /********************************************************************/ /* Function to read the input data set */ /* The file name is assumed to be itest.data */ /* Status: Tested */ /* Output: Data from the file into the "data" (Global) data structure */ /* Output: Count (Global), the count of the number of objects */ /********************************************************************/ void readInput() { FILE *fp; char fname[80]; int i=0,j=0; char ch; sprintf(fname,"%s.data",filename); /* Check if the input file is opened */ if((fp=fopen(fname,"r"))==NULL) { printf("\n Unable to open input file \n"); exit(0); } /*initialise the minimum maximum and the scale */ for(i=0;i<features;i++) { minInput[i]=1000; maxInput[i]=0; minForHeaps[i]=1000; maxForHeaps[i]=0; scale[i]=0; scaleForHeaps[i]=0; } /* Discard leading comments */ ch = 'c'; while (ch != '#') fscanf (fp, "%c", &ch); i=0; /* Parse the file and populate the data structure */ while(!feof(fp)) { for(j=0;j<features;j++) { fscanf(fp,"%f ",&data[i][j]); } fscanf(fp,"\n"); for(j=0;j<features;j++) { if(data[i][j]<minInput[j]) minInput[j]=data[i][j]; if(data[i][j]>maxInput[j]) maxInput[j]=data[i][j]; } i++; } count=i; /* Normailze the feature values in between 0 and 1 */ for(j=0;j<features;j++) { if(minInput[j]!=maxInput[j]) scale[j]=1.0/(maxInput[j]-minInput[j]); else scale[j]=1.0; } for(i=0;i<count;i++) { for(j=0;j<features;j++) data[i][j]=(data[i][j]-minInput[j])*scale[j]; } fclose(fp); return; }//end of function /********************************************************************/ /*Function to compute the eucldiean distance for all input data set */ /* Output : an array conatining the distance of each object with the other */ /********************************************************************/ float computeDistance() { float distance,dist=0; int i=0,j=0,k=0; distance=0; for(j=0;j<count;j++) for(i=0;i<count;i++) { for(k=0;k<features;k++) dist+=sqrt((data[j][k]-data[i][k])*(data[j][k]-data[i][k])); if(distance<dist)distance=dist; dist=0; } return(distance); } /********************************************************************/ /* Function to compute the distance between two objects */ /* Output : Euclidean d istance between the two input objects */ /********************************************************************/ float computeDistanceBetween2(irisData a,irisData b) { float temp=0; int i=0; for(i=0;i<features;i++) temp+=(a[i]-b[i])*(a[i]-b[i]); temp=sqrt(temp); return(temp); } /********************************************************************/ /* Function to find the maximum distance between the input objects*/ /* Output: the maximum distance */ /* Input : The array of distances between objects */ /********************************************************************/ /*float findMax(float *distance) { int i=0,j=0; float max=distance[0]; for(i=0;i<count;i++) for(j=0;j<count;j++) { if(max<distance[i*count+j]) max=distance[i*count+j]; } return(max); }*/ /********************************************************************/ /* Function to compute the value of an object */ /********************************************************************/ float value(irisData a) { int i=0; float temp=0; for(i=0;i<features;i++) temp+=a[i]*a[i]; return(sqrt(temp)); } /********************************************************************/ /* Function to find the object in the data structure */ /* Output : The position of the object in the data */ /* Input : The object */ /********************************************************************/ int findInData(irisData object,int iFlag) { int i=0,lastCount=0,j,position=-1,flag[features],flg;if(iFlag==1)lastCount=MAXDATA;else{}for(i=0;i<lastCount;i++){ for(j=0;j<features;j++) if(fabs(object[j]-data[i][j])<0.00001) flag[j]=1; else { flag[j]=0; break;} flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /* Function to find whether there is an object on the board at a,b */ /* Output : a flag indicating whether an object is found or not */ /* Input : The row and column indicating the board position */ /********************************************************************/ int found(int a , int b) { if(board[a][b]==9) return 1; else return 0; } /********************************************************************/ /* Function to initialize the initial board */ /* Output : None */ /* Global Structures modified : heaps */ /* Input : Flag indicating the iteration 1: First 0: Second */ /********************************************************************/ void initialise(int flag) { int a,b,i=0,k=0; int loopCount,rowCount,colCount; /* Initialize the row, column and number of heaps */ if(flag==1) { loopCount=count; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=lCount; rowCount=heapRow; colCount=heapRow; } /* Initialize the heaps */ for(i=0;i<loopCount;i++) { heaps[i].count=0; heaps[i].x=0; heaps[i].y=0; heaps[i].disPosition=0; heaps[i].Dmax=0; heaps[i].Dmean=0; } for(i=0;i<loopCount;i++) { /*find a board position which is empty*/ do { a=lrand48()%rowCount; b=lrand48()%colCount; } while(found(a,b)); /*Allocate the object to that place and assign a heap to it*/ heaps[i].x=a; heaps[i].y=b; heaps[i].count=1; heaps[i].Dmax=0; heaps[i].Dmean=0; if(flag==1) { heaps[i].objects[0]=i; for(k=0;k<features;k++)heaps[i].Ocenter[k]=data[i][k]; } else { for(k=0;k<features;k++) heaps[i].Ocenter[k]=newHeaps[i].Ocenter[k]; } heaps[i].disPosition=0; board[a][b]=9; if((debugLevel>0)&&(flag==1))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],data[heaps[i].objects[0]][0]); if((debugLevel>0)&&(flag==0))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],newHeaps[i].Ocenter[0]); } /*initialise the initial heap count*/ heapCount=loopCount; currentRow=rowCount; } /********************************************************************/ /* Function to find whether an heap is present at the location a b */ /* Output : Flag indicating the presencs of the heap */ /* Input : Roe and column indicating the board position */ /********************************************************************/ int findObject(int a,int b) { int i; int position=-1; for(i=0;i<heapCount;i++) { if((heaps[i].x==a)&&(heaps[i].y==b)) { position=i; break; } } return(position); } /********************************************************************/ /* Function initialize the ants */ /* Output : None */ /* Input : Flag indicating the iteration */ /* Global Variables Modified : ant, heapCount, heaps, board */ /********************************************************************/ void initialiseAnts(int flag) { int i=0,a=0,b=0,position,j=0,loopCount=0,rowCount,colCount,k=0; if(flag==1) { loopCount=MAXANTS; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=MAXANTSFORHEAPS; rowCount=heapRow; colCount=heapRow; } for(i=0;i<loopCount;i++) { /*generate random positions for the ants*/ a=lrand48()%rowCount; b=lrand48()%colCount; ants[i].x=a; ants[i].y=b; /*Find if an object is present at that position or not*/ if(board[a][b]==9) { ants[i].carrying=1; /*find the heap at that location*/ position=findObject(a,b); if(position==-1) { printf("\n Error in logic: Ant init \n"); //getchar(); break; } else { /*Assign the heap data to the ant data and decrement the heap count*/ if(flag==1){ for(k=0;k<features;k++)ants[i].data[k]=data[heaps[position].objects[0]][k]; }else{for(k=0;k<features;k++)ants[i].data[k]=heaps[position].Ocenter[k];} for(j=position;j<heapCount-1;j++) heaps[j]=heaps[j+1]; heapCount--; } /*Clear the board position */ board[a][b]=-9; } else ants[i].carrying=-1; ants[i].speed=0; ants[i].dir=lrand48()%8; printf("\n Ant %2d X: %2d Y: %2d Carying : %2d ",i,ants[i].x,ants[i].y,ants[i].carrying); } currentAntCount=loopCount; } /********************************************************************/ /* Function to move the ant */ /* Output: None */ /* Input: Ant to be moved and the flag indicating the iteration */ /********************************************************************/ void moveNext(ant* a,int flag) { int rowCount,colCount; /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; } else { rowCount=heapRow; colCount=heapRow; }*/rowCount=currentRow;colCount=currentRow; /*Depending upon the direction move the ant*/ switch (a->dir) { case 0: a->y++; if(a->y>=colCount)a->y=0; break; case 1: a->x--; a->y++;; if(a->x<0)a->x=rowCount-1; if(a->y>=colCount)a->y=0; break; case 2: a->x--; if(a->x<0)a->x=rowCount-1; break; case 3: a->x--; a->y--; if(a->x<0)a->x=rowCount-1; if(a->y<0)a->y=colCount-1; break; case 4: a->y--; if(a->y<0)a->y=colCount-1; break; case 5: a->x++; a->y--; if(a->x>=rowCount)a->x=0; if(a->y<0)a->y=colCount-1; break; case 6: a->x++; if(a->x>=rowCount) a->x=0; break; case 7: a->x++; a->y++; if(a->x>=rowCount)a->x=0; if(a->y>=colCount)a->y=0; break; } }//end of function /********************************************************************/ /* Function to compute the parameters of the heap */ /* Output: None */ /* Input: The heap whose parameters are to be computed iteration flag*/ /********************************************************************/ void computeHeapParameters(heap* heapData,int flag) { int i=0,j=0,k=0,position=0; float distance=0; float Dmean=0.0; float *dis; float featureSum[features]; float max=0; float sum=0; /* init*/ for(k=0;k<features;k++) featureSum[k]=0; /*Compute the distance of each object and find the maximum distance*/ max=0; if(flag==1){ for(j=0;j<heapData->count;j++) for(i=0;i<heapData->count;i++) { for(k=0;k<features;k++) sum+= (data[heapData->objects[j]][k]-data[heapData->objects[i]][k])*(data[heapData->objects[j]][k]-data[heapData->objects[i]][k]); distance=sqrt(sum); if(max<distance) max=distance; sum=0; } /* Assign the maximum distance to the heap */ heapData->Dmax=max;/*Compute the centre object*/for(i=0;i<heapData->count;i++)for(k=0;k<features;k++) featureSum[k]+=data[heapData->objects[i]][k];for(k=0;k<features;k++)heapData->Ocenter[k]=featureSum[k]*1.0/heapData->count; /* Find the mean distance */if((dis=(float *) calloc(heapData->count,sizeof(float)))==NULL){printf("\nUnable to allocate memory in the compute heap parameters procedure\n");exit(0);} for(i=0;i<heapData->count;i++) { Dmean+=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); dis[i]=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); } heapData->Dmean=Dmean*1.0/heapData->count; /*Compute the most dissimilar object*/ max=dis[0]; for(i=1;i<heapData->count;i++) if(max<dis[i]) { max=dis[i]; position=i; } /*Assign the most dissimilar object to the heap variable*/ for(k=0;k<features;k++) heapData->Odissim[k]=data[heapData->objects[position]][k]; heapData->disPosition=position;free(dis); } else{/* Heap Parameters for the second stage */for(k=0;k<features;k++){ heapData->Odissim[k]=heapData->Ocenter[k];}heapData->disPosition=0;heapData->Dmean=0;heapData->Dmax=0;} }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a single object*/ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject1(ant *a,int position,int flag) { int i,k=0; /*Clear the board*/ board[heaps[position].x][heaps[position].y]=-9; /* Assign the data to the ant*/if(flag==1){ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[0]][k];}else {for(k=0;k<features;k++) a->data[k]=heaps[position].Ocenter[k];} a->carrying=1; /*Copy all the heaps remaining heaps in the structure*/ for(i=position;i<heapCount-1;i++) heaps[i]=heaps[i+1]; /*Decrement the heap count*/ heapCount--; }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a two objects */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject2(ant *a , int position,int flag) { float Pdestroy1=-1; int i=0,k=0; /*Compute the probability to destroy the heap*/ Pdestroy1=lrand48()%13*1.0/12.0; /*If the probability is more than Pdestroy then destroy the heap */ if(Pdestroy1<Pdestroy) { /*pick the object randomly*/ i=lrand48()%2; /* Assign the data to the ant */ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[i]][k]; a->carrying=1; /*Correct the heap parameters*/ heaps[position].count=1; heaps[position].objects[0]=heaps[position].objects[1-i]; computeHeapParameters(&heaps[position],flag); } }//end of function /********************************************************************/ /*Function to pick a object from a heap consisting of more than two object */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /********************************************************************/ void pickObjectn(ant *a,int position,int flag) { int i=0,k=0; /*If the criteria is satsfied then pick the object*/ if((computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)*1.0/heaps[position].Dmean)>Tremove) { a->carrying=1; for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[heaps[position].disPosition]][k]; for(i=heaps[position].disPosition;i<heaps[position].count-1;i++) heaps[position].objects[i]=heaps[position].objects[i+1]; heaps[position].count--; computeHeapParameters(&heaps[position],1); } }//end of function /********************************************************************/ /* Function to pick a object */ /********************************************************************/ void pick(ant *a,int flag) { int position=-1,i=0; float Pload1=-1.0; for(i=0;i<heapCount;i++) { /*Check if a heap is present in the eight neighbouring cells*/ if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if Heap is found*/ if(position!=-1) { /* heap or object found.*/ /*Depending upon the number present in the heap call the corresponding routine*/ switch(heaps[i].count) { case 1: Pload1 = lrand48()%151*1.0/150.0; if(Pload1<Pload) { pickObject1(a,position,flag); } break; case 2: pickObject2(a,position,flag); break; default: pickObjectn(a,position,flag); break; } } } /********************************************************************/ /* Function to drop a object to form a new heap */ /* Output: None */ /* Input: Ant, iteration flag */ /* Global Structure modified : heap, heapCount */ /********************************************************************/ void dropObject(ant* a,int flag) { /*Create a new heap*/ int k=0; heaps[heapCount].count=1; heaps[heapCount].x=a->x; heaps[heapCount].y=a->y; heaps[heapCount].Dmax=0; heaps[heapCount].Dmean=0; heaps[heapCount].disPosition=0; for(k=0;k<features;k++) { heaps[heapCount].Odissim[k]=a->data[k]; heaps[heapCount].Ocenter[k]=a->data[k]; } if(flag==1) {heaps[heapCount].objects[0]=findInData(a->data,flag); /*computeHeapParameters(&heaps[heapCount],flag);*/ } computeHeapParameters(&heaps[heapCount],flag); heapCount++; a->carrying=-1; board[a->x][a->y]=9; }//end of function /********************************************************************/ /* Function to find the heap position during the second iteration */ /* Output: position of the heap */ /* Input: object center of the heap that the ant is carrying */ /* Global Structure modified : none */ /********************************************************************/ int findInNewheaps(irisData object) { int position=-1,i,j=0,flag[features],flg; for(i=0;i<newHeapCount;i++) { for(j=0;j<features;j++) { if(fabs(object[j]-newHeaps[i].Ocenter[j])<0.00001) flag[j]=1; else {flag[j]=0;break;} } flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /*Function to drop a object to a heap consisting of a one or more object */ /* Output: none */ /* Input: Ant, position of the heap , iteration flag */ /* Global Structure modified: heaps,newHeaps */ /********************************************************************/ void dropObject1(ant* a, int position,int flag) { int heapPosition=-1,heapPosition1=-1,i,j,k=0; irisData newData,temp; if(flag==1) { /*Add the object to the heap and compute the heap parameters*/ /*if(heaps[position].count==heaps[position].objCount) {if((junk=(int *)realloc(heaps[position].objects,((heaps[position].objCount+OBJINC)*sizeof(int))))==NULL){printf("\n Cannot Allocate memory to the new object for %d heap",position);exit(0);}heaps[position].objects=junk;heaps[position].objCount+=OBJINC;free(junk); }*/ heaps[position].objects[heaps[position].count]=findInData(a->data,flag); heaps[position].count++; computeHeapParameters(&heaps[position],flag); } else { for(k=0;k<features;k++)temp[k]=heaps[position].Ocenter[k]; heapPosition=findInNewheaps(a->data); heapPosition1=findInNewheaps(heaps[position].Ocenter); if(heapPosition==-1||heapPosition1==-1) { printf("\n error in logic:new heaps\n"); //getchar(); return; } for(k=0;k<features;k++) {newData[k]=(newHeaps[heapPosition].Ocenter[k]*newHeaps[heapPosition].count+newHeaps[heapPosition1].Ocenter[k]*newHeaps[heapPosition1].count)*1.0/(newHeaps[heapPosition].count+newHeaps[heapPosition1].count);newHeaps[heapPosition].Ocenter[k]=newData[k];heaps[position].Ocenter[k]=newData[k]; } computeHeapParameters(&heaps[position],flag); for(i=newHeaps[heapPosition].count,j=0;j<newHeaps[heapPosition1].count;i++,j++) { newHeaps[heapPosition].objects[i]=newHeaps[heapPosition1].objects[j]; } newHeaps[heapPosition].count+=newHeaps[heapPosition1].count; for(i=heapPosition1;i<newHeapCount-1;i++) newHeaps[i]=newHeaps[i+1]; newHeapCount--; } a->carrying=-1; }//end of function /********************************************************************/ /* Function to drop a object */ /* Output: None */ /* Input: Ant, iteration flag */ /********************************************************************/ void drop(ant* a,int flag) { int i, position=-1; float Pdrop1=0.0; /*Find whether we have a heap in the neighbourhood of the cell*/ for(i=0;i<heapCount;i++) { if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if a heap is found*/ if(position!=-1) { /*heap or object found.*/ /*Depending on the number of objects present take action*/ switch(heaps[position].count) { /*If criteria is satisfied then drop the object*/ case 1: if(flag==1) { if((computeDistanceBetween2(a->data,data[heaps[position].objects[0]])*1.0/Dmax)<Tcreate) dropObject1(a,position,flag); } else { if((computeDistanceBetween2(a->data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) dropObject1(a,position,flag); } break; default: if(computeDistanceBetween2(a->data,heaps[position].Ocenter)<computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)) dropObject1(a,position,flag); break; } } else { /*Compute the probability to drop the object*/ Pdrop1 = lrand48()%151*1.0/150; if(Pdrop1<Pdrop) dropObject(a,flag); } }//end of function /********************************************************************/ /* Function to move the ant */ /* Output: none */ /* Input: Ant, iteration flag */ /********************************************************************/ void move(ant* a,int flag) { float pDir; /*Check the speed */ if (a->speed!=0) { /*move in the same direction*/ a->speed--; moveNext(a,flag); } else { /*generate the new direction*/ pDir=lrand48()%17*1.0/16.0; if(pDir<.85) { a->dir=lrand48()%8; } else if(pDir>.95) { a->speed=2; } moveNext(a,flag); } } /********************************************************************/ /* Function to simulate the movement of the ants */ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified: minHeapCount, minHeapPosition */ /********************************************************************/ void iterate(int flag) { int i=0,j=0,k=0,loopCount=0; if (flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS; while (i<MAXITERATIONS) { i++; for(j=0;j<loopCount;j++) { move(&ants[j],flag); if(ants[j].carrying==1) { drop(&ants[j],flag); } else { pick(&ants[j],flag); } } if(debugLevel>0){ for(k=0;k<heapCount;k++) for(j=0;j<heapCount;j++) if((k!=j)&&(heaps[k].x==heaps[j].x)&&(heaps[k].y==heaps[j].y)) { printf("\nerror two heaps with same co ordinates %d %d ",k,j); //getchar(); } k=0; for(j=0;j<heapCount;j++) k+=heaps[j].count; } if(heapCount<minHeapCount) { minHeapCount=heapCount; minPosition=i; } if(debugLevel>0) printf("\n i:%d Heap count %d sum %d",i,heapCount,k); else printf("\n i:%d Heap count %d",i,heapCount); heapSum+=heapCount; /*if(i%updateAfter==0) {adjustBoard(flag); writeIncremental(i,flag);heapSum=0;loopCount=currentAntCount; }*/ } }//end of function /********************************************************************/ /*Function to drop the objects carried by the ants after all the iterations*/ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified:none */ /********************************************************************/ void dropFinal(int flag) { int i=0,j=0,position=-1,loopCount=0; /*if(flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS;*/ loopCount=currentAntCount; for(i=0;i<loopCount;i++) { if(ants[i].carrying==1) { if(flag==1) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position,flag); } } else { /*Find if a heap is present */ do { position=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position,flag); position=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position!=-1); } } } }//end of function /********************************************************************/ /* Function for the implementation of QuickSort */ /* Output: none */ /* Input: data structure, low and high indices */ /* Global structure modified:none */ /********************************************************************/ void quickSort( heap A[], int low,int high ) { int mid=0; if(low<high) { mid=partition(A,low,high); quickSort(A,low,mid); quickSort(A,mid+1,high); } } /********************************************************************/ /* Partition routine used by quick sort */ /* Output: partition location */ /* Input: data , low, high */ /* Global structure modified:none */ /********************************************************************/ int partition(heap a[], int low,int high) { heap temp; int x=0,i=0,j=0; i=low; j=high; x=a[low].count; while (1) { while (a[j].count<x) j=j-1; while (a[i].count>x) i=i+1; if(i<j) { temp=a[i]; a[i]=a[j]; a[j--]=temp; } else return(j); } } /********************************************************************/ /* Function used to write the cluster information */ /* Output: none */ /* Input:iteration flag */ /* Global structure modified:none */ /********************************************************************/ void writeClusterInformation(int flag) { FILE *fp=fopen("center.clt","w"); FILE *fp1; FILE *fp2; FILE *fp3; char temp[80]; int i=0,j=0,k=0; int lastCount=0; int rowCount,colCount,antCount; strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp3=fopen(temp,"a"); if(dataDump) {strcpy(temp,"");sprintf(temp,"%sTot.out",filename);fp1=fopen(temp,"a");strcpy(temp,"");sprintf(temp,"%sObj.out",filename);fp2=fopen(temp,"a");if(fp1==NULL||fp2==NULL)printf("\n Error in opening file in the writer Cluster Information routine\n"); } /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; antCount=MAXANTS; } else { rowCount=heapRow; colCount=heapRow; antCount=MAXANTSFORHEAPS; }*/ rowCount=currentRow; colCount=currentRow; antCount=currentAntCount; if(fp==NULL) { printf("\n Unable to open cluster center output file \n"); /*return;*/ exit(0); } /*sort the array according to the count value and write the value of the top three elements*/ if((flag==1)&&(!EntireHeaps)) quickSort(heaps,0,heapCount); if(EntireHeaps) {if(flag==1) lastCount=heapCount;else lastCount=newHeapCount; } else lastCount=c; for(i=0;i<lastCount;i++) { if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",newHeaps[i].Ocenter[k]); fprintf(fp,"\n"); } else { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); fprintf(fp,"\n"); } } if(dataDump) { fprintf(fp1,"\n Information from the Ant Based Algorithm \n"); fprintf(fp1,"\n Important Parameters : Board %d X %d Ants : %d Iterations %d Total Heaps %d ",rowCount,colCount,antCount,MAXITERATIONS,lastCount); } if(flag==0) { if(dataDump) { fprintf(fp1," TCreateForHeaps %f \n",TcreateForHeaps); fprintf(fp2,"\nTotal Heaps : %d\n",heapCount); fprintf(fp2,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); } fprintf(fp3,"\n@ %d\n",lastCount); } else if(dataDump) fprintf(fp1,"\n");if(dataDump) { fprintf(fp1,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); for(i=0;i<lastCount;i++) if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp2,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); } fprintf(fp1," %5d\n",newHeaps[i].count); fprintf(fp2," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp1," %5d\n",heaps[i].count); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]); fprintf(fp1," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]); fprintf(fp1," %5d\n",heaps[i].count); }} if(flag==0) { if(dataDump) fprintf(fp1,"\n Objects in the heaps \n");for(i=0;i<newHeapCount;i++) { if(dataDump) fprintf(fp1,"\n\n Heap %d\n \n",i+1);fprintf(fp3,"# %d %d\n",i ,newHeaps[i].count); for(j=0;j<newHeaps[i].count;j++){ for(k=0;k<features;k++){ fprintf(fp3,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]); if(dataDump) fprintf(fp1,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]);} if(dataDump) fprintf(fp1,"\n"); fprintf(fp3,"\n"); } } } fclose(fp); fclose(fp3); if(dataDump) { fclose(fp1);fclose(fp2); }}//end of flie /********************************************************************/ /* Function to initialise the new heaps */ /* Output: none */ /* Input:new Heap structure */ /* Global structure modified:none */ /********************************************************************/ void initialiseNewHeaps(heap newHeaps[]) { int i=0,j=0; for(i=0;i<lCount;i++) { newHeaps[i].count=0; for(j=0;j<features;j++) newHeaps[i].Ocenter[j]=V[i][j]; newHeaps[i].x=heaps[i].x; newHeaps[i].y=heaps[i].y; } }//end of function /********************************************************************/ /* Function to initialise the new heaps */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ int findPosition(int i) { int j,position=0; for(j=1;j<lCount;j++) { if(U[j][i]>U[position][i]) position=j; } printf("\n Position %d ",position); return(position); }//end of function find position /********************************************************************/ /* Function to add object */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ void addObject(int object,heap * heapPosition) { heapPosition->objects[heapPosition->count]=object; heapPosition->count++; }//end of function add object /********************************************************************/ /* Function to harden the outputs obtained from fcm */ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/ void harden(heap newHeaps[]) { int i,heapPosition=-1,sum=0,j=0; /*initialise the new heaps*/ initialiseNewHeaps(newHeaps); for(i=0;i<count;i++) { heapPosition=findPosition(i); addObject(i,&newHeaps[heapPosition]); } /* To check for degenerate partitions*/ for(i=0;i<lCount;i++) { if(newHeaps[i].count==0){for(j=i;j<lCount-1;j++){newHeaps[j]=newHeaps[j+1];}lCount--;i--;} } newHeapCount=lCount; for(i=0;i<lCount;i++) computeHeapParameters(&newHeaps[i],1); if(debugLevel>0) { for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\n sum = %d",sum);} }//end of function/********************************************************************/ /* Function to initialize the initial parameters for the ant algorithm*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void init() { int i=0,j=0; for(i=0;i<MAXROWS;i++) for(j=0;j<MAXCOLS;j++) board[i][j]=-9; heapCount=0; newHeapCount=0; heapRow=0; minPosition=-1; minHeapCount=100000; for(i=0;i<MAXANTS;i++) { ants[i].carrying=-1; ants[i].x=-1; ants[i].y=-1; ants[i].speed=-1; ants[i].dir=-1; } } /********************************************************************/ /* Function to initialize the initial board */ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void initialiseBoard() { int i,j; for(i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; }/********************************************************************/ /* Function to harden the outputs obtained from fcm(2nd stage)*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: Cluster center , cluster center count*/ /********************************************************************/void harden1() { int i=0,heapPosition=-1; for(i=0;i<heapCount;i++) cenCount[i]=0; for(i=0;i<n;i++) { heapPosition=findPosition1(i); addObject1(i,heapPosition); } writeInfo(); }//end of function/********************************************************************/ /* Function to find to which class the object belongs */ /* Output: Class number */ /* Input: object position */ /* Global Structure Modified: None */ /********************************************************************/int findPosition1(int i) { int j,position=0; for(j=1;j<heapCount;j++) { if(U[j][i]>U[position][i]) position=j; } return(position); }//end of function find position/********************************************************************/ /* Function to Write the output of the hardened objects to file*/ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/void writeInfo(){int i=0,j=0,k=0;FILE *fp=fopen("fcm.out","a");if(fp==NULL){printf("\n Unable to open fcm output file \n");return;}fprintf(fp,"\n@ %d\n",heapCount);for(i=0;i<heapCount;i++){fprintf(fp,"# %d %d\n",i,cenCount[i]);for(j=0;j<cenCount[i];j++){for(k=0;k<s;k++)fprintf(fp,"%8.2f ",clsCen[i][j][k]/scale[k]+minInput[k]);fprintf(fp,"\n");}}fclose(fp);return;}/********************************************************************/ /* Function to add a object to a cluster (2nd stage) */ /* Output: none */ /* Input: object poistion , cluster position */ /* Global Structure Modified: Cluster object and cluster count*/ /*******************************************************************/void addObject1(int object,int heapPosition) { int k=0; for(k=0;k<features;k++) clsCen[heapPosition][cenCount[heapPosition]][k]=X[object][k]; cenCount[heapPosition]++; return; }//end of function add object/********************************************************************/ /* Function to read the original classification of objects */ /* Output: none */ /* Input: none */ /* Global Structure Modified: None */ /*******************************************************************/void readOrg(){int i=0,k=0;char temp[80];FILE *fp;//= fopen(dataname,"r");strcpy(temp,"");sprintf(temp,"%sFull.data",filename);fp=fopen(temp,"r");if(fp==NULL){printf("\n Unable to open full data input file ");exit(0);}for(i=0;i<n;i++){fscanf(fp,"%f ",&orgData[i][0]);for(k=1;k<s+1;k++)fscanf(fp,"%f ",&orgData[i][k]);}return;}// end of function/********************************************************************/ /* Function to classify the objects in different clusters */ /* Output: none */ /* Input: the cluster objects, the original classification, */ /* number of objects in the cluster,file to write the data */ /* Global Structure Modified: None *//********************************************************************/int analysisData(float data[][s],float orgData[n][s+1],int count,FILE * fp){int i=0,j=0,k=0,type=1,max=0;heapInfo info;for(i=0;i<c;i++){info.classObj[i]=0;}info.total=0;info.total=count;for(i=0;i<count;i++)for(j=0;j<n;j++){type=1;for(k=0;k<s;k++)if(fabs(data[i][k]-orgData[j][k+1])>errThresh){type=-1;break;}if(type!=-1){info.classObj[(int)orgData[j][0]-1]++;break;}}max=0;for(k=0;k<c;k++){if(info.classObj[k]>info.classObj[max])max=k;fprintf(fp,"\nClass %d Objects % d ",k+1,info.classObj[k]);}j=0;for(k=0;k<c;k++){if(k!=max)j+=info.classObj[k];}fprintf(fp,"\n Total errors : %d \n",j);return(j);}//end of analyse/********************************************************************/ /* Function to read the cluster information */ /* Output: none */ /* Input: input file pointer , output file pointer */ /* Global Structure Modified: None *//********************************************************************/void readFCM(FILE* fp,FILE *fp1){int i=0,j=0,k=0,l=0;int totalRuns=0,heapCount=0,junk=0,sum=0;char ch;FILE *fp2=fopen("errors.out","a");ch = 'c'; while (ch != '$') fscanf (fp, "%c", &ch);fscanf(fp,"%d\n",&totalRuns);printf("\n total runs %d ",totalRuns);for(l=0;l<totalRuns;l++){fscanf(fp,"%c",&ch);fscanf(fp,"%d\n",&heapCount);fprintf(fp1,"\n \nExperiment %d \n ",l+1);sum=0;for(i=0;i<heapCount;i++){fscanf(fp,"%c",&ch);fscanf(fp," %d %d\n",&junk,&clsCenCount[i]);for(j=0;j<clsCenCount[i];j++)for(k=0;k<s;k++)fscanf(fp,"%f",&fcmData[i][j][k]);fscanf(fp,"\n");fprintf(fp1,"\n\n Heap %d Total Objects %d \n",i+1,clsCenCount[i]);sum+=analysisData(fcmData[i],orgData,clsCenCount[i],fp1);}fprintf(fp2," %3d %3d %3d \n",l,sum,heapCount);}fprintf(fp2,"\n --------------------------\n");fclose(fp2);return;}//end of function/********************************************************************/ /* Function to update the board parameters */ /* Output: none */ /* Input: none */ /* Global Structure Modified: board size, ant count *//********************************************************************/void adjustBoard(int flag){int newRow=0,newAnt=0,antDiff=0,antsKilled=0,i=0,position[MAXANTS],position1=-1,j=0,k=0,a,b; newRow= (int)ceil(sqrt(4.0*heapSum/updateAfter)); newAnt= (int)ceil((heapSum*1.0/updateAfter)*1.0/3.0); if(newAnt<minAnts)newAnt=minAnts; if(newRow<rowMin)newRow=rowMin;antDiff=currentAntCount-newAnt; if((antDiff>0)&&(newAnt>=minAnts)) {for(i=0;i<currentAntCount;i++){if(ants[i].carrying==-1){position[antsKilled++]=i;}} if(antsKilled>=antDiff){for(i=0;i<antDiff;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1];for(k=i+1;k<antsKilled;k++)position[k]--; } currentAntCount=newAnt; }else {for(i=0;i<antsKilled;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1]; for(k=i+1;k<antsKilled;k++)position[k]--; }if(flag==1) { for(i=currentAntCount-1,k=0;k<antDiff-antsKilled;k++,i--) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position1,flag); }else { dropObject(&ants[i],flag); } } } else { //flag is zero 2nd stage /*Find if a heap is present */ do { position1=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position1].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position1,flag); position1=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position1!=-1); }//end else currentAntCount=newAnt;}//end elsecurrentAntCount=newAnt;}//end iffor(i=0;i<newAnt;i++){if((ants[i].x>=newRow)||(ants[i].y>=newRow)) { a=lrand48()%newRow; b=lrand48()%newRow; ants[i].x=a; ants[i].y=b; }} //Done with ants, now adjust the boardif((currentRow>newRow)&&(newRow>=rowMin)){for(i=0;i<heapCount;i++){if((heaps[i].x>=newRow)||(heaps[i].y>=newRow)) {do { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionheaps[i].x=a;heaps[i].y=b;board[a][b]=9;}//end if}//end for for(i=0;i<currentAntCount;i++){if((ants[i].carrying==1)&&((ants[i].x>=newRow)||(ants[i].y>=newRow))){//adjust the ant locationdo { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionants[i].x=a;ants[i].y=b;}//end if}//end for currentRow=newRow;}//end if }//end of function void writeIncremental(int iteration,int flag){FILE *fp=fopen("dump.txt","w");int i=0,j=0,k=0;fprintf(fp,"Stage %d\n",flag);fprintf(fp,"Board %d\n",currentRow);fprintf(fp,"Ants %d\n",currentAntCount);fprintf(fp,"Iteration %d\n",iteration);fprintf(fp,"Heaps %d\n",heapCount); if(flag==0)fprintf(fp,"NewHeapCount %d\n",newHeapCount); fprintf(fp,"Ants\n");for(i=0;i<currentAntCount;i++){fprintf(fp,"%d %d %d %d %d ",ants[i].x,ants[i].y,ants[i].carrying,ants[i].speed,ants[i].dir);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",ants[i].data[k]);fprintf(fp,"\n");}fprintf(fp,"Heaps\n");for(i=0;i<heapCount;i++){fprintf(fp,"%d %d %d %d %8.2f %8.2f \n",heaps[i].x,heaps[i].y,heaps[i].count,heaps[i].disPosition,heaps[i].Dmax,heaps[i].Dmean);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Ocenter[k]);fprintf(fp,"\n");for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Odissim[k]);fprintf(fp,"\n");if(flag==1){for(j=0;j<heaps[i].count;j++)fprintf(fp,"%d ",heaps[i].objects[j]);fprintf(fp,"\n");}}if(flag==0){fprintf(fp,"newHeaps\n");for(i=0;i<newHeapCount;i++){fprintf(fp,"%d\n",newHeaps[i].count);for(j=0;j<newHeaps[i].count;j++)fprintf(fp,"%d ",newHeaps[i].objects[j]);fprintf(fp,"\n");}}fclose(fp);}//end of function/********************************************************************/ /* Function Main */ /********************************************************************/ int main(int argc ,char** argv) { int sum=0,k=0,i=0,j=0; char temp[80]; FILE *fp=fopen("fcm.out","w"); FILE *fp1; FILE *fp2=fopen("antAnalysis.out","a"); FILE *fp3=fopen("fcmAnalysis.out","a"); FILE *fp4=fopen("errors.out","w"); FILE *fp5; fclose(fp4); sprintf(temp,"%sObj.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sTot.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp1=fopen(temp,"w"); fprintf(fp,"\n$%d",EXPRUN); fprintf(fp1,"\n$%d",EXPRUN); fclose(fp); fclose(fp1); if(argc==2)sscanf(argv[1],"%d",&debugLevel); printf("\n Debug level %d\n",debugLevel); for( i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; //Read from the file readInput(); //Compute the distance of all the points if(maxDist) { Dmax=computeDistance(); //Compute the maximum distance fp5=fopen("maxData.txt","w");fprintf(fp5,"%f",Dmax);fclose(fp5); } else {fp5=fopen("maxData.txt","r");fscanf(fp5,"%f",&Dmax);fclose(fp5); } printf("\n %f \n",Dmax); //Initialise the board for(k=0;k<EXPRUN;k++) { init(); sum=0; srand48(state1[k]); initialiseBoard(); initialise(1); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(1); printf("\n %d \n",heapCount); //Simulate the working of ants iterate(1); //drop the objects after all the iterations dropFinal(1); //to verify the correctness for(i=0;i<heapCount;i++) sum+=heaps[i].count; //write the cluster centers to the file writeClusterInformation(1); printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); //getchar(); //Run FCM // heapCount=2973;/* To be commented */ printf("\n\n k %d \n\n",k); Fcm(data); //compute new board size. lCount=heapCount; heapRow=(int)ceil(sqrt(4*heapCount)); newHeapCount=lCount; printf("\n LCount %d newHeapCount %d heap Row %d \n",lCount,newHeapCount,heapRow); //harden the objects harden(newHeaps); //iterate with the heaps as the objects. initialiseBoard(); initialise(0); for(i=0;i<lCount;i++) computeHeapParameters(&heaps[i],0); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(0); printf("\n %d \n",heapCount); //getchar(); //Simulate the working of ants iterate(0); dropFinal(0); writeClusterInformation(0); sum=0; for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); // getchar(); Fcm(data); harden1(); } fp=fopen("fcm.out","a"); fp1=fopen(temp,"a"); fprintf(fp,"\n"); fprintf(fp1,"\n"); fclose(fp); fclose(fp1); fp=fopen("fcm.out","r"); fp1=fopen(temp,"r");printf("\n Before read org\n");readOrg();printf("\nafter read org\n");readFCM(fp1,fp2);printf("\n After 1st read fcm\n");readFCM(fp,fp3);printf("\n After 2 fcm read \n");return(1); }//end of main /****************************************************************/ float NORM(feature , feature); void find_covar(); void Fcm (irisData Data[MAXDATA]) { int i,j,l; FILE *ofile; char temp[80]; int flag=0;//added by parag FILE *iniClsCen=fopen("center.clt","a+"); if(iniClsCen==NULL) { printf("\n Unable to open the initial cluster center file\n"); printf("\n choosing random cluster centers....\n"); flag=1; } strcpy(temp,""); sprintf(temp,"%s.data",filename); strcpy (fname,temp); /* Read from this file */ m=2.0; /* The exponent */ /*GET_INPUTS1(fname);*/ /* read in feature vectors */ for (j=0; j<n ; j++) /* Read File in row-major */ for (i=0; i<s ; i++) /* format */ X[j][i]=Data[j][i]; Random_seed=state1[run];/*randseed*/ srand48(Random_seed); for (run=0;run<TOTRUNS;run++) { //flag=1;//for testing random values if (EntireHeaps) lCount=heapCount; else lCount=c; for(i=0;i<lCount;i++) for(j=0;j<s;j++) V[i][j]=0; for(i=0;i<lCount;i++) { for(l=0;l<s;l++) { if(flag==1) { rand_index = lrand48() % n; V[i][l] = X[rand_index][l]; } else { fscanf(iniClsCen,"%f ",&V[i][l]); } }//end for } eps=0.001; stop = FALSE; /* This loop finds the final cluster center and the corresponding U values */ z = 0; while (stop == FALSE) { z++; UMAT(U,V,X); /** Update the U matrix **/ stop = FINISHED(U1,eps); CLUSTER(U,X); /** Get new cluster center **/ printf("Iteration: %d\n\n", z); } /* end while */ printf("Number of iterations: %d\n\n", z);strcpy(temp,""); sprintf(temp,"%sFCM.out",filename);if(dataDump) Output(temp); /* output the results */ }/*end for*/ if(dataDump) { ofile=fopen(temp,"a"); for (i=0; i <= mins; i++) fprintf(ofile, "Min %d of %10.3f occurred %d times\n", i, mintab[i], mincount[i]); fprintf(ofile, "Average iterations %f\n", (float)aveit/(float)TOTRUNS); fclose(ofile); } }/* end Main */ /* The GET_INPUTS1 procedure opens an input file, reads the number of input vectors, the number of features per vector, the number of clusters, and epsilon, then it reads the input values */ void GET_INPUTS1(char fname[]) //char fname[]; { /* Parameters: fname -- name of file containing input info. */ FILE *infile ;//*fopen(); //char junk[10][80]; char realfname[80]; char ch; char fileName1[80]; //int temp[10], i, j, inputs, outputs, count; int i,j; sprintf (realfname, "%s", fname); /* open input file */ if(normalize==1) strcpy(fileName1,"gtest1.data"); else strcpy(fileName1,fname); if((infile = fopen (fileName1, "r")) == NULL) printf("\n CAN'T OPEN %s\n",realfname); else { ch = 'c'; /* Discard leading comments */ while (ch != '#') fscanf (infile, "%c", &ch); for (j=0; j<n ; j++) /* Read File in row-major */ { /* format */ for (i=0; i<s ; i++) fscanf (infile, "%f", &X[j][i]); /* fscanf (infile, "%d", &temp[1]); */ /* end for */ } /* end for */ fclose(infile); /* close input file */ }/* end else */ } /* end GET_INPUTS1 */ /* The NORM function computes the norm of two vectors, x and v, of dimension s. This gives an indication of the distance between them */ float NORM( feature x, feature v) //feature x, v; { /* Parameters : x -- a local copy of an input vector v -- a local copy of a cluster center */ int i,j; /* loop variable */ double sum; /* the square root of sum is the norm; sum is the sum of the differences squared */ float mat1[s]; float mat2[s]; if (maha) { for (i=0; i<s; i++) mat1[i]=x[i]-v[i]; for(i=0;i<s;i++) { sum =0; for(j=0;j<s;j++) sum += mat1[j] * inv_cov[j][i]; mat2[i] = sum; } sum =0; for(j=0;j<s;j++) sum += mat1[j]*mat2[j]; } else { sum = 0; for(j=0;j<s;j++) sum += (x[j] - v[j])* (x[j] - v[j]); } return (float)(sqrt(sum)); } /* end NORM */ /* The UMAT procedure calculates the updated U matrix according to Bezdek's formula. Its side-effect is the update of the global array U1 */ void UMAT( matrix U,center V, objects X) /*matrix U; center V; objects X;*/ { /* Parameters: U, V, and X: same as in main program */ int i, j, k,l ;/* loop variables *///, class /* class whose cluster center //is closest to pattern k */; float d1,d2,d; float sum; int exact; for (k=0;k<n;k++) { /*printf("\n k %d ",k);*/ exact=false; for (i=0;i<lCount;i++) { sum=0; for (j=0;j<lCount;j++) { d1=NORM(X[k],V[i]); d2=NORM(X[k],V[j]); if(d2!=0) { d= d1/d2; d= d * d;/* pow(d1/d2,2.0/(m-1.0)); */ sum+=d; } else { exact = true; for(l=0;l<lCount;l++) if (l==j) U1[l][k]=1.0; else U1[l][k]=0.0; break; } } if (exact!=true) U1[i][k]=1.0/sum; } } } /* end UMAT */ /* The function FINISHED determines if a termination occurs. If not it updates U with U1, so its side-effect is the potential modification of U */ BOOLEAN FINISHED( matrix U1,float eps) //matrix U1; float eps; { /* Parameters: U1, eps-- same as in main */ float sum; /* sum of squared differences between corresponding elements of U and U1 */ int i,k; /* loop control variabes */ BOOLEAN finished; /* set to true if all corresponding elements are within epsilon */ finished = TRUE; sum = 0; for (i=0; i<lCount; i++) for (k=0; k<n; k++) sum += (U[i][k] - U1[i][k])*(U[i][k]-U1[i][k]); if (sqrt(sum) > eps) { finished = FALSE; for (i=0; i<lCount; i++) for (k=0; k<n; k++) U[i][k] = U1[i][k]; } /* end if */ return finished; } /* end FINISHED */ /* The CLUSTER procedure determines cluster centers in V for the c classes being searched for. The global array V is updated */ void CLUSTER( matrix U, objects X) //matrix U; objects X; { /* Parameters: U, X -- as in main */ int i, j, k; /* loop control variables */ feature num; /* numerator in the cluster center computation formula presented by Bezdek */ float denum; /* denumenator in the obove formula */ for (i=0; i<lCount; i++) { denum = 0; for (j=0; j<s; j++) { num[j] = 0; for (k=0; k<n; k++) num[j] += U[i][k] * U[i][k] * X[k][j]; /* pow(U[i][k],m) * X[k][j]; */ } /* end for */ for (k=0; k<n; k++) denum += U[i][k] * U[i][k]; /* pow(U[i][k],m); */ for (j=0; j<s; j++) V[i][j] = num[j] / denum; } /* end for */ } /* end CLUSTER */ float Compute_Jm(center V, objects X) //center V; //objects X; { int i, k,found; double Jm_value; float u,dik; Jm_value = 0; for (k=0; k<n; k++) { found = FALSE; for (i=0; i<lCount; i++) { dik=NORM(X[k],V[i]); dik=dik*dik; if (dik==0.0) { if (found == FALSE) { u=1.0; found = TRUE; printf("found the case with dik=0\n"); } else { printf("\n cant proceed with this initialization"); exit(1); } } else { if (found != TRUE) u=U1[i][k]; /* get_Uvalue(V,X,dik,k); */ else u=0.0; } Jm_value += u * u * dik;/* pow(u, m) * dik; */ } } return (Jm_value); } /* end Compute_Jm */ /* The Output procedure outputs the U matrix which gives the fuzzy measure of each feature belonging to a cluster center. It also outputs the cluster center for each class */ void Output(char fname[]) //char fname[80]; /* Parameters: U, V -- same as in main */ { int i, j, found; /* loop control variables */ float J2c; if ((fp=fopen(fname,"a"))==NULL) printf("\n CAN'T OPEN %s\n",fname); else { fprintf(fp,"\n The cluster centers are: \n"); fprintf(fp,"\n \n"); for (i=0; i<lCount; i++) { fprintf(fp,"\nCluster center %d: ",i+1); fprintf(fp,"\n"); for (j=0; j<s; j++) fprintf(fp,"%8.7f ",V[i][j]); } /* end for */ fprintf(fp,"\nThe membership grades for the feature vectors are:\n"); for (j=0; j<n; j++) { fprintf(fp,"\n"); for (i=0; i<lCount; i++) fprintf(fp," %8.7f",U[i][j]); } /* end for */ } /* end if */ J2c= Compute_Jm(V,X); found =0; for (i=0;i<= mins; i++){ if ((found == 0) && ((J2c - mintab[i]) < .001) && ((J2c - mintab[i]) > -.001)){ mincount[i]++; found = 1; } } if (found == 0){ mins++; mintab[mins]=J2c; mincount[mins]=1; } fprintf(fp,"\nJ%3.1f = %f", m,J2c); fprintf(fp, "Number of iterations: %d\n\n", z); aveit=aveit + z; fclose(fp); } /***************************************************************/ void find_covar(int m) //int m; { int i,j,k; float mean[s],sum; for (i=0;i<s;i++) mean[i]=0; for (i=0;i<s;i++) for (j=0;j<m;j++) mean[i]+=X[j][i]; for (i=0;i<s;i++) mean[i]/=m; for (i=0;i<s;i++) for (j=0;j<s;j++) { sum=0; for (k=0;k<m;k++) sum+=(X[k][i]-mean[i])*(X[k][j]-mean[j]); Y[i][j]=sum/m; } }
Parag Kanade/fuzzy ants/wine/maxData.txt
6.282280
Parag Kanade/fuzzy ants/wine/headerStatic.h
/********************************************************************//* Ant Class parameters *//* SPEED # amplitude of moves [1,10] *//* P direction Probability to move in the same direction [.5,1] *//* Max carry : Maximum object carrying time [20,200] *//* P load Probability to pick up a single object [0.4,0.8] *//* P destroy probability to destroy a heap of two objects [0,0.6] *//* T remove min. dissimilarity necessary for removing an object *//* from a heap [.1,.2] *//* T create max dissimilarity permitted for creating a heap[.05,.2]*//********************************************************************/ #include <stdio.h>#include <math.h>#include <string.h>#include<stdlib.h>#include <ctype.h>#include <time.h>#define MAXANTS 59#define MAXDATA 178#define MAXANTSFORHEAPS 15#define MAXITERATIONS 3000#define MAXROWS 30#define MAXCOLS 30#define EXPRUN 50#define Tremove 3.0#define Tcreate 1.5#define Pdrop 0.2#define Pdestroy 0.3#define Pload 0.3#define normalize 0#define EntireHeaps 1#define TcreateForHeaps 0.09#define features 13#define filename "wine"#define errThresh 0.1#define dataDump 1#define maxDist 0#define INITIALOBJECTS 75#define OBJINC 10/* some type definitions to make C code a little more readable */#define TRUE 1#define FALSE 0#define n MAXDATA /* number of input vectors */#define s features /* number of features */#define c 3 /* number of clusters */#define TOTRUNS 1 /* number of V's to write out */#define false 0#define true 1#define maha 0#define square 0extern int count;int debugLevel=0;/* To debug the code and verify the correctness of algorithms*/int currHeapCount=0;typedef int BOOLEAN;typedef short TYPE_IN_DATA; /* Type of input binary data */typedef float feature[s]; /* Type of each input; made up of input features */typedef float irisData[s];typedef feature objects[MAXDATA]; /* Type of array holding all inputs */typedef feature center[MAXDATA]; /* Type of array holding cluster centers */typedef float matrix[MAXDATA][MAXDATA];/* Type of the matrix containing membership grades */typedef struct Heap {float Dmax;//maximum dissimilar distanceirisData Ocenter;//center objectfloat Dmean;//mean of the distance between the center and all the objectsirisData Odissim;//most dissimilar objectint x;//x position on the boardint y;//y position on the boardint count;//number of objects in the heapsint disPosition;//most dissimilar objectint objects[MAXDATA];int objCount;}heap;typedef struct Ant{int x;int y;int carrying;int speed;int dir;irisData data;}ant;float orgData[n][s+1];float fcmData[260][n][s];int clsCenCount[260];int currentRow=0;int currentAntCount=0;int updateAfter=50;int heapSum=0;int minAnts=3;int rowMin=5;typedef struct HeapInfo{int total;int classObj[c];} heapInfo;/*heapInfo info[MAXDATA];*//********************************************************************//***Function decelarations*//********************************************************************//***For ant based algorithm*/void readInput();float computeDistance();float computeDistanceBetween2(irisData a,irisData b);float findMax(float *distance);float value(irisData a);int found(int a , int b);void initialise(int flag);int findObject(int a,int b);void initialiseAnts(int flag);void moveNext(ant* a,int flag);void computeHeapParameters(heap* data,int flag);void pickObject1(ant *a,int position,int flag);void pickObject2(ant *a , int position,int flag);void pickObjectn(ant *a,int position,int flag);void pick(ant *a,int flag);void dropObject(ant* a,int flag);int findInNewheaps(irisData object);void dropObject1(ant* a, int position,int flag);void drop(ant* a,int flag);void move(ant* a,int flag);void iterate(int flag);void dropFinal(int flag);int partition(heap a[], int low,int high);void quickSort( heap A[], int low,int high ) ;void writeClusterInformation(int flag);void initialiseNewHeaps(heap newHeaps[]);int findPosition(int i);void harden(heap newHeaps[]);void harden1();int findPosition1(int );void writeInfo();void addObject1(int ,int);void readFCM(FILE *,FILE *);void readOrg();int findInData(irisData input,int iflag);void adjustBoard(int flag);void writeIncremental(int iteration,int flag);/********************************************************************//***For FCM algorithm*/void GET_INPUTS1(char []);void UMAT( matrix,center,objects);BOOLEAN FINISHED(matrix, float);void CLUSTER( matrix, objects);void Output(char[]);void Fcm(irisData data[]);/********************************************************************/
Parag Kanade/fuzzy ants/wine/wineFull.data
1 | 14.23 | 1.71 | 2.43 | 15.6 | 127 | 2.8 | 3.06 | 0.28 | 2.29 | 5.64 | 1.04 | 3.92 | 1065 |
1 | 13.2 | 1.78 | 2.14 | 11.2 | 100 | 2.65 | 2.76 | 0.26 | 1.28 | 4.38 | 1.05 | 3.4 | 1050 |
1 | 13.16 | 2.36 | 2.67 | 18.6 | 101 | 2.8 | 3.24 | 0.3 | 2.81 | 5.68 | 1.03 | 3.17 | 1185 |
1 | 14.37 | 1.95 | 2.5 | 16.8 | 113 | 3.85 | 3.49 | 0.24 | 2.18 | 7.8 | 0.86 | 3.45 | 1480 |
1 | 13.24 | 2.59 | 2.87 | 21 | 118 | 2.8 | 2.69 | 0.39 | 1.82 | 4.32 | 1.04 | 2.93 | 735 |
1 | 14.2 | 1.76 | 2.45 | 15.2 | 112 | 3.27 | 3.39 | 0.34 | 1.97 | 6.75 | 1.05 | 2.85 | 1450 |
1 | 14.39 | 1.87 | 2.45 | 14.6 | 96 | 2.5 | 2.52 | 0.3 | 1.98 | 5.25 | 1.02 | 3.58 | 1290 |
1 | 14.06 | 2.15 | 2.61 | 17.6 | 121 | 2.6 | 2.51 | 0.31 | 1.25 | 5.05 | 1.06 | 3.58 | 1295 |
1 | 14.83 | 1.64 | 2.17 | 14 | 97 | 2.8 | 2.98 | 0.29 | 1.98 | 5.2 | 1.08 | 2.85 | 1045 |
1 | 13.86 | 1.35 | 2.27 | 16 | 98 | 2.98 | 3.15 | 0.22 | 1.85 | 7.22 | 1.01 | 3.55 | 1045 |
1 | 14.1 | 2.16 | 2.3 | 18 | 105 | 2.95 | 3.32 | 0.22 | 2.38 | 5.75 | 1.25 | 3.17 | 1510 |
1 | 14.12 | 1.48 | 2.32 | 16.8 | 95 | 2.2 | 2.43 | 0.26 | 1.57 | 5 | 1.17 | 2.82 | 1280 |
1 | 13.75 | 1.73 | 2.41 | 16 | 89 | 2.6 | 2.76 | 0.29 | 1.81 | 5.6 | 1.15 | 2.9 | 1320 |
1 | 14.75 | 1.73 | 2.39 | 11.4 | 91 | 3.1 | 3.69 | 0.43 | 2.81 | 5.4 | 1.25 | 2.73 | 1150 |
1 | 14.38 | 1.87 | 2.38 | 12 | 102 | 3.3 | 3.64 | 0.29 | 2.96 | 7.5 | 1.2 | 3 | 1547 |
1 | 13.63 | 1.81 | 2.7 | 17.2 | 112 | 2.85 | 2.91 | 0.3 | 1.46 | 7.3 | 1.28 | 2.88 | 1310 |
1 | 14.3 | 1.92 | 2.72 | 20 | 120 | 2.8 | 3.14 | 0.33 | 1.97 | 6.2 | 1.07 | 2.65 | 1280 |
1 | 13.83 | 1.57 | 2.62 | 20 | 115 | 2.95 | 3.4 | 0.4 | 1.72 | 6.6 | 1.13 | 2.57 | 1130 |
1 | 14.19 | 1.59 | 2.48 | 16.5 | 108 | 3.3 | 3.93 | 0.32 | 1.86 | 8.7 | 1.23 | 2.82 | 1680 |
1 | 13.64 | 3.1 | 2.56 | 15.2 | 116 | 2.7 | 3.03 | 0.17 | 1.66 | 5.1 | 0.96 | 3.36 | 845 |
1 | 14.06 | 1.63 | 2.28 | 16 | 126 | 3 | 3.17 | 0.24 | 2.1 | 5.65 | 1.09 | 3.71 | 780 |
1 | 12.93 | 3.8 | 2.65 | 18.6 | 102 | 2.41 | 2.41 | 0.25 | 1.98 | 4.5 | 1.03 | 3.52 | 770 |
1 | 13.71 | 1.86 | 2.36 | 16.6 | 101 | 2.61 | 2.88 | 0.27 | 1.69 | 3.8 | 1.11 | 4 | 1035 |
1 | 12.85 | 1.6 | 2.52 | 17.8 | 95 | 2.48 | 2.37 | 0.26 | 1.46 | 3.93 | 1.09 | 3.63 | 1015 |
1 | 13.5 | 1.81 | 2.61 | 20 | 96 | 2.53 | 2.61 | 0.28 | 1.66 | 3.52 | 1.12 | 3.82 | 845 |
1 | 13.05 | 2.05 | 3.22 | 25 | 124 | 2.63 | 2.68 | 0.47 | 1.92 | 3.58 | 1.13 | 3.2 | 830 |
1 | 13.39 | 1.77 | 2.62 | 16.1 | 93 | 2.85 | 2.94 | 0.34 | 1.45 | 4.8 | 0.92 | 3.22 | 1195 |
1 | 13.3 | 1.72 | 2.14 | 17 | 94 | 2.4 | 2.19 | 0.27 | 1.35 | 3.95 | 1.02 | 2.77 | 1285 |
1 | 13.87 | 1.9 | 2.8 | 19.4 | 107 | 2.95 | 2.97 | 0.37 | 1.76 | 4.5 | 1.25 | 3.4 | 915 |
1 | 14.02 | 1.68 | 2.21 | 16 | 96 | 2.65 | 2.33 | 0.26 | 1.98 | 4.7 | 1.04 | 3.59 | 1035 |
1 | 13.73 | 1.5 | 2.7 | 22.5 | 101 | 3 | 3.25 | 0.29 | 2.38 | 5.7 | 1.19 | 2.71 | 1285 |
1 | 13.58 | 1.66 | 2.36 | 19.1 | 106 | 2.86 | 3.19 | 0.22 | 1.95 | 6.9 | 1.09 | 2.88 | 1515 |
1 | 13.68 | 1.83 | 2.36 | 17.2 | 104 | 2.42 | 2.69 | 0.42 | 1.97 | 3.84 | 1.23 | 2.87 | 990 |
1 | 13.76 | 1.53 | 2.7 | 19.5 | 132 | 2.95 | 2.74 | 0.5 | 1.35 | 5.4 | 1.25 | 3 | 1235 |
1 | 13.51 | 1.8 | 2.65 | 19 | 110 | 2.35 | 2.53 | 0.29 | 1.54 | 4.2 | 1.1 | 2.87 | 1095 |
1 | 13.48 | 1.81 | 2.41 | 20.5 | 100 | 2.7 | 2.98 | 0.26 | 1.86 | 5.1 | 1.04 | 3.47 | 920 |
1 | 13.28 | 1.64 | 2.84 | 15.5 | 110 | 2.6 | 2.68 | 0.34 | 1.36 | 4.6 | 1.09 | 2.78 | 880 |
1 | 13.05 | 1.65 | 2.55 | 18 | 98 | 2.45 | 2.43 | 0.29 | 1.44 | 4.25 | 1.12 | 2.51 | 1105 |
1 | 13.07 | 1.5 | 2.1 | 15.5 | 98 | 2.4 | 2.64 | 0.28 | 1.37 | 3.7 | 1.18 | 2.69 | 1020 |
1 | 14.22 | 3.99 | 2.51 | 13.2 | 128 | 3 | 3.04 | 0.2 | 2.08 | 5.1 | 0.89 | 3.53 | 760 |
1 | 13.56 | 1.71 | 2.31 | 16.2 | 117 | 3.15 | 3.29 | 0.34 | 2.34 | 6.13 | 0.95 | 3.38 | 795 |
1 | 13.41 | 3.84 | 2.12 | 18.8 | 90 | 2.45 | 2.68 | 0.27 | 1.48 | 4.28 | 0.91 | 3 | 1035 |
1 | 13.88 | 1.89 | 2.59 | 15 | 101 | 3.25 | 3.56 | 0.17 | 1.7 | 5.43 | 0.88 | 3.56 | 1095 |
1 | 13.24 | 3.98 | 2.29 | 17.5 | 103 | 2.64 | 2.63 | 0.32 | 1.66 | 4.36 | 0.82 | 3 | 680 |
1 | 13.05 | 1.77 | 2.1 | 17 | 107 | 3 | 3 | 0.28 | 2.03 | 5.04 | 0.88 | 3.35 | 885 |
1 | 14.21 | 4.04 | 2.44 | 18.9 | 111 | 2.85 | 2.65 | 0.3 | 1.25 | 5.24 | 0.87 | 3.33 | 1080 |
1 | 14.38 | 3.59 | 2.28 | 16 | 102 | 3.25 | 3.17 | 0.27 | 2.19 | 4.9 | 1.04 | 3.44 | 1065 |
1 | 13.9 | 1.68 | 2.12 | 16 | 101 | 3.1 | 3.39 | 0.21 | 2.14 | 6.1 | 0.91 | 3.33 | 985 |
1 | 14.1 | 2.02 | 2.4 | 18.8 | 103 | 2.75 | 2.92 | 0.32 | 2.38 | 6.2 | 1.07 | 2.75 | 1060 |
1 | 13.94 | 1.73 | 2.27 | 17.4 | 108 | 2.88 | 3.54 | 0.32 | 2.08 | 8.9 | 1.12 | 3.1 | 1260 |
1 | 13.05 | 1.73 | 2.04 | 12.4 | 92 | 2.72 | 3.27 | 0.17 | 2.91 | 7.2 | 1.12 | 2.91 | 1150 |
1 | 13.83 | 1.65 | 2.6 | 17.2 | 94 | 2.45 | 2.99 | 0.22 | 2.29 | 5.6 | 1.24 | 3.37 | 1265 |
1 | 13.82 | 1.75 | 2.42 | 14 | 111 | 3.88 | 3.74 | 0.32 | 1.87 | 7.05 | 1.01 | 3.26 | 1190 |
1 | 13.77 | 1.9 | 2.68 | 17.1 | 115 | 3 | 2.79 | 0.39 | 1.68 | 6.3 | 1.13 | 2.93 | 1375 |
1 | 13.74 | 1.67 | 2.25 | 16.4 | 118 | 2.6 | 2.9 | 0.21 | 1.62 | 5.85 | 0.92 | 3.2 | 1060 |
1 | 13.56 | 1.73 | 2.46 | 20.5 | 116 | 2.96 | 2.78 | 0.2 | 2.45 | 6.25 | 0.98 | 3.03 | 1120 |
1 | 14.22 | 1.7 | 2.3 | 16.3 | 118 | 3.2 | 3 | 0.26 | 2.03 | 6.38 | 0.94 | 3.31 | 970 |
1 | 13.29 | 1.97 | 2.68 | 16.8 | 102 | 3 | 3.23 | 0.31 | 1.66 | 6 | 1.07 | 2.84 | 1270 |
1 | 13.72 | 1.43 | 2.5 | 16.7 | 108 | 3.4 | 3.67 | 0.19 | 2.04 | 6.8 | 0.89 | 2.87 | 1285 |
2 | 12.37 | 0.94 | 1.36 | 10.6 | 88 | 1.98 | 0.57 | 0.28 | 0.42 | 1.95 | 1.05 | 1.82 | 520 |
2 | 12.33 | 1.1 | 2.28 | 16 | 101 | 2.05 | 1.09 | 0.63 | 0.41 | 3.27 | 1.25 | 1.67 | 680 |
2 | 12.64 | 1.36 | 2.02 | 16.8 | 100 | 2.02 | 1.41 | 0.53 | 0.62 | 5.75 | 0.98 | 1.59 | 450 |
2 | 13.67 | 1.25 | 1.92 | 18 | 94 | 2.1 | 1.79 | 0.32 | 0.73 | 3.8 | 1.23 | 2.46 | 630 |
2 | 12.37 | 1.13 | 2.16 | 19 | 87 | 3.5 | 3.1 | 0.19 | 1.87 | 4.45 | 1.22 | 2.87 | 420 |
2 | 12.17 | 1.45 | 2.53 | 19 | 104 | 1.89 | 1.75 | 0.45 | 1.03 | 2.95 | 1.45 | 2.23 | 355 |
2 | 12.37 | 1.21 | 2.56 | 18.1 | 98 | 2.42 | 2.65 | 0.37 | 2.08 | 4.6 | 1.19 | 2.3 | 678 |
2 | 13.11 | 1.01 | 1.7 | 15 | 78 | 2.98 | 3.18 | 0.26 | 2.28 | 5.3 | 1.12 | 3.18 | 502 |
2 | 12.37 | 1.17 | 1.92 | 19.6 | 78 | 2.11 | 2 | 0.27 | 1.04 | 4.68 | 1.12 | 3.48 | 510 |
2 | 13.34 | 0.94 | 2.36 | 17 | 110 | 2.53 | 1.3 | 0.55 | 0.42 | 3.17 | 1.02 | 1.93 | 750 |
2 | 12.21 | 1.19 | 1.75 | 16.8 | 151 | 1.85 | 1.28 | 0.14 | 2.5 | 2.85 | 1.28 | 3.07 | 718 |
2 | 12.29 | 1.61 | 2.21 | 20.4 | 103 | 1.1 | 1.02 | 0.37 | 1.46 | 3.05 | 0.906 | 1.82 | 870 |
2 | 13.86 | 1.51 | 2.67 | 25 | 86 | 2.95 | 2.86 | 0.21 | 1.87 | 3.38 | 1.36 | 3.16 | 410 |
2 | 13.49 | 1.66 | 2.24 | 24 | 87 | 1.88 | 1.84 | 0.27 | 1.03 | 3.74 | 0.98 | 2.78 | 472 |
2 | 12.99 | 1.67 | 2.6 | 30 | 139 | 3.3 | 2.89 | 0.21 | 1.96 | 3.35 | 1.31 | 3.5 | 985 |
2 | 11.96 | 1.09 | 2.3 | 21 | 101 | 3.38 | 2.14 | 0.13 | 1.65 | 3.21 | 0.99 | 3.13 | 886 |
2 | 11.66 | 1.88 | 1.92 | 16 | 97 | 1.61 | 1.57 | 0.34 | 1.15 | 3.8 | 1.23 | 2.14 | 428 |
2 | 13.03 | 0.9 | 1.71 | 16 | 86 | 1.95 | 2.03 | 0.24 | 1.46 | 4.6 | 1.19 | 2.48 | 392 |
2 | 11.84 | 2.89 | 2.23 | 18 | 112 | 1.72 | 1.32 | 0.43 | 0.95 | 2.65 | 0.96 | 2.52 | 500 |
2 | 12.33 | 0.99 | 1.95 | 14.8 | 136 | 1.9 | 1.85 | 0.35 | 2.76 | 3.4 | 1.06 | 2.31 | 750 |
2 | 12.7 | 3.87 | 2.4 | 23 | 101 | 2.83 | 2.55 | 0.43 | 1.95 | 2.57 | 1.19 | 3.13 | 463 |
2 | 12 | 0.92 | 2 | 19 | 86 | 2.42 | 2.26 | 0.3 | 1.43 | 2.5 | 1.38 | 3.12 | 278 |
2 | 12.72 | 1.81 | 2.2 | 18.8 | 86 | 2.2 | 2.53 | 0.26 | 1.77 | 3.9 | 1.16 | 3.14 | 714 |
2 | 12.08 | 1.13 | 2.51 | 24 | 78 | 2 | 1.58 | 0.4 | 1.4 | 2.2 | 1.31 | 2.72 | 630 |
2 | 13.05 | 3.86 | 2.32 | 22.5 | 85 | 1.65 | 1.59 | 0.61 | 1.62 | 4.8 | 0.84 | 2.01 | 515 |
2 | 11.84 | 0.89 | 2.58 | 18 | 94 | 2.2 | 2.21 | 0.22 | 2.35 | 3.05 | 0.79 | 3.08 | 520 |
2 | 12.67 | 0.98 | 2.24 | 18 | 99 | 2.2 | 1.94 | 0.3 | 1.46 | 2.62 | 1.23 | 3.16 | 450 |
2 | 12.16 | 1.61 | 2.31 | 22.8 | 90 | 1.78 | 1.69 | 0.43 | 1.56 | 2.45 | 1.33 | 2.26 | 495 |
2 | 11.65 | 1.67 | 2.62 | 26 | 88 | 1.92 | 1.61 | 0.4 | 1.34 | 2.6 | 1.36 | 3.21 | 562 |
2 | 11.64 | 2.06 | 2.46 | 21.6 | 84 | 1.95 | 1.69 | 0.48 | 1.35 | 2.8 | 1 | 2.75 | 680 |
2 | 12.08 | 1.33 | 2.3 | 23.6 | 70 | 2.2 | 1.59 | 0.42 | 1.38 | 1.74 | 1.07 | 3.21 | 625 |
2 | 12.08 | 1.83 | 2.32 | 18.5 | 81 | 1.6 | 1.5 | 0.52 | 1.64 | 2.4 | 1.08 | 2.27 | 480 |
2 | 12 | 1.51 | 2.42 | 22 | 86 | 1.45 | 1.25 | 0.5 | 1.63 | 3.6 | 1.05 | 2.65 | 450 |
2 | 12.69 | 1.53 | 2.26 | 20.7 | 80 | 1.38 | 1.46 | 0.58 | 1.62 | 3.05 | 0.96 | 2.06 | 495 |
2 | 12.29 | 2.83 | 2.22 | 18 | 88 | 2.45 | 2.25 | 0.25 | 1.99 | 2.15 | 1.15 | 3.3 | 290 |
2 | 11.62 | 1.99 | 2.28 | 18 | 98 | 3.02 | 2.26 | 0.17 | 1.35 | 3.25 | 1.16 | 2.96 | 345 |
2 | 12.47 | 1.52 | 2.2 | 19 | 162 | 2.5 | 2.27 | 0.32 | 3.28 | 2.6 | 1.16 | 2.63 | 937 |
2 | 11.81 | 2.12 | 2.74 | 21.5 | 134 | 1.6 | 0.99 | 0.14 | 1.56 | 2.5 | 0.95 | 2.26 | 625 |
2 | 12.29 | 1.41 | 1.98 | 16 | 85 | 2.55 | 2.5 | 0.29 | 1.77 | 2.9 | 1.23 | 2.74 | 428 |
2 | 12.37 | 1.07 | 2.1 | 18.5 | 88 | 3.52 | 3.75 | 0.24 | 1.95 | 4.5 | 1.04 | 2.77 | 660 |
2 | 12.29 | 3.17 | 2.21 | 18 | 88 | 2.85 | 2.99 | 0.45 | 2.81 | 2.3 | 1.42 | 2.83 | 406 |
2 | 12.08 | 2.08 | 1.7 | 17.5 | 97 | 2.23 | 2.17 | 0.26 | 1.4 | 3.3 | 1.27 | 2.96 | 710 |
2 | 12.6 | 1.34 | 1.9 | 18.5 | 88 | 1.45 | 1.36 | 0.29 | 1.35 | 2.45 | 1.04 | 2.77 | 562 |
2 | 12.34 | 2.45 | 2.46 | 21 | 98 | 2.56 | 2.11 | 0.34 | 1.31 | 2.8 | 0.8 | 3.38 | 438 |
2 | 11.82 | 1.72 | 1.88 | 19.5 | 86 | 2.5 | 1.64 | 0.37 | 1.42 | 2.06 | 0.94 | 2.44 | 415 |
2 | 12.51 | 1.73 | 1.98 | 20.5 | 85 | 2.2 | 1.92 | 0.32 | 1.48 | 2.94 | 1.04 | 3.57 | 672 |
2 | 12.42 | 2.55 | 2.27 | 22 | 90 | 1.68 | 1.84 | 0.66 | 1.42 | 2.7 | 0.86 | 3.3 | 315 |
2 | 12.25 | 1.73 | 2.12 | 19 | 80 | 1.65 | 2.03 | 0.37 | 1.63 | 3.4 | 1 | 3.17 | 510 |
2 | 12.72 | 1.75 | 2.28 | 22.5 | 84 | 1.38 | 1.76 | 0.48 | 1.63 | 3.3 | 0.88 | 2.42 | 488 |
2 | 12.22 | 1.29 | 1.94 | 19 | 92 | 2.36 | 2.04 | 0.39 | 2.08 | 2.7 | 0.86 | 3.02 | 312 |
2 | 11.61 | 1.35 | 2.7 | 20 | 94 | 2.74 | 2.92 | 0.29 | 2.49 | 2.65 | 0.96 | 3.26 | 680 |
2 | 11.46 | 3.74 | 1.82 | 19.5 | 107 | 3.18 | 2.58 | 0.24 | 3.58 | 2.9 | 0.75 | 2.81 | 562 |
2 | 12.52 | 2.43 | 2.17 | 21 | 88 | 2.55 | 2.27 | 0.26 | 1.22 | 2 | 0.9 | 2.78 | 325 |
2 | 11.76 | 2.68 | 2.92 | 20 | 103 | 1.75 | 2.03 | 0.6 | 1.05 | 3.8 | 1.23 | 2.5 | 607 |
2 | 11.41 | 0.74 | 2.5 | 21 | 88 | 2.48 | 2.01 | 0.42 | 1.44 | 3.08 | 1.1 | 2.31 | 434 |
2 | 12.08 | 1.39 | 2.5 | 22.5 | 84 | 2.56 | 2.29 | 0.43 | 1.04 | 2.9 | 0.93 | 3.19 | 385 |
2 | 11.03 | 1.51 | 2.2 | 21.5 | 85 | 2.46 | 2.17 | 0.52 | 2.01 | 1.9 | 1.71 | 2.87 | 407 |
2 | 11.82 | 1.47 | 1.99 | 20.8 | 86 | 1.98 | 1.6 | 0.3 | 1.53 | 1.95 | 0.95 | 3.33 | 495 |
2 | 12.42 | 1.61 | 2.19 | 22.5 | 108 | 2 | 2.09 | 0.34 | 1.61 | 2.06 | 1.06 | 2.96 | 345 |
2 | 12.77 | 3.43 | 1.98 | 16 | 80 | 1.63 | 1.25 | 0.43 | 0.83 | 3.4 | 0.7 | 2.12 | 372 |
2 | 12 | 3.43 | 2 | 19 | 87 | 2 | 1.64 | 0.37 | 1.87 | 1.28 | 0.93 | 3.05 | 564 |
2 | 11.45 | 2.4 | 2.42 | 20 | 96 | 2.9 | 2.79 | 0.32 | 1.83 | 3.25 | 0.8 | 3.39 | 625 |
2 | 11.56 | 2.05 | 3.23 | 28.5 | 119 | 3.18 | 5.08 | 0.47 | 1.87 | 6 | 0.93 | 3.69 | 465 |
2 | 12.42 | 4.43 | 2.73 | 26.5 | 102 | 2.2 | 2.13 | 0.43 | 1.71 | 2.08 | 0.92 | 3.12 | 365 |
2 | 13.05 | 5.8 | 2.13 | 21.5 | 86 | 2.62 | 2.65 | 0.3 | 2.01 | 2.6 | 0.73 | 3.1 | 380 |
2 | 11.87 | 4.31 | 2.39 | 21 | 82 | 2.86 | 3.03 | 0.21 | 2.91 | 2.8 | 0.75 | 3.64 | 380 |
2 | 12.07 | 2.16 | 2.17 | 21 | 85 | 2.6 | 2.65 | 0.37 | 1.35 | 2.76 | 0.86 | 3.28 | 378 |
2 | 12.43 | 1.53 | 2.29 | 21.5 | 86 | 2.74 | 3.15 | 0.39 | 1.77 | 3.94 | 0.69 | 2.84 | 352 |
2 | 11.79 | 2.13 | 2.78 | 28.5 | 92 | 2.13 | 2.24 | 0.58 | 1.76 | 3 | 0.97 | 2.44 | 466 |
2 | 12.37 | 1.63 | 2.3 | 24.5 | 88 | 2.22 | 2.45 | 0.4 | 1.9 | 2.12 | 0.89 | 2.78 | 342 |
2 | 12.04 | 4.3 | 2.38 | 22 | 80 | 2.1 | 1.75 | 0.42 | 1.35 | 2.6 | 0.79 | 2.57 | 580 |
3 | 12.86 | 1.35 | 2.32 | 18 | 122 | 1.51 | 1.25 | 0.21 | 0.94 | 4.1 | 0.76 | 1.29 | 630 |
3 | 12.88 | 2.99 | 2.4 | 20 | 104 | 1.3 | 1.22 | 0.24 | 0.83 | 5.4 | 0.74 | 1.42 | 530 |
3 | 12.81 | 2.31 | 2.4 | 24 | 98 | 1.15 | 1.09 | 0.27 | 0.83 | 5.7 | 0.66 | 1.36 | 560 |
3 | 12.7 | 3.55 | 2.36 | 21.5 | 106 | 1.7 | 1.2 | 0.17 | 0.84 | 5 | 0.78 | 1.29 | 600 |
3 | 12.51 | 1.24 | 2.25 | 17.5 | 85 | 2 | 0.58 | 0.6 | 1.25 | 5.45 | 0.75 | 1.51 | 650 |
3 | 12.6 | 2.46 | 2.2 | 18.5 | 94 | 1.62 | 0.66 | 0.63 | 0.94 | 7.1 | 0.73 | 1.58 | 695 |
3 | 12.25 | 4.72 | 2.54 | 21 | 89 | 1.38 | 0.47 | 0.53 | 0.8 | 3.85 | 0.75 | 1.27 | 720 |
3 | 12.53 | 5.51 | 2.64 | 25 | 96 | 1.79 | 0.6 | 0.63 | 1.1 | 5 | 0.82 | 1.69 | 515 |
3 | 13.49 | 3.59 | 2.19 | 19.5 | 88 | 1.62 | 0.48 | 0.58 | 0.88 | 5.7 | 0.81 | 1.82 | 580 |
3 | 12.84 | 2.96 | 2.61 | 24 | 101 | 2.32 | 0.6 | 0.53 | 0.81 | 4.92 | 0.89 | 2.15 | 590 |
3 | 12.93 | 2.81 | 2.7 | 21 | 96 | 1.54 | 0.5 | 0.53 | 0.75 | 4.6 | 0.77 | 2.31 | 600 |
3 | 13.36 | 2.56 | 2.35 | 20 | 89 | 1.4 | 0.5 | 0.37 | 0.64 | 5.6 | 0.7 | 2.47 | 780 |
3 | 13.52 | 3.17 | 2.72 | 23.5 | 97 | 1.55 | 0.52 | 0.5 | 0.55 | 4.35 | 0.89 | 2.06 | 520 |
3 | 13.62 | 4.95 | 2.35 | 20 | 92 | 2 | 0.8 | 0.47 | 1.02 | 4.4 | 0.91 | 2.05 | 550 |
3 | 12.25 | 3.88 | 2.2 | 18.5 | 112 | 1.38 | 0.78 | 0.29 | 1.14 | 8.21 | 0.65 | 2 | 855 |
3 | 13.16 | 3.57 | 2.15 | 21 | 102 | 1.5 | 0.55 | 0.43 | 1.3 | 4 | 0.6 | 1.68 | 830 |
3 | 13.88 | 5.04 | 2.23 | 20 | 80 | 0.98 | 0.34 | 0.4 | 0.68 | 4.9 | 0.58 | 1.33 | 415 |
3 | 12.87 | 4.61 | 2.48 | 21.5 | 86 | 1.7 | 0.65 | 0.47 | 0.86 | 7.65 | 0.54 | 1.86 | 625 |
3 | 13.32 | 3.24 | 2.38 | 21.5 | 92 | 1.93 | 0.76 | 0.45 | 1.25 | 8.42 | 0.55 | 1.62 | 650 |
3 | 13.08 | 3.9 | 2.36 | 21.5 | 113 | 1.41 | 1.39 | 0.34 | 1.14 | 9.4 | 0.57 | 1.33 | 550 |
3 | 13.5 | 3.12 | 2.62 | 24 | 123 | 1.4 | 1.57 | 0.22 | 1.25 | 8.6 | 0.59 | 1.3 | 500 |
3 | 12.79 | 2.67 | 2.48 | 22 | 112 | 1.48 | 1.36 | 0.24 | 1.26 | 10.8 | 0.48 | 1.47 | 480 |
3 | 13.11 | 1.9 | 2.75 | 25.5 | 116 | 2.2 | 1.28 | 0.26 | 1.56 | 7.1 | 0.61 | 1.33 | 425 |
3 | 13.23 | 3.3 | 2.28 | 18.5 | 98 | 1.8 | 0.83 | 0.61 | 1.87 | 10.52 | 0.56 | 1.51 | 675 |
3 | 12.58 | 1.29 | 2.1 | 20 | 103 | 1.48 | 0.58 | 0.53 | 1.4 | 7.6 | 0.58 | 1.55 | 640 |
3 | 13.17 | 5.19 | 2.32 | 22 | 93 | 1.74 | 0.63 | 0.61 | 1.55 | 7.9 | 0.6 | 1.48 | 725 |
3 | 13.84 | 4.12 | 2.38 | 19.5 | 89 | 1.8 | 0.83 | 0.48 | 1.56 | 9.01 | 0.57 | 1.64 | 480 |
3 | 12.45 | 3.03 | 2.64 | 27 | 97 | 1.9 | 0.58 | 0.63 | 1.14 | 7.5 | 0.67 | 1.73 | 880 |
3 | 14.34 | 1.68 | 2.7 | 25 | 98 | 2.8 | 1.31 | 0.53 | 2.7 | 13 | 0.57 | 1.96 | 660 |
3 | 13.48 | 1.67 | 2.64 | 22.5 | 89 | 2.6 | 1.1 | 0.52 | 2.29 | 11.75 | 0.57 | 1.78 | 620 |
3 | 12.36 | 3.83 | 2.38 | 21 | 88 | 2.3 | 0.92 | 0.5 | 1.04 | 7.65 | 0.56 | 1.58 | 520 |
3 | 13.69 | 3.26 | 2.54 | 20 | 107 | 1.83 | 0.56 | 0.5 | 0.8 | 5.88 | 0.96 | 1.82 | 680 |
3 | 12.85 | 3.27 | 2.58 | 22 | 106 | 1.65 | 0.6 | 0.6 | 0.96 | 5.58 | 0.87 | 2.11 | 570 |
3 | 12.96 | 3.45 | 2.35 | 18.5 | 106 | 1.39 | 0.7 | 0.4 | 0.94 | 5.28 | 0.68 | 1.75 | 675 |
3 | 13.78 | 2.76 | 2.3 | 22 | 90 | 1.35 | 0.68 | 0.41 | 1.03 | 9.58 | 0.7 | 1.68 | 615 |
3 | 13.73 | 4.36 | 2.26 | 22.5 | 88 | 1.28 | 0.47 | 0.52 | 1.15 | 6.62 | 0.78 | 1.75 | 520 |
3 | 13.45 | 3.7 | 2.6 | 23 | 111 | 1.7 | 0.92 | 0.43 | 1.46 | 10.68 | 0.85 | 1.56 | 695 |
3 | 12.82 | 3.37 | 2.3 | 19.5 | 88 | 1.48 | 0.66 | 0.4 | 0.97 | 10.26 | 0.72 | 1.75 | 685 |
3 | 13.58 | 2.58 | 2.69 | 24.5 | 105 | 1.55 | 0.84 | 0.39 | 1.54 | 8.66 | 0.74 | 1.8 | 750 |
3 | 13.4 | 4.6 | 2.86 | 25 | 112 | 1.98 | 0.96 | 0.27 | 1.11 | 8.5 | 0.67 | 1.92 | 630 |
3 | 12.2 | 3.03 | 2.32 | 19 | 96 | 1.25 | 0.49 | 0.4 | 0.73 | 5.5 | 0.66 | 1.83 | 510 |
3 | 12.77 | 2.39 | 2.28 | 19.5 | 86 | 1.39 | 0.51 | 0.48 | 0.64 | 9.899999 | 0.57 | 1.63 | 470 |
3 | 14.16 | 2.51 | 2.48 | 20 | 91 | 1.68 | 0.7 | 0.44 | 1.24 | 9.7 | 0.62 | 1.71 | 660 |
3 | 13.71 | 5.65 | 2.45 | 20.5 | 95 | 1.68 | 0.61 | 0.52 | 1.06 | 7.7 | 0.64 | 1.74 | 740 |
3 | 13.4 | 3.91 | 2.48 | 23 | 102 | 1.8 | 0.75 | 0.43 | 1.41 | 7.3 | 0.7 | 1.56 | 750 |
3 | 13.27 | 4.28 | 2.26 | 20 | 120 | 1.59 | 0.69 | 0.43 | 1.35 | 10.2 | 0.59 | 1.56 | 835 |
3 | 13.17 | 2.59 | 2.37 | 20 | 120 | 1.65 | 0.68 | 0.53 | 1.46 | 9.3 | 0.6 | 1.62 | 840 |
3 | 14.13 | 4.1 | 2.74 | 24.5 | 96 | 2.05 | 0.76 | 0.56 | 1.35 | 9.2 | 0.61 | 1.6 | 560 |
Parag Kanade/fuzzy ants/wine/wine.data
Wine data # 14.23 1.71 2.43 15.6 127 2.8 3.06 0.28 2.29 5.64 1.04 3.92 1065 13.2 1.78 2.14 11.2 100 2.65 2.76 0.26 1.28 4.38 1.05 3.4 1050 13.16 2.36 2.67 18.6 101 2.8 3.24 0.3 2.81 5.68 1.03 3.17 1185 14.37 1.95 2.5 16.8 113 3.85 3.49 0.24 2.18 7.8 0.86 3.45 1480 13.24 2.59 2.87 21 118 2.8 2.69 0.39 1.82 4.32 1.04 2.93 735 14.2 1.76 2.45 15.2 112 3.27 3.39 0.34 1.97 6.75 1.05 2.85 1450 14.39 1.87 2.45 14.6 96 2.5 2.52 0.3 1.98 5.25 1.02 3.58 1290 14.06 2.15 2.61 17.6 121 2.6 2.51 0.31 1.25 5.05 1.06 3.58 1295 14.83 1.64 2.17 14 97 2.8 2.98 0.29 1.98 5.2 1.08 2.85 1045 13.86 1.35 2.27 16 98 2.98 3.15 0.22 1.85 7.22 1.01 3.55 1045 14.1 2.16 2.3 18 105 2.95 3.32 0.22 2.38 5.75 1.25 3.17 1510 14.12 1.48 2.32 16.8 95 2.2 2.43 0.26 1.57 5 1.17 2.82 1280 13.75 1.73 2.41 16 89 2.6 2.76 0.29 1.81 5.6 1.15 2.9 1320 14.75 1.73 2.39 11.4 91 3.1 3.69 0.43 2.81 5.4 1.25 2.73 1150 14.38 1.87 2.38 12 102 3.3 3.64 0.29 2.96 7.5 1.2 3 1547 13.63 1.81 2.7 17.2 112 2.85 2.91 0.3 1.46 7.3 1.28 2.88 1310 14.3 1.92 2.72 20 120 2.8 3.14 0.33 1.97 6.2 1.07 2.65 1280 13.83 1.57 2.62 20 115 2.95 3.4 0.4 1.72 6.6 1.13 2.57 1130 14.19 1.59 2.48 16.5 108 3.3 3.93 0.32 1.86 8.7 1.23 2.82 1680 13.64 3.1 2.56 15.2 116 2.7 3.03 0.17 1.66 5.1 0.96 3.36 845 14.06 1.63 2.28 16 126 3 3.17 0.24 2.1 5.65 1.09 3.71 780 12.93 3.8 2.65 18.6 102 2.41 2.41 0.25 1.98 4.5 1.03 3.52 770 13.71 1.86 2.36 16.6 101 2.61 2.88 0.27 1.69 3.8 1.11 4 1035 12.85 1.6 2.52 17.8 95 2.48 2.37 0.26 1.46 3.93 1.09 3.63 1015 13.5 1.81 2.61 20 96 2.53 2.61 0.28 1.66 3.52 1.12 3.82 845 13.05 2.05 3.22 25 124 2.63 2.68 0.47 1.92 3.58 1.13 3.2 830 13.39 1.77 2.62 16.1 93 2.85 2.94 0.34 1.45 4.8 0.92 3.22 1195 13.3 1.72 2.14 17 94 2.4 2.19 0.27 1.35 3.95 1.02 2.77 1285 13.87 1.9 2.8 19.4 107 2.95 2.97 0.37 1.76 4.5 1.25 3.4 915 14.02 1.68 2.21 16 96 2.65 2.33 0.26 1.98 4.7 1.04 3.59 1035 13.73 1.5 2.7 22.5 101 3 3.25 0.29 2.38 5.7 1.19 2.71 1285 13.58 1.66 2.36 19.1 106 2.86 3.19 0.22 1.95 6.9 1.09 2.88 1515 13.68 1.83 2.36 17.2 104 2.42 2.69 0.42 1.97 3.84 1.23 2.87 990 13.76 1.53 2.7 19.5 132 2.95 2.74 0.5 1.35 5.4 1.25 3 1235 13.51 1.8 2.65 19 110 2.35 2.53 0.29 1.54 4.2 1.1 2.87 1095 13.48 1.81 2.41 20.5 100 2.7 2.98 0.26 1.86 5.1 1.04 3.47 920 13.28 1.64 2.84 15.5 110 2.6 2.68 0.34 1.36 4.6 1.09 2.78 880 13.05 1.65 2.55 18 98 2.45 2.43 0.29 1.44 4.25 1.12 2.51 1105 13.07 1.5 2.1 15.5 98 2.4 2.64 0.28 1.37 3.7 1.18 2.69 1020 14.22 3.99 2.51 13.2 128 3 3.04 0.2 2.08 5.1 0.89 3.53 760 13.56 1.71 2.31 16.2 117 3.15 3.29 0.34 2.34 6.13 0.95 3.38 795 13.41 3.84 2.12 18.8 90 2.45 2.68 0.27 1.48 4.28 0.91 3 1035 13.88 1.89 2.59 15 101 3.25 3.56 0.17 1.7 5.43 0.88 3.56 1095 13.24 3.98 2.29 17.5 103 2.64 2.63 0.32 1.66 4.36 0.82 3 680 13.05 1.77 2.1 17 107 3 3 0.28 2.03 5.04 0.88 3.35 885 14.21 4.04 2.44 18.9 111 2.85 2.65 0.3 1.25 5.24 0.87 3.33 1080 14.38 3.59 2.28 16 102 3.25 3.17 0.27 2.19 4.9 1.04 3.44 1065 13.9 1.68 2.12 16 101 3.1 3.39 0.21 2.14 6.1 0.91 3.33 985 14.1 2.02 2.4 18.8 103 2.75 2.92 0.32 2.38 6.2 1.07 2.75 1060 13.94 1.73 2.27 17.4 108 2.88 3.54 0.32 2.08 8.9 1.12 3.1 1260 13.05 1.73 2.04 12.4 92 2.72 3.27 0.17 2.91 7.2 1.12 2.91 1150 13.83 1.65 2.6 17.2 94 2.45 2.99 0.22 2.29 5.6 1.24 3.37 1265 13.82 1.75 2.42 14 111 3.88 3.74 0.32 1.87 7.05 1.01 3.26 1190 13.77 1.9 2.68 17.1 115 3 2.79 0.39 1.68 6.3 1.13 2.93 1375 13.74 1.67 2.25 16.4 118 2.6 2.9 0.21 1.62 5.85 0.92 3.2 1060 13.56 1.73 2.46 20.5 116 2.96 2.78 0.2 2.45 6.25 0.98 3.03 1120 14.22 1.7 2.3 16.3 118 3.2 3 0.26 2.03 6.38 0.94 3.31 970 13.29 1.97 2.68 16.8 102 3 3.23 0.31 1.66 6 1.07 2.84 1270 13.72 1.43 2.5 16.7 108 3.4 3.67 0.19 2.04 6.8 0.89 2.87 1285 12.37 0.94 1.36 10.6 88 1.98 0.57 0.28 0.42 1.95 1.05 1.82 520 12.33 1.1 2.28 16 101 2.05 1.09 0.63 0.41 3.27 1.25 1.67 680 12.64 1.36 2.02 16.8 100 2.02 1.41 0.53 0.62 5.75 0.98 1.59 450 13.67 1.25 1.92 18 94 2.1 1.79 0.32 0.73 3.8 1.23 2.46 630 12.37 1.13 2.16 19 87 3.5 3.1 0.19 1.87 4.45 1.22 2.87 420 12.17 1.45 2.53 19 104 1.89 1.75 0.45 1.03 2.95 1.45 2.23 355 12.37 1.21 2.56 18.1 98 2.42 2.65 0.37 2.08 4.6 1.19 2.3 678 13.11 1.01 1.7 15 78 2.98 3.18 0.26 2.28 5.3 1.12 3.18 502 12.37 1.17 1.92 19.6 78 2.11 2 0.27 1.04 4.68 1.12 3.48 510 13.34 0.94 2.36 17 110 2.53 1.3 0.55 0.42 3.17 1.02 1.93 750 12.21 1.19 1.75 16.8 151 1.85 1.28 0.14 2.5 2.85 1.28 3.07 718 12.29 1.61 2.21 20.4 103 1.1 1.02 0.37 1.46 3.05 0.906 1.82 870 13.86 1.51 2.67 25 86 2.95 2.86 0.21 1.87 3.38 1.36 3.16 410 13.49 1.66 2.24 24 87 1.88 1.84 0.27 1.03 3.74 0.98 2.78 472 12.99 1.67 2.6 30 139 3.3 2.89 0.21 1.96 3.35 1.31 3.5 985 11.96 1.09 2.3 21 101 3.38 2.14 0.13 1.65 3.21 0.99 3.13 886 11.66 1.88 1.92 16 97 1.61 1.57 0.34 1.15 3.8 1.23 2.14 428 13.03 0.9 1.71 16 86 1.95 2.03 0.24 1.46 4.6 1.19 2.48 392 11.84 2.89 2.23 18 112 1.72 1.32 0.43 0.95 2.65 0.96 2.52 500 12.33 0.99 1.95 14.8 136 1.9 1.85 0.35 2.76 3.4 1.06 2.31 750 12.7 3.87 2.4 23 101 2.83 2.55 0.43 1.95 2.57 1.19 3.13 463 12 0.92 2 19 86 2.42 2.26 0.3 1.43 2.5 1.38 3.12 278 12.72 1.81 2.2 18.8 86 2.2 2.53 0.26 1.77 3.9 1.16 3.14 714 12.08 1.13 2.51 24 78 2 1.58 0.4 1.4 2.2 1.31 2.72 630 13.05 3.86 2.32 22.5 85 1.65 1.59 0.61 1.62 4.8 0.84 2.01 515 11.84 0.89 2.58 18 94 2.2 2.21 0.22 2.35 3.05 0.79 3.08 520 12.67 0.98 2.24 18 99 2.2 1.94 0.3 1.46 2.62 1.23 3.16 450 12.16 1.61 2.31 22.8 90 1.78 1.69 0.43 1.56 2.45 1.33 2.26 495 11.65 1.67 2.62 26 88 1.92 1.61 0.4 1.34 2.6 1.36 3.21 562 11.64 2.06 2.46 21.6 84 1.95 1.69 0.48 1.35 2.8 1 2.75 680 12.08 1.33 2.3 23.6 70 2.2 1.59 0.42 1.38 1.74 1.07 3.21 625 12.08 1.83 2.32 18.5 81 1.6 1.5 0.52 1.64 2.4 1.08 2.27 480 12 1.51 2.42 22 86 1.45 1.25 0.5 1.63 3.6 1.05 2.65 450 12.69 1.53 2.26 20.7 80 1.38 1.46 0.58 1.62 3.05 0.96 2.06 495 12.29 2.83 2.22 18 88 2.45 2.25 0.25 1.99 2.15 1.15 3.3 290 11.62 1.99 2.28 18 98 3.02 2.26 0.17 1.35 3.25 1.16 2.96 345 12.47 1.52 2.2 19 162 2.5 2.27 0.32 3.28 2.6 1.16 2.63 937 11.81 2.12 2.74 21.5 134 1.6 0.99 0.14 1.56 2.5 0.95 2.26 625 12.29 1.41 1.98 16 85 2.55 2.5 0.29 1.77 2.9 1.23 2.74 428 12.37 1.07 2.1 18.5 88 3.52 3.75 0.24 1.95 4.5 1.04 2.77 660 12.29 3.17 2.21 18 88 2.85 2.99 0.45 2.81 2.3 1.42 2.83 406 12.08 2.08 1.7 17.5 97 2.23 2.17 0.26 1.4 3.3 1.27 2.96 710 12.6 1.34 1.9 18.5 88 1.45 1.36 0.29 1.35 2.45 1.04 2.77 562 12.34 2.45 2.46 21 98 2.56 2.11 0.34 1.31 2.8 0.8 3.38 438 11.82 1.72 1.88 19.5 86 2.5 1.64 0.37 1.42 2.06 0.94 2.44 415 12.51 1.73 1.98 20.5 85 2.2 1.92 0.32 1.48 2.94 1.04 3.57 672 12.42 2.55 2.27 22 90 1.68 1.84 0.66 1.42 2.7 0.86 3.3 315 12.25 1.73 2.12 19 80 1.65 2.03 0.37 1.63 3.4 1 3.17 510 12.72 1.75 2.28 22.5 84 1.38 1.76 0.48 1.63 3.3 0.88 2.42 488 12.22 1.29 1.94 19 92 2.36 2.04 0.39 2.08 2.7 0.86 3.02 312 11.61 1.35 2.7 20 94 2.74 2.92 0.29 2.49 2.65 0.96 3.26 680 11.46 3.74 1.82 19.5 107 3.18 2.58 0.24 3.58 2.9 0.75 2.81 562 12.52 2.43 2.17 21 88 2.55 2.27 0.26 1.22 2 0.9 2.78 325 11.76 2.68 2.92 20 103 1.75 2.03 0.6 1.05 3.8 1.23 2.5 607 11.41 0.74 2.5 21 88 2.48 2.01 0.42 1.44 3.08 1.1 2.31 434 12.08 1.39 2.5 22.5 84 2.56 2.29 0.43 1.04 2.9 0.93 3.19 385 11.03 1.51 2.2 21.5 85 2.46 2.17 0.52 2.01 1.9 1.71 2.87 407 11.82 1.47 1.99 20.8 86 1.98 1.6 0.3 1.53 1.95 0.95 3.33 495 12.42 1.61 2.19 22.5 108 2 2.09 0.34 1.61 2.06 1.06 2.96 345 12.77 3.43 1.98 16 80 1.63 1.25 0.43 0.83 3.4 0.7 2.12 372 12 3.43 2 19 87 2 1.64 0.37 1.87 1.28 0.93 3.05 564 11.45 2.4 2.42 20 96 2.9 2.79 0.32 1.83 3.25 0.8 3.39 625 11.56 2.05 3.23 28.5 119 3.18 5.08 0.47 1.87 6 0.93 3.69 465 12.42 4.43 2.73 26.5 102 2.2 2.13 0.43 1.71 2.08 0.92 3.12 365 13.05 5.8 2.13 21.5 86 2.62 2.65 0.3 2.01 2.6 0.73 3.1 380 11.87 4.31 2.39 21 82 2.86 3.03 0.21 2.91 2.8 0.75 3.64 380 12.07 2.16 2.17 21 85 2.6 2.65 0.37 1.35 2.76 0.86 3.28 378 12.43 1.53 2.29 21.5 86 2.74 3.15 0.39 1.77 3.94 0.69 2.84 352 11.79 2.13 2.78 28.5 92 2.13 2.24 0.58 1.76 3 0.97 2.44 466 12.37 1.63 2.3 24.5 88 2.22 2.45 0.4 1.9 2.12 0.89 2.78 342 12.04 4.3 2.38 22 80 2.1 1.75 0.42 1.35 2.6 0.79 2.57 580 12.86 1.35 2.32 18 122 1.51 1.25 0.21 0.94 4.1 0.76 1.29 630 12.88 2.99 2.4 20 104 1.3 1.22 0.24 0.83 5.4 0.74 1.42 530 12.81 2.31 2.4 24 98 1.15 1.09 0.27 0.83 5.7 0.66 1.36 560 12.7 3.55 2.36 21.5 106 1.7 1.2 0.17 0.84 5 0.78 1.29 600 12.51 1.24 2.25 17.5 85 2 0.58 0.6 1.25 5.45 0.75 1.51 650 12.6 2.46 2.2 18.5 94 1.62 0.66 0.63 0.94 7.1 0.73 1.58 695 12.25 4.72 2.54 21 89 1.38 0.47 0.53 0.8 3.85 0.75 1.27 720 12.53 5.51 2.64 25 96 1.79 0.6 0.63 1.1 5 0.82 1.69 515 13.49 3.59 2.19 19.5 88 1.62 0.48 0.58 0.88 5.7 0.81 1.82 580 12.84 2.96 2.61 24 101 2.32 0.6 0.53 0.81 4.92 0.89 2.15 590 12.93 2.81 2.7 21 96 1.54 0.5 0.53 0.75 4.6 0.77 2.31 600 13.36 2.56 2.35 20 89 1.4 0.5 0.37 0.64 5.6 0.7 2.47 780 13.52 3.17 2.72 23.5 97 1.55 0.52 0.5 0.55 4.35 0.89 2.06 520 13.62 4.95 2.35 20 92 2 0.8 0.47 1.02 4.4 0.91 2.05 550 12.25 3.88 2.2 18.5 112 1.38 0.78 0.29 1.14 8.21 0.65 2 855 13.16 3.57 2.15 21 102 1.5 0.55 0.43 1.3 4 0.6 1.68 830 13.88 5.04 2.23 20 80 0.98 0.34 0.4 0.68 4.9 0.58 1.33 415 12.87 4.61 2.48 21.5 86 1.7 0.65 0.47 0.86 7.65 0.54 1.86 625 13.32 3.24 2.38 21.5 92 1.93 0.76 0.45 1.25 8.42 0.55 1.62 650 13.08 3.9 2.36 21.5 113 1.41 1.39 0.34 1.14 9.4 0.57 1.33 550 13.5 3.12 2.62 24 123 1.4 1.57 0.22 1.25 8.6 0.59 1.3 500 12.79 2.67 2.48 22 112 1.48 1.36 0.24 1.26 10.8 0.48 1.47 480 13.11 1.9 2.75 25.5 116 2.2 1.28 0.26 1.56 7.1 0.61 1.33 425 13.23 3.3 2.28 18.5 98 1.8 0.83 0.61 1.87 10.52 0.56 1.51 675 12.58 1.29 2.1 20 103 1.48 0.58 0.53 1.4 7.6 0.58 1.55 640 13.17 5.19 2.32 22 93 1.74 0.63 0.61 1.55 7.9 0.6 1.48 725 13.84 4.12 2.38 19.5 89 1.8 0.83 0.48 1.56 9.01 0.57 1.64 480 12.45 3.03 2.64 27 97 1.9 0.58 0.63 1.14 7.5 0.67 1.73 880 14.34 1.68 2.7 25 98 2.8 1.31 0.53 2.7 13 0.57 1.96 660 13.48 1.67 2.64 22.5 89 2.6 1.1 0.52 2.29 11.75 0.57 1.78 620 12.36 3.83 2.38 21 88 2.3 0.92 0.5 1.04 7.65 0.56 1.58 520 13.69 3.26 2.54 20 107 1.83 0.56 0.5 0.8 5.88 0.96 1.82 680 12.85 3.27 2.58 22 106 1.65 0.6 0.6 0.96 5.58 0.87 2.11 570 12.96 3.45 2.35 18.5 106 1.39 0.7 0.4 0.94 5.28 0.68 1.75 675 13.78 2.76 2.3 22 90 1.35 0.68 0.41 1.03 9.58 0.7 1.68 615 13.73 4.36 2.26 22.5 88 1.28 0.47 0.52 1.15 6.62 0.78 1.75 520 13.45 3.7 2.6 23 111 1.7 0.92 0.43 1.46 10.68 0.85 1.56 695 12.82 3.37 2.3 19.5 88 1.48 0.66 0.4 0.97 10.26 0.72 1.75 685 13.58 2.58 2.69 24.5 105 1.55 0.84 0.39 1.54 8.66 0.74 1.8 750 13.4 4.6 2.86 25 112 1.98 0.96 0.27 1.11 8.5 0.67 1.92 630 12.2 3.03 2.32 19 96 1.25 0.49 0.4 0.73 5.5 0.66 1.83 510 12.77 2.39 2.28 19.5 86 1.39 0.51 0.48 0.64 9.899999 0.57 1.63 470 14.16 2.51 2.48 20 91 1.68 0.7 0.44 1.24 9.7 0.62 1.71 660 13.71 5.65 2.45 20.5 95 1.68 0.61 0.52 1.06 7.7 0.64 1.74 740 13.4 3.91 2.48 23 102 1.8 0.75 0.43 1.41 7.3 0.7 1.56 750 13.27 4.28 2.26 20 120 1.59 0.69 0.43 1.35 10.2 0.59 1.56 835 13.17 2.59 2.37 20 120 1.65 0.68 0.53 1.46 9.3 0.6 1.62 840 14.13 4.1 2.74 24.5 96 2.05 0.76 0.56 1.35 9.2 0.61 1.6 560
Parag Kanade/fuzzy ants/Gauss1/maxData.txt
1.784235
Parag Kanade/fuzzy ants/Gauss1/gauss01Full.data
1 | -0.46551197 | 1.3396181 |
1 | -0.14154019 | 1.6467355 |
1 | -0.06147374 | 1.910021 |
1 | -0.00960664 | 1.6959237 |
1 | 0.13522751 | 2.3371545 |
1 | 0.15816343 | 1.74101 |
1 | 0.16902868 | 1.7145902 |
1 | 0.20321506 | 1.3230994 |
1 | 0.24094079 | 1.3069846 |
1 | 0.25245225 | 2.1839526 |
1 | 0.26993324 | 2.5483323 |
1 | 0.28680391 | 1.6052432 |
1 | 0.3192367 | 2.2276855 |
1 | 0.36114833 | 2.8009784 |
1 | 0.4244067 | 1.8634449 |
1 | 0.46037797 | 1.4532789 |
1 | 0.46098959 | 2.3555875 |
1 | 0.48936047 | 1.8126198 |
1 | 0.493417 | 0.52432961 |
1 | 0.5579586 | 2.0069093 |
1 | 0.59517099 | 0.74266104 |
1 | 0.601286 | 2.447746 |
1 | 0.64249205 | 0.22137058 |
1 | 0.64603926 | 2.098612 |
1 | 0.68936857 | 2.3436606 |
1 | 0.70125847 | 1.9881431 |
1 | 0.70954162 | 1.8340884 |
1 | 0.71271143 | 1.1911658 |
1 | 0.73828501 | 2.9157625 |
1 | 0.76121259 | 2.887774 |
1 | 0.76300537 | 3.36236 |
1 | 0.78715506 | 1.7998882 |
1 | 0.79603202 | 1.3837631 |
1 | 0.81552587 | 0.7659359 |
1 | 0.81671088 | 2.0235945 |
1 | 0.83646559 | 1.7292928 |
1 | 0.84905869 | 0.90959966 |
1 | 0.87280583 | 1.9185033 |
1 | 0.93911004 | 2.2377149 |
1 | 0.94658989 | 1.8099329 |
1 | 0.95071896 | 3.3593771 |
1 | 0.95477185 | 0.82422933 |
1 | 1.0475351 | 3.7358953 |
1 | 1.0483555 | 2.6222619 |
1 | 1.0663274 | 2.0772458 |
1 | 1.0719789 | 2.3051114 |
1 | 1.0841659 | 2.8982847 |
1 | 1.0917331 | 1.4965835 |
1 | 1.1268271 | 1.7541776 |
1 | 1.1308673 | 2.1353612 |
1 | 1.1428466 | 2.0972579 |
1 | 1.1493513 | 1.8227118 |
1 | 1.1819349 | 1.8738619 |
1 | 1.1900377 | 1.5835831 |
1 | 1.2101874 | 1.8796963 |
1 | 1.2181118 | 3.0111068 |
1 | 1.2277972 | 2.0808183 |
1 | 1.2335498 | 2.9573163 |
1 | 1.2448562 | 1.6017201 |
1 | 1.2555436 | 1.9472067 |
1 | 1.2597352 | 0.95874592 |
1 | 1.2601195 | 0.81798378 |
1 | 1.2715242 | 0.46185734 |
1 | 1.2749423 | 3.2592336 |
1 | 1.2888759 | 2.4162943 |
1 | 1.319464 | 2.1180977 |
1 | 1.3266557 | 1.9249356 |
1 | 1.3269461 | 2.8783508 |
1 | 1.3458998 | 1.6047048 |
1 | 1.3471548 | 2.0660325 |
1 | 1.3753515 | 2.4089999 |
1 | 1.3793406 | 2.1089793 |
1 | 1.3872928 | 3.3455047 |
1 | 1.3979966 | 2.3829163 |
1 | 1.4001717 | 3.0482038 |
1 | 1.4054732 | 1.6215221 |
1 | 1.4312392 | 0.79191521 |
1 | 1.4354818 | 3.0271297 |
1 | 1.4410139 | 2.7986203 |
1 | 1.4641202 | 0.58155858 |
1 | 1.4646153 | 3.9791516 |
1 | 1.5055329 | 1.0990125 |
1 | 1.5286615 | 2.6943944 |
1 | 1.5534019 | 3.741445 |
1 | 1.5735908 | 1.5571016 |
1 | 1.5856639 | 0.99127551 |
1 | 1.6083411 | 2.3154722 |
1 | 1.6167515 | 3.4641362 |
1 | 1.6315791 | 2.9447703 |
1 | 1.6485825 | 1.9459715 |
1 | 1.6558902 | 1.1154736 |
1 | 1.6603318 | 2.4801616 |
1 | 1.6657018 | 1.9762646 |
1 | 1.6740867 | 2.9751515 |
1 | 1.7109312 | 1.5716093 |
1 | 1.7172934 | 1.9542265 |
1 | 1.7245997 | 2.387059 |
1 | 1.7280016 | 3.2168608 |
1 | 1.7407356 | 1.6770587 |
1 | 1.7446611 | 3.8440441 |
1 | 1.7479167 | 1.3913499 |
1 | 1.7507312 | 2.769599 |
1 | 1.7567404 | 1.4447784 |
1 | 1.7591262 | 3.9952283 |
1 | 1.7610234 | 3.5877581 |
1 | 1.7736913 | 1.4399875 |
1 | 1.7826518 | 3.1827802 |
1 | 1.7882331 | 2.7558682 |
1 | 1.8048077 | 1.4894358 |
1 | 1.806578 | 2.2980184 |
1 | 1.8105734 | 3.0728863 |
1 | 1.8132452 | 0.11900227 |
1 | 1.8581162 | 2.3816176 |
1 | 1.8735926 | 2.1120087 |
1 | 1.8771577 | 1.9606585 |
1 | 1.8791867 | 0.81713304 |
1 | 1.8866894 | 1.5761363 |
1 | 1.8881009 | 0.12698201 |
1 | 1.8980516 | 2.4640572 |
1 | 1.911659 | 0.92031474 |
1 | 1.9163593 | 2.2659011 |
1 | 1.9217044 | 1.9429349 |
1 | 1.9240625 | 1.2683148 |
1 | 1.933498 | 0.99443935 |
1 | 1.9366692 | 3.0426166 |
1 | 1.9572064 | 3.2689621 |
1 | 1.987931 | 4.1287767 |
1 | 1.9907116 | 1.6489055 |
1 | 1.9930155 | 2.6846483 |
1 | 2.0011578 | 2.3236036 |
1 | 2.0107086 | 2.1802041 |
1 | 2.0650972 | 0.62687304 |
1 | 2.0760993 | 1.8564104 |
1 | 2.076595 | 3.141211 |
1 | 2.0797088 | 2.6444816 |
1 | 2.0828643 | 2.4026682 |
1 | 2.0948837 | 1.8648059 |
1 | 2.0985622 | 3.7026465 |
1 | 2.0994979 | 4.0382142 |
1 | 2.1023642 | 3.2814187 |
1 | 2.1102441 | 3.3805769 |
1 | 2.1522589 | 1.6625872 |
1 | 2.1613626 | 2.6416719 |
1 | 2.1760954 | 0.66759943 |
1 | 2.1805424 | 2.0442384 |
1 | 2.1842685 | 2.5954692 |
1 | 2.1891405 | 2.9582391 |
1 | 2.1963915 | 2.0430046 |
1 | 2.2020264 | 2.176707 |
1 | 2.204684 | 0.83693931 |
1 | 2.2052541 | 1.7499996 |
1 | 2.2066926 | 2.7208274 |
1 | 2.2109871 | 0.60017807 |
1 | 2.2146996 | 1.399128 |
1 | 2.2174554 | 0.72364346 |
1 | 2.2304159 | 0.82961734 |
1 | 2.2473506 | 1.2875368 |
1 | 2.2490397 | 2.1734422 |
1 | 2.2519844 | 1.2969987 |
1 | 2.2604619 | 0.7826934 |
1 | 2.2688021 | 2.0460717 |
1 | 2.3082186 | 3.4655713 |
1 | 2.337285 | 2.3586476 |
1 | 2.3616657 | 2.9431843 |
1 | 2.372691 | 1.7305975 |
1 | 2.3783937 | 1.3535819 |
1 | 2.3816021 | 1.9007384 |
1 | 2.3967371 | 1.1569486 |
1 | 2.409683 | 2.3595594 |
1 | 2.4193469 | 1.0856312 |
1 | 2.4234583 | 0.51782552 |
1 | 2.4392568 | 3.1463499 |
1 | 2.440037 | 3.2618835 |
1 | 2.4499319 | 0.4923003 |
1 | 2.4582683 | 1.3588849 |
1 | 2.4769531 | 3.5814207 |
1 | 2.4844316 | 1.9984511 |
1 | 2.4845173 | 1.8737064 |
1 | 2.4932187 | 1.66146 |
1 | 2.5161047 | 2.2298843 |
1 | 2.5216744 | 2.9607432 |
1 | 2.5229139 | 1.492989 |
1 | 2.5270772 | -0.06387469 |
1 | 2.5353904 | 0.28615059 |
1 | 2.5781225 | 2.5085023 |
1 | 2.5789043 | 2.6564247 |
1 | 2.5913078 | 3.4678316 |
1 | 2.6017795 | 2.3329228 |
1 | 2.6083691 | 1.7219107 |
1 | 2.609068 | 2.4104897 |
1 | 2.6328854 | 1.4587599 |
1 | 2.6469687 | 1.7014709 |
1 | 2.6920039 | 1.295654 |
1 | 2.6979838 | 2.9314267 |
1 | 2.7126542 | 2.1619493 |
1 | 2.7176177 | 2.6184841 |
1 | 2.720342 | 2.7590754 |
1 | 2.7288016 | 1.8601606 |
1 | 2.7729759 | 2.3649024 |
1 | 2.8041777 | 1.8947211 |
1 | 2.8297566 | 2.1058471 |
1 | 2.8568165 | 3.2398304 |
1 | 2.8708006 | 2.5365312 |
1 | 2.8884565 | 2.4983996 |
1 | 2.8940135 | 0.80718637 |
1 | 2.9270099 | 1.4705192 |
1 | 2.933241 | 0.61062 |
1 | 2.9722306 | 1.9105811 |
1 | 2.9772854 | 0.05260017 |
1 | 2.9773797 | 2.4382292 |
1 | 2.980513 | 0.98434561 |
1 | 3.005612 | 2.8833924 |
1 | 3.0089706 | 0.48283347 |
1 | 3.0261818 | 2.8696189 |
1 | 3.0400688 | 2.2351968 |
1 | 3.0647613 | 1.3867858 |
1 | 3.0958156 | 4.7977043 |
1 | 3.0974361 | 0.61238889 |
1 | 3.123407 | 3.2756611 |
1 | 3.140026 | 1.9104996 |
1 | 3.1401996 | 3.0088845 |
1 | 3.1743328 | 2.9899578 |
1 | 3.1808794 | 2.408549 |
1 | 3.1832203 | 1.0703815 |
1 | 3.2276428 | 2.180782 |
1 | 3.2372055 | 1.4413745 |
1 | 3.2952069 | 2.9016304 |
1 | 3.3387983 | 3.2365316 |
1 | 3.3562441 | 3.3595853 |
1 | 3.4416423 | 4.7357497 |
1 | 3.521928 | 2.8651324 |
1 | 3.5249241 | 2.4056552 |
1 | 3.6396121 | 0.74341452 |
1 | 3.6525806 | 4.0596418 |
1 | 3.6773415 | 0.65264229 |
1 | 3.7089812 | 3.4749576 |
1 | 3.7570425 | 2.2789297 |
1 | 3.7990812 | 1.8031089 |
1 | 3.8079212 | 3.2604948 |
1 | 3.8635523 | 3.3065351 |
1 | 3.8826769 | 2.4434805 |
1 | 3.9105801 | 0.0730681 |
1 | 4.0275824 | 2.9110729 |
1 | 4.2610977 | 3.5150765 |
1 | 4.2654032 | 2.5862794 |
1 | 4.3772226 | 3.6939538 |
1 | 4.3862929 | 1.8272327 |
1 | 4.6736332 | 1.4853571 |
2 | 5.9435583 | 7.4739571 |
2 | 5.9739184 | 5.87866 |
2 | 6.187397 | 7.348852 |
2 | 6.2407109 | 6.5518535 |
2 | 6.2436521 | 7.4541242 |
2 | 6.2551838 | 5.5564442 |
2 | 6.285243 | 8.2071673 |
2 | 6.3299446 | 7.0000361 |
2 | 6.3319237 | 8.0936765 |
2 | 6.373557 | 7.8826912 |
2 | 6.464094 | 7.0581829 |
2 | 6.4906742 | 7.3292611 |
2 | 6.5115338 | 7.8535287 |
2 | 6.5659971 | 8.0486414 |
2 | 6.6023175 | 5.9585361 |
2 | 6.6234813 | 6.3907157 |
2 | 6.6445082 | 7.6998504 |
2 | 6.649045 | 7.8849591 |
2 | 6.6584125 | 7.0152807 |
2 | 6.6665508 | 7.4282592 |
2 | 6.6730605 | 8.5942431 |
2 | 6.763729 | 6.2835604 |
2 | 6.7755229 | 8.407463 |
2 | 6.8076254 | 7.658945 |
2 | 6.8276345 | 6.4644596 |
2 | 6.8479234 | 5.756862 |
2 | 6.856574 | 6.503814 |
2 | 6.8622591 | 7.9170009 |
2 | 6.9363758 | 5.2319598 |
2 | 6.943909 | 6.4875439 |
2 | 6.9889206 | 8.611449 |
2 | 7.0165059 | 7.5475354 |
2 | 7.0419705 | 8.8528666 |
2 | 7.102277 | 9.0164613 |
2 | 7.1288555 | 6.7255618 |
2 | 7.1296474 | 7.9023458 |
2 | 7.1553296 | 8.365873 |
2 | 7.1730311 | 6.742746 |
2 | 7.1820635 | 6.0384904 |
2 | 7.2560427 | 8.2301575 |
2 | 7.2981906 | 9.2181469 |
2 | 7.3011218 | 3.9657148 |
2 | 7.301961 | 7.6504424 |
2 | 7.3145947 | 6.2175059 |
2 | 7.3361955 | 9.0435696 |
2 | 7.3803912 | 7.9176344 |
2 | 7.4078596 | 7.5672229 |
2 | 7.40994 | 7.6915476 |
2 | 7.4850186 | 6.672043 |
2 | 7.4965347 | 8.4085449 |
2 | 7.5192183 | 7.1697117 |
2 | 7.5647357 | 8.0321895 |
2 | 7.5648727 | 8.5589759 |
2 | 7.6015189 | 4.0994906 |
2 | 7.603581 | 8.3790253 |
2 | 7.6099817 | 5.1638026 |
2 | 7.6206807 | 7.6087325 |
2 | 7.6345994 | 7.1531639 |
2 | 7.6429483 | 8.3542054 |
2 | 7.6724078 | 6.4637002 |
2 | 7.7092349 | 6.7151763 |
2 | 7.714601 | 5.8089865 |
2 | 7.7182087 | 5.8359403 |
2 | 7.7245 | 6.2597278 |
2 | 7.7385045 | 6.4247141 |
2 | 7.770265 | 7.7400903 |
2 | 7.8110738 | 6.4712292 |
2 | 7.8312662 | 5.5418477 |
2 | 7.8319838 | 6.9931978 |
2 | 7.8578799 | 7.0934209 |
2 | 7.8853276 | 7.0234515 |
2 | 7.913638 | 7.5415647 |
2 | 7.9267408 | 6.7133325 |
2 | 8.018074 | 7.6140025 |
2 | 8.0184744 | 7.045611 |
2 | 8.0412225 | 6.2239493 |
2 | 8.0485496 | 7.0632895 |
2 | 8.0518117 | 6.0080764 |
2 | 8.0664894 | 7.1414022 |
2 | 8.0949584 | 7.125697 |
2 | 8.101395 | 7.8750952 |
2 | 8.1235131 | 6.6977035 |
2 | 8.1394266 | 6.110125 |
2 | 8.1673507 | 6.731084 |
2 | 8.1958179 | 7.1986208 |
2 | 8.2270168 | 8.334217 |
2 | 8.2319251 | 7.5158861 |
2 | 8.2327407 | 7.0726365 |
2 | 8.2746275 | 6.693953 |
2 | 8.2802248 | 4.3492874 |
2 | 8.307973 | 6.5744575 |
2 | 8.4089124 | 6.1652054 |
2 | 8.4206061 | 5.1979654 |
2 | 8.4332237 | 7.4580566 |
2 | 8.4413669 | 6.0914636 |
2 | 8.4696749 | 6.8581128 |
2 | 8.4830634 | 9.2508174 |
2 | 8.4864111 | 5.7290216 |
2 | 8.4928201 | 8.746028 |
2 | 8.4952661 | 5.12129 |
2 | 8.4990939 | 8.0108213 |
2 | 8.5146056 | 7.6430751 |
2 | 8.5521972 | 6.328596 |
2 | 8.574167 | 7.0679398 |
2 | 8.5811656 | 5.0079888 |
2 | 8.5818258 | 7.1019273 |
2 | 8.6091367 | 6.5752111 |
2 | 8.6246849 | 6.5365028 |
2 | 8.6642143 | 6.4458003 |
2 | 8.6691018 | 8.7915455 |
2 | 8.7002922 | 8.6383879 |
2 | 8.7120615 | 6.794039 |
2 | 8.7644048 | 6.8808288 |
2 | 8.7934826 | 5.4950836 |
2 | 8.9684594 | 8.0053487 |
2 | 8.9714406 | 5.2756851 |
2 | 8.9788712 | 7.9465767 |
2 | 9.0029676 | 5.9771513 |
2 | 9.024769 | 4.9830776 |
2 | 9.108955 | 8.0022074 |
2 | 9.1667502 | 5.1966235 |
2 | 9.2008513 | 9.2806987 |
2 | 9.2237865 | 7.3287031 |
2 | 9.3157701 | 5.5950945 |
2 | 9.3606768 | 10.1086731 |
2 | 9.5844491 | 7.865713 |
2 | 9.6733525 | 5.6230164 |
2 | 9.682216 | 7.4233843 |
2 | 9.6856208 | 7.310157 |
2 | 9.6906946 | 5.328908 |
2 | 9.7297457 | 8.1547281 |
2 | 12.382204 | 7.6953397 |
3 | -0.53802474 | 14.8670258 |
3 | -0.50977026 | 14.5352805 |
3 | -0.43584458 | 15.831295 |
3 | -0.04882059 | 13.9503718 |
3 | 0.05835481 | 15.557332 |
3 | 0.10288324 | 14.5935174 |
3 | 0.17447523 | 13.0540215 |
3 | 0.19810974 | 14.12201 |
3 | 0.21934452 | 14.0784394 |
3 | 0.23439904 | 14.844791 |
3 | 0.26788561 | 15.209558 |
3 | 0.47250581 | 13.6123102 |
3 | 0.5142698 | 13.4614009 |
3 | 0.54996643 | 14.2768358 |
3 | 0.55418227 | 13.884939 |
3 | 0.60602417 | 15.936468 |
3 | 0.63375978 | 15.206995 |
3 | 0.63673117 | 13.7844843 |
3 | 0.7274187 | 14.0976652 |
3 | 0.78672127 | 13.6171725 |
3 | 0.84069897 | 13.7650607 |
3 | 0.885701 | 15.137431 |
3 | 0.91613686 | 15.233336 |
3 | 0.92942006 | 13.5713626 |
3 | 0.95596944 | 15.535309 |
3 | 0.96854857 | 14.8038184 |
3 | 1.0145628 | 13.2879164 |
3 | 1.0177927 | 15.84433 |
3 | 1.0215634 | 15.765331 |
3 | 1.0319656 | 14.6683734 |
3 | 1.0682963 | 14.1762061 |
3 | 1.0797411 | 15.497518 |
3 | 1.0890363 | 14.7297415 |
3 | 1.1020139 | 14.1104753 |
3 | 1.1111965 | 15.974068 |
3 | 1.1118762 | 15.730051 |
3 | 1.1190241 | 15.626021 |
3 | 1.1290053 | 15.708113 |
3 | 1.1567038 | 13.9859388 |
3 | 1.1642717 | 15.86776 |
3 | 1.1877287 | 14.0277225 |
3 | 1.2417761 | 14.9239422 |
3 | 1.2697233 | 15.58267 |
3 | 1.2805359 | 15.839587 |
3 | 1.315033 | 12.800678 |
3 | 1.3374848 | 14.8847305 |
3 | 1.3436787 | 16.160946 |
3 | 1.3601605 | 14.9220547 |
3 | 1.3804341 | 14.5464206 |
3 | 1.419576 | 13.5611838 |
3 | 1.44766 | 14.7976419 |
3 | 1.4497856 | 15.992422 |
3 | 1.4515913 | 14.246366 |
3 | 1.462917 | 14.0683491 |
3 | 1.469379 | 16.277371 |
3 | 1.476635 | 14.7049207 |
3 | 1.4789768 | 13.7587035 |
3 | 1.4864838 | 12.8367824 |
3 | 1.494347 | 13.4188009 |
3 | 1.4977578 | 15.235316 |
3 | 1.5150408 | 16.469438 |
3 | 1.5465376 | 15.102797 |
3 | 1.5481756 | 15.500124 |
3 | 1.5623819 | 16.11233 |
3 | 1.5657523 | 14.8653065 |
3 | 1.5680518 | 14.7992902 |
3 | 1.5787906 | 14.4795982 |
3 | 1.580711 | 15.634115 |
3 | 1.5882776 | 16.154661 |
3 | 1.6154553 | 14.5561227 |
3 | 1.6240277 | 13.1513374 |
3 | 1.6271007 | 14.9594745 |
3 | 1.6423654 | 14.5207591 |
3 | 1.6532214 | 13.9213972 |
3 | 1.6708971 | 14.0647823 |
3 | 1.6816109 | 15.307332 |
3 | 1.6831495 | 15.753881 |
3 | 1.6909234 | 13.3056743 |
3 | 1.694486 | 13.4031309 |
3 | 1.7029568 | 13.7852089 |
3 | 1.7209245 | 16.160009 |
3 | 1.7554475 | 14.5635625 |
3 | 1.7561105 | 14.1486694 |
3 | 1.7591644 | 16.053899 |
3 | 1.7816041 | 16.754704 |
3 | 1.7876631 | 15.692215 |
3 | 1.8234422 | 14.7212479 |
3 | 1.8262062 | 15.727142 |
3 | 1.8288627 | 15.673864 |
3 | 1.8297793 | 15.458916 |
3 | 1.832603 | 16.074711 |
3 | 1.8353628 | 14.0803144 |
3 | 1.8556235 | 14.6185811 |
3 | 1.8563045 | 15.950317 |
3 | 1.8567533 | 15.230949 |
3 | 1.8755811 | 14.7954 |
3 | 1.8808773 | 16.261579 |
3 | 1.8832988 | 13.9781784 |
3 | 1.8843075 | 14.8027541 |
3 | 1.8905587 | 17.469766 |
3 | 1.8975282 | 15.28635 |
3 | 1.9109833 | 15.301225 |
3 | 1.9144448 | 13.974059 |
3 | 1.9165083 | 16.676352 |
3 | 1.9209176 | 14.7131755 |
3 | 1.9781659 | 16.664901 |
3 | 1.9788063 | 12.9605311 |
3 | 1.9795792 | 15.604285 |
3 | 1.9988977 | 14.3873 |
3 | 2.0085747 | 15.703644 |
3 | 2.0196867 | 17.969208 |
3 | 2.025619 | 15.081437 |
3 | 2.0534619 | 15.705229 |
3 | 2.0547586 | 15.305228 |
3 | 2.0547586 | 15.816871 |
3 | 2.0755392 | 13.3552001 |
3 | 2.075569 | 14.5328423 |
3 | 2.1066715 | 13.9310227 |
3 | 2.1219421 | 13.0786952 |
3 | 2.1325375 | 15.278667 |
3 | 2.1346469 | 14.7929784 |
3 | 2.1377228 | 14.3141014 |
3 | 2.1424518 | 14.0621782 |
3 | 2.163728 | 13.0126414 |
3 | 2.1789909 | 16.545179 |
3 | 2.1910496 | 17.74184 |
3 | 2.192648 | 16.567828 |
3 | 2.2120042 | 14.5149355 |
3 | 2.2236802 | 14.7026045 |
3 | 2.235359 | 16.291386 |
3 | 2.2504888 | 15.255275 |
3 | 2.2849944 | 14.6670767 |
3 | 2.2936236 | 15.04094 |
3 | 2.2943962 | 13.6098342 |
3 | 2.2972952 | 16.044405 |
3 | 2.3159775 | 13.8025205 |
3 | 2.3183388 | 14.7124052 |
3 | 2.3312717 | 14.1945021 |
3 | 2.3332788 | 14.858556 |
3 | 2.3436751 | 15.278825 |
3 | 2.3510198 | 14.4443378 |
3 | 2.3536828 | 14.6918611 |
3 | 2.3762487 | 15.001178 |
3 | 2.3873331 | 14.944966 |
3 | 2.4018079 | 16.336344 |
3 | 2.4049931 | 15.354974 |
3 | 2.4069312 | 15.229606 |
3 | 2.4145946 | 16.865367 |
3 | 2.4298175 | 15.177013 |
3 | 2.4304013 | 16.295831 |
3 | 2.4350526 | 14.2814343 |
3 | 2.4365224 | 15.607422 |
3 | 2.4385972 | 15.113629 |
3 | 2.4395695 | 15.287594 |
3 | 2.4433867 | 14.5672236 |
3 | 2.4581051 | 14.3005269 |
3 | 2.484958 | 14.6122817 |
3 | 2.4855137 | 14.7430907 |
3 | 2.4961756 | 14.0852748 |
3 | 2.4961815 | 14.9774792 |
3 | 2.5060367 | 15.626502 |
3 | 2.5111277 | 15.048125 |
3 | 2.5353022 | 16.006037 |
3 | 2.5477455 | 14.5218191 |
3 | 2.5646723 | 13.5753288 |
3 | 2.6069566 | 14.4928334 |
3 | 2.610661 | 14.2333245 |
3 | 2.6110635 | 16.161409 |
3 | 2.6156599 | 17.24306 |
3 | 2.6157363 | 14.6247648 |
3 | 2.6231143 | 16.467851 |
3 | 2.6303499 | 16.166585 |
3 | 2.6479363 | 14.4927011 |
3 | 2.649848 | 14.9999997 |
3 | 2.6726846 | 16.196404 |
3 | 2.6956556 | 16.338031 |
3 | 2.7507975 | 16.35678 |
3 | 2.8039113 | 15.381728 |
3 | 2.8669884 | 16.926908 |
3 | 2.8952958 | 14.2367016 |
3 | 2.9323323 | 14.425336 |
3 | 2.9469818 | 15.622926 |
3 | 2.9524754 | 14.5783952 |
3 | 2.9781864 | 15.542842 |
3 | 2.9871194 | 13.4396185 |
3 | 3.0319823 | 15.890154 |
3 | 3.0549366 | 14.0793781 |
3 | 3.0848657 | 15.441317 |
3 | 3.0908691 | 15.080454 |
3 | 3.1299154 | 14.4593151 |
3 | 3.1662752 | 16.241106 |
3 | 3.1816155 | 13.5673625 |
3 | 3.2062795 | 14.3081385 |
3 | 3.2424753 | 15.28896 |
3 | 3.2425295 | 15.158123 |
3 | 3.2906467 | 16.072758 |
3 | 3.297312 | 14.8472714 |
3 | 3.2975145 | 15.757499 |
3 | 3.3062086 | 15.421346 |
3 | 3.3323506 | 15.513092 |
3 | 3.3448124 | 14.1347046 |
3 | 3.3474952 | 15.536695 |
3 | 3.4494709 | 16.900892 |
3 | 3.4986571 | 15.600885 |
3 | 3.5130076 | 16.136178 |
3 | 3.5275875 | 16.167535 |
3 | 3.5458203 | 15.827132 |
3 | 3.6357217 | 16.777843 |
3 | 3.6418671 | 15.280765 |
3 | 3.642627 | 14.750893 |
3 | 3.766496 | 15.256047 |
3 | 3.8495488 | 13.0793218 |
3 | 4.1037454 | 15.818065 |
3 | 4.2250822 | 17.607042 |
3 | 4.3813155 | 15.092317 |
3 | 4.634051 | 16.15266 |
3 | 5.0207123 | 15.895823 |
4 | 14.2951741 | 4.950383 |
4 | 14.6426889 | 3.026425 |
4 | 15.3783284 | 1.6677586 |
4 | 15.6610826 | 1.2858431 |
4 | 15.7658667 | 1.2502372 |
4 | 15.8735189 | 3.0070031 |
4 | 15.9202878 | 2.3794615 |
4 | 16.2157376 | 4.0456349 |
4 | 16.2828371 | 4.7614267 |
4 | 16.3416173 | 4.7342967 |
4 | 16.372867 | 4.071573 |
4 | 16.3793344 | 3.4288482 |
4 | 16.4471513 | 1.0290971 |
4 | 16.5507429 | 3.1520108 |
4 | 16.5796525 | 2.3137553 |
4 | 16.6592429 | 1.9047836 |
4 | 16.7027051 | 2.391466 |
4 | 16.7066826 | 2.8575872 |
4 | 16.7665198 | 3.6534996 |
4 | 16.8166826 | 4.0681208 |
4 | 16.8309236 | 3.4234537 |
4 | 16.8705837 | 0.95144045 |
4 | 16.8706565 | 1.4984245 |
4 | 16.8761654 | 3.5287529 |
4 | 16.9085948 | 0.91336718 |
4 | 16.9163915 | 4.4980526 |
4 | 16.9321293 | 4.6884465 |
4 | 16.9635774 | 4.1519153 |
4 | 16.9774131 | 0.71576669 |
4 | 17.005386 | 3.9725339 |
4 | 17.03108 | 2.1899709 |
4 | 17.031303 | 4.3222825 |
4 | 17.03259 | 4.1497509 |
4 | 17.03428 | 4.0453932 |
4 | 17.080447 | 3.3698057 |
4 | 17.083517 | 5.3154411 |
4 | 17.109498 | 0.6949377 |
4 | 17.12784 | 2.1077324 |
4 | 17.143328 | 4.2932866 |
4 | 17.153527 | 0.14745808 |
4 | 17.185165 | 4.6840752 |
4 | 17.186108 | 2.0095029 |
4 | 17.218486 | 0.86943064 |
4 | 17.225788 | 3.6446198 |
4 | 17.230586 | 2.5665214 |
4 | 17.242446 | 2.0842829 |
4 | 17.250058 | 3.6674981 |
4 | 17.256518 | 4.1025102 |
4 | 17.265683 | 1.0045272 |
4 | 17.282189 | 2.5401449 |
4 | 17.302099 | 2.6052738 |
4 | 17.308668 | 5.0612829 |
4 | 17.351454 | 3.9648817 |
4 | 17.353287 | 1.9206918 |
4 | 17.36641 | 1.0461857 |
4 | 17.372119 | 3.0134533 |
4 | 17.373874 | 3.3479411 |
4 | 17.385863 | 4.8749841 |
4 | 17.409758 | 1.4770249 |
4 | 17.429302 | 3.1856019 |
4 | 17.584737 | 4.5193866 |
4 | 17.607137 | 2.7815047 |
4 | 17.612883 | 0.24133727 |
4 | 17.62282 | 2.8538072 |
4 | 17.626709 | 4.3176161 |
4 | 17.631416 | 3.6234233 |
4 | 17.637825 | 0.13733134 |
4 | 17.650459 | 4.6764957 |
4 | 17.65138 | 4.4412149 |
4 | 17.663191 | 4.1562683 |
4 | 17.671364 | 2.1726842 |
4 | 17.676551 | 2.3428428 |
4 | 17.689668 | 0.11834644 |
4 | 17.693096 | 4.0325472 |
4 | 17.696343 | 3.5175537 |
4 | 17.699593 | 1.8767087 |
4 | 17.703645 | 3.631295 |
4 | 17.795686 | 1.7721686 |
4 | 17.809542 | 5.5642634 |
4 | 17.825847 | 2.1371149 |
4 | 17.842786 | 3.3904774 |
4 | 17.84874 | 5.3513859 |
4 | 17.860288 | 5.4784907 |
4 | 17.86037 | 1.8584966 |
4 | 17.869171 | 4.2307423 |
4 | 17.872055 | 3.0749112 |
4 | 17.87257 | 0.23464118 |
4 | 17.910788 | 4.2690191 |
4 | 17.928634 | 2.6359366 |
4 | 17.970335 | 2.8242789 |
4 | 18.036661 | 1.7005158 |
4 | 18.049342 | 2.7664064 |
4 | 18.060166 | 3.2008833 |
4 | 18.060814 | 3.9944114 |
4 | 18.068511 | 3.9511485 |
4 | 18.075475 | 2.162381 |
4 | 18.121069 | 3.024253 |
4 | 18.135204 | 3.2472877 |
4 | 18.137853 | 2.0020879 |
4 | 18.173174 | 3.1480361 |
4 | 18.186386 | 6.2251656 |
4 | 18.200991 | 1.1901514 |
4 | 18.208839 | 3.4279441 |
4 | 18.218948 | 2.7864309 |
4 | 18.221807 | 2.0719514 |
4 | 18.246152 | 4.4355796 |
4 | 18.262461 | 1.9578559 |
4 | 18.268682 | 2.628921 |
4 | 18.290465 | 2.2874838 |
4 | 18.293326 | 3.106079 |
4 | 18.301133 | 3.1777477 |
4 | 18.302882 | 2.2121843 |
4 | 18.307465 | 5.3794084 |
4 | 18.310338 | 2.0792017 |
4 | 18.377903 | 2.5628289 |
4 | 18.432628 | 2.2225798 |
4 | 18.439473 | 2.385765 |
4 | 18.467547 | 3.7781926 |
4 | 18.477121 | 2.6562905 |
4 | 18.501194 | 1.3480532 |
4 | 18.533824 | 3.9138983 |
4 | 18.54175 | 1.9172603 |
4 | 18.548589 | 3.4224972 |
4 | 18.551281 | 4.034822 |
4 | 18.580005 | 1.4249323 |
4 | 18.622936 | 1.6350977 |
4 | 18.635703 | 4.0811729 |
4 | 18.635766 | -0.3160307 |
4 | 18.636906 | 4.1485335 |
4 | 18.640693 | 4.0050765 |
4 | 18.644646 | 1.6398355 |
4 | 18.659895 | 2.7598802 |
4 | 18.6671 | 2.0851933 |
4 | 18.672122 | 0.82188274 |
4 | 18.790655 | 2.9990614 |
4 | 18.791466 | 2.9976649 |
4 | 18.823915 | 4.5021609 |
4 | 18.836958 | 1.770455 |
4 | 18.849023 | 4.0410794 |
4 | 18.875795 | 2.4999431 |
4 | 18.906133 | 4.8123412 |
4 | 18.929987 | 5.0171549 |
4 | 18.943218 | 3.5029935 |
4 | 18.944168 | 3.8880596 |
4 | 18.973628 | 4.3975676 |
4 | 18.977883 | 2.6668553 |
4 | 18.986891 | 2.3156703 |
4 | 18.990816 | 5.0919267 |
4 | 18.998018 | 4.5690895 |
4 | 19.002982 | 1.9423729 |
4 | 19.003167 | 2.1783848 |
4 | 19.02293 | 2.7394457 |
4 | 19.048313 | 4.7878447 |
4 | 19.04935 | 2.9196468 |
4 | 19.102964 | 5.9353623 |
4 | 19.104117 | 1.3553044 |
4 | 19.112408 | 3.44293 |
4 | 19.116913 | 4.7040627 |
4 | 19.117363 | 4.4379922 |
4 | 19.132975 | 3.7215931 |
4 | 19.148421 | 2.8419177 |
4 | 19.157023 | 2.3189264 |
4 | 19.209926 | 5.0647142 |
4 | 19.231745 | 3.1059839 |
4 | 19.243242 | 4.6659826 |
4 | 19.275244 | 2.4509242 |
4 | 19.283633 | 2.0655829 |
4 | 19.31873 | 2.5765372 |
4 | 19.360228 | 0.30690857 |
4 | 19.390107 | 4.4824678 |
4 | 19.391019 | 4.1110448 |
4 | 19.418397 | 2.6016607 |
4 | 19.438045 | 4.2962146 |
4 | 19.502628 | 1.9129491 |
4 | 19.530678 | 4.270917 |
4 | 19.531774 | 2.510775 |
4 | 19.535484 | 5.3496156 |
4 | 19.555906 | 1.8812822 |
4 | 19.574879 | 3.1483826 |
4 | 19.577047 | 5.5748674 |
4 | 19.698119 | 4.5684472 |
4 | 19.712666 | 1.8698348 |
4 | 19.754716 | 1.8842441 |
4 | 19.840546 | 4.1758951 |
4 | 19.875637 | 4.5823763 |
4 | 19.913839 | 3.7236013 |
4 | 19.921435 | 3.992112 |
4 | 19.95051 | 4.507263 |
4 | 19.968837 | 2.8102658 |
4 | 20.372123 | 4.1056244 |
4 | 20.570015 | 6.3520417 |
4 | 20.871862 | 1.2839561 |
5 | 9.776254 | 11.9332623 |
5 | 9.828535 | 13.754768 |
5 | 9.9985099 | 15.006255 |
5 | 10.0332013 | 15.171739 |
5 | 10.3495864 | 14.344629 |
5 | 10.3643301 | 13.307221 |
5 | 10.6308644 | 14.729308 |
5 | 10.6742915 | 14.422276 |
5 | 10.6765912 | 14.957163 |
5 | 10.7242125 | 14.603576 |
5 | 10.7309358 | 14.287858 |
5 | 10.8201135 | 13.317803 |
5 | 11.04405 | 14.326776 |
5 | 11.2843895 | 15.224467 |
5 | 11.3338087 | 16.315561 |
5 | 11.3864874 | 15.430293 |
5 | 11.391851 | 12.6688446 |
5 | 11.4134342 | 15.813134 |
5 | 11.4887595 | 14.338325 |
5 | 11.4927375 | 14.033762 |
5 | 11.5616717 | 15.041559 |
5 | 11.679285 | 14.295844 |
5 | 11.6980917 | 12.8332204 |
5 | 11.7248246 | 13.813209 |
5 | 11.738379 | 16.513935 |
5 | 11.7447018 | 16.612144 |
5 | 11.759245 | 16.425581 |
5 | 11.8174379 | 13.387096 |
5 | 11.8318274 | 16.132314 |
5 | 11.8411981 | 14.775724 |
5 | 11.8657639 | 11.18619 |
5 | 11.9045035 | 12.6292852 |
5 | 11.9060549 | 13.432955 |
5 | 11.9236652 | 12.5085818 |
5 | 11.9246185 | 14.501414 |
5 | 11.9371979 | 14.538343 |
5 | 11.9424162 | 13.669786 |
5 | 11.9436611 | 13.422198 |
5 | 11.954384 | 12.6210745 |
5 | 12.0048745 | 14.647301 |
5 | 12.0093275 | 14.155081 |
5 | 12.0495475 | 14.4833 |
5 | 12.0627556 | 14.23776 |
5 | 12.0848806 | 14.073719 |
5 | 12.0988263 | 14.650373 |
5 | 12.1219141 | 13.029351 |
5 | 12.1366616 | 15.971848 |
5 | 12.1485928 | 14.236786 |
5 | 12.1559942 | 12.9274005 |
5 | 12.1784265 | 12.6347077 |
5 | 12.2007163 | 16.458792 |
5 | 12.2067843 | 14.878027 |
5 | 12.2126233 | 13.627478 |
5 | 12.27771 | 14.301138 |
5 | 12.339495 | 18.147247 |
5 | 12.3421613 | 14.489292 |
5 | 12.3577314 | 13.460453 |
5 | 12.3724251 | 13.838472 |
5 | 12.3996649 | 11.71695 |
5 | 12.4002773 | 10.6913483 |
5 | 12.4324959 | 11.5923088 |
5 | 12.4391638 | 14.273311 |
5 | 12.474673 | 12.1187519 |
5 | 12.4783074 | 12.7469574 |
5 | 12.4828174 | 14.835584 |
5 | 12.5082782 | 13.96041 |
5 | 12.5131746 | 12.1271108 |
5 | 12.5226118 | 16.37399 |
5 | 12.5411115 | 14.970615 |
5 | 12.5478529 | 16.084663 |
5 | 12.5593776 | 14.467168 |
5 | 12.5604301 | 12.6251063 |
5 | 12.5621066 | 11.6151074 |
5 | 12.5639823 | 11.6570201 |
5 | 12.5727543 | 12.2284542 |
5 | 12.5999234 | 15.382793 |
5 | 12.6097383 | 12.6748319 |
5 | 12.6335421 | 13.659876 |
5 | 12.6346179 | 15.120215 |
5 | 12.6394592 | 10.6308142 |
5 | 12.6442026 | 15.402978 |
5 | 12.6624146 | 14.518399 |
5 | 12.6824201 | 15.045062 |
5 | 12.6933922 | 14.000639 |
5 | 12.6988315 | 14.716886 |
5 | 12.7180367 | 14.103054 |
5 | 12.7549039 | 12.4974324 |
5 | 12.7672336 | 14.161612 |
5 | 12.7675093 | 15.396513 |
5 | 12.7926923 | 14.684571 |
5 | 12.8061956 | 14.138528 |
5 | 12.8161585 | 13.744709 |
5 | 12.8442842 | 12.5564664 |
5 | 12.8517083 | 14.048076 |
5 | 12.8798602 | 14.078834 |
5 | 12.894805 | 13.364323 |
5 | 12.897217 | 12.2556095 |
5 | 12.9274089 | 13.295782 |
5 | 12.9540314 | 13.790538 |
5 | 12.9833606 | 13.01958 |
5 | 13.010122 | 12.2967178 |
5 | 13.011117 | 13.84965 |
5 | 13.02912 | 14.488563 |
5 | 13.036761 | 12.4478485 |
5 | 13.037256 | 14.574155 |
5 | 13.063049 | 14.151774 |
5 | 13.090068 | 14.56643 |
5 | 13.094963 | 14.018778 |
5 | 13.10096 | 11.8177448 |
5 | 13.122916 | 13.674656 |
5 | 13.129248 | 14.158393 |
5 | 13.13386 | 10.7555909 |
5 | 13.149812 | 12.2079389 |
5 | 13.152682 | 16.011784 |
5 | 13.176491 | 15.079545 |
5 | 13.178535 | 13.691873 |
5 | 13.183269 | 14.910638 |
5 | 13.215687 | 11.8817595 |
5 | 13.235729 | 11.7945041 |
5 | 13.259081 | 13.087312 |
5 | 13.264561 | 13.029223 |
5 | 13.274332 | 11.8333249 |
5 | 13.330272 | 12.7431158 |
5 | 13.368219 | 12.0200739 |
5 | 13.379084 | 15.194089 |
5 | 13.379872 | 14.124247 |
5 | 13.385792 | 14.179336 |
5 | 13.398364 | 15.606996 |
5 | 13.409342 | 13.693611 |
5 | 13.437678 | 13.926307 |
5 | 13.455588 | 15.845492 |
5 | 13.475238 | 14.791697 |
5 | 13.508271 | 12.4602961 |
5 | 13.527687 | 15.682064 |
5 | 13.536628 | 13.831121 |
5 | 13.542094 | 13.563114 |
5 | 13.545504 | 13.37607 |
5 | 13.547878 | 13.319933 |
5 | 13.553336 | 15.569272 |
5 | 13.557667 | 11.180909 |
5 | 13.582784 | 15.483361 |
5 | 13.590279 | 13.149325 |
5 | 13.634664 | 14.86855 |
5 | 13.639971 | 17.681327 |
5 | 13.643215 | 12.5278489 |
5 | 13.650616 | 14.021068 |
5 | 13.659338 | 15.160969 |
5 | 13.664585 | 13.421214 |
5 | 13.67864 | 9.6651535 |
5 | 13.706178 | 15.788597 |
5 | 13.743804 | 14.332319 |
5 | 13.754485 | 13.600224 |
5 | 13.776854 | 14.299507 |
5 | 13.788332 | 14.461131 |
5 | 13.797314 | 10.9900939 |
5 | 13.812277 | 12.7877808 |
5 | 13.818708 | 13.767132 |
5 | 13.825362 | 13.998126 |
5 | 13.827257 | 13.411798 |
5 | 13.855049 | 16.06313 |
5 | 13.895247 | 11.6882882 |
5 | 13.89677 | 14.241082 |
5 | 13.90694 | 12.3827126 |
5 | 13.931778 | 15.185287 |
5 | 13.935962 | 13.947167 |
5 | 13.936954 | 15.25114 |
5 | 13.958115 | 14.59757 |
5 | 14.026628 | 15.205066 |
5 | 14.037261 | 13.780271 |
5 | 14.061187 | 15.016911 |
5 | 14.097614 | 14.740769 |
5 | 14.099027 | 14.797805 |
5 | 14.1145 | 13.767203 |
5 | 14.131498 | 13.562132 |
5 | 14.170495 | 14.460691 |
5 | 14.188678 | 15.321407 |
5 | 14.191673 | 11.5556509 |
5 | 14.201821 | 14.442701 |
5 | 14.237079 | 11.6778069 |
5 | 14.25179 | 14.030541 |
5 | 14.270079 | 15.044006 |
5 | 14.333913 | 11.3620963 |
5 | 14.35918 | 13.033823 |
5 | 14.361986 | 13.354937 |
5 | 14.365055 | 15.033464 |
5 | 14.365386 | 12.7474302 |
5 | 14.367864 | 14.965754 |
5 | 14.432841 | 15.920374 |
5 | 14.455325 | 13.293297 |
5 | 14.457648 | 14.584263 |
5 | 14.482073 | 12.4698072 |
5 | 14.495794 | 11.2869317 |
5 | 14.520868 | 13.981305 |
5 | 14.601644 | 11.5475595 |
5 | 14.626402 | 13.237819 |
5 | 14.639048 | 13.63884 |
5 | 14.664319 | 14.12114 |
5 | 14.678355 | 14.234852 |
5 | 14.706041 | 15.347441 |
5 | 14.946172 | 14.768173 |
5 | 14.954228 | 13.480191 |
5 | 15.016013 | 16.799353 |
5 | 15.025227 | 14.322595 |
5 | 15.065571 | 15.06146 |
5 | 15.080158 | 13.622466 |
5 | 15.260129 | 13.286994 |
5 | 15.385613 | 15.526589 |
5 | 15.591116 | 16.438186 |
5 | 15.774989 | 15.963467 |
5 | 15.973478 | 14.539765 |
5 | 16.657494 | 11.7015363 |
Parag Kanade/fuzzy ants/Gauss1/headerStatic.h
/********************************************************************//* Ant Class parameters *//* SPEED # amplitude of moves [1,10] *//* P direction Probability to move in the same direction [.5,1] *//* Max carry : Maximum object carrying time [20,200] *//* P load Probability to pick up a single object [0.4,0.8] *//* P destroy probability to destroy a heap of two objects [0,0.6] *//* T remove min. dissimilarity necessary for removing an object *//* from a heap [.1,.2] *//* T create max dissimilarity permitted for creating a heap[.05,.2]*//********************************************************************/ #include <stdio.h>#include <math.h>#include <string.h>#include<stdlib.h>#include <ctype.h>#include <time.h>#define MAXANTS 334#define MAXDATA 1000#define MAXANTSFORHEAPS 90#define MAXITERATIONS 1000#define MAXROWS 64#define MAXCOLS 64#define EXPRUN 10#define Tremove 1.50#define Tcreate 0.5#define Pdrop 0.2#define Pdestroy 0.3#define Pload 0.3#define normalize 0#define EntireHeaps 1#define TcreateForHeaps 0.19#define features 2#define filename "gauss01"#define errThresh 0.1#define dataDump 1#define maxDist 1#define INITIALOBJECTS 75#define OBJINC 10/* some type definitions to make C code a little more readable */#define TRUE 1#define FALSE 0#define n MAXDATA /* number of input vectors */#define s features /* number of features */#define c 5 /* number of clusters */#define TOTRUNS 1 /* number of V's to write out */#define false 0#define true 1#define maha 0#define square 0extern int count;int debugLevel=0;/* To debug the code and verify the correctness of algorithms*/int currHeapCount=0;typedef int BOOLEAN;typedef short TYPE_IN_DATA; /* Type of input binary data */typedef float feature[s]; /* Type of each input; made up of input features */typedef float irisData[s];typedef feature objects[MAXDATA]; /* Type of array holding all inputs */typedef feature center[MAXDATA]; /* Type of array holding cluster centers */typedef float matrix[MAXDATA][MAXDATA];/* Type of the matrix containing membership grades */typedef struct Heap {float Dmax;//maximum dissimilar distanceirisData Ocenter;//center objectfloat Dmean;//mean of the distance between the center and all the objectsirisData Odissim;//most dissimilar objectint x;//x position on the boardint y;//y position on the boardint count;//number of objects in the heapsint disPosition;//most dissimilar objectint objects[MAXDATA];int objCount;}heap;typedef struct Ant{int x;int y;int carrying;int speed;int dir;irisData data;}ant;float orgData[n][s+1];float fcmData[MAXDATA][n][s];int clsCenCount[MAXDATA];int currentRow=0;int currentAntCount=0;int updateAfter=50;int heapSum=0;int minAnts=3;int rowMin=5;typedef struct HeapInfo{int total;int classObj[c];} heapInfo;/*heapInfo info[MAXDATA];*//********************************************************************//***Function decelarations*//********************************************************************//***For ant based algorithm*/void readInput();float computeDistance();float computeDistanceBetween2(irisData a,irisData b);float findMax(float *distance);float value(irisData a);int found(int a , int b);void initialise(int flag);int findObject(int a,int b);void initialiseAnts(int flag);void moveNext(ant* a,int flag);void computeHeapParameters(heap* data,int flag);void pickObject1(ant *a,int position,int flag);void pickObject2(ant *a , int position,int flag);void pickObjectn(ant *a,int position,int flag);void pick(ant *a,int flag);void dropObject(ant* a,int flag);int findInNewheaps(irisData object);void dropObject1(ant* a, int position,int flag);void drop(ant* a,int flag);void move(ant* a,int flag);void iterate(int flag);void dropFinal(int flag);int partition(heap a[], int low,int high);void quickSort( heap A[], int low,int high ) ;void writeClusterInformation(int flag);void initialiseNewHeaps(heap newHeaps[]);int findPosition(int i);void harden(heap newHeaps[]);void harden1();int findPosition1(int );void writeInfo();void addObject1(int ,int);void readFCM(FILE *,FILE *);void readOrg();int findInData(irisData input,int iflag);void adjustBoard(int flag);void writeIncremental(int iteration,int flag);/********************************************************************//***For FCM algorithm*/void GET_INPUTS1(char []);void UMAT( matrix,center,objects);BOOLEAN FINISHED(matrix, float);void CLUSTER( matrix, objects);void Output(char[]);void Fcm();/********************************************************************/
Parag Kanade/fuzzy ants/Gauss1/gauss01.data
Gauss data | |
# | |
-0.46551197 | 1.3396181 |
-0.14154019 | 1.6467355 |
-0.06147374 | 1.910021 |
-0.00960664 | 1.6959237 |
0.13522751 | 2.3371545 |
0.15816343 | 1.74101 |
0.16902868 | 1.7145902 |
0.20321506 | 1.3230994 |
0.24094079 | 1.3069846 |
0.25245225 | 2.1839526 |
0.26993324 | 2.5483323 |
0.28680391 | 1.6052432 |
0.3192367 | 2.2276855 |
0.36114833 | 2.8009784 |
0.4244067 | 1.8634449 |
0.46037797 | 1.4532789 |
0.46098959 | 2.3555875 |
0.48936047 | 1.8126198 |
0.493417 | 0.52432961 |
0.5579586 | 2.0069093 |
0.59517099 | 0.74266104 |
0.601286 | 2.447746 |
0.64249205 | 0.22137058 |
0.64603926 | 2.098612 |
0.68936857 | 2.3436606 |
0.70125847 | 1.9881431 |
0.70954162 | 1.8340884 |
0.71271143 | 1.1911658 |
0.73828501 | 2.9157625 |
0.76121259 | 2.887774 |
0.76300537 | 3.36236 |
0.78715506 | 1.7998882 |
0.79603202 | 1.3837631 |
0.81552587 | 0.7659359 |
0.81671088 | 2.0235945 |
0.83646559 | 1.7292928 |
0.84905869 | 0.90959966 |
0.87280583 | 1.9185033 |
0.93911004 | 2.2377149 |
0.94658989 | 1.8099329 |
0.95071896 | 3.3593771 |
0.95477185 | 0.82422933 |
1.0475351 | 3.7358953 |
1.0483555 | 2.6222619 |
1.0663274 | 2.0772458 |
1.0719789 | 2.3051114 |
1.0841659 | 2.8982847 |
1.0917331 | 1.4965835 |
1.1268271 | 1.7541776 |
1.1308673 | 2.1353612 |
1.1428466 | 2.0972579 |
1.1493513 | 1.8227118 |
1.1819349 | 1.8738619 |
1.1900377 | 1.5835831 |
1.2101874 | 1.8796963 |
1.2181118 | 3.0111068 |
1.2277972 | 2.0808183 |
1.2335498 | 2.9573163 |
1.2448562 | 1.6017201 |
1.2555436 | 1.9472067 |
1.2597352 | 0.95874592 |
1.2601195 | 0.81798378 |
1.2715242 | 0.46185734 |
1.2749423 | 3.2592336 |
1.2888759 | 2.4162943 |
1.319464 | 2.1180977 |
1.3266557 | 1.9249356 |
1.3269461 | 2.8783508 |
1.3458998 | 1.6047048 |
1.3471548 | 2.0660325 |
1.3753515 | 2.4089999 |
1.3793406 | 2.1089793 |
1.3872928 | 3.3455047 |
1.3979966 | 2.3829163 |
1.4001717 | 3.0482038 |
1.4054732 | 1.6215221 |
1.4312392 | 0.79191521 |
1.4354818 | 3.0271297 |
1.4410139 | 2.7986203 |
1.4641202 | 0.58155858 |
1.4646153 | 3.9791516 |
1.5055329 | 1.0990125 |
1.5286615 | 2.6943944 |
1.5534019 | 3.741445 |
1.5735908 | 1.5571016 |
1.5856639 | 0.99127551 |
1.6083411 | 2.3154722 |
1.6167515 | 3.4641362 |
1.6315791 | 2.9447703 |
1.6485825 | 1.9459715 |
1.6558902 | 1.1154736 |
1.6603318 | 2.4801616 |
1.6657018 | 1.9762646 |
1.6740867 | 2.9751515 |
1.7109312 | 1.5716093 |
1.7172934 | 1.9542265 |
1.7245997 | 2.387059 |
1.7280016 | 3.2168608 |
1.7407356 | 1.6770587 |
1.7446611 | 3.8440441 |
1.7479167 | 1.3913499 |
1.7507312 | 2.769599 |
1.7567404 | 1.4447784 |
1.7591262 | 3.9952283 |
1.7610234 | 3.5877581 |
1.7736913 | 1.4399875 |
1.7826518 | 3.1827802 |
1.7882331 | 2.7558682 |
1.8048077 | 1.4894358 |
1.806578 | 2.2980184 |
1.8105734 | 3.0728863 |
1.8132452 | 0.11900227 |
1.8581162 | 2.3816176 |
1.8735926 | 2.1120087 |
1.8771577 | 1.9606585 |
1.8791867 | 0.81713304 |
1.8866894 | 1.5761363 |
1.8881009 | 0.12698201 |
1.8980516 | 2.4640572 |
1.911659 | 0.92031474 |
1.9163593 | 2.2659011 |
1.9217044 | 1.9429349 |
1.9240625 | 1.2683148 |
1.933498 | 0.99443935 |
1.9366692 | 3.0426166 |
1.9572064 | 3.2689621 |
1.987931 | 4.1287767 |
1.9907116 | 1.6489055 |
1.9930155 | 2.6846483 |
2.0011578 | 2.3236036 |
2.0107086 | 2.1802041 |
2.0650972 | 0.62687304 |
2.0760993 | 1.8564104 |
2.076595 | 3.141211 |
2.0797088 | 2.6444816 |
2.0828643 | 2.4026682 |
2.0948837 | 1.8648059 |
2.0985622 | 3.7026465 |
2.0994979 | 4.0382142 |
2.1023642 | 3.2814187 |
2.1102441 | 3.3805769 |
2.1522589 | 1.6625872 |
2.1613626 | 2.6416719 |
2.1760954 | 0.66759943 |
2.1805424 | 2.0442384 |
2.1842685 | 2.5954692 |
2.1891405 | 2.9582391 |
2.1963915 | 2.0430046 |
2.2020264 | 2.176707 |
2.204684 | 0.83693931 |
2.2052541 | 1.7499996 |
2.2066926 | 2.7208274 |
2.2109871 | 0.60017807 |
2.2146996 | 1.399128 |
2.2174554 | 0.72364346 |
2.2304159 | 0.82961734 |
2.2473506 | 1.2875368 |
2.2490397 | 2.1734422 |
2.2519844 | 1.2969987 |
2.2604619 | 0.7826934 |
2.2688021 | 2.0460717 |
2.3082186 | 3.4655713 |
2.337285 | 2.3586476 |
2.3616657 | 2.9431843 |
2.372691 | 1.7305975 |
2.3783937 | 1.3535819 |
2.3816021 | 1.9007384 |
2.3967371 | 1.1569486 |
2.409683 | 2.3595594 |
2.4193469 | 1.0856312 |
2.4234583 | 0.51782552 |
2.4392568 | 3.1463499 |
2.440037 | 3.2618835 |
2.4499319 | 0.4923003 |
2.4582683 | 1.3588849 |
2.4769531 | 3.5814207 |
2.4844316 | 1.9984511 |
2.4845173 | 1.8737064 |
2.4932187 | 1.66146 |
2.5161047 | 2.2298843 |
2.5216744 | 2.9607432 |
2.5229139 | 1.492989 |
2.5270772 | -0.06387469 |
2.5353904 | 0.28615059 |
2.5781225 | 2.5085023 |
2.5789043 | 2.6564247 |
2.5913078 | 3.4678316 |
2.6017795 | 2.3329228 |
2.6083691 | 1.7219107 |
2.609068 | 2.4104897 |
2.6328854 | 1.4587599 |
2.6469687 | 1.7014709 |
2.6920039 | 1.295654 |
2.6979838 | 2.9314267 |
2.7126542 | 2.1619493 |
2.7176177 | 2.6184841 |
2.720342 | 2.7590754 |
2.7288016 | 1.8601606 |
2.7729759 | 2.3649024 |
2.8041777 | 1.8947211 |
2.8297566 | 2.1058471 |
2.8568165 | 3.2398304 |
2.8708006 | 2.5365312 |
2.8884565 | 2.4983996 |
2.8940135 | 0.80718637 |
2.9270099 | 1.4705192 |
2.933241 | 0.61062 |
2.9722306 | 1.9105811 |
2.9772854 | 0.05260017 |
2.9773797 | 2.4382292 |
2.980513 | 0.98434561 |
3.005612 | 2.8833924 |
3.0089706 | 0.48283347 |
3.0261818 | 2.8696189 |
3.0400688 | 2.2351968 |
3.0647613 | 1.3867858 |
3.0958156 | 4.7977043 |
3.0974361 | 0.61238889 |
3.123407 | 3.2756611 |
3.140026 | 1.9104996 |
3.1401996 | 3.0088845 |
3.1743328 | 2.9899578 |
3.1808794 | 2.408549 |
3.1832203 | 1.0703815 |
3.2276428 | 2.180782 |
3.2372055 | 1.4413745 |
3.2952069 | 2.9016304 |
3.3387983 | 3.2365316 |
3.3562441 | 3.3595853 |
3.4416423 | 4.7357497 |
3.521928 | 2.8651324 |
3.5249241 | 2.4056552 |
3.6396121 | 0.74341452 |
3.6525806 | 4.0596418 |
3.6773415 | 0.65264229 |
3.7089812 | 3.4749576 |
3.7570425 | 2.2789297 |
3.7990812 | 1.8031089 |
3.8079212 | 3.2604948 |
3.8635523 | 3.3065351 |
3.8826769 | 2.4434805 |
3.9105801 | 0.0730681 |
4.0275824 | 2.9110729 |
4.2610977 | 3.5150765 |
4.2654032 | 2.5862794 |
4.3772226 | 3.6939538 |
4.3862929 | 1.8272327 |
4.6736332 | 1.4853571 |
5.9435583 | 7.4739571 |
5.9739184 | 5.87866 |
6.187397 | 7.348852 |
6.2407109 | 6.5518535 |
6.2436521 | 7.4541242 |
6.2551838 | 5.5564442 |
6.285243 | 8.2071673 |
6.3299446 | 7.0000361 |
6.3319237 | 8.0936765 |
6.373557 | 7.8826912 |
6.464094 | 7.0581829 |
6.4906742 | 7.3292611 |
6.5115338 | 7.8535287 |
6.5659971 | 8.0486414 |
6.6023175 | 5.9585361 |
6.6234813 | 6.3907157 |
6.6445082 | 7.6998504 |
6.649045 | 7.8849591 |
6.6584125 | 7.0152807 |
6.6665508 | 7.4282592 |
6.6730605 | 8.5942431 |
6.763729 | 6.2835604 |
6.7755229 | 8.407463 |
6.8076254 | 7.658945 |
6.8276345 | 6.4644596 |
6.8479234 | 5.756862 |
6.856574 | 6.503814 |
6.8622591 | 7.9170009 |
6.9363758 | 5.2319598 |
6.943909 | 6.4875439 |
6.9889206 | 8.611449 |
7.0165059 | 7.5475354 |
7.0419705 | 8.8528666 |
7.102277 | 9.0164613 |
7.1288555 | 6.7255618 |
7.1296474 | 7.9023458 |
7.1553296 | 8.365873 |
7.1730311 | 6.742746 |
7.1820635 | 6.0384904 |
7.2560427 | 8.2301575 |
7.2981906 | 9.2181469 |
7.3011218 | 3.9657148 |
7.301961 | 7.6504424 |
7.3145947 | 6.2175059 |
7.3361955 | 9.0435696 |
7.3803912 | 7.9176344 |
7.4078596 | 7.5672229 |
7.40994 | 7.6915476 |
7.4850186 | 6.672043 |
7.4965347 | 8.4085449 |
7.5192183 | 7.1697117 |
7.5647357 | 8.0321895 |
7.5648727 | 8.5589759 |
7.6015189 | 4.0994906 |
7.603581 | 8.3790253 |
7.6099817 | 5.1638026 |
7.6206807 | 7.6087325 |
7.6345994 | 7.1531639 |
7.6429483 | 8.3542054 |
7.6724078 | 6.4637002 |
7.7092349 | 6.7151763 |
7.714601 | 5.8089865 |
7.7182087 | 5.8359403 |
7.7245 | 6.2597278 |
7.7385045 | 6.4247141 |
7.770265 | 7.7400903 |
7.8110738 | 6.4712292 |
7.8312662 | 5.5418477 |
7.8319838 | 6.9931978 |
7.8578799 | 7.0934209 |
7.8853276 | 7.0234515 |
7.913638 | 7.5415647 |
7.9267408 | 6.7133325 |
8.018074 | 7.6140025 |
8.0184744 | 7.045611 |
8.0412225 | 6.2239493 |
8.0485496 | 7.0632895 |
8.0518117 | 6.0080764 |
8.0664894 | 7.1414022 |
8.0949584 | 7.125697 |
8.101395 | 7.8750952 |
8.1235131 | 6.6977035 |
8.1394266 | 6.110125 |
8.1673507 | 6.731084 |
8.1958179 | 7.1986208 |
8.2270168 | 8.334217 |
8.2319251 | 7.5158861 |
8.2327407 | 7.0726365 |
8.2746275 | 6.693953 |
8.2802248 | 4.3492874 |
8.307973 | 6.5744575 |
8.4089124 | 6.1652054 |
8.4206061 | 5.1979654 |
8.4332237 | 7.4580566 |
8.4413669 | 6.0914636 |
8.4696749 | 6.8581128 |
8.4830634 | 9.2508174 |
8.4864111 | 5.7290216 |
8.4928201 | 8.746028 |
8.4952661 | 5.12129 |
8.4990939 | 8.0108213 |
8.5146056 | 7.6430751 |
8.5521972 | 6.328596 |
8.574167 | 7.0679398 |
8.5811656 | 5.0079888 |
8.5818258 | 7.1019273 |
8.6091367 | 6.5752111 |
8.6246849 | 6.5365028 |
8.6642143 | 6.4458003 |
8.6691018 | 8.7915455 |
8.7002922 | 8.6383879 |
8.7120615 | 6.794039 |
8.7644048 | 6.8808288 |
8.7934826 | 5.4950836 |
8.9684594 | 8.0053487 |
8.9714406 | 5.2756851 |
8.9788712 | 7.9465767 |
9.0029676 | 5.9771513 |
9.024769 | 4.9830776 |
9.108955 | 8.0022074 |
9.1667502 | 5.1966235 |
9.2008513 | 9.2806987 |
9.2237865 | 7.3287031 |
9.3157701 | 5.5950945 |
9.3606768 | 10.1086731 |
9.5844491 | 7.865713 |
9.6733525 | 5.6230164 |
9.682216 | 7.4233843 |
9.6856208 | 7.310157 |
9.6906946 | 5.328908 |
9.7297457 | 8.1547281 |
12.382204 | 7.6953397 |
-0.53802474 | 14.8670258 |
-0.50977026 | 14.5352805 |
-0.43584458 | 15.831295 |
-0.04882059 | 13.9503718 |
0.05835481 | 15.557332 |
0.10288324 | 14.5935174 |
0.17447523 | 13.0540215 |
0.19810974 | 14.12201 |
0.21934452 | 14.0784394 |
0.23439904 | 14.844791 |
0.26788561 | 15.209558 |
0.47250581 | 13.6123102 |
0.5142698 | 13.4614009 |
0.54996643 | 14.2768358 |
0.55418227 | 13.884939 |
0.60602417 | 15.936468 |
0.63375978 | 15.206995 |
0.63673117 | 13.7844843 |
0.7274187 | 14.0976652 |
0.78672127 | 13.6171725 |
0.84069897 | 13.7650607 |
0.885701 | 15.137431 |
0.91613686 | 15.233336 |
0.92942006 | 13.5713626 |
0.95596944 | 15.535309 |
0.96854857 | 14.8038184 |
1.0145628 | 13.2879164 |
1.0177927 | 15.84433 |
1.0215634 | 15.765331 |
1.0319656 | 14.6683734 |
1.0682963 | 14.1762061 |
1.0797411 | 15.497518 |
1.0890363 | 14.7297415 |
1.1020139 | 14.1104753 |
1.1111965 | 15.974068 |
1.1118762 | 15.730051 |
1.1190241 | 15.626021 |
1.1290053 | 15.708113 |
1.1567038 | 13.9859388 |
1.1642717 | 15.86776 |
1.1877287 | 14.0277225 |
1.2417761 | 14.9239422 |
1.2697233 | 15.58267 |
1.2805359 | 15.839587 |
1.315033 | 12.800678 |
1.3374848 | 14.8847305 |
1.3436787 | 16.160946 |
1.3601605 | 14.9220547 |
1.3804341 | 14.5464206 |
1.419576 | 13.5611838 |
1.44766 | 14.7976419 |
1.4497856 | 15.992422 |
1.4515913 | 14.246366 |
1.462917 | 14.0683491 |
1.469379 | 16.277371 |
1.476635 | 14.7049207 |
1.4789768 | 13.7587035 |
1.4864838 | 12.8367824 |
1.494347 | 13.4188009 |
1.4977578 | 15.235316 |
1.5150408 | 16.469438 |
1.5465376 | 15.102797 |
1.5481756 | 15.500124 |
1.5623819 | 16.11233 |
1.5657523 | 14.8653065 |
1.5680518 | 14.7992902 |
1.5787906 | 14.4795982 |
1.580711 | 15.634115 |
1.5882776 | 16.154661 |
1.6154553 | 14.5561227 |
1.6240277 | 13.1513374 |
1.6271007 | 14.9594745 |
1.6423654 | 14.5207591 |
1.6532214 | 13.9213972 |
1.6708971 | 14.0647823 |
1.6816109 | 15.307332 |
1.6831495 | 15.753881 |
1.6909234 | 13.3056743 |
1.694486 | 13.4031309 |
1.7029568 | 13.7852089 |
1.7209245 | 16.160009 |
1.7554475 | 14.5635625 |
1.7561105 | 14.1486694 |
1.7591644 | 16.053899 |
1.7816041 | 16.754704 |
1.7876631 | 15.692215 |
1.8234422 | 14.7212479 |
1.8262062 | 15.727142 |
1.8288627 | 15.673864 |
1.8297793 | 15.458916 |
1.832603 | 16.074711 |
1.8353628 | 14.0803144 |
1.8556235 | 14.6185811 |
1.8563045 | 15.950317 |
1.8567533 | 15.230949 |
1.8755811 | 14.7954 |
1.8808773 | 16.261579 |
1.8832988 | 13.9781784 |
1.8843075 | 14.8027541 |
1.8905587 | 17.469766 |
1.8975282 | 15.28635 |
1.9109833 | 15.301225 |
1.9144448 | 13.974059 |
1.9165083 | 16.676352 |
1.9209176 | 14.7131755 |
1.9781659 | 16.664901 |
1.9788063 | 12.9605311 |
1.9795792 | 15.604285 |
1.9988977 | 14.3873 |
2.0085747 | 15.703644 |
2.0196867 | 17.969208 |
2.025619 | 15.081437 |
2.0534619 | 15.705229 |
2.0547586 | 15.305228 |
2.0547586 | 15.816871 |
2.0755392 | 13.3552001 |
2.075569 | 14.5328423 |
2.1066715 | 13.9310227 |
2.1219421 | 13.0786952 |
2.1325375 | 15.278667 |
2.1346469 | 14.7929784 |
2.1377228 | 14.3141014 |
2.1424518 | 14.0621782 |
2.163728 | 13.0126414 |
2.1789909 | 16.545179 |
2.1910496 | 17.74184 |
2.192648 | 16.567828 |
2.2120042 | 14.5149355 |
2.2236802 | 14.7026045 |
2.235359 | 16.291386 |
2.2504888 | 15.255275 |
2.2849944 | 14.6670767 |
2.2936236 | 15.04094 |
2.2943962 | 13.6098342 |
2.2972952 | 16.044405 |
2.3159775 | 13.8025205 |
2.3183388 | 14.7124052 |
2.3312717 | 14.1945021 |
2.3332788 | 14.858556 |
2.3436751 | 15.278825 |
2.3510198 | 14.4443378 |
2.3536828 | 14.6918611 |
2.3762487 | 15.001178 |
2.3873331 | 14.944966 |
2.4018079 | 16.336344 |
2.4049931 | 15.354974 |
2.4069312 | 15.229606 |
2.4145946 | 16.865367 |
2.4298175 | 15.177013 |
2.4304013 | 16.295831 |
2.4350526 | 14.2814343 |
2.4365224 | 15.607422 |
2.4385972 | 15.113629 |
2.4395695 | 15.287594 |
2.4433867 | 14.5672236 |
2.4581051 | 14.3005269 |
2.484958 | 14.6122817 |
2.4855137 | 14.7430907 |
2.4961756 | 14.0852748 |
2.4961815 | 14.9774792 |
2.5060367 | 15.626502 |
2.5111277 | 15.048125 |
2.5353022 | 16.006037 |
2.5477455 | 14.5218191 |
2.5646723 | 13.5753288 |
2.6069566 | 14.4928334 |
2.610661 | 14.2333245 |
2.6110635 | 16.161409 |
2.6156599 | 17.24306 |
2.6157363 | 14.6247648 |
2.6231143 | 16.467851 |
2.6303499 | 16.166585 |
2.6479363 | 14.4927011 |
2.649848 | 14.9999997 |
2.6726846 | 16.196404 |
2.6956556 | 16.338031 |
2.7507975 | 16.35678 |
2.8039113 | 15.381728 |
2.8669884 | 16.926908 |
2.8952958 | 14.2367016 |
2.9323323 | 14.425336 |
2.9469818 | 15.622926 |
2.9524754 | 14.5783952 |
2.9781864 | 15.542842 |
2.9871194 | 13.4396185 |
3.0319823 | 15.890154 |
3.0549366 | 14.0793781 |
3.0848657 | 15.441317 |
3.0908691 | 15.080454 |
3.1299154 | 14.4593151 |
3.1662752 | 16.241106 |
3.1816155 | 13.5673625 |
3.2062795 | 14.3081385 |
3.2424753 | 15.28896 |
3.2425295 | 15.158123 |
3.2906467 | 16.072758 |
3.297312 | 14.8472714 |
3.2975145 | 15.757499 |
3.3062086 | 15.421346 |
3.3323506 | 15.513092 |
3.3448124 | 14.1347046 |
3.3474952 | 15.536695 |
3.4494709 | 16.900892 |
3.4986571 | 15.600885 |
3.5130076 | 16.136178 |
3.5275875 | 16.167535 |
3.5458203 | 15.827132 |
3.6357217 | 16.777843 |
3.6418671 | 15.280765 |
3.642627 | 14.750893 |
3.766496 | 15.256047 |
3.8495488 | 13.0793218 |
4.1037454 | 15.818065 |
4.2250822 | 17.607042 |
4.3813155 | 15.092317 |
4.634051 | 16.15266 |
5.0207123 | 15.895823 |
14.2951741 | 4.950383 |
14.6426889 | 3.026425 |
15.3783284 | 1.6677586 |
15.6610826 | 1.2858431 |
15.7658667 | 1.2502372 |
15.8735189 | 3.0070031 |
15.9202878 | 2.3794615 |
16.2157376 | 4.0456349 |
16.2828371 | 4.7614267 |
16.3416173 | 4.7342967 |
16.372867 | 4.071573 |
16.3793344 | 3.4288482 |
16.4471513 | 1.0290971 |
16.5507429 | 3.1520108 |
16.5796525 | 2.3137553 |
16.6592429 | 1.9047836 |
16.7027051 | 2.391466 |
16.7066826 | 2.8575872 |
16.7665198 | 3.6534996 |
16.8166826 | 4.0681208 |
16.8309236 | 3.4234537 |
16.8705837 | 0.95144045 |
16.8706565 | 1.4984245 |
16.8761654 | 3.5287529 |
16.9085948 | 0.91336718 |
16.9163915 | 4.4980526 |
16.9321293 | 4.6884465 |
16.9635774 | 4.1519153 |
16.9774131 | 0.71576669 |
17.005386 | 3.9725339 |
17.03108 | 2.1899709 |
17.031303 | 4.3222825 |
17.03259 | 4.1497509 |
17.03428 | 4.0453932 |
17.080447 | 3.3698057 |
17.083517 | 5.3154411 |
17.109498 | 0.6949377 |
17.12784 | 2.1077324 |
17.143328 | 4.2932866 |
17.153527 | 0.14745808 |
17.185165 | 4.6840752 |
17.186108 | 2.0095029 |
17.218486 | 0.86943064 |
17.225788 | 3.6446198 |
17.230586 | 2.5665214 |
17.242446 | 2.0842829 |
17.250058 | 3.6674981 |
17.256518 | 4.1025102 |
17.265683 | 1.0045272 |
17.282189 | 2.5401449 |
17.302099 | 2.6052738 |
17.308668 | 5.0612829 |
17.351454 | 3.9648817 |
17.353287 | 1.9206918 |
17.36641 | 1.0461857 |
17.372119 | 3.0134533 |
17.373874 | 3.3479411 |
17.385863 | 4.8749841 |
17.409758 | 1.4770249 |
17.429302 | 3.1856019 |
17.584737 | 4.5193866 |
17.607137 | 2.7815047 |
17.612883 | 0.24133727 |
17.62282 | 2.8538072 |
17.626709 | 4.3176161 |
17.631416 | 3.6234233 |
17.637825 | 0.13733134 |
17.650459 | 4.6764957 |
17.65138 | 4.4412149 |
17.663191 | 4.1562683 |
17.671364 | 2.1726842 |
17.676551 | 2.3428428 |
17.689668 | 0.11834644 |
17.693096 | 4.0325472 |
17.696343 | 3.5175537 |
17.699593 | 1.8767087 |
17.703645 | 3.631295 |
17.795686 | 1.7721686 |
17.809542 | 5.5642634 |
17.825847 | 2.1371149 |
17.842786 | 3.3904774 |
17.84874 | 5.3513859 |
17.860288 | 5.4784907 |
17.86037 | 1.8584966 |
17.869171 | 4.2307423 |
17.872055 | 3.0749112 |
17.87257 | 0.23464118 |
17.910788 | 4.2690191 |
17.928634 | 2.6359366 |
17.970335 | 2.8242789 |
18.036661 | 1.7005158 |
18.049342 | 2.7664064 |
18.060166 | 3.2008833 |
18.060814 | 3.9944114 |
18.068511 | 3.9511485 |
18.075475 | 2.162381 |
18.121069 | 3.024253 |
18.135204 | 3.2472877 |
18.137853 | 2.0020879 |
18.173174 | 3.1480361 |
18.186386 | 6.2251656 |
18.200991 | 1.1901514 |
18.208839 | 3.4279441 |
18.218948 | 2.7864309 |
18.221807 | 2.0719514 |
18.246152 | 4.4355796 |
18.262461 | 1.9578559 |
18.268682 | 2.628921 |
18.290465 | 2.2874838 |
18.293326 | 3.106079 |
18.301133 | 3.1777477 |
18.302882 | 2.2121843 |
18.307465 | 5.3794084 |
18.310338 | 2.0792017 |
18.377903 | 2.5628289 |
18.432628 | 2.2225798 |
18.439473 | 2.385765 |
18.467547 | 3.7781926 |
18.477121 | 2.6562905 |
18.501194 | 1.3480532 |
18.533824 | 3.9138983 |
18.54175 | 1.9172603 |
18.548589 | 3.4224972 |
18.551281 | 4.034822 |
18.580005 | 1.4249323 |
18.622936 | 1.6350977 |
18.635703 | 4.0811729 |
18.635766 | -0.3160307 |
18.636906 | 4.1485335 |
18.640693 | 4.0050765 |
18.644646 | 1.6398355 |
18.659895 | 2.7598802 |
18.6671 | 2.0851933 |
18.672122 | 0.82188274 |
18.790655 | 2.9990614 |
18.791466 | 2.9976649 |
18.823915 | 4.5021609 |
18.836958 | 1.770455 |
18.849023 | 4.0410794 |
18.875795 | 2.4999431 |
18.906133 | 4.8123412 |
18.929987 | 5.0171549 |
18.943218 | 3.5029935 |
18.944168 | 3.8880596 |
18.973628 | 4.3975676 |
18.977883 | 2.6668553 |
18.986891 | 2.3156703 |
18.990816 | 5.0919267 |
18.998018 | 4.5690895 |
19.002982 | 1.9423729 |
19.003167 | 2.1783848 |
19.02293 | 2.7394457 |
19.048313 | 4.7878447 |
19.04935 | 2.9196468 |
19.102964 | 5.9353623 |
19.104117 | 1.3553044 |
19.112408 | 3.44293 |
19.116913 | 4.7040627 |
19.117363 | 4.4379922 |
19.132975 | 3.7215931 |
19.148421 | 2.8419177 |
19.157023 | 2.3189264 |
19.209926 | 5.0647142 |
19.231745 | 3.1059839 |
19.243242 | 4.6659826 |
19.275244 | 2.4509242 |
19.283633 | 2.0655829 |
19.31873 | 2.5765372 |
19.360228 | 0.30690857 |
19.390107 | 4.4824678 |
19.391019 | 4.1110448 |
19.418397 | 2.6016607 |
19.438045 | 4.2962146 |
19.502628 | 1.9129491 |
19.530678 | 4.270917 |
19.531774 | 2.510775 |
19.535484 | 5.3496156 |
19.555906 | 1.8812822 |
19.574879 | 3.1483826 |
19.577047 | 5.5748674 |
19.698119 | 4.5684472 |
19.712666 | 1.8698348 |
19.754716 | 1.8842441 |
19.840546 | 4.1758951 |
19.875637 | 4.5823763 |
19.913839 | 3.7236013 |
19.921435 | 3.992112 |
19.95051 | 4.507263 |
19.968837 | 2.8102658 |
20.372123 | 4.1056244 |
20.570015 | 6.3520417 |
20.871862 | 1.2839561 |
9.776254 | 11.9332623 |
9.828535 | 13.754768 |
9.9985099 | 15.006255 |
10.0332013 | 15.171739 |
10.3495864 | 14.344629 |
10.3643301 | 13.307221 |
10.6308644 | 14.729308 |
10.6742915 | 14.422276 |
10.6765912 | 14.957163 |
10.7242125 | 14.603576 |
10.7309358 | 14.287858 |
10.8201135 | 13.317803 |
11.04405 | 14.326776 |
11.2843895 | 15.224467 |
11.3338087 | 16.315561 |
11.3864874 | 15.430293 |
11.391851 | 12.6688446 |
11.4134342 | 15.813134 |
11.4887595 | 14.338325 |
11.4927375 | 14.033762 |
11.5616717 | 15.041559 |
11.679285 | 14.295844 |
11.6980917 | 12.8332204 |
11.7248246 | 13.813209 |
11.738379 | 16.513935 |
11.7447018 | 16.612144 |
11.759245 | 16.425581 |
11.8174379 | 13.387096 |
11.8318274 | 16.132314 |
11.8411981 | 14.775724 |
11.8657639 | 11.18619 |
11.9045035 | 12.6292852 |
11.9060549 | 13.432955 |
11.9236652 | 12.5085818 |
11.9246185 | 14.501414 |
11.9371979 | 14.538343 |
11.9424162 | 13.669786 |
11.9436611 | 13.422198 |
11.954384 | 12.6210745 |
12.0048745 | 14.647301 |
12.0093275 | 14.155081 |
12.0495475 | 14.4833 |
12.0627556 | 14.23776 |
12.0848806 | 14.073719 |
12.0988263 | 14.650373 |
12.1219141 | 13.029351 |
12.1366616 | 15.971848 |
12.1485928 | 14.236786 |
12.1559942 | 12.9274005 |
12.1784265 | 12.6347077 |
12.2007163 | 16.458792 |
12.2067843 | 14.878027 |
12.2126233 | 13.627478 |
12.27771 | 14.301138 |
12.339495 | 18.147247 |
12.3421613 | 14.489292 |
12.3577314 | 13.460453 |
12.3724251 | 13.838472 |
12.3996649 | 11.71695 |
12.4002773 | 10.6913483 |
12.4324959 | 11.5923088 |
12.4391638 | 14.273311 |
12.474673 | 12.1187519 |
12.4783074 | 12.7469574 |
12.4828174 | 14.835584 |
12.5082782 | 13.96041 |
12.5131746 | 12.1271108 |
12.5226118 | 16.37399 |
12.5411115 | 14.970615 |
12.5478529 | 16.084663 |
12.5593776 | 14.467168 |
12.5604301 | 12.6251063 |
12.5621066 | 11.6151074 |
12.5639823 | 11.6570201 |
12.5727543 | 12.2284542 |
12.5999234 | 15.382793 |
12.6097383 | 12.6748319 |
12.6335421 | 13.659876 |
12.6346179 | 15.120215 |
12.6394592 | 10.6308142 |
12.6442026 | 15.402978 |
12.6624146 | 14.518399 |
12.6824201 | 15.045062 |
12.6933922 | 14.000639 |
12.6988315 | 14.716886 |
12.7180367 | 14.103054 |
12.7549039 | 12.4974324 |
12.7672336 | 14.161612 |
12.7675093 | 15.396513 |
12.7926923 | 14.684571 |
12.8061956 | 14.138528 |
12.8161585 | 13.744709 |
12.8442842 | 12.5564664 |
12.8517083 | 14.048076 |
12.8798602 | 14.078834 |
12.894805 | 13.364323 |
12.897217 | 12.2556095 |
12.9274089 | 13.295782 |
12.9540314 | 13.790538 |
12.9833606 | 13.01958 |
13.010122 | 12.2967178 |
13.011117 | 13.84965 |
13.02912 | 14.488563 |
13.036761 | 12.4478485 |
13.037256 | 14.574155 |
13.063049 | 14.151774 |
13.090068 | 14.56643 |
13.094963 | 14.018778 |
13.10096 | 11.8177448 |
13.122916 | 13.674656 |
13.129248 | 14.158393 |
13.13386 | 10.7555909 |
13.149812 | 12.2079389 |
13.152682 | 16.011784 |
13.176491 | 15.079545 |
13.178535 | 13.691873 |
13.183269 | 14.910638 |
13.215687 | 11.8817595 |
13.235729 | 11.7945041 |
13.259081 | 13.087312 |
13.264561 | 13.029223 |
13.274332 | 11.8333249 |
13.330272 | 12.7431158 |
13.368219 | 12.0200739 |
13.379084 | 15.194089 |
13.379872 | 14.124247 |
13.385792 | 14.179336 |
13.398364 | 15.606996 |
13.409342 | 13.693611 |
13.437678 | 13.926307 |
13.455588 | 15.845492 |
13.475238 | 14.791697 |
13.508271 | 12.4602961 |
13.527687 | 15.682064 |
13.536628 | 13.831121 |
13.542094 | 13.563114 |
13.545504 | 13.37607 |
13.547878 | 13.319933 |
13.553336 | 15.569272 |
13.557667 | 11.180909 |
13.582784 | 15.483361 |
13.590279 | 13.149325 |
13.634664 | 14.86855 |
13.639971 | 17.681327 |
13.643215 | 12.5278489 |
13.650616 | 14.021068 |
13.659338 | 15.160969 |
13.664585 | 13.421214 |
13.67864 | 9.6651535 |
13.706178 | 15.788597 |
13.743804 | 14.332319 |
13.754485 | 13.600224 |
13.776854 | 14.299507 |
13.788332 | 14.461131 |
13.797314 | 10.9900939 |
13.812277 | 12.7877808 |
13.818708 | 13.767132 |
13.825362 | 13.998126 |
13.827257 | 13.411798 |
13.855049 | 16.06313 |
13.895247 | 11.6882882 |
13.89677 | 14.241082 |
13.90694 | 12.3827126 |
13.931778 | 15.185287 |
13.935962 | 13.947167 |
13.936954 | 15.25114 |
13.958115 | 14.59757 |
14.026628 | 15.205066 |
14.037261 | 13.780271 |
14.061187 | 15.016911 |
14.097614 | 14.740769 |
14.099027 | 14.797805 |
14.1145 | 13.767203 |
14.131498 | 13.562132 |
14.170495 | 14.460691 |
14.188678 | 15.321407 |
14.191673 | 11.5556509 |
14.201821 | 14.442701 |
14.237079 | 11.6778069 |
14.25179 | 14.030541 |
14.270079 | 15.044006 |
14.333913 | 11.3620963 |
14.35918 | 13.033823 |
14.361986 | 13.354937 |
14.365055 | 15.033464 |
14.365386 | 12.7474302 |
14.367864 | 14.965754 |
14.432841 | 15.920374 |
14.455325 | 13.293297 |
14.457648 | 14.584263 |
14.482073 | 12.4698072 |
14.495794 | 11.2869317 |
14.520868 | 13.981305 |
14.601644 | 11.5475595 |
14.626402 | 13.237819 |
14.639048 | 13.63884 |
14.664319 | 14.12114 |
14.678355 | 14.234852 |
14.706041 | 15.347441 |
14.946172 | 14.768173 |
14.954228 | 13.480191 |
15.016013 | 16.799353 |
15.025227 | 14.322595 |
15.065571 | 15.06146 |
15.080158 | 13.622466 |
15.260129 | 13.286994 |
15.385613 | 15.526589 |
15.591116 | 16.438186 |
15.774989 | 15.963467 |
15.973478 | 14.539765 |
16.657494 | 11.7015363 |
Parag Kanade/fuzzy ants/Gauss1/gauss.c
#include "headerStatic.h" /*******************************************************************/ /*** Global Variables ***/ irisData data[MAXDATA]; //To hold the data read from the file int count=0; //Count of the total number of data elements int heapCount=0; // Total number of heaps int heapRow=0; // Rows for the second iteration with heaps int newHeapCount=0; // Count of the heaps for the second iteration heap heaps[MAXDATA]; // Data structure to hold the heap information heap newHeaps[MAXDATA]; // Data Structure to hold the new heap information // For the second iteration int board[MAXROWS][MAXCOLS]; // Board on which the objects are located ant ants[MAXANTS]; // Data structure to hold the ants float Dmax=0; // Distance of the most dissimilar object pair int minHeapCount=100000; // Counter to hold the minimum heap count, used only for academic purpose // no use in the algorithm int minPosition; // the minimum heap iteration , only for academic purpose // no use in the algorithm float clsCen[MAXDATA][MAXDATA][s];//to hold the objects after hardening int cenCount[MAXDATA];//to hold the number of objects after hardening /********************************************************************/ /*** Varaibles to normalize the features between 0 and 1 */ float minInput[features], maxInput[features],scale[features],minForHeaps[features],maxForHeaps[features],scaleForHeaps[features]; /********************************************************************/ /** Variables for the FCM algorithm */ int temp[200]; /* for square matrix tests */ float eps,m; matrix U, U1; BOOLEAN stop; center V; objects X; char fname[80]; FILE *fp; int run; float inv_cov[s+1][s+1]; /* inverse of covariance matrix Y */ float Y[s][s]; long rand_index, Random_seed; long state1[52] = { 9347, 3835, 5194, 8310, 346, 535, 5297, 6711, 77, 3834, 668, 4175, 6868, 5890, 9304, 8462, 5269, 920, 65392, 41600, 70119, 91032, 76220, 26245, 4746, 73608, 32823, 63264, 75641, 99104, 36534, 24704, 98255, 72266, 75336, 65152, 7269, 63163, 88471, 27271, 43641, 76649, 47773, 23777, 27491, 35926, 16651, 48652, 89766, 90921, 6056 }; int z; int mins=0; int aveit =0; float mintab[200]; int mincount[200]; long start,end,total; int lCount;//added by parag /********************************************************************/ /********************************************************************//*int lrand48(){return(rand());}void srand48(int a){return;}*//********************************************************************/ /********************************************************************/ /* Function to read the input data set */ /* The file name is assumed to be itest.data */ /* Status: Tested */ /* Output: Data from the file into the "data" (Global) data structure */ /* Output: Count (Global), the count of the number of objects */ /********************************************************************/ void readInput() { FILE *fp; char fname[80]; int i=0,j=0; char ch; sprintf(fname,"%s.data",filename); /* Check if the input file is opened */ if((fp=fopen(fname,"r"))==NULL) { printf("\n Unable to open input file \n"); exit(0); } /*initialise the minimum maximum and the scale */ for(i=0;i<features;i++) { minInput[i]=1000; maxInput[i]=0; minForHeaps[i]=1000; maxForHeaps[i]=0; scale[i]=0; scaleForHeaps[i]=0; } /* Discard leading comments */ ch = 'c'; while (ch != '#') fscanf (fp, "%c", &ch); i=0; /* Parse the file and populate the data structure */ while(!feof(fp)) { for(j=0;j<features;j++) { fscanf(fp,"%f ",&data[i][j]); } fscanf(fp,"\n"); for(j=0;j<features;j++) { if(data[i][j]<minInput[j]) minInput[j]=data[i][j]; if(data[i][j]>maxInput[j]) maxInput[j]=data[i][j]; } i++; } count=i; /* Normailze the feature values in between 0 and 1 */ for(j=0;j<features;j++) { if(minInput[j]!=maxInput[j]) scale[j]=1.0/(maxInput[j]-minInput[j]); else scale[j]=1.0; } for(i=0;i<count;i++) { for(j=0;j<features;j++) data[i][j]=(data[i][j]-minInput[j])*scale[j]; } fclose(fp); return; }//end of function /********************************************************************/ /*Function to compute the eucldiean distance for all input data set */ /* Output : an array conatining the distance of each object with the other */ /********************************************************************/ float computeDistance() { float distance,dist=0; int i=0,j=0,k=0; distance=0; for(j=0;j<count;j++) for(i=0;i<count;i++) { for(k=0;k<features;k++) dist+=sqrt((data[j][k]-data[i][k])*(data[j][k]-data[i][k])); if(distance<dist)distance=dist; dist=0; } return(distance); } /********************************************************************/ /* Function to compute the distance between two objects */ /* Output : Euclidean d istance between the two input objects */ /********************************************************************/ float computeDistanceBetween2(irisData a,irisData b) { float temp=0; int i=0; for(i=0;i<features;i++) temp+=(a[i]-b[i])*(a[i]-b[i]); temp=sqrt(temp); return(temp); } /********************************************************************/ /* Function to find the maximum distance between the input objects*/ /* Output: the maximum distance */ /* Input : The array of distances between objects */ /********************************************************************/ /*float findMax(float *distance) { int i=0,j=0; float max=distance[0]; for(i=0;i<count;i++) for(j=0;j<count;j++) { if(max<distance[i*count+j]) max=distance[i*count+j]; } return(max); }*/ /********************************************************************/ /* Function to compute the value of an object */ /********************************************************************/ float value(irisData a) { int i=0; float temp=0; for(i=0;i<features;i++) temp+=a[i]*a[i]; return(sqrt(temp)); } /********************************************************************/ /* Function to find the object in the data structure */ /* Output : The position of the object in the data */ /* Input : The object */ /********************************************************************/ int findInData(irisData object,int iFlag) { int i=0,lastCount=0,j,position=-1,flag[features],flg;if(iFlag==1)lastCount=MAXDATA;else{}for(i=0;i<lastCount;i++){ for(j=0;j<features;j++) if(fabs(object[j]-data[i][j])<0.00001) flag[j]=1; else { flag[j]=0; break;} flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /* Function to find whether there is an object on the board at a,b */ /* Output : a flag indicating whether an object is found or not */ /* Input : The row and column indicating the board position */ /********************************************************************/ int found(int a , int b) { if(board[a][b]==9) return 1; else return 0; } /********************************************************************/ /* Function to initialize the initial board */ /* Output : None */ /* Global Structures modified : heaps */ /* Input : Flag indicating the iteration 1: First 0: Second */ /********************************************************************/ void initialise(int flag) { int a,b,i=0,k=0; int loopCount,rowCount,colCount; /* Initialize the row, column and number of heaps */ if(flag==1) { loopCount=count; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=lCount; rowCount=heapRow; colCount=heapRow; } /* Initialize the heaps */ for(i=0;i<loopCount;i++) { heaps[i].count=0; heaps[i].x=0; heaps[i].y=0; heaps[i].disPosition=0; heaps[i].Dmax=0; heaps[i].Dmean=0; } for(i=0;i<loopCount;i++) { /*find a board position which is empty*/ do { a=lrand48()%rowCount; b=lrand48()%colCount; } while(found(a,b)); /*Allocate the object to that place and assign a heap to it*/ heaps[i].x=a; heaps[i].y=b; heaps[i].count=1; heaps[i].Dmax=0; heaps[i].Dmean=0; if(flag==1) { heaps[i].objects[0]=i; for(k=0;k<features;k++)heaps[i].Ocenter[k]=data[i][k]; } else { for(k=0;k<features;k++) heaps[i].Ocenter[k]=newHeaps[i].Ocenter[k]; } heaps[i].disPosition=0; board[a][b]=9; if((debugLevel>0)&&(flag==1))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],data[heaps[i].objects[0]][0]); if((debugLevel>0)&&(flag==0))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],newHeaps[i].Ocenter[0]); } /*initialise the initial heap count*/ heapCount=loopCount; currentRow=rowCount; } /********************************************************************/ /* Function to find whether an heap is present at the location a b */ /* Output : Flag indicating the presencs of the heap */ /* Input : Roe and column indicating the board position */ /********************************************************************/ int findObject(int a,int b) { int i; int position=-1; for(i=0;i<heapCount;i++) { if((heaps[i].x==a)&&(heaps[i].y==b)) { position=i; break; } } return(position); } /********************************************************************/ /* Function initialize the ants */ /* Output : None */ /* Input : Flag indicating the iteration */ /* Global Variables Modified : ant, heapCount, heaps, board */ /********************************************************************/ void initialiseAnts(int flag) { int i=0,a=0,b=0,position,j=0,loopCount=0,rowCount,colCount,k=0; if(flag==1) { loopCount=MAXANTS; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=MAXANTSFORHEAPS; rowCount=heapRow; colCount=heapRow; } for(i=0;i<loopCount;i++) { /*generate random positions for the ants*/ a=lrand48()%rowCount; b=lrand48()%colCount; ants[i].x=a; ants[i].y=b; /*Find if an object is present at that position or not*/ if(board[a][b]==9) { ants[i].carrying=1; /*find the heap at that location*/ position=findObject(a,b); if(position==-1) { printf("\n Error in logic: Ant init \n"); //getchar(); break; } else { /*Assign the heap data to the ant data and decrement the heap count*/ if(flag==1){ for(k=0;k<features;k++)ants[i].data[k]=data[heaps[position].objects[0]][k]; }else{for(k=0;k<features;k++)ants[i].data[k]=heaps[position].Ocenter[k];} for(j=position;j<heapCount-1;j++) heaps[j]=heaps[j+1]; heapCount--; } /*Clear the board position */ board[a][b]=-9; } else ants[i].carrying=-1; ants[i].speed=0; ants[i].dir=lrand48()%8; printf("\n Ant %2d X: %2d Y: %2d Carying : %2d ",i,ants[i].x,ants[i].y,ants[i].carrying); } currentAntCount=loopCount; } /********************************************************************/ /* Function to move the ant */ /* Output: None */ /* Input: Ant to be moved and the flag indicating the iteration */ /********************************************************************/ void moveNext(ant* a,int flag) { int rowCount,colCount; /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; } else { rowCount=heapRow; colCount=heapRow; }*/rowCount=currentRow;colCount=currentRow; /*Depending upon the direction move the ant*/ switch (a->dir) { case 0: a->y++; if(a->y>=colCount)a->y=0; break; case 1: a->x--; a->y++;; if(a->x<0)a->x=rowCount-1; if(a->y>=colCount)a->y=0; break; case 2: a->x--; if(a->x<0)a->x=rowCount-1; break; case 3: a->x--; a->y--; if(a->x<0)a->x=rowCount-1; if(a->y<0)a->y=colCount-1; break; case 4: a->y--; if(a->y<0)a->y=colCount-1; break; case 5: a->x++; a->y--; if(a->x>=rowCount)a->x=0; if(a->y<0)a->y=colCount-1; break; case 6: a->x++; if(a->x>=rowCount) a->x=0; break; case 7: a->x++; a->y++; if(a->x>=rowCount)a->x=0; if(a->y>=colCount)a->y=0; break; } }//end of function /********************************************************************/ /* Function to compute the parameters of the heap */ /* Output: None */ /* Input: The heap whose parameters are to be computed iteration flag*/ /********************************************************************/ void computeHeapParameters(heap* heapData,int flag) { int i=0,j=0,k=0,position=0; float distance=0; float Dmean=0.0; float *dis; float featureSum[features]; float max=0; float sum=0; /* init*/ for(k=0;k<features;k++) featureSum[k]=0; /*Compute the distance of each object and find the maximum distance*/ max=0; if(flag==1){ for(j=0;j<heapData->count;j++) for(i=0;i<heapData->count;i++) { for(k=0;k<features;k++) sum+= (data[heapData->objects[j]][k]-data[heapData->objects[i]][k])*(data[heapData->objects[j]][k]-data[heapData->objects[i]][k]); distance=sqrt(sum); if(max<distance) max=distance; sum=0; } /* Assign the maximum distance to the heap */ heapData->Dmax=max;/*Compute the centre object*/for(i=0;i<heapData->count;i++)for(k=0;k<features;k++) featureSum[k]+=data[heapData->objects[i]][k];for(k=0;k<features;k++)heapData->Ocenter[k]=featureSum[k]*1.0/heapData->count; /* Find the mean distance */if((dis=(float *) calloc(heapData->count,sizeof(float)))==NULL){printf("\nUnable to allocate memory in the compute heap parameters procedure\n");exit(0);} for(i=0;i<heapData->count;i++) { Dmean+=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); dis[i]=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); } heapData->Dmean=Dmean*1.0/heapData->count; /*Compute the most dissimilar object*/ max=dis[0]; for(i=1;i<heapData->count;i++) if(max<dis[i]) { max=dis[i]; position=i; } /*Assign the most dissimilar object to the heap variable*/ for(k=0;k<features;k++) heapData->Odissim[k]=data[heapData->objects[position]][k]; heapData->disPosition=position;free(dis); } else{/* Heap Parameters for the second stage */for(k=0;k<features;k++){ heapData->Odissim[k]=heapData->Ocenter[k];}heapData->disPosition=0;heapData->Dmean=0;heapData->Dmax=0;} }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a single object*/ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject1(ant *a,int position,int flag) { int i,k=0; /*Clear the board*/ board[heaps[position].x][heaps[position].y]=-9; /* Assign the data to the ant*/if(flag==1){ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[0]][k];}else {for(k=0;k<features;k++) a->data[k]=heaps[position].Ocenter[k];} a->carrying=1; /*Copy all the heaps remaining heaps in the structure*/ for(i=position;i<heapCount-1;i++) heaps[i]=heaps[i+1]; /*Decrement the heap count*/ heapCount--; }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a two objects */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject2(ant *a , int position,int flag) { float Pdestroy1=-1; int i=0,k=0; /*Compute the probability to destroy the heap*/ Pdestroy1=lrand48()%13*1.0/12.0; /*If the probability is more than Pdestroy then destroy the heap */ if(Pdestroy1<Pdestroy) { /*pick the object randomly*/ i=lrand48()%2; /* Assign the data to the ant */ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[i]][k]; a->carrying=1; /*Correct the heap parameters*/ heaps[position].count=1; heaps[position].objects[0]=heaps[position].objects[1-i]; computeHeapParameters(&heaps[position],flag); } }//end of function /********************************************************************/ /*Function to pick a object from a heap consisting of more than two object */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /********************************************************************/ void pickObjectn(ant *a,int position,int flag) { int i=0,k=0; /*If the criteria is satsfied then pick the object*/ if((computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)*1.0/heaps[position].Dmean)>Tremove) { a->carrying=1; for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[heaps[position].disPosition]][k]; for(i=heaps[position].disPosition;i<heaps[position].count-1;i++) heaps[position].objects[i]=heaps[position].objects[i+1]; heaps[position].count--; computeHeapParameters(&heaps[position],1); } }//end of function /********************************************************************/ /* Function to pick a object */ /********************************************************************/ void pick(ant *a,int flag) { int position=-1,i=0; float Pload1=-1.0; for(i=0;i<heapCount;i++) { /*Check if a heap is present in the eight neighbouring cells*/ if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if Heap is found*/ if(position!=-1) { /* heap or object found.*/ /*Depending upon the number present in the heap call the corresponding routine*/ switch(heaps[i].count) { case 1: Pload1 = lrand48()%151*1.0/150.0; if(Pload1<Pload) { pickObject1(a,position,flag); } break; case 2: pickObject2(a,position,flag); break; default: pickObjectn(a,position,flag); break; } } } /********************************************************************/ /* Function to drop a object to form a new heap */ /* Output: None */ /* Input: Ant, iteration flag */ /* Global Structure modified : heap, heapCount */ /********************************************************************/ void dropObject(ant* a,int flag) { /*Create a new heap*/ int k=0; heaps[heapCount].count=1; heaps[heapCount].x=a->x; heaps[heapCount].y=a->y; heaps[heapCount].Dmax=0; heaps[heapCount].Dmean=0; heaps[heapCount].disPosition=0; for(k=0;k<features;k++) { heaps[heapCount].Odissim[k]=a->data[k]; heaps[heapCount].Ocenter[k]=a->data[k]; } if(flag==1) {heaps[heapCount].objects[0]=findInData(a->data,flag); /*computeHeapParameters(&heaps[heapCount],flag);*/ } computeHeapParameters(&heaps[heapCount],flag); heapCount++; a->carrying=-1; board[a->x][a->y]=9; }//end of function /********************************************************************/ /* Function to find the heap position during the second iteration */ /* Output: position of the heap */ /* Input: object center of the heap that the ant is carrying */ /* Global Structure modified : none */ /********************************************************************/ int findInNewheaps(irisData object) { int position=-1,i,j=0,flag[features],flg; for(i=0;i<newHeapCount;i++) { for(j=0;j<features;j++) { if(fabs(object[j]-newHeaps[i].Ocenter[j])<0.00001) flag[j]=1; else {flag[j]=0;break;} } flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /*Function to drop a object to a heap consisting of a one or more object */ /* Output: none */ /* Input: Ant, position of the heap , iteration flag */ /* Global Structure modified: heaps,newHeaps */ /********************************************************************/ void dropObject1(ant* a, int position,int flag) { int heapPosition=-1,heapPosition1=-1,i,j,k=0; irisData newData,temp; if(flag==1) { /*Add the object to the heap and compute the heap parameters*/ /*if(heaps[position].count==heaps[position].objCount) {if((junk=(int *)realloc(heaps[position].objects,((heaps[position].objCount+OBJINC)*sizeof(int))))==NULL){printf("\n Cannot Allocate memory to the new object for %d heap",position);exit(0);}heaps[position].objects=junk;heaps[position].objCount+=OBJINC;free(junk); }*/ heaps[position].objects[heaps[position].count]=findInData(a->data,flag); heaps[position].count++; computeHeapParameters(&heaps[position],flag); } else { for(k=0;k<features;k++)temp[k]=heaps[position].Ocenter[k]; heapPosition=findInNewheaps(a->data); heapPosition1=findInNewheaps(heaps[position].Ocenter); if(heapPosition==-1||heapPosition1==-1) { printf("\n error in logic:new heaps\n"); //getchar(); return; } for(k=0;k<features;k++) {newData[k]=(newHeaps[heapPosition].Ocenter[k]*newHeaps[heapPosition].count+newHeaps[heapPosition1].Ocenter[k]*newHeaps[heapPosition1].count)*1.0/(newHeaps[heapPosition].count+newHeaps[heapPosition1].count);newHeaps[heapPosition].Ocenter[k]=newData[k];heaps[position].Ocenter[k]=newData[k]; } computeHeapParameters(&heaps[position],flag); for(i=newHeaps[heapPosition].count,j=0;j<newHeaps[heapPosition1].count;i++,j++) { newHeaps[heapPosition].objects[i]=newHeaps[heapPosition1].objects[j]; } newHeaps[heapPosition].count+=newHeaps[heapPosition1].count; for(i=heapPosition1;i<newHeapCount-1;i++) newHeaps[i]=newHeaps[i+1]; newHeapCount--; } a->carrying=-1; }//end of function /********************************************************************/ /* Function to drop a object */ /* Output: None */ /* Input: Ant, iteration flag */ /********************************************************************/ void drop(ant* a,int flag) { int i, position=-1; float Pdrop1=0.0; /*Find whether we have a heap in the neighbourhood of the cell*/ for(i=0;i<heapCount;i++) { if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if a heap is found*/ if(position!=-1) { /*heap or object found.*/ /*Depending on the number of objects present take action*/ switch(heaps[position].count) { /*If criteria is satisfied then drop the object*/ case 1: if(flag==1) { if((computeDistanceBetween2(a->data,data[heaps[position].objects[0]])*1.0/Dmax)<Tcreate) dropObject1(a,position,flag); } else { if((computeDistanceBetween2(a->data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) dropObject1(a,position,flag); } break; default: if(computeDistanceBetween2(a->data,heaps[position].Ocenter)<computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)) dropObject1(a,position,flag); break; } } else { /*Compute the probability to drop the object*/ Pdrop1 = lrand48()%151*1.0/150; if(Pdrop1<Pdrop) dropObject(a,flag); } }//end of function /********************************************************************/ /* Function to move the ant */ /* Output: none */ /* Input: Ant, iteration flag */ /********************************************************************/ void move(ant* a,int flag) { float pDir; /*Check the speed */ if (a->speed!=0) { /*move in the same direction*/ a->speed--; moveNext(a,flag); } else { /*generate the new direction*/ pDir=lrand48()%17*1.0/16.0; if(pDir<.85) { a->dir=lrand48()%8; } else if(pDir>.95) { a->speed=2; } moveNext(a,flag); } } /********************************************************************/ /* Function to simulate the movement of the ants */ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified: minHeapCount, minHeapPosition */ /********************************************************************/ void iterate(int flag) { int i=0,j=0,k=0,loopCount=0; if (flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS; while (i<MAXITERATIONS) { i++; for(j=0;j<loopCount;j++) { move(&ants[j],flag); if(ants[j].carrying==1) { drop(&ants[j],flag); } else { pick(&ants[j],flag); } } if(debugLevel>0){ for(k=0;k<heapCount;k++) for(j=0;j<heapCount;j++) if((k!=j)&&(heaps[k].x==heaps[j].x)&&(heaps[k].y==heaps[j].y)) { printf("\nerror two heaps with same co ordinates %d %d ",k,j); //getchar(); } k=0; for(j=0;j<heapCount;j++) k+=heaps[j].count; } if(heapCount<minHeapCount) { minHeapCount=heapCount; minPosition=i; } if(debugLevel>0) printf("\n i:%d Heap count %d sum %d",i,heapCount,k); else printf("\n i:%d Heap count %d",i,heapCount); heapSum+=heapCount; /*if(i%updateAfter==0) {adjustBoard(flag); writeIncremental(i,flag);heapSum=0;loopCount=currentAntCount; }*/ } }//end of function /********************************************************************/ /*Function to drop the objects carried by the ants after all the iterations*/ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified:none */ /********************************************************************/ void dropFinal(int flag) { int i=0,j=0,position=-1,loopCount=0; /*if(flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS;*/ loopCount=currentAntCount; for(i=0;i<loopCount;i++) { if(ants[i].carrying==1) { if(flag==1) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position,flag); } } else { /*Find if a heap is present */ do { position=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position,flag); position=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position!=-1); } } } }//end of function /********************************************************************/ /* Function for the implementation of QuickSort */ /* Output: none */ /* Input: data structure, low and high indices */ /* Global structure modified:none */ /********************************************************************/ void quickSort( heap A[], int low,int high ) { int mid=0; if(low<high) { mid=partition(A,low,high); quickSort(A,low,mid); quickSort(A,mid+1,high); } } /********************************************************************/ /* Partition routine used by quick sort */ /* Output: partition location */ /* Input: data , low, high */ /* Global structure modified:none */ /********************************************************************/ int partition(heap a[], int low,int high) { heap temp; int x=0,i=0,j=0; i=low; j=high; x=a[low].count; while (1) { while (a[j].count<x) j=j-1; while (a[i].count>x) i=i+1; if(i<j) { temp=a[i]; a[i]=a[j]; a[j--]=temp; } else return(j); } } /********************************************************************/ /* Function used to write the cluster information */ /* Output: none */ /* Input:iteration flag */ /* Global structure modified:none */ /********************************************************************/ void writeClusterInformation(int flag) { FILE *fp=fopen("center.clt","w"); FILE *fp1; FILE *fp2; FILE *fp3; char temp[80]; int i=0,j=0,k=0; int lastCount=0; int rowCount,colCount,antCount; strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp3=fopen(temp,"a"); if(dataDump) {strcpy(temp,"");sprintf(temp,"%sTot.out",filename);fp1=fopen(temp,"a");strcpy(temp,"");sprintf(temp,"%sObj.out",filename);fp2=fopen(temp,"a");if(fp1==NULL||fp2==NULL)printf("\n Error in opening file in the writer Cluster Information routine\n"); } /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; antCount=MAXANTS; } else { rowCount=heapRow; colCount=heapRow; antCount=MAXANTSFORHEAPS; }*/ rowCount=currentRow; colCount=currentRow; antCount=currentAntCount; if(fp==NULL) { printf("\n Unable to open cluster center output file \n"); /*return;*/ exit(0); } /*sort the array according to the count value and write the value of the top three elements*/ if((flag==1)&&(!EntireHeaps)) quickSort(heaps,0,heapCount); if(EntireHeaps) {if(flag==1) lastCount=heapCount;else lastCount=newHeapCount; } else lastCount=c; for(i=0;i<lastCount;i++) { if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",newHeaps[i].Ocenter[k]); fprintf(fp,"\n"); } else { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); fprintf(fp,"\n"); } } if(dataDump) { fprintf(fp1,"\n Information from the Ant Based Algorithm \n"); fprintf(fp1,"\n Important Parameters : Board %d X %d Ants : %d Iterations %d Total Heaps %d ",rowCount,colCount,antCount,MAXITERATIONS,lastCount); } if(flag==0) { if(dataDump) { fprintf(fp1," TCreateForHeaps %f \n",TcreateForHeaps); fprintf(fp2,"\nTotal Heaps : %d\n",heapCount); fprintf(fp2,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); } fprintf(fp3,"\n@ %d\n",lastCount); } else if(dataDump) fprintf(fp1,"\n");if(dataDump) { fprintf(fp1,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); for(i=0;i<lastCount;i++) if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp2,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); } fprintf(fp1," %5d\n",newHeaps[i].count); fprintf(fp2," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp1," %5d\n",heaps[i].count); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]); fprintf(fp1," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]); fprintf(fp1," %5d\n",heaps[i].count); }} if(flag==0) { if(dataDump) fprintf(fp1,"\n Objects in the heaps \n");for(i=0;i<newHeapCount;i++) { if(dataDump) fprintf(fp1,"\n\n Heap %d\n \n",i+1);fprintf(fp3,"# %d %d\n",i ,newHeaps[i].count); for(j=0;j<newHeaps[i].count;j++){ for(k=0;k<features;k++){ fprintf(fp3,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]); if(dataDump) fprintf(fp1,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]);} if(dataDump) fprintf(fp1,"\n"); fprintf(fp3,"\n"); } } } fclose(fp); fclose(fp3); if(dataDump) { fclose(fp1);fclose(fp2); }}//end of flie /********************************************************************/ /* Function to initialise the new heaps */ /* Output: none */ /* Input:new Heap structure */ /* Global structure modified:none */ /********************************************************************/ void initialiseNewHeaps(heap newHeaps[]) { int i=0,j=0; for(i=0;i<lCount;i++) { newHeaps[i].count=0; for(j=0;j<features;j++) newHeaps[i].Ocenter[j]=V[i][j]; newHeaps[i].x=heaps[i].x; newHeaps[i].y=heaps[i].y; } }//end of function /********************************************************************/ /* Function to initialise the new heaps */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ int findPosition(int i) { int j,position=0; for(j=1;j<lCount;j++) { if(U[j][i]>U[position][i]) position=j; } printf("\n Position %d ",position); return(position); }//end of function find position /********************************************************************/ /* Function to add object */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ void addObject(int object,heap * heapPosition) { heapPosition->objects[heapPosition->count]=object; heapPosition->count++; }//end of function add object /********************************************************************/ /* Function to harden the outputs obtained from fcm */ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/ void harden(heap newHeaps[]) { int i,heapPosition=-1,sum=0,j=0; /*initialise the new heaps*/ initialiseNewHeaps(newHeaps); for(i=0;i<count;i++) { heapPosition=findPosition(i); addObject(i,&newHeaps[heapPosition]); } /* To check for degenerate partitions*/ for(i=0;i<lCount;i++) { if(newHeaps[i].count==0){for(j=i;j<lCount-1;j++){newHeaps[j]=newHeaps[j+1];}lCount--;i--;} } newHeapCount=lCount; for(i=0;i<lCount;i++) computeHeapParameters(&newHeaps[i],1); if(debugLevel>0) { for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\n sum = %d",sum);} }//end of function/********************************************************************/ /* Function to initialize the initial parameters for the ant algorithm*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void init() { int i=0,j=0; for(i=0;i<MAXROWS;i++) for(j=0;j<MAXCOLS;j++) board[i][j]=-9; heapCount=0; newHeapCount=0; heapRow=0; minPosition=-1; minHeapCount=100000; for(i=0;i<MAXANTS;i++) { ants[i].carrying=-1; ants[i].x=-1; ants[i].y=-1; ants[i].speed=-1; ants[i].dir=-1; } } /********************************************************************/ /* Function to initialize the initial board */ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void initialiseBoard() { int i,j; for(i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; }/********************************************************************/ /* Function to harden the outputs obtained from fcm(2nd stage)*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: Cluster center , cluster center count*/ /********************************************************************/void harden1() { int i=0,heapPosition=-1; for(i=0;i<heapCount;i++) cenCount[i]=0; for(i=0;i<n;i++) { heapPosition=findPosition1(i); addObject1(i,heapPosition); } writeInfo(); }//end of function/********************************************************************/ /* Function to find to which class the object belongs */ /* Output: Class number */ /* Input: object position */ /* Global Structure Modified: None */ /********************************************************************/int findPosition1(int i) { int j,position=0; for(j=1;j<heapCount;j++) { if(U[j][i]>U[position][i]) position=j; } return(position); }//end of function find position/********************************************************************/ /* Function to Write the output of the hardened objects to file*/ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/void writeInfo(){int i=0,j=0,k=0;FILE *fp=fopen("fcm.out","a");if(fp==NULL){printf("\n Unable to open fcm output file \n");return;}fprintf(fp,"\n@ %d\n",heapCount);for(i=0;i<heapCount;i++){fprintf(fp,"# %d %d\n",i,cenCount[i]);for(j=0;j<cenCount[i];j++){for(k=0;k<s;k++)fprintf(fp,"%8.2f ",clsCen[i][j][k]/scale[k]+minInput[k]);fprintf(fp,"\n");}}fclose(fp);return;}/********************************************************************/ /* Function to add a object to a cluster (2nd stage) */ /* Output: none */ /* Input: object poistion , cluster position */ /* Global Structure Modified: Cluster object and cluster count*/ /*******************************************************************/void addObject1(int object,int heapPosition) { int k=0; for(k=0;k<features;k++) clsCen[heapPosition][cenCount[heapPosition]][k]=X[object][k]; cenCount[heapPosition]++; return; }//end of function add object/********************************************************************/ /* Function to read the original classification of objects */ /* Output: none */ /* Input: none */ /* Global Structure Modified: None */ /*******************************************************************/void readOrg(){int i=0,k=0;char temp[80];FILE *fp;//= fopen(dataname,"r");strcpy(temp,"");sprintf(temp,"%sFull.data",filename);fp=fopen(temp,"r");if(fp==NULL){printf("\n Unable to open full data input file ");exit(0);}for(i=0;i<n;i++){fscanf(fp,"%f ",&orgData[i][0]);for(k=1;k<s+1;k++)fscanf(fp,"%f ",&orgData[i][k]);}return;}// end of function/********************************************************************/ /* Function to classify the objects in different clusters */ /* Output: none */ /* Input: the cluster objects, the original classification, */ /* number of objects in the cluster,file to write the data */ /* Global Structure Modified: None *//********************************************************************/int analysisData(float data[][s],float orgData[n][s+1],int count,FILE * fp){int i=0,j=0,k=0,type=1,max=0;heapInfo info;for(i=0;i<c;i++){info.classObj[i]=0;}info.total=0;info.total=count;for(i=0;i<count;i++)for(j=0;j<n;j++){type=1;for(k=0;k<s;k++)if(fabs(data[i][k]-orgData[j][k+1])>errThresh){type=-1;break;}if(type!=-1){info.classObj[(int)orgData[j][0]-1]++;break;}}max=0;for(k=0;k<c;k++){if(info.classObj[k]>info.classObj[max])max=k;fprintf(fp,"\nClass %d Objects % d ",k+1,info.classObj[k]);}j=0;for(k=0;k<c;k++){if(k!=max)j+=info.classObj[k];}fprintf(fp,"\n Total errors : %d \n",j);return(j);}//end of analyse/********************************************************************/ /* Function to read the cluster information */ /* Output: none */ /* Input: input file pointer , output file pointer */ /* Global Structure Modified: None *//********************************************************************/void readFCM(FILE* fp,FILE *fp1){int i=0,j=0,k=0,l=0;int totalRuns=0,heapCount=0,junk=0,sum=0;char ch;FILE *fp2=fopen("errors.out","a");ch = 'c'; while (ch != '$') fscanf (fp, "%c", &ch);fscanf(fp,"%d\n",&totalRuns);printf("\n total runs %d ",totalRuns);for(l=0;l<totalRuns;l++){fscanf(fp,"%c",&ch);fscanf(fp,"%d\n",&heapCount);fprintf(fp1,"\n \nExperiment %d \n ",l+1);sum=0;for(i=0;i<heapCount;i++){fscanf(fp,"%c",&ch);fscanf(fp," %d %d\n",&junk,&clsCenCount[i]);for(j=0;j<clsCenCount[i];j++)for(k=0;k<s;k++)fscanf(fp,"%f",&fcmData[i][j][k]);fscanf(fp,"\n");fprintf(fp1,"\n\n Heap %d Total Objects %d \n",i+1,clsCenCount[i]);sum+=analysisData(fcmData[i],orgData,clsCenCount[i],fp1);}fprintf(fp2," %3d %3d %3d \n",l,sum,heapCount);}fprintf(fp2,"\n --------------------------\n");fclose(fp2);return;}//end of function/********************************************************************/ /* Function to update the board parameters */ /* Output: none */ /* Input: none */ /* Global Structure Modified: board size, ant count *//********************************************************************/void adjustBoard(int flag){int newRow=0,newAnt=0,antDiff=0,antsKilled=0,i=0,position[MAXANTS],position1=-1,j=0,k=0,a,b; newRow= (int)ceil(sqrt(4.0*heapSum/updateAfter)); newAnt= (int)ceil((heapSum*1.0/updateAfter)*1.0/3.0); if(newAnt<minAnts)newAnt=minAnts; if(newRow<rowMin)newRow=rowMin;antDiff=currentAntCount-newAnt; if((antDiff>0)&&(newAnt>=minAnts)) {for(i=0;i<currentAntCount;i++){if(ants[i].carrying==-1){position[antsKilled++]=i;}} if(antsKilled>=antDiff){for(i=0;i<antDiff;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1];for(k=i+1;k<antsKilled;k++)position[k]--; } currentAntCount=newAnt; }else {for(i=0;i<antsKilled;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1]; for(k=i+1;k<antsKilled;k++)position[k]--; }if(flag==1) { for(i=currentAntCount-1,k=0;k<antDiff-antsKilled;k++,i--) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position1,flag); }else { dropObject(&ants[i],flag); } } } else { //flag is zero 2nd stage /*Find if a heap is present */ do { position1=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position1].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position1,flag); position1=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position1!=-1); }//end else currentAntCount=newAnt;}//end elsecurrentAntCount=newAnt;}//end iffor(i=0;i<newAnt;i++){if((ants[i].x>=newRow)||(ants[i].y>=newRow)) { a=lrand48()%newRow; b=lrand48()%newRow; ants[i].x=a; ants[i].y=b; }} //Done with ants, now adjust the boardif((currentRow>newRow)&&(newRow>=rowMin)){for(i=0;i<heapCount;i++){if((heaps[i].x>=newRow)||(heaps[i].y>=newRow)) {do { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionheaps[i].x=a;heaps[i].y=b;board[a][b]=9;}//end if}//end for for(i=0;i<currentAntCount;i++){if((ants[i].carrying==1)&&((ants[i].x>=newRow)||(ants[i].y>=newRow))){//adjust the ant locationdo { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionants[i].x=a;ants[i].y=b;}//end if}//end for currentRow=newRow;}//end if }//end of function void writeIncremental(int iteration,int flag){FILE *fp=fopen("dump.txt","w");int i=0,j=0,k=0;fprintf(fp,"Stage %d\n",flag);fprintf(fp,"Board %d\n",currentRow);fprintf(fp,"Ants %d\n",currentAntCount);fprintf(fp,"Iteration %d\n",iteration);fprintf(fp,"Heaps %d\n",heapCount); if(flag==0)fprintf(fp,"NewHeapCount %d\n",newHeapCount); fprintf(fp,"Ants\n");for(i=0;i<currentAntCount;i++){fprintf(fp,"%d %d %d %d %d ",ants[i].x,ants[i].y,ants[i].carrying,ants[i].speed,ants[i].dir);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",ants[i].data[k]);fprintf(fp,"\n");}fprintf(fp,"Heaps\n");for(i=0;i<heapCount;i++){fprintf(fp,"%d %d %d %d %8.2f %8.2f \n",heaps[i].x,heaps[i].y,heaps[i].count,heaps[i].disPosition,heaps[i].Dmax,heaps[i].Dmean);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Ocenter[k]);fprintf(fp,"\n");for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Odissim[k]);fprintf(fp,"\n");if(flag==1){for(j=0;j<heaps[i].count;j++)fprintf(fp,"%d ",heaps[i].objects[j]);fprintf(fp,"\n");}}if(flag==0){fprintf(fp,"newHeaps\n");for(i=0;i<newHeapCount;i++){fprintf(fp,"%d\n",newHeaps[i].count);for(j=0;j<newHeaps[i].count;j++)fprintf(fp,"%d ",newHeaps[i].objects[j]);fprintf(fp,"\n");}}fclose(fp);}//end of function/********************************************************************/ /* Function Main */ /********************************************************************/ int main(int argc ,char** argv) { int sum=0,k=0,i=0,j=0; char temp[80]; FILE *fp=fopen("fcm.out","w"); FILE *fp1; FILE *fp2=fopen("antAnalysis.out","a"); FILE *fp3=fopen("fcmAnalysis.out","a"); FILE *fp4=fopen("errors.out","w"); FILE *fp5; fclose(fp4); sprintf(temp,"%sObj.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sTot.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp1=fopen(temp,"w"); fprintf(fp,"\n$%d",EXPRUN); fprintf(fp1,"\n$%d",EXPRUN); fclose(fp); fclose(fp1); if(argc==2)sscanf(argv[1],"%d",&debugLevel); printf("\n Debug level %d\n",debugLevel); for( i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; //Read from the file readInput(); //Compute the distance of all the points if(maxDist) { Dmax=computeDistance(); //Compute the maximum distance fp5=fopen("maxData.txt","w");fprintf(fp5,"%f",Dmax);fclose(fp5); } else {fp5=fopen("maxData.txt","r");fscanf(fp5,"%f",&Dmax);fclose(fp5); } printf("\n %f \n",Dmax); //Initialise the board for(k=0;k<EXPRUN;k++) { init(); sum=0; srand48(state1[k]); initialiseBoard(); initialise(1); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(1); printf("\n %d \n",heapCount); //Simulate the working of ants iterate(1); //drop the objects after all the iterations dropFinal(1); //to verify the correctness for(i=0;i<heapCount;i++) sum+=heaps[i].count; //write the cluster centers to the file writeClusterInformation(1); printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); //getchar(); //Run FCM // heapCount=2973;/* To be commented */ printf("\n\n k %d \n\n",k); Fcm(data); //compute new board size. lCount=heapCount; heapRow=(int)ceil(sqrt(4*heapCount)); newHeapCount=lCount; printf("\n LCount %d newHeapCount %d heap Row %d \n",lCount,newHeapCount,heapRow); //harden the objects harden(newHeaps); //iterate with the heaps as the objects. initialiseBoard(); initialise(0); for(i=0;i<lCount;i++) computeHeapParameters(&heaps[i],0); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(0); printf("\n %d \n",heapCount); //getchar(); //Simulate the working of ants iterate(0); dropFinal(0); writeClusterInformation(0); sum=0; for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); // getchar(); Fcm(data); harden1(); } fp=fopen("fcm.out","a"); fp1=fopen(temp,"a"); fprintf(fp,"\n"); fprintf(fp1,"\n"); fclose(fp); fclose(fp1); fp=fopen("fcm.out","r"); fp1=fopen(temp,"r");printf("\n Before read org\n");readOrg();printf("\nafter read org\n");readFCM(fp1,fp2);printf("\n After 1st read fcm\n");readFCM(fp,fp3);printf("\n After 2 fcm read \n");return(1); }//end of main /****************************************************************/ float NORM(feature , feature); void find_covar(); void Fcm (irisData Data[MAXDATA]) { int i,j,l; FILE *ofile; char temp[80]; int flag=0;//added by parag FILE *iniClsCen=fopen("center.clt","a+"); if(iniClsCen==NULL) { printf("\n Unable to open the initial cluster center file\n"); printf("\n choosing random cluster centers....\n"); flag=1; } strcpy(temp,""); sprintf(temp,"%s.data",filename); strcpy (fname,temp); /* Read from this file */ m=2.0; /* The exponent */ /*GET_INPUTS1(fname);*/ /* read in feature vectors */ for (j=0; j<n ; j++) /* Read File in row-major */ for (i=0; i<s ; i++) /* format */ X[j][i]=Data[j][i]; Random_seed=state1[run];/*randseed*/ srand48(Random_seed); for (run=0;run<TOTRUNS;run++) { //flag=1;//for testing random values if (EntireHeaps) lCount=heapCount; else lCount=c; for(i=0;i<lCount;i++) for(j=0;j<s;j++) V[i][j]=0; for(i=0;i<lCount;i++) { for(l=0;l<s;l++) { if(flag==1) { rand_index = lrand48() % n; V[i][l] = X[rand_index][l]; } else { fscanf(iniClsCen,"%f ",&V[i][l]); } }//end for } eps=0.001; stop = FALSE; /* This loop finds the final cluster center and the corresponding U values */ z = 0; while (stop == FALSE) { z++; UMAT(U,V,X); /** Update the U matrix **/ stop = FINISHED(U1,eps); CLUSTER(U,X); /** Get new cluster center **/ printf("Iteration: %d\n\n", z); } /* end while */ printf("Number of iterations: %d\n\n", z);strcpy(temp,""); sprintf(temp,"%sFCM.out",filename);if(dataDump) Output(temp); /* output the results */ }/*end for*/ if(dataDump) { ofile=fopen(temp,"a"); for (i=0; i <= mins; i++) fprintf(ofile, "Min %d of %10.3f occurred %d times\n", i, mintab[i], mincount[i]); fprintf(ofile, "Average iterations %f\n", (float)aveit/(float)TOTRUNS); fclose(ofile); } }/* end Main */ /* The GET_INPUTS1 procedure opens an input file, reads the number of input vectors, the number of features per vector, the number of clusters, and epsilon, then it reads the input values */ void GET_INPUTS1(char fname[]) //char fname[]; { /* Parameters: fname -- name of file containing input info. */ FILE *infile ;//*fopen(); //char junk[10][80]; char realfname[80]; char ch; char fileName1[80]; //int temp[10], i, j, inputs, outputs, count; int i,j; sprintf (realfname, "%s", fname); /* open input file */ if(normalize==1) strcpy(fileName1,"gtest1.data"); else strcpy(fileName1,fname); if((infile = fopen (fileName1, "r")) == NULL) printf("\n CAN'T OPEN %s\n",realfname); else { ch = 'c'; /* Discard leading comments */ while (ch != '#') fscanf (infile, "%c", &ch); for (j=0; j<n ; j++) /* Read File in row-major */ { /* format */ for (i=0; i<s ; i++) fscanf (infile, "%f", &X[j][i]); /* fscanf (infile, "%d", &temp[1]); */ /* end for */ } /* end for */ fclose(infile); /* close input file */ }/* end else */ } /* end GET_INPUTS1 */ /* The NORM function computes the norm of two vectors, x and v, of dimension s. This gives an indication of the distance between them */ float NORM( feature x, feature v) //feature x, v; { /* Parameters : x -- a local copy of an input vector v -- a local copy of a cluster center */ int i,j; /* loop variable */ double sum; /* the square root of sum is the norm; sum is the sum of the differences squared */ float mat1[s]; float mat2[s]; if (maha) { for (i=0; i<s; i++) mat1[i]=x[i]-v[i]; for(i=0;i<s;i++) { sum =0; for(j=0;j<s;j++) sum += mat1[j] * inv_cov[j][i]; mat2[i] = sum; } sum =0; for(j=0;j<s;j++) sum += mat1[j]*mat2[j]; } else { sum = 0; for(j=0;j<s;j++) sum += (x[j] - v[j])* (x[j] - v[j]); } return (float)(sqrt(sum)); } /* end NORM */ /* The UMAT procedure calculates the updated U matrix according to Bezdek's formula. Its side-effect is the update of the global array U1 */ void UMAT( matrix U,center V, objects X) /*matrix U; center V; objects X;*/ { /* Parameters: U, V, and X: same as in main program */ int i, j, k,l ;/* loop variables *///, class /* class whose cluster center //is closest to pattern k */; float d1,d2,d; float sum; int exact; for (k=0;k<n;k++) { /*printf("\n k %d ",k);*/ exact=false; for (i=0;i<lCount;i++) { sum=0; for (j=0;j<lCount;j++) { d1=NORM(X[k],V[i]); d2=NORM(X[k],V[j]); if(d2!=0) { d= d1/d2; d= d * d;/* pow(d1/d2,2.0/(m-1.0)); */ sum+=d; } else { exact = true; for(l=0;l<lCount;l++) if (l==j) U1[l][k]=1.0; else U1[l][k]=0.0; break; } } if (exact!=true) U1[i][k]=1.0/sum; } } } /* end UMAT */ /* The function FINISHED determines if a termination occurs. If not it updates U with U1, so its side-effect is the potential modification of U */ BOOLEAN FINISHED( matrix U1,float eps) //matrix U1; float eps; { /* Parameters: U1, eps-- same as in main */ float sum; /* sum of squared differences between corresponding elements of U and U1 */ int i,k; /* loop control variabes */ BOOLEAN finished; /* set to true if all corresponding elements are within epsilon */ finished = TRUE; sum = 0; for (i=0; i<lCount; i++) for (k=0; k<n; k++) sum += (U[i][k] - U1[i][k])*(U[i][k]-U1[i][k]); if (sqrt(sum) > eps) { finished = FALSE; for (i=0; i<lCount; i++) for (k=0; k<n; k++) U[i][k] = U1[i][k]; } /* end if */ return finished; } /* end FINISHED */ /* The CLUSTER procedure determines cluster centers in V for the c classes being searched for. The global array V is updated */ void CLUSTER( matrix U, objects X) //matrix U; objects X; { /* Parameters: U, X -- as in main */ int i, j, k; /* loop control variables */ feature num; /* numerator in the cluster center computation formula presented by Bezdek */ float denum; /* denumenator in the obove formula */ for (i=0; i<lCount; i++) { denum = 0; for (j=0; j<s; j++) { num[j] = 0; for (k=0; k<n; k++) num[j] += U[i][k] * U[i][k] * X[k][j]; /* pow(U[i][k],m) * X[k][j]; */ } /* end for */ for (k=0; k<n; k++) denum += U[i][k] * U[i][k]; /* pow(U[i][k],m); */ for (j=0; j<s; j++) V[i][j] = num[j] / denum; } /* end for */ } /* end CLUSTER */ float Compute_Jm(center V, objects X) //center V; //objects X; { int i, k,found; double Jm_value; float u,dik; Jm_value = 0; for (k=0; k<n; k++) { found = FALSE; for (i=0; i<lCount; i++) { dik=NORM(X[k],V[i]); dik=dik*dik; if (dik==0.0) { if (found == FALSE) { u=1.0; found = TRUE; printf("found the case with dik=0\n"); } else { printf("\n cant proceed with this initialization"); exit(1); } } else { if (found != TRUE) u=U1[i][k]; /* get_Uvalue(V,X,dik,k); */ else u=0.0; } Jm_value += u * u * dik;/* pow(u, m) * dik; */ } } return (Jm_value); } /* end Compute_Jm */ /* The Output procedure outputs the U matrix which gives the fuzzy measure of each feature belonging to a cluster center. It also outputs the cluster center for each class */ void Output(char fname[]) //char fname[80]; /* Parameters: U, V -- same as in main */ { int i, j, found; /* loop control variables */ float J2c; if ((fp=fopen(fname,"a"))==NULL) printf("\n CAN'T OPEN %s\n",fname); else { fprintf(fp,"\n The cluster centers are: \n"); fprintf(fp,"\n \n"); for (i=0; i<lCount; i++) { fprintf(fp,"\nCluster center %d: ",i+1); fprintf(fp,"\n"); for (j=0; j<s; j++) fprintf(fp,"%8.7f ",V[i][j]); } /* end for */ fprintf(fp,"\nThe membership grades for the feature vectors are:\n"); for (j=0; j<n; j++) { fprintf(fp,"\n"); for (i=0; i<lCount; i++) fprintf(fp," %8.7f",U[i][j]); } /* end for */ } /* end if */ J2c= Compute_Jm(V,X); found =0; for (i=0;i<= mins; i++){ if ((found == 0) && ((J2c - mintab[i]) < .001) && ((J2c - mintab[i]) > -.001)){ mincount[i]++; found = 1; } } if (found == 0){ mins++; mintab[mins]=J2c; mincount[mins]=1; } fprintf(fp,"\nJ%3.1f = %f", m,J2c); fprintf(fp, "Number of iterations: %d\n\n", z); aveit=aveit + z; fclose(fp); } /***************************************************************/ void find_covar(int m) //int m; { int i,j,k; float mean[s],sum; for (i=0;i<s;i++) mean[i]=0; for (i=0;i<s;i++) for (j=0;j<m;j++) mean[i]+=X[j][i]; for (i=0;i<s;i++) mean[i]/=m; for (i=0;i<s;i++) for (j=0;j<s;j++) { sum=0; for (k=0;k<m;k++) sum+=(X[k][i]-mean[i])*(X[k][j]-mean[j]); Y[i][j]=sum/m; } }
Parag Kanade/fuzzy ants/3D Board/header_z3.h
/********************************************************************//* Ant Class parameters *//* SPEED # amplitude of moves [1,10] *//* P direction Probability to move in the same direction [.5,1] *//* Max carry : Maximum object carrying time [20,200] *//* P load Probability to pick up a single object [0.4,0.8] *//* P destroy probability to destroy a heap of two objects [0,0.6] *//* T remove min. dissimilarity necessary for removing an object *//* from a heap [.1,.2] *//* T create max dissimilarity permitted for creating a heap[.05,.2]*//********************************************************************/ #include <stdio.h>#include <math.h>#include <string.h>#include<stdlib.h>#include <ctype.h>#include <time.h>#define MAXANTS 50#define MAXDATA 150#define MAXANTSFORHEAPS 10#define MAXITERATIONS 1000#define MAXROWS 17#define MAXCOLS 17#define zDim 3#define EXPRUN 50#define Tremove 1.50#define Tcreate 0.5#define Pdrop 0.2#define Pdestroy 0.3#define Pload 0.3#define normalize 0#define EntireHeaps 1#define TcreateForHeaps 0.12#define features 4#define filename "iris"#define errThresh 0.1#define dataDump 1#define maxDist 0#define INITIALOBJECTS 75#define OBJINC 10/* some type definitions to make C code a little more readable */#define TRUE 1#define FALSE 0#define n MAXDATA /* number of input vectors */#define s features /* number of features */#define c 3 /* number of clusters */#define TOTRUNS 1 /* number of V's to write out */#define false 0#define true 1#define maha 0#define square 0extern int count;int debugLevel=0;/* To debug the code and verify the correctness of algorithms*/int currHeapCount=0;typedef int BOOLEAN;typedef short TYPE_IN_DATA; /* Type of input binary data */typedef float feature[s]; /* Type of each input; made up of input features */typedef float irisData[s];typedef feature objects[MAXDATA]; /* Type of array holding all inputs */typedef feature center[MAXDATA]; /* Type of array holding cluster centers */typedef float matrix[MAXDATA][MAXDATA];/* Type of the matrix containing membership grades */typedef struct Heap {float Dmax;//maximum dissimilar distanceirisData Ocenter;//center objectfloat Dmean;//mean of the distance between the center and all the objectsirisData Odissim;//most dissimilar objectint x;//x position on the boardint y;//y position on the boardint z;//z position on the boardint count;//number of objects in the heapsint disPosition;//most dissimilar objectint objects[MAXDATA];int objCount;}heap;typedef struct Ant{int x;int y;int z;int carrying;int speed;int dir;irisData data;}ant;float orgData[n][s+1];float fcmData[260][n][s];int clsCenCount[260];int currentRow=0;int currentAntCount=0;int updateAfter=50;int heapSum=0;int minAnts=3;int rowMin=5;typedef struct HeapInfo{int total;int classObj[c];} heapInfo;/*heapInfo info[MAXDATA];*//********************************************************************//***Function decelarations*//********************************************************************//***For ant based algorithm*/void readInput();float computeDistance();float computeDistanceBetween2(irisData a,irisData b);float findMax(float *distance);float value(irisData a);int found(int z,int a , int b);void initialise(int flag);int findObject(int z,int a,int b);void initialiseAnts(int flag);void moveNext(ant* a,int flag);void computeHeapParameters(heap* data,int flag);void pickObject1(ant *a,int position,int flag);int pickObject2(ant *a , int position,int flag);int pickObjectn(ant *a,int position,int flag);void pick(ant *a,int flag);void dropObject(ant* a,int flag);int findInNewheaps(irisData object);void dropObject1(ant* a, int position,int flag);void drop(ant* a,int flag);void move(ant* a,int flag);void iterate(int flag);void dropFinal(int flag);int partition(heap a[], int low,int high);void quickSort( heap A[], int low,int high ) ;void writeClusterInformation(int flag);void initialiseNewHeaps(heap newHeaps[]);int findPosition(int i);void harden(heap newHeaps[]);void harden1();int findPosition1(int );void writeInfo();void addObject1(int ,int);void readFCM(FILE *,FILE *);void readOrg();int findInData(irisData input,int iflag);void adjustBoard(int flag);void writeIncremental(int iteration,int flag);/********************************************************************//***For FCM algorithm*/void GET_INPUTS1(char []);void UMAT( matrix,center,objects);BOOLEAN FINISHED(matrix, float);void CLUSTER( matrix, objects);void Output(char[]);void Fcm(irisData data[],int stage);float Compute_Jm(center V, objects X);/********************************************************************/
Parag Kanade/fuzzy ants/3D Board/ant_z3.c
#include "header_z3.h" /*******************************************************************/ /*** Global Variables ***/ irisData data[MAXDATA]; //To hold the data read from the file int count=0; //Count of the total number of data elements int heapCount=0; // Total number of heaps int heapRow=0; // Rows for the second iteration with heaps int newHeapCount=0; // Count of the heaps for the second iteration heap heaps[MAXDATA]; // Data structure to hold the heap information heap newHeaps[MAXDATA]; // Data Structure to hold the new heap information // For the second iteration int board[zDim][MAXROWS][MAXCOLS]; // Board on which the objects are located ant ants[MAXANTS]; // Data structure to hold the ants float Dmax=0; // Distance of the most dissimilar object pair int minHeapCount=100000; // Counter to hold the minimum heap count, used only for academic purpose // no use in the algorithm int minPosition; // the minimum heap iteration , only for academic purpose // no use in the algorithm float clsCen[MAXDATA][MAXDATA][s];//to hold the objects after hardening int cenCount[MAXDATA];//to hold the number of objects after hardening /********************************************************************/ /*** Varaibles to normalize the features between 0 and 1 */ float minInput[features], maxInput[features],scale[features],minForHeaps[features],maxForHeaps[features],scaleForHeaps[features]; /********************************************************************/ /** Variables for the FCM algorithm */ int temp[200]; /* for square matrix tests */ float eps,m; matrix U, U1; BOOLEAN stop; center V; objects X; char fname[80]; FILE *fp; int run; float inv_cov[s+1][s+1]; /* inverse of covariance matrix Y */ float Y[s][s]; long rand_index, Random_seed; long state1[52] = { 9347, 3835, 5194, 8310, 346, 535, 5297, 6711, 77, 3834, 668, 4175, 6868, 5890, 9304, 8462, 5269, 920, 65392, 41600, 70119, 91032, 76220, 26245, 4746, 73608, 32823, 63264, 75641, 99104, 36534, 24704, 98255, 72266, 75336, 65152, 7269, 63163, 88471, 27271, 43641, 76649, 47773, 23777, 27491, 35926, 16651, 48652, 89766, 90921, 6056 }; int z; int mins=0; int aveit =0; float mintab[200]; int mincount[200]; long start,end,total; int lCount;//added by parag /********************************************************************/ /********************************************************************/ /* Function to read the input data set */ /* The file name is assumed to be itest.data */ /* Status: Tested */ /* Output: Data from the file into the "data" (Global) data structure */ /* Output: Count (Global), the count of the number of objects */ /********************************************************************/ void readInput() { FILE *fp; char fname[80]; int i=0,j=0; char ch; sprintf(fname,"%s.data",filename); /* Check if the input file is opened */ if((fp=fopen(fname,"r"))==NULL) { printf("\n Unable to open input file \n"); exit(0); } /*initialise the minimum maximum and the scale */ for(i=0;i<features;i++) { minInput[i]=1000; maxInput[i]=0; minForHeaps[i]=1000; maxForHeaps[i]=0; scale[i]=0; scaleForHeaps[i]=0; } /* Discard leading comments */ ch = 'c'; while (ch != '#') fscanf (fp, "%c", &ch); i=0; /* Parse the file and populate the data structure */ while(!feof(fp)) { for(j=0;j<features;j++) { fscanf(fp,"%f ",&data[i][j]); } fscanf(fp,"\n"); for(j=0;j<features;j++) { if(data[i][j]<minInput[j]) minInput[j]=data[i][j]; if(data[i][j]>maxInput[j]) maxInput[j]=data[i][j]; } i++; } count=i; /* Normailze the feature values in between 0 and 1 */ for(j=0;j<features;j++) { if(minInput[j]!=maxInput[j]) scale[j]=1.0/(maxInput[j]-minInput[j]); else scale[j]=1.0; } for(i=0;i<count;i++) { for(j=0;j<features;j++) data[i][j]=(data[i][j]-minInput[j])*scale[j]; } fclose(fp); return; }//end of function /********************************************************************/ /*Function to compute the eucldiean distance for all input data set */ /* Output : an array conatining the distance of each object with the other */ /********************************************************************/ float computeDistance() { float distance,dist=0; int i=0,j=0,k=0; distance=0; for(j=0;j<count;j++) for(i=0;i<count;i++) { for(k=0;k<features;k++) dist+=sqrt((data[j][k]-data[i][k])*(data[j][k]-data[i][k])); if(distance<dist)distance=dist; dist=0; } return(distance); } /********************************************************************/ /* Function to compute the distance between two objects */ /* Output : Euclidean d istance between the two input objects */ /********************************************************************/ float computeDistanceBetween2(irisData a,irisData b) { float temp=0; int i=0; for(i=0;i<features;i++) temp+=(a[i]-b[i])*(a[i]-b[i]); temp=sqrt(temp); return(temp); } /********************************************************************/ /* Function to compute the value of an object */ /********************************************************************/ float value(irisData a) { int i=0; float temp=0; for(i=0;i<features;i++) temp+=a[i]*a[i]; return(sqrt(temp)); } /********************************************************************/ /* Function to find the object in the data structure */ /* Output : The position of the object in the data */ /* Input : The object */ /********************************************************************/ int findInData(irisData object,int iFlag) { int i=0,lastCount=0,j,position=-1,flag[features],flg;if(iFlag==1)lastCount=MAXDATA;else{}for(i=0;i<lastCount;i++){ for(j=0;j<features;j++) if(fabs(object[j]-data[i][j])<0.00001) flag[j]=1; else { flag[j]=0; break;} flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /* Function to find whether there is an object on the board at a,b */ /* Output : a flag indicating whether an object is found or not */ /* Input : The row and column indicating the board position */ /********************************************************************/ int found(int z,int a , int b) { if(board[z][a][b]==9) return 1; else return 0; } /********************************************************************/ /* Function to initialize the initial board */ /* Output : None */ /* Global Structures modified : heaps */ /* Input : Flag indicating the iteration 1: First 0: Second */ /********************************************************************/ void initialise(int flag) { int a,b,i=0,k=0,z; int loopCount,rowCount,colCount,zCount; /* Initialize the row, column and number of heaps */ if(flag==1) { loopCount=count; rowCount=MAXROWS; colCount=MAXCOLS; /*zCount=zDim;*/ } else { loopCount=lCount; rowCount=heapRow; colCount=heapRow; /*zCount=heapRow;*/ } zCount=zDim; /* Initialize the heaps */ for(i=0;i<loopCount;i++) { heaps[i].count=0; heaps[i].x=0; heaps[i].y=0; heaps[i].z=0; heaps[i].disPosition=0; heaps[i].Dmax=0; heaps[i].Dmean=0; } for(i=0;i<loopCount;i++) { /*find a board position which is empty*/ do { a=lrand48()%rowCount; b=lrand48()%colCount; z=lrand48()%zCount; } while(found(z,a,b)); /*Allocate the object to that place and assign a heap to it*/ heaps[i].x=a; heaps[i].y=b; heaps[i].z=z; heaps[i].count=1; heaps[i].Dmax=0; heaps[i].Dmean=0; if(flag==1) { heaps[i].objects[0]=i; for(k=0;k<features;k++)heaps[i].Ocenter[k]=data[i][k]; } else { for(k=0;k<features;k++) heaps[i].Ocenter[k]=newHeaps[i].Ocenter[k]; } heaps[i].disPosition=0; board[z][a][b]=9; if((debugLevel>0)&&(flag==1))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],data[heaps[i].objects[0]][0]); if((debugLevel>0)&&(flag==0))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],newHeaps[i].Ocenter[0]); } /*initialise the initial heap count*/ heapCount=loopCount; currentRow=rowCount; } /********************************************************************/ /* Function to find whether an heap is present at the location a b */ /* Output : Flag indicating the presencs of the heap */ /* Input : Roe and column indicating the board position */ /********************************************************************/ int findObject(int z,int a,int b) { int i; int position=-1; for(i=0;i<heapCount;i++) { if((heaps[i].z==z)&&(heaps[i].x==a)&&(heaps[i].y==b)) { position=i; break; } } return(position); } /********************************************************************/ /* Function initialize the ants */ /* Output : None */ /* Input : Flag indicating the iteration */ /* Global Variables Modified : ant, heapCount, heaps, board */ /********************************************************************/ void initialiseAnts(int flag) { int i=0,a=0,b=0,position,j=0,loopCount=0,rowCount,colCount,k=0,z=0,zCount=0; if(flag==1) { loopCount=MAXANTS; rowCount=MAXROWS; colCount=MAXCOLS; /*zCount=zDim;*/ } else { loopCount=MAXANTSFORHEAPS; rowCount=heapRow; colCount=heapRow; /*zCount=heapRow;*/ } zCount=zDim; for(i=0;i<loopCount;i++) { /*generate random positions for the ants*/ a=lrand48()%rowCount; b=lrand48()%colCount; z=lrand48()%zCount; ants[i].x=a; ants[i].y=b; ants[i].z=z; /*Find if an object is present at that position or not*/ if(board[z][a][b]==9) { ants[i].carrying=1; /*find the heap at that location*/ position=findObject(z,a,b); if(position==-1) { printf("\n Error in logic: Ant init \n"); //getchar(); break; } else { /*Assign the heap data to the ant data and decrement the heap count*/ if(flag==1){ for(k=0;k<features;k++)ants[i].data[k]=data[heaps[position].objects[0]][k]; }else{for(k=0;k<features;k++)ants[i].data[k]=heaps[position].Ocenter[k];} for(j=position;j<heapCount-1;j++) heaps[j]=heaps[j+1]; heapCount--; } /*Clear the board position */ board[z][a][b]=-9; } else ants[i].carrying=-1; ants[i].speed=0; ants[i].dir=lrand48()%26; printf("\n Ant %2d X: %2d Y: %2d Z:%2d Carying : %2d ",i,ants[i].x,ants[i].y,ants[i].z,ants[i].carrying); } currentAntCount=loopCount; } /********************************************************************/ /* Function to move the ant */ /* Output: None */ /* Input: Ant to be moved and the flag indicating the iteration */ /********************************************************************/ void moveNext(ant* a,int flag) { int rowCount,colCount,zCount; rowCount=currentRow; colCount=currentRow; /*if(flag==1)zCount=zDim;else zCount=heapRow;*/ zCount=zDim; /*Depending upon the direction move the ant*/ switch (a->dir) { case 0: a->y++; if(a->y>=colCount)a->y=0; break; case 1: a->x--; a->y++; if(a->x<0)a->x=rowCount-1; if(a->y>=colCount)a->y=0; break; case 2: a->x--; if(a->x<0)a->x=rowCount-1; break; case 3: a->x--; a->y--; if(a->x<0)a->x=rowCount-1; if(a->y<0)a->y=colCount-1; break; case 4: a->y--; if(a->y<0)a->y=colCount-1; break; case 5: a->x++; a->y--; if(a->x>=rowCount)a->x=0; if(a->y<0)a->y=colCount-1; break; case 6: a->x++; if(a->x>=rowCount) a->x=0; break; case 7: a->x++; a->y++; if(a->x>=rowCount)a->x=0; if(a->y>=colCount)a->y=0; break; case 8: a->y++; if(a->y>=colCount)a->y=0; a->z--; if(a->z<0)a->z=zCount-1; break; case 9: a->x--; a->y++; a->z--; if(a->z<0)a->z=zCount-1; if(a->x<0)a->x=rowCount-1; if(a->y>=colCount)a->y=0; break; case 10: a->x--; a->z--; if(a->z<0)a->z=zCount-1; if(a->x<0)a->x=rowCount-1; break; case 11: a->x--; a->y--; a->z--; if(a->z<0)a->z=zCount-1; if(a->x<0)a->x=rowCount-1; if(a->y<0)a->y=colCount-1; break; case 12: a->y--; a->z--; if(a->z<0)a->z=zCount-1; if(a->y<0)a->y=colCount-1; break; case 13: a->x++; a->y--; a->z--; if(a->z<0)a->z=zCount-1; if(a->x>=rowCount)a->x=0; if(a->y<0)a->y=colCount-1; break; case 14: a->x++; a->z--; if(a->z<0)a->z=zCount-1; if(a->x>=rowCount) a->x=0; break; case 15: a->x++; a->y++; a->z--; if(a->z<0)a->z=zCount-1; if(a->x>=rowCount)a->x=0; if(a->y>=colCount)a->y=0; break; case 16: a->z--; if(a->z<0)a->z=zCount-1; break; case 17: a->y++; a->z++; if(a->z>=zCount)a->z=0; if(a->y>=colCount)a->y=0; break; case 18: a->x--; a->y++; a->z++; if(a->z>=zCount)a->z=0; if(a->x<0)a->x=rowCount-1; if(a->y>=colCount)a->y=0; break; case 19: a->x--; a->z++; if(a->z>=zCount)a->z=0; if(a->x<0)a->x=rowCount-1; break; case 20: a->x--; a->y--; a->z++; if(a->z>=zCount)a->z=0; if(a->x<0)a->x=rowCount-1; if(a->y<0)a->y=colCount-1; break; case 21: a->y--; a->z++; if(a->z>=zCount)a->z=0; if(a->y<0)a->y=colCount-1; break; case 22: a->x++; a->y--; a->z++; if(a->z>=zCount)a->z=0; if(a->x>=rowCount)a->x=0; if(a->y<0)a->y=colCount-1; break; case 23: a->x++; a->z++; if(a->z>=zCount)a->z=0; if(a->x>=rowCount) a->x=0; break; case 24: a->x++; a->y++; a->z++; if(a->z>=zCount)a->z=0; if(a->x>=rowCount)a->x=0; if(a->y>=colCount)a->y=0; break;case 25: a->z++; if(a->z>=zCount)a->z=0; break;default: break; } }//end of function /********************************************************************/ /* Function to compute the parameters of the heap */ /* Output: None */ /* Input: The heap whose parameters are to be computed iteration flag*/ /********************************************************************/ void computeHeapParameters(heap* heapData,int flag) { int i=0,j=0,k=0,position=0; float distance=0; float Dmean=0.0; float *dis; float featureSum[features]; float max=0; float sum=0; /* init*/ for(k=0;k<features;k++) featureSum[k]=0; /*Compute the distance of each object and find the maximum distance*/ max=0; if(flag==1){ for(j=0;j<heapData->count;j++) for(i=0;i<heapData->count;i++) { for(k=0;k<features;k++) sum+= (data[heapData->objects[j]][k]-data[heapData->objects[i]][k])*(data[heapData->objects[j]][k]-data[heapData->objects[i]][k]); distance=sqrt(sum); if(max<distance) max=distance; sum=0; } /* Assign the maximum distance to the heap */ heapData->Dmax=max;/*Compute the centre object*/for(i=0;i<heapData->count;i++)for(k=0;k<features;k++) featureSum[k]+=data[heapData->objects[i]][k];for(k=0;k<features;k++)heapData->Ocenter[k]=featureSum[k]*1.0/heapData->count; /* Find the mean distance */if((dis=(float *) calloc(heapData->count,sizeof(float)))==NULL){printf("\nUnable to allocate memory in the compute heap parameters procedure\n");exit(0);} for(i=0;i<heapData->count;i++) { Dmean+=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); dis[i]=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); } heapData->Dmean=Dmean*1.0/heapData->count; /*Compute the most dissimilar object*/ max=dis[0]; for(i=1;i<heapData->count;i++) if(max<dis[i]) { max=dis[i]; position=i; } /*Assign the most dissimilar object to the heap variable*/ for(k=0;k<features;k++) heapData->Odissim[k]=data[heapData->objects[position]][k]; heapData->disPosition=position;free(dis); } else{/* Heap Parameters for the second stage */for(k=0;k<features;k++){ heapData->Odissim[k]=heapData->Ocenter[k];}heapData->disPosition=0;heapData->Dmean=0;heapData->Dmax=0;} }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a single object*/ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject1(ant *a,int position,int flag) { int i,k=0; /*Clear the board*/ board[heaps[position].z][heaps[position].x][heaps[position].y]=-9; /* Assign the data to the ant*/if(flag==1){ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[0]][k];}else {for(k=0;k<features;k++) a->data[k]=heaps[position].Ocenter[k];} a->carrying=1; /*Copy all the heaps remaining heaps in the structure*/ for(i=position;i<heapCount-1;i++) heaps[i]=heaps[i+1]; /*Decrement the heap count*/ heapCount--; }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a two objects */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ int pickObject2(ant *a , int position,int flag) { float Pdestroy1=-1; int i=0,k=0; /*Compute the probability to destroy the heap*/ Pdestroy1=lrand48()%13*1.0/12.0; /*If the probability is more than Pdestroy then destroy the heap */ if(Pdestroy1<Pdestroy) { /*pick the object randomly*/ i=lrand48()%2; /* Assign the data to the ant */ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[i]][k]; a->carrying=1; /*Correct the heap parameters*/ heaps[position].count=1; heaps[position].objects[0]=heaps[position].objects[1-i]; computeHeapParameters(&heaps[position],flag); return(1); } else return(0); }//end of function /********************************************************************/ /*Function to pick a object from a heap consisting of more than two object */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /********************************************************************/ int pickObjectn(ant *a,int position,int flag) { int i=0,k=0; /*If the criteria is satsfied then pick the object*/ if((computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)*1.0/heaps[position].Dmean)>Tremove) { a->carrying=1; for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[heaps[position].disPosition]][k]; for(i=heaps[position].disPosition;i<heaps[position].count-1;i++) heaps[position].objects[i]=heaps[position].objects[i+1]; heaps[position].count--; computeHeapParameters(&heaps[position],1); return(1);}elsereturn(0); }//end of function /********************************************************************/ /* Function to pick a object */ /********************************************************************/ void pick(ant *a,int flag) { int position=-1,i=0,j=0; float Pload1=-1.0; int hCount=0,hPos[26],picked=0; for(i=0;i<heapCount;i++) { /*Check if a heap is present in the eight neighbouring cells*/ if(abs(heaps[i].z-a->z)<=1&&abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; hPos[hCount++]=i; /*break;*/ } } /*Check if Heap is found*/ /*if(position!=-1)*/ if(hCount>0) { /* heap or object found.*/ /*Depending upon the number present in the heap call the corresponding routine*/ j=0; while(j<hCount && !picked) { switch(heaps[hPos[j]].count) { case 1: Pload1 = lrand48()%151*1.0/150.0; if(Pload1<Pload) { pickObject1(a,hPos[j],flag);picked=1; }else picked=0; break; case 2: picked=pickObject2(a,hPos[j],flag); break; default: picked=pickObjectn(a,hPos[j],flag); break; }j++;} } } /********************************************************************/ /* Function to drop a object to form a new heap */ /* Output: None */ /* Input: Ant, iteration flag */ /* Global Structure modified : heap, heapCount */ /********************************************************************/ void dropObject(ant* a,int flag) { /*Create a new heap*/ int k=0; heaps[heapCount].count=1; heaps[heapCount].x=a->x; heaps[heapCount].y=a->y; heaps[heapCount].z=a->z; heaps[heapCount].Dmax=0; heaps[heapCount].Dmean=0; heaps[heapCount].disPosition=0; for(k=0;k<features;k++) { heaps[heapCount].Odissim[k]=a->data[k]; heaps[heapCount].Ocenter[k]=a->data[k]; } if(flag==1) {heaps[heapCount].objects[0]=findInData(a->data,flag); /*computeHeapParameters(&heaps[heapCount],flag);*/ } computeHeapParameters(&heaps[heapCount],flag); heapCount++; a->carrying=-1; board[a->z][a->x][a->y]=9; }//end of function /********************************************************************/ /* Function to find the heap position during the second iteration */ /* Output: position of the heap */ /* Input: object center of the heap that the ant is carrying */ /* Global Structure modified : none */ /********************************************************************/ int findInNewheaps(irisData object) { int position=-1,i,j=0,flag[features],flg; for(i=0;i<newHeapCount;i++) { for(j=0;j<features;j++) { if(fabs(object[j]-newHeaps[i].Ocenter[j])<0.00001) flag[j]=1; else {flag[j]=0;break;} } flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /*Function to drop a object to a heap consisting of a one or more object */ /* Output: none */ /* Input: Ant, position of the heap , iteration flag */ /* Global Structure modified: heaps,newHeaps */ /********************************************************************/ void dropObject1(ant* a, int position,int flag) { int heapPosition=-1,heapPosition1=-1,i,j,k=0; irisData newData,temp; if(flag==1) { heaps[position].objects[heaps[position].count]=findInData(a->data,flag); heaps[position].count++; computeHeapParameters(&heaps[position],flag); } else { for(k=0;k<features;k++)temp[k]=heaps[position].Ocenter[k]; heapPosition=findInNewheaps(a->data); heapPosition1=findInNewheaps(heaps[position].Ocenter); if(heapPosition==-1||heapPosition1==-1) { printf("\n error in logic:new heaps\n"); //getchar(); return; } for(k=0;k<features;k++) {newData[k]=(newHeaps[heapPosition].Ocenter[k]*newHeaps[heapPosition].count+newHeaps[heapPosition1].Ocenter[k]*newHeaps[heapPosition1].count)*1.0/(newHeaps[heapPosition].count+newHeaps[heapPosition1].count);newHeaps[heapPosition].Ocenter[k]=newData[k];heaps[position].Ocenter[k]=newData[k]; } computeHeapParameters(&heaps[position],flag); for(i=newHeaps[heapPosition].count,j=0;j<newHeaps[heapPosition1].count;i++,j++) { newHeaps[heapPosition].objects[i]=newHeaps[heapPosition1].objects[j]; } newHeaps[heapPosition].count+=newHeaps[heapPosition1].count; for(i=heapPosition1;i<newHeapCount-1;i++) newHeaps[i]=newHeaps[i+1]; newHeapCount--; } a->carrying=-1; }//end of function /********************************************************************/ /* Function to drop a object */ /* Output: None */ /* Input: Ant, iteration flag */ /********************************************************************/ void drop(ant* a,int flag) { float Pdrop1=0.0; int position=-1,i=0,j=0; int hCount=0,hPos[26],dropped=0; for(i=0;i<heapCount;i++) { /*Check if a heap is present in the eight neighbouring cells*/ if(abs(heaps[i].z-a->z)<=1&&abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; hPos[hCount++]=i; /*break;*/ } } /*Check if Heap is found*/ /*if(position!=-1)*/ if(hCount>0) { /*heap or object found.*/ /*Depending on the number of objects present take action*/j=0;while(j<hCount && !dropped){ switch(heaps[hPos[j]].count) { /*If criteria is satisfied then drop the object*/ case 1: if(flag==1) { if((computeDistanceBetween2(a->data,data[heaps[position].objects[0]])*1.0/Dmax)<Tcreate) { dropObject1(a,position,flag);dropped=1; } else dropped =0; } else { if((computeDistanceBetween2(a->data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(a,position,flag); dropped=1; } else dropped=0; } break; default: if(computeDistanceBetween2(a->data,heaps[position].Ocenter)<computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)) { dropObject1(a,position,flag); dropped=1; } else dropped=0; break; }j++;} } else { /*Compute the probability to drop the object*/ Pdrop1 = lrand48()%151*1.0/150; if(Pdrop1<Pdrop) dropObject(a,flag); } }//end of function /********************************************************************/ /* Function to move the ant */ /* Output: none */ /* Input: Ant, iteration flag */ /********************************************************************/ void move(ant* a,int flag) { float pDir; /*Check the speed */ if (a->speed!=0) { /*move in the same direction*/ a->speed--; moveNext(a,flag); } else { /*generate the new direction*/ pDir=lrand48()%17*1.0/16.0; if(pDir<.85) { a->dir=lrand48()%26; } else if(pDir>.95) { a->speed=2; } moveNext(a,flag); } } /********************************************************************/ /* Function to simulate the movement of the ants */ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified: minHeapCount, minHeapPosition */ /********************************************************************/ void iterate(int flag) { int i=0,j=0,k=0,loopCount=0; if (flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS; while (i<MAXITERATIONS) { i++; for(j=0;j<loopCount;j++) { move(&ants[j],flag); if(ants[j].carrying==1) { drop(&ants[j],flag); } else { pick(&ants[j],flag); } } if(debugLevel>0){ for(k=0;k<heapCount;k++) for(j=0;j<heapCount;j++) if((k!=j)&&(heaps[k].x==heaps[j].x)&&(heaps[k].y==heaps[j].y)&&(heaps[k].z==heaps[j].z)) { printf("\nerror two heaps with same co ordinates %d %d",k,j); //getchar(); } k=0; for(j=0;j<heapCount;j++) k+=heaps[j].count; } if(heapCount<minHeapCount) { minHeapCount=heapCount; minPosition=i; } if(debugLevel>0) printf("\n i:%d Heap count %d sum %d",i,heapCount,k); else printf("\n i:%d Heap count %d",i,heapCount); heapSum+=heapCount; } }//end of function /********************************************************************/ /*Function to drop the objects carried by the ants after all the iterations*/ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified:none */ /********************************************************************/ void dropFinal(int flag) { int i=0,j=0,position=-1,loopCount=0; loopCount=currentAntCount; for(i=0;i<loopCount;i++) { if(ants[i].carrying==1) { if(flag==1) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)&&(heaps[j].z==ants[i].z)) { position=i; break; } } if(position!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position,flag); } } else { /*Find if a heap is present */ do { position=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)&&(heaps[j].z==ants[i].z)) { position=i; break; } } if(position!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position,flag); position=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position!=-1); } } } }//end of function /********************************************************************/ /* Function for the implementation of QuickSort */ /* Output: none */ /* Input: data structure, low and high indices */ /* Global structure modified:none */ /********************************************************************/ void quickSort( heap A[], int low,int high ) { int mid=0; if(low<high) { mid=partition(A,low,high); quickSort(A,low,mid); quickSort(A,mid+1,high); } } /********************************************************************/ /* Partition routine used by quick sort */ /* Output: partition location */ /* Input: data , low, high */ /* Global structure modified:none */ /********************************************************************/ int partition(heap a[], int low,int high) { heap temp; int x=0,i=0,j=0; i=low; j=high; x=a[low].count; while (1) { while (a[j].count<x) j=j-1; while (a[i].count>x) i=i+1; if(i<j) { temp=a[i]; a[i]=a[j]; a[j--]=temp; } else return(j); } } /********************************************************************/ /* Function used to write the cluster information */ /* Output: none */ /* Input:iteration flag */ /* Global structure modified:none */ /********************************************************************/ void writeClusterInformation(int flag) { FILE *fp=fopen("center.clt","w"); FILE *fp1; FILE *fp2; FILE *fp3; char temp[80]; int i=0,j=0,k=0; int lastCount=0; int rowCount,colCount,antCount; strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp3=fopen(temp,"a"); if(dataDump) {strcpy(temp,"");sprintf(temp,"%sTot.out",filename);fp1=fopen(temp,"a");strcpy(temp,"");sprintf(temp,"%sObj.out",filename);fp2=fopen(temp,"a");if(fp1==NULL||fp2==NULL)printf("\n Error in opening file in the writer Cluster Information routine\n"); } rowCount=currentRow; colCount=currentRow; antCount=currentAntCount; if(fp==NULL) { printf("\n Unable to open cluster center output file \n"); /*return;*/ exit(0); } /*sort the array according to the count value and write the value of the top three elements*/ if((flag==1)&&(!EntireHeaps)) quickSort(heaps,0,heapCount); if(EntireHeaps) {if(flag==1) lastCount=heapCount;else lastCount=newHeapCount; } else lastCount=c; for(i=0;i<lastCount;i++) { if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else { for(k=0;k<features;k++) { fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",newHeaps[i].Ocenter[k]); fprintf(fp,"\n"); } else { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); fprintf(fp,"\n"); } } if(dataDump) { fprintf(fp1,"\n Information from the Ant Based Algorithm \n"); fprintf(fp1,"\n Important Parameters : Board %d X %d Ants : %d Iterations %d Total Heaps %d ",rowCount,colCount,antCount,MAXITERATIONS,lastCount); } if(flag==0) { if(dataDump) { fprintf(fp1," TCreateForHeaps %f \n",TcreateForHeaps); fprintf(fp2,"\nTotal Heaps : %d\n",heapCount); fprintf(fp2,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); } fprintf(fp3,"\n@ %d\n",lastCount); } else if(dataDump) fprintf(fp1,"\n");if(dataDump) { fprintf(fp1,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); for(i=0;i<lastCount;i++) if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp2,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); } fprintf(fp1," %5d\n",newHeaps[i].count); fprintf(fp2," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp1," %5d\n",heaps[i].count); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]); fprintf(fp1," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]); fprintf(fp1," %5d\n",heaps[i].count); }} if(flag==0) { if(dataDump) fprintf(fp1,"\n Objects in the heaps \n");for(i=0;i<newHeapCount;i++) { if(dataDump) fprintf(fp1,"\n\n Heap %d\n \n",i+1);fprintf(fp3,"# %d %d\n",i ,newHeaps[i].count); for(j=0;j<newHeaps[i].count;j++){ for(k=0;k<features;k++){ fprintf(fp3,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]); if(dataDump) fprintf(fp1,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]);} if(dataDump) fprintf(fp1,"\n"); fprintf(fp3,"\n"); } } } fclose(fp); fclose(fp3); if(dataDump) { fclose(fp1);fclose(fp2); }}//end of flie /********************************************************************/ /* Function to initialise the new heaps */ /* Output: none */ /* Input:new Heap structure */ /* Global structure modified:none */ /********************************************************************/ void initialiseNewHeaps(heap newHeaps[]) { int i=0,j=0; for(i=0;i<lCount;i++) { newHeaps[i].count=0; for(j=0;j<features;j++) newHeaps[i].Ocenter[j]=V[i][j]; newHeaps[i].x=heaps[i].x; newHeaps[i].y=heaps[i].y; newHeaps[i].z=heaps[i].z; } }//end of function /********************************************************************/ /* Function to initialise the new heaps */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ int findPosition(int i) { int j,position=0; for(j=1;j<lCount;j++) { if(U[j][i]>U[position][i]) position=j; } /*printf("\n Position %d ",position);*/ return(position); }//end of function find position /********************************************************************/ /* Function to add object */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ void addObject(int object,heap * heapPosition) { heapPosition->objects[heapPosition->count]=object; heapPosition->count++; }//end of function add object /********************************************************************/ /* Function to harden the outputs obtained from fcm */ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/ void harden(heap newHeaps[]) { int i,heapPosition=-1,sum=0,j=0; /*initialise the new heaps*/ initialiseNewHeaps(newHeaps); for(i=0;i<count;i++) { heapPosition=findPosition(i); addObject(i,&newHeaps[heapPosition]); } /* To check for degenerate partitions*/ for(i=0;i<lCount;i++) { if(newHeaps[i].count==0){for(j=i;j<lCount-1;j++){newHeaps[j]=newHeaps[j+1];}lCount--;i--;} } newHeapCount=lCount; for(i=0;i<lCount;i++) computeHeapParameters(&newHeaps[i],1); if(debugLevel>0) { for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\n sum = %d",sum);} }//end of function/********************************************************************/ /* Function to initialize the initial parameters for the ant algorithm*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void init() { int i=0,j=0,k; for(k=0;k<zDim;k++)for(i=0;i<MAXROWS;i++) for(j=0;j<MAXCOLS;j++) board[k][i][j]=-9; heapCount=0; newHeapCount=0; heapRow=0; minPosition=-1; minHeapCount=100000; for(i=0;i<MAXANTS;i++) { ants[i].carrying=-1; ants[i].x=-1; ants[i].y=-1; ants[i].z=-1; ants[i].speed=-1; ants[i].dir=-1; } } /********************************************************************/ /* Function to initialize the initial board */ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void initialiseBoard() { int i,j,k;for(k=0;k<zDim;k++) for(i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[k][i][j]=-9; }/********************************************************************/ /* Function to harden the outputs obtained from fcm(2nd stage)*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: Cluster center , cluster center count*/ /********************************************************************/void harden1() { int i=0,heapPosition=-1; for(i=0;i<heapCount;i++) cenCount[i]=0; for(i=0;i<n;i++) { heapPosition=findPosition1(i); addObject1(i,heapPosition); } writeInfo(); }//end of function/********************************************************************/ /* Function to find to which class the object belongs */ /* Output: Class number */ /* Input: object position */ /* Global Structure Modified: None */ /********************************************************************/int findPosition1(int i) { int j,position=0; for(j=1;j<heapCount;j++) { if(U[j][i]>U[position][i]) position=j; } return(position); }//end of function find position/********************************************************************/ /* Function to Write the output of the hardened objects to file*/ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/void writeInfo(){int i=0,j=0,k=0;FILE *fp=fopen("fcm.out","a");if(fp==NULL){printf("\n Unable to open fcm output file \n");return;}fprintf(fp,"\n@ %d\n",heapCount);for(i=0;i<heapCount;i++){fprintf(fp,"# %d %d\n",i,cenCount[i]);for(j=0;j<cenCount[i];j++){for(k=0;k<s;k++)fprintf(fp,"%8.2f ",clsCen[i][j][k]/scale[k]+minInput[k]);fprintf(fp,"\n");}}fclose(fp);return;}/********************************************************************/ /* Function to add a object to a cluster (2nd stage) */ /* Output: none */ /* Input: object poistion , cluster position */ /* Global Structure Modified: Cluster object and cluster count*/ /*******************************************************************/void addObject1(int object,int heapPosition) { int k=0; for(k=0;k<features;k++) clsCen[heapPosition][cenCount[heapPosition]][k]=X[object][k]; cenCount[heapPosition]++; return; }//end of function add object/********************************************************************/ /* Function to read the original classification of objects */ /* Output: none */ /* Input: none */ /* Global Structure Modified: None */ /*******************************************************************/void readOrg(){int i=0,k=0;char temp[80];FILE *fp;strcpy(temp,"");sprintf(temp,"%sFull.data",filename);fp=fopen(temp,"r");if(fp==NULL){printf("\n Unable to open full data input file ");exit(0);}for(i=0;i<n;i++){fscanf(fp,"%f ",&orgData[i][0]);for(k=1;k<s+1;k++)fscanf(fp,"%f ",&orgData[i][k]);}return;}// end of function/********************************************************************/ /* Function to classify the objects in different clusters */ /* Output: none */ /* Input: the cluster objects, the original classification, */ /* number of objects in the cluster,file to write the data */ /* Global Structure Modified: None *//********************************************************************/int analysisData(float data[][s],float orgData[n][s+1],int count,FILE * fp){int i=0,j=0,k=0,type=1,max=0;heapInfo info;for(i=0;i<c;i++){info.classObj[i]=0;}info.total=0;info.total=count;for(i=0;i<count;i++)for(j=0;j<n;j++){type=1;for(k=0;k<s;k++)if(fabs(data[i][k]-orgData[j][k+1])>errThresh){type=-1;break;}if(type!=-1){info.classObj[(int)orgData[j][0]-1]++;break;}}max=0;for(k=0;k<c;k++){if(info.classObj[k]>info.classObj[max])max=k;fprintf(fp,"\nClass %d Objects % d ",k+1,info.classObj[k]);}j=0;for(k=0;k<c;k++){if(k!=max)j+=info.classObj[k];}fprintf(fp,"\n Total errors : %d \n",j);return(j);}//end of analyse/********************************************************************/ /* Function to read the cluster information */ /* Output: none */ /* Input: input file pointer , output file pointer */ /* Global Structure Modified: None *//********************************************************************/void readFCM(FILE* fp,FILE *fp1){int i=0,j=0,k=0,l=0;int totalRuns=0,heapCount=0,junk=0,sum=0;char ch;FILE *fp2=fopen("errors.out","a");ch = 'c'; while (ch != '$') fscanf (fp, "%c", &ch);fscanf(fp,"%d\n",&totalRuns);printf("\n total runs %d ",totalRuns);for(l=0;l<totalRuns;l++){fscanf(fp,"%c",&ch);fscanf(fp,"%d\n",&heapCount);fprintf(fp1,"\n \nExperiment %d \n ",l+1);sum=0;for(i=0;i<heapCount;i++){fscanf(fp,"%c",&ch);fscanf(fp," %d %d\n",&junk,&clsCenCount[i]);for(j=0;j<clsCenCount[i];j++)for(k=0;k<s;k++)fscanf(fp,"%f",&fcmData[i][j][k]);fscanf(fp,"\n");fprintf(fp1,"\n\n Heap %d Total Objects %d \n",i+1,clsCenCount[i]);sum+=analysisData(fcmData[i],orgData,clsCenCount[i],fp1);}fprintf(fp2," %3d %3d %3d \n",l,sum,heapCount);}fprintf(fp2,"\n --------------------------\n");fclose(fp2);return;}//end of function/********************************************************************/ /* Function to update the board parameters */ /* Output: none */ /* Input: none */ /* Global Structure Modified: board size, ant count *//********************************************************************/void adjustBoard(int flag){int newRow=0,newAnt=0,antDiff=0,antsKilled=0,i=0,position[MAXANTS],position1=-1,j=0,k=0,a,b,z; newRow= (int)ceil(sqrt(4.0*heapSum/updateAfter)); newAnt= (int)ceil((heapSum*1.0/updateAfter)*1.0/3.0); if(newAnt<minAnts)newAnt=minAnts; if(newRow<rowMin)newRow=rowMin;antDiff=currentAntCount-newAnt; if((antDiff>0)&&(newAnt>=minAnts)) {for(i=0;i<currentAntCount;i++){if(ants[i].carrying==-1){position[antsKilled++]=i;}} if(antsKilled>=antDiff){for(i=0;i<antDiff;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1];for(k=i+1;k<antsKilled;k++)position[k]--; } currentAntCount=newAnt; }else {for(i=0;i<antsKilled;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1]; for(k=i+1;k<antsKilled;k++)position[k]--; }if(flag==1) { for(i=currentAntCount-1,k=0;k<antDiff-antsKilled;k++,i--) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)&&(heaps[j].z==ants[i].z)) { position1=i; break; } } if(position1!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position1,flag); }else { dropObject(&ants[i],flag); } } } else { //flag is zero 2nd stage /*Find if a heap is present */ do { position1=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)&&(heaps[j].z==ants[i].z)) { position1=i; break; } } if(position1!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position1].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position1,flag); position1=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position1!=-1); }//end else currentAntCount=newAnt;}//end elsecurrentAntCount=newAnt;}//end iffor(i=0;i<newAnt;i++){if((ants[i].x>=newRow)||(ants[i].y>=newRow)||ants[i].z>zDim) { a=lrand48()%newRow; b=lrand48()%newRow; z=lrand48()%zDim; ants[i].x=a; ants[i].y=b; ants[i].z=z; }} //Done with ants, now adjust the boardif((currentRow>newRow)&&(newRow>=rowMin)){for(i=0;i<heapCount;i++){if((heaps[i].x>=newRow)||(heaps[i].y>=newRow)||(heaps[i].z>=zDim)) {do { a=lrand48()%newRow; b=lrand48()%newRow; z=lrand48()%zDim; } while(found(z,a,b));//adjust the heap poistionheaps[i].x=a;heaps[i].y=b;heaps[i].z=z;board[z][a][b]=9;}//end if}//end for for(i=0;i<currentAntCount;i++){if((ants[i].carrying==1)&&((ants[i].x>=newRow)||(ants[i].y>=newRow)||(ants[i].z>=zDim))){//adjust the ant locationdo { a=lrand48()%newRow; b=lrand48()%newRow; z=lrand48()%zDim; } while(found(z,a,b));//adjust the heap poistionants[i].x=a;ants[i].y=b;ants[i].z=z;}//end if}//end for currentRow=newRow;}//end if }//end of function void writeIncremental(int iteration,int flag){FILE *fp=fopen("dump.txt","w");int i=0,j=0,k=0;fprintf(fp,"Stage %d\n",flag);fprintf(fp,"Board %d\n",currentRow);fprintf(fp,"Ants %d\n",currentAntCount);fprintf(fp,"Iteration %d\n",iteration);fprintf(fp,"Heaps %d\n",heapCount); if(flag==0)fprintf(fp,"NewHeapCount %d\n",newHeapCount); fprintf(fp,"Ants\n");for(i=0;i<currentAntCount;i++){fprintf(fp,"%d %d %d %d %d ",ants[i].x,ants[i].y,ants[i].carrying,ants[i].speed,ants[i].dir);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",ants[i].data[k]);fprintf(fp,"\n");}fprintf(fp,"Heaps\n");for(i=0;i<heapCount;i++){fprintf(fp,"%d %d %d %d %8.2f %8.2f \n",heaps[i].x,heaps[i].y,heaps[i].count,heaps[i].disPosition,heaps[i].Dmax,heaps[i].Dmean);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Ocenter[k]);fprintf(fp,"\n");for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Odissim[k]);fprintf(fp,"\n");if(flag==1){for(j=0;j<heaps[i].count;j++)fprintf(fp,"%d ",heaps[i].objects[j]);fprintf(fp,"\n");}}if(flag==0){fprintf(fp,"newHeaps\n");for(i=0;i<newHeapCount;i++){fprintf(fp,"%d\n",newHeaps[i].count);for(j=0;j<newHeaps[i].count;j++)fprintf(fp,"%d ",newHeaps[i].objects[j]);fprintf(fp,"\n");}}fclose(fp);}//end of function/********************************************************************/ /* Function Main */ /********************************************************************/ int main(int argc ,char** argv) { int sum=0,k=0,i=0,j=0; char temp[80]; FILE *fp=fopen("fcm.out","w"); FILE *fp1; FILE *fp2=fopen("antAnalysis.out","a"); FILE *fp3=fopen("fcmAnalysis.out","a"); FILE *fp4=fopen("errors.out","w"); FILE *fp5; FILE *fpJm=fopen("jm.out","w"); fclose(fp4); fclose(fpJm); sprintf(temp,"%sObj.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sTot.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp1=fopen(temp,"w"); fprintf(fp,"\n$%d",EXPRUN); fprintf(fp1,"\n$%d",EXPRUN); fclose(fp); fclose(fp1); if(argc==2)sscanf(argv[1],"%d",&debugLevel); printf("\n Debug level %d\n",debugLevel); for(k=0;k<zDim;k++) for( i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[k][i][j]=-9; //Read from the file readInput(); //Compute the distance of all the points if(maxDist) { Dmax=computeDistance(); //Compute the maximum distance fp5=fopen("maxData.txt","w");fprintf(fp5,"%f",Dmax);fclose(fp5); } else {/*if((fp5=fopen("maxData.txt","r"))==NULL);{printf("\n Max Distance file not found, exiting . . . \n");exit(-1);}*/fp5=fopen("maxData.txt","r");fscanf(fp5,"%f",&Dmax);fclose(fp5); } printf("\n %f \n",Dmax); //Initialise the board for(k=0;k<EXPRUN;k++) { init(); sum=0; srand48(state1[k]); initialiseBoard(); initialise(1); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(1); printf("\n %d \n",heapCount); //Simulate the working of ants iterate(1); //drop the objects after all the iterations dropFinal(1); //to verify the correctness for(i=0;i<heapCount;i++) sum+=heaps[i].count; //write the cluster centers to the file writeClusterInformation(1); printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); printf("\n\n k %d \n\n",k); Fcm(data,0); //compute new board size. lCount=heapCount; heapRow=(int)ceil(sqrt(heapCount*4.0/3.0)); newHeapCount=lCount; printf("\n LCount %d newHeapCount %d heap Row %d \n",lCount,newHeapCount,heapRow); //harden the objects harden(newHeaps); //iterate with the heaps as the objects. initialiseBoard(); initialise(0); for(i=0;i<lCount;i++) computeHeapParameters(&heaps[i],0); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(0); printf("\n %d \n",heapCount); //getchar(); //Simulate the working of ants iterate(0); dropFinal(0); writeClusterInformation(0); sum=0; for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); // getchar(); fpJm=fopen("jm.out","a"); fprintf(fpJm,"Experiment %2d: ",k); fclose(fpJm); Fcm(data,1); harden1(); } fp=fopen("fcm.out","a"); fp1=fopen(temp,"a"); fprintf(fp,"\n"); fprintf(fp1,"\n"); fclose(fp); fclose(fp1); fp=fopen("fcm.out","r"); fp1=fopen(temp,"r");printf("\n Before read org\n");readOrg();printf("\nafter read org\n");readFCM(fp1,fp2);printf("\n After 1st read fcm\n");readFCM(fp,fp3);printf("\n After 2 fcm read \n");return(1); }//end of main /****************************************************************/ float NORM(feature , feature); void find_covar(); void Fcm (irisData Data[MAXDATA],int stage) { int i,j,l; FILE *ofile; char temp[80]; int flag=0;//added by parag FILE *iniClsCen=fopen("center.clt","a+"),*fpJm; float jmFinal=0; if(iniClsCen==NULL) { printf("\n Unable to open the initial cluster center file\n"); printf("\n choosing random cluster centers....\n"); flag=1; } strcpy(temp,""); sprintf(temp,"%s.data",filename); strcpy (fname,temp); /* Read from this file */ m=2.0; /* The exponent */ /*GET_INPUTS1(fname);*/ /* read in feature vectors */ for (j=0; j<n ; j++) /* Read File in row-major */ for (i=0; i<s ; i++) /* format */ X[j][i]=Data[j][i]; Random_seed=state1[run];/*randseed*/ srand48(Random_seed); for (run=0;run<TOTRUNS;run++) { //flag=1;//for testing random values if (EntireHeaps) lCount=heapCount; else lCount=c; for(i=0;i<lCount;i++) for(j=0;j<s;j++) V[i][j]=0; for(i=0;i<lCount;i++) { for(l=0;l<s;l++) { if(flag==1) { rand_index = lrand48() % n; V[i][l] = X[rand_index][l]; } else { fscanf(iniClsCen,"%f ",&V[i][l]); } }//end for } eps=0.001; stop = FALSE; /* This loop finds the final cluster center and the corresponding U values */ z = 0; while (stop == FALSE) { z++; UMAT(U,V,X); /** Update the U matrix **/ stop = FINISHED(U1,eps); CLUSTER(U,X); /** Get new cluster center **/ printf("Iteration: %d\n\n", z); } /* end while */ printf("Number of iterations: %d\n\n", z);strcpy(temp,""); sprintf(temp,"%sFCM.out",filename);if(stage>0){jmFinal=Compute_Jm(V,X);fpJm=fopen("jm.out","a");fprintf(fpJm," classes %2d Jm: %8.5f\n",lCount,jmFinal);fclose(fpJm);}if(dataDump) Output(temp); /* output the results */ }/*end for*/ if(dataDump) { ofile=fopen(temp,"a"); for (i=0; i <= mins; i++) fprintf(ofile, "Min %d of %10.3f occurred %d times\n", i, mintab[i], mincount[i]); fprintf(ofile, "Average iterations %f\n", (float)aveit/(float)TOTRUNS); fclose(ofile); } }/* end Main */ /* The GET_INPUTS1 procedure opens an input file, reads the number of input vectors, the number of features per vector, the number of clusters, and epsilon, then it reads the input values */ void GET_INPUTS1(char fname[]) //char fname[]; { /* Parameters: fname -- name of file containing input info. */ FILE *infile ;//*fopen(); //char junk[10][80]; char realfname[80]; char ch; char fileName1[80]; //int temp[10], i, j, inputs, outputs, count; int i,j; sprintf (realfname, "%s", fname); /* open input file */ if(normalize==1) strcpy(fileName1,"gtest1.data"); else strcpy(fileName1,fname); if((infile = fopen (fileName1, "r")) == NULL) printf("\n CAN'T OPEN %s\n",realfname); else { ch = 'c'; /* Discard leading comments */ while (ch != '#') fscanf (infile, "%c", &ch); for (j=0; j<n ; j++) /* Read File in row-major */ { /* format */ for (i=0; i<s ; i++) fscanf (infile, "%f", &X[j][i]); /* fscanf (infile, "%d", &temp[1]); */ /* end for */ } /* end for */ fclose(infile); /* close input file */ }/* end else */ } /* end GET_INPUTS1 */ /* The NORM function computes the norm of two vectors, x and v, of dimension s. This gives an indication of the distance between them */ float NORM( feature x, feature v) //feature x, v; { /* Parameters : x -- a local copy of an input vector v -- a local copy of a cluster center */ int i,j; /* loop variable */ double sum; /* the square root of sum is the norm; sum is the sum of the differences squared */ float mat1[s]; float mat2[s]; if (maha) { for (i=0; i<s; i++) mat1[i]=x[i]-v[i]; for(i=0;i<s;i++) { sum =0; for(j=0;j<s;j++) sum += mat1[j] * inv_cov[j][i]; mat2[i] = sum; } sum =0; for(j=0;j<s;j++) sum += mat1[j]*mat2[j]; } else { sum = 0; for(j=0;j<s;j++) sum += (x[j] - v[j])* (x[j] - v[j]); } return (float)(sqrt(sum)); } /* end NORM */ /* The UMAT procedure calculates the updated U matrix according to Bezdek's formula. Its side-effect is the update of the global array U1 */ void UMAT( matrix U,center V, objects X) /*matrix U; center V; objects X;*/ { /* Parameters: U, V, and X: same as in main program */ int i, j, k,l ;/* loop variables *///, class /* class whose cluster center //is closest to pattern k */; float d1,d2,d; float sum; int exact; for (k=0;k<n;k++) { /*printf("\n k %d ",k);*/ exact=false; for (i=0;i<lCount;i++) { sum=0; for (j=0;j<lCount;j++) { d1=NORM(X[k],V[i]); d2=NORM(X[k],V[j]); if(d2!=0) { d= d1/d2; d= d * d;/* pow(d1/d2,2.0/(m-1.0)); */ sum+=d; } else { exact = true; for(l=0;l<lCount;l++) if (l==j) U1[l][k]=1.0; else U1[l][k]=0.0; break; } } if (exact!=true) U1[i][k]=1.0/sum; } } } /* end UMAT */ /* The function FINISHED determines if a termination occurs. If not it updates U with U1, so its side-effect is the potential modification of U */ BOOLEAN FINISHED( matrix U1,float eps) //matrix U1; float eps; { /* Parameters: U1, eps-- same as in main */ float sum; /* sum of squared differences between corresponding elements of U and U1 */ int i,k; /* loop control variabes */ BOOLEAN finished; /* set to true if all corresponding elements are within epsilon */ finished = TRUE; sum = 0; for (i=0; i<lCount; i++) for (k=0; k<n; k++) sum += (U[i][k] - U1[i][k])*(U[i][k]-U1[i][k]); if (sqrt(sum) > eps) { finished = FALSE; for (i=0; i<lCount; i++) for (k=0; k<n; k++) U[i][k] = U1[i][k]; } /* end if */ return finished; } /* end FINISHED */ /* The CLUSTER procedure determines cluster centers in V for the c classes being searched for. The global array V is updated */ void CLUSTER( matrix U, objects X) //matrix U; objects X; { /* Parameters: U, X -- as in main */ int i, j, k; /* loop control variables */ feature num; /* numerator in the cluster center computation formula presented by Bezdek */ float denum; /* denumenator in the obove formula */ for (i=0; i<lCount; i++) { denum = 0; for (j=0; j<s; j++) { num[j] = 0; for (k=0; k<n; k++) num[j] += U[i][k] * U[i][k] * X[k][j]; /* pow(U[i][k],m) * X[k][j]; */ } /* end for */ for (k=0; k<n; k++) denum += U[i][k] * U[i][k]; /* pow(U[i][k],m); */ for (j=0; j<s; j++) V[i][j] = num[j] / denum; } /* end for */ } /* end CLUSTER */ float Compute_Jm(center V, objects X) //center V; //objects X; { int i, k,found; double Jm_value; float u,dik; Jm_value = 0; for (k=0; k<n; k++) { found = FALSE; for (i=0; i<lCount; i++) { dik=NORM(X[k],V[i]); dik=dik*dik; if (dik==0.0) { if (found == FALSE) { u=1.0; found = TRUE; printf("found the case with dik=0\n"); } else { printf("\n cant proceed with this initialization"); exit(1); } } else { if (found != TRUE) u=U1[i][k]; /* get_Uvalue(V,X,dik,k); */ else u=0.0; } Jm_value += u * u * dik;/* pow(u, m) * dik; */ } } return (Jm_value); } /* end Compute_Jm */ /* The Output procedure outputs the U matrix which gives the fuzzy measure of each feature belonging to a cluster center. It also outputs the cluster center for each class */ void Output(char fname[]) //char fname[80]; /* Parameters: U, V -- same as in main */ { int i, j, found; /* loop control variables */ float J2c; if ((fp=fopen(fname,"a"))==NULL) printf("\n CAN'T OPEN %s\n",fname); else { fprintf(fp,"\n The cluster centers are: \n"); fprintf(fp,"\n \n"); for (i=0; i<lCount; i++) { fprintf(fp,"\nCluster center %d: ",i+1); fprintf(fp,"\n"); for (j=0; j<s; j++) fprintf(fp,"%8.7f ",V[i][j]); } /* end for */ fprintf(fp,"\nThe membership grades for the feature vectors are:\n"); for (j=0; j<n; j++) { fprintf(fp,"\n"); for (i=0; i<lCount; i++) fprintf(fp," %8.7f",U[i][j]); } /* end for */ } /* end if */ J2c= Compute_Jm(V,X); found =0; for (i=0;i<= mins; i++){ if ((found == 0) && ((J2c - mintab[i]) < .001) && ((J2c - mintab[i]) > -.001)){ mincount[i]++; found = 1; } } if (found == 0){ mins++; mintab[mins]=J2c; mincount[mins]=1; } fprintf(fp,"\nJ%3.1f = %f", m,J2c); fprintf(fp, "Number of iterations: %d\n\n", z); aveit=aveit + z; fclose(fp); } /***************************************************************/ void find_covar(int m) //int m; { int i,j,k; float mean[s],sum; for (i=0;i<s;i++) mean[i]=0; for (i=0;i<s;i++) for (j=0;j<m;j++) mean[i]+=X[j][i]; for (i=0;i<s;i++) mean[i]/=m; for (i=0;i<s;i++) for (j=0;j<s;j++) { sum=0; for (k=0;k<m;k++) sum+=(X[k][i]-mean[i])*(X[k][j]-mean[j]); Y[i][j]=sum/m; } }
Parag Kanade/fuzzy ants/3D Board/ant_xyz.c
#include "header_xyz.h" /*******************************************************************/ /*** Global Variables ***/ irisData data[MAXDATA]; //To hold the data read from the file int count=0; //Count of the total number of data elements int heapCount=0; // Total number of heaps int heapRow=0; // Rows for the second iteration with heaps int newHeapCount=0; // Count of the heaps for the second iteration heap heaps[MAXDATA]; // Data structure to hold the heap information heap newHeaps[MAXDATA]; // Data Structure to hold the new heap information // For the second iteration int board[zDim][MAXROWS][MAXCOLS]; // Board on which the objects are located ant ants[MAXANTS]; // Data structure to hold the ants float Dmax=0; // Distance of the most dissimilar object pair int minHeapCount=100000; // Counter to hold the minimum heap count, used only for academic purpose // no use in the algorithm int minPosition; // the minimum heap iteration , only for academic purpose // no use in the algorithm float clsCen[MAXDATA][MAXDATA][s];//to hold the objects after hardening int cenCount[MAXDATA];//to hold the number of objects after hardening /********************************************************************/ /*** Varaibles to normalize the features between 0 and 1 */ float minInput[features], maxInput[features],scale[features],minForHeaps[features],maxForHeaps[features],scaleForHeaps[features]; /********************************************************************/ /** Variables for the FCM algorithm */ int temp[200]; /* for square matrix tests */ float eps,m; matrix U, U1; BOOLEAN stop; center V; objects X; char fname[80]; FILE *fp; int run; float inv_cov[s+1][s+1]; /* inverse of covariance matrix Y */ float Y[s][s]; long rand_index, Random_seed; long state1[52] = { 9347, 3835, 5194, 8310, 346, 535, 5297, 6711, 77, 3834, 668, 4175, 6868, 5890, 9304, 8462, 5269, 920, 65392, 41600, 70119, 91032, 76220, 26245, 4746, 73608, 32823, 63264, 75641, 99104, 36534, 24704, 98255, 72266, 75336, 65152, 7269, 63163, 88471, 27271, 43641, 76649, 47773, 23777, 27491, 35926, 16651, 48652, 89766, 90921, 6056 }; int z; int mins=0; int aveit =0; float mintab[200]; int mincount[200]; long start,end,total; int lCount;//added by parag /********************************************************************/ /********************************************************************/ /* Function to read the input data set */ /* The file name is assumed to be itest.data */ /* Status: Tested */ /* Output: Data from the file into the "data" (Global) data structure */ /* Output: Count (Global), the count of the number of objects */ /********************************************************************/ void readInput() { FILE *fp; char fname[80]; int i=0,j=0; char ch; sprintf(fname,"%s.data",filename); /* Check if the input file is opened */ if((fp=fopen(fname,"r"))==NULL) { printf("\n Unable to open input file \n"); exit(0); } /*initialise the minimum maximum and the scale */ for(i=0;i<features;i++) { minInput[i]=1000; maxInput[i]=0; minForHeaps[i]=1000; maxForHeaps[i]=0; scale[i]=0; scaleForHeaps[i]=0; } /* Discard leading comments */ ch = 'c'; while (ch != '#') fscanf (fp, "%c", &ch); i=0; /* Parse the file and populate the data structure */ while(!feof(fp)) { for(j=0;j<features;j++) { fscanf(fp,"%f ",&data[i][j]); } fscanf(fp,"\n"); for(j=0;j<features;j++) { if(data[i][j]<minInput[j]) minInput[j]=data[i][j]; if(data[i][j]>maxInput[j]) maxInput[j]=data[i][j]; } i++; } count=i; /* Normailze the feature values in between 0 and 1 */ for(j=0;j<features;j++) { if(minInput[j]!=maxInput[j]) scale[j]=1.0/(maxInput[j]-minInput[j]); else scale[j]=1.0; } for(i=0;i<count;i++) { for(j=0;j<features;j++) data[i][j]=(data[i][j]-minInput[j])*scale[j]; } fclose(fp); return; }//end of function /********************************************************************/ /*Function to compute the eucldiean distance for all input data set */ /* Output : an array conatining the distance of each object with the other */ /********************************************************************/ float computeDistance() { float distance,dist=0; int i=0,j=0,k=0; distance=0; for(j=0;j<count;j++) for(i=0;i<count;i++) { for(k=0;k<features;k++) dist+=sqrt((data[j][k]-data[i][k])*(data[j][k]-data[i][k])); if(distance<dist)distance=dist; dist=0; } return(distance); } /********************************************************************/ /* Function to compute the distance between two objects */ /* Output : Euclidean d istance between the two input objects */ /********************************************************************/ float computeDistanceBetween2(irisData a,irisData b) { float temp=0; int i=0; for(i=0;i<features;i++) temp+=(a[i]-b[i])*(a[i]-b[i]); temp=sqrt(temp); return(temp); } /********************************************************************/ /* Function to compute the value of an object */ /********************************************************************/ float value(irisData a) { int i=0; float temp=0; for(i=0;i<features;i++) temp+=a[i]*a[i]; return(sqrt(temp)); } /********************************************************************/ /* Function to find the object in the data structure */ /* Output : The position of the object in the data */ /* Input : The object */ /********************************************************************/ int findInData(irisData object,int iFlag) { int i=0,lastCount=0,j,position=-1,flag[features],flg;if(iFlag==1)lastCount=MAXDATA;else{}for(i=0;i<lastCount;i++){ for(j=0;j<features;j++) if(fabs(object[j]-data[i][j])<0.00001) flag[j]=1; else { flag[j]=0; break;} flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /* Function to find whether there is an object on the board at a,b */ /* Output : a flag indicating whether an object is found or not */ /* Input : The row and column indicating the board position */ /********************************************************************/ int found(int z,int a , int b) { if(board[z][a][b]==9) return 1; else return 0; } /********************************************************************/ /* Function to initialize the initial board */ /* Output : None */ /* Global Structures modified : heaps */ /* Input : Flag indicating the iteration 1: First 0: Second */ /********************************************************************/ void initialise(int flag) { int a,b,i=0,k=0,z; int loopCount,rowCount,colCount,zCount; /* Initialize the row, column and number of heaps */ if(flag==1) { loopCount=count; rowCount=MAXROWS; colCount=MAXCOLS; zCount=zDim; } else { loopCount=lCount; rowCount=heapRow; colCount=heapRow; zCount=heapRow; } /* Initialize the heaps */ for(i=0;i<loopCount;i++) { heaps[i].count=0; heaps[i].x=0; heaps[i].y=0; heaps[i].z=0; heaps[i].disPosition=0; heaps[i].Dmax=0; heaps[i].Dmean=0; } for(i=0;i<loopCount;i++) { /*find a board position which is empty*/ do { a=lrand48()%rowCount; b=lrand48()%colCount; z=lrand48()%zCount; } while(found(z,a,b)); /*Allocate the object to that place and assign a heap to it*/ heaps[i].x=a; heaps[i].y=b; heaps[i].z=z; heaps[i].count=1; heaps[i].Dmax=0; heaps[i].Dmean=0; if(flag==1) { heaps[i].objects[0]=i; for(k=0;k<features;k++)heaps[i].Ocenter[k]=data[i][k]; } else { for(k=0;k<features;k++) heaps[i].Ocenter[k]=newHeaps[i].Ocenter[k]; } heaps[i].disPosition=0; board[z][a][b]=9; if((debugLevel>0)&&(flag==1))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],data[heaps[i].objects[0]][0]); if((debugLevel>0)&&(flag==0))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],newHeaps[i].Ocenter[0]); } /*initialise the initial heap count*/ heapCount=loopCount; currentRow=rowCount; } /********************************************************************/ /* Function to find whether an heap is present at the location a b */ /* Output : Flag indicating the presencs of the heap */ /* Input : Roe and column indicating the board position */ /********************************************************************/ int findObject(int z,int a,int b) { int i; int position=-1; for(i=0;i<heapCount;i++) { if((heaps[i].z==z)&&(heaps[i].x==a)&&(heaps[i].y==b)) { position=i; break; } } return(position); } /********************************************************************/ /* Function initialize the ants */ /* Output : None */ /* Input : Flag indicating the iteration */ /* Global Variables Modified : ant, heapCount, heaps, board */ /********************************************************************/ void initialiseAnts(int flag) { int i=0,a=0,b=0,position,j=0,loopCount=0,rowCount,colCount,k=0,z=0,zCount=0; if(flag==1) { loopCount=MAXANTS; rowCount=MAXROWS; colCount=MAXCOLS; zCount=zDim; } else { loopCount=MAXANTSFORHEAPS; rowCount=heapRow; colCount=heapRow; zCount=heapRow; } for(i=0;i<loopCount;i++) { /*generate random positions for the ants*/ a=lrand48()%rowCount; b=lrand48()%colCount; z=lrand48()%zCount; ants[i].x=a; ants[i].y=b; ants[i].z=z; /*Find if an object is present at that position or not*/ if(board[z][a][b]==9) { ants[i].carrying=1; /*find the heap at that location*/ position=findObject(z,a,b); if(position==-1) { printf("\n Error in logic: Ant init \n"); //getchar(); break; } else { /*Assign the heap data to the ant data and decrement the heap count*/ if(flag==1){ for(k=0;k<features;k++)ants[i].data[k]=data[heaps[position].objects[0]][k]; }else{for(k=0;k<features;k++)ants[i].data[k]=heaps[position].Ocenter[k];} for(j=position;j<heapCount-1;j++) heaps[j]=heaps[j+1]; heapCount--; } /*Clear the board position */ board[z][a][b]=-9; } else ants[i].carrying=-1; ants[i].speed=0; ants[i].dir=lrand48()%26; printf("\n Ant %2d X: %2d Y: %2d Z:%2d Carying : %2d ",i,ants[i].x,ants[i].y,ants[i].z,ants[i].carrying); } currentAntCount=loopCount; } /********************************************************************/ /* Function to move the ant */ /* Output: None */ /* Input: Ant to be moved and the flag indicating the iteration */ /********************************************************************/ void moveNext(ant* a,int flag) { int rowCount,colCount,zCount; rowCount=currentRow; colCount=currentRow; if(flag==1)zCount=zDim;else zCount=heapRow; /*Depending upon the direction move the ant*/ switch (a->dir) { case 0: a->y++; if(a->y>=colCount)a->y=0; break; case 1: a->x--; a->y++; if(a->x<0)a->x=rowCount-1; if(a->y>=colCount)a->y=0; break; case 2: a->x--; if(a->x<0)a->x=rowCount-1; break; case 3: a->x--; a->y--; if(a->x<0)a->x=rowCount-1; if(a->y<0)a->y=colCount-1; break; case 4: a->y--; if(a->y<0)a->y=colCount-1; break; case 5: a->x++; a->y--; if(a->x>=rowCount)a->x=0; if(a->y<0)a->y=colCount-1; break; case 6: a->x++; if(a->x>=rowCount) a->x=0; break; case 7: a->x++; a->y++; if(a->x>=rowCount)a->x=0; if(a->y>=colCount)a->y=0; break; case 8: a->y++; if(a->y>=colCount)a->y=0; a->z--; if(a->z<0)a->z=zCount-1; break; case 9: a->x--; a->y++; a->z--; if(a->z<0)a->z=zCount-1; if(a->x<0)a->x=rowCount-1; if(a->y>=colCount)a->y=0; break; case 10: a->x--; a->z--; if(a->z<0)a->z=zCount-1; if(a->x<0)a->x=rowCount-1; break; case 11: a->x--; a->y--; a->z--; if(a->z<0)a->z=zCount-1; if(a->x<0)a->x=rowCount-1; if(a->y<0)a->y=colCount-1; break; case 12: a->y--; a->z--; if(a->z<0)a->z=zCount-1; if(a->y<0)a->y=colCount-1; break; case 13: a->x++; a->y--; a->z--; if(a->z<0)a->z=zCount-1; if(a->x>=rowCount)a->x=0; if(a->y<0)a->y=colCount-1; break; case 14: a->x++; a->z--; if(a->z<0)a->z=zCount-1; if(a->x>=rowCount) a->x=0; break; case 15: a->x++; a->y++; a->z--; if(a->z<0)a->z=zCount-1; if(a->x>=rowCount)a->x=0; if(a->y>=colCount)a->y=0; break; case 16: a->z--; if(a->z<0)a->z=zCount-1; break; case 17: a->y++; a->z++; if(a->z>=zCount)a->z=0; if(a->y>=colCount)a->y=0; break; case 18: a->x--; a->y++; a->z++; if(a->z>=zCount)a->z=0; if(a->x<0)a->x=rowCount-1; if(a->y>=colCount)a->y=0; break; case 19: a->x--; a->z++; if(a->z>=zCount)a->z=0; if(a->x<0)a->x=rowCount-1; break; case 20: a->x--; a->y--; a->z++; if(a->z>=zCount)a->z=0; if(a->x<0)a->x=rowCount-1; if(a->y<0)a->y=colCount-1; break; case 21: a->y--; a->z++; if(a->z>=zCount)a->z=0; if(a->y<0)a->y=colCount-1; break; case 22: a->x++; a->y--; a->z++; if(a->z>=zCount)a->z=0; if(a->x>=rowCount)a->x=0; if(a->y<0)a->y=colCount-1; break; case 23: a->x++; a->z++; if(a->z>=zCount)a->z=0; if(a->x>=rowCount) a->x=0; break; case 24: a->x++; a->y++; a->z++; if(a->z>=zCount)a->z=0; if(a->x>=rowCount)a->x=0; if(a->y>=colCount)a->y=0; break;case 25: a->z++; if(a->z>=zCount)a->z=0; break;default: break; } }//end of function /********************************************************************/ /* Function to compute the parameters of the heap */ /* Output: None */ /* Input: The heap whose parameters are to be computed iteration flag*/ /********************************************************************/ void computeHeapParameters(heap* heapData,int flag) { int i=0,j=0,k=0,position=0; float distance=0; float Dmean=0.0; float *dis; float featureSum[features]; float max=0; float sum=0; /* init*/ for(k=0;k<features;k++) featureSum[k]=0; /*Compute the distance of each object and find the maximum distance*/ max=0; if(flag==1){ for(j=0;j<heapData->count;j++) for(i=0;i<heapData->count;i++) { for(k=0;k<features;k++) sum+= (data[heapData->objects[j]][k]-data[heapData->objects[i]][k])*(data[heapData->objects[j]][k]-data[heapData->objects[i]][k]); distance=sqrt(sum); if(max<distance) max=distance; sum=0; } /* Assign the maximum distance to the heap */ heapData->Dmax=max;/*Compute the centre object*/for(i=0;i<heapData->count;i++)for(k=0;k<features;k++) featureSum[k]+=data[heapData->objects[i]][k];for(k=0;k<features;k++)heapData->Ocenter[k]=featureSum[k]*1.0/heapData->count; /* Find the mean distance */if((dis=(float *) calloc(heapData->count,sizeof(float)))==NULL){printf("\nUnable to allocate memory in the compute heap parameters procedure\n");exit(0);} for(i=0;i<heapData->count;i++) { Dmean+=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); dis[i]=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); } heapData->Dmean=Dmean*1.0/heapData->count; /*Compute the most dissimilar object*/ max=dis[0]; for(i=1;i<heapData->count;i++) if(max<dis[i]) { max=dis[i]; position=i; } /*Assign the most dissimilar object to the heap variable*/ for(k=0;k<features;k++) heapData->Odissim[k]=data[heapData->objects[position]][k]; heapData->disPosition=position;free(dis); } else{/* Heap Parameters for the second stage */for(k=0;k<features;k++){ heapData->Odissim[k]=heapData->Ocenter[k];}heapData->disPosition=0;heapData->Dmean=0;heapData->Dmax=0;} }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a single object*/ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject1(ant *a,int position,int flag) { int i,k=0; /*Clear the board*/ board[heaps[position].z][heaps[position].x][heaps[position].y]=-9; /* Assign the data to the ant*/if(flag==1){ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[0]][k];}else {for(k=0;k<features;k++) a->data[k]=heaps[position].Ocenter[k];} a->carrying=1; /*Copy all the heaps remaining heaps in the structure*/ for(i=position;i<heapCount-1;i++) heaps[i]=heaps[i+1]; /*Decrement the heap count*/ heapCount--; }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a two objects */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ int pickObject2(ant *a , int position,int flag) { float Pdestroy1=-1; int i=0,k=0; /*Compute the probability to destroy the heap*/ Pdestroy1=lrand48()%13*1.0/12.0; /*If the probability is more than Pdestroy then destroy the heap */ if(Pdestroy1<Pdestroy) { /*pick the object randomly*/ i=lrand48()%2; /* Assign the data to the ant */ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[i]][k]; a->carrying=1; /*Correct the heap parameters*/ heaps[position].count=1; heaps[position].objects[0]=heaps[position].objects[1-i]; computeHeapParameters(&heaps[position],flag); return(1); } else return(0); }//end of function /********************************************************************/ /*Function to pick a object from a heap consisting of more than two object */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /********************************************************************/ int pickObjectn(ant *a,int position,int flag) { int i=0,k=0; /*If the criteria is satsfied then pick the object*/ if((computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)*1.0/heaps[position].Dmean)>Tremove) { a->carrying=1; for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[heaps[position].disPosition]][k]; for(i=heaps[position].disPosition;i<heaps[position].count-1;i++) heaps[position].objects[i]=heaps[position].objects[i+1]; heaps[position].count--; computeHeapParameters(&heaps[position],1); return(1);}elsereturn(0); }//end of function /********************************************************************/ /* Function to pick a object */ /********************************************************************/ void pick(ant *a,int flag) { int position=-1,i=0,j=0; float Pload1=-1.0; int hCount=0,hPos[26],picked=0; for(i=0;i<heapCount;i++) { /*Check if a heap is present in the eight neighbouring cells*/ if(abs(heaps[i].z-a->z)<=1&&abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; hPos[hCount++]=i; /*break;*/ } } /*Check if Heap is found*/ /*if(position!=-1)*/ if(hCount>0) { /* heap or object found.*/ /*Depending upon the number present in the heap call the corresponding routine*/ j=0; while(j<hCount && !picked) { switch(heaps[hPos[j]].count) { case 1: Pload1 = lrand48()%151*1.0/150.0; if(Pload1<Pload) { pickObject1(a,hPos[j],flag);picked=1; }else picked=0; break; case 2: picked=pickObject2(a,hPos[j],flag); break; default: picked=pickObjectn(a,hPos[j],flag); break; }j++;} } } /********************************************************************/ /* Function to drop a object to form a new heap */ /* Output: None */ /* Input: Ant, iteration flag */ /* Global Structure modified : heap, heapCount */ /********************************************************************/ void dropObject(ant* a,int flag) { /*Create a new heap*/ int k=0; heaps[heapCount].count=1; heaps[heapCount].x=a->x; heaps[heapCount].y=a->y; heaps[heapCount].z=a->z; heaps[heapCount].Dmax=0; heaps[heapCount].Dmean=0; heaps[heapCount].disPosition=0; for(k=0;k<features;k++) { heaps[heapCount].Odissim[k]=a->data[k]; heaps[heapCount].Ocenter[k]=a->data[k]; } if(flag==1) {heaps[heapCount].objects[0]=findInData(a->data,flag); /*computeHeapParameters(&heaps[heapCount],flag);*/ } computeHeapParameters(&heaps[heapCount],flag); heapCount++; a->carrying=-1; board[a->z][a->x][a->y]=9; }//end of function /********************************************************************/ /* Function to find the heap position during the second iteration */ /* Output: position of the heap */ /* Input: object center of the heap that the ant is carrying */ /* Global Structure modified : none */ /********************************************************************/ int findInNewheaps(irisData object) { int position=-1,i,j=0,flag[features],flg; for(i=0;i<newHeapCount;i++) { for(j=0;j<features;j++) { if(fabs(object[j]-newHeaps[i].Ocenter[j])<0.00001) flag[j]=1; else {flag[j]=0;break;} } flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /*Function to drop a object to a heap consisting of a one or more object */ /* Output: none */ /* Input: Ant, position of the heap , iteration flag */ /* Global Structure modified: heaps,newHeaps */ /********************************************************************/ void dropObject1(ant* a, int position,int flag) { int heapPosition=-1,heapPosition1=-1,i,j,k=0; irisData newData,temp; if(flag==1) { heaps[position].objects[heaps[position].count]=findInData(a->data,flag); heaps[position].count++; computeHeapParameters(&heaps[position],flag); } else { for(k=0;k<features;k++)temp[k]=heaps[position].Ocenter[k]; heapPosition=findInNewheaps(a->data); heapPosition1=findInNewheaps(heaps[position].Ocenter); if(heapPosition==-1||heapPosition1==-1) { printf("\n error in logic:new heaps\n"); //getchar(); return; } for(k=0;k<features;k++) {newData[k]=(newHeaps[heapPosition].Ocenter[k]*newHeaps[heapPosition].count+newHeaps[heapPosition1].Ocenter[k]*newHeaps[heapPosition1].count)*1.0/(newHeaps[heapPosition].count+newHeaps[heapPosition1].count);newHeaps[heapPosition].Ocenter[k]=newData[k];heaps[position].Ocenter[k]=newData[k]; } computeHeapParameters(&heaps[position],flag); for(i=newHeaps[heapPosition].count,j=0;j<newHeaps[heapPosition1].count;i++,j++) { newHeaps[heapPosition].objects[i]=newHeaps[heapPosition1].objects[j]; } newHeaps[heapPosition].count+=newHeaps[heapPosition1].count; for(i=heapPosition1;i<newHeapCount-1;i++) newHeaps[i]=newHeaps[i+1]; newHeapCount--; } a->carrying=-1; }//end of function /********************************************************************/ /* Function to drop a object */ /* Output: None */ /* Input: Ant, iteration flag */ /********************************************************************/ void drop(ant* a,int flag) { float Pdrop1=0.0; int position=-1,i=0,j=0; int hCount=0,hPos[26],dropped=0; for(i=0;i<heapCount;i++) { /*Check if a heap is present in the eight neighbouring cells*/ if(abs(heaps[i].z-a->z)<=1&&abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; hPos[hCount++]=i; /*break;*/ } } /*Check if Heap is found*/ /*if(position!=-1)*/ if(hCount>0) { /*heap or object found.*/ /*Depending on the number of objects present take action*/j=0;while(j<hCount && !dropped){ switch(heaps[hPos[j]].count) { /*If criteria is satisfied then drop the object*/ case 1: if(flag==1) { if((computeDistanceBetween2(a->data,data[heaps[position].objects[0]])*1.0/Dmax)<Tcreate) { dropObject1(a,position,flag);dropped=1; } else dropped =0; } else { if((computeDistanceBetween2(a->data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(a,position,flag); dropped=1; } else dropped=0; } break; default: if(computeDistanceBetween2(a->data,heaps[position].Ocenter)<computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)) { dropObject1(a,position,flag); dropped=1; } else dropped=0; break; }j++;} } else { /*Compute the probability to drop the object*/ Pdrop1 = lrand48()%151*1.0/150; if(Pdrop1<Pdrop) dropObject(a,flag); } }//end of function /********************************************************************/ /* Function to move the ant */ /* Output: none */ /* Input: Ant, iteration flag */ /********************************************************************/ void move(ant* a,int flag) { float pDir; /*Check the speed */ if (a->speed!=0) { /*move in the same direction*/ a->speed--; moveNext(a,flag); } else { /*generate the new direction*/ pDir=lrand48()%17*1.0/16.0; if(pDir<.85) { a->dir=lrand48()%26; } else if(pDir>.95) { a->speed=2; } moveNext(a,flag); } } /********************************************************************/ /* Function to simulate the movement of the ants */ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified: minHeapCount, minHeapPosition */ /********************************************************************/ void iterate(int flag) { int i=0,j=0,k=0,loopCount=0; if (flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS; while (i<MAXITERATIONS) { i++; for(j=0;j<loopCount;j++) { move(&ants[j],flag); if(ants[j].carrying==1) { drop(&ants[j],flag); } else { pick(&ants[j],flag); } } if(debugLevel>0){ for(k=0;k<heapCount;k++) for(j=0;j<heapCount;j++) if((k!=j)&&(heaps[k].x==heaps[j].x)&&(heaps[k].y==heaps[j].y)&&(heaps[k].z==heaps[j].z)) { printf("\nerror two heaps with same co ordinates %d %d",k,j); //getchar(); } k=0; for(j=0;j<heapCount;j++) k+=heaps[j].count; } if(heapCount<minHeapCount) { minHeapCount=heapCount; minPosition=i; } if(debugLevel>0) printf("\n i:%d Heap count %d sum %d",i,heapCount,k); else printf("\n i:%d Heap count %d",i,heapCount); heapSum+=heapCount; } }//end of function /********************************************************************/ /*Function to drop the objects carried by the ants after all the iterations*/ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified:none */ /********************************************************************/ void dropFinal(int flag) { int i=0,j=0,position=-1,loopCount=0; loopCount=currentAntCount; for(i=0;i<loopCount;i++) { if(ants[i].carrying==1) { if(flag==1) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)&&(heaps[j].z==ants[i].z)) { position=i; break; } } if(position!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position,flag); } } else { /*Find if a heap is present */ do { position=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)&&(heaps[j].z==ants[i].z)) { position=i; break; } } if(position!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position,flag); position=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position!=-1); } } } }//end of function /********************************************************************/ /* Function for the implementation of QuickSort */ /* Output: none */ /* Input: data structure, low and high indices */ /* Global structure modified:none */ /********************************************************************/ void quickSort( heap A[], int low,int high ) { int mid=0; if(low<high) { mid=partition(A,low,high); quickSort(A,low,mid); quickSort(A,mid+1,high); } } /********************************************************************/ /* Partition routine used by quick sort */ /* Output: partition location */ /* Input: data , low, high */ /* Global structure modified:none */ /********************************************************************/ int partition(heap a[], int low,int high) { heap temp; int x=0,i=0,j=0; i=low; j=high; x=a[low].count; while (1) { while (a[j].count<x) j=j-1; while (a[i].count>x) i=i+1; if(i<j) { temp=a[i]; a[i]=a[j]; a[j--]=temp; } else return(j); } } /********************************************************************/ /* Function used to write the cluster information */ /* Output: none */ /* Input:iteration flag */ /* Global structure modified:none */ /********************************************************************/ void writeClusterInformation(int flag) { FILE *fp=fopen("center.clt","w"); FILE *fp1; FILE *fp2; FILE *fp3; char temp[80]; int i=0,j=0,k=0; int lastCount=0; int rowCount,colCount,antCount; strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp3=fopen(temp,"a"); if(dataDump) {strcpy(temp,"");sprintf(temp,"%sTot.out",filename);fp1=fopen(temp,"a");strcpy(temp,"");sprintf(temp,"%sObj.out",filename);fp2=fopen(temp,"a");if(fp1==NULL||fp2==NULL)printf("\n Error in opening file in the writer Cluster Information routine\n"); } rowCount=currentRow; colCount=currentRow; antCount=currentAntCount; if(fp==NULL) { printf("\n Unable to open cluster center output file \n"); /*return;*/ exit(0); } /*sort the array according to the count value and write the value of the top three elements*/ if((flag==1)&&(!EntireHeaps)) quickSort(heaps,0,heapCount); if(EntireHeaps) {if(flag==1) lastCount=heapCount;else lastCount=newHeapCount; } else lastCount=c; for(i=0;i<lastCount;i++) { if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else { for(k=0;k<features;k++) { fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",newHeaps[i].Ocenter[k]); fprintf(fp,"\n"); } else { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); fprintf(fp,"\n"); } } if(dataDump) { fprintf(fp1,"\n Information from the Ant Based Algorithm \n"); fprintf(fp1,"\n Important Parameters : Board %d X %d Ants : %d Iterations %d Total Heaps %d ",rowCount,colCount,antCount,MAXITERATIONS,lastCount); } if(flag==0) { if(dataDump) { fprintf(fp1," TCreateForHeaps %f \n",TcreateForHeaps); fprintf(fp2,"\nTotal Heaps : %d\n",heapCount); fprintf(fp2,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); } fprintf(fp3,"\n@ %d\n",lastCount); } else if(dataDump) fprintf(fp1,"\n");if(dataDump) { fprintf(fp1,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); for(i=0;i<lastCount;i++) if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp2,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); } fprintf(fp1," %5d\n",newHeaps[i].count); fprintf(fp2," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp1," %5d\n",heaps[i].count); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]); fprintf(fp1," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]); fprintf(fp1," %5d\n",heaps[i].count); }} if(flag==0) { if(dataDump) fprintf(fp1,"\n Objects in the heaps \n");for(i=0;i<newHeapCount;i++) { if(dataDump) fprintf(fp1,"\n\n Heap %d\n \n",i+1);fprintf(fp3,"# %d %d\n",i ,newHeaps[i].count); for(j=0;j<newHeaps[i].count;j++){ for(k=0;k<features;k++){ fprintf(fp3,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]); if(dataDump) fprintf(fp1,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]);} if(dataDump) fprintf(fp1,"\n"); fprintf(fp3,"\n"); } } } fclose(fp); fclose(fp3); if(dataDump) { fclose(fp1);fclose(fp2); }}//end of flie /********************************************************************/ /* Function to initialise the new heaps */ /* Output: none */ /* Input:new Heap structure */ /* Global structure modified:none */ /********************************************************************/ void initialiseNewHeaps(heap newHeaps[]) { int i=0,j=0; for(i=0;i<lCount;i++) { newHeaps[i].count=0; for(j=0;j<features;j++) newHeaps[i].Ocenter[j]=V[i][j]; newHeaps[i].x=heaps[i].x; newHeaps[i].y=heaps[i].y; newHeaps[i].z=heaps[i].z; } }//end of function /********************************************************************/ /* Function to initialise the new heaps */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ int findPosition(int i) { int j,position=0; for(j=1;j<lCount;j++) { if(U[j][i]>U[position][i]) position=j; } printf("\n Position %d ",position); return(position); }//end of function find position /********************************************************************/ /* Function to add object */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ void addObject(int object,heap * heapPosition) { heapPosition->objects[heapPosition->count]=object; heapPosition->count++; }//end of function add object /********************************************************************/ /* Function to harden the outputs obtained from fcm */ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/ void harden(heap newHeaps[]) { int i,heapPosition=-1,sum=0,j=0; /*initialise the new heaps*/ initialiseNewHeaps(newHeaps); for(i=0;i<count;i++) { heapPosition=findPosition(i); addObject(i,&newHeaps[heapPosition]); } /* To check for degenerate partitions*/ for(i=0;i<lCount;i++) { if(newHeaps[i].count==0){for(j=i;j<lCount-1;j++){newHeaps[j]=newHeaps[j+1];}lCount--;i--;} } newHeapCount=lCount; for(i=0;i<lCount;i++) computeHeapParameters(&newHeaps[i],1); if(debugLevel>0) { for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\n sum = %d",sum);} }//end of function/********************************************************************/ /* Function to initialize the initial parameters for the ant algorithm*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void init() { int i=0,j=0,k; for(k=0;k<zDim;k++)for(i=0;i<MAXROWS;i++) for(j=0;j<MAXCOLS;j++) board[k][i][j]=-9; heapCount=0; newHeapCount=0; heapRow=0; minPosition=-1; minHeapCount=100000; for(i=0;i<MAXANTS;i++) { ants[i].carrying=-1; ants[i].x=-1; ants[i].y=-1; ants[i].z=-1; ants[i].speed=-1; ants[i].dir=-1; } } /********************************************************************/ /* Function to initialize the initial board */ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void initialiseBoard() { int i,j,k;for(k=0;k<zDim;k++) for(i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[k][i][j]=-9; }/********************************************************************/ /* Function to harden the outputs obtained from fcm(2nd stage)*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: Cluster center , cluster center count*/ /********************************************************************/void harden1() { int i=0,heapPosition=-1; for(i=0;i<heapCount;i++) cenCount[i]=0; for(i=0;i<n;i++) { heapPosition=findPosition1(i); addObject1(i,heapPosition); } writeInfo(); }//end of function/********************************************************************/ /* Function to find to which class the object belongs */ /* Output: Class number */ /* Input: object position */ /* Global Structure Modified: None */ /********************************************************************/int findPosition1(int i) { int j,position=0; for(j=1;j<heapCount;j++) { if(U[j][i]>U[position][i]) position=j; } return(position); }//end of function find position/********************************************************************/ /* Function to Write the output of the hardened objects to file*/ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/void writeInfo(){int i=0,j=0,k=0;FILE *fp=fopen("fcm.out","a");if(fp==NULL){printf("\n Unable to open fcm output file \n");return;}fprintf(fp,"\n@ %d\n",heapCount);for(i=0;i<heapCount;i++){fprintf(fp,"# %d %d\n",i,cenCount[i]);for(j=0;j<cenCount[i];j++){for(k=0;k<s;k++)fprintf(fp,"%8.2f ",clsCen[i][j][k]/scale[k]+minInput[k]);fprintf(fp,"\n");}}fclose(fp);return;}/********************************************************************/ /* Function to add a object to a cluster (2nd stage) */ /* Output: none */ /* Input: object poistion , cluster position */ /* Global Structure Modified: Cluster object and cluster count*/ /*******************************************************************/void addObject1(int object,int heapPosition) { int k=0; for(k=0;k<features;k++) clsCen[heapPosition][cenCount[heapPosition]][k]=X[object][k]; cenCount[heapPosition]++; return; }//end of function add object/********************************************************************/ /* Function to read the original classification of objects */ /* Output: none */ /* Input: none */ /* Global Structure Modified: None */ /*******************************************************************/void readOrg(){int i=0,k=0;char temp[80];FILE *fp;strcpy(temp,"");sprintf(temp,"%sFull.data",filename);fp=fopen(temp,"r");if(fp==NULL){printf("\n Unable to open full data input file ");exit(0);}for(i=0;i<n;i++){fscanf(fp,"%f ",&orgData[i][0]);for(k=1;k<s+1;k++)fscanf(fp,"%f ",&orgData[i][k]);}return;}// end of function/********************************************************************/ /* Function to classify the objects in different clusters */ /* Output: none */ /* Input: the cluster objects, the original classification, */ /* number of objects in the cluster,file to write the data */ /* Global Structure Modified: None *//********************************************************************/int analysisData(float data[][s],float orgData[n][s+1],int count,FILE * fp){int i=0,j=0,k=0,type=1,max=0;heapInfo info;for(i=0;i<c;i++){info.classObj[i]=0;}info.total=0;info.total=count;for(i=0;i<count;i++)for(j=0;j<n;j++){type=1;for(k=0;k<s;k++)if(fabs(data[i][k]-orgData[j][k+1])>errThresh){type=-1;break;}if(type!=-1){info.classObj[(int)orgData[j][0]-1]++;break;}}max=0;for(k=0;k<c;k++){if(info.classObj[k]>info.classObj[max])max=k;fprintf(fp,"\nClass %d Objects % d ",k+1,info.classObj[k]);}j=0;for(k=0;k<c;k++){if(k!=max)j+=info.classObj[k];}fprintf(fp,"\n Total errors : %d \n",j);return(j);}//end of analyse/********************************************************************/ /* Function to read the cluster information */ /* Output: none */ /* Input: input file pointer , output file pointer */ /* Global Structure Modified: None *//********************************************************************/void readFCM(FILE* fp,FILE *fp1){int i=0,j=0,k=0,l=0;int totalRuns=0,heapCount=0,junk=0,sum=0;char ch;FILE *fp2=fopen("errors.out","a");ch = 'c'; while (ch != '$') fscanf (fp, "%c", &ch);fscanf(fp,"%d\n",&totalRuns);printf("\n total runs %d ",totalRuns);for(l=0;l<totalRuns;l++){fscanf(fp,"%c",&ch);fscanf(fp,"%d\n",&heapCount);fprintf(fp1,"\n \nExperiment %d \n ",l+1);sum=0;for(i=0;i<heapCount;i++){fscanf(fp,"%c",&ch);fscanf(fp," %d %d\n",&junk,&clsCenCount[i]);for(j=0;j<clsCenCount[i];j++)for(k=0;k<s;k++)fscanf(fp,"%f",&fcmData[i][j][k]);fscanf(fp,"\n");fprintf(fp1,"\n\n Heap %d Total Objects %d \n",i+1,clsCenCount[i]);sum+=analysisData(fcmData[i],orgData,clsCenCount[i],fp1);}fprintf(fp2," %3d %3d %3d \n",l,sum,heapCount);}fprintf(fp2,"\n --------------------------\n");fclose(fp2);return;}//end of function/********************************************************************/ /* Function to update the board parameters */ /* Output: none */ /* Input: none */ /* Global Structure Modified: board size, ant count *//********************************************************************/void adjustBoard(int flag){int newRow=0,newAnt=0,antDiff=0,antsKilled=0,i=0,position[MAXANTS],position1=-1,j=0,k=0,a,b,z; newRow= (int)ceil(sqrt(4.0*heapSum/updateAfter)); newAnt= (int)ceil((heapSum*1.0/updateAfter)*1.0/3.0); if(newAnt<minAnts)newAnt=minAnts; if(newRow<rowMin)newRow=rowMin;antDiff=currentAntCount-newAnt; if((antDiff>0)&&(newAnt>=minAnts)) {for(i=0;i<currentAntCount;i++){if(ants[i].carrying==-1){position[antsKilled++]=i;}} if(antsKilled>=antDiff){for(i=0;i<antDiff;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1];for(k=i+1;k<antsKilled;k++)position[k]--; } currentAntCount=newAnt; }else {for(i=0;i<antsKilled;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1]; for(k=i+1;k<antsKilled;k++)position[k]--; }if(flag==1) { for(i=currentAntCount-1,k=0;k<antDiff-antsKilled;k++,i--) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)&&(heaps[j].z==ants[i].z)) { position1=i; break; } } if(position1!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position1,flag); }else { dropObject(&ants[i],flag); } } } else { //flag is zero 2nd stage /*Find if a heap is present */ do { position1=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)&&(heaps[j].z==ants[i].z)) { position1=i; break; } } if(position1!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position1].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position1,flag); position1=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position1!=-1); }//end else currentAntCount=newAnt;}//end elsecurrentAntCount=newAnt;}//end iffor(i=0;i<newAnt;i++){if((ants[i].x>=newRow)||(ants[i].y>=newRow)||ants[i].z>zDim) { a=lrand48()%newRow; b=lrand48()%newRow; z=lrand48()%zDim; ants[i].x=a; ants[i].y=b; ants[i].z=z; }} //Done with ants, now adjust the boardif((currentRow>newRow)&&(newRow>=rowMin)){for(i=0;i<heapCount;i++){if((heaps[i].x>=newRow)||(heaps[i].y>=newRow)||(heaps[i].z>=zDim)) {do { a=lrand48()%newRow; b=lrand48()%newRow; z=lrand48()%zDim; } while(found(z,a,b));//adjust the heap poistionheaps[i].x=a;heaps[i].y=b;heaps[i].z=z;board[z][a][b]=9;}//end if}//end for for(i=0;i<currentAntCount;i++){if((ants[i].carrying==1)&&((ants[i].x>=newRow)||(ants[i].y>=newRow)||(ants[i].z>=zDim))){//adjust the ant locationdo { a=lrand48()%newRow; b=lrand48()%newRow; z=lrand48()%zDim; } while(found(z,a,b));//adjust the heap poistionants[i].x=a;ants[i].y=b;ants[i].z=z;}//end if}//end for currentRow=newRow;}//end if }//end of function void writeIncremental(int iteration,int flag){FILE *fp=fopen("dump.txt","w");int i=0,j=0,k=0;fprintf(fp,"Stage %d\n",flag);fprintf(fp,"Board %d\n",currentRow);fprintf(fp,"Ants %d\n",currentAntCount);fprintf(fp,"Iteration %d\n",iteration);fprintf(fp,"Heaps %d\n",heapCount); if(flag==0)fprintf(fp,"NewHeapCount %d\n",newHeapCount); fprintf(fp,"Ants\n");for(i=0;i<currentAntCount;i++){fprintf(fp,"%d %d %d %d %d ",ants[i].x,ants[i].y,ants[i].carrying,ants[i].speed,ants[i].dir);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",ants[i].data[k]);fprintf(fp,"\n");}fprintf(fp,"Heaps\n");for(i=0;i<heapCount;i++){fprintf(fp,"%d %d %d %d %8.2f %8.2f \n",heaps[i].x,heaps[i].y,heaps[i].count,heaps[i].disPosition,heaps[i].Dmax,heaps[i].Dmean);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Ocenter[k]);fprintf(fp,"\n");for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Odissim[k]);fprintf(fp,"\n");if(flag==1){for(j=0;j<heaps[i].count;j++)fprintf(fp,"%d ",heaps[i].objects[j]);fprintf(fp,"\n");}}if(flag==0){fprintf(fp,"newHeaps\n");for(i=0;i<newHeapCount;i++){fprintf(fp,"%d\n",newHeaps[i].count);for(j=0;j<newHeaps[i].count;j++)fprintf(fp,"%d ",newHeaps[i].objects[j]);fprintf(fp,"\n");}}fclose(fp);}//end of function/********************************************************************/ /* Function Main */ /********************************************************************/ int main(int argc ,char** argv) { int sum=0,k=0,i=0,j=0; char temp[80]; FILE *fp=fopen("fcm.out","w"); FILE *fp1; FILE *fp2=fopen("antAnalysis.out","a"); FILE *fp3=fopen("fcmAnalysis.out","a"); FILE *fp4=fopen("errors.out","w"); FILE *fp5; FILE *fpJm=fopen("jm.out","w"); fclose(fp4); fclose(fpJm); sprintf(temp,"%sObj.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sTot.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp1=fopen(temp,"w"); fprintf(fp,"\n$%d",EXPRUN); fprintf(fp1,"\n$%d",EXPRUN); fclose(fp); fclose(fp1); if(argc==2)sscanf(argv[1],"%d",&debugLevel); printf("\n Debug level %d\n",debugLevel); for(k=0;k<zDim;k++) for( i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[k][i][j]=-9; //Read from the file readInput(); //Compute the distance of all the points if(maxDist) { Dmax=computeDistance(); //Compute the maximum distance fp5=fopen("maxData.txt","w");fprintf(fp5,"%f",Dmax);fclose(fp5); } else {/*if((fp5=fopen("maxData.txt","r"))==NULL);{printf("\n Max Distance file not found, exiting . . . \n");exit(-1);}*/fp5=fopen("maxData.txt","r");fscanf(fp5,"%f",&Dmax);fclose(fp5); } printf("\n %f \n",Dmax); //Initialise the board for(k=0;k<EXPRUN;k++) { init(); sum=0; srand48(state1[k]); initialiseBoard(); initialise(1); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(1); printf("\n %d \n",heapCount); //Simulate the working of ants iterate(1); //drop the objects after all the iterations dropFinal(1); //to verify the correctness for(i=0;i<heapCount;i++) sum+=heaps[i].count; //write the cluster centers to the file writeClusterInformation(1); printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); printf("\n\n k %d \n\n",k); Fcm(data,0); //compute new board size. lCount=heapCount; heapRow=(int)ceil(pow(4*heapCount,1.0/3.0)); newHeapCount=lCount; printf("\n LCount %d newHeapCount %d heap Row %d \n",lCount,newHeapCount,heapRow); //harden the objects harden(newHeaps); //iterate with the heaps as the objects. initialiseBoard(); initialise(0); for(i=0;i<lCount;i++) computeHeapParameters(&heaps[i],0); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(0); printf("\n %d \n",heapCount); //getchar(); //Simulate the working of ants iterate(0); dropFinal(0); writeClusterInformation(0); sum=0; for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); // getchar(); fpJm=fopen("jm.out","a"); fprintf(fpJm,"Experiment %2d: ",k); fclose(fpJm); Fcm(data,1); harden1(); } fp=fopen("fcm.out","a"); fp1=fopen(temp,"a"); fprintf(fp,"\n"); fprintf(fp1,"\n"); fclose(fp); fclose(fp1); fp=fopen("fcm.out","r"); fp1=fopen(temp,"r");printf("\n Before read org\n");readOrg();printf("\nafter read org\n");readFCM(fp1,fp2);printf("\n After 1st read fcm\n");readFCM(fp,fp3);printf("\n After 2 fcm read \n");return(1); }//end of main /****************************************************************/ float NORM(feature , feature); void find_covar(); void Fcm (irisData Data[MAXDATA],int stage) { int i,j,l; FILE *ofile; char temp[80]; int flag=0;//added by parag FILE *iniClsCen=fopen("center.clt","a+"),*fpJm; float jmFinal=0; if(iniClsCen==NULL) { printf("\n Unable to open the initial cluster center file\n"); printf("\n choosing random cluster centers....\n"); flag=1; } strcpy(temp,""); sprintf(temp,"%s.data",filename); strcpy (fname,temp); /* Read from this file */ m=2.0; /* The exponent */ /*GET_INPUTS1(fname);*/ /* read in feature vectors */ for (j=0; j<n ; j++) /* Read File in row-major */ for (i=0; i<s ; i++) /* format */ X[j][i]=Data[j][i]; Random_seed=state1[run];/*randseed*/ srand48(Random_seed); for (run=0;run<TOTRUNS;run++) { //flag=1;//for testing random values if (EntireHeaps) lCount=heapCount; else lCount=c; for(i=0;i<lCount;i++) for(j=0;j<s;j++) V[i][j]=0; for(i=0;i<lCount;i++) { for(l=0;l<s;l++) { if(flag==1) { rand_index = lrand48() % n; V[i][l] = X[rand_index][l]; } else { fscanf(iniClsCen,"%f ",&V[i][l]); } }//end for } eps=0.001; stop = FALSE; /* This loop finds the final cluster center and the corresponding U values */ z = 0; while (stop == FALSE) { z++; UMAT(U,V,X); /** Update the U matrix **/ stop = FINISHED(U1,eps); CLUSTER(U,X); /** Get new cluster center **/ printf("Iteration: %d\n\n", z); } /* end while */ printf("Number of iterations: %d\n\n", z);strcpy(temp,""); sprintf(temp,"%sFCM.out",filename);if(stage>0){jmFinal=Compute_Jm(V,X);fpJm=fopen("jm.out","a");fprintf(fpJm," classes %2d Jm: %8.5f\n",lCount,jmFinal);fclose(fpJm);}if(dataDump) Output(temp); /* output the results */ }/*end for*/ if(dataDump) { ofile=fopen(temp,"a"); for (i=0; i <= mins; i++) fprintf(ofile, "Min %d of %10.3f occurred %d times\n", i, mintab[i], mincount[i]); fprintf(ofile, "Average iterations %f\n", (float)aveit/(float)TOTRUNS); fclose(ofile); } }/* end Main */ /* The GET_INPUTS1 procedure opens an input file, reads the number of input vectors, the number of features per vector, the number of clusters, and epsilon, then it reads the input values */ void GET_INPUTS1(char fname[]) //char fname[]; { /* Parameters: fname -- name of file containing input info. */ FILE *infile ;//*fopen(); //char junk[10][80]; char realfname[80]; char ch; char fileName1[80]; //int temp[10], i, j, inputs, outputs, count; int i,j; sprintf (realfname, "%s", fname); /* open input file */ if(normalize==1) strcpy(fileName1,"gtest1.data"); else strcpy(fileName1,fname); if((infile = fopen (fileName1, "r")) == NULL) printf("\n CAN'T OPEN %s\n",realfname); else { ch = 'c'; /* Discard leading comments */ while (ch != '#') fscanf (infile, "%c", &ch); for (j=0; j<n ; j++) /* Read File in row-major */ { /* format */ for (i=0; i<s ; i++) fscanf (infile, "%f", &X[j][i]); /* fscanf (infile, "%d", &temp[1]); */ /* end for */ } /* end for */ fclose(infile); /* close input file */ }/* end else */ } /* end GET_INPUTS1 */ /* The NORM function computes the norm of two vectors, x and v, of dimension s. This gives an indication of the distance between them */ float NORM( feature x, feature v) //feature x, v; { /* Parameters : x -- a local copy of an input vector v -- a local copy of a cluster center */ int i,j; /* loop variable */ double sum; /* the square root of sum is the norm; sum is the sum of the differences squared */ float mat1[s]; float mat2[s]; if (maha) { for (i=0; i<s; i++) mat1[i]=x[i]-v[i]; for(i=0;i<s;i++) { sum =0; for(j=0;j<s;j++) sum += mat1[j] * inv_cov[j][i]; mat2[i] = sum; } sum =0; for(j=0;j<s;j++) sum += mat1[j]*mat2[j]; } else { sum = 0; for(j=0;j<s;j++) sum += (x[j] - v[j])* (x[j] - v[j]); } return (float)(sqrt(sum)); } /* end NORM */ /* The UMAT procedure calculates the updated U matrix according to Bezdek's formula. Its side-effect is the update of the global array U1 */ void UMAT( matrix U,center V, objects X) /*matrix U; center V; objects X;*/ { /* Parameters: U, V, and X: same as in main program */ int i, j, k,l ;/* loop variables *///, class /* class whose cluster center //is closest to pattern k */; float d1,d2,d; float sum; int exact; for (k=0;k<n;k++) { /*printf("\n k %d ",k);*/ exact=false; for (i=0;i<lCount;i++) { sum=0; for (j=0;j<lCount;j++) { d1=NORM(X[k],V[i]); d2=NORM(X[k],V[j]); if(d2!=0) { d= d1/d2; d= d * d;/* pow(d1/d2,2.0/(m-1.0)); */ sum+=d; } else { exact = true; for(l=0;l<lCount;l++) if (l==j) U1[l][k]=1.0; else U1[l][k]=0.0; break; } } if (exact!=true) U1[i][k]=1.0/sum; } } } /* end UMAT */ /* The function FINISHED determines if a termination occurs. If not it updates U with U1, so its side-effect is the potential modification of U */ BOOLEAN FINISHED( matrix U1,float eps) //matrix U1; float eps; { /* Parameters: U1, eps-- same as in main */ float sum; /* sum of squared differences between corresponding elements of U and U1 */ int i,k; /* loop control variabes */ BOOLEAN finished; /* set to true if all corresponding elements are within epsilon */ finished = TRUE; sum = 0; for (i=0; i<lCount; i++) for (k=0; k<n; k++) sum += (U[i][k] - U1[i][k])*(U[i][k]-U1[i][k]); if (sqrt(sum) > eps) { finished = FALSE; for (i=0; i<lCount; i++) for (k=0; k<n; k++) U[i][k] = U1[i][k]; } /* end if */ return finished; } /* end FINISHED */ /* The CLUSTER procedure determines cluster centers in V for the c classes being searched for. The global array V is updated */ void CLUSTER( matrix U, objects X) //matrix U; objects X; { /* Parameters: U, X -- as in main */ int i, j, k; /* loop control variables */ feature num; /* numerator in the cluster center computation formula presented by Bezdek */ float denum; /* denumenator in the obove formula */ for (i=0; i<lCount; i++) { denum = 0; for (j=0; j<s; j++) { num[j] = 0; for (k=0; k<n; k++) num[j] += U[i][k] * U[i][k] * X[k][j]; /* pow(U[i][k],m) * X[k][j]; */ } /* end for */ for (k=0; k<n; k++) denum += U[i][k] * U[i][k]; /* pow(U[i][k],m); */ for (j=0; j<s; j++) V[i][j] = num[j] / denum; } /* end for */ } /* end CLUSTER */ float Compute_Jm(center V, objects X) //center V; //objects X; { int i, k,found; double Jm_value; float u,dik; Jm_value = 0; for (k=0; k<n; k++) { found = FALSE; for (i=0; i<lCount; i++) { dik=NORM(X[k],V[i]); dik=dik*dik; if (dik==0.0) { if (found == FALSE) { u=1.0; found = TRUE; printf("found the case with dik=0\n"); } else { printf("\n cant proceed with this initialization"); exit(1); } } else { if (found != TRUE) u=U1[i][k]; /* get_Uvalue(V,X,dik,k); */ else u=0.0; } Jm_value += u * u * dik;/* pow(u, m) * dik; */ } } return (Jm_value); } /* end Compute_Jm */ /* The Output procedure outputs the U matrix which gives the fuzzy measure of each feature belonging to a cluster center. It also outputs the cluster center for each class */ void Output(char fname[]) //char fname[80]; /* Parameters: U, V -- same as in main */ { int i, j, found; /* loop control variables */ float J2c; if ((fp=fopen(fname,"a"))==NULL) printf("\n CAN'T OPEN %s\n",fname); else { fprintf(fp,"\n The cluster centers are: \n"); fprintf(fp,"\n \n"); for (i=0; i<lCount; i++) { fprintf(fp,"\nCluster center %d: ",i+1); fprintf(fp,"\n"); for (j=0; j<s; j++) fprintf(fp,"%8.7f ",V[i][j]); } /* end for */ fprintf(fp,"\nThe membership grades for the feature vectors are:\n"); for (j=0; j<n; j++) { fprintf(fp,"\n"); for (i=0; i<lCount; i++) fprintf(fp," %8.7f",U[i][j]); } /* end for */ } /* end if */ J2c= Compute_Jm(V,X); found =0; for (i=0;i<= mins; i++){ if ((found == 0) && ((J2c - mintab[i]) < .001) && ((J2c - mintab[i]) > -.001)){ mincount[i]++; found = 1; } } if (found == 0){ mins++; mintab[mins]=J2c; mincount[mins]=1; } fprintf(fp,"\nJ%3.1f = %f", m,J2c); fprintf(fp, "Number of iterations: %d\n\n", z); aveit=aveit + z; fclose(fp); } /***************************************************************/ void find_covar(int m) //int m; { int i,j,k; float mean[s],sum; for (i=0;i<s;i++) mean[i]=0; for (i=0;i<s;i++) for (j=0;j<m;j++) mean[i]+=X[j][i]; for (i=0;i<s;i++) mean[i]/=m; for (i=0;i<s;i++) for (j=0;j<s;j++) { sum=0; for (k=0;k<m;k++) sum+=(X[k][i]-mean[i])*(X[k][j]-mean[j]); Y[i][j]=sum/m; } }
Parag Kanade/fuzzy ants/3D Board/header_xyz.h
/********************************************************************//* Ant Class parameters *//* SPEED # amplitude of moves [1,10] *//* P direction Probability to move in the same direction [.5,1] *//* Max carry : Maximum object carrying time [20,200] *//* P load Probability to pick up a single object [0.4,0.8] *//* P destroy probability to destroy a heap of two objects [0,0.6] *//* T remove min. dissimilarity necessary for removing an object *//* from a heap [.1,.2] *//* T create max dissimilarity permitted for creating a heap[.05,.2]*//********************************************************************/ #include <stdio.h>#include <math.h>#include <string.h>#include<stdlib.h>#include <ctype.h>#include <time.h>#define MAXANTS 50#define MAXDATA 150#define MAXANTSFORHEAPS 10#define MAXITERATIONS 1000#define MAXROWS 9#define MAXCOLS 9#define zDim 9#define EXPRUN 50#define Tremove 1.50#define Tcreate 0.5#define Pdrop 0.2#define Pdestroy 0.3#define Pload 0.3#define normalize 0#define EntireHeaps 1#define TcreateForHeaps 0.12#define features 4#define filename "iris"#define errThresh 0.1#define dataDump 1#define maxDist 0#define INITIALOBJECTS 75#define OBJINC 10/* some type definitions to make C code a little more readable */#define TRUE 1#define FALSE 0#define n MAXDATA /* number of input vectors */#define s features /* number of features */#define c 3 /* number of clusters */#define TOTRUNS 1 /* number of V's to write out */#define false 0#define true 1#define maha 0#define square 0extern int count;int debugLevel=0;/* To debug the code and verify the correctness of algorithms*/int currHeapCount=0;typedef int BOOLEAN;typedef short TYPE_IN_DATA; /* Type of input binary data */typedef float feature[s]; /* Type of each input; made up of input features */typedef float irisData[s];typedef feature objects[MAXDATA]; /* Type of array holding all inputs */typedef feature center[MAXDATA]; /* Type of array holding cluster centers */typedef float matrix[MAXDATA][MAXDATA];/* Type of the matrix containing membership grades */typedef struct Heap {float Dmax;//maximum dissimilar distanceirisData Ocenter;//center objectfloat Dmean;//mean of the distance between the center and all the objectsirisData Odissim;//most dissimilar objectint x;//x position on the boardint y;//y position on the boardint z;//z position on the boardint count;//number of objects in the heapsint disPosition;//most dissimilar objectint objects[MAXDATA];int objCount;}heap;typedef struct Ant{int x;int y;int z;int carrying;int speed;int dir;irisData data;}ant;float orgData[n][s+1];float fcmData[260][n][s];int clsCenCount[260];int currentRow=0;int currentAntCount=0;int updateAfter=50;int heapSum=0;int minAnts=3;int rowMin=5;typedef struct HeapInfo{int total;int classObj[c];} heapInfo;/*heapInfo info[MAXDATA];*//********************************************************************//***Function decelarations*//********************************************************************//***For ant based algorithm*/void readInput();float computeDistance();float computeDistanceBetween2(irisData a,irisData b);float findMax(float *distance);float value(irisData a);int found(int z,int a , int b);void initialise(int flag);int findObject(int z,int a,int b);void initialiseAnts(int flag);void moveNext(ant* a,int flag);void computeHeapParameters(heap* data,int flag);void pickObject1(ant *a,int position,int flag);int pickObject2(ant *a , int position,int flag);int pickObjectn(ant *a,int position,int flag);void pick(ant *a,int flag);void dropObject(ant* a,int flag);int findInNewheaps(irisData object);void dropObject1(ant* a, int position,int flag);void drop(ant* a,int flag);void move(ant* a,int flag);void iterate(int flag);void dropFinal(int flag);int partition(heap a[], int low,int high);void quickSort( heap A[], int low,int high ) ;void writeClusterInformation(int flag);void initialiseNewHeaps(heap newHeaps[]);int findPosition(int i);void harden(heap newHeaps[]);void harden1();int findPosition1(int );void writeInfo();void addObject1(int ,int);void readFCM(FILE *,FILE *);void readOrg();int findInData(irisData input,int iflag);void adjustBoard(int flag);void writeIncremental(int iteration,int flag);/********************************************************************//***For FCM algorithm*/void GET_INPUTS1(char []);void UMAT( matrix,center,objects);BOOLEAN FINISHED(matrix, float);void CLUSTER( matrix, objects);void Output(char[]);void Fcm(irisData data[],int stage);float Compute_Jm(center V, objects X);/********************************************************************/
Parag Kanade/fuzzy ants/Gauss3/gauss03.data
Gauss data | |
# | |
-0.46551197 | 2.3396181 |
-0.14154019 | 2.6467355 |
-0.06147374 | 2.910021 |
-0.00960664 | 2.6959237 |
0.13522751 | 3.3371545 |
0.15816343 | 2.74101 |
0.16902868 | 2.7145902 |
0.20321506 | 2.3230994 |
0.24094079 | 2.3069846 |
0.25245225 | 3.1839526 |
0.26993324 | 3.5483323 |
0.28680391 | 2.6052432 |
0.3192367 | 3.2276855 |
0.36114833 | 3.8009784 |
0.4244067 | 2.8634449 |
0.46037797 | 2.4532789 |
0.46098959 | 3.3555875 |
0.48936047 | 2.8126198 |
0.493417 | 1.52432961 |
0.5579586 | 3.0069093 |
0.59517099 | 1.74266104 |
0.601286 | 3.447746 |
0.64249205 | 1.22137058 |
0.64603926 | 3.098612 |
0.68936857 | 3.3436606 |
0.70125847 | 2.9881431 |
0.70954162 | 2.8340884 |
0.71271143 | 2.1911658 |
0.73828501 | 3.9157625 |
0.76121259 | 3.887774 |
0.76300537 | 4.36236 |
0.78715506 | 2.7998882 |
0.79603202 | 2.3837631 |
0.81552587 | 1.7659359 |
0.81671088 | 3.0235945 |
0.83646559 | 2.7292928 |
0.84905869 | 1.90959966 |
0.87280583 | 2.9185033 |
0.93911004 | 3.2377149 |
0.94658989 | 2.8099329 |
0.95071896 | 4.3593771 |
0.95477185 | 1.82422933 |
1.0475351 | 4.7358953 |
1.0483555 | 3.6222619 |
1.0663274 | 3.0772458 |
1.0719789 | 3.3051114 |
1.0841659 | 3.8982847 |
1.0917331 | 2.4965835 |
1.1268271 | 2.7541776 |
1.1308673 | 3.1353612 |
1.1428466 | 3.0972579 |
1.1493513 | 2.8227118 |
1.1819349 | 2.8738619 |
1.1900377 | 2.5835831 |
1.2101874 | 2.8796963 |
1.2181118 | 4.0111068 |
1.2277972 | 3.0808183 |
1.2335498 | 3.9573163 |
1.2448562 | 2.6017201 |
1.2555436 | 2.9472067 |
1.2597352 | 1.95874592 |
1.2601195 | 1.81798378 |
1.2715242 | 1.46185734 |
1.2749423 | 4.2592336 |
1.2888759 | 3.4162943 |
1.319464 | 3.1180977 |
1.3266557 | 2.9249356 |
1.3269461 | 3.8783508 |
1.3458998 | 2.6047048 |
1.3471548 | 3.0660325 |
1.3753515 | 3.4089999 |
1.3793406 | 3.1089793 |
1.3872928 | 4.3455047 |
1.3979966 | 3.3829163 |
1.4001717 | 4.0482038 |
1.4054732 | 2.6215221 |
1.4312392 | 1.79191521 |
1.4354818 | 4.0271297 |
1.4410139 | 3.7986203 |
1.4641202 | 1.58155858 |
1.4646153 | 4.9791516 |
1.5055329 | 2.0990125 |
1.5286615 | 3.6943944 |
1.5534019 | 4.741445 |
1.5735908 | 2.5571016 |
1.5856639 | 1.99127551 |
1.6083411 | 3.3154722 |
1.6167515 | 4.4641362 |
1.6315791 | 3.9447703 |
1.6485825 | 2.9459715 |
1.6558902 | 2.1154736 |
1.6603318 | 3.4801616 |
1.6657018 | 2.9762646 |
1.6740867 | 3.9751515 |
1.7109312 | 2.5716093 |
1.7172934 | 2.9542265 |
1.7245997 | 3.387059 |
1.7280016 | 4.2168608 |
1.7407356 | 2.6770587 |
1.7446611 | 4.8440441 |
1.7479167 | 2.3913499 |
1.7507312 | 3.769599 |
1.7567404 | 2.4447784 |
1.7591262 | 4.9952283 |
1.7610234 | 4.5877581 |
1.7736913 | 2.4399875 |
1.7826518 | 4.1827802 |
1.7882331 | 3.7558682 |
1.8048077 | 2.4894358 |
1.806578 | 3.2980184 |
1.8105734 | 4.0728863 |
1.8132452 | 1.11900227 |
1.8581162 | 3.3816176 |
1.8735926 | 3.1120087 |
1.8771577 | 2.9606585 |
1.8791867 | 1.81713304 |
1.8866894 | 2.5761363 |
1.8881009 | 1.12698201 |
1.8980516 | 3.4640572 |
1.911659 | 1.92031474 |
1.9163593 | 3.2659011 |
1.9217044 | 2.9429349 |
1.9240625 | 2.2683148 |
1.933498 | 1.99443935 |
1.9366692 | 4.0426166 |
1.9572064 | 4.2689621 |
1.987931 | 5.1287767 |
1.9907116 | 2.6489055 |
1.9930155 | 3.6846483 |
2.0011578 | 3.3236036 |
2.0107086 | 3.1802041 |
2.0650972 | 1.62687304 |
2.0760993 | 2.8564104 |
2.076595 | 4.141211 |
2.0797088 | 3.6444816 |
2.0828643 | 3.4026682 |
2.0948837 | 2.8648059 |
2.0985622 | 4.7026465 |
2.0994979 | 5.0382142 |
2.1023642 | 4.2814187 |
2.1102441 | 4.3805769 |
2.1522589 | 2.6625872 |
2.1613626 | 3.6416719 |
2.1760954 | 1.66759943 |
2.1805424 | 3.0442384 |
2.1842685 | 3.5954692 |
2.1891405 | 3.9582391 |
2.1963915 | 3.0430046 |
2.2020264 | 3.176707 |
2.204684 | 1.83693931 |
2.2052541 | 2.7499996 |
2.2066926 | 3.7208274 |
2.2109871 | 1.60017807 |
2.2146996 | 2.399128 |
2.2174554 | 1.72364346 |
2.2304159 | 1.82961734 |
2.2473506 | 2.2875368 |
2.2490397 | 3.1734422 |
2.2519844 | 2.2969987 |
2.2604619 | 1.7826934 |
2.2688021 | 3.0460717 |
2.3082186 | 4.4655713 |
2.337285 | 3.3586476 |
2.3616657 | 3.9431843 |
2.372691 | 2.7305975 |
2.3783937 | 2.3535819 |
2.3816021 | 2.9007384 |
2.3967371 | 2.1569486 |
2.409683 | 3.3595594 |
2.4193469 | 2.0856312 |
2.4234583 | 1.51782552 |
2.4392568 | 4.1463499 |
2.440037 | 4.2618835 |
2.4499319 | 1.4923003 |
2.4582683 | 2.3588849 |
2.4769531 | 4.5814207 |
2.4844316 | 2.9984511 |
2.4845173 | 2.8737064 |
2.4932187 | 2.66146 |
2.5161047 | 3.2298843 |
2.5216744 | 3.9607432 |
2.5229139 | 2.492989 |
2.5270772 | 0.93612531 |
2.5353904 | 1.28615059 |
2.5781225 | 3.5085023 |
2.5789043 | 3.6564247 |
2.5913078 | 4.4678316 |
2.6017795 | 3.3329228 |
2.6083691 | 2.7219107 |
2.609068 | 3.4104897 |
2.6328854 | 2.4587599 |
2.6469687 | 2.7014709 |
2.6920039 | 2.295654 |
2.6979838 | 3.9314267 |
2.7126542 | 3.1619493 |
2.7176177 | 3.6184841 |
2.720342 | 3.7590754 |
2.7288016 | 2.8601606 |
2.7729759 | 3.3649024 |
2.8041777 | 2.8947211 |
2.8297566 | 3.1058471 |
2.8568165 | 4.2398304 |
2.8708006 | 3.5365312 |
2.8884565 | 3.4983996 |
2.8940135 | 1.80718637 |
2.9270099 | 2.4705192 |
2.933241 | 1.61062 |
2.9722306 | 2.9105811 |
2.9772854 | 1.05260017 |
2.9773797 | 3.4382292 |
2.980513 | 1.98434561 |
3.005612 | 3.8833924 |
3.0089706 | 1.48283347 |
3.0261818 | 3.8696189 |
3.0400688 | 3.2351968 |
3.0647613 | 2.3867858 |
3.0958156 | 5.7977043 |
3.0974361 | 1.61238889 |
3.123407 | 4.2756611 |
3.140026 | 2.9104996 |
3.1401996 | 4.0088845 |
3.1743328 | 3.9899578 |
3.1808794 | 3.408549 |
3.1832203 | 2.0703815 |
3.2276428 | 3.180782 |
3.2372055 | 2.4413745 |
3.2952069 | 3.9016304 |
3.3387983 | 4.2365316 |
3.3562441 | 4.3595853 |
3.4416423 | 5.7357497 |
3.521928 | 3.8651324 |
3.5249241 | 3.4056552 |
3.6396121 | 1.74341452 |
3.6525806 | 5.0596418 |
3.6773415 | 1.65264229 |
3.7089812 | 4.4749576 |
3.7570425 | 3.2789297 |
3.7990812 | 2.8031089 |
3.8079212 | 4.2604948 |
3.8635523 | 4.3065351 |
3.8826769 | 3.4434805 |
3.9105801 | 1.0730681 |
4.0275824 | 3.9110729 |
4.2610977 | 4.5150765 |
4.2654032 | 3.5862794 |
4.3772226 | 4.6939538 |
4.3862929 | 2.8272327 |
4.6736332 | 2.4853571 |
8.9435583 | 9.4739571 |
8.9739184 | 7.87866 |
9.187397 | 9.348852 |
9.2407109 | 8.5518535 |
9.2436521 | 9.4541242 |
9.2551838 | 7.5564442 |
9.285243 | 10.2071673 |
9.3299446 | 9.0000361 |
9.3319237 | 10.0936765 |
9.373557 | 9.8826912 |
9.464094 | 9.0581829 |
9.4906742 | 9.3292611 |
9.5115338 | 9.8535287 |
9.5659971 | 10.0486414 |
9.6023175 | 7.9585361 |
9.6234813 | 8.3907157 |
9.6445082 | 9.6998504 |
9.649045 | 9.8849591 |
9.6584125 | 9.0152807 |
9.6665508 | 9.4282592 |
9.6730605 | 10.5942431 |
9.763729 | 8.2835604 |
9.7755229 | 10.407463 |
9.8076254 | 9.658945 |
9.8276345 | 8.4644596 |
9.8479234 | 7.756862 |
9.856574 | 8.503814 |
9.8622591 | 9.9170009 |
9.9363758 | 7.2319598 |
9.943909 | 8.4875439 |
9.9889206 | 10.611449 |
10.0165059 | 9.5475354 |
10.0419705 | 10.8528666 |
10.102277 | 11.0164613 |
10.1288555 | 8.7255618 |
10.1296474 | 9.9023458 |
10.1553296 | 10.365873 |
10.1730311 | 8.742746 |
10.1820635 | 8.0384904 |
10.2560427 | 10.2301575 |
10.2981906 | 11.2181469 |
10.3011218 | 5.9657148 |
10.301961 | 9.6504424 |
10.3145947 | 8.2175059 |
10.3361955 | 11.0435696 |
10.3803912 | 9.9176344 |
10.4078596 | 9.5672229 |
10.40994 | 9.6915476 |
10.4850186 | 8.672043 |
10.4965347 | 10.4085449 |
10.5192183 | 9.1697117 |
10.5647357 | 10.0321895 |
10.5648727 | 10.5589759 |
10.6015189 | 6.0994906 |
10.603581 | 10.3790253 |
10.6099817 | 7.1638026 |
10.6206807 | 9.6087325 |
10.6345994 | 9.1531639 |
10.6429483 | 10.3542054 |
10.6724078 | 8.4637002 |
10.7092349 | 8.7151763 |
10.714601 | 7.8089865 |
10.7182087 | 7.8359403 |
10.7245 | 8.2597278 |
10.7385045 | 8.4247141 |
10.770265 | 9.7400903 |
10.8110738 | 8.4712292 |
10.8312662 | 7.5418477 |
10.8319838 | 8.9931978 |
10.8578799 | 9.0934209 |
10.8853276 | 9.0234515 |
10.913638 | 9.5415647 |
10.9267408 | 8.7133325 |
11.018074 | 9.6140025 |
11.0184744 | 9.045611 |
11.0412225 | 8.2239493 |
11.0485496 | 9.0632895 |
11.0518117 | 8.0080764 |
11.0664894 | 9.1414022 |
11.0949584 | 9.125697 |
11.101395 | 9.8750952 |
11.1235131 | 8.6977035 |
11.1394266 | 8.110125 |
11.1673507 | 8.731084 |
11.1958179 | 9.1986208 |
11.2270168 | 10.334217 |
11.2319251 | 9.5158861 |
11.2327407 | 9.0726365 |
11.2746275 | 8.693953 |
11.2802248 | 6.3492874 |
11.307973 | 8.5744575 |
11.4089124 | 8.1652054 |
11.4206061 | 7.1979654 |
11.4332237 | 9.4580566 |
11.4413669 | 8.0914636 |
11.4696749 | 8.8581128 |
11.4830634 | 11.2508174 |
11.4864111 | 7.7290216 |
11.4928201 | 10.746028 |
11.4952661 | 7.12129 |
11.4990939 | 10.0108213 |
11.5146056 | 9.6430751 |
11.5521972 | 8.328596 |
11.574167 | 9.0679398 |
11.5811656 | 7.0079888 |
11.5818258 | 9.1019273 |
11.6091367 | 8.5752111 |
11.6246849 | 8.5365028 |
11.6642143 | 8.4458003 |
11.6691018 | 10.7915455 |
11.7002922 | 10.6383879 |
11.7120615 | 8.794039 |
11.7644048 | 8.8808288 |
11.7934826 | 7.4950836 |
11.9684594 | 10.0053487 |
11.9714406 | 7.2756851 |
11.9788712 | 9.9465767 |
12.0029676 | 7.9771513 |
12.024769 | 6.9830776 |
12.108955 | 10.0022074 |
12.1667502 | 7.1966235 |
12.2008513 | 11.2806987 |
12.2237865 | 9.3287031 |
12.3157701 | 7.5950945 |
12.3606768 | 12.1086731 |
12.5844491 | 9.865713 |
12.6733525 | 7.6230164 |
12.682216 | 9.4233843 |
12.6856208 | 9.310157 |
12.6906946 | 7.328908 |
12.7297457 | 10.1547281 |
15.382204 | 9.6953397 |
1.46197526 | 19.8670258 |
1.49022974 | 19.5352805 |
1.56415542 | 20.831295 |
1.95117941 | 18.9503718 |
2.05835481 | 20.557332 |
2.10288324 | 19.5935174 |
2.17447523 | 18.0540215 |
2.19810974 | 19.12201 |
2.21934452 | 19.0784394 |
2.23439904 | 19.844791 |
2.26788561 | 20.209558 |
2.47250581 | 18.6123102 |
2.5142698 | 18.4614009 |
2.54996643 | 19.2768358 |
2.55418227 | 18.884939 |
2.60602417 | 20.936468 |
2.63375978 | 20.206995 |
2.63673117 | 18.7844843 |
2.7274187 | 19.0976652 |
2.78672127 | 18.6171725 |
2.84069897 | 18.7650607 |
2.885701 | 20.137431 |
2.91613686 | 20.233336 |
2.92942006 | 18.5713626 |
2.95596944 | 20.535309 |
2.96854857 | 19.8038184 |
3.0145628 | 18.2879164 |
3.0177927 | 20.84433 |
3.0215634 | 20.765331 |
3.0319656 | 19.6683734 |
3.0682963 | 19.1762061 |
3.0797411 | 20.497518 |
3.0890363 | 19.7297415 |
3.1020139 | 19.1104753 |
3.1111965 | 20.974068 |
3.1118762 | 20.730051 |
3.1190241 | 20.626021 |
3.1290053 | 20.708113 |
3.1567038 | 18.9859388 |
3.1642717 | 20.86776 |
3.1877287 | 19.0277225 |
3.2417761 | 19.9239422 |
3.2697233 | 20.58267 |
3.2805359 | 20.839587 |
3.315033 | 17.800678 |
3.3374848 | 19.8847305 |
3.3436787 | 21.160946 |
3.3601605 | 19.9220547 |
3.3804341 | 19.5464206 |
3.419576 | 18.5611838 |
3.44766 | 19.7976419 |
3.4497856 | 20.992422 |
3.4515913 | 19.246366 |
3.462917 | 19.0683491 |
3.469379 | 21.277371 |
3.476635 | 19.7049207 |
3.4789768 | 18.7587035 |
3.4864838 | 17.8367824 |
3.494347 | 18.4188009 |
3.4977578 | 20.235316 |
3.5150408 | 21.469438 |
3.5465376 | 20.102797 |
3.5481756 | 20.500124 |
3.5623819 | 21.11233 |
3.5657523 | 19.8653065 |
3.5680518 | 19.7992902 |
3.5787906 | 19.4795982 |
3.580711 | 20.634115 |
3.5882776 | 21.154661 |
3.6154553 | 19.5561227 |
3.6240277 | 18.1513374 |
3.6271007 | 19.9594745 |
3.6423654 | 19.5207591 |
3.6532214 | 18.9213972 |
3.6708971 | 19.0647823 |
3.6816109 | 20.307332 |
3.6831495 | 20.753881 |
3.6909234 | 18.3056743 |
3.694486 | 18.4031309 |
3.7029568 | 18.7852089 |
3.7209245 | 21.160009 |
3.7554475 | 19.5635625 |
3.7561105 | 19.1486694 |
3.7591644 | 21.053899 |
3.7816041 | 21.754704 |
3.7876631 | 20.692215 |
3.8234422 | 19.7212479 |
3.8262062 | 20.727142 |
3.8288627 | 20.673864 |
3.8297793 | 20.458916 |
3.832603 | 21.074711 |
3.8353628 | 19.0803144 |
3.8556235 | 19.6185811 |
3.8563045 | 20.950317 |
3.8567533 | 20.230949 |
3.8755811 | 19.7954 |
3.8808773 | 21.261579 |
3.8832988 | 18.9781784 |
3.8843075 | 19.8027541 |
3.8905587 | 22.469766 |
3.8975282 | 20.28635 |
3.9109833 | 20.301225 |
3.9144448 | 18.974059 |
3.9165083 | 21.676352 |
3.9209176 | 19.7131755 |
3.9781659 | 21.664901 |
3.9788063 | 17.9605311 |
3.9795792 | 20.604285 |
3.9988977 | 19.3873 |
4.0085747 | 20.703644 |
4.0196867 | 22.969208 |
4.025619 | 20.081437 |
4.0534619 | 20.705229 |
4.0547586 | 20.305228 |
4.0547586 | 20.816871 |
4.0755392 | 18.3552001 |
4.075569 | 19.5328423 |
4.1066715 | 18.9310227 |
4.1219421 | 18.0786952 |
4.1325375 | 20.278667 |
4.1346469 | 19.7929784 |
4.1377228 | 19.3141014 |
4.1424518 | 19.0621782 |
4.163728 | 18.0126414 |
4.1789909 | 21.545179 |
4.1910496 | 22.74184 |
4.192648 | 21.567828 |
4.2120042 | 19.5149355 |
4.2236802 | 19.7026045 |
4.235359 | 21.291386 |
4.2504888 | 20.255275 |
4.2849944 | 19.6670767 |
4.2936236 | 20.04094 |
4.2943962 | 18.6098342 |
4.2972952 | 21.044405 |
4.3159775 | 18.8025205 |
4.3183388 | 19.7124052 |
4.3312717 | 19.1945021 |
4.3332788 | 19.858556 |
4.3436751 | 20.278825 |
4.3510198 | 19.4443378 |
4.3536828 | 19.6918611 |
4.3762487 | 20.001178 |
4.3873331 | 19.944966 |
4.4018079 | 21.336344 |
4.4049931 | 20.354974 |
4.4069312 | 20.229606 |
4.4145946 | 21.865367 |
4.4298175 | 20.177013 |
4.4304013 | 21.295831 |
4.4350526 | 19.2814343 |
4.4365224 | 20.607422 |
4.4385972 | 20.113629 |
4.4395695 | 20.287594 |
4.4433867 | 19.5672236 |
4.4581051 | 19.3005269 |
4.484958 | 19.6122817 |
4.4855137 | 19.7430907 |
4.4961756 | 19.0852748 |
4.4961815 | 19.9774792 |
4.5060367 | 20.626502 |
4.5111277 | 20.048125 |
4.5353022 | 21.006037 |
4.5477455 | 19.5218191 |
4.5646723 | 18.5753288 |
4.6069566 | 19.4928334 |
4.610661 | 19.2333245 |
4.6110635 | 21.161409 |
4.6156599 | 22.24306 |
4.6157363 | 19.6247648 |
4.6231143 | 21.467851 |
4.6303499 | 21.166585 |
4.6479363 | 19.4927011 |
4.649848 | 19.9999997 |
4.6726846 | 21.196404 |
4.6956556 | 21.338031 |
4.7507975 | 21.35678 |
4.8039113 | 20.381728 |
4.8669884 | 21.926908 |
4.8952958 | 19.2367016 |
4.9323323 | 19.425336 |
4.9469818 | 20.622926 |
4.9524754 | 19.5783952 |
4.9781864 | 20.542842 |
4.9871194 | 18.4396185 |
5.0319823 | 20.890154 |
5.0549366 | 19.0793781 |
5.0848657 | 20.441317 |
5.0908691 | 20.080454 |
5.1299154 | 19.4593151 |
5.1662752 | 21.241106 |
5.1816155 | 18.5673625 |
5.2062795 | 19.3081385 |
5.2424753 | 20.28896 |
5.2425295 | 20.158123 |
5.2906467 | 21.072758 |
5.297312 | 19.8472714 |
5.2975145 | 20.757499 |
5.3062086 | 20.421346 |
5.3323506 | 20.513092 |
5.3448124 | 19.1347046 |
5.3474952 | 20.536695 |
5.4494709 | 21.900892 |
5.4986571 | 20.600885 |
5.5130076 | 21.136178 |
5.5275875 | 21.167535 |
5.5458203 | 20.827132 |
5.6357217 | 21.777843 |
5.6418671 | 20.280765 |
5.642627 | 19.750893 |
5.766496 | 20.256047 |
5.8495488 | 18.0793218 |
6.1037454 | 20.818065 |
6.2250822 | 22.607042 |
6.3813155 | 20.092317 |
6.634051 | 21.15266 |
7.0207123 | 20.895823 |
17.2951741 | 5.950383 |
17.6426889 | 4.026425 |
18.3783284 | 2.6677586 |
18.6610826 | 2.2858431 |
18.7658667 | 2.2502372 |
18.8735189 | 4.0070031 |
18.9202878 | 3.3794615 |
19.2157376 | 5.0456349 |
19.2828371 | 5.7614267 |
19.3416173 | 5.7342967 |
19.372867 | 5.071573 |
19.3793344 | 4.4288482 |
19.4471513 | 2.0290971 |
19.5507429 | 4.1520108 |
19.5796525 | 3.3137553 |
19.6592429 | 2.9047836 |
19.7027051 | 3.391466 |
19.7066826 | 3.8575872 |
19.7665198 | 4.6534996 |
19.8166826 | 5.0681208 |
19.8309236 | 4.4234537 |
19.8705837 | 1.95144045 |
19.8706565 | 2.4984245 |
19.8761654 | 4.5287529 |
19.9085948 | 1.91336718 |
19.9163915 | 5.4980526 |
19.9321293 | 5.6884465 |
19.9635774 | 5.1519153 |
19.9774131 | 1.71576669 |
20.005386 | 4.9725339 |
20.03108 | 3.1899709 |
20.031303 | 5.3222825 |
20.03259 | 5.1497509 |
20.03428 | 5.0453932 |
20.080447 | 4.3698057 |
20.083517 | 6.3154411 |
20.109498 | 1.6949377 |
20.12784 | 3.1077324 |
20.143328 | 5.2932866 |
20.153527 | 1.14745808 |
20.185165 | 5.6840752 |
20.186108 | 3.0095029 |
20.218486 | 1.86943064 |
20.225788 | 4.6446198 |
20.230586 | 3.5665214 |
20.242446 | 3.0842829 |
20.250058 | 4.6674981 |
20.256518 | 5.1025102 |
20.265683 | 2.0045272 |
20.282189 | 3.5401449 |
20.302099 | 3.6052738 |
20.308668 | 6.0612829 |
20.351454 | 4.9648817 |
20.353287 | 2.9206918 |
20.36641 | 2.0461857 |
20.372119 | 4.0134533 |
20.373874 | 4.3479411 |
20.385863 | 5.8749841 |
20.409758 | 2.4770249 |
20.429302 | 4.1856019 |
20.584737 | 5.5193866 |
20.607137 | 3.7815047 |
20.612883 | 1.24133727 |
20.62282 | 3.8538072 |
20.626709 | 5.3176161 |
20.631416 | 4.6234233 |
20.637825 | 1.13733134 |
20.650459 | 5.6764957 |
20.65138 | 5.4412149 |
20.663191 | 5.1562683 |
20.671364 | 3.1726842 |
20.676551 | 3.3428428 |
20.689668 | 1.11834644 |
20.693096 | 5.0325472 |
20.696343 | 4.5175537 |
20.699593 | 2.8767087 |
20.703645 | 4.631295 |
20.795686 | 2.7721686 |
20.809542 | 6.5642634 |
20.825847 | 3.1371149 |
20.842786 | 4.3904774 |
20.84874 | 6.3513859 |
20.860288 | 6.4784907 |
20.86037 | 2.8584966 |
20.869171 | 5.2307423 |
20.872055 | 4.0749112 |
20.87257 | 1.23464118 |
20.910788 | 5.2690191 |
20.928634 | 3.6359366 |
20.970335 | 3.8242789 |
21.036661 | 2.7005158 |
21.049342 | 3.7664064 |
21.060166 | 4.2008833 |
21.060814 | 4.9944114 |
21.068511 | 4.9511485 |
21.075475 | 3.162381 |
21.121069 | 4.024253 |
21.135204 | 4.2472877 |
21.137853 | 3.0020879 |
21.173174 | 4.1480361 |
21.186386 | 7.2251656 |
21.200991 | 2.1901514 |
21.208839 | 4.4279441 |
21.218948 | 3.7864309 |
21.221807 | 3.0719514 |
21.246152 | 5.4355796 |
21.262461 | 2.9578559 |
21.268682 | 3.628921 |
21.290465 | 3.2874838 |
21.293326 | 4.106079 |
21.301133 | 4.1777477 |
21.302882 | 3.2121843 |
21.307465 | 6.3794084 |
21.310338 | 3.0792017 |
21.377903 | 3.5628289 |
21.432628 | 3.2225798 |
21.439473 | 3.385765 |
21.467547 | 4.7781926 |
21.477121 | 3.6562905 |
21.501194 | 2.3480532 |
21.533824 | 4.9138983 |
21.54175 | 2.9172603 |
21.548589 | 4.4224972 |
21.551281 | 5.034822 |
21.580005 | 2.4249323 |
21.622936 | 2.6350977 |
21.635703 | 5.0811729 |
21.635766 | 0.6839693 |
21.636906 | 5.1485335 |
21.640693 | 5.0050765 |
21.644646 | 2.6398355 |
21.659895 | 3.7598802 |
21.6671 | 3.0851933 |
21.672122 | 1.82188274 |
21.790655 | 3.9990614 |
21.791466 | 3.9976649 |
21.823915 | 5.5021609 |
21.836958 | 2.770455 |
21.849023 | 5.0410794 |
21.875795 | 3.4999431 |
21.906133 | 5.8123412 |
21.929987 | 6.0171549 |
21.943218 | 4.5029935 |
21.944168 | 4.8880596 |
21.973628 | 5.3975676 |
21.977883 | 3.6668553 |
21.986891 | 3.3156703 |
21.990816 | 6.0919267 |
21.998018 | 5.5690895 |
22.002982 | 2.9423729 |
22.003167 | 3.1783848 |
22.02293 | 3.7394457 |
22.048313 | 5.7878447 |
22.04935 | 3.9196468 |
22.102964 | 6.9353623 |
22.104117 | 2.3553044 |
22.112408 | 4.44293 |
22.116913 | 5.7040627 |
22.117363 | 5.4379922 |
22.132975 | 4.7215931 |
22.148421 | 3.8419177 |
22.157023 | 3.3189264 |
22.209926 | 6.0647142 |
22.231745 | 4.1059839 |
22.243242 | 5.6659826 |
22.275244 | 3.4509242 |
22.283633 | 3.0655829 |
22.31873 | 3.5765372 |
22.360228 | 1.30690857 |
22.390107 | 5.4824678 |
22.391019 | 5.1110448 |
22.418397 | 3.6016607 |
22.438045 | 5.2962146 |
22.502628 | 2.9129491 |
22.530678 | 5.270917 |
22.531774 | 3.510775 |
22.535484 | 6.3496156 |
22.555906 | 2.8812822 |
22.574879 | 4.1483826 |
22.577047 | 6.5748674 |
22.698119 | 5.5684472 |
22.712666 | 2.8698348 |
22.754716 | 2.8842441 |
22.840546 | 5.1758951 |
22.875637 | 5.5823763 |
22.913839 | 4.7236013 |
22.921435 | 4.992112 |
22.95051 | 5.507263 |
22.968837 | 3.8102658 |
23.372123 | 5.1056244 |
23.570015 | 7.3520417 |
23.871862 | 2.2839561 |
14.776254 | 15.9332623 |
14.828535 | 17.754768 |
14.9985099 | 19.006255 |
15.0332013 | 19.171739 |
15.3495864 | 18.344629 |
15.3643301 | 17.307221 |
15.6308644 | 18.729308 |
15.6742915 | 18.422276 |
15.6765912 | 18.957163 |
15.7242125 | 18.603576 |
15.7309358 | 18.287858 |
15.8201135 | 17.317803 |
16.04405 | 18.326776 |
16.2843895 | 19.224467 |
16.3338087 | 20.315561 |
16.3864874 | 19.430293 |
16.391851 | 16.6688446 |
16.4134342 | 19.813134 |
16.4887595 | 18.338325 |
16.4927375 | 18.033762 |
16.5616717 | 19.041559 |
16.679285 | 18.295844 |
16.6980917 | 16.8332204 |
16.7248246 | 17.813209 |
16.738379 | 20.513935 |
16.7447018 | 20.612144 |
16.759245 | 20.425581 |
16.8174379 | 17.387096 |
16.8318274 | 20.132314 |
16.8411981 | 18.775724 |
16.8657639 | 15.18619 |
16.9045035 | 16.6292852 |
16.9060549 | 17.432955 |
16.9236652 | 16.5085818 |
16.9246185 | 18.501414 |
16.9371979 | 18.538343 |
16.9424162 | 17.669786 |
16.9436611 | 17.422198 |
16.954384 | 16.6210745 |
17.0048745 | 18.647301 |
17.0093275 | 18.155081 |
17.0495475 | 18.4833 |
17.0627556 | 18.23776 |
17.0848806 | 18.073719 |
17.0988263 | 18.650373 |
17.1219141 | 17.029351 |
17.1366616 | 19.971848 |
17.1485928 | 18.236786 |
17.1559942 | 16.9274005 |
17.1784265 | 16.6347077 |
17.2007163 | 20.458792 |
17.2067843 | 18.878027 |
17.2126233 | 17.627478 |
17.27771 | 18.301138 |
17.339495 | 22.147247 |
17.3421613 | 18.489292 |
17.3577314 | 17.460453 |
17.3724251 | 17.838472 |
17.3996649 | 15.71695 |
17.4002773 | 14.6913483 |
17.4324959 | 15.5923088 |
17.4391638 | 18.273311 |
17.474673 | 16.1187519 |
17.4783074 | 16.7469574 |
17.4828174 | 18.835584 |
17.5082782 | 17.96041 |
17.5131746 | 16.1271108 |
17.5226118 | 20.37399 |
17.5411115 | 18.970615 |
17.5478529 | 20.084663 |
17.5593776 | 18.467168 |
17.5604301 | 16.6251063 |
17.5621066 | 15.6151074 |
17.5639823 | 15.6570201 |
17.5727543 | 16.2284542 |
17.5999234 | 19.382793 |
17.6097383 | 16.6748319 |
17.6335421 | 17.659876 |
17.6346179 | 19.120215 |
17.6394592 | 14.6308142 |
17.6442026 | 19.402978 |
17.6624146 | 18.518399 |
17.6824201 | 19.045062 |
17.6933922 | 18.000639 |
17.6988315 | 18.716886 |
17.7180367 | 18.103054 |
17.7549039 | 16.4974324 |
17.7672336 | 18.161612 |
17.7675093 | 19.396513 |
17.7926923 | 18.684571 |
17.8061956 | 18.138528 |
17.8161585 | 17.744709 |
17.8442842 | 16.5564664 |
17.8517083 | 18.048076 |
17.8798602 | 18.078834 |
17.894805 | 17.364323 |
17.897217 | 16.2556095 |
17.9274089 | 17.295782 |
17.9540314 | 17.790538 |
17.9833606 | 17.01958 |
18.010122 | 16.2967178 |
18.011117 | 17.84965 |
18.02912 | 18.488563 |
18.036761 | 16.4478485 |
18.037256 | 18.574155 |
18.063049 | 18.151774 |
18.090068 | 18.56643 |
18.094963 | 18.018778 |
18.10096 | 15.8177448 |
18.122916 | 17.674656 |
18.129248 | 18.158393 |
18.13386 | 14.7555909 |
18.149812 | 16.2079389 |
18.152682 | 20.011784 |
18.176491 | 19.079545 |
18.178535 | 17.691873 |
18.183269 | 18.910638 |
18.215687 | 15.8817595 |
18.235729 | 15.7945041 |
18.259081 | 17.087312 |
18.264561 | 17.029223 |
18.274332 | 15.8333249 |
18.330272 | 16.7431158 |
18.368219 | 16.0200739 |
18.379084 | 19.194089 |
18.379872 | 18.124247 |
18.385792 | 18.179336 |
18.398364 | 19.606996 |
18.409342 | 17.693611 |
18.437678 | 17.926307 |
18.455588 | 19.845492 |
18.475238 | 18.791697 |
18.508271 | 16.4602961 |
18.527687 | 19.682064 |
18.536628 | 17.831121 |
18.542094 | 17.563114 |
18.545504 | 17.37607 |
18.547878 | 17.319933 |
18.553336 | 19.569272 |
18.557667 | 15.180909 |
18.582784 | 19.483361 |
18.590279 | 17.149325 |
18.634664 | 18.86855 |
18.639971 | 21.681327 |
18.643215 | 16.5278489 |
18.650616 | 18.021068 |
18.659338 | 19.160969 |
18.664585 | 17.421214 |
18.67864 | 13.6651535 |
18.706178 | 19.788597 |
18.743804 | 18.332319 |
18.754485 | 17.600224 |
18.776854 | 18.299507 |
18.788332 | 18.461131 |
18.797314 | 14.9900939 |
18.812277 | 16.7877808 |
18.818708 | 17.767132 |
18.825362 | 17.998126 |
18.827257 | 17.411798 |
18.855049 | 20.06313 |
18.895247 | 15.6882882 |
18.89677 | 18.241082 |
18.90694 | 16.3827126 |
18.931778 | 19.185287 |
18.935962 | 17.947167 |
18.936954 | 19.25114 |
18.958115 | 18.59757 |
19.026628 | 19.205066 |
19.037261 | 17.780271 |
19.061187 | 19.016911 |
19.097614 | 18.740769 |
19.099027 | 18.797805 |
19.1145 | 17.767203 |
19.131498 | 17.562132 |
19.170495 | 18.460691 |
19.188678 | 19.321407 |
19.191673 | 15.5556509 |
19.201821 | 18.442701 |
19.237079 | 15.6778069 |
19.25179 | 18.030541 |
19.270079 | 19.044006 |
19.333913 | 15.3620963 |
19.35918 | 17.033823 |
19.361986 | 17.354937 |
19.365055 | 19.033464 |
19.365386 | 16.7474302 |
19.367864 | 18.965754 |
19.432841 | 19.920374 |
19.455325 | 17.293297 |
19.457648 | 18.584263 |
19.482073 | 16.4698072 |
19.495794 | 15.2869317 |
19.520868 | 17.981305 |
19.601644 | 15.5475595 |
19.626402 | 17.237819 |
19.639048 | 17.63884 |
19.664319 | 18.12114 |
19.678355 | 18.234852 |
19.706041 | 19.347441 |
19.946172 | 18.768173 |
19.954228 | 17.480191 |
20.016013 | 20.799353 |
20.025227 | 18.322595 |
20.065571 | 19.06146 |
20.080158 | 17.622466 |
20.260129 | 17.286994 |
20.385613 | 19.526589 |
20.591116 | 20.438186 |
20.774989 | 19.963467 |
20.973478 | 18.539765 |
21.657494 | 15.7015363 |
Parag Kanade/fuzzy ants/Gauss3/gauss03Full.data
1 | -0.46551197 | 2.3396181 |
1 | -0.14154019 | 2.6467355 |
1 | -0.06147374 | 2.910021 |
1 | -0.00960664 | 2.6959237 |
1 | 0.13522751 | 3.3371545 |
1 | 0.15816343 | 2.74101 |
1 | 0.16902868 | 2.7145902 |
1 | 0.20321506 | 2.3230994 |
1 | 0.24094079 | 2.3069846 |
1 | 0.25245225 | 3.1839526 |
1 | 0.26993324 | 3.5483323 |
1 | 0.28680391 | 2.6052432 |
1 | 0.3192367 | 3.2276855 |
1 | 0.36114833 | 3.8009784 |
1 | 0.4244067 | 2.8634449 |
1 | 0.46037797 | 2.4532789 |
1 | 0.46098959 | 3.3555875 |
1 | 0.48936047 | 2.8126198 |
1 | 0.493417 | 1.52432961 |
1 | 0.5579586 | 3.0069093 |
1 | 0.59517099 | 1.74266104 |
1 | 0.601286 | 3.447746 |
1 | 0.64249205 | 1.22137058 |
1 | 0.64603926 | 3.098612 |
1 | 0.68936857 | 3.3436606 |
1 | 0.70125847 | 2.9881431 |
1 | 0.70954162 | 2.8340884 |
1 | 0.71271143 | 2.1911658 |
1 | 0.73828501 | 3.9157625 |
1 | 0.76121259 | 3.887774 |
1 | 0.76300537 | 4.36236 |
1 | 0.78715506 | 2.7998882 |
1 | 0.79603202 | 2.3837631 |
1 | 0.81552587 | 1.7659359 |
1 | 0.81671088 | 3.0235945 |
1 | 0.83646559 | 2.7292928 |
1 | 0.84905869 | 1.90959966 |
1 | 0.87280583 | 2.9185033 |
1 | 0.93911004 | 3.2377149 |
1 | 0.94658989 | 2.8099329 |
1 | 0.95071896 | 4.3593771 |
1 | 0.95477185 | 1.82422933 |
1 | 1.0475351 | 4.7358953 |
1 | 1.0483555 | 3.6222619 |
1 | 1.0663274 | 3.0772458 |
1 | 1.0719789 | 3.3051114 |
1 | 1.0841659 | 3.8982847 |
1 | 1.0917331 | 2.4965835 |
1 | 1.1268271 | 2.7541776 |
1 | 1.1308673 | 3.1353612 |
1 | 1.1428466 | 3.0972579 |
1 | 1.1493513 | 2.8227118 |
1 | 1.1819349 | 2.8738619 |
1 | 1.1900377 | 2.5835831 |
1 | 1.2101874 | 2.8796963 |
1 | 1.2181118 | 4.0111068 |
1 | 1.2277972 | 3.0808183 |
1 | 1.2335498 | 3.9573163 |
1 | 1.2448562 | 2.6017201 |
1 | 1.2555436 | 2.9472067 |
1 | 1.2597352 | 1.95874592 |
1 | 1.2601195 | 1.81798378 |
1 | 1.2715242 | 1.46185734 |
1 | 1.2749423 | 4.2592336 |
1 | 1.2888759 | 3.4162943 |
1 | 1.319464 | 3.1180977 |
1 | 1.3266557 | 2.9249356 |
1 | 1.3269461 | 3.8783508 |
1 | 1.3458998 | 2.6047048 |
1 | 1.3471548 | 3.0660325 |
1 | 1.3753515 | 3.4089999 |
1 | 1.3793406 | 3.1089793 |
1 | 1.3872928 | 4.3455047 |
1 | 1.3979966 | 3.3829163 |
1 | 1.4001717 | 4.0482038 |
1 | 1.4054732 | 2.6215221 |
1 | 1.4312392 | 1.79191521 |
1 | 1.4354818 | 4.0271297 |
1 | 1.4410139 | 3.7986203 |
1 | 1.4641202 | 1.58155858 |
1 | 1.4646153 | 4.9791516 |
1 | 1.5055329 | 2.0990125 |
1 | 1.5286615 | 3.6943944 |
1 | 1.5534019 | 4.741445 |
1 | 1.5735908 | 2.5571016 |
1 | 1.5856639 | 1.99127551 |
1 | 1.6083411 | 3.3154722 |
1 | 1.6167515 | 4.4641362 |
1 | 1.6315791 | 3.9447703 |
1 | 1.6485825 | 2.9459715 |
1 | 1.6558902 | 2.1154736 |
1 | 1.6603318 | 3.4801616 |
1 | 1.6657018 | 2.9762646 |
1 | 1.6740867 | 3.9751515 |
1 | 1.7109312 | 2.5716093 |
1 | 1.7172934 | 2.9542265 |
1 | 1.7245997 | 3.387059 |
1 | 1.7280016 | 4.2168608 |
1 | 1.7407356 | 2.6770587 |
1 | 1.7446611 | 4.8440441 |
1 | 1.7479167 | 2.3913499 |
1 | 1.7507312 | 3.769599 |
1 | 1.7567404 | 2.4447784 |
1 | 1.7591262 | 4.9952283 |
1 | 1.7610234 | 4.5877581 |
1 | 1.7736913 | 2.4399875 |
1 | 1.7826518 | 4.1827802 |
1 | 1.7882331 | 3.7558682 |
1 | 1.8048077 | 2.4894358 |
1 | 1.806578 | 3.2980184 |
1 | 1.8105734 | 4.0728863 |
1 | 1.8132452 | 1.11900227 |
1 | 1.8581162 | 3.3816176 |
1 | 1.8735926 | 3.1120087 |
1 | 1.8771577 | 2.9606585 |
1 | 1.8791867 | 1.81713304 |
1 | 1.8866894 | 2.5761363 |
1 | 1.8881009 | 1.12698201 |
1 | 1.8980516 | 3.4640572 |
1 | 1.911659 | 1.92031474 |
1 | 1.9163593 | 3.2659011 |
1 | 1.9217044 | 2.9429349 |
1 | 1.9240625 | 2.2683148 |
1 | 1.933498 | 1.99443935 |
1 | 1.9366692 | 4.0426166 |
1 | 1.9572064 | 4.2689621 |
1 | 1.987931 | 5.1287767 |
1 | 1.9907116 | 2.6489055 |
1 | 1.9930155 | 3.6846483 |
1 | 2.0011578 | 3.3236036 |
1 | 2.0107086 | 3.1802041 |
1 | 2.0650972 | 1.62687304 |
1 | 2.0760993 | 2.8564104 |
1 | 2.076595 | 4.141211 |
1 | 2.0797088 | 3.6444816 |
1 | 2.0828643 | 3.4026682 |
1 | 2.0948837 | 2.8648059 |
1 | 2.0985622 | 4.7026465 |
1 | 2.0994979 | 5.0382142 |
1 | 2.1023642 | 4.2814187 |
1 | 2.1102441 | 4.3805769 |
1 | 2.1522589 | 2.6625872 |
1 | 2.1613626 | 3.6416719 |
1 | 2.1760954 | 1.66759943 |
1 | 2.1805424 | 3.0442384 |
1 | 2.1842685 | 3.5954692 |
1 | 2.1891405 | 3.9582391 |
1 | 2.1963915 | 3.0430046 |
1 | 2.2020264 | 3.176707 |
1 | 2.204684 | 1.83693931 |
1 | 2.2052541 | 2.7499996 |
1 | 2.2066926 | 3.7208274 |
1 | 2.2109871 | 1.60017807 |
1 | 2.2146996 | 2.399128 |
1 | 2.2174554 | 1.72364346 |
1 | 2.2304159 | 1.82961734 |
1 | 2.2473506 | 2.2875368 |
1 | 2.2490397 | 3.1734422 |
1 | 2.2519844 | 2.2969987 |
1 | 2.2604619 | 1.7826934 |
1 | 2.2688021 | 3.0460717 |
1 | 2.3082186 | 4.4655713 |
1 | 2.337285 | 3.3586476 |
1 | 2.3616657 | 3.9431843 |
1 | 2.372691 | 2.7305975 |
1 | 2.3783937 | 2.3535819 |
1 | 2.3816021 | 2.9007384 |
1 | 2.3967371 | 2.1569486 |
1 | 2.409683 | 3.3595594 |
1 | 2.4193469 | 2.0856312 |
1 | 2.4234583 | 1.51782552 |
1 | 2.4392568 | 4.1463499 |
1 | 2.440037 | 4.2618835 |
1 | 2.4499319 | 1.4923003 |
1 | 2.4582683 | 2.3588849 |
1 | 2.4769531 | 4.5814207 |
1 | 2.4844316 | 2.9984511 |
1 | 2.4845173 | 2.8737064 |
1 | 2.4932187 | 2.66146 |
1 | 2.5161047 | 3.2298843 |
1 | 2.5216744 | 3.9607432 |
1 | 2.5229139 | 2.492989 |
1 | 2.5270772 | 0.93612531 |
1 | 2.5353904 | 1.28615059 |
1 | 2.5781225 | 3.5085023 |
1 | 2.5789043 | 3.6564247 |
1 | 2.5913078 | 4.4678316 |
1 | 2.6017795 | 3.3329228 |
1 | 2.6083691 | 2.7219107 |
1 | 2.609068 | 3.4104897 |
1 | 2.6328854 | 2.4587599 |
1 | 2.6469687 | 2.7014709 |
1 | 2.6920039 | 2.295654 |
1 | 2.6979838 | 3.9314267 |
1 | 2.7126542 | 3.1619493 |
1 | 2.7176177 | 3.6184841 |
1 | 2.720342 | 3.7590754 |
1 | 2.7288016 | 2.8601606 |
1 | 2.7729759 | 3.3649024 |
1 | 2.8041777 | 2.8947211 |
1 | 2.8297566 | 3.1058471 |
1 | 2.8568165 | 4.2398304 |
1 | 2.8708006 | 3.5365312 |
1 | 2.8884565 | 3.4983996 |
1 | 2.8940135 | 1.80718637 |
1 | 2.9270099 | 2.4705192 |
1 | 2.933241 | 1.61062 |
1 | 2.9722306 | 2.9105811 |
1 | 2.9772854 | 1.05260017 |
1 | 2.9773797 | 3.4382292 |
1 | 2.980513 | 1.98434561 |
1 | 3.005612 | 3.8833924 |
1 | 3.0089706 | 1.48283347 |
1 | 3.0261818 | 3.8696189 |
1 | 3.0400688 | 3.2351968 |
1 | 3.0647613 | 2.3867858 |
1 | 3.0958156 | 5.7977043 |
1 | 3.0974361 | 1.61238889 |
1 | 3.123407 | 4.2756611 |
1 | 3.140026 | 2.9104996 |
1 | 3.1401996 | 4.0088845 |
1 | 3.1743328 | 3.9899578 |
1 | 3.1808794 | 3.408549 |
1 | 3.1832203 | 2.0703815 |
1 | 3.2276428 | 3.180782 |
1 | 3.2372055 | 2.4413745 |
1 | 3.2952069 | 3.9016304 |
1 | 3.3387983 | 4.2365316 |
1 | 3.3562441 | 4.3595853 |
1 | 3.4416423 | 5.7357497 |
1 | 3.521928 | 3.8651324 |
1 | 3.5249241 | 3.4056552 |
1 | 3.6396121 | 1.74341452 |
1 | 3.6525806 | 5.0596418 |
1 | 3.6773415 | 1.65264229 |
1 | 3.7089812 | 4.4749576 |
1 | 3.7570425 | 3.2789297 |
1 | 3.7990812 | 2.8031089 |
1 | 3.8079212 | 4.2604948 |
1 | 3.8635523 | 4.3065351 |
1 | 3.8826769 | 3.4434805 |
1 | 3.9105801 | 1.0730681 |
1 | 4.0275824 | 3.9110729 |
1 | 4.2610977 | 4.5150765 |
1 | 4.2654032 | 3.5862794 |
1 | 4.3772226 | 4.6939538 |
1 | 4.3862929 | 2.8272327 |
1 | 4.6736332 | 2.4853571 |
2 | 8.9435583 | 9.4739571 |
2 | 8.9739184 | 7.87866 |
2 | 9.187397 | 9.348852 |
2 | 9.2407109 | 8.5518535 |
2 | 9.2436521 | 9.4541242 |
2 | 9.2551838 | 7.5564442 |
2 | 9.285243 | 10.2071673 |
2 | 9.3299446 | 9.0000361 |
2 | 9.3319237 | 10.0936765 |
2 | 9.373557 | 9.8826912 |
2 | 9.464094 | 9.0581829 |
2 | 9.4906742 | 9.3292611 |
2 | 9.5115338 | 9.8535287 |
2 | 9.5659971 | 10.0486414 |
2 | 9.6023175 | 7.9585361 |
2 | 9.6234813 | 8.3907157 |
2 | 9.6445082 | 9.6998504 |
2 | 9.649045 | 9.8849591 |
2 | 9.6584125 | 9.0152807 |
2 | 9.6665508 | 9.4282592 |
2 | 9.6730605 | 10.5942431 |
2 | 9.763729 | 8.2835604 |
2 | 9.7755229 | 10.407463 |
2 | 9.8076254 | 9.658945 |
2 | 9.8276345 | 8.4644596 |
2 | 9.8479234 | 7.756862 |
2 | 9.856574 | 8.503814 |
2 | 9.8622591 | 9.9170009 |
2 | 9.9363758 | 7.2319598 |
2 | 9.943909 | 8.4875439 |
2 | 9.9889206 | 10.611449 |
2 | 10.0165059 | 9.5475354 |
2 | 10.0419705 | 10.8528666 |
2 | 10.102277 | 11.0164613 |
2 | 10.1288555 | 8.7255618 |
2 | 10.1296474 | 9.9023458 |
2 | 10.1553296 | 10.365873 |
2 | 10.1730311 | 8.742746 |
2 | 10.1820635 | 8.0384904 |
2 | 10.2560427 | 10.2301575 |
2 | 10.2981906 | 11.2181469 |
2 | 10.3011218 | 5.9657148 |
2 | 10.301961 | 9.6504424 |
2 | 10.3145947 | 8.2175059 |
2 | 10.3361955 | 11.0435696 |
2 | 10.3803912 | 9.9176344 |
2 | 10.4078596 | 9.5672229 |
2 | 10.40994 | 9.6915476 |
2 | 10.4850186 | 8.672043 |
2 | 10.4965347 | 10.4085449 |
2 | 10.5192183 | 9.1697117 |
2 | 10.5647357 | 10.0321895 |
2 | 10.5648727 | 10.5589759 |
2 | 10.6015189 | 6.0994906 |
2 | 10.603581 | 10.3790253 |
2 | 10.6099817 | 7.1638026 |
2 | 10.6206807 | 9.6087325 |
2 | 10.6345994 | 9.1531639 |
2 | 10.6429483 | 10.3542054 |
2 | 10.6724078 | 8.4637002 |
2 | 10.7092349 | 8.7151763 |
2 | 10.714601 | 7.8089865 |
2 | 10.7182087 | 7.8359403 |
2 | 10.7245 | 8.2597278 |
2 | 10.7385045 | 8.4247141 |
2 | 10.770265 | 9.7400903 |
2 | 10.8110738 | 8.4712292 |
2 | 10.8312662 | 7.5418477 |
2 | 10.8319838 | 8.9931978 |
2 | 10.8578799 | 9.0934209 |
2 | 10.8853276 | 9.0234515 |
2 | 10.913638 | 9.5415647 |
2 | 10.9267408 | 8.7133325 |
2 | 11.018074 | 9.6140025 |
2 | 11.0184744 | 9.045611 |
2 | 11.0412225 | 8.2239493 |
2 | 11.0485496 | 9.0632895 |
2 | 11.0518117 | 8.0080764 |
2 | 11.0664894 | 9.1414022 |
2 | 11.0949584 | 9.125697 |
2 | 11.101395 | 9.8750952 |
2 | 11.1235131 | 8.6977035 |
2 | 11.1394266 | 8.110125 |
2 | 11.1673507 | 8.731084 |
2 | 11.1958179 | 9.1986208 |
2 | 11.2270168 | 10.334217 |
2 | 11.2319251 | 9.5158861 |
2 | 11.2327407 | 9.0726365 |
2 | 11.2746275 | 8.693953 |
2 | 11.2802248 | 6.3492874 |
2 | 11.307973 | 8.5744575 |
2 | 11.4089124 | 8.1652054 |
2 | 11.4206061 | 7.1979654 |
2 | 11.4332237 | 9.4580566 |
2 | 11.4413669 | 8.0914636 |
2 | 11.4696749 | 8.8581128 |
2 | 11.4830634 | 11.2508174 |
2 | 11.4864111 | 7.7290216 |
2 | 11.4928201 | 10.746028 |
2 | 11.4952661 | 7.12129 |
2 | 11.4990939 | 10.0108213 |
2 | 11.5146056 | 9.6430751 |
2 | 11.5521972 | 8.328596 |
2 | 11.574167 | 9.0679398 |
2 | 11.5811656 | 7.0079888 |
2 | 11.5818258 | 9.1019273 |
2 | 11.6091367 | 8.5752111 |
2 | 11.6246849 | 8.5365028 |
2 | 11.6642143 | 8.4458003 |
2 | 11.6691018 | 10.7915455 |
2 | 11.7002922 | 10.6383879 |
2 | 11.7120615 | 8.794039 |
2 | 11.7644048 | 8.8808288 |
2 | 11.7934826 | 7.4950836 |
2 | 11.9684594 | 10.0053487 |
2 | 11.9714406 | 7.2756851 |
2 | 11.9788712 | 9.9465767 |
2 | 12.0029676 | 7.9771513 |
2 | 12.024769 | 6.9830776 |
2 | 12.108955 | 10.0022074 |
2 | 12.1667502 | 7.1966235 |
2 | 12.2008513 | 11.2806987 |
2 | 12.2237865 | 9.3287031 |
2 | 12.3157701 | 7.5950945 |
2 | 12.3606768 | 12.1086731 |
2 | 12.5844491 | 9.865713 |
2 | 12.6733525 | 7.6230164 |
2 | 12.682216 | 9.4233843 |
2 | 12.6856208 | 9.310157 |
2 | 12.6906946 | 7.328908 |
2 | 12.7297457 | 10.1547281 |
2 | 15.382204 | 9.6953397 |
3 | 1.46197526 | 19.8670258 |
3 | 1.49022974 | 19.5352805 |
3 | 1.56415542 | 20.831295 |
3 | 1.95117941 | 18.9503718 |
3 | 2.05835481 | 20.557332 |
3 | 2.10288324 | 19.5935174 |
3 | 2.17447523 | 18.0540215 |
3 | 2.19810974 | 19.12201 |
3 | 2.21934452 | 19.0784394 |
3 | 2.23439904 | 19.844791 |
3 | 2.26788561 | 20.209558 |
3 | 2.47250581 | 18.6123102 |
3 | 2.5142698 | 18.4614009 |
3 | 2.54996643 | 19.2768358 |
3 | 2.55418227 | 18.884939 |
3 | 2.60602417 | 20.936468 |
3 | 2.63375978 | 20.206995 |
3 | 2.63673117 | 18.7844843 |
3 | 2.7274187 | 19.0976652 |
3 | 2.78672127 | 18.6171725 |
3 | 2.84069897 | 18.7650607 |
3 | 2.885701 | 20.137431 |
3 | 2.91613686 | 20.233336 |
3 | 2.92942006 | 18.5713626 |
3 | 2.95596944 | 20.535309 |
3 | 2.96854857 | 19.8038184 |
3 | 3.0145628 | 18.2879164 |
3 | 3.0177927 | 20.84433 |
3 | 3.0215634 | 20.765331 |
3 | 3.0319656 | 19.6683734 |
3 | 3.0682963 | 19.1762061 |
3 | 3.0797411 | 20.497518 |
3 | 3.0890363 | 19.7297415 |
3 | 3.1020139 | 19.1104753 |
3 | 3.1111965 | 20.974068 |
3 | 3.1118762 | 20.730051 |
3 | 3.1190241 | 20.626021 |
3 | 3.1290053 | 20.708113 |
3 | 3.1567038 | 18.9859388 |
3 | 3.1642717 | 20.86776 |
3 | 3.1877287 | 19.0277225 |
3 | 3.2417761 | 19.9239422 |
3 | 3.2697233 | 20.58267 |
3 | 3.2805359 | 20.839587 |
3 | 3.315033 | 17.800678 |
3 | 3.3374848 | 19.8847305 |
3 | 3.3436787 | 21.160946 |
3 | 3.3601605 | 19.9220547 |
3 | 3.3804341 | 19.5464206 |
3 | 3.419576 | 18.5611838 |
3 | 3.44766 | 19.7976419 |
3 | 3.4497856 | 20.992422 |
3 | 3.4515913 | 19.246366 |
3 | 3.462917 | 19.0683491 |
3 | 3.469379 | 21.277371 |
3 | 3.476635 | 19.7049207 |
3 | 3.4789768 | 18.7587035 |
3 | 3.4864838 | 17.8367824 |
3 | 3.494347 | 18.4188009 |
3 | 3.4977578 | 20.235316 |
3 | 3.5150408 | 21.469438 |
3 | 3.5465376 | 20.102797 |
3 | 3.5481756 | 20.500124 |
3 | 3.5623819 | 21.11233 |
3 | 3.5657523 | 19.8653065 |
3 | 3.5680518 | 19.7992902 |
3 | 3.5787906 | 19.4795982 |
3 | 3.580711 | 20.634115 |
3 | 3.5882776 | 21.154661 |
3 | 3.6154553 | 19.5561227 |
3 | 3.6240277 | 18.1513374 |
3 | 3.6271007 | 19.9594745 |
3 | 3.6423654 | 19.5207591 |
3 | 3.6532214 | 18.9213972 |
3 | 3.6708971 | 19.0647823 |
3 | 3.6816109 | 20.307332 |
3 | 3.6831495 | 20.753881 |
3 | 3.6909234 | 18.3056743 |
3 | 3.694486 | 18.4031309 |
3 | 3.7029568 | 18.7852089 |
3 | 3.7209245 | 21.160009 |
3 | 3.7554475 | 19.5635625 |
3 | 3.7561105 | 19.1486694 |
3 | 3.7591644 | 21.053899 |
3 | 3.7816041 | 21.754704 |
3 | 3.7876631 | 20.692215 |
3 | 3.8234422 | 19.7212479 |
3 | 3.8262062 | 20.727142 |
3 | 3.8288627 | 20.673864 |
3 | 3.8297793 | 20.458916 |
3 | 3.832603 | 21.074711 |
3 | 3.8353628 | 19.0803144 |
3 | 3.8556235 | 19.6185811 |
3 | 3.8563045 | 20.950317 |
3 | 3.8567533 | 20.230949 |
3 | 3.8755811 | 19.7954 |
3 | 3.8808773 | 21.261579 |
3 | 3.8832988 | 18.9781784 |
3 | 3.8843075 | 19.8027541 |
3 | 3.8905587 | 22.469766 |
3 | 3.8975282 | 20.28635 |
3 | 3.9109833 | 20.301225 |
3 | 3.9144448 | 18.974059 |
3 | 3.9165083 | 21.676352 |
3 | 3.9209176 | 19.7131755 |
3 | 3.9781659 | 21.664901 |
3 | 3.9788063 | 17.9605311 |
3 | 3.9795792 | 20.604285 |
3 | 3.9988977 | 19.3873 |
3 | 4.0085747 | 20.703644 |
3 | 4.0196867 | 22.969208 |
3 | 4.025619 | 20.081437 |
3 | 4.0534619 | 20.705229 |
3 | 4.0547586 | 20.305228 |
3 | 4.0547586 | 20.816871 |
3 | 4.0755392 | 18.3552001 |
3 | 4.075569 | 19.5328423 |
3 | 4.1066715 | 18.9310227 |
3 | 4.1219421 | 18.0786952 |
3 | 4.1325375 | 20.278667 |
3 | 4.1346469 | 19.7929784 |
3 | 4.1377228 | 19.3141014 |
3 | 4.1424518 | 19.0621782 |
3 | 4.163728 | 18.0126414 |
3 | 4.1789909 | 21.545179 |
3 | 4.1910496 | 22.74184 |
3 | 4.192648 | 21.567828 |
3 | 4.2120042 | 19.5149355 |
3 | 4.2236802 | 19.7026045 |
3 | 4.235359 | 21.291386 |
3 | 4.2504888 | 20.255275 |
3 | 4.2849944 | 19.6670767 |
3 | 4.2936236 | 20.04094 |
3 | 4.2943962 | 18.6098342 |
3 | 4.2972952 | 21.044405 |
3 | 4.3159775 | 18.8025205 |
3 | 4.3183388 | 19.7124052 |
3 | 4.3312717 | 19.1945021 |
3 | 4.3332788 | 19.858556 |
3 | 4.3436751 | 20.278825 |
3 | 4.3510198 | 19.4443378 |
3 | 4.3536828 | 19.6918611 |
3 | 4.3762487 | 20.001178 |
3 | 4.3873331 | 19.944966 |
3 | 4.4018079 | 21.336344 |
3 | 4.4049931 | 20.354974 |
3 | 4.4069312 | 20.229606 |
3 | 4.4145946 | 21.865367 |
3 | 4.4298175 | 20.177013 |
3 | 4.4304013 | 21.295831 |
3 | 4.4350526 | 19.2814343 |
3 | 4.4365224 | 20.607422 |
3 | 4.4385972 | 20.113629 |
3 | 4.4395695 | 20.287594 |
3 | 4.4433867 | 19.5672236 |
3 | 4.4581051 | 19.3005269 |
3 | 4.484958 | 19.6122817 |
3 | 4.4855137 | 19.7430907 |
3 | 4.4961756 | 19.0852748 |
3 | 4.4961815 | 19.9774792 |
3 | 4.5060367 | 20.626502 |
3 | 4.5111277 | 20.048125 |
3 | 4.5353022 | 21.006037 |
3 | 4.5477455 | 19.5218191 |
3 | 4.5646723 | 18.5753288 |
3 | 4.6069566 | 19.4928334 |
3 | 4.610661 | 19.2333245 |
3 | 4.6110635 | 21.161409 |
3 | 4.6156599 | 22.24306 |
3 | 4.6157363 | 19.6247648 |
3 | 4.6231143 | 21.467851 |
3 | 4.6303499 | 21.166585 |
3 | 4.6479363 | 19.4927011 |
3 | 4.649848 | 19.9999997 |
3 | 4.6726846 | 21.196404 |
3 | 4.6956556 | 21.338031 |
3 | 4.7507975 | 21.35678 |
3 | 4.8039113 | 20.381728 |
3 | 4.8669884 | 21.926908 |
3 | 4.8952958 | 19.2367016 |
3 | 4.9323323 | 19.425336 |
3 | 4.9469818 | 20.622926 |
3 | 4.9524754 | 19.5783952 |
3 | 4.9781864 | 20.542842 |
3 | 4.9871194 | 18.4396185 |
3 | 5.0319823 | 20.890154 |
3 | 5.0549366 | 19.0793781 |
3 | 5.0848657 | 20.441317 |
3 | 5.0908691 | 20.080454 |
3 | 5.1299154 | 19.4593151 |
3 | 5.1662752 | 21.241106 |
3 | 5.1816155 | 18.5673625 |
3 | 5.2062795 | 19.3081385 |
3 | 5.2424753 | 20.28896 |
3 | 5.2425295 | 20.158123 |
3 | 5.2906467 | 21.072758 |
3 | 5.297312 | 19.8472714 |
3 | 5.2975145 | 20.757499 |
3 | 5.3062086 | 20.421346 |
3 | 5.3323506 | 20.513092 |
3 | 5.3448124 | 19.1347046 |
3 | 5.3474952 | 20.536695 |
3 | 5.4494709 | 21.900892 |
3 | 5.4986571 | 20.600885 |
3 | 5.5130076 | 21.136178 |
3 | 5.5275875 | 21.167535 |
3 | 5.5458203 | 20.827132 |
3 | 5.6357217 | 21.777843 |
3 | 5.6418671 | 20.280765 |
3 | 5.642627 | 19.750893 |
3 | 5.766496 | 20.256047 |
3 | 5.8495488 | 18.0793218 |
3 | 6.1037454 | 20.818065 |
3 | 6.2250822 | 22.607042 |
3 | 6.3813155 | 20.092317 |
3 | 6.634051 | 21.15266 |
3 | 7.0207123 | 20.895823 |
4 | 17.2951741 | 5.950383 |
4 | 17.6426889 | 4.026425 |
4 | 18.3783284 | 2.6677586 |
4 | 18.6610826 | 2.2858431 |
4 | 18.7658667 | 2.2502372 |
4 | 18.8735189 | 4.0070031 |
4 | 18.9202878 | 3.3794615 |
4 | 19.2157376 | 5.0456349 |
4 | 19.2828371 | 5.7614267 |
4 | 19.3416173 | 5.7342967 |
4 | 19.372867 | 5.071573 |
4 | 19.3793344 | 4.4288482 |
4 | 19.4471513 | 2.0290971 |
4 | 19.5507429 | 4.1520108 |
4 | 19.5796525 | 3.3137553 |
4 | 19.6592429 | 2.9047836 |
4 | 19.7027051 | 3.391466 |
4 | 19.7066826 | 3.8575872 |
4 | 19.7665198 | 4.6534996 |
4 | 19.8166826 | 5.0681208 |
4 | 19.8309236 | 4.4234537 |
4 | 19.8705837 | 1.95144045 |
4 | 19.8706565 | 2.4984245 |
4 | 19.8761654 | 4.5287529 |
4 | 19.9085948 | 1.91336718 |
4 | 19.9163915 | 5.4980526 |
4 | 19.9321293 | 5.6884465 |
4 | 19.9635774 | 5.1519153 |
4 | 19.9774131 | 1.71576669 |
4 | 20.005386 | 4.9725339 |
4 | 20.03108 | 3.1899709 |
4 | 20.031303 | 5.3222825 |
4 | 20.03259 | 5.1497509 |
4 | 20.03428 | 5.0453932 |
4 | 20.080447 | 4.3698057 |
4 | 20.083517 | 6.3154411 |
4 | 20.109498 | 1.6949377 |
4 | 20.12784 | 3.1077324 |
4 | 20.143328 | 5.2932866 |
4 | 20.153527 | 1.14745808 |
4 | 20.185165 | 5.6840752 |
4 | 20.186108 | 3.0095029 |
4 | 20.218486 | 1.86943064 |
4 | 20.225788 | 4.6446198 |
4 | 20.230586 | 3.5665214 |
4 | 20.242446 | 3.0842829 |
4 | 20.250058 | 4.6674981 |
4 | 20.256518 | 5.1025102 |
4 | 20.265683 | 2.0045272 |
4 | 20.282189 | 3.5401449 |
4 | 20.302099 | 3.6052738 |
4 | 20.308668 | 6.0612829 |
4 | 20.351454 | 4.9648817 |
4 | 20.353287 | 2.9206918 |
4 | 20.36641 | 2.0461857 |
4 | 20.372119 | 4.0134533 |
4 | 20.373874 | 4.3479411 |
4 | 20.385863 | 5.8749841 |
4 | 20.409758 | 2.4770249 |
4 | 20.429302 | 4.1856019 |
4 | 20.584737 | 5.5193866 |
4 | 20.607137 | 3.7815047 |
4 | 20.612883 | 1.24133727 |
4 | 20.62282 | 3.8538072 |
4 | 20.626709 | 5.3176161 |
4 | 20.631416 | 4.6234233 |
4 | 20.637825 | 1.13733134 |
4 | 20.650459 | 5.6764957 |
4 | 20.65138 | 5.4412149 |
4 | 20.663191 | 5.1562683 |
4 | 20.671364 | 3.1726842 |
4 | 20.676551 | 3.3428428 |
4 | 20.689668 | 1.11834644 |
4 | 20.693096 | 5.0325472 |
4 | 20.696343 | 4.5175537 |
4 | 20.699593 | 2.8767087 |
4 | 20.703645 | 4.631295 |
4 | 20.795686 | 2.7721686 |
4 | 20.809542 | 6.5642634 |
4 | 20.825847 | 3.1371149 |
4 | 20.842786 | 4.3904774 |
4 | 20.84874 | 6.3513859 |
4 | 20.860288 | 6.4784907 |
4 | 20.86037 | 2.8584966 |
4 | 20.869171 | 5.2307423 |
4 | 20.872055 | 4.0749112 |
4 | 20.87257 | 1.23464118 |
4 | 20.910788 | 5.2690191 |
4 | 20.928634 | 3.6359366 |
4 | 20.970335 | 3.8242789 |
4 | 21.036661 | 2.7005158 |
4 | 21.049342 | 3.7664064 |
4 | 21.060166 | 4.2008833 |
4 | 21.060814 | 4.9944114 |
4 | 21.068511 | 4.9511485 |
4 | 21.075475 | 3.162381 |
4 | 21.121069 | 4.024253 |
4 | 21.135204 | 4.2472877 |
4 | 21.137853 | 3.0020879 |
4 | 21.173174 | 4.1480361 |
4 | 21.186386 | 7.2251656 |
4 | 21.200991 | 2.1901514 |
4 | 21.208839 | 4.4279441 |
4 | 21.218948 | 3.7864309 |
4 | 21.221807 | 3.0719514 |
4 | 21.246152 | 5.4355796 |
4 | 21.262461 | 2.9578559 |
4 | 21.268682 | 3.628921 |
4 | 21.290465 | 3.2874838 |
4 | 21.293326 | 4.106079 |
4 | 21.301133 | 4.1777477 |
4 | 21.302882 | 3.2121843 |
4 | 21.307465 | 6.3794084 |
4 | 21.310338 | 3.0792017 |
4 | 21.377903 | 3.5628289 |
4 | 21.432628 | 3.2225798 |
4 | 21.439473 | 3.385765 |
4 | 21.467547 | 4.7781926 |
4 | 21.477121 | 3.6562905 |
4 | 21.501194 | 2.3480532 |
4 | 21.533824 | 4.9138983 |
4 | 21.54175 | 2.9172603 |
4 | 21.548589 | 4.4224972 |
4 | 21.551281 | 5.034822 |
4 | 21.580005 | 2.4249323 |
4 | 21.622936 | 2.6350977 |
4 | 21.635703 | 5.0811729 |
4 | 21.635766 | 0.6839693 |
4 | 21.636906 | 5.1485335 |
4 | 21.640693 | 5.0050765 |
4 | 21.644646 | 2.6398355 |
4 | 21.659895 | 3.7598802 |
4 | 21.6671 | 3.0851933 |
4 | 21.672122 | 1.82188274 |
4 | 21.790655 | 3.9990614 |
4 | 21.791466 | 3.9976649 |
4 | 21.823915 | 5.5021609 |
4 | 21.836958 | 2.770455 |
4 | 21.849023 | 5.0410794 |
4 | 21.875795 | 3.4999431 |
4 | 21.906133 | 5.8123412 |
4 | 21.929987 | 6.0171549 |
4 | 21.943218 | 4.5029935 |
4 | 21.944168 | 4.8880596 |
4 | 21.973628 | 5.3975676 |
4 | 21.977883 | 3.6668553 |
4 | 21.986891 | 3.3156703 |
4 | 21.990816 | 6.0919267 |
4 | 21.998018 | 5.5690895 |
4 | 22.002982 | 2.9423729 |
4 | 22.003167 | 3.1783848 |
4 | 22.02293 | 3.7394457 |
4 | 22.048313 | 5.7878447 |
4 | 22.04935 | 3.9196468 |
4 | 22.102964 | 6.9353623 |
4 | 22.104117 | 2.3553044 |
4 | 22.112408 | 4.44293 |
4 | 22.116913 | 5.7040627 |
4 | 22.117363 | 5.4379922 |
4 | 22.132975 | 4.7215931 |
4 | 22.148421 | 3.8419177 |
4 | 22.157023 | 3.3189264 |
4 | 22.209926 | 6.0647142 |
4 | 22.231745 | 4.1059839 |
4 | 22.243242 | 5.6659826 |
4 | 22.275244 | 3.4509242 |
4 | 22.283633 | 3.0655829 |
4 | 22.31873 | 3.5765372 |
4 | 22.360228 | 1.30690857 |
4 | 22.390107 | 5.4824678 |
4 | 22.391019 | 5.1110448 |
4 | 22.418397 | 3.6016607 |
4 | 22.438045 | 5.2962146 |
4 | 22.502628 | 2.9129491 |
4 | 22.530678 | 5.270917 |
4 | 22.531774 | 3.510775 |
4 | 22.535484 | 6.3496156 |
4 | 22.555906 | 2.8812822 |
4 | 22.574879 | 4.1483826 |
4 | 22.577047 | 6.5748674 |
4 | 22.698119 | 5.5684472 |
4 | 22.712666 | 2.8698348 |
4 | 22.754716 | 2.8842441 |
4 | 22.840546 | 5.1758951 |
4 | 22.875637 | 5.5823763 |
4 | 22.913839 | 4.7236013 |
4 | 22.921435 | 4.992112 |
4 | 22.95051 | 5.507263 |
4 | 22.968837 | 3.8102658 |
4 | 23.372123 | 5.1056244 |
4 | 23.570015 | 7.3520417 |
4 | 23.871862 | 2.2839561 |
5 | 14.776254 | 15.9332623 |
5 | 14.828535 | 17.754768 |
5 | 14.9985099 | 19.006255 |
5 | 15.0332013 | 19.171739 |
5 | 15.3495864 | 18.344629 |
5 | 15.3643301 | 17.307221 |
5 | 15.6308644 | 18.729308 |
5 | 15.6742915 | 18.422276 |
5 | 15.6765912 | 18.957163 |
5 | 15.7242125 | 18.603576 |
5 | 15.7309358 | 18.287858 |
5 | 15.8201135 | 17.317803 |
5 | 16.04405 | 18.326776 |
5 | 16.2843895 | 19.224467 |
5 | 16.3338087 | 20.315561 |
5 | 16.3864874 | 19.430293 |
5 | 16.391851 | 16.6688446 |
5 | 16.4134342 | 19.813134 |
5 | 16.4887595 | 18.338325 |
5 | 16.4927375 | 18.033762 |
5 | 16.5616717 | 19.041559 |
5 | 16.679285 | 18.295844 |
5 | 16.6980917 | 16.8332204 |
5 | 16.7248246 | 17.813209 |
5 | 16.738379 | 20.513935 |
5 | 16.7447018 | 20.612144 |
5 | 16.759245 | 20.425581 |
5 | 16.8174379 | 17.387096 |
5 | 16.8318274 | 20.132314 |
5 | 16.8411981 | 18.775724 |
5 | 16.8657639 | 15.18619 |
5 | 16.9045035 | 16.6292852 |
5 | 16.9060549 | 17.432955 |
5 | 16.9236652 | 16.5085818 |
5 | 16.9246185 | 18.501414 |
5 | 16.9371979 | 18.538343 |
5 | 16.9424162 | 17.669786 |
5 | 16.9436611 | 17.422198 |
5 | 16.954384 | 16.6210745 |
5 | 17.0048745 | 18.647301 |
5 | 17.0093275 | 18.155081 |
5 | 17.0495475 | 18.4833 |
5 | 17.0627556 | 18.23776 |
5 | 17.0848806 | 18.073719 |
5 | 17.0988263 | 18.650373 |
5 | 17.1219141 | 17.029351 |
5 | 17.1366616 | 19.971848 |
5 | 17.1485928 | 18.236786 |
5 | 17.1559942 | 16.9274005 |
5 | 17.1784265 | 16.6347077 |
5 | 17.2007163 | 20.458792 |
5 | 17.2067843 | 18.878027 |
5 | 17.2126233 | 17.627478 |
5 | 17.27771 | 18.301138 |
5 | 17.339495 | 22.147247 |
5 | 17.3421613 | 18.489292 |
5 | 17.3577314 | 17.460453 |
5 | 17.3724251 | 17.838472 |
5 | 17.3996649 | 15.71695 |
5 | 17.4002773 | 14.6913483 |
5 | 17.4324959 | 15.5923088 |
5 | 17.4391638 | 18.273311 |
5 | 17.474673 | 16.1187519 |
5 | 17.4783074 | 16.7469574 |
5 | 17.4828174 | 18.835584 |
5 | 17.5082782 | 17.96041 |
5 | 17.5131746 | 16.1271108 |
5 | 17.5226118 | 20.37399 |
5 | 17.5411115 | 18.970615 |
5 | 17.5478529 | 20.084663 |
5 | 17.5593776 | 18.467168 |
5 | 17.5604301 | 16.6251063 |
5 | 17.5621066 | 15.6151074 |
5 | 17.5639823 | 15.6570201 |
5 | 17.5727543 | 16.2284542 |
5 | 17.5999234 | 19.382793 |
5 | 17.6097383 | 16.6748319 |
5 | 17.6335421 | 17.659876 |
5 | 17.6346179 | 19.120215 |
5 | 17.6394592 | 14.6308142 |
5 | 17.6442026 | 19.402978 |
5 | 17.6624146 | 18.518399 |
5 | 17.6824201 | 19.045062 |
5 | 17.6933922 | 18.000639 |
5 | 17.6988315 | 18.716886 |
5 | 17.7180367 | 18.103054 |
5 | 17.7549039 | 16.4974324 |
5 | 17.7672336 | 18.161612 |
5 | 17.7675093 | 19.396513 |
5 | 17.7926923 | 18.684571 |
5 | 17.8061956 | 18.138528 |
5 | 17.8161585 | 17.744709 |
5 | 17.8442842 | 16.5564664 |
5 | 17.8517083 | 18.048076 |
5 | 17.8798602 | 18.078834 |
5 | 17.894805 | 17.364323 |
5 | 17.897217 | 16.2556095 |
5 | 17.9274089 | 17.295782 |
5 | 17.9540314 | 17.790538 |
5 | 17.9833606 | 17.01958 |
5 | 18.010122 | 16.2967178 |
5 | 18.011117 | 17.84965 |
5 | 18.02912 | 18.488563 |
5 | 18.036761 | 16.4478485 |
5 | 18.037256 | 18.574155 |
5 | 18.063049 | 18.151774 |
5 | 18.090068 | 18.56643 |
5 | 18.094963 | 18.018778 |
5 | 18.10096 | 15.8177448 |
5 | 18.122916 | 17.674656 |
5 | 18.129248 | 18.158393 |
5 | 18.13386 | 14.7555909 |
5 | 18.149812 | 16.2079389 |
5 | 18.152682 | 20.011784 |
5 | 18.176491 | 19.079545 |
5 | 18.178535 | 17.691873 |
5 | 18.183269 | 18.910638 |
5 | 18.215687 | 15.8817595 |
5 | 18.235729 | 15.7945041 |
5 | 18.259081 | 17.087312 |
5 | 18.264561 | 17.029223 |
5 | 18.274332 | 15.8333249 |
5 | 18.330272 | 16.7431158 |
5 | 18.368219 | 16.0200739 |
5 | 18.379084 | 19.194089 |
5 | 18.379872 | 18.124247 |
5 | 18.385792 | 18.179336 |
5 | 18.398364 | 19.606996 |
5 | 18.409342 | 17.693611 |
5 | 18.437678 | 17.926307 |
5 | 18.455588 | 19.845492 |
5 | 18.475238 | 18.791697 |
5 | 18.508271 | 16.4602961 |
5 | 18.527687 | 19.682064 |
5 | 18.536628 | 17.831121 |
5 | 18.542094 | 17.563114 |
5 | 18.545504 | 17.37607 |
5 | 18.547878 | 17.319933 |
5 | 18.553336 | 19.569272 |
5 | 18.557667 | 15.180909 |
5 | 18.582784 | 19.483361 |
5 | 18.590279 | 17.149325 |
5 | 18.634664 | 18.86855 |
5 | 18.639971 | 21.681327 |
5 | 18.643215 | 16.5278489 |
5 | 18.650616 | 18.021068 |
5 | 18.659338 | 19.160969 |
5 | 18.664585 | 17.421214 |
5 | 18.67864 | 13.6651535 |
5 | 18.706178 | 19.788597 |
5 | 18.743804 | 18.332319 |
5 | 18.754485 | 17.600224 |
5 | 18.776854 | 18.299507 |
5 | 18.788332 | 18.461131 |
5 | 18.797314 | 14.9900939 |
5 | 18.812277 | 16.7877808 |
5 | 18.818708 | 17.767132 |
5 | 18.825362 | 17.998126 |
5 | 18.827257 | 17.411798 |
5 | 18.855049 | 20.06313 |
5 | 18.895247 | 15.6882882 |
5 | 18.89677 | 18.241082 |
5 | 18.90694 | 16.3827126 |
5 | 18.931778 | 19.185287 |
5 | 18.935962 | 17.947167 |
5 | 18.936954 | 19.25114 |
5 | 18.958115 | 18.59757 |
5 | 19.026628 | 19.205066 |
5 | 19.037261 | 17.780271 |
5 | 19.061187 | 19.016911 |
5 | 19.097614 | 18.740769 |
5 | 19.099027 | 18.797805 |
5 | 19.1145 | 17.767203 |
5 | 19.131498 | 17.562132 |
5 | 19.170495 | 18.460691 |
5 | 19.188678 | 19.321407 |
5 | 19.191673 | 15.5556509 |
5 | 19.201821 | 18.442701 |
5 | 19.237079 | 15.6778069 |
5 | 19.25179 | 18.030541 |
5 | 19.270079 | 19.044006 |
5 | 19.333913 | 15.3620963 |
5 | 19.35918 | 17.033823 |
5 | 19.361986 | 17.354937 |
5 | 19.365055 | 19.033464 |
5 | 19.365386 | 16.7474302 |
5 | 19.367864 | 18.965754 |
5 | 19.432841 | 19.920374 |
5 | 19.455325 | 17.293297 |
5 | 19.457648 | 18.584263 |
5 | 19.482073 | 16.4698072 |
5 | 19.495794 | 15.2869317 |
5 | 19.520868 | 17.981305 |
5 | 19.601644 | 15.5475595 |
5 | 19.626402 | 17.237819 |
5 | 19.639048 | 17.63884 |
5 | 19.664319 | 18.12114 |
5 | 19.678355 | 18.234852 |
5 | 19.706041 | 19.347441 |
5 | 19.946172 | 18.768173 |
5 | 19.954228 | 17.480191 |
5 | 20.016013 | 20.799353 |
5 | 20.025227 | 18.322595 |
5 | 20.065571 | 19.06146 |
5 | 20.080158 | 17.622466 |
5 | 20.260129 | 17.286994 |
5 | 20.385613 | 19.526589 |
5 | 20.591116 | 20.438186 |
5 | 20.774989 | 19.963467 |
5 | 20.973478 | 18.539765 |
5 | 21.657494 | 15.7015363 |
Parag Kanade/fuzzy ants/Gauss3/gauss.c
#include "headerStatic.h" /*******************************************************************/ /*** Global Variables ***/ irisData data[MAXDATA]; //To hold the data read from the file int count=0; //Count of the total number of data elements int heapCount=0; // Total number of heaps int heapRow=0; // Rows for the second iteration with heaps int newHeapCount=0; // Count of the heaps for the second iteration heap heaps[MAXDATA]; // Data structure to hold the heap information heap newHeaps[MAXDATA]; // Data Structure to hold the new heap information // For the second iteration int board[MAXROWS][MAXCOLS]; // Board on which the objects are located ant ants[MAXANTS]; // Data structure to hold the ants float Dmax=0; // Distance of the most dissimilar object pair int minHeapCount=100000; // Counter to hold the minimum heap count, used only for academic purpose // no use in the algorithm int minPosition; // the minimum heap iteration , only for academic purpose // no use in the algorithm float clsCen[MAXDATA][MAXDATA][s];//to hold the objects after hardening int cenCount[MAXDATA];//to hold the number of objects after hardening /********************************************************************/ /*** Varaibles to normalize the features between 0 and 1 */ float minInput[features], maxInput[features],scale[features],minForHeaps[features],maxForHeaps[features],scaleForHeaps[features]; /********************************************************************/ /** Variables for the FCM algorithm */ int temp[200]; /* for square matrix tests */ float eps,m; matrix U, U1; BOOLEAN stop; center V; objects X; char fname[80]; FILE *fp; int run; float inv_cov[s+1][s+1]; /* inverse of covariance matrix Y */ float Y[s][s]; long rand_index, Random_seed; long state1[52] = { 9347, 3835, 5194, 8310, 346, 535, 5297, 6711, 77, 3834, 668, 4175, 6868, 5890, 9304, 8462, 5269, 920, 65392, 41600, 70119, 91032, 76220, 26245, 4746, 73608, 32823, 63264, 75641, 99104, 36534, 24704, 98255, 72266, 75336, 65152, 7269, 63163, 88471, 27271, 43641, 76649, 47773, 23777, 27491, 35926, 16651, 48652, 89766, 90921, 6056 }; int z; int mins=0; int aveit =0; float mintab[200]; int mincount[200]; long start,end,total; int lCount;//added by parag /********************************************************************/ /********************************************************************//*int lrand48(){return(rand());}void srand48(int a){return;}*//********************************************************************/ /********************************************************************/ /* Function to read the input data set */ /* The file name is assumed to be itest.data */ /* Status: Tested */ /* Output: Data from the file into the "data" (Global) data structure */ /* Output: Count (Global), the count of the number of objects */ /********************************************************************/ void readInput() { FILE *fp; char fname[80]; int i=0,j=0; char ch; sprintf(fname,"%s.data",filename); /* Check if the input file is opened */ if((fp=fopen(fname,"r"))==NULL) { printf("\n Unable to open input file \n"); exit(0); } /*initialise the minimum maximum and the scale */ for(i=0;i<features;i++) { minInput[i]=1000; maxInput[i]=0; minForHeaps[i]=1000; maxForHeaps[i]=0; scale[i]=0; scaleForHeaps[i]=0; } /* Discard leading comments */ ch = 'c'; while (ch != '#') fscanf (fp, "%c", &ch); i=0; /* Parse the file and populate the data structure */ while(!feof(fp)) { for(j=0;j<features;j++) { fscanf(fp,"%f ",&data[i][j]); } fscanf(fp,"\n"); for(j=0;j<features;j++) { if(data[i][j]<minInput[j]) minInput[j]=data[i][j]; if(data[i][j]>maxInput[j]) maxInput[j]=data[i][j]; } i++; } count=i; /* Normailze the feature values in between 0 and 1 */ for(j=0;j<features;j++) { if(minInput[j]!=maxInput[j]) scale[j]=1.0/(maxInput[j]-minInput[j]); else scale[j]=1.0; } for(i=0;i<count;i++) { for(j=0;j<features;j++) data[i][j]=(data[i][j]-minInput[j])*scale[j]; } fclose(fp); return; }//end of function /********************************************************************/ /*Function to compute the eucldiean distance for all input data set */ /* Output : an array conatining the distance of each object with the other */ /********************************************************************/ float computeDistance() { float distance,dist=0; int i=0,j=0,k=0; distance=0; for(j=0;j<count;j++) for(i=0;i<count;i++) { for(k=0;k<features;k++) dist+=sqrt((data[j][k]-data[i][k])*(data[j][k]-data[i][k])); if(distance<dist)distance=dist; dist=0; } return(distance); } /********************************************************************/ /* Function to compute the distance between two objects */ /* Output : Euclidean d istance between the two input objects */ /********************************************************************/ float computeDistanceBetween2(irisData a,irisData b) { float temp=0; int i=0; for(i=0;i<features;i++) temp+=(a[i]-b[i])*(a[i]-b[i]); temp=sqrt(temp); return(temp); } /********************************************************************/ /* Function to find the maximum distance between the input objects*/ /* Output: the maximum distance */ /* Input : The array of distances between objects */ /********************************************************************/ /*float findMax(float *distance) { int i=0,j=0; float max=distance[0]; for(i=0;i<count;i++) for(j=0;j<count;j++) { if(max<distance[i*count+j]) max=distance[i*count+j]; } return(max); }*/ /********************************************************************/ /* Function to compute the value of an object */ /********************************************************************/ float value(irisData a) { int i=0; float temp=0; for(i=0;i<features;i++) temp+=a[i]*a[i]; return(sqrt(temp)); } /********************************************************************/ /* Function to find the object in the data structure */ /* Output : The position of the object in the data */ /* Input : The object */ /********************************************************************/ int findInData(irisData object,int iFlag) { int i=0,lastCount=0,j,position=-1,flag[features],flg;if(iFlag==1)lastCount=MAXDATA;else{}for(i=0;i<lastCount;i++){ for(j=0;j<features;j++) if(fabs(object[j]-data[i][j])<0.00001) flag[j]=1; else { flag[j]=0; break;} flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /* Function to find whether there is an object on the board at a,b */ /* Output : a flag indicating whether an object is found or not */ /* Input : The row and column indicating the board position */ /********************************************************************/ int found(int a , int b) { if(board[a][b]==9) return 1; else return 0; } /********************************************************************/ /* Function to initialize the initial board */ /* Output : None */ /* Global Structures modified : heaps */ /* Input : Flag indicating the iteration 1: First 0: Second */ /********************************************************************/ void initialise(int flag) { int a,b,i=0,k=0; int loopCount,rowCount,colCount; /* Initialize the row, column and number of heaps */ if(flag==1) { loopCount=count; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=lCount; rowCount=heapRow; colCount=heapRow; } /* Initialize the heaps */ for(i=0;i<loopCount;i++) { heaps[i].count=0; heaps[i].x=0; heaps[i].y=0; heaps[i].disPosition=0; heaps[i].Dmax=0; heaps[i].Dmean=0; } for(i=0;i<loopCount;i++) { /*find a board position which is empty*/ do { a=lrand48()%rowCount; b=lrand48()%colCount; } while(found(a,b)); /*Allocate the object to that place and assign a heap to it*/ heaps[i].x=a; heaps[i].y=b; heaps[i].count=1; heaps[i].Dmax=0; heaps[i].Dmean=0; if(flag==1) { heaps[i].objects[0]=i; for(k=0;k<features;k++)heaps[i].Ocenter[k]=data[i][k]; } else { for(k=0;k<features;k++) heaps[i].Ocenter[k]=newHeaps[i].Ocenter[k]; } heaps[i].disPosition=0; board[a][b]=9; if((debugLevel>0)&&(flag==1))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],data[heaps[i].objects[0]][0]); if((debugLevel>0)&&(flag==0))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],newHeaps[i].Ocenter[0]); } /*initialise the initial heap count*/ heapCount=loopCount; currentRow=rowCount; } /********************************************************************/ /* Function to find whether an heap is present at the location a b */ /* Output : Flag indicating the presencs of the heap */ /* Input : Roe and column indicating the board position */ /********************************************************************/ int findObject(int a,int b) { int i; int position=-1; for(i=0;i<heapCount;i++) { if((heaps[i].x==a)&&(heaps[i].y==b)) { position=i; break; } } return(position); } /********************************************************************/ /* Function initialize the ants */ /* Output : None */ /* Input : Flag indicating the iteration */ /* Global Variables Modified : ant, heapCount, heaps, board */ /********************************************************************/ void initialiseAnts(int flag) { int i=0,a=0,b=0,position,j=0,loopCount=0,rowCount,colCount,k=0; if(flag==1) { loopCount=MAXANTS; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=MAXANTSFORHEAPS; rowCount=heapRow; colCount=heapRow; } for(i=0;i<loopCount;i++) { /*generate random positions for the ants*/ a=lrand48()%rowCount; b=lrand48()%colCount; ants[i].x=a; ants[i].y=b; /*Find if an object is present at that position or not*/ if(board[a][b]==9) { ants[i].carrying=1; /*find the heap at that location*/ position=findObject(a,b); if(position==-1) { printf("\n Error in logic: Ant init \n"); //getchar(); break; } else { /*Assign the heap data to the ant data and decrement the heap count*/ if(flag==1){ for(k=0;k<features;k++)ants[i].data[k]=data[heaps[position].objects[0]][k]; }else{for(k=0;k<features;k++)ants[i].data[k]=heaps[position].Ocenter[k];} for(j=position;j<heapCount-1;j++) heaps[j]=heaps[j+1]; heapCount--; } /*Clear the board position */ board[a][b]=-9; } else ants[i].carrying=-1; ants[i].speed=0; ants[i].dir=lrand48()%8; printf("\n Ant %2d X: %2d Y: %2d Carying : %2d ",i,ants[i].x,ants[i].y,ants[i].carrying); } currentAntCount=loopCount; } /********************************************************************/ /* Function to move the ant */ /* Output: None */ /* Input: Ant to be moved and the flag indicating the iteration */ /********************************************************************/ void moveNext(ant* a,int flag) { int rowCount,colCount; /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; } else { rowCount=heapRow; colCount=heapRow; }*/rowCount=currentRow;colCount=currentRow; /*Depending upon the direction move the ant*/ switch (a->dir) { case 0: a->y++; if(a->y>=colCount)a->y=0; break; case 1: a->x--; a->y++;; if(a->x<0)a->x=rowCount-1; if(a->y>=colCount)a->y=0; break; case 2: a->x--; if(a->x<0)a->x=rowCount-1; break; case 3: a->x--; a->y--; if(a->x<0)a->x=rowCount-1; if(a->y<0)a->y=colCount-1; break; case 4: a->y--; if(a->y<0)a->y=colCount-1; break; case 5: a->x++; a->y--; if(a->x>=rowCount)a->x=0; if(a->y<0)a->y=colCount-1; break; case 6: a->x++; if(a->x>=rowCount) a->x=0; break; case 7: a->x++; a->y++; if(a->x>=rowCount)a->x=0; if(a->y>=colCount)a->y=0; break; } }//end of function /********************************************************************/ /* Function to compute the parameters of the heap */ /* Output: None */ /* Input: The heap whose parameters are to be computed iteration flag*/ /********************************************************************/ void computeHeapParameters(heap* heapData,int flag) { int i=0,j=0,k=0,position=0; float distance=0; float Dmean=0.0; float *dis; float featureSum[features]; float max=0; float sum=0; /* init*/ for(k=0;k<features;k++) featureSum[k]=0; /*Compute the distance of each object and find the maximum distance*/ max=0; if(flag==1){ for(j=0;j<heapData->count;j++) for(i=0;i<heapData->count;i++) { for(k=0;k<features;k++) sum+= (data[heapData->objects[j]][k]-data[heapData->objects[i]][k])*(data[heapData->objects[j]][k]-data[heapData->objects[i]][k]); distance=sqrt(sum); if(max<distance) max=distance; sum=0; } /* Assign the maximum distance to the heap */ heapData->Dmax=max;/*Compute the centre object*/for(i=0;i<heapData->count;i++)for(k=0;k<features;k++) featureSum[k]+=data[heapData->objects[i]][k];for(k=0;k<features;k++)heapData->Ocenter[k]=featureSum[k]*1.0/heapData->count; /* Find the mean distance */if((dis=(float *) calloc(heapData->count,sizeof(float)))==NULL){printf("\nUnable to allocate memory in the compute heap parameters procedure\n");exit(0);} for(i=0;i<heapData->count;i++) { Dmean+=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); dis[i]=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); } heapData->Dmean=Dmean*1.0/heapData->count; /*Compute the most dissimilar object*/ max=dis[0]; for(i=1;i<heapData->count;i++) if(max<dis[i]) { max=dis[i]; position=i; } /*Assign the most dissimilar object to the heap variable*/ for(k=0;k<features;k++) heapData->Odissim[k]=data[heapData->objects[position]][k]; heapData->disPosition=position;free(dis); } else{/* Heap Parameters for the second stage */for(k=0;k<features;k++){ heapData->Odissim[k]=heapData->Ocenter[k];}heapData->disPosition=0;heapData->Dmean=0;heapData->Dmax=0;} }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a single object*/ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject1(ant *a,int position,int flag) { int i,k=0; /*Clear the board*/ board[heaps[position].x][heaps[position].y]=-9; /* Assign the data to the ant*/if(flag==1){ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[0]][k];}else {for(k=0;k<features;k++) a->data[k]=heaps[position].Ocenter[k];} a->carrying=1; /*Copy all the heaps remaining heaps in the structure*/ for(i=position;i<heapCount-1;i++) heaps[i]=heaps[i+1]; /*Decrement the heap count*/ heapCount--; }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a two objects */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject2(ant *a , int position,int flag) { float Pdestroy1=-1; int i=0,k=0; /*Compute the probability to destroy the heap*/ Pdestroy1=lrand48()%13*1.0/12.0; /*If the probability is more than Pdestroy then destroy the heap */ if(Pdestroy1<Pdestroy) { /*pick the object randomly*/ i=lrand48()%2; /* Assign the data to the ant */ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[i]][k]; a->carrying=1; /*Correct the heap parameters*/ heaps[position].count=1; heaps[position].objects[0]=heaps[position].objects[1-i]; computeHeapParameters(&heaps[position],flag); } }//end of function /********************************************************************/ /*Function to pick a object from a heap consisting of more than two object */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /********************************************************************/ void pickObjectn(ant *a,int position,int flag) { int i=0,k=0; /*If the criteria is satsfied then pick the object*/ if((computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)*1.0/heaps[position].Dmean)>Tremove) { a->carrying=1; for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[heaps[position].disPosition]][k]; for(i=heaps[position].disPosition;i<heaps[position].count-1;i++) heaps[position].objects[i]=heaps[position].objects[i+1]; heaps[position].count--; computeHeapParameters(&heaps[position],1); } }//end of function /********************************************************************/ /* Function to pick a object */ /********************************************************************/ void pick(ant *a,int flag) { int position=-1,i=0; float Pload1=-1.0; for(i=0;i<heapCount;i++) { /*Check if a heap is present in the eight neighbouring cells*/ if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if Heap is found*/ if(position!=-1) { /* heap or object found.*/ /*Depending upon the number present in the heap call the corresponding routine*/ switch(heaps[i].count) { case 1: Pload1 = lrand48()%151*1.0/150.0; if(Pload1<Pload) { pickObject1(a,position,flag); } break; case 2: pickObject2(a,position,flag); break; default: pickObjectn(a,position,flag); break; } } } /********************************************************************/ /* Function to drop a object to form a new heap */ /* Output: None */ /* Input: Ant, iteration flag */ /* Global Structure modified : heap, heapCount */ /********************************************************************/ void dropObject(ant* a,int flag) { /*Create a new heap*/ int k=0; heaps[heapCount].count=1; heaps[heapCount].x=a->x; heaps[heapCount].y=a->y; heaps[heapCount].Dmax=0; heaps[heapCount].Dmean=0; heaps[heapCount].disPosition=0; for(k=0;k<features;k++) { heaps[heapCount].Odissim[k]=a->data[k]; heaps[heapCount].Ocenter[k]=a->data[k]; } if(flag==1) {heaps[heapCount].objects[0]=findInData(a->data,flag); /*computeHeapParameters(&heaps[heapCount],flag);*/ } computeHeapParameters(&heaps[heapCount],flag); heapCount++; a->carrying=-1; board[a->x][a->y]=9; }//end of function /********************************************************************/ /* Function to find the heap position during the second iteration */ /* Output: position of the heap */ /* Input: object center of the heap that the ant is carrying */ /* Global Structure modified : none */ /********************************************************************/ int findInNewheaps(irisData object) { int position=-1,i,j=0,flag[features],flg; for(i=0;i<newHeapCount;i++) { for(j=0;j<features;j++) { if(fabs(object[j]-newHeaps[i].Ocenter[j])<0.00001) flag[j]=1; else {flag[j]=0;break;} } flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /*Function to drop a object to a heap consisting of a one or more object */ /* Output: none */ /* Input: Ant, position of the heap , iteration flag */ /* Global Structure modified: heaps,newHeaps */ /********************************************************************/ void dropObject1(ant* a, int position,int flag) { int heapPosition=-1,heapPosition1=-1,i,j,k=0; irisData newData,temp; if(flag==1) { /*Add the object to the heap and compute the heap parameters*/ /*if(heaps[position].count==heaps[position].objCount) {if((junk=(int *)realloc(heaps[position].objects,((heaps[position].objCount+OBJINC)*sizeof(int))))==NULL){printf("\n Cannot Allocate memory to the new object for %d heap",position);exit(0);}heaps[position].objects=junk;heaps[position].objCount+=OBJINC;free(junk); }*/ heaps[position].objects[heaps[position].count]=findInData(a->data,flag); heaps[position].count++; computeHeapParameters(&heaps[position],flag); } else { for(k=0;k<features;k++)temp[k]=heaps[position].Ocenter[k]; heapPosition=findInNewheaps(a->data); heapPosition1=findInNewheaps(heaps[position].Ocenter); if(heapPosition==-1||heapPosition1==-1) { printf("\n error in logic:new heaps\n"); //getchar(); return; } for(k=0;k<features;k++) {newData[k]=(newHeaps[heapPosition].Ocenter[k]*newHeaps[heapPosition].count+newHeaps[heapPosition1].Ocenter[k]*newHeaps[heapPosition1].count)*1.0/(newHeaps[heapPosition].count+newHeaps[heapPosition1].count);newHeaps[heapPosition].Ocenter[k]=newData[k];heaps[position].Ocenter[k]=newData[k]; } computeHeapParameters(&heaps[position],flag); for(i=newHeaps[heapPosition].count,j=0;j<newHeaps[heapPosition1].count;i++,j++) { newHeaps[heapPosition].objects[i]=newHeaps[heapPosition1].objects[j]; } newHeaps[heapPosition].count+=newHeaps[heapPosition1].count; for(i=heapPosition1;i<newHeapCount-1;i++) newHeaps[i]=newHeaps[i+1]; newHeapCount--; } a->carrying=-1; }//end of function /********************************************************************/ /* Function to drop a object */ /* Output: None */ /* Input: Ant, iteration flag */ /********************************************************************/ void drop(ant* a,int flag) { int i, position=-1; float Pdrop1=0.0; /*Find whether we have a heap in the neighbourhood of the cell*/ for(i=0;i<heapCount;i++) { if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if a heap is found*/ if(position!=-1) { /*heap or object found.*/ /*Depending on the number of objects present take action*/ switch(heaps[position].count) { /*If criteria is satisfied then drop the object*/ case 1: if(flag==1) { if((computeDistanceBetween2(a->data,data[heaps[position].objects[0]])*1.0/Dmax)<Tcreate) dropObject1(a,position,flag); } else { if((computeDistanceBetween2(a->data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) dropObject1(a,position,flag); } break; default: if(computeDistanceBetween2(a->data,heaps[position].Ocenter)<computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)) dropObject1(a,position,flag); break; } } else { /*Compute the probability to drop the object*/ Pdrop1 = lrand48()%151*1.0/150; if(Pdrop1<Pdrop) dropObject(a,flag); } }//end of function /********************************************************************/ /* Function to move the ant */ /* Output: none */ /* Input: Ant, iteration flag */ /********************************************************************/ void move(ant* a,int flag) { float pDir; /*Check the speed */ if (a->speed!=0) { /*move in the same direction*/ a->speed--; moveNext(a,flag); } else { /*generate the new direction*/ pDir=lrand48()%17*1.0/16.0; if(pDir<.85) { a->dir=lrand48()%8; } else if(pDir>.95) { a->speed=2; } moveNext(a,flag); } } /********************************************************************/ /* Function to simulate the movement of the ants */ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified: minHeapCount, minHeapPosition */ /********************************************************************/ void iterate(int flag) { int i=0,j=0,k=0,loopCount=0; if (flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS; while (i<MAXITERATIONS) { i++; for(j=0;j<loopCount;j++) { move(&ants[j],flag); if(ants[j].carrying==1) { drop(&ants[j],flag); } else { pick(&ants[j],flag); } } if(debugLevel>0){ for(k=0;k<heapCount;k++) for(j=0;j<heapCount;j++) if((k!=j)&&(heaps[k].x==heaps[j].x)&&(heaps[k].y==heaps[j].y)) { printf("\nerror two heaps with same co ordinates %d %d ",k,j); //getchar(); } k=0; for(j=0;j<heapCount;j++) k+=heaps[j].count; } if(heapCount<minHeapCount) { minHeapCount=heapCount; minPosition=i; } if(debugLevel>0) printf("\n i:%d Heap count %d sum %d",i,heapCount,k); else printf("\n i:%d Heap count %d",i,heapCount); heapSum+=heapCount; /*if(i%updateAfter==0) {adjustBoard(flag); writeIncremental(i,flag);heapSum=0;loopCount=currentAntCount; }*/ } }//end of function /********************************************************************/ /*Function to drop the objects carried by the ants after all the iterations*/ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified:none */ /********************************************************************/ void dropFinal(int flag) { int i=0,j=0,position=-1,loopCount=0; /*if(flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS;*/ loopCount=currentAntCount; for(i=0;i<loopCount;i++) { if(ants[i].carrying==1) { if(flag==1) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position,flag); } } else { /*Find if a heap is present */ do { position=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position,flag); position=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position!=-1); } } } }//end of function /********************************************************************/ /* Function for the implementation of QuickSort */ /* Output: none */ /* Input: data structure, low and high indices */ /* Global structure modified:none */ /********************************************************************/ void quickSort( heap A[], int low,int high ) { int mid=0; if(low<high) { mid=partition(A,low,high); quickSort(A,low,mid); quickSort(A,mid+1,high); } } /********************************************************************/ /* Partition routine used by quick sort */ /* Output: partition location */ /* Input: data , low, high */ /* Global structure modified:none */ /********************************************************************/ int partition(heap a[], int low,int high) { heap temp; int x=0,i=0,j=0; i=low; j=high; x=a[low].count; while (1) { while (a[j].count<x) j=j-1; while (a[i].count>x) i=i+1; if(i<j) { temp=a[i]; a[i]=a[j]; a[j--]=temp; } else return(j); } } /********************************************************************/ /* Function used to write the cluster information */ /* Output: none */ /* Input:iteration flag */ /* Global structure modified:none */ /********************************************************************/ void writeClusterInformation(int flag) { FILE *fp=fopen("center.clt","w"); FILE *fp1; FILE *fp2; FILE *fp3; char temp[80]; int i=0,j=0,k=0; int lastCount=0; int rowCount,colCount,antCount; strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp3=fopen(temp,"a"); if(dataDump) {strcpy(temp,"");sprintf(temp,"%sTot.out",filename);fp1=fopen(temp,"a");strcpy(temp,"");sprintf(temp,"%sObj.out",filename);fp2=fopen(temp,"a");if(fp1==NULL||fp2==NULL)printf("\n Error in opening file in the writer Cluster Information routine\n"); } /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; antCount=MAXANTS; } else { rowCount=heapRow; colCount=heapRow; antCount=MAXANTSFORHEAPS; }*/ rowCount=currentRow; colCount=currentRow; antCount=currentAntCount; if(fp==NULL) { printf("\n Unable to open cluster center output file \n"); /*return;*/ exit(0); } /*sort the array according to the count value and write the value of the top three elements*/ if((flag==1)&&(!EntireHeaps)) quickSort(heaps,0,heapCount); if(EntireHeaps) {if(flag==1) lastCount=heapCount;else lastCount=newHeapCount; } else lastCount=c; for(i=0;i<lastCount;i++) { if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",newHeaps[i].Ocenter[k]); fprintf(fp,"\n"); } else { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); fprintf(fp,"\n"); } } if(dataDump) { fprintf(fp1,"\n Information from the Ant Based Algorithm \n"); fprintf(fp1,"\n Important Parameters : Board %d X %d Ants : %d Iterations %d Total Heaps %d ",rowCount,colCount,antCount,MAXITERATIONS,lastCount); } if(flag==0) { if(dataDump) { fprintf(fp1," TCreateForHeaps %f \n",TcreateForHeaps); fprintf(fp2,"\nTotal Heaps : %d\n",heapCount); fprintf(fp2,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); } fprintf(fp3,"\n@ %d\n",lastCount); } else if(dataDump) fprintf(fp1,"\n");if(dataDump) { fprintf(fp1,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); for(i=0;i<lastCount;i++) if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp2,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); } fprintf(fp1," %5d\n",newHeaps[i].count); fprintf(fp2," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp1," %5d\n",heaps[i].count); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]); fprintf(fp1," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]); fprintf(fp1," %5d\n",heaps[i].count); }} if(flag==0) { if(dataDump) fprintf(fp1,"\n Objects in the heaps \n");for(i=0;i<newHeapCount;i++) { if(dataDump) fprintf(fp1,"\n\n Heap %d\n \n",i+1);fprintf(fp3,"# %d %d\n",i ,newHeaps[i].count); for(j=0;j<newHeaps[i].count;j++){ for(k=0;k<features;k++){ fprintf(fp3,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]); if(dataDump) fprintf(fp1,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]);} if(dataDump) fprintf(fp1,"\n"); fprintf(fp3,"\n"); } } } fclose(fp); fclose(fp3); if(dataDump) { fclose(fp1);fclose(fp2); }}//end of flie /********************************************************************/ /* Function to initialise the new heaps */ /* Output: none */ /* Input:new Heap structure */ /* Global structure modified:none */ /********************************************************************/ void initialiseNewHeaps(heap newHeaps[]) { int i=0,j=0; for(i=0;i<lCount;i++) { newHeaps[i].count=0; for(j=0;j<features;j++) newHeaps[i].Ocenter[j]=V[i][j]; newHeaps[i].x=heaps[i].x; newHeaps[i].y=heaps[i].y; } }//end of function /********************************************************************/ /* Function to initialise the new heaps */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ int findPosition(int i) { int j,position=0; for(j=1;j<lCount;j++) { if(U[j][i]>U[position][i]) position=j; } printf("\n Position %d ",position); return(position); }//end of function find position /********************************************************************/ /* Function to add object */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ void addObject(int object,heap * heapPosition) { heapPosition->objects[heapPosition->count]=object; heapPosition->count++; }//end of function add object /********************************************************************/ /* Function to harden the outputs obtained from fcm */ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/ void harden(heap newHeaps[]) { int i,heapPosition=-1,sum=0,j=0; /*initialise the new heaps*/ initialiseNewHeaps(newHeaps); for(i=0;i<count;i++) { heapPosition=findPosition(i); addObject(i,&newHeaps[heapPosition]); } /* To check for degenerate partitions*/ for(i=0;i<lCount;i++) { if(newHeaps[i].count==0){for(j=i;j<lCount-1;j++){newHeaps[j]=newHeaps[j+1];}lCount--;i--;} } newHeapCount=lCount; for(i=0;i<lCount;i++) computeHeapParameters(&newHeaps[i],1); if(debugLevel>0) { for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\n sum = %d",sum);} }//end of function/********************************************************************/ /* Function to initialize the initial parameters for the ant algorithm*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void init() { int i=0,j=0; for(i=0;i<MAXROWS;i++) for(j=0;j<MAXCOLS;j++) board[i][j]=-9; heapCount=0; newHeapCount=0; heapRow=0; minPosition=-1; minHeapCount=100000; for(i=0;i<MAXANTS;i++) { ants[i].carrying=-1; ants[i].x=-1; ants[i].y=-1; ants[i].speed=-1; ants[i].dir=-1; } } /********************************************************************/ /* Function to initialize the initial board */ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void initialiseBoard() { int i,j; for(i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; }/********************************************************************/ /* Function to harden the outputs obtained from fcm(2nd stage)*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: Cluster center , cluster center count*/ /********************************************************************/void harden1() { int i=0,heapPosition=-1; for(i=0;i<heapCount;i++) cenCount[i]=0; for(i=0;i<n;i++) { heapPosition=findPosition1(i); addObject1(i,heapPosition); } writeInfo(); }//end of function/********************************************************************/ /* Function to find to which class the object belongs */ /* Output: Class number */ /* Input: object position */ /* Global Structure Modified: None */ /********************************************************************/int findPosition1(int i) { int j,position=0; for(j=1;j<heapCount;j++) { if(U[j][i]>U[position][i]) position=j; } return(position); }//end of function find position/********************************************************************/ /* Function to Write the output of the hardened objects to file*/ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/void writeInfo(){int i=0,j=0,k=0;FILE *fp=fopen("fcm.out","a");if(fp==NULL){printf("\n Unable to open fcm output file \n");return;}fprintf(fp,"\n@ %d\n",heapCount);for(i=0;i<heapCount;i++){fprintf(fp,"# %d %d\n",i,cenCount[i]);for(j=0;j<cenCount[i];j++){for(k=0;k<s;k++)fprintf(fp,"%8.2f ",clsCen[i][j][k]/scale[k]+minInput[k]);fprintf(fp,"\n");}}fclose(fp);return;}/********************************************************************/ /* Function to add a object to a cluster (2nd stage) */ /* Output: none */ /* Input: object poistion , cluster position */ /* Global Structure Modified: Cluster object and cluster count*/ /*******************************************************************/void addObject1(int object,int heapPosition) { int k=0; for(k=0;k<features;k++) clsCen[heapPosition][cenCount[heapPosition]][k]=X[object][k]; cenCount[heapPosition]++; return; }//end of function add object/********************************************************************/ /* Function to read the original classification of objects */ /* Output: none */ /* Input: none */ /* Global Structure Modified: None */ /*******************************************************************/void readOrg(){int i=0,k=0;char temp[80];FILE *fp;//= fopen(dataname,"r");strcpy(temp,"");sprintf(temp,"%sFull.data",filename);fp=fopen(temp,"r");if(fp==NULL){printf("\n Unable to open full data input file ");exit(0);}for(i=0;i<n;i++){fscanf(fp,"%f ",&orgData[i][0]);for(k=1;k<s+1;k++)fscanf(fp,"%f ",&orgData[i][k]);}return;}// end of function/********************************************************************/ /* Function to classify the objects in different clusters */ /* Output: none */ /* Input: the cluster objects, the original classification, */ /* number of objects in the cluster,file to write the data */ /* Global Structure Modified: None *//********************************************************************/int analysisData(float data[][s],float orgData[n][s+1],int count,FILE * fp){int i=0,j=0,k=0,type=1,max=0;heapInfo info;for(i=0;i<c;i++){info.classObj[i]=0;}info.total=0;info.total=count;for(i=0;i<count;i++)for(j=0;j<n;j++){type=1;for(k=0;k<s;k++)if(fabs(data[i][k]-orgData[j][k+1])>errThresh){type=-1;break;}if(type!=-1){info.classObj[(int)orgData[j][0]-1]++;break;}}max=0;for(k=0;k<c;k++){if(info.classObj[k]>info.classObj[max])max=k;fprintf(fp,"\nClass %d Objects % d ",k+1,info.classObj[k]);}j=0;for(k=0;k<c;k++){if(k!=max)j+=info.classObj[k];}fprintf(fp,"\n Total errors : %d \n",j);return(j);}//end of analyse/********************************************************************/ /* Function to read the cluster information */ /* Output: none */ /* Input: input file pointer , output file pointer */ /* Global Structure Modified: None *//********************************************************************/void readFCM(FILE* fp,FILE *fp1){int i=0,j=0,k=0,l=0;int totalRuns=0,heapCount=0,junk=0,sum=0;char ch;FILE *fp2=fopen("errors.out","a");ch = 'c'; while (ch != '$') fscanf (fp, "%c", &ch);fscanf(fp,"%d\n",&totalRuns);printf("\n total runs %d ",totalRuns);for(l=0;l<totalRuns;l++){fscanf(fp,"%c",&ch);fscanf(fp,"%d\n",&heapCount);fprintf(fp1,"\n \nExperiment %d \n ",l+1);sum=0;for(i=0;i<heapCount;i++){fscanf(fp,"%c",&ch);fscanf(fp," %d %d\n",&junk,&clsCenCount[i]);for(j=0;j<clsCenCount[i];j++)for(k=0;k<s;k++)fscanf(fp,"%f",&fcmData[i][j][k]);fscanf(fp,"\n");fprintf(fp1,"\n\n Heap %d Total Objects %d \n",i+1,clsCenCount[i]);sum+=analysisData(fcmData[i],orgData,clsCenCount[i],fp1);}fprintf(fp2," %3d %3d %3d \n",l,sum,heapCount);}fprintf(fp2,"\n --------------------------\n");fclose(fp2);return;}//end of function/********************************************************************/ /* Function to update the board parameters */ /* Output: none */ /* Input: none */ /* Global Structure Modified: board size, ant count *//********************************************************************/void adjustBoard(int flag){int newRow=0,newAnt=0,antDiff=0,antsKilled=0,i=0,position[MAXANTS],position1=-1,j=0,k=0,a,b; newRow= (int)ceil(sqrt(4.0*heapSum/updateAfter)); newAnt= (int)ceil((heapSum*1.0/updateAfter)*1.0/3.0); if(newAnt<minAnts)newAnt=minAnts; if(newRow<rowMin)newRow=rowMin;antDiff=currentAntCount-newAnt; if((antDiff>0)&&(newAnt>=minAnts)) {for(i=0;i<currentAntCount;i++){if(ants[i].carrying==-1){position[antsKilled++]=i;}} if(antsKilled>=antDiff){for(i=0;i<antDiff;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1];for(k=i+1;k<antsKilled;k++)position[k]--; } currentAntCount=newAnt; }else {for(i=0;i<antsKilled;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1]; for(k=i+1;k<antsKilled;k++)position[k]--; }if(flag==1) { for(i=currentAntCount-1,k=0;k<antDiff-antsKilled;k++,i--) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position1,flag); }else { dropObject(&ants[i],flag); } } } else { //flag is zero 2nd stage /*Find if a heap is present */ do { position1=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position1].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position1,flag); position1=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position1!=-1); }//end else currentAntCount=newAnt;}//end elsecurrentAntCount=newAnt;}//end iffor(i=0;i<newAnt;i++){if((ants[i].x>=newRow)||(ants[i].y>=newRow)) { a=lrand48()%newRow; b=lrand48()%newRow; ants[i].x=a; ants[i].y=b; }} //Done with ants, now adjust the boardif((currentRow>newRow)&&(newRow>=rowMin)){for(i=0;i<heapCount;i++){if((heaps[i].x>=newRow)||(heaps[i].y>=newRow)) {do { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionheaps[i].x=a;heaps[i].y=b;board[a][b]=9;}//end if}//end for for(i=0;i<currentAntCount;i++){if((ants[i].carrying==1)&&((ants[i].x>=newRow)||(ants[i].y>=newRow))){//adjust the ant locationdo { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionants[i].x=a;ants[i].y=b;}//end if}//end for currentRow=newRow;}//end if }//end of function void writeIncremental(int iteration,int flag){FILE *fp=fopen("dump.txt","w");int i=0,j=0,k=0;fprintf(fp,"Stage %d\n",flag);fprintf(fp,"Board %d\n",currentRow);fprintf(fp,"Ants %d\n",currentAntCount);fprintf(fp,"Iteration %d\n",iteration);fprintf(fp,"Heaps %d\n",heapCount); if(flag==0)fprintf(fp,"NewHeapCount %d\n",newHeapCount); fprintf(fp,"Ants\n");for(i=0;i<currentAntCount;i++){fprintf(fp,"%d %d %d %d %d ",ants[i].x,ants[i].y,ants[i].carrying,ants[i].speed,ants[i].dir);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",ants[i].data[k]);fprintf(fp,"\n");}fprintf(fp,"Heaps\n");for(i=0;i<heapCount;i++){fprintf(fp,"%d %d %d %d %8.2f %8.2f \n",heaps[i].x,heaps[i].y,heaps[i].count,heaps[i].disPosition,heaps[i].Dmax,heaps[i].Dmean);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Ocenter[k]);fprintf(fp,"\n");for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Odissim[k]);fprintf(fp,"\n");if(flag==1){for(j=0;j<heaps[i].count;j++)fprintf(fp,"%d ",heaps[i].objects[j]);fprintf(fp,"\n");}}if(flag==0){fprintf(fp,"newHeaps\n");for(i=0;i<newHeapCount;i++){fprintf(fp,"%d\n",newHeaps[i].count);for(j=0;j<newHeaps[i].count;j++)fprintf(fp,"%d ",newHeaps[i].objects[j]);fprintf(fp,"\n");}}fclose(fp);}//end of function/********************************************************************/ /* Function Main */ /********************************************************************/ int main(int argc ,char** argv) { int sum=0,k=0,i=0,j=0; char temp[80]; FILE *fp=fopen("fcm.out","w"); FILE *fp1; FILE *fp2=fopen("antAnalysis.out","a"); FILE *fp3=fopen("fcmAnalysis.out","a"); FILE *fp4=fopen("errors.out","w"); FILE *fp5; fclose(fp4); sprintf(temp,"%sObj.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sTot.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp1=fopen(temp,"w"); fprintf(fp,"\n$%d",EXPRUN); fprintf(fp1,"\n$%d",EXPRUN); fclose(fp); fclose(fp1); if(argc==2)sscanf(argv[1],"%d",&debugLevel); printf("\n Debug level %d\n",debugLevel); for( i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; //Read from the file readInput(); //Compute the distance of all the points if(maxDist) { Dmax=computeDistance(); //Compute the maximum distance fp5=fopen("maxData.txt","w");fprintf(fp5,"%f",Dmax);fclose(fp5); } else {fp5=fopen("maxData.txt","r");fscanf(fp5,"%f",&Dmax);fclose(fp5); } printf("\n %f \n",Dmax); //Initialise the board for(k=0;k<EXPRUN;k++) { init(); sum=0; srand48(state1[k]); initialiseBoard(); initialise(1); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(1); printf("\n %d \n",heapCount); //Simulate the working of ants iterate(1); //drop the objects after all the iterations dropFinal(1); //to verify the correctness for(i=0;i<heapCount;i++) sum+=heaps[i].count; //write the cluster centers to the file writeClusterInformation(1); printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); //getchar(); //Run FCM // heapCount=2973;/* To be commented */ printf("\n\n k %d \n\n",k); Fcm(data); //compute new board size. lCount=heapCount; heapRow=(int)ceil(sqrt(4*heapCount)); newHeapCount=lCount; printf("\n LCount %d newHeapCount %d heap Row %d \n",lCount,newHeapCount,heapRow); //harden the objects harden(newHeaps); //iterate with the heaps as the objects. initialiseBoard(); initialise(0); for(i=0;i<lCount;i++) computeHeapParameters(&heaps[i],0); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(0); printf("\n %d \n",heapCount); //getchar(); //Simulate the working of ants iterate(0); dropFinal(0); writeClusterInformation(0); sum=0; for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); // getchar(); Fcm(data); harden1(); } fp=fopen("fcm.out","a"); fp1=fopen(temp,"a"); fprintf(fp,"\n"); fprintf(fp1,"\n"); fclose(fp); fclose(fp1); fp=fopen("fcm.out","r"); fp1=fopen(temp,"r");printf("\n Before read org\n");readOrg();printf("\nafter read org\n");readFCM(fp1,fp2);printf("\n After 1st read fcm\n");readFCM(fp,fp3);printf("\n After 2 fcm read \n");return(1); }//end of main /****************************************************************/ float NORM(feature , feature); void find_covar(); void Fcm (irisData Data[MAXDATA]) { int i,j,l; FILE *ofile; char temp[80]; int flag=0;//added by parag FILE *iniClsCen=fopen("center.clt","a+"); if(iniClsCen==NULL) { printf("\n Unable to open the initial cluster center file\n"); printf("\n choosing random cluster centers....\n"); flag=1; } strcpy(temp,""); sprintf(temp,"%s.data",filename); strcpy (fname,temp); /* Read from this file */ m=2.0; /* The exponent */ /*GET_INPUTS1(fname);*/ /* read in feature vectors */ for (j=0; j<n ; j++) /* Read File in row-major */ for (i=0; i<s ; i++) /* format */ X[j][i]=Data[j][i]; Random_seed=state1[run];/*randseed*/ srand48(Random_seed); for (run=0;run<TOTRUNS;run++) { //flag=1;//for testing random values if (EntireHeaps) lCount=heapCount; else lCount=c; for(i=0;i<lCount;i++) for(j=0;j<s;j++) V[i][j]=0; for(i=0;i<lCount;i++) { for(l=0;l<s;l++) { if(flag==1) { rand_index = lrand48() % n; V[i][l] = X[rand_index][l]; } else { fscanf(iniClsCen,"%f ",&V[i][l]); } }//end for } eps=0.001; stop = FALSE; /* This loop finds the final cluster center and the corresponding U values */ z = 0; while (stop == FALSE) { z++; UMAT(U,V,X); /** Update the U matrix **/ stop = FINISHED(U1,eps); CLUSTER(U,X); /** Get new cluster center **/ printf("Iteration: %d\n\n", z); } /* end while */ printf("Number of iterations: %d\n\n", z);strcpy(temp,""); sprintf(temp,"%sFCM.out",filename);if(dataDump) Output(temp); /* output the results */ }/*end for*/ if(dataDump) { ofile=fopen(temp,"a"); for (i=0; i <= mins; i++) fprintf(ofile, "Min %d of %10.3f occurred %d times\n", i, mintab[i], mincount[i]); fprintf(ofile, "Average iterations %f\n", (float)aveit/(float)TOTRUNS); fclose(ofile); } }/* end Main */ /* The GET_INPUTS1 procedure opens an input file, reads the number of input vectors, the number of features per vector, the number of clusters, and epsilon, then it reads the input values */ void GET_INPUTS1(char fname[]) //char fname[]; { /* Parameters: fname -- name of file containing input info. */ FILE *infile ;//*fopen(); //char junk[10][80]; char realfname[80]; char ch; char fileName1[80]; //int temp[10], i, j, inputs, outputs, count; int i,j; sprintf (realfname, "%s", fname); /* open input file */ if(normalize==1) strcpy(fileName1,"gtest1.data"); else strcpy(fileName1,fname); if((infile = fopen (fileName1, "r")) == NULL) printf("\n CAN'T OPEN %s\n",realfname); else { ch = 'c'; /* Discard leading comments */ while (ch != '#') fscanf (infile, "%c", &ch); for (j=0; j<n ; j++) /* Read File in row-major */ { /* format */ for (i=0; i<s ; i++) fscanf (infile, "%f", &X[j][i]); /* fscanf (infile, "%d", &temp[1]); */ /* end for */ } /* end for */ fclose(infile); /* close input file */ }/* end else */ } /* end GET_INPUTS1 */ /* The NORM function computes the norm of two vectors, x and v, of dimension s. This gives an indication of the distance between them */ float NORM( feature x, feature v) //feature x, v; { /* Parameters : x -- a local copy of an input vector v -- a local copy of a cluster center */ int i,j; /* loop variable */ double sum; /* the square root of sum is the norm; sum is the sum of the differences squared */ float mat1[s]; float mat2[s]; if (maha) { for (i=0; i<s; i++) mat1[i]=x[i]-v[i]; for(i=0;i<s;i++) { sum =0; for(j=0;j<s;j++) sum += mat1[j] * inv_cov[j][i]; mat2[i] = sum; } sum =0; for(j=0;j<s;j++) sum += mat1[j]*mat2[j]; } else { sum = 0; for(j=0;j<s;j++) sum += (x[j] - v[j])* (x[j] - v[j]); } return (float)(sqrt(sum)); } /* end NORM */ /* The UMAT procedure calculates the updated U matrix according to Bezdek's formula. Its side-effect is the update of the global array U1 */ void UMAT( matrix U,center V, objects X) /*matrix U; center V; objects X;*/ { /* Parameters: U, V, and X: same as in main program */ int i, j, k,l ;/* loop variables *///, class /* class whose cluster center //is closest to pattern k */; float d1,d2,d; float sum; int exact; for (k=0;k<n;k++) { /*printf("\n k %d ",k);*/ exact=false; for (i=0;i<lCount;i++) { sum=0; for (j=0;j<lCount;j++) { d1=NORM(X[k],V[i]); d2=NORM(X[k],V[j]); if(d2!=0) { d= d1/d2; d= d * d;/* pow(d1/d2,2.0/(m-1.0)); */ sum+=d; } else { exact = true; for(l=0;l<lCount;l++) if (l==j) U1[l][k]=1.0; else U1[l][k]=0.0; break; } } if (exact!=true) U1[i][k]=1.0/sum; } } } /* end UMAT */ /* The function FINISHED determines if a termination occurs. If not it updates U with U1, so its side-effect is the potential modification of U */ BOOLEAN FINISHED( matrix U1,float eps) //matrix U1; float eps; { /* Parameters: U1, eps-- same as in main */ float sum; /* sum of squared differences between corresponding elements of U and U1 */ int i,k; /* loop control variabes */ BOOLEAN finished; /* set to true if all corresponding elements are within epsilon */ finished = TRUE; sum = 0; for (i=0; i<lCount; i++) for (k=0; k<n; k++) sum += (U[i][k] - U1[i][k])*(U[i][k]-U1[i][k]); if (sqrt(sum) > eps) { finished = FALSE; for (i=0; i<lCount; i++) for (k=0; k<n; k++) U[i][k] = U1[i][k]; } /* end if */ return finished; } /* end FINISHED */ /* The CLUSTER procedure determines cluster centers in V for the c classes being searched for. The global array V is updated */ void CLUSTER( matrix U, objects X) //matrix U; objects X; { /* Parameters: U, X -- as in main */ int i, j, k; /* loop control variables */ feature num; /* numerator in the cluster center computation formula presented by Bezdek */ float denum; /* denumenator in the obove formula */ for (i=0; i<lCount; i++) { denum = 0; for (j=0; j<s; j++) { num[j] = 0; for (k=0; k<n; k++) num[j] += U[i][k] * U[i][k] * X[k][j]; /* pow(U[i][k],m) * X[k][j]; */ } /* end for */ for (k=0; k<n; k++) denum += U[i][k] * U[i][k]; /* pow(U[i][k],m); */ for (j=0; j<s; j++) V[i][j] = num[j] / denum; } /* end for */ } /* end CLUSTER */ float Compute_Jm(center V, objects X) //center V; //objects X; { int i, k,found; double Jm_value; float u,dik; Jm_value = 0; for (k=0; k<n; k++) { found = FALSE; for (i=0; i<lCount; i++) { dik=NORM(X[k],V[i]); dik=dik*dik; if (dik==0.0) { if (found == FALSE) { u=1.0; found = TRUE; printf("found the case with dik=0\n"); } else { printf("\n cant proceed with this initialization"); exit(1); } } else { if (found != TRUE) u=U1[i][k]; /* get_Uvalue(V,X,dik,k); */ else u=0.0; } Jm_value += u * u * dik;/* pow(u, m) * dik; */ } } return (Jm_value); } /* end Compute_Jm */ /* The Output procedure outputs the U matrix which gives the fuzzy measure of each feature belonging to a cluster center. It also outputs the cluster center for each class */ void Output(char fname[]) //char fname[80]; /* Parameters: U, V -- same as in main */ { int i, j, found; /* loop control variables */ float J2c; if ((fp=fopen(fname,"a"))==NULL) printf("\n CAN'T OPEN %s\n",fname); else { fprintf(fp,"\n The cluster centers are: \n"); fprintf(fp,"\n \n"); for (i=0; i<lCount; i++) { fprintf(fp,"\nCluster center %d: ",i+1); fprintf(fp,"\n"); for (j=0; j<s; j++) fprintf(fp,"%8.7f ",V[i][j]); } /* end for */ fprintf(fp,"\nThe membership grades for the feature vectors are:\n"); for (j=0; j<n; j++) { fprintf(fp,"\n"); for (i=0; i<lCount; i++) fprintf(fp," %8.7f",U[i][j]); } /* end for */ } /* end if */ J2c= Compute_Jm(V,X); found =0; for (i=0;i<= mins; i++){ if ((found == 0) && ((J2c - mintab[i]) < .001) && ((J2c - mintab[i]) > -.001)){ mincount[i]++; found = 1; } } if (found == 0){ mins++; mintab[mins]=J2c; mincount[mins]=1; } fprintf(fp,"\nJ%3.1f = %f", m,J2c); fprintf(fp, "Number of iterations: %d\n\n", z); aveit=aveit + z; fclose(fp); } /***************************************************************/ void find_covar(int m) //int m; { int i,j,k; float mean[s],sum; for (i=0;i<s;i++) mean[i]=0; for (i=0;i<s;i++) for (j=0;j<m;j++) mean[i]+=X[j][i]; for (i=0;i<s;i++) mean[i]/=m; for (i=0;i<s;i++) for (j=0;j<s;j++) { sum=0; for (k=0;k<m;k++) sum+=(X[k][i]-mean[i])*(X[k][j]-mean[j]); Y[i][j]=sum/m; } }
Parag Kanade/fuzzy ants/Gauss3/headerStatic.h
/********************************************************************//* Ant Class parameters *//* SPEED # amplitude of moves [1,10] *//* P direction Probability to move in the same direction [.5,1] *//* Max carry : Maximum object carrying time [20,200] *//* P load Probability to pick up a single object [0.4,0.8] *//* P destroy probability to destroy a heap of two objects [0,0.6] *//* T remove min. dissimilarity necessary for removing an object *//* from a heap [.1,.2] *//* T create max dissimilarity permitted for creating a heap[.05,.2]*//********************************************************************/ #include <stdio.h>#include <math.h>#include <string.h>#include<stdlib.h>#include <ctype.h>#include <time.h>#define MAXANTS 334#define MAXDATA 1000#define MAXANTSFORHEAPS 90#define MAXITERATIONS 1000#define MAXROWS 64#define MAXCOLS 64#define EXPRUN 10#define Tremove 1.50#define Tcreate 0.5#define Pdrop 0.2#define Pdestroy 0.3#define Pload 0.3#define normalize 0#define EntireHeaps 1#define TcreateForHeaps 0.19#define features 2#define filename "gauss03"#define errThresh 0.1#define dataDump 1#define maxDist 1#define INITIALOBJECTS 75#define OBJINC 10/* some type definitions to make C code a little more readable */#define TRUE 1#define FALSE 0#define n MAXDATA /* number of input vectors */#define s features /* number of features */#define c 5 /* number of clusters */#define TOTRUNS 1 /* number of V's to write out */#define false 0#define true 1#define maha 0#define square 0extern int count;int debugLevel=0;/* To debug the code and verify the correctness of algorithms*/int currHeapCount=0;typedef int BOOLEAN;typedef short TYPE_IN_DATA; /* Type of input binary data */typedef float feature[s]; /* Type of each input; made up of input features */typedef float irisData[s];typedef feature objects[MAXDATA]; /* Type of array holding all inputs */typedef feature center[MAXDATA]; /* Type of array holding cluster centers */typedef float matrix[MAXDATA][MAXDATA];/* Type of the matrix containing membership grades */typedef struct Heap {float Dmax;//maximum dissimilar distanceirisData Ocenter;//center objectfloat Dmean;//mean of the distance between the center and all the objectsirisData Odissim;//most dissimilar objectint x;//x position on the boardint y;//y position on the boardint count;//number of objects in the heapsint disPosition;//most dissimilar objectint objects[MAXDATA];int objCount;}heap;typedef struct Ant{int x;int y;int carrying;int speed;int dir;irisData data;}ant;float orgData[n][s+1];float fcmData[MAXDATA][n][s];int clsCenCount[MAXDATA];int currentRow=0;int currentAntCount=0;int updateAfter=50;int heapSum=0;int minAnts=3;int rowMin=5;typedef struct HeapInfo{int total;int classObj[c];} heapInfo;/*heapInfo info[MAXDATA];*//********************************************************************//***Function decelarations*//********************************************************************//***For ant based algorithm*/void readInput();float computeDistance();float computeDistanceBetween2(irisData a,irisData b);float findMax(float *distance);float value(irisData a);int found(int a , int b);void initialise(int flag);int findObject(int a,int b);void initialiseAnts(int flag);void moveNext(ant* a,int flag);void computeHeapParameters(heap* data,int flag);void pickObject1(ant *a,int position,int flag);void pickObject2(ant *a , int position,int flag);void pickObjectn(ant *a,int position,int flag);void pick(ant *a,int flag);void dropObject(ant* a,int flag);int findInNewheaps(irisData object);void dropObject1(ant* a, int position,int flag);void drop(ant* a,int flag);void move(ant* a,int flag);void iterate(int flag);void dropFinal(int flag);int partition(heap a[], int low,int high);void quickSort( heap A[], int low,int high ) ;void writeClusterInformation(int flag);void initialiseNewHeaps(heap newHeaps[]);int findPosition(int i);void harden(heap newHeaps[]);void harden1();int findPosition1(int );void writeInfo();void addObject1(int ,int);void readFCM(FILE *,FILE *);void readOrg();int findInData(irisData input,int iflag);void adjustBoard(int flag);void writeIncremental(int iteration,int flag);/********************************************************************//***For FCM algorithm*/void GET_INPUTS1(char []);void UMAT( matrix,center,objects);BOOLEAN FINISHED(matrix, float);void CLUSTER( matrix, objects);void Output(char[]);void Fcm();/********************************************************************/
Parag Kanade/fuzzy ants/Gauss3/maxData.txt
1.748873
Parag Kanade/fuzzy ants/Gauss4/gauss04.data
Gauss Data | |
# | |
0.53448803 | 2.3396181 |
0.85845981 | 2.6467355 |
0.93852626 | 2.910021 |
0.99039336 | 2.6959237 |
1.13522751 | 3.3371545 |
1.15816343 | 2.74101 |
1.16902868 | 2.7145902 |
1.20321506 | 2.3230994 |
1.24094079 | 2.3069846 |
1.25245225 | 3.1839526 |
1.26993324 | 3.5483323 |
1.28680391 | 2.6052432 |
1.3192367 | 3.2276855 |
1.36114833 | 3.8009784 |
1.4244067 | 2.8634449 |
1.46037797 | 2.4532789 |
1.46098959 | 3.3555875 |
1.48936047 | 2.8126198 |
1.493417 | 1.52432961 |
1.5579586 | 3.0069093 |
1.59517099 | 1.74266104 |
1.601286 | 3.447746 |
1.64249205 | 1.22137058 |
1.64603926 | 3.098612 |
1.68936857 | 3.3436606 |
1.70125847 | 2.9881431 |
1.70954162 | 2.8340884 |
1.71271143 | 2.1911658 |
1.73828501 | 3.9157625 |
1.76121259 | 3.887774 |
1.76300537 | 4.36236 |
1.78715506 | 2.7998882 |
1.79603202 | 2.3837631 |
1.81552587 | 1.7659359 |
1.81671088 | 3.0235945 |
1.83646559 | 2.7292928 |
1.84905869 | 1.90959966 |
1.87280583 | 2.9185033 |
1.93911004 | 3.2377149 |
1.94658989 | 2.8099329 |
1.95071896 | 4.3593771 |
1.95477185 | 1.82422933 |
2.0475351 | 4.7358953 |
2.0483555 | 3.6222619 |
2.0663274 | 3.0772458 |
2.0719789 | 3.3051114 |
2.0841659 | 3.8982847 |
2.0917331 | 2.4965835 |
2.1268271 | 2.7541776 |
2.1308673 | 3.1353612 |
2.1428466 | 3.0972579 |
2.1493513 | 2.8227118 |
2.1819349 | 2.8738619 |
2.1900377 | 2.5835831 |
2.2101874 | 2.8796963 |
2.2181118 | 4.0111068 |
2.2277972 | 3.0808183 |
2.2335498 | 3.9573163 |
2.2448562 | 2.6017201 |
2.2555436 | 2.9472067 |
2.2597352 | 1.95874592 |
2.2601195 | 1.81798378 |
2.2715242 | 1.46185734 |
2.2749423 | 4.2592336 |
2.2888759 | 3.4162943 |
2.319464 | 3.1180977 |
2.3266557 | 2.9249356 |
2.3269461 | 3.8783508 |
2.3458998 | 2.6047048 |
2.3471548 | 3.0660325 |
2.3753515 | 3.4089999 |
2.3793406 | 3.1089793 |
2.3872928 | 4.3455047 |
2.3979966 | 3.3829163 |
2.4001717 | 4.0482038 |
2.4054732 | 2.6215221 |
2.4312392 | 1.79191521 |
2.4354818 | 4.0271297 |
2.4410139 | 3.7986203 |
2.4641202 | 1.58155858 |
2.4646153 | 4.9791516 |
2.5055329 | 2.0990125 |
2.5286615 | 3.6943944 |
2.5534019 | 4.741445 |
2.5735908 | 2.5571016 |
2.5856639 | 1.99127551 |
2.6083411 | 3.3154722 |
2.6167515 | 4.4641362 |
2.6315791 | 3.9447703 |
2.6485825 | 2.9459715 |
2.6558902 | 2.1154736 |
2.6603318 | 3.4801616 |
2.6657018 | 2.9762646 |
2.6740867 | 3.9751515 |
2.7109312 | 2.5716093 |
2.7172934 | 2.9542265 |
2.7245997 | 3.387059 |
2.7280016 | 4.2168608 |
2.7407356 | 2.6770587 |
2.7446611 | 4.8440441 |
2.7479167 | 2.3913499 |
2.7507312 | 3.769599 |
2.7567404 | 2.4447784 |
2.7591262 | 4.9952283 |
2.7610234 | 4.5877581 |
2.7736913 | 2.4399875 |
2.7826518 | 4.1827802 |
2.7882331 | 3.7558682 |
2.8048077 | 2.4894358 |
2.806578 | 3.2980184 |
2.8105734 | 4.0728863 |
2.8132452 | 1.11900227 |
2.8581162 | 3.3816176 |
2.8735926 | 3.1120087 |
2.8771577 | 2.9606585 |
2.8791867 | 1.81713304 |
2.8866894 | 2.5761363 |
2.8881009 | 1.12698201 |
2.8980516 | 3.4640572 |
2.911659 | 1.92031474 |
2.9163593 | 3.2659011 |
2.9217044 | 2.9429349 |
2.9240625 | 2.2683148 |
2.933498 | 1.99443935 |
2.9366692 | 4.0426166 |
2.9572064 | 4.2689621 |
2.987931 | 5.1287767 |
2.9907116 | 2.6489055 |
2.9930155 | 3.6846483 |
3.0011578 | 3.3236036 |
3.0107086 | 3.1802041 |
3.0650972 | 1.62687304 |
3.0760993 | 2.8564104 |
3.076595 | 4.141211 |
3.0797088 | 3.6444816 |
3.0828643 | 3.4026682 |
3.0948837 | 2.8648059 |
3.0985622 | 4.7026465 |
3.0994979 | 5.0382142 |
3.1023642 | 4.2814187 |
3.1102441 | 4.3805769 |
3.1522589 | 2.6625872 |
3.1613626 | 3.6416719 |
3.1760954 | 1.66759943 |
3.1805424 | 3.0442384 |
3.1842685 | 3.5954692 |
3.1891405 | 3.9582391 |
3.1963915 | 3.0430046 |
3.2020264 | 3.176707 |
3.204684 | 1.83693931 |
3.2052541 | 2.7499996 |
3.2066926 | 3.7208274 |
3.2109871 | 1.60017807 |
3.2146996 | 2.399128 |
3.2174554 | 1.72364346 |
3.2304159 | 1.82961734 |
3.2473506 | 2.2875368 |
3.2490397 | 3.1734422 |
3.2519844 | 2.2969987 |
3.2604619 | 1.7826934 |
3.2688021 | 3.0460717 |
3.3082186 | 4.4655713 |
3.337285 | 3.3586476 |
3.3616657 | 3.9431843 |
3.372691 | 2.7305975 |
3.3783937 | 2.3535819 |
3.3816021 | 2.9007384 |
3.3967371 | 2.1569486 |
3.409683 | 3.3595594 |
3.4193469 | 2.0856312 |
3.4234583 | 1.51782552 |
3.4392568 | 4.1463499 |
3.440037 | 4.2618835 |
3.4499319 | 1.4923003 |
3.4582683 | 2.3588849 |
3.4769531 | 4.5814207 |
3.4844316 | 2.9984511 |
3.4845173 | 2.8737064 |
3.4932187 | 2.66146 |
3.5161047 | 3.2298843 |
3.5216744 | 3.9607432 |
3.5229139 | 2.492989 |
3.5270772 | 0.93612531 |
3.5353904 | 1.28615059 |
3.5781225 | 3.5085023 |
3.5789043 | 3.6564247 |
3.5913078 | 4.4678316 |
3.6017795 | 3.3329228 |
3.6083691 | 2.7219107 |
3.609068 | 3.4104897 |
3.6328854 | 2.4587599 |
3.6469687 | 2.7014709 |
3.6920039 | 2.295654 |
3.6979838 | 3.9314267 |
3.7126542 | 3.1619493 |
3.7176177 | 3.6184841 |
3.720342 | 3.7590754 |
3.7288016 | 2.8601606 |
3.7729759 | 3.3649024 |
3.8041777 | 2.8947211 |
3.8297566 | 3.1058471 |
3.8568165 | 4.2398304 |
3.8708006 | 3.5365312 |
3.8884565 | 3.4983996 |
3.8940135 | 1.80718637 |
3.9270099 | 2.4705192 |
3.933241 | 1.61062 |
3.9722306 | 2.9105811 |
3.9772854 | 1.05260017 |
3.9773797 | 3.4382292 |
3.980513 | 1.98434561 |
4.005612 | 3.8833924 |
4.0089706 | 1.48283347 |
4.0261818 | 3.8696189 |
4.0400688 | 3.2351968 |
4.0647613 | 2.3867858 |
4.0958156 | 5.7977043 |
4.0974361 | 1.61238889 |
4.123407 | 4.2756611 |
4.140026 | 2.9104996 |
4.1401996 | 4.0088845 |
4.1743328 | 3.9899578 |
4.1808794 | 3.408549 |
4.1832203 | 2.0703815 |
4.2276428 | 3.180782 |
4.2372055 | 2.4413745 |
4.2952069 | 3.9016304 |
4.3387983 | 4.2365316 |
4.3562441 | 4.3595853 |
4.4416423 | 5.7357497 |
4.521928 | 3.8651324 |
4.5249241 | 3.4056552 |
4.6396121 | 1.74341452 |
4.6525806 | 5.0596418 |
4.6773415 | 1.65264229 |
4.7089812 | 4.4749576 |
4.7570425 | 3.2789297 |
4.7990812 | 2.8031089 |
4.8079212 | 4.2604948 |
4.8635523 | 4.3065351 |
4.8826769 | 3.4434805 |
4.9105801 | 1.0730681 |
5.0275824 | 3.9110729 |
5.2610977 | 4.5150765 |
5.2654032 | 3.5862794 |
5.3772226 | 4.6939538 |
5.3862929 | 2.8272327 |
5.6736332 | 2.4853571 |
8.9435583 | 11.4739571 |
8.9739184 | 9.87866 |
9.187397 | 11.348852 |
9.2407109 | 10.5518535 |
9.2436521 | 11.4541242 |
9.2551838 | 9.5564442 |
9.285243 | 12.2071673 |
9.3299446 | 11.0000361 |
9.3319237 | 12.0936765 |
9.373557 | 11.8826912 |
9.464094 | 11.0581829 |
9.4906742 | 11.3292611 |
9.5115338 | 11.8535287 |
9.5659971 | 12.0486414 |
9.6023175 | 9.9585361 |
9.6234813 | 10.3907157 |
9.6445082 | 11.6998504 |
9.649045 | 11.8849591 |
9.6584125 | 11.0152807 |
9.6665508 | 11.4282592 |
9.6730605 | 12.5942431 |
9.763729 | 10.2835604 |
9.7755229 | 12.407463 |
9.8076254 | 11.658945 |
9.8276345 | 10.4644596 |
9.8479234 | 9.756862 |
9.856574 | 10.503814 |
9.8622591 | 11.9170009 |
9.9363758 | 9.2319598 |
9.943909 | 10.4875439 |
9.9889206 | 12.611449 |
10.0165059 | 11.5475354 |
10.0419705 | 12.8528666 |
10.102277 | 13.0164613 |
10.1288555 | 10.7255618 |
10.1296474 | 11.9023458 |
10.1553296 | 12.365873 |
10.1730311 | 10.742746 |
10.1820635 | 10.0384904 |
10.2560427 | 12.2301575 |
10.2981906 | 13.2181469 |
10.3011218 | 7.9657148 |
10.301961 | 11.6504424 |
10.3145947 | 10.2175059 |
10.3361955 | 13.0435696 |
10.3803912 | 11.9176344 |
10.4078596 | 11.5672229 |
10.40994 | 11.6915476 |
10.4850186 | 10.672043 |
10.4965347 | 12.4085449 |
10.5192183 | 11.1697117 |
10.5647357 | 12.0321895 |
10.5648727 | 12.5589759 |
10.6015189 | 8.0994906 |
10.603581 | 12.3790253 |
10.6099817 | 9.1638026 |
10.6206807 | 11.6087325 |
10.6345994 | 11.1531639 |
10.6429483 | 12.3542054 |
10.6724078 | 10.4637002 |
10.7092349 | 10.7151763 |
10.714601 | 9.8089865 |
10.7182087 | 9.8359403 |
10.7245 | 10.2597278 |
10.7385045 | 10.4247141 |
10.770265 | 11.7400903 |
10.8110738 | 10.4712292 |
10.8312662 | 9.5418477 |
10.8319838 | 10.9931978 |
10.8578799 | 11.0934209 |
10.8853276 | 11.0234515 |
10.913638 | 11.5415647 |
10.9267408 | 10.7133325 |
11.018074 | 11.6140025 |
11.0184744 | 11.045611 |
11.0412225 | 10.2239493 |
11.0485496 | 11.0632895 |
11.0518117 | 10.0080764 |
11.0664894 | 11.1414022 |
11.0949584 | 11.125697 |
11.101395 | 11.8750952 |
11.1235131 | 10.6977035 |
11.1394266 | 10.110125 |
11.1673507 | 10.731084 |
11.1958179 | 11.1986208 |
11.2270168 | 12.334217 |
11.2319251 | 11.5158861 |
11.2327407 | 11.0726365 |
11.2746275 | 10.693953 |
11.2802248 | 8.3492874 |
11.307973 | 10.5744575 |
11.4089124 | 10.1652054 |
11.4206061 | 9.1979654 |
11.4332237 | 11.4580566 |
11.4413669 | 10.0914636 |
11.4696749 | 10.8581128 |
11.4830634 | 13.2508174 |
11.4864111 | 9.7290216 |
11.4928201 | 12.746028 |
11.4952661 | 9.12129 |
11.4990939 | 12.0108213 |
11.5146056 | 11.6430751 |
11.5521972 | 10.328596 |
11.574167 | 11.0679398 |
11.5811656 | 9.0079888 |
11.5818258 | 11.1019273 |
11.6091367 | 10.5752111 |
11.6246849 | 10.5365028 |
11.6642143 | 10.4458003 |
11.6691018 | 12.7915455 |
11.7002922 | 12.6383879 |
11.7120615 | 10.794039 |
11.7644048 | 10.8808288 |
11.7934826 | 9.4950836 |
11.9684594 | 12.0053487 |
11.9714406 | 9.2756851 |
11.9788712 | 11.9465767 |
12.0029676 | 9.9771513 |
12.024769 | 8.9830776 |
12.108955 | 12.0022074 |
12.1667502 | 9.1966235 |
12.2008513 | 13.2806987 |
12.2237865 | 11.3287031 |
12.3157701 | 9.5950945 |
12.3606768 | 14.1086731 |
12.5844491 | 11.865713 |
12.6733525 | 9.6230164 |
12.682216 | 11.4233843 |
12.6856208 | 11.310157 |
12.6906946 | 9.328908 |
12.7297457 | 12.1547281 |
15.382204 | 11.6953397 |
6.46197526 | 29.8670258 |
6.49022974 | 29.5352805 |
6.56415542 | 30.831295 |
6.95117941 | 28.9503718 |
7.05835481 | 30.557332 |
7.10288324 | 29.5935174 |
7.17447523 | 28.0540215 |
7.19810974 | 29.12201 |
7.21934452 | 29.0784394 |
7.23439904 | 29.844791 |
7.26788561 | 30.209558 |
7.47250581 | 28.6123102 |
7.5142698 | 28.4614009 |
7.54996643 | 29.2768358 |
7.55418227 | 28.884939 |
7.60602417 | 30.936468 |
7.63375978 | 30.206995 |
7.63673117 | 28.7844843 |
7.7274187 | 29.0976652 |
7.78672127 | 28.6171725 |
7.84069897 | 28.7650607 |
7.885701 | 30.137431 |
7.91613686 | 30.233336 |
7.92942006 | 28.5713626 |
7.95596944 | 30.535309 |
7.96854857 | 29.8038184 |
8.0145628 | 28.2879164 |
8.0177927 | 30.84433 |
8.0215634 | 30.765331 |
8.0319656 | 29.6683734 |
8.0682963 | 29.1762061 |
8.0797411 | 30.497518 |
8.0890363 | 29.7297415 |
8.1020139 | 29.1104753 |
8.1111965 | 30.974068 |
8.1118762 | 30.730051 |
8.1190241 | 30.626021 |
8.1290053 | 30.708113 |
8.1567038 | 28.9859388 |
8.1642717 | 30.86776 |
8.1877287 | 29.0277225 |
8.2417761 | 29.9239422 |
8.2697233 | 30.58267 |
8.2805359 | 30.839587 |
8.315033 | 27.800678 |
8.3374848 | 29.8847305 |
8.3436787 | 31.160946 |
8.3601605 | 29.9220547 |
8.3804341 | 29.5464206 |
8.419576 | 28.5611838 |
8.44766 | 29.7976419 |
8.4497856 | 30.992422 |
8.4515913 | 29.246366 |
8.462917 | 29.0683491 |
8.469379 | 31.277371 |
8.476635 | 29.7049207 |
8.4789768 | 28.7587035 |
8.4864838 | 27.8367824 |
8.494347 | 28.4188009 |
8.4977578 | 30.235316 |
8.5150408 | 31.469438 |
8.5465376 | 30.102797 |
8.5481756 | 30.500124 |
8.5623819 | 31.11233 |
8.5657523 | 29.8653065 |
8.5680518 | 29.7992902 |
8.5787906 | 29.4795982 |
8.580711 | 30.634115 |
8.5882776 | 31.154661 |
8.6154553 | 29.5561227 |
8.6240277 | 28.1513374 |
8.6271007 | 29.9594745 |
8.6423654 | 29.5207591 |
8.6532214 | 28.9213972 |
8.6708971 | 29.0647823 |
8.6816109 | 30.307332 |
8.6831495 | 30.753881 |
8.6909234 | 28.3056743 |
8.694486 | 28.4031309 |
8.7029568 | 28.7852089 |
8.7209245 | 31.160009 |
8.7554475 | 29.5635625 |
8.7561105 | 29.1486694 |
8.7591644 | 31.053899 |
8.7816041 | 31.754704 |
8.7876631 | 30.692215 |
8.8234422 | 29.7212479 |
8.8262062 | 30.727142 |
8.8288627 | 30.673864 |
8.8297793 | 30.458916 |
8.832603 | 31.074711 |
8.8353628 | 29.0803144 |
8.8556235 | 29.6185811 |
8.8563045 | 30.950317 |
8.8567533 | 30.230949 |
8.8755811 | 29.7954 |
8.8808773 | 31.261579 |
8.8832988 | 28.9781784 |
8.8843075 | 29.8027541 |
8.8905587 | 32.469766 |
8.8975282 | 30.28635 |
8.9109833 | 30.301225 |
8.9144448 | 28.974059 |
8.9165083 | 31.676352 |
8.9209176 | 29.7131755 |
8.9781659 | 31.664901 |
8.9788063 | 27.9605311 |
8.9795792 | 30.604285 |
8.9988977 | 29.3873 |
9.0085747 | 30.703644 |
9.0196867 | 32.969208 |
9.025619 | 30.081437 |
9.0534619 | 30.705229 |
9.0547586 | 30.305228 |
9.0547586 | 30.816871 |
9.0755392 | 28.3552001 |
9.075569 | 29.5328423 |
9.1066715 | 28.9310227 |
9.1219421 | 28.0786952 |
9.1325375 | 30.278667 |
9.1346469 | 29.7929784 |
9.1377228 | 29.3141014 |
9.1424518 | 29.0621782 |
9.163728 | 28.0126414 |
9.1789909 | 31.545179 |
9.1910496 | 32.74184 |
9.192648 | 31.567828 |
9.2120042 | 29.5149355 |
9.2236802 | 29.7026045 |
9.235359 | 31.291386 |
9.2504888 | 30.255275 |
9.2849944 | 29.6670767 |
9.2936236 | 30.04094 |
9.2943962 | 28.6098342 |
9.2972952 | 31.044405 |
9.3159775 | 28.8025205 |
9.3183388 | 29.7124052 |
9.3312717 | 29.1945021 |
9.3332788 | 29.858556 |
9.3436751 | 30.278825 |
9.3510198 | 29.4443378 |
9.3536828 | 29.6918611 |
9.3762487 | 30.001178 |
9.3873331 | 29.944966 |
9.4018079 | 31.336344 |
9.4049931 | 30.354974 |
9.4069312 | 30.229606 |
9.4145946 | 31.865367 |
9.4298175 | 30.177013 |
9.4304013 | 31.295831 |
9.4350526 | 29.2814343 |
9.4365224 | 30.607422 |
9.4385972 | 30.113629 |
9.4395695 | 30.287594 |
9.4433867 | 29.5672236 |
9.4581051 | 29.3005269 |
9.484958 | 29.6122817 |
9.4855137 | 29.7430907 |
9.4961756 | 29.0852748 |
9.4961815 | 29.9774792 |
9.5060367 | 30.626502 |
9.5111277 | 30.048125 |
9.5353022 | 31.006037 |
9.5477455 | 29.5218191 |
9.5646723 | 28.5753288 |
9.6069566 | 29.4928334 |
9.610661 | 29.2333245 |
9.6110635 | 31.161409 |
9.6156599 | 32.24306 |
9.6157363 | 29.6247648 |
9.6231143 | 31.467851 |
9.6303499 | 31.166585 |
9.6479363 | 29.4927011 |
9.649848 | 29.9999997 |
9.6726846 | 31.196404 |
9.6956556 | 31.338031 |
9.7507975 | 31.35678 |
9.8039113 | 30.381728 |
9.8669884 | 31.926908 |
9.8952958 | 29.2367016 |
9.9323323 | 29.425336 |
9.9469818 | 30.622926 |
9.9524754 | 29.5783952 |
9.9781864 | 30.542842 |
9.9871194 | 28.4396185 |
10.0319823 | 30.890154 |
10.0549366 | 29.0793781 |
10.0848657 | 30.441317 |
10.0908691 | 30.080454 |
10.1299154 | 29.4593151 |
10.1662752 | 31.241106 |
10.1816155 | 28.5673625 |
10.2062795 | 29.3081385 |
10.2424753 | 30.28896 |
10.2425295 | 30.158123 |
10.2906467 | 31.072758 |
10.297312 | 29.8472714 |
10.2975145 | 30.757499 |
10.3062086 | 30.421346 |
10.3323506 | 30.513092 |
10.3448124 | 29.1347046 |
10.3474952 | 30.536695 |
10.4494709 | 31.900892 |
10.4986571 | 30.600885 |
10.5130076 | 31.136178 |
10.5275875 | 31.167535 |
10.5458203 | 30.827132 |
10.6357217 | 31.777843 |
10.6418671 | 30.280765 |
10.642627 | 29.750893 |
10.766496 | 30.256047 |
10.8495488 | 28.0793218 |
11.1037454 | 30.818065 |
11.2250822 | 32.607042 |
11.3813155 | 30.092317 |
11.634051 | 31.15266 |
12.0207123 | 30.895823 |
27.2951741 | 5.950383 |
27.6426889 | 4.026425 |
28.3783284 | 2.6677586 |
28.6610826 | 2.2858431 |
28.7658667 | 2.2502372 |
28.8735189 | 4.0070031 |
28.9202878 | 3.3794615 |
29.2157376 | 5.0456349 |
29.2828371 | 5.7614267 |
29.3416173 | 5.7342967 |
29.372867 | 5.071573 |
29.3793344 | 4.4288482 |
29.4471513 | 2.0290971 |
29.5507429 | 4.1520108 |
29.5796525 | 3.3137553 |
29.6592429 | 2.9047836 |
29.7027051 | 3.391466 |
29.7066826 | 3.8575872 |
29.7665198 | 4.6534996 |
29.8166826 | 5.0681208 |
29.8309236 | 4.4234537 |
29.8705837 | 1.95144045 |
29.8706565 | 2.4984245 |
29.8761654 | 4.5287529 |
29.9085948 | 1.91336718 |
29.9163915 | 5.4980526 |
29.9321293 | 5.6884465 |
29.9635774 | 5.1519153 |
29.9774131 | 1.71576669 |
30.005386 | 4.9725339 |
30.03108 | 3.1899709 |
30.031303 | 5.3222825 |
30.03259 | 5.1497509 |
30.03428 | 5.0453932 |
30.080447 | 4.3698057 |
30.083517 | 6.3154411 |
30.109498 | 1.6949377 |
30.12784 | 3.1077324 |
30.143328 | 5.2932866 |
30.153527 | 1.14745808 |
30.185165 | 5.6840752 |
30.186108 | 3.0095029 |
30.218486 | 1.86943064 |
30.225788 | 4.6446198 |
30.230586 | 3.5665214 |
30.242446 | 3.0842829 |
30.250058 | 4.6674981 |
30.256518 | 5.1025102 |
30.265683 | 2.0045272 |
30.282189 | 3.5401449 |
30.302099 | 3.6052738 |
30.308668 | 6.0612829 |
30.351454 | 4.9648817 |
30.353287 | 2.9206918 |
30.36641 | 2.0461857 |
30.372119 | 4.0134533 |
30.373874 | 4.3479411 |
30.385863 | 5.8749841 |
30.409758 | 2.4770249 |
30.429302 | 4.1856019 |
30.584737 | 5.5193866 |
30.607137 | 3.7815047 |
30.612883 | 1.24133727 |
30.62282 | 3.8538072 |
30.626709 | 5.3176161 |
30.631416 | 4.6234233 |
30.637825 | 1.13733134 |
30.650459 | 5.6764957 |
30.65138 | 5.4412149 |
30.663191 | 5.1562683 |
30.671364 | 3.1726842 |
30.676551 | 3.3428428 |
30.689668 | 1.11834644 |
30.693096 | 5.0325472 |
30.696343 | 4.5175537 |
30.699593 | 2.8767087 |
30.703645 | 4.631295 |
30.795686 | 2.7721686 |
30.809542 | 6.5642634 |
30.825847 | 3.1371149 |
30.842786 | 4.3904774 |
30.84874 | 6.3513859 |
30.860288 | 6.4784907 |
30.86037 | 2.8584966 |
30.869171 | 5.2307423 |
30.872055 | 4.0749112 |
30.87257 | 1.23464118 |
30.910788 | 5.2690191 |
30.928634 | 3.6359366 |
30.970335 | 3.8242789 |
31.036661 | 2.7005158 |
31.049342 | 3.7664064 |
31.060166 | 4.2008833 |
31.060814 | 4.9944114 |
31.068511 | 4.9511485 |
31.075475 | 3.162381 |
31.121069 | 4.024253 |
31.135204 | 4.2472877 |
31.137853 | 3.0020879 |
31.173174 | 4.1480361 |
31.186386 | 7.2251656 |
31.200991 | 2.1901514 |
31.208839 | 4.4279441 |
31.218948 | 3.7864309 |
31.221807 | 3.0719514 |
31.246152 | 5.4355796 |
31.262461 | 2.9578559 |
31.268682 | 3.628921 |
31.290465 | 3.2874838 |
31.293326 | 4.106079 |
31.301133 | 4.1777477 |
31.302882 | 3.2121843 |
31.307465 | 6.3794084 |
31.310338 | 3.0792017 |
31.377903 | 3.5628289 |
31.432628 | 3.2225798 |
31.439473 | 3.385765 |
31.467547 | 4.7781926 |
31.477121 | 3.6562905 |
31.501194 | 2.3480532 |
31.533824 | 4.9138983 |
31.54175 | 2.9172603 |
31.548589 | 4.4224972 |
31.551281 | 5.034822 |
31.580005 | 2.4249323 |
31.622936 | 2.6350977 |
31.635703 | 5.0811729 |
31.635766 | 0.6839693 |
31.636906 | 5.1485335 |
31.640693 | 5.0050765 |
31.644646 | 2.6398355 |
31.659895 | 3.7598802 |
31.6671 | 3.0851933 |
31.672122 | 1.82188274 |
31.790655 | 3.9990614 |
31.791466 | 3.9976649 |
31.823915 | 5.5021609 |
31.836958 | 2.770455 |
31.849023 | 5.0410794 |
31.875795 | 3.4999431 |
31.906133 | 5.8123412 |
31.929987 | 6.0171549 |
31.943218 | 4.5029935 |
31.944168 | 4.8880596 |
31.973628 | 5.3975676 |
31.977883 | 3.6668553 |
31.986891 | 3.3156703 |
31.990816 | 6.0919267 |
31.998018 | 5.5690895 |
32.002982 | 2.9423729 |
32.003167 | 3.1783848 |
32.02293 | 3.7394457 |
32.048313 | 5.7878447 |
32.04935 | 3.9196468 |
32.102964 | 6.9353623 |
32.104117 | 2.3553044 |
32.112408 | 4.44293 |
32.116913 | 5.7040627 |
32.117363 | 5.4379922 |
32.132975 | 4.7215931 |
32.148421 | 3.8419177 |
32.157023 | 3.3189264 |
32.209926 | 6.0647142 |
32.231745 | 4.1059839 |
32.243242 | 5.6659826 |
32.275244 | 3.4509242 |
32.283633 | 3.0655829 |
32.31873 | 3.5765372 |
32.360228 | 1.30690857 |
32.390107 | 5.4824678 |
32.391019 | 5.1110448 |
32.418397 | 3.6016607 |
32.438045 | 5.2962146 |
32.502628 | 2.9129491 |
32.530678 | 5.270917 |
32.531774 | 3.510775 |
32.535484 | 6.3496156 |
32.555906 | 2.8812822 |
32.574879 | 4.1483826 |
32.577047 | 6.5748674 |
32.698119 | 5.5684472 |
32.712666 | 2.8698348 |
32.754716 | 2.8842441 |
32.840546 | 5.1758951 |
32.875637 | 5.5823763 |
32.913839 | 4.7236013 |
32.921435 | 4.992112 |
32.95051 | 5.507263 |
32.968837 | 3.8102658 |
33.372123 | 5.1056244 |
33.570015 | 7.3520417 |
33.871862 | 2.2839561 |
14.776254 | 30.9332623 |
14.828535 | 32.754768 |
14.9985099 | 34.006255 |
15.0332013 | 34.171739 |
15.3495864 | 33.344629 |
15.3643301 | 32.307221 |
15.6308644 | 33.729308 |
15.6742915 | 33.422276 |
15.6765912 | 33.957163 |
15.7242125 | 33.603576 |
15.7309358 | 33.287858 |
15.8201135 | 32.317803 |
16.04405 | 33.326776 |
16.2843895 | 34.224467 |
16.3338087 | 35.315561 |
16.3864874 | 34.430293 |
16.391851 | 31.6688446 |
16.4134342 | 34.813134 |
16.4887595 | 33.338325 |
16.4927375 | 33.033762 |
16.5616717 | 34.041559 |
16.679285 | 33.295844 |
16.6980917 | 31.8332204 |
16.7248246 | 32.813209 |
16.738379 | 35.513935 |
16.7447018 | 35.612144 |
16.759245 | 35.425581 |
16.8174379 | 32.387096 |
16.8318274 | 35.132314 |
16.8411981 | 33.775724 |
16.8657639 | 30.18619 |
16.9045035 | 31.6292852 |
16.9060549 | 32.432955 |
16.9236652 | 31.5085818 |
16.9246185 | 33.501414 |
16.9371979 | 33.538343 |
16.9424162 | 32.669786 |
16.9436611 | 32.422198 |
16.954384 | 31.6210745 |
17.0048745 | 33.647301 |
17.0093275 | 33.155081 |
17.0495475 | 33.4833 |
17.0627556 | 33.23776 |
17.0848806 | 33.073719 |
17.0988263 | 33.650373 |
17.1219141 | 32.029351 |
17.1366616 | 34.971848 |
17.1485928 | 33.236786 |
17.1559942 | 31.9274005 |
17.1784265 | 31.6347077 |
17.2007163 | 35.458792 |
17.2067843 | 33.878027 |
17.2126233 | 32.627478 |
17.27771 | 33.301138 |
17.339495 | 37.147247 |
17.3421613 | 33.489292 |
17.3577314 | 32.460453 |
17.3724251 | 32.838472 |
17.3996649 | 30.71695 |
17.4002773 | 29.6913483 |
17.4324959 | 30.5923088 |
17.4391638 | 33.273311 |
17.474673 | 31.1187519 |
17.4783074 | 31.7469574 |
17.4828174 | 33.835584 |
17.5082782 | 32.96041 |
17.5131746 | 31.1271108 |
17.5226118 | 35.37399 |
17.5411115 | 33.970615 |
17.5478529 | 35.084663 |
17.5593776 | 33.467168 |
17.5604301 | 31.6251063 |
17.5621066 | 30.6151074 |
17.5639823 | 30.6570201 |
17.5727543 | 31.2284542 |
17.5999234 | 34.382793 |
17.6097383 | 31.6748319 |
17.6335421 | 32.659876 |
17.6346179 | 34.120215 |
17.6394592 | 29.6308142 |
17.6442026 | 34.402978 |
17.6624146 | 33.518399 |
17.6824201 | 34.045062 |
17.6933922 | 33.000639 |
17.6988315 | 33.716886 |
17.7180367 | 33.103054 |
17.7549039 | 31.4974324 |
17.7672336 | 33.161612 |
17.7675093 | 34.396513 |
17.7926923 | 33.684571 |
17.8061956 | 33.138528 |
17.8161585 | 32.744709 |
17.8442842 | 31.5564664 |
17.8517083 | 33.048076 |
17.8798602 | 33.078834 |
17.894805 | 32.364323 |
17.897217 | 31.2556095 |
17.9274089 | 32.295782 |
17.9540314 | 32.790538 |
17.9833606 | 32.01958 |
18.010122 | 31.2967178 |
18.011117 | 32.84965 |
18.02912 | 33.488563 |
18.036761 | 31.4478485 |
18.037256 | 33.574155 |
18.063049 | 33.151774 |
18.090068 | 33.56643 |
18.094963 | 33.018778 |
18.10096 | 30.8177448 |
18.122916 | 32.674656 |
18.129248 | 33.158393 |
18.13386 | 29.7555909 |
18.149812 | 31.2079389 |
18.152682 | 35.011784 |
18.176491 | 34.079545 |
18.178535 | 32.691873 |
18.183269 | 33.910638 |
18.215687 | 30.8817595 |
18.235729 | 30.7945041 |
18.259081 | 32.087312 |
18.264561 | 32.029223 |
18.274332 | 30.8333249 |
18.330272 | 31.7431158 |
18.368219 | 31.0200739 |
18.379084 | 34.194089 |
18.379872 | 33.124247 |
18.385792 | 33.179336 |
18.398364 | 34.606996 |
18.409342 | 32.693611 |
18.437678 | 32.926307 |
18.455588 | 34.845492 |
18.475238 | 33.791697 |
18.508271 | 31.4602961 |
18.527687 | 34.682064 |
18.536628 | 32.831121 |
18.542094 | 32.563114 |
18.545504 | 32.37607 |
18.547878 | 32.319933 |
18.553336 | 34.569272 |
18.557667 | 30.180909 |
18.582784 | 34.483361 |
18.590279 | 32.149325 |
18.634664 | 33.86855 |
18.639971 | 36.681327 |
18.643215 | 31.5278489 |
18.650616 | 33.021068 |
18.659338 | 34.160969 |
18.664585 | 32.421214 |
18.67864 | 28.6651535 |
18.706178 | 34.788597 |
18.743804 | 33.332319 |
18.754485 | 32.600224 |
18.776854 | 33.299507 |
18.788332 | 33.461131 |
18.797314 | 29.9900939 |
18.812277 | 31.7877808 |
18.818708 | 32.767132 |
18.825362 | 32.998126 |
18.827257 | 32.411798 |
18.855049 | 35.06313 |
18.895247 | 30.6882882 |
18.89677 | 33.241082 |
18.90694 | 31.3827126 |
18.931778 | 34.185287 |
18.935962 | 32.947167 |
18.936954 | 34.25114 |
18.958115 | 33.59757 |
19.026628 | 34.205066 |
19.037261 | 32.780271 |
19.061187 | 34.016911 |
19.097614 | 33.740769 |
19.099027 | 33.797805 |
19.1145 | 32.767203 |
19.131498 | 32.562132 |
19.170495 | 33.460691 |
19.188678 | 34.321407 |
19.191673 | 30.5556509 |
19.201821 | 33.442701 |
19.237079 | 30.6778069 |
19.25179 | 33.030541 |
19.270079 | 34.044006 |
19.333913 | 30.3620963 |
19.35918 | 32.033823 |
19.361986 | 32.354937 |
19.365055 | 34.033464 |
19.365386 | 31.7474302 |
19.367864 | 33.965754 |
19.432841 | 34.920374 |
19.455325 | 32.293297 |
19.457648 | 33.584263 |
19.482073 | 31.4698072 |
19.495794 | 30.2869317 |
19.520868 | 32.981305 |
19.601644 | 30.5475595 |
19.626402 | 32.237819 |
19.639048 | 32.63884 |
19.664319 | 33.12114 |
19.678355 | 33.234852 |
19.706041 | 34.347441 |
19.946172 | 33.768173 |
19.954228 | 32.480191 |
20.016013 | 35.799353 |
20.025227 | 33.322595 |
20.065571 | 34.06146 |
20.080158 | 32.622466 |
20.260129 | 32.286994 |
20.385613 | 34.526589 |
20.591116 | 35.438186 |
20.774989 | 34.963467 |
20.973478 | 33.539765 |
21.657494 | 30.7015363 |
Parag Kanade/fuzzy ants/Gauss4/gauss04Full.data
1 | 0.53448803 | 2.3396181 |
1 | 0.85845981 | 2.6467355 |
1 | 0.93852626 | 2.910021 |
1 | 0.99039336 | 2.6959237 |
1 | 1.13522751 | 3.3371545 |
1 | 1.15816343 | 2.74101 |
1 | 1.16902868 | 2.7145902 |
1 | 1.20321506 | 2.3230994 |
1 | 1.24094079 | 2.3069846 |
1 | 1.25245225 | 3.1839526 |
1 | 1.26993324 | 3.5483323 |
1 | 1.28680391 | 2.6052432 |
1 | 1.3192367 | 3.2276855 |
1 | 1.36114833 | 3.8009784 |
1 | 1.4244067 | 2.8634449 |
1 | 1.46037797 | 2.4532789 |
1 | 1.46098959 | 3.3555875 |
1 | 1.48936047 | 2.8126198 |
1 | 1.493417 | 1.52432961 |
1 | 1.5579586 | 3.0069093 |
1 | 1.59517099 | 1.74266104 |
1 | 1.601286 | 3.447746 |
1 | 1.64249205 | 1.22137058 |
1 | 1.64603926 | 3.098612 |
1 | 1.68936857 | 3.3436606 |
1 | 1.70125847 | 2.9881431 |
1 | 1.70954162 | 2.8340884 |
1 | 1.71271143 | 2.1911658 |
1 | 1.73828501 | 3.9157625 |
1 | 1.76121259 | 3.887774 |
1 | 1.76300537 | 4.36236 |
1 | 1.78715506 | 2.7998882 |
1 | 1.79603202 | 2.3837631 |
1 | 1.81552587 | 1.7659359 |
1 | 1.81671088 | 3.0235945 |
1 | 1.83646559 | 2.7292928 |
1 | 1.84905869 | 1.90959966 |
1 | 1.87280583 | 2.9185033 |
1 | 1.93911004 | 3.2377149 |
1 | 1.94658989 | 2.8099329 |
1 | 1.95071896 | 4.3593771 |
1 | 1.95477185 | 1.82422933 |
1 | 2.0475351 | 4.7358953 |
1 | 2.0483555 | 3.6222619 |
1 | 2.0663274 | 3.0772458 |
1 | 2.0719789 | 3.3051114 |
1 | 2.0841659 | 3.8982847 |
1 | 2.0917331 | 2.4965835 |
1 | 2.1268271 | 2.7541776 |
1 | 2.1308673 | 3.1353612 |
1 | 2.1428466 | 3.0972579 |
1 | 2.1493513 | 2.8227118 |
1 | 2.1819349 | 2.8738619 |
1 | 2.1900377 | 2.5835831 |
1 | 2.2101874 | 2.8796963 |
1 | 2.2181118 | 4.0111068 |
1 | 2.2277972 | 3.0808183 |
1 | 2.2335498 | 3.9573163 |
1 | 2.2448562 | 2.6017201 |
1 | 2.2555436 | 2.9472067 |
1 | 2.2597352 | 1.95874592 |
1 | 2.2601195 | 1.81798378 |
1 | 2.2715242 | 1.46185734 |
1 | 2.2749423 | 4.2592336 |
1 | 2.2888759 | 3.4162943 |
1 | 2.319464 | 3.1180977 |
1 | 2.3266557 | 2.9249356 |
1 | 2.3269461 | 3.8783508 |
1 | 2.3458998 | 2.6047048 |
1 | 2.3471548 | 3.0660325 |
1 | 2.3753515 | 3.4089999 |
1 | 2.3793406 | 3.1089793 |
1 | 2.3872928 | 4.3455047 |
1 | 2.3979966 | 3.3829163 |
1 | 2.4001717 | 4.0482038 |
1 | 2.4054732 | 2.6215221 |
1 | 2.4312392 | 1.79191521 |
1 | 2.4354818 | 4.0271297 |
1 | 2.4410139 | 3.7986203 |
1 | 2.4641202 | 1.58155858 |
1 | 2.4646153 | 4.9791516 |
1 | 2.5055329 | 2.0990125 |
1 | 2.5286615 | 3.6943944 |
1 | 2.5534019 | 4.741445 |
1 | 2.5735908 | 2.5571016 |
1 | 2.5856639 | 1.99127551 |
1 | 2.6083411 | 3.3154722 |
1 | 2.6167515 | 4.4641362 |
1 | 2.6315791 | 3.9447703 |
1 | 2.6485825 | 2.9459715 |
1 | 2.6558902 | 2.1154736 |
1 | 2.6603318 | 3.4801616 |
1 | 2.6657018 | 2.9762646 |
1 | 2.6740867 | 3.9751515 |
1 | 2.7109312 | 2.5716093 |
1 | 2.7172934 | 2.9542265 |
1 | 2.7245997 | 3.387059 |
1 | 2.7280016 | 4.2168608 |
1 | 2.7407356 | 2.6770587 |
1 | 2.7446611 | 4.8440441 |
1 | 2.7479167 | 2.3913499 |
1 | 2.7507312 | 3.769599 |
1 | 2.7567404 | 2.4447784 |
1 | 2.7591262 | 4.9952283 |
1 | 2.7610234 | 4.5877581 |
1 | 2.7736913 | 2.4399875 |
1 | 2.7826518 | 4.1827802 |
1 | 2.7882331 | 3.7558682 |
1 | 2.8048077 | 2.4894358 |
1 | 2.806578 | 3.2980184 |
1 | 2.8105734 | 4.0728863 |
1 | 2.8132452 | 1.11900227 |
1 | 2.8581162 | 3.3816176 |
1 | 2.8735926 | 3.1120087 |
1 | 2.8771577 | 2.9606585 |
1 | 2.8791867 | 1.81713304 |
1 | 2.8866894 | 2.5761363 |
1 | 2.8881009 | 1.12698201 |
1 | 2.8980516 | 3.4640572 |
1 | 2.911659 | 1.92031474 |
1 | 2.9163593 | 3.2659011 |
1 | 2.9217044 | 2.9429349 |
1 | 2.9240625 | 2.2683148 |
1 | 2.933498 | 1.99443935 |
1 | 2.9366692 | 4.0426166 |
1 | 2.9572064 | 4.2689621 |
1 | 2.987931 | 5.1287767 |
1 | 2.9907116 | 2.6489055 |
1 | 2.9930155 | 3.6846483 |
1 | 3.0011578 | 3.3236036 |
1 | 3.0107086 | 3.1802041 |
1 | 3.0650972 | 1.62687304 |
1 | 3.0760993 | 2.8564104 |
1 | 3.076595 | 4.141211 |
1 | 3.0797088 | 3.6444816 |
1 | 3.0828643 | 3.4026682 |
1 | 3.0948837 | 2.8648059 |
1 | 3.0985622 | 4.7026465 |
1 | 3.0994979 | 5.0382142 |
1 | 3.1023642 | 4.2814187 |
1 | 3.1102441 | 4.3805769 |
1 | 3.1522589 | 2.6625872 |
1 | 3.1613626 | 3.6416719 |
1 | 3.1760954 | 1.66759943 |
1 | 3.1805424 | 3.0442384 |
1 | 3.1842685 | 3.5954692 |
1 | 3.1891405 | 3.9582391 |
1 | 3.1963915 | 3.0430046 |
1 | 3.2020264 | 3.176707 |
1 | 3.204684 | 1.83693931 |
1 | 3.2052541 | 2.7499996 |
1 | 3.2066926 | 3.7208274 |
1 | 3.2109871 | 1.60017807 |
1 | 3.2146996 | 2.399128 |
1 | 3.2174554 | 1.72364346 |
1 | 3.2304159 | 1.82961734 |
1 | 3.2473506 | 2.2875368 |
1 | 3.2490397 | 3.1734422 |
1 | 3.2519844 | 2.2969987 |
1 | 3.2604619 | 1.7826934 |
1 | 3.2688021 | 3.0460717 |
1 | 3.3082186 | 4.4655713 |
1 | 3.337285 | 3.3586476 |
1 | 3.3616657 | 3.9431843 |
1 | 3.372691 | 2.7305975 |
1 | 3.3783937 | 2.3535819 |
1 | 3.3816021 | 2.9007384 |
1 | 3.3967371 | 2.1569486 |
1 | 3.409683 | 3.3595594 |
1 | 3.4193469 | 2.0856312 |
1 | 3.4234583 | 1.51782552 |
1 | 3.4392568 | 4.1463499 |
1 | 3.440037 | 4.2618835 |
1 | 3.4499319 | 1.4923003 |
1 | 3.4582683 | 2.3588849 |
1 | 3.4769531 | 4.5814207 |
1 | 3.4844316 | 2.9984511 |
1 | 3.4845173 | 2.8737064 |
1 | 3.4932187 | 2.66146 |
1 | 3.5161047 | 3.2298843 |
1 | 3.5216744 | 3.9607432 |
1 | 3.5229139 | 2.492989 |
1 | 3.5270772 | 0.93612531 |
1 | 3.5353904 | 1.28615059 |
1 | 3.5781225 | 3.5085023 |
1 | 3.5789043 | 3.6564247 |
1 | 3.5913078 | 4.4678316 |
1 | 3.6017795 | 3.3329228 |
1 | 3.6083691 | 2.7219107 |
1 | 3.609068 | 3.4104897 |
1 | 3.6328854 | 2.4587599 |
1 | 3.6469687 | 2.7014709 |
1 | 3.6920039 | 2.295654 |
1 | 3.6979838 | 3.9314267 |
1 | 3.7126542 | 3.1619493 |
1 | 3.7176177 | 3.6184841 |
1 | 3.720342 | 3.7590754 |
1 | 3.7288016 | 2.8601606 |
1 | 3.7729759 | 3.3649024 |
1 | 3.8041777 | 2.8947211 |
1 | 3.8297566 | 3.1058471 |
1 | 3.8568165 | 4.2398304 |
1 | 3.8708006 | 3.5365312 |
1 | 3.8884565 | 3.4983996 |
1 | 3.8940135 | 1.80718637 |
1 | 3.9270099 | 2.4705192 |
1 | 3.933241 | 1.61062 |
1 | 3.9722306 | 2.9105811 |
1 | 3.9772854 | 1.05260017 |
1 | 3.9773797 | 3.4382292 |
1 | 3.980513 | 1.98434561 |
1 | 4.005612 | 3.8833924 |
1 | 4.0089706 | 1.48283347 |
1 | 4.0261818 | 3.8696189 |
1 | 4.0400688 | 3.2351968 |
1 | 4.0647613 | 2.3867858 |
1 | 4.0958156 | 5.7977043 |
1 | 4.0974361 | 1.61238889 |
1 | 4.123407 | 4.2756611 |
1 | 4.140026 | 2.9104996 |
1 | 4.1401996 | 4.0088845 |
1 | 4.1743328 | 3.9899578 |
1 | 4.1808794 | 3.408549 |
1 | 4.1832203 | 2.0703815 |
1 | 4.2276428 | 3.180782 |
1 | 4.2372055 | 2.4413745 |
1 | 4.2952069 | 3.9016304 |
1 | 4.3387983 | 4.2365316 |
1 | 4.3562441 | 4.3595853 |
1 | 4.4416423 | 5.7357497 |
1 | 4.521928 | 3.8651324 |
1 | 4.5249241 | 3.4056552 |
1 | 4.6396121 | 1.74341452 |
1 | 4.6525806 | 5.0596418 |
1 | 4.6773415 | 1.65264229 |
1 | 4.7089812 | 4.4749576 |
1 | 4.7570425 | 3.2789297 |
1 | 4.7990812 | 2.8031089 |
1 | 4.8079212 | 4.2604948 |
1 | 4.8635523 | 4.3065351 |
1 | 4.8826769 | 3.4434805 |
1 | 4.9105801 | 1.0730681 |
1 | 5.0275824 | 3.9110729 |
1 | 5.2610977 | 4.5150765 |
1 | 5.2654032 | 3.5862794 |
1 | 5.3772226 | 4.6939538 |
1 | 5.3862929 | 2.8272327 |
1 | 5.6736332 | 2.4853571 |
2 | 8.9435583 | 11.4739571 |
2 | 8.9739184 | 9.87866 |
2 | 9.187397 | 11.348852 |
2 | 9.2407109 | 10.5518535 |
2 | 9.2436521 | 11.4541242 |
2 | 9.2551838 | 9.5564442 |
2 | 9.285243 | 12.2071673 |
2 | 9.3299446 | 11.0000361 |
2 | 9.3319237 | 12.0936765 |
2 | 9.373557 | 11.8826912 |
2 | 9.464094 | 11.0581829 |
2 | 9.4906742 | 11.3292611 |
2 | 9.5115338 | 11.8535287 |
2 | 9.5659971 | 12.0486414 |
2 | 9.6023175 | 9.9585361 |
2 | 9.6234813 | 10.3907157 |
2 | 9.6445082 | 11.6998504 |
2 | 9.649045 | 11.8849591 |
2 | 9.6584125 | 11.0152807 |
2 | 9.6665508 | 11.4282592 |
2 | 9.6730605 | 12.5942431 |
2 | 9.763729 | 10.2835604 |
2 | 9.7755229 | 12.407463 |
2 | 9.8076254 | 11.658945 |
2 | 9.8276345 | 10.4644596 |
2 | 9.8479234 | 9.756862 |
2 | 9.856574 | 10.503814 |
2 | 9.8622591 | 11.9170009 |
2 | 9.9363758 | 9.2319598 |
2 | 9.943909 | 10.4875439 |
2 | 9.9889206 | 12.611449 |
2 | 10.0165059 | 11.5475354 |
2 | 10.0419705 | 12.8528666 |
2 | 10.102277 | 13.0164613 |
2 | 10.1288555 | 10.7255618 |
2 | 10.1296474 | 11.9023458 |
2 | 10.1553296 | 12.365873 |
2 | 10.1730311 | 10.742746 |
2 | 10.1820635 | 10.0384904 |
2 | 10.2560427 | 12.2301575 |
2 | 10.2981906 | 13.2181469 |
2 | 10.3011218 | 7.9657148 |
2 | 10.301961 | 11.6504424 |
2 | 10.3145947 | 10.2175059 |
2 | 10.3361955 | 13.0435696 |
2 | 10.3803912 | 11.9176344 |
2 | 10.4078596 | 11.5672229 |
2 | 10.40994 | 11.6915476 |
2 | 10.4850186 | 10.672043 |
2 | 10.4965347 | 12.4085449 |
2 | 10.5192183 | 11.1697117 |
2 | 10.5647357 | 12.0321895 |
2 | 10.5648727 | 12.5589759 |
2 | 10.6015189 | 8.0994906 |
2 | 10.603581 | 12.3790253 |
2 | 10.6099817 | 9.1638026 |
2 | 10.6206807 | 11.6087325 |
2 | 10.6345994 | 11.1531639 |
2 | 10.6429483 | 12.3542054 |
2 | 10.6724078 | 10.4637002 |
2 | 10.7092349 | 10.7151763 |
2 | 10.714601 | 9.8089865 |
2 | 10.7182087 | 9.8359403 |
2 | 10.7245 | 10.2597278 |
2 | 10.7385045 | 10.4247141 |
2 | 10.770265 | 11.7400903 |
2 | 10.8110738 | 10.4712292 |
2 | 10.8312662 | 9.5418477 |
2 | 10.8319838 | 10.9931978 |
2 | 10.8578799 | 11.0934209 |
2 | 10.8853276 | 11.0234515 |
2 | 10.913638 | 11.5415647 |
2 | 10.9267408 | 10.7133325 |
2 | 11.018074 | 11.6140025 |
2 | 11.0184744 | 11.045611 |
2 | 11.0412225 | 10.2239493 |
2 | 11.0485496 | 11.0632895 |
2 | 11.0518117 | 10.0080764 |
2 | 11.0664894 | 11.1414022 |
2 | 11.0949584 | 11.125697 |
2 | 11.101395 | 11.8750952 |
2 | 11.1235131 | 10.6977035 |
2 | 11.1394266 | 10.110125 |
2 | 11.1673507 | 10.731084 |
2 | 11.1958179 | 11.1986208 |
2 | 11.2270168 | 12.334217 |
2 | 11.2319251 | 11.5158861 |
2 | 11.2327407 | 11.0726365 |
2 | 11.2746275 | 10.693953 |
2 | 11.2802248 | 8.3492874 |
2 | 11.307973 | 10.5744575 |
2 | 11.4089124 | 10.1652054 |
2 | 11.4206061 | 9.1979654 |
2 | 11.4332237 | 11.4580566 |
2 | 11.4413669 | 10.0914636 |
2 | 11.4696749 | 10.8581128 |
2 | 11.4830634 | 13.2508174 |
2 | 11.4864111 | 9.7290216 |
2 | 11.4928201 | 12.746028 |
2 | 11.4952661 | 9.12129 |
2 | 11.4990939 | 12.0108213 |
2 | 11.5146056 | 11.6430751 |
2 | 11.5521972 | 10.328596 |
2 | 11.574167 | 11.0679398 |
2 | 11.5811656 | 9.0079888 |
2 | 11.5818258 | 11.1019273 |
2 | 11.6091367 | 10.5752111 |
2 | 11.6246849 | 10.5365028 |
2 | 11.6642143 | 10.4458003 |
2 | 11.6691018 | 12.7915455 |
2 | 11.7002922 | 12.6383879 |
2 | 11.7120615 | 10.794039 |
2 | 11.7644048 | 10.8808288 |
2 | 11.7934826 | 9.4950836 |
2 | 11.9684594 | 12.0053487 |
2 | 11.9714406 | 9.2756851 |
2 | 11.9788712 | 11.9465767 |
2 | 12.0029676 | 9.9771513 |
2 | 12.024769 | 8.9830776 |
2 | 12.108955 | 12.0022074 |
2 | 12.1667502 | 9.1966235 |
2 | 12.2008513 | 13.2806987 |
2 | 12.2237865 | 11.3287031 |
2 | 12.3157701 | 9.5950945 |
2 | 12.3606768 | 14.1086731 |
2 | 12.5844491 | 11.865713 |
2 | 12.6733525 | 9.6230164 |
2 | 12.682216 | 11.4233843 |
2 | 12.6856208 | 11.310157 |
2 | 12.6906946 | 9.328908 |
2 | 12.7297457 | 12.1547281 |
2 | 15.382204 | 11.6953397 |
3 | 6.46197526 | 29.8670258 |
3 | 6.49022974 | 29.5352805 |
3 | 6.56415542 | 30.831295 |
3 | 6.95117941 | 28.9503718 |
3 | 7.05835481 | 30.557332 |
3 | 7.10288324 | 29.5935174 |
3 | 7.17447523 | 28.0540215 |
3 | 7.19810974 | 29.12201 |
3 | 7.21934452 | 29.0784394 |
3 | 7.23439904 | 29.844791 |
3 | 7.26788561 | 30.209558 |
3 | 7.47250581 | 28.6123102 |
3 | 7.5142698 | 28.4614009 |
3 | 7.54996643 | 29.2768358 |
3 | 7.55418227 | 28.884939 |
3 | 7.60602417 | 30.936468 |
3 | 7.63375978 | 30.206995 |
3 | 7.63673117 | 28.7844843 |
3 | 7.7274187 | 29.0976652 |
3 | 7.78672127 | 28.6171725 |
3 | 7.84069897 | 28.7650607 |
3 | 7.885701 | 30.137431 |
3 | 7.91613686 | 30.233336 |
3 | 7.92942006 | 28.5713626 |
3 | 7.95596944 | 30.535309 |
3 | 7.96854857 | 29.8038184 |
3 | 8.0145628 | 28.2879164 |
3 | 8.0177927 | 30.84433 |
3 | 8.0215634 | 30.765331 |
3 | 8.0319656 | 29.6683734 |
3 | 8.0682963 | 29.1762061 |
3 | 8.0797411 | 30.497518 |
3 | 8.0890363 | 29.7297415 |
3 | 8.1020139 | 29.1104753 |
3 | 8.1111965 | 30.974068 |
3 | 8.1118762 | 30.730051 |
3 | 8.1190241 | 30.626021 |
3 | 8.1290053 | 30.708113 |
3 | 8.1567038 | 28.9859388 |
3 | 8.1642717 | 30.86776 |
3 | 8.1877287 | 29.0277225 |
3 | 8.2417761 | 29.9239422 |
3 | 8.2697233 | 30.58267 |
3 | 8.2805359 | 30.839587 |
3 | 8.315033 | 27.800678 |
3 | 8.3374848 | 29.8847305 |
3 | 8.3436787 | 31.160946 |
3 | 8.3601605 | 29.9220547 |
3 | 8.3804341 | 29.5464206 |
3 | 8.419576 | 28.5611838 |
3 | 8.44766 | 29.7976419 |
3 | 8.4497856 | 30.992422 |
3 | 8.4515913 | 29.246366 |
3 | 8.462917 | 29.0683491 |
3 | 8.469379 | 31.277371 |
3 | 8.476635 | 29.7049207 |
3 | 8.4789768 | 28.7587035 |
3 | 8.4864838 | 27.8367824 |
3 | 8.494347 | 28.4188009 |
3 | 8.4977578 | 30.235316 |
3 | 8.5150408 | 31.469438 |
3 | 8.5465376 | 30.102797 |
3 | 8.5481756 | 30.500124 |
3 | 8.5623819 | 31.11233 |
3 | 8.5657523 | 29.8653065 |
3 | 8.5680518 | 29.7992902 |
3 | 8.5787906 | 29.4795982 |
3 | 8.580711 | 30.634115 |
3 | 8.5882776 | 31.154661 |
3 | 8.6154553 | 29.5561227 |
3 | 8.6240277 | 28.1513374 |
3 | 8.6271007 | 29.9594745 |
3 | 8.6423654 | 29.5207591 |
3 | 8.6532214 | 28.9213972 |
3 | 8.6708971 | 29.0647823 |
3 | 8.6816109 | 30.307332 |
3 | 8.6831495 | 30.753881 |
3 | 8.6909234 | 28.3056743 |
3 | 8.694486 | 28.4031309 |
3 | 8.7029568 | 28.7852089 |
3 | 8.7209245 | 31.160009 |
3 | 8.7554475 | 29.5635625 |
3 | 8.7561105 | 29.1486694 |
3 | 8.7591644 | 31.053899 |
3 | 8.7816041 | 31.754704 |
3 | 8.7876631 | 30.692215 |
3 | 8.8234422 | 29.7212479 |
3 | 8.8262062 | 30.727142 |
3 | 8.8288627 | 30.673864 |
3 | 8.8297793 | 30.458916 |
3 | 8.832603 | 31.074711 |
3 | 8.8353628 | 29.0803144 |
3 | 8.8556235 | 29.6185811 |
3 | 8.8563045 | 30.950317 |
3 | 8.8567533 | 30.230949 |
3 | 8.8755811 | 29.7954 |
3 | 8.8808773 | 31.261579 |
3 | 8.8832988 | 28.9781784 |
3 | 8.8843075 | 29.8027541 |
3 | 8.8905587 | 32.469766 |
3 | 8.8975282 | 30.28635 |
3 | 8.9109833 | 30.301225 |
3 | 8.9144448 | 28.974059 |
3 | 8.9165083 | 31.676352 |
3 | 8.9209176 | 29.7131755 |
3 | 8.9781659 | 31.664901 |
3 | 8.9788063 | 27.9605311 |
3 | 8.9795792 | 30.604285 |
3 | 8.9988977 | 29.3873 |
3 | 9.0085747 | 30.703644 |
3 | 9.0196867 | 32.969208 |
3 | 9.025619 | 30.081437 |
3 | 9.0534619 | 30.705229 |
3 | 9.0547586 | 30.305228 |
3 | 9.0547586 | 30.816871 |
3 | 9.0755392 | 28.3552001 |
3 | 9.075569 | 29.5328423 |
3 | 9.1066715 | 28.9310227 |
3 | 9.1219421 | 28.0786952 |
3 | 9.1325375 | 30.278667 |
3 | 9.1346469 | 29.7929784 |
3 | 9.1377228 | 29.3141014 |
3 | 9.1424518 | 29.0621782 |
3 | 9.163728 | 28.0126414 |
3 | 9.1789909 | 31.545179 |
3 | 9.1910496 | 32.74184 |
3 | 9.192648 | 31.567828 |
3 | 9.2120042 | 29.5149355 |
3 | 9.2236802 | 29.7026045 |
3 | 9.235359 | 31.291386 |
3 | 9.2504888 | 30.255275 |
3 | 9.2849944 | 29.6670767 |
3 | 9.2936236 | 30.04094 |
3 | 9.2943962 | 28.6098342 |
3 | 9.2972952 | 31.044405 |
3 | 9.3159775 | 28.8025205 |
3 | 9.3183388 | 29.7124052 |
3 | 9.3312717 | 29.1945021 |
3 | 9.3332788 | 29.858556 |
3 | 9.3436751 | 30.278825 |
3 | 9.3510198 | 29.4443378 |
3 | 9.3536828 | 29.6918611 |
3 | 9.3762487 | 30.001178 |
3 | 9.3873331 | 29.944966 |
3 | 9.4018079 | 31.336344 |
3 | 9.4049931 | 30.354974 |
3 | 9.4069312 | 30.229606 |
3 | 9.4145946 | 31.865367 |
3 | 9.4298175 | 30.177013 |
3 | 9.4304013 | 31.295831 |
3 | 9.4350526 | 29.2814343 |
3 | 9.4365224 | 30.607422 |
3 | 9.4385972 | 30.113629 |
3 | 9.4395695 | 30.287594 |
3 | 9.4433867 | 29.5672236 |
3 | 9.4581051 | 29.3005269 |
3 | 9.484958 | 29.6122817 |
3 | 9.4855137 | 29.7430907 |
3 | 9.4961756 | 29.0852748 |
3 | 9.4961815 | 29.9774792 |
3 | 9.5060367 | 30.626502 |
3 | 9.5111277 | 30.048125 |
3 | 9.5353022 | 31.006037 |
3 | 9.5477455 | 29.5218191 |
3 | 9.5646723 | 28.5753288 |
3 | 9.6069566 | 29.4928334 |
3 | 9.610661 | 29.2333245 |
3 | 9.6110635 | 31.161409 |
3 | 9.6156599 | 32.24306 |
3 | 9.6157363 | 29.6247648 |
3 | 9.6231143 | 31.467851 |
3 | 9.6303499 | 31.166585 |
3 | 9.6479363 | 29.4927011 |
3 | 9.649848 | 29.9999997 |
3 | 9.6726846 | 31.196404 |
3 | 9.6956556 | 31.338031 |
3 | 9.7507975 | 31.35678 |
3 | 9.8039113 | 30.381728 |
3 | 9.8669884 | 31.926908 |
3 | 9.8952958 | 29.2367016 |
3 | 9.9323323 | 29.425336 |
3 | 9.9469818 | 30.622926 |
3 | 9.9524754 | 29.5783952 |
3 | 9.9781864 | 30.542842 |
3 | 9.9871194 | 28.4396185 |
3 | 10.0319823 | 30.890154 |
3 | 10.0549366 | 29.0793781 |
3 | 10.0848657 | 30.441317 |
3 | 10.0908691 | 30.080454 |
3 | 10.1299154 | 29.4593151 |
3 | 10.1662752 | 31.241106 |
3 | 10.1816155 | 28.5673625 |
3 | 10.2062795 | 29.3081385 |
3 | 10.2424753 | 30.28896 |
3 | 10.2425295 | 30.158123 |
3 | 10.2906467 | 31.072758 |
3 | 10.297312 | 29.8472714 |
3 | 10.2975145 | 30.757499 |
3 | 10.3062086 | 30.421346 |
3 | 10.3323506 | 30.513092 |
3 | 10.3448124 | 29.1347046 |
3 | 10.3474952 | 30.536695 |
3 | 10.4494709 | 31.900892 |
3 | 10.4986571 | 30.600885 |
3 | 10.5130076 | 31.136178 |
3 | 10.5275875 | 31.167535 |
3 | 10.5458203 | 30.827132 |
3 | 10.6357217 | 31.777843 |
3 | 10.6418671 | 30.280765 |
3 | 10.642627 | 29.750893 |
3 | 10.766496 | 30.256047 |
3 | 10.8495488 | 28.0793218 |
3 | 11.1037454 | 30.818065 |
3 | 11.2250822 | 32.607042 |
3 | 11.3813155 | 30.092317 |
3 | 11.634051 | 31.15266 |
3 | 12.0207123 | 30.895823 |
4 | 27.2951741 | 5.950383 |
4 | 27.6426889 | 4.026425 |
4 | 28.3783284 | 2.6677586 |
4 | 28.6610826 | 2.2858431 |
4 | 28.7658667 | 2.2502372 |
4 | 28.8735189 | 4.0070031 |
4 | 28.9202878 | 3.3794615 |
4 | 29.2157376 | 5.0456349 |
4 | 29.2828371 | 5.7614267 |
4 | 29.3416173 | 5.7342967 |
4 | 29.372867 | 5.071573 |
4 | 29.3793344 | 4.4288482 |
4 | 29.4471513 | 2.0290971 |
4 | 29.5507429 | 4.1520108 |
4 | 29.5796525 | 3.3137553 |
4 | 29.6592429 | 2.9047836 |
4 | 29.7027051 | 3.391466 |
4 | 29.7066826 | 3.8575872 |
4 | 29.7665198 | 4.6534996 |
4 | 29.8166826 | 5.0681208 |
4 | 29.8309236 | 4.4234537 |
4 | 29.8705837 | 1.95144045 |
4 | 29.8706565 | 2.4984245 |
4 | 29.8761654 | 4.5287529 |
4 | 29.9085948 | 1.91336718 |
4 | 29.9163915 | 5.4980526 |
4 | 29.9321293 | 5.6884465 |
4 | 29.9635774 | 5.1519153 |
4 | 29.9774131 | 1.71576669 |
4 | 30.005386 | 4.9725339 |
4 | 30.03108 | 3.1899709 |
4 | 30.031303 | 5.3222825 |
4 | 30.03259 | 5.1497509 |
4 | 30.03428 | 5.0453932 |
4 | 30.080447 | 4.3698057 |
4 | 30.083517 | 6.3154411 |
4 | 30.109498 | 1.6949377 |
4 | 30.12784 | 3.1077324 |
4 | 30.143328 | 5.2932866 |
4 | 30.153527 | 1.14745808 |
4 | 30.185165 | 5.6840752 |
4 | 30.186108 | 3.0095029 |
4 | 30.218486 | 1.86943064 |
4 | 30.225788 | 4.6446198 |
4 | 30.230586 | 3.5665214 |
4 | 30.242446 | 3.0842829 |
4 | 30.250058 | 4.6674981 |
4 | 30.256518 | 5.1025102 |
4 | 30.265683 | 2.0045272 |
4 | 30.282189 | 3.5401449 |
4 | 30.302099 | 3.6052738 |
4 | 30.308668 | 6.0612829 |
4 | 30.351454 | 4.9648817 |
4 | 30.353287 | 2.9206918 |
4 | 30.36641 | 2.0461857 |
4 | 30.372119 | 4.0134533 |
4 | 30.373874 | 4.3479411 |
4 | 30.385863 | 5.8749841 |
4 | 30.409758 | 2.4770249 |
4 | 30.429302 | 4.1856019 |
4 | 30.584737 | 5.5193866 |
4 | 30.607137 | 3.7815047 |
4 | 30.612883 | 1.24133727 |
4 | 30.62282 | 3.8538072 |
4 | 30.626709 | 5.3176161 |
4 | 30.631416 | 4.6234233 |
4 | 30.637825 | 1.13733134 |
4 | 30.650459 | 5.6764957 |
4 | 30.65138 | 5.4412149 |
4 | 30.663191 | 5.1562683 |
4 | 30.671364 | 3.1726842 |
4 | 30.676551 | 3.3428428 |
4 | 30.689668 | 1.11834644 |
4 | 30.693096 | 5.0325472 |
4 | 30.696343 | 4.5175537 |
4 | 30.699593 | 2.8767087 |
4 | 30.703645 | 4.631295 |
4 | 30.795686 | 2.7721686 |
4 | 30.809542 | 6.5642634 |
4 | 30.825847 | 3.1371149 |
4 | 30.842786 | 4.3904774 |
4 | 30.84874 | 6.3513859 |
4 | 30.860288 | 6.4784907 |
4 | 30.86037 | 2.8584966 |
4 | 30.869171 | 5.2307423 |
4 | 30.872055 | 4.0749112 |
4 | 30.87257 | 1.23464118 |
4 | 30.910788 | 5.2690191 |
4 | 30.928634 | 3.6359366 |
4 | 30.970335 | 3.8242789 |
4 | 31.036661 | 2.7005158 |
4 | 31.049342 | 3.7664064 |
4 | 31.060166 | 4.2008833 |
4 | 31.060814 | 4.9944114 |
4 | 31.068511 | 4.9511485 |
4 | 31.075475 | 3.162381 |
4 | 31.121069 | 4.024253 |
4 | 31.135204 | 4.2472877 |
4 | 31.137853 | 3.0020879 |
4 | 31.173174 | 4.1480361 |
4 | 31.186386 | 7.2251656 |
4 | 31.200991 | 2.1901514 |
4 | 31.208839 | 4.4279441 |
4 | 31.218948 | 3.7864309 |
4 | 31.221807 | 3.0719514 |
4 | 31.246152 | 5.4355796 |
4 | 31.262461 | 2.9578559 |
4 | 31.268682 | 3.628921 |
4 | 31.290465 | 3.2874838 |
4 | 31.293326 | 4.106079 |
4 | 31.301133 | 4.1777477 |
4 | 31.302882 | 3.2121843 |
4 | 31.307465 | 6.3794084 |
4 | 31.310338 | 3.0792017 |
4 | 31.377903 | 3.5628289 |
4 | 31.432628 | 3.2225798 |
4 | 31.439473 | 3.385765 |
4 | 31.467547 | 4.7781926 |
4 | 31.477121 | 3.6562905 |
4 | 31.501194 | 2.3480532 |
4 | 31.533824 | 4.9138983 |
4 | 31.54175 | 2.9172603 |
4 | 31.548589 | 4.4224972 |
4 | 31.551281 | 5.034822 |
4 | 31.580005 | 2.4249323 |
4 | 31.622936 | 2.6350977 |
4 | 31.635703 | 5.0811729 |
4 | 31.635766 | 0.6839693 |
4 | 31.636906 | 5.1485335 |
4 | 31.640693 | 5.0050765 |
4 | 31.644646 | 2.6398355 |
4 | 31.659895 | 3.7598802 |
4 | 31.6671 | 3.0851933 |
4 | 31.672122 | 1.82188274 |
4 | 31.790655 | 3.9990614 |
4 | 31.791466 | 3.9976649 |
4 | 31.823915 | 5.5021609 |
4 | 31.836958 | 2.770455 |
4 | 31.849023 | 5.0410794 |
4 | 31.875795 | 3.4999431 |
4 | 31.906133 | 5.8123412 |
4 | 31.929987 | 6.0171549 |
4 | 31.943218 | 4.5029935 |
4 | 31.944168 | 4.8880596 |
4 | 31.973628 | 5.3975676 |
4 | 31.977883 | 3.6668553 |
4 | 31.986891 | 3.3156703 |
4 | 31.990816 | 6.0919267 |
4 | 31.998018 | 5.5690895 |
4 | 32.002982 | 2.9423729 |
4 | 32.003167 | 3.1783848 |
4 | 32.02293 | 3.7394457 |
4 | 32.048313 | 5.7878447 |
4 | 32.04935 | 3.9196468 |
4 | 32.102964 | 6.9353623 |
4 | 32.104117 | 2.3553044 |
4 | 32.112408 | 4.44293 |
4 | 32.116913 | 5.7040627 |
4 | 32.117363 | 5.4379922 |
4 | 32.132975 | 4.7215931 |
4 | 32.148421 | 3.8419177 |
4 | 32.157023 | 3.3189264 |
4 | 32.209926 | 6.0647142 |
4 | 32.231745 | 4.1059839 |
4 | 32.243242 | 5.6659826 |
4 | 32.275244 | 3.4509242 |
4 | 32.283633 | 3.0655829 |
4 | 32.31873 | 3.5765372 |
4 | 32.360228 | 1.30690857 |
4 | 32.390107 | 5.4824678 |
4 | 32.391019 | 5.1110448 |
4 | 32.418397 | 3.6016607 |
4 | 32.438045 | 5.2962146 |
4 | 32.502628 | 2.9129491 |
4 | 32.530678 | 5.270917 |
4 | 32.531774 | 3.510775 |
4 | 32.535484 | 6.3496156 |
4 | 32.555906 | 2.8812822 |
4 | 32.574879 | 4.1483826 |
4 | 32.577047 | 6.5748674 |
4 | 32.698119 | 5.5684472 |
4 | 32.712666 | 2.8698348 |
4 | 32.754716 | 2.8842441 |
4 | 32.840546 | 5.1758951 |
4 | 32.875637 | 5.5823763 |
4 | 32.913839 | 4.7236013 |
4 | 32.921435 | 4.992112 |
4 | 32.95051 | 5.507263 |
4 | 32.968837 | 3.8102658 |
4 | 33.372123 | 5.1056244 |
4 | 33.570015 | 7.3520417 |
4 | 33.871862 | 2.2839561 |
5 | 14.776254 | 30.9332623 |
5 | 14.828535 | 32.754768 |
5 | 14.9985099 | 34.006255 |
5 | 15.0332013 | 34.171739 |
5 | 15.3495864 | 33.344629 |
5 | 15.3643301 | 32.307221 |
5 | 15.6308644 | 33.729308 |
5 | 15.6742915 | 33.422276 |
5 | 15.6765912 | 33.957163 |
5 | 15.7242125 | 33.603576 |
5 | 15.7309358 | 33.287858 |
5 | 15.8201135 | 32.317803 |
5 | 16.04405 | 33.326776 |
5 | 16.2843895 | 34.224467 |
5 | 16.3338087 | 35.315561 |
5 | 16.3864874 | 34.430293 |
5 | 16.391851 | 31.6688446 |
5 | 16.4134342 | 34.813134 |
5 | 16.4887595 | 33.338325 |
5 | 16.4927375 | 33.033762 |
5 | 16.5616717 | 34.041559 |
5 | 16.679285 | 33.295844 |
5 | 16.6980917 | 31.8332204 |
5 | 16.7248246 | 32.813209 |
5 | 16.738379 | 35.513935 |
5 | 16.7447018 | 35.612144 |
5 | 16.759245 | 35.425581 |
5 | 16.8174379 | 32.387096 |
5 | 16.8318274 | 35.132314 |
5 | 16.8411981 | 33.775724 |
5 | 16.8657639 | 30.18619 |
5 | 16.9045035 | 31.6292852 |
5 | 16.9060549 | 32.432955 |
5 | 16.9236652 | 31.5085818 |
5 | 16.9246185 | 33.501414 |
5 | 16.9371979 | 33.538343 |
5 | 16.9424162 | 32.669786 |
5 | 16.9436611 | 32.422198 |
5 | 16.954384 | 31.6210745 |
5 | 17.0048745 | 33.647301 |
5 | 17.0093275 | 33.155081 |
5 | 17.0495475 | 33.4833 |
5 | 17.0627556 | 33.23776 |
5 | 17.0848806 | 33.073719 |
5 | 17.0988263 | 33.650373 |
5 | 17.1219141 | 32.029351 |
5 | 17.1366616 | 34.971848 |
5 | 17.1485928 | 33.236786 |
5 | 17.1559942 | 31.9274005 |
5 | 17.1784265 | 31.6347077 |
5 | 17.2007163 | 35.458792 |
5 | 17.2067843 | 33.878027 |
5 | 17.2126233 | 32.627478 |
5 | 17.27771 | 33.301138 |
5 | 17.339495 | 37.147247 |
5 | 17.3421613 | 33.489292 |
5 | 17.3577314 | 32.460453 |
5 | 17.3724251 | 32.838472 |
5 | 17.3996649 | 30.71695 |
5 | 17.4002773 | 29.6913483 |
5 | 17.4324959 | 30.5923088 |
5 | 17.4391638 | 33.273311 |
5 | 17.474673 | 31.1187519 |
5 | 17.4783074 | 31.7469574 |
5 | 17.4828174 | 33.835584 |
5 | 17.5082782 | 32.96041 |
5 | 17.5131746 | 31.1271108 |
5 | 17.5226118 | 35.37399 |
5 | 17.5411115 | 33.970615 |
5 | 17.5478529 | 35.084663 |
5 | 17.5593776 | 33.467168 |
5 | 17.5604301 | 31.6251063 |
5 | 17.5621066 | 30.6151074 |
5 | 17.5639823 | 30.6570201 |
5 | 17.5727543 | 31.2284542 |
5 | 17.5999234 | 34.382793 |
5 | 17.6097383 | 31.6748319 |
5 | 17.6335421 | 32.659876 |
5 | 17.6346179 | 34.120215 |
5 | 17.6394592 | 29.6308142 |
5 | 17.6442026 | 34.402978 |
5 | 17.6624146 | 33.518399 |
5 | 17.6824201 | 34.045062 |
5 | 17.6933922 | 33.000639 |
5 | 17.6988315 | 33.716886 |
5 | 17.7180367 | 33.103054 |
5 | 17.7549039 | 31.4974324 |
5 | 17.7672336 | 33.161612 |
5 | 17.7675093 | 34.396513 |
5 | 17.7926923 | 33.684571 |
5 | 17.8061956 | 33.138528 |
5 | 17.8161585 | 32.744709 |
5 | 17.8442842 | 31.5564664 |
5 | 17.8517083 | 33.048076 |
5 | 17.8798602 | 33.078834 |
5 | 17.894805 | 32.364323 |
5 | 17.897217 | 31.2556095 |
5 | 17.9274089 | 32.295782 |
5 | 17.9540314 | 32.790538 |
5 | 17.9833606 | 32.01958 |
5 | 18.010122 | 31.2967178 |
5 | 18.011117 | 32.84965 |
5 | 18.02912 | 33.488563 |
5 | 18.036761 | 31.4478485 |
5 | 18.037256 | 33.574155 |
5 | 18.063049 | 33.151774 |
5 | 18.090068 | 33.56643 |
5 | 18.094963 | 33.018778 |
5 | 18.10096 | 30.8177448 |
5 | 18.122916 | 32.674656 |
5 | 18.129248 | 33.158393 |
5 | 18.13386 | 29.7555909 |
5 | 18.149812 | 31.2079389 |
5 | 18.152682 | 35.011784 |
5 | 18.176491 | 34.079545 |
5 | 18.178535 | 32.691873 |
5 | 18.183269 | 33.910638 |
5 | 18.215687 | 30.8817595 |
5 | 18.235729 | 30.7945041 |
5 | 18.259081 | 32.087312 |
5 | 18.264561 | 32.029223 |
5 | 18.274332 | 30.8333249 |
5 | 18.330272 | 31.7431158 |
5 | 18.368219 | 31.0200739 |
5 | 18.379084 | 34.194089 |
5 | 18.379872 | 33.124247 |
5 | 18.385792 | 33.179336 |
5 | 18.398364 | 34.606996 |
5 | 18.409342 | 32.693611 |
5 | 18.437678 | 32.926307 |
5 | 18.455588 | 34.845492 |
5 | 18.475238 | 33.791697 |
5 | 18.508271 | 31.4602961 |
5 | 18.527687 | 34.682064 |
5 | 18.536628 | 32.831121 |
5 | 18.542094 | 32.563114 |
5 | 18.545504 | 32.37607 |
5 | 18.547878 | 32.319933 |
5 | 18.553336 | 34.569272 |
5 | 18.557667 | 30.180909 |
5 | 18.582784 | 34.483361 |
5 | 18.590279 | 32.149325 |
5 | 18.634664 | 33.86855 |
5 | 18.639971 | 36.681327 |
5 | 18.643215 | 31.5278489 |
5 | 18.650616 | 33.021068 |
5 | 18.659338 | 34.160969 |
5 | 18.664585 | 32.421214 |
5 | 18.67864 | 28.6651535 |
5 | 18.706178 | 34.788597 |
5 | 18.743804 | 33.332319 |
5 | 18.754485 | 32.600224 |
5 | 18.776854 | 33.299507 |
5 | 18.788332 | 33.461131 |
5 | 18.797314 | 29.9900939 |
5 | 18.812277 | 31.7877808 |
5 | 18.818708 | 32.767132 |
5 | 18.825362 | 32.998126 |
5 | 18.827257 | 32.411798 |
5 | 18.855049 | 35.06313 |
5 | 18.895247 | 30.6882882 |
5 | 18.89677 | 33.241082 |
5 | 18.90694 | 31.3827126 |
5 | 18.931778 | 34.185287 |
5 | 18.935962 | 32.947167 |
5 | 18.936954 | 34.25114 |
5 | 18.958115 | 33.59757 |
5 | 19.026628 | 34.205066 |
5 | 19.037261 | 32.780271 |
5 | 19.061187 | 34.016911 |
5 | 19.097614 | 33.740769 |
5 | 19.099027 | 33.797805 |
5 | 19.1145 | 32.767203 |
5 | 19.131498 | 32.562132 |
5 | 19.170495 | 33.460691 |
5 | 19.188678 | 34.321407 |
5 | 19.191673 | 30.5556509 |
5 | 19.201821 | 33.442701 |
5 | 19.237079 | 30.6778069 |
5 | 19.25179 | 33.030541 |
5 | 19.270079 | 34.044006 |
5 | 19.333913 | 30.3620963 |
5 | 19.35918 | 32.033823 |
5 | 19.361986 | 32.354937 |
5 | 19.365055 | 34.033464 |
5 | 19.365386 | 31.7474302 |
5 | 19.367864 | 33.965754 |
5 | 19.432841 | 34.920374 |
5 | 19.455325 | 32.293297 |
5 | 19.457648 | 33.584263 |
5 | 19.482073 | 31.4698072 |
5 | 19.495794 | 30.2869317 |
5 | 19.520868 | 32.981305 |
5 | 19.601644 | 30.5475595 |
5 | 19.626402 | 32.237819 |
5 | 19.639048 | 32.63884 |
5 | 19.664319 | 33.12114 |
5 | 19.678355 | 33.234852 |
5 | 19.706041 | 34.347441 |
5 | 19.946172 | 33.768173 |
5 | 19.954228 | 32.480191 |
5 | 20.016013 | 35.799353 |
5 | 20.025227 | 33.322595 |
5 | 20.065571 | 34.06146 |
5 | 20.080158 | 32.622466 |
5 | 20.260129 | 32.286994 |
5 | 20.385613 | 34.526589 |
5 | 20.591116 | 35.438186 |
5 | 20.774989 | 34.963467 |
5 | 20.973478 | 33.539765 |
5 | 21.657494 | 30.7015363 |
Parag Kanade/fuzzy ants/Gauss4/gauss.c
#include "headerStatic.h" /*******************************************************************/ /*** Global Variables ***/ irisData data[MAXDATA]; //To hold the data read from the file int count=0; //Count of the total number of data elements int heapCount=0; // Total number of heaps int heapRow=0; // Rows for the second iteration with heaps int newHeapCount=0; // Count of the heaps for the second iteration heap heaps[MAXDATA]; // Data structure to hold the heap information heap newHeaps[MAXDATA]; // Data Structure to hold the new heap information // For the second iteration int board[MAXROWS][MAXCOLS]; // Board on which the objects are located ant ants[MAXANTS]; // Data structure to hold the ants float Dmax=0; // Distance of the most dissimilar object pair int minHeapCount=100000; // Counter to hold the minimum heap count, used only for academic purpose // no use in the algorithm int minPosition; // the minimum heap iteration , only for academic purpose // no use in the algorithm float clsCen[MAXDATA][MAXDATA][s];//to hold the objects after hardening int cenCount[MAXDATA];//to hold the number of objects after hardening /********************************************************************/ /*** Varaibles to normalize the features between 0 and 1 */ float minInput[features], maxInput[features],scale[features],minForHeaps[features],maxForHeaps[features],scaleForHeaps[features]; /********************************************************************/ /** Variables for the FCM algorithm */ int temp[200]; /* for square matrix tests */ float eps,m; matrix U, U1; BOOLEAN stop; center V; objects X; char fname[80]; FILE *fp; int run; float inv_cov[s+1][s+1]; /* inverse of covariance matrix Y */ float Y[s][s]; long rand_index, Random_seed; long state1[52] = { 9347, 3835, 5194, 8310, 346, 535, 5297, 6711, 77, 3834, 668, 4175, 6868, 5890, 9304, 8462, 5269, 920, 65392, 41600, 70119, 91032, 76220, 26245, 4746, 73608, 32823, 63264, 75641, 99104, 36534, 24704, 98255, 72266, 75336, 65152, 7269, 63163, 88471, 27271, 43641, 76649, 47773, 23777, 27491, 35926, 16651, 48652, 89766, 90921, 6056 }; int z; int mins=0; int aveit =0; float mintab[200]; int mincount[200]; long start,end,total; int lCount;//added by parag /********************************************************************/ /********************************************************************//*int lrand48(){return(rand());}void srand48(int a){return;}*//********************************************************************/ /********************************************************************/ /* Function to read the input data set */ /* The file name is assumed to be itest.data */ /* Status: Tested */ /* Output: Data from the file into the "data" (Global) data structure */ /* Output: Count (Global), the count of the number of objects */ /********************************************************************/ void readInput() { FILE *fp; char fname[80]; int i=0,j=0; char ch; sprintf(fname,"%s.data",filename); /* Check if the input file is opened */ if((fp=fopen(fname,"r"))==NULL) { printf("\n Unable to open input file \n"); exit(0); } /*initialise the minimum maximum and the scale */ for(i=0;i<features;i++) { minInput[i]=1000; maxInput[i]=0; minForHeaps[i]=1000; maxForHeaps[i]=0; scale[i]=0; scaleForHeaps[i]=0; } /* Discard leading comments */ ch = 'c'; while (ch != '#') fscanf (fp, "%c", &ch); i=0; /* Parse the file and populate the data structure */ while(!feof(fp)) { for(j=0;j<features;j++) { fscanf(fp,"%f ",&data[i][j]); } fscanf(fp,"\n"); for(j=0;j<features;j++) { if(data[i][j]<minInput[j]) minInput[j]=data[i][j]; if(data[i][j]>maxInput[j]) maxInput[j]=data[i][j]; } i++; } count=i; /* Normailze the feature values in between 0 and 1 */ for(j=0;j<features;j++) { if(minInput[j]!=maxInput[j]) scale[j]=1.0/(maxInput[j]-minInput[j]); else scale[j]=1.0; } for(i=0;i<count;i++) { for(j=0;j<features;j++) data[i][j]=(data[i][j]-minInput[j])*scale[j]; } fclose(fp); return; }//end of function /********************************************************************/ /*Function to compute the eucldiean distance for all input data set */ /* Output : an array conatining the distance of each object with the other */ /********************************************************************/ float computeDistance() { float distance,dist=0; int i=0,j=0,k=0; distance=0; for(j=0;j<count;j++) for(i=0;i<count;i++) { for(k=0;k<features;k++) dist+=sqrt((data[j][k]-data[i][k])*(data[j][k]-data[i][k])); if(distance<dist)distance=dist; dist=0; } return(distance); } /********************************************************************/ /* Function to compute the distance between two objects */ /* Output : Euclidean d istance between the two input objects */ /********************************************************************/ float computeDistanceBetween2(irisData a,irisData b) { float temp=0; int i=0; for(i=0;i<features;i++) temp+=(a[i]-b[i])*(a[i]-b[i]); temp=sqrt(temp); return(temp); } /********************************************************************/ /* Function to find the maximum distance between the input objects*/ /* Output: the maximum distance */ /* Input : The array of distances between objects */ /********************************************************************/ /*float findMax(float *distance) { int i=0,j=0; float max=distance[0]; for(i=0;i<count;i++) for(j=0;j<count;j++) { if(max<distance[i*count+j]) max=distance[i*count+j]; } return(max); }*/ /********************************************************************/ /* Function to compute the value of an object */ /********************************************************************/ float value(irisData a) { int i=0; float temp=0; for(i=0;i<features;i++) temp+=a[i]*a[i]; return(sqrt(temp)); } /********************************************************************/ /* Function to find the object in the data structure */ /* Output : The position of the object in the data */ /* Input : The object */ /********************************************************************/ int findInData(irisData object,int iFlag) { int i=0,lastCount=0,j,position=-1,flag[features],flg;if(iFlag==1)lastCount=MAXDATA;else{}for(i=0;i<lastCount;i++){ for(j=0;j<features;j++) if(fabs(object[j]-data[i][j])<0.00001) flag[j]=1; else { flag[j]=0; break;} flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /* Function to find whether there is an object on the board at a,b */ /* Output : a flag indicating whether an object is found or not */ /* Input : The row and column indicating the board position */ /********************************************************************/ int found(int a , int b) { if(board[a][b]==9) return 1; else return 0; } /********************************************************************/ /* Function to initialize the initial board */ /* Output : None */ /* Global Structures modified : heaps */ /* Input : Flag indicating the iteration 1: First 0: Second */ /********************************************************************/ void initialise(int flag) { int a,b,i=0,k=0; int loopCount,rowCount,colCount; /* Initialize the row, column and number of heaps */ if(flag==1) { loopCount=count; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=lCount; rowCount=heapRow; colCount=heapRow; } /* Initialize the heaps */ for(i=0;i<loopCount;i++) { heaps[i].count=0; heaps[i].x=0; heaps[i].y=0; heaps[i].disPosition=0; heaps[i].Dmax=0; heaps[i].Dmean=0; } for(i=0;i<loopCount;i++) { /*find a board position which is empty*/ do { a=lrand48()%rowCount; b=lrand48()%colCount; } while(found(a,b)); /*Allocate the object to that place and assign a heap to it*/ heaps[i].x=a; heaps[i].y=b; heaps[i].count=1; heaps[i].Dmax=0; heaps[i].Dmean=0; if(flag==1) { heaps[i].objects[0]=i; for(k=0;k<features;k++)heaps[i].Ocenter[k]=data[i][k]; } else { for(k=0;k<features;k++) heaps[i].Ocenter[k]=newHeaps[i].Ocenter[k]; } heaps[i].disPosition=0; board[a][b]=9; if((debugLevel>0)&&(flag==1))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],data[heaps[i].objects[0]][0]); if((debugLevel>0)&&(flag==0))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],newHeaps[i].Ocenter[0]); } /*initialise the initial heap count*/ heapCount=loopCount; currentRow=rowCount; } /********************************************************************/ /* Function to find whether an heap is present at the location a b */ /* Output : Flag indicating the presencs of the heap */ /* Input : Roe and column indicating the board position */ /********************************************************************/ int findObject(int a,int b) { int i; int position=-1; for(i=0;i<heapCount;i++) { if((heaps[i].x==a)&&(heaps[i].y==b)) { position=i; break; } } return(position); } /********************************************************************/ /* Function initialize the ants */ /* Output : None */ /* Input : Flag indicating the iteration */ /* Global Variables Modified : ant, heapCount, heaps, board */ /********************************************************************/ void initialiseAnts(int flag) { int i=0,a=0,b=0,position,j=0,loopCount=0,rowCount,colCount,k=0; if(flag==1) { loopCount=MAXANTS; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=MAXANTSFORHEAPS; rowCount=heapRow; colCount=heapRow; } for(i=0;i<loopCount;i++) { /*generate random positions for the ants*/ a=lrand48()%rowCount; b=lrand48()%colCount; ants[i].x=a; ants[i].y=b; /*Find if an object is present at that position or not*/ if(board[a][b]==9) { ants[i].carrying=1; /*find the heap at that location*/ position=findObject(a,b); if(position==-1) { printf("\n Error in logic: Ant init \n"); //getchar(); break; } else { /*Assign the heap data to the ant data and decrement the heap count*/ if(flag==1){ for(k=0;k<features;k++)ants[i].data[k]=data[heaps[position].objects[0]][k]; }else{for(k=0;k<features;k++)ants[i].data[k]=heaps[position].Ocenter[k];} for(j=position;j<heapCount-1;j++) heaps[j]=heaps[j+1]; heapCount--; } /*Clear the board position */ board[a][b]=-9; } else ants[i].carrying=-1; ants[i].speed=0; ants[i].dir=lrand48()%8; printf("\n Ant %2d X: %2d Y: %2d Carying : %2d ",i,ants[i].x,ants[i].y,ants[i].carrying); } currentAntCount=loopCount; } /********************************************************************/ /* Function to move the ant */ /* Output: None */ /* Input: Ant to be moved and the flag indicating the iteration */ /********************************************************************/ void moveNext(ant* a,int flag) { int rowCount,colCount; /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; } else { rowCount=heapRow; colCount=heapRow; }*/rowCount=currentRow;colCount=currentRow; /*Depending upon the direction move the ant*/ switch (a->dir) { case 0: a->y++; if(a->y>=colCount)a->y=0; break; case 1: a->x--; a->y++;; if(a->x<0)a->x=rowCount-1; if(a->y>=colCount)a->y=0; break; case 2: a->x--; if(a->x<0)a->x=rowCount-1; break; case 3: a->x--; a->y--; if(a->x<0)a->x=rowCount-1; if(a->y<0)a->y=colCount-1; break; case 4: a->y--; if(a->y<0)a->y=colCount-1; break; case 5: a->x++; a->y--; if(a->x>=rowCount)a->x=0; if(a->y<0)a->y=colCount-1; break; case 6: a->x++; if(a->x>=rowCount) a->x=0; break; case 7: a->x++; a->y++; if(a->x>=rowCount)a->x=0; if(a->y>=colCount)a->y=0; break; } }//end of function /********************************************************************/ /* Function to compute the parameters of the heap */ /* Output: None */ /* Input: The heap whose parameters are to be computed iteration flag*/ /********************************************************************/ void computeHeapParameters(heap* heapData,int flag) { int i=0,j=0,k=0,position=0; float distance=0; float Dmean=0.0; float *dis; float featureSum[features]; float max=0; float sum=0; /* init*/ for(k=0;k<features;k++) featureSum[k]=0; /*Compute the distance of each object and find the maximum distance*/ max=0; if(flag==1){ for(j=0;j<heapData->count;j++) for(i=0;i<heapData->count;i++) { for(k=0;k<features;k++) sum+= (data[heapData->objects[j]][k]-data[heapData->objects[i]][k])*(data[heapData->objects[j]][k]-data[heapData->objects[i]][k]); distance=sqrt(sum); if(max<distance) max=distance; sum=0; } /* Assign the maximum distance to the heap */ heapData->Dmax=max;/*Compute the centre object*/for(i=0;i<heapData->count;i++)for(k=0;k<features;k++) featureSum[k]+=data[heapData->objects[i]][k];for(k=0;k<features;k++)heapData->Ocenter[k]=featureSum[k]*1.0/heapData->count; /* Find the mean distance */if((dis=(float *) calloc(heapData->count,sizeof(float)))==NULL){printf("\nUnable to allocate memory in the compute heap parameters procedure\n");exit(0);} for(i=0;i<heapData->count;i++) { Dmean+=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); dis[i]=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); } heapData->Dmean=Dmean*1.0/heapData->count; /*Compute the most dissimilar object*/ max=dis[0]; for(i=1;i<heapData->count;i++) if(max<dis[i]) { max=dis[i]; position=i; } /*Assign the most dissimilar object to the heap variable*/ for(k=0;k<features;k++) heapData->Odissim[k]=data[heapData->objects[position]][k]; heapData->disPosition=position;free(dis); } else{/* Heap Parameters for the second stage */for(k=0;k<features;k++){ heapData->Odissim[k]=heapData->Ocenter[k];}heapData->disPosition=0;heapData->Dmean=0;heapData->Dmax=0;} }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a single object*/ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject1(ant *a,int position,int flag) { int i,k=0; /*Clear the board*/ board[heaps[position].x][heaps[position].y]=-9; /* Assign the data to the ant*/if(flag==1){ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[0]][k];}else {for(k=0;k<features;k++) a->data[k]=heaps[position].Ocenter[k];} a->carrying=1; /*Copy all the heaps remaining heaps in the structure*/ for(i=position;i<heapCount-1;i++) heaps[i]=heaps[i+1]; /*Decrement the heap count*/ heapCount--; }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a two objects */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject2(ant *a , int position,int flag) { float Pdestroy1=-1; int i=0,k=0; /*Compute the probability to destroy the heap*/ Pdestroy1=lrand48()%13*1.0/12.0; /*If the probability is more than Pdestroy then destroy the heap */ if(Pdestroy1<Pdestroy) { /*pick the object randomly*/ i=lrand48()%2; /* Assign the data to the ant */ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[i]][k]; a->carrying=1; /*Correct the heap parameters*/ heaps[position].count=1; heaps[position].objects[0]=heaps[position].objects[1-i]; computeHeapParameters(&heaps[position],flag); } }//end of function /********************************************************************/ /*Function to pick a object from a heap consisting of more than two object */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /********************************************************************/ void pickObjectn(ant *a,int position,int flag) { int i=0,k=0; /*If the criteria is satsfied then pick the object*/ if((computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)*1.0/heaps[position].Dmean)>Tremove) { a->carrying=1; for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[heaps[position].disPosition]][k]; for(i=heaps[position].disPosition;i<heaps[position].count-1;i++) heaps[position].objects[i]=heaps[position].objects[i+1]; heaps[position].count--; computeHeapParameters(&heaps[position],1); } }//end of function /********************************************************************/ /* Function to pick a object */ /********************************************************************/ void pick(ant *a,int flag) { int position=-1,i=0; float Pload1=-1.0; for(i=0;i<heapCount;i++) { /*Check if a heap is present in the eight neighbouring cells*/ if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if Heap is found*/ if(position!=-1) { /* heap or object found.*/ /*Depending upon the number present in the heap call the corresponding routine*/ switch(heaps[i].count) { case 1: Pload1 = lrand48()%151*1.0/150.0; if(Pload1<Pload) { pickObject1(a,position,flag); } break; case 2: pickObject2(a,position,flag); break; default: pickObjectn(a,position,flag); break; } } } /********************************************************************/ /* Function to drop a object to form a new heap */ /* Output: None */ /* Input: Ant, iteration flag */ /* Global Structure modified : heap, heapCount */ /********************************************************************/ void dropObject(ant* a,int flag) { /*Create a new heap*/ int k=0; heaps[heapCount].count=1; heaps[heapCount].x=a->x; heaps[heapCount].y=a->y; heaps[heapCount].Dmax=0; heaps[heapCount].Dmean=0; heaps[heapCount].disPosition=0; for(k=0;k<features;k++) { heaps[heapCount].Odissim[k]=a->data[k]; heaps[heapCount].Ocenter[k]=a->data[k]; } if(flag==1) {heaps[heapCount].objects[0]=findInData(a->data,flag); /*computeHeapParameters(&heaps[heapCount],flag);*/ } computeHeapParameters(&heaps[heapCount],flag); heapCount++; a->carrying=-1; board[a->x][a->y]=9; }//end of function /********************************************************************/ /* Function to find the heap position during the second iteration */ /* Output: position of the heap */ /* Input: object center of the heap that the ant is carrying */ /* Global Structure modified : none */ /********************************************************************/ int findInNewheaps(irisData object) { int position=-1,i,j=0,flag[features],flg; for(i=0;i<newHeapCount;i++) { for(j=0;j<features;j++) { if(fabs(object[j]-newHeaps[i].Ocenter[j])<0.00001) flag[j]=1; else {flag[j]=0;break;} } flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /*Function to drop a object to a heap consisting of a one or more object */ /* Output: none */ /* Input: Ant, position of the heap , iteration flag */ /* Global Structure modified: heaps,newHeaps */ /********************************************************************/ void dropObject1(ant* a, int position,int flag) { int heapPosition=-1,heapPosition1=-1,i,j,k=0; irisData newData,temp; if(flag==1) { /*Add the object to the heap and compute the heap parameters*/ /*if(heaps[position].count==heaps[position].objCount) {if((junk=(int *)realloc(heaps[position].objects,((heaps[position].objCount+OBJINC)*sizeof(int))))==NULL){printf("\n Cannot Allocate memory to the new object for %d heap",position);exit(0);}heaps[position].objects=junk;heaps[position].objCount+=OBJINC;free(junk); }*/ heaps[position].objects[heaps[position].count]=findInData(a->data,flag); heaps[position].count++; computeHeapParameters(&heaps[position],flag); } else { for(k=0;k<features;k++)temp[k]=heaps[position].Ocenter[k]; heapPosition=findInNewheaps(a->data); heapPosition1=findInNewheaps(heaps[position].Ocenter); if(heapPosition==-1||heapPosition1==-1) { printf("\n error in logic:new heaps\n"); //getchar(); return; } for(k=0;k<features;k++) {newData[k]=(newHeaps[heapPosition].Ocenter[k]*newHeaps[heapPosition].count+newHeaps[heapPosition1].Ocenter[k]*newHeaps[heapPosition1].count)*1.0/(newHeaps[heapPosition].count+newHeaps[heapPosition1].count);newHeaps[heapPosition].Ocenter[k]=newData[k];heaps[position].Ocenter[k]=newData[k]; } computeHeapParameters(&heaps[position],flag); for(i=newHeaps[heapPosition].count,j=0;j<newHeaps[heapPosition1].count;i++,j++) { newHeaps[heapPosition].objects[i]=newHeaps[heapPosition1].objects[j]; } newHeaps[heapPosition].count+=newHeaps[heapPosition1].count; for(i=heapPosition1;i<newHeapCount-1;i++) newHeaps[i]=newHeaps[i+1]; newHeapCount--; } a->carrying=-1; }//end of function /********************************************************************/ /* Function to drop a object */ /* Output: None */ /* Input: Ant, iteration flag */ /********************************************************************/ void drop(ant* a,int flag) { int i, position=-1; float Pdrop1=0.0; /*Find whether we have a heap in the neighbourhood of the cell*/ for(i=0;i<heapCount;i++) { if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if a heap is found*/ if(position!=-1) { /*heap or object found.*/ /*Depending on the number of objects present take action*/ switch(heaps[position].count) { /*If criteria is satisfied then drop the object*/ case 1: if(flag==1) { if((computeDistanceBetween2(a->data,data[heaps[position].objects[0]])*1.0/Dmax)<Tcreate) dropObject1(a,position,flag); } else { if((computeDistanceBetween2(a->data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) dropObject1(a,position,flag); } break; default: if(computeDistanceBetween2(a->data,heaps[position].Ocenter)<computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)) dropObject1(a,position,flag); break; } } else { /*Compute the probability to drop the object*/ Pdrop1 = lrand48()%151*1.0/150; if(Pdrop1<Pdrop) dropObject(a,flag); } }//end of function /********************************************************************/ /* Function to move the ant */ /* Output: none */ /* Input: Ant, iteration flag */ /********************************************************************/ void move(ant* a,int flag) { float pDir; /*Check the speed */ if (a->speed!=0) { /*move in the same direction*/ a->speed--; moveNext(a,flag); } else { /*generate the new direction*/ pDir=lrand48()%17*1.0/16.0; if(pDir<.85) { a->dir=lrand48()%8; } else if(pDir>.95) { a->speed=2; } moveNext(a,flag); } } /********************************************************************/ /* Function to simulate the movement of the ants */ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified: minHeapCount, minHeapPosition */ /********************************************************************/ void iterate(int flag) { int i=0,j=0,k=0,loopCount=0; if (flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS; while (i<MAXITERATIONS) { i++; for(j=0;j<loopCount;j++) { move(&ants[j],flag); if(ants[j].carrying==1) { drop(&ants[j],flag); } else { pick(&ants[j],flag); } } if(debugLevel>0){ for(k=0;k<heapCount;k++) for(j=0;j<heapCount;j++) if((k!=j)&&(heaps[k].x==heaps[j].x)&&(heaps[k].y==heaps[j].y)) { printf("\nerror two heaps with same co ordinates %d %d ",k,j); //getchar(); } k=0; for(j=0;j<heapCount;j++) k+=heaps[j].count; } if(heapCount<minHeapCount) { minHeapCount=heapCount; minPosition=i; } if(debugLevel>0) printf("\n i:%d Heap count %d sum %d",i,heapCount,k); else printf("\n i:%d Heap count %d",i,heapCount); heapSum+=heapCount; /*if(i%updateAfter==0) {adjustBoard(flag); writeIncremental(i,flag);heapSum=0;loopCount=currentAntCount; }*/ } }//end of function /********************************************************************/ /*Function to drop the objects carried by the ants after all the iterations*/ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified:none */ /********************************************************************/ void dropFinal(int flag) { int i=0,j=0,position=-1,loopCount=0; /*if(flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS;*/ loopCount=currentAntCount; for(i=0;i<loopCount;i++) { if(ants[i].carrying==1) { if(flag==1) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position,flag); } } else { /*Find if a heap is present */ do { position=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position,flag); position=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position!=-1); } } } }//end of function /********************************************************************/ /* Function for the implementation of QuickSort */ /* Output: none */ /* Input: data structure, low and high indices */ /* Global structure modified:none */ /********************************************************************/ void quickSort( heap A[], int low,int high ) { int mid=0; if(low<high) { mid=partition(A,low,high); quickSort(A,low,mid); quickSort(A,mid+1,high); } } /********************************************************************/ /* Partition routine used by quick sort */ /* Output: partition location */ /* Input: data , low, high */ /* Global structure modified:none */ /********************************************************************/ int partition(heap a[], int low,int high) { heap temp; int x=0,i=0,j=0; i=low; j=high; x=a[low].count; while (1) { while (a[j].count<x) j=j-1; while (a[i].count>x) i=i+1; if(i<j) { temp=a[i]; a[i]=a[j]; a[j--]=temp; } else return(j); } } /********************************************************************/ /* Function used to write the cluster information */ /* Output: none */ /* Input:iteration flag */ /* Global structure modified:none */ /********************************************************************/ void writeClusterInformation(int flag) { FILE *fp=fopen("center.clt","w"); FILE *fp1; FILE *fp2; FILE *fp3; char temp[80]; int i=0,j=0,k=0; int lastCount=0; int rowCount,colCount,antCount; strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp3=fopen(temp,"a"); if(dataDump) {strcpy(temp,"");sprintf(temp,"%sTot.out",filename);fp1=fopen(temp,"a");strcpy(temp,"");sprintf(temp,"%sObj.out",filename);fp2=fopen(temp,"a");if(fp1==NULL||fp2==NULL)printf("\n Error in opening file in the writer Cluster Information routine\n"); } /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; antCount=MAXANTS; } else { rowCount=heapRow; colCount=heapRow; antCount=MAXANTSFORHEAPS; }*/ rowCount=currentRow; colCount=currentRow; antCount=currentAntCount; if(fp==NULL) { printf("\n Unable to open cluster center output file \n"); /*return;*/ exit(0); } /*sort the array according to the count value and write the value of the top three elements*/ if((flag==1)&&(!EntireHeaps)) quickSort(heaps,0,heapCount); if(EntireHeaps) {if(flag==1) lastCount=heapCount;else lastCount=newHeapCount; } else lastCount=c; for(i=0;i<lastCount;i++) { if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",newHeaps[i].Ocenter[k]); fprintf(fp,"\n"); } else { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); fprintf(fp,"\n"); } } if(dataDump) { fprintf(fp1,"\n Information from the Ant Based Algorithm \n"); fprintf(fp1,"\n Important Parameters : Board %d X %d Ants : %d Iterations %d Total Heaps %d ",rowCount,colCount,antCount,MAXITERATIONS,lastCount); } if(flag==0) { if(dataDump) { fprintf(fp1," TCreateForHeaps %f \n",TcreateForHeaps); fprintf(fp2,"\nTotal Heaps : %d\n",heapCount); fprintf(fp2,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); } fprintf(fp3,"\n@ %d\n",lastCount); } else if(dataDump) fprintf(fp1,"\n");if(dataDump) { fprintf(fp1,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); for(i=0;i<lastCount;i++) if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp2,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); } fprintf(fp1," %5d\n",newHeaps[i].count); fprintf(fp2," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp1," %5d\n",heaps[i].count); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]); fprintf(fp1," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]); fprintf(fp1," %5d\n",heaps[i].count); }} if(flag==0) { if(dataDump) fprintf(fp1,"\n Objects in the heaps \n");for(i=0;i<newHeapCount;i++) { if(dataDump) fprintf(fp1,"\n\n Heap %d\n \n",i+1);fprintf(fp3,"# %d %d\n",i ,newHeaps[i].count); for(j=0;j<newHeaps[i].count;j++){ for(k=0;k<features;k++){ fprintf(fp3,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]); if(dataDump) fprintf(fp1,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]);} if(dataDump) fprintf(fp1,"\n"); fprintf(fp3,"\n"); } } } fclose(fp); fclose(fp3); if(dataDump) { fclose(fp1);fclose(fp2); }}//end of flie /********************************************************************/ /* Function to initialise the new heaps */ /* Output: none */ /* Input:new Heap structure */ /* Global structure modified:none */ /********************************************************************/ void initialiseNewHeaps(heap newHeaps[]) { int i=0,j=0; for(i=0;i<lCount;i++) { newHeaps[i].count=0; for(j=0;j<features;j++) newHeaps[i].Ocenter[j]=V[i][j]; newHeaps[i].x=heaps[i].x; newHeaps[i].y=heaps[i].y; } }//end of function /********************************************************************/ /* Function to initialise the new heaps */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ int findPosition(int i) { int j,position=0; for(j=1;j<lCount;j++) { if(U[j][i]>U[position][i]) position=j; } printf("\n Position %d ",position); return(position); }//end of function find position /********************************************************************/ /* Function to add object */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ void addObject(int object,heap * heapPosition) { heapPosition->objects[heapPosition->count]=object; heapPosition->count++; }//end of function add object /********************************************************************/ /* Function to harden the outputs obtained from fcm */ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/ void harden(heap newHeaps[]) { int i,heapPosition=-1,sum=0,j=0; /*initialise the new heaps*/ initialiseNewHeaps(newHeaps); for(i=0;i<count;i++) { heapPosition=findPosition(i); addObject(i,&newHeaps[heapPosition]); } /* To check for degenerate partitions*/ for(i=0;i<lCount;i++) { if(newHeaps[i].count==0){for(j=i;j<lCount-1;j++){newHeaps[j]=newHeaps[j+1];}lCount--;i--;} } newHeapCount=lCount; for(i=0;i<lCount;i++) computeHeapParameters(&newHeaps[i],1); if(debugLevel>0) { for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\n sum = %d",sum);} }//end of function/********************************************************************/ /* Function to initialize the initial parameters for the ant algorithm*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void init() { int i=0,j=0; for(i=0;i<MAXROWS;i++) for(j=0;j<MAXCOLS;j++) board[i][j]=-9; heapCount=0; newHeapCount=0; heapRow=0; minPosition=-1; minHeapCount=100000; for(i=0;i<MAXANTS;i++) { ants[i].carrying=-1; ants[i].x=-1; ants[i].y=-1; ants[i].speed=-1; ants[i].dir=-1; } } /********************************************************************/ /* Function to initialize the initial board */ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void initialiseBoard() { int i,j; for(i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; }/********************************************************************/ /* Function to harden the outputs obtained from fcm(2nd stage)*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: Cluster center , cluster center count*/ /********************************************************************/void harden1() { int i=0,heapPosition=-1; for(i=0;i<heapCount;i++) cenCount[i]=0; for(i=0;i<n;i++) { heapPosition=findPosition1(i); addObject1(i,heapPosition); } writeInfo(); }//end of function/********************************************************************/ /* Function to find to which class the object belongs */ /* Output: Class number */ /* Input: object position */ /* Global Structure Modified: None */ /********************************************************************/int findPosition1(int i) { int j,position=0; for(j=1;j<heapCount;j++) { if(U[j][i]>U[position][i]) position=j; } return(position); }//end of function find position/********************************************************************/ /* Function to Write the output of the hardened objects to file*/ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/void writeInfo(){int i=0,j=0,k=0;FILE *fp=fopen("fcm.out","a");if(fp==NULL){printf("\n Unable to open fcm output file \n");return;}fprintf(fp,"\n@ %d\n",heapCount);for(i=0;i<heapCount;i++){fprintf(fp,"# %d %d\n",i,cenCount[i]);for(j=0;j<cenCount[i];j++){for(k=0;k<s;k++)fprintf(fp,"%8.2f ",clsCen[i][j][k]/scale[k]+minInput[k]);fprintf(fp,"\n");}}fclose(fp);return;}/********************************************************************/ /* Function to add a object to a cluster (2nd stage) */ /* Output: none */ /* Input: object poistion , cluster position */ /* Global Structure Modified: Cluster object and cluster count*/ /*******************************************************************/void addObject1(int object,int heapPosition) { int k=0; for(k=0;k<features;k++) clsCen[heapPosition][cenCount[heapPosition]][k]=X[object][k]; cenCount[heapPosition]++; return; }//end of function add object/********************************************************************/ /* Function to read the original classification of objects */ /* Output: none */ /* Input: none */ /* Global Structure Modified: None */ /*******************************************************************/void readOrg(){int i=0,k=0;char temp[80];FILE *fp;//= fopen(dataname,"r");strcpy(temp,"");sprintf(temp,"%sFull.data",filename);fp=fopen(temp,"r");if(fp==NULL){printf("\n Unable to open full data input file ");exit(0);}for(i=0;i<n;i++){fscanf(fp,"%f ",&orgData[i][0]);for(k=1;k<s+1;k++)fscanf(fp,"%f ",&orgData[i][k]);}return;}// end of function/********************************************************************/ /* Function to classify the objects in different clusters */ /* Output: none */ /* Input: the cluster objects, the original classification, */ /* number of objects in the cluster,file to write the data */ /* Global Structure Modified: None *//********************************************************************/int analysisData(float data[][s],float orgData[n][s+1],int count,FILE * fp){int i=0,j=0,k=0,type=1,max=0;heapInfo info;for(i=0;i<c;i++){info.classObj[i]=0;}info.total=0;info.total=count;for(i=0;i<count;i++)for(j=0;j<n;j++){type=1;for(k=0;k<s;k++)if(fabs(data[i][k]-orgData[j][k+1])>errThresh){type=-1;break;}if(type!=-1){info.classObj[(int)orgData[j][0]-1]++;break;}}max=0;for(k=0;k<c;k++){if(info.classObj[k]>info.classObj[max])max=k;fprintf(fp,"\nClass %d Objects % d ",k+1,info.classObj[k]);}j=0;for(k=0;k<c;k++){if(k!=max)j+=info.classObj[k];}fprintf(fp,"\n Total errors : %d \n",j);return(j);}//end of analyse/********************************************************************/ /* Function to read the cluster information */ /* Output: none */ /* Input: input file pointer , output file pointer */ /* Global Structure Modified: None *//********************************************************************/void readFCM(FILE* fp,FILE *fp1){int i=0,j=0,k=0,l=0;int totalRuns=0,heapCount=0,junk=0,sum=0;char ch;FILE *fp2=fopen("errors.out","a");ch = 'c'; while (ch != '$') fscanf (fp, "%c", &ch);fscanf(fp,"%d\n",&totalRuns);printf("\n total runs %d ",totalRuns);for(l=0;l<totalRuns;l++){fscanf(fp,"%c",&ch);fscanf(fp,"%d\n",&heapCount);fprintf(fp1,"\n \nExperiment %d \n ",l+1);sum=0;for(i=0;i<heapCount;i++){fscanf(fp,"%c",&ch);fscanf(fp," %d %d\n",&junk,&clsCenCount[i]);for(j=0;j<clsCenCount[i];j++)for(k=0;k<s;k++)fscanf(fp,"%f",&fcmData[i][j][k]);fscanf(fp,"\n");fprintf(fp1,"\n\n Heap %d Total Objects %d \n",i+1,clsCenCount[i]);sum+=analysisData(fcmData[i],orgData,clsCenCount[i],fp1);}fprintf(fp2," %3d %3d %3d \n",l,sum,heapCount);}fprintf(fp2,"\n --------------------------\n");fclose(fp2);return;}//end of function/********************************************************************/ /* Function to update the board parameters */ /* Output: none */ /* Input: none */ /* Global Structure Modified: board size, ant count *//********************************************************************/void adjustBoard(int flag){int newRow=0,newAnt=0,antDiff=0,antsKilled=0,i=0,position[MAXANTS],position1=-1,j=0,k=0,a,b; newRow= (int)ceil(sqrt(4.0*heapSum/updateAfter)); newAnt= (int)ceil((heapSum*1.0/updateAfter)*1.0/3.0); if(newAnt<minAnts)newAnt=minAnts; if(newRow<rowMin)newRow=rowMin;antDiff=currentAntCount-newAnt; if((antDiff>0)&&(newAnt>=minAnts)) {for(i=0;i<currentAntCount;i++){if(ants[i].carrying==-1){position[antsKilled++]=i;}} if(antsKilled>=antDiff){for(i=0;i<antDiff;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1];for(k=i+1;k<antsKilled;k++)position[k]--; } currentAntCount=newAnt; }else {for(i=0;i<antsKilled;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1]; for(k=i+1;k<antsKilled;k++)position[k]--; }if(flag==1) { for(i=currentAntCount-1,k=0;k<antDiff-antsKilled;k++,i--) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position1,flag); }else { dropObject(&ants[i],flag); } } } else { //flag is zero 2nd stage /*Find if a heap is present */ do { position1=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position1].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position1,flag); position1=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position1!=-1); }//end else currentAntCount=newAnt;}//end elsecurrentAntCount=newAnt;}//end iffor(i=0;i<newAnt;i++){if((ants[i].x>=newRow)||(ants[i].y>=newRow)) { a=lrand48()%newRow; b=lrand48()%newRow; ants[i].x=a; ants[i].y=b; }} //Done with ants, now adjust the boardif((currentRow>newRow)&&(newRow>=rowMin)){for(i=0;i<heapCount;i++){if((heaps[i].x>=newRow)||(heaps[i].y>=newRow)) {do { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionheaps[i].x=a;heaps[i].y=b;board[a][b]=9;}//end if}//end for for(i=0;i<currentAntCount;i++){if((ants[i].carrying==1)&&((ants[i].x>=newRow)||(ants[i].y>=newRow))){//adjust the ant locationdo { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionants[i].x=a;ants[i].y=b;}//end if}//end for currentRow=newRow;}//end if }//end of function void writeIncremental(int iteration,int flag){FILE *fp=fopen("dump.txt","w");int i=0,j=0,k=0;fprintf(fp,"Stage %d\n",flag);fprintf(fp,"Board %d\n",currentRow);fprintf(fp,"Ants %d\n",currentAntCount);fprintf(fp,"Iteration %d\n",iteration);fprintf(fp,"Heaps %d\n",heapCount); if(flag==0)fprintf(fp,"NewHeapCount %d\n",newHeapCount); fprintf(fp,"Ants\n");for(i=0;i<currentAntCount;i++){fprintf(fp,"%d %d %d %d %d ",ants[i].x,ants[i].y,ants[i].carrying,ants[i].speed,ants[i].dir);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",ants[i].data[k]);fprintf(fp,"\n");}fprintf(fp,"Heaps\n");for(i=0;i<heapCount;i++){fprintf(fp,"%d %d %d %d %8.2f %8.2f \n",heaps[i].x,heaps[i].y,heaps[i].count,heaps[i].disPosition,heaps[i].Dmax,heaps[i].Dmean);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Ocenter[k]);fprintf(fp,"\n");for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Odissim[k]);fprintf(fp,"\n");if(flag==1){for(j=0;j<heaps[i].count;j++)fprintf(fp,"%d ",heaps[i].objects[j]);fprintf(fp,"\n");}}if(flag==0){fprintf(fp,"newHeaps\n");for(i=0;i<newHeapCount;i++){fprintf(fp,"%d\n",newHeaps[i].count);for(j=0;j<newHeaps[i].count;j++)fprintf(fp,"%d ",newHeaps[i].objects[j]);fprintf(fp,"\n");}}fclose(fp);}//end of function/********************************************************************/ /* Function Main */ /********************************************************************/ int main(int argc ,char** argv) { int sum=0,k=0,i=0,j=0; char temp[80]; FILE *fp=fopen("fcm.out","w"); FILE *fp1; FILE *fp2=fopen("antAnalysis.out","a"); FILE *fp3=fopen("fcmAnalysis.out","a"); FILE *fp4=fopen("errors.out","w"); FILE *fp5; fclose(fp4); sprintf(temp,"%sObj.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sTot.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp1=fopen(temp,"w"); fprintf(fp,"\n$%d",EXPRUN); fprintf(fp1,"\n$%d",EXPRUN); fclose(fp); fclose(fp1); if(argc==2)sscanf(argv[1],"%d",&debugLevel); printf("\n Debug level %d\n",debugLevel); for( i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; //Read from the file readInput(); //Compute the distance of all the points if(maxDist) { Dmax=computeDistance(); //Compute the maximum distance fp5=fopen("maxData.txt","w");fprintf(fp5,"%f",Dmax);fclose(fp5); } else {fp5=fopen("maxData.txt","r");fscanf(fp5,"%f",&Dmax);fclose(fp5); } printf("\n %f \n",Dmax); //Initialise the board for(k=0;k<EXPRUN;k++) { init(); sum=0; srand48(state1[k]); initialiseBoard(); initialise(1); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(1); printf("\n %d \n",heapCount); //Simulate the working of ants iterate(1); //drop the objects after all the iterations dropFinal(1); //to verify the correctness for(i=0;i<heapCount;i++) sum+=heaps[i].count; //write the cluster centers to the file writeClusterInformation(1); printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); //getchar(); //Run FCM // heapCount=2973;/* To be commented */ printf("\n\n k %d \n\n",k); Fcm(data); //compute new board size. lCount=heapCount; heapRow=(int)ceil(sqrt(4*heapCount)); newHeapCount=lCount; printf("\n LCount %d newHeapCount %d heap Row %d \n",lCount,newHeapCount,heapRow); //harden the objects harden(newHeaps); //iterate with the heaps as the objects. initialiseBoard(); initialise(0); for(i=0;i<lCount;i++) computeHeapParameters(&heaps[i],0); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(0); printf("\n %d \n",heapCount); //getchar(); //Simulate the working of ants iterate(0); dropFinal(0); writeClusterInformation(0); sum=0; for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); // getchar(); Fcm(data); harden1(); } fp=fopen("fcm.out","a"); fp1=fopen(temp,"a"); fprintf(fp,"\n"); fprintf(fp1,"\n"); fclose(fp); fclose(fp1); fp=fopen("fcm.out","r"); fp1=fopen(temp,"r");printf("\n Before read org\n");readOrg();printf("\nafter read org\n");readFCM(fp1,fp2);printf("\n After 1st read fcm\n");readFCM(fp,fp3);printf("\n After 2 fcm read \n");return(1); }//end of main /****************************************************************/ float NORM(feature , feature); void find_covar(); void Fcm (irisData Data[MAXDATA]) { int i,j,l; FILE *ofile; char temp[80]; int flag=0;//added by parag FILE *iniClsCen=fopen("center.clt","a+"); if(iniClsCen==NULL) { printf("\n Unable to open the initial cluster center file\n"); printf("\n choosing random cluster centers....\n"); flag=1; } strcpy(temp,""); sprintf(temp,"%s.data",filename); strcpy (fname,temp); /* Read from this file */ m=2.0; /* The exponent */ /*GET_INPUTS1(fname);*/ /* read in feature vectors */ for (j=0; j<n ; j++) /* Read File in row-major */ for (i=0; i<s ; i++) /* format */ X[j][i]=Data[j][i]; Random_seed=state1[run];/*randseed*/ srand48(Random_seed); for (run=0;run<TOTRUNS;run++) { //flag=1;//for testing random values if (EntireHeaps) lCount=heapCount; else lCount=c; for(i=0;i<lCount;i++) for(j=0;j<s;j++) V[i][j]=0; for(i=0;i<lCount;i++) { for(l=0;l<s;l++) { if(flag==1) { rand_index = lrand48() % n; V[i][l] = X[rand_index][l]; } else { fscanf(iniClsCen,"%f ",&V[i][l]); } }//end for } eps=0.001; stop = FALSE; /* This loop finds the final cluster center and the corresponding U values */ z = 0; while (stop == FALSE) { z++; UMAT(U,V,X); /** Update the U matrix **/ stop = FINISHED(U1,eps); CLUSTER(U,X); /** Get new cluster center **/ printf("Iteration: %d\n\n", z); } /* end while */ printf("Number of iterations: %d\n\n", z);strcpy(temp,""); sprintf(temp,"%sFCM.out",filename);if(dataDump) Output(temp); /* output the results */ }/*end for*/ if(dataDump) { ofile=fopen(temp,"a"); for (i=0; i <= mins; i++) fprintf(ofile, "Min %d of %10.3f occurred %d times\n", i, mintab[i], mincount[i]); fprintf(ofile, "Average iterations %f\n", (float)aveit/(float)TOTRUNS); fclose(ofile); } }/* end Main */ /* The GET_INPUTS1 procedure opens an input file, reads the number of input vectors, the number of features per vector, the number of clusters, and epsilon, then it reads the input values */ void GET_INPUTS1(char fname[]) //char fname[]; { /* Parameters: fname -- name of file containing input info. */ FILE *infile ;//*fopen(); //char junk[10][80]; char realfname[80]; char ch; char fileName1[80]; //int temp[10], i, j, inputs, outputs, count; int i,j; sprintf (realfname, "%s", fname); /* open input file */ if(normalize==1) strcpy(fileName1,"gtest1.data"); else strcpy(fileName1,fname); if((infile = fopen (fileName1, "r")) == NULL) printf("\n CAN'T OPEN %s\n",realfname); else { ch = 'c'; /* Discard leading comments */ while (ch != '#') fscanf (infile, "%c", &ch); for (j=0; j<n ; j++) /* Read File in row-major */ { /* format */ for (i=0; i<s ; i++) fscanf (infile, "%f", &X[j][i]); /* fscanf (infile, "%d", &temp[1]); */ /* end for */ } /* end for */ fclose(infile); /* close input file */ }/* end else */ } /* end GET_INPUTS1 */ /* The NORM function computes the norm of two vectors, x and v, of dimension s. This gives an indication of the distance between them */ float NORM( feature x, feature v) //feature x, v; { /* Parameters : x -- a local copy of an input vector v -- a local copy of a cluster center */ int i,j; /* loop variable */ double sum; /* the square root of sum is the norm; sum is the sum of the differences squared */ float mat1[s]; float mat2[s]; if (maha) { for (i=0; i<s; i++) mat1[i]=x[i]-v[i]; for(i=0;i<s;i++) { sum =0; for(j=0;j<s;j++) sum += mat1[j] * inv_cov[j][i]; mat2[i] = sum; } sum =0; for(j=0;j<s;j++) sum += mat1[j]*mat2[j]; } else { sum = 0; for(j=0;j<s;j++) sum += (x[j] - v[j])* (x[j] - v[j]); } return (float)(sqrt(sum)); } /* end NORM */ /* The UMAT procedure calculates the updated U matrix according to Bezdek's formula. Its side-effect is the update of the global array U1 */ void UMAT( matrix U,center V, objects X) /*matrix U; center V; objects X;*/ { /* Parameters: U, V, and X: same as in main program */ int i, j, k,l ;/* loop variables *///, class /* class whose cluster center //is closest to pattern k */; float d1,d2,d; float sum; int exact; for (k=0;k<n;k++) { /*printf("\n k %d ",k);*/ exact=false; for (i=0;i<lCount;i++) { sum=0; for (j=0;j<lCount;j++) { d1=NORM(X[k],V[i]); d2=NORM(X[k],V[j]); if(d2!=0) { d= d1/d2; d= d * d;/* pow(d1/d2,2.0/(m-1.0)); */ sum+=d; } else { exact = true; for(l=0;l<lCount;l++) if (l==j) U1[l][k]=1.0; else U1[l][k]=0.0; break; } } if (exact!=true) U1[i][k]=1.0/sum; } } } /* end UMAT */ /* The function FINISHED determines if a termination occurs. If not it updates U with U1, so its side-effect is the potential modification of U */ BOOLEAN FINISHED( matrix U1,float eps) //matrix U1; float eps; { /* Parameters: U1, eps-- same as in main */ float sum; /* sum of squared differences between corresponding elements of U and U1 */ int i,k; /* loop control variabes */ BOOLEAN finished; /* set to true if all corresponding elements are within epsilon */ finished = TRUE; sum = 0; for (i=0; i<lCount; i++) for (k=0; k<n; k++) sum += (U[i][k] - U1[i][k])*(U[i][k]-U1[i][k]); if (sqrt(sum) > eps) { finished = FALSE; for (i=0; i<lCount; i++) for (k=0; k<n; k++) U[i][k] = U1[i][k]; } /* end if */ return finished; } /* end FINISHED */ /* The CLUSTER procedure determines cluster centers in V for the c classes being searched for. The global array V is updated */ void CLUSTER( matrix U, objects X) //matrix U; objects X; { /* Parameters: U, X -- as in main */ int i, j, k; /* loop control variables */ feature num; /* numerator in the cluster center computation formula presented by Bezdek */ float denum; /* denumenator in the obove formula */ for (i=0; i<lCount; i++) { denum = 0; for (j=0; j<s; j++) { num[j] = 0; for (k=0; k<n; k++) num[j] += U[i][k] * U[i][k] * X[k][j]; /* pow(U[i][k],m) * X[k][j]; */ } /* end for */ for (k=0; k<n; k++) denum += U[i][k] * U[i][k]; /* pow(U[i][k],m); */ for (j=0; j<s; j++) V[i][j] = num[j] / denum; } /* end for */ } /* end CLUSTER */ float Compute_Jm(center V, objects X) //center V; //objects X; { int i, k,found; double Jm_value; float u,dik; Jm_value = 0; for (k=0; k<n; k++) { found = FALSE; for (i=0; i<lCount; i++) { dik=NORM(X[k],V[i]); dik=dik*dik; if (dik==0.0) { if (found == FALSE) { u=1.0; found = TRUE; printf("found the case with dik=0\n"); } else { printf("\n cant proceed with this initialization"); exit(1); } } else { if (found != TRUE) u=U1[i][k]; /* get_Uvalue(V,X,dik,k); */ else u=0.0; } Jm_value += u * u * dik;/* pow(u, m) * dik; */ } } return (Jm_value); } /* end Compute_Jm */ /* The Output procedure outputs the U matrix which gives the fuzzy measure of each feature belonging to a cluster center. It also outputs the cluster center for each class */ void Output(char fname[]) //char fname[80]; /* Parameters: U, V -- same as in main */ { int i, j, found; /* loop control variables */ float J2c; if ((fp=fopen(fname,"a"))==NULL) printf("\n CAN'T OPEN %s\n",fname); else { fprintf(fp,"\n The cluster centers are: \n"); fprintf(fp,"\n \n"); for (i=0; i<lCount; i++) { fprintf(fp,"\nCluster center %d: ",i+1); fprintf(fp,"\n"); for (j=0; j<s; j++) fprintf(fp,"%8.7f ",V[i][j]); } /* end for */ fprintf(fp,"\nThe membership grades for the feature vectors are:\n"); for (j=0; j<n; j++) { fprintf(fp,"\n"); for (i=0; i<lCount; i++) fprintf(fp," %8.7f",U[i][j]); } /* end for */ } /* end if */ J2c= Compute_Jm(V,X); found =0; for (i=0;i<= mins; i++){ if ((found == 0) && ((J2c - mintab[i]) < .001) && ((J2c - mintab[i]) > -.001)){ mincount[i]++; found = 1; } } if (found == 0){ mins++; mintab[mins]=J2c; mincount[mins]=1; } fprintf(fp,"\nJ%3.1f = %f", m,J2c); fprintf(fp, "Number of iterations: %d\n\n", z); aveit=aveit + z; fclose(fp); } /***************************************************************/ void find_covar(int m) //int m; { int i,j,k; float mean[s],sum; for (i=0;i<s;i++) mean[i]=0; for (i=0;i<s;i++) for (j=0;j<m;j++) mean[i]+=X[j][i]; for (i=0;i<s;i++) mean[i]/=m; for (i=0;i<s;i++) for (j=0;j<s;j++) { sum=0; for (k=0;k<m;k++) sum+=(X[k][i]-mean[i])*(X[k][j]-mean[j]); Y[i][j]=sum/m; } }
Parag Kanade/fuzzy ants/Gauss4/headerStatic.h
/********************************************************************//* Ant Class parameters *//* SPEED # amplitude of moves [1,10] *//* P direction Probability to move in the same direction [.5,1] *//* Max carry : Maximum object carrying time [20,200] *//* P load Probability to pick up a single object [0.4,0.8] *//* P destroy probability to destroy a heap of two objects [0,0.6] *//* T remove min. dissimilarity necessary for removing an object *//* from a heap [.1,.2] *//* T create max dissimilarity permitted for creating a heap[.05,.2]*//********************************************************************/ #include <stdio.h>#include <math.h>#include <string.h>#include<stdlib.h>#include <ctype.h>#include <time.h>#define MAXANTS 334#define MAXDATA 1000#define MAXANTSFORHEAPS 90#define MAXITERATIONS 1000#define MAXROWS 64#define MAXCOLS 64#define EXPRUN 10#define Tremove 1.50#define Tcreate 0.5#define Pdrop 0.2#define Pdestroy 0.3#define Pload 0.3#define normalize 0#define EntireHeaps 1#define TcreateForHeaps 0.19#define features 2#define filename "gauss04"#define errThresh 0.1#define dataDump 1#define maxDist 1#define INITIALOBJECTS 75#define OBJINC 10/* some type definitions to make C code a little more readable */#define TRUE 1#define FALSE 0#define n MAXDATA /* number of input vectors */#define s features /* number of features */#define c 5 /* number of clusters */#define TOTRUNS 1 /* number of V's to write out */#define false 0#define true 1#define maha 0#define square 0extern int count;int debugLevel=0;/* To debug the code and verify the correctness of algorithms*/int currHeapCount=0;typedef int BOOLEAN;typedef short TYPE_IN_DATA; /* Type of input binary data */typedef float feature[s]; /* Type of each input; made up of input features */typedef float irisData[s];typedef feature objects[MAXDATA]; /* Type of array holding all inputs */typedef feature center[MAXDATA]; /* Type of array holding cluster centers */typedef float matrix[MAXDATA][MAXDATA];/* Type of the matrix containing membership grades */typedef struct Heap {float Dmax;//maximum dissimilar distanceirisData Ocenter;//center objectfloat Dmean;//mean of the distance between the center and all the objectsirisData Odissim;//most dissimilar objectint x;//x position on the boardint y;//y position on the boardint count;//number of objects in the heapsint disPosition;//most dissimilar objectint objects[MAXDATA];int objCount;}heap;typedef struct Ant{int x;int y;int carrying;int speed;int dir;irisData data;}ant;float orgData[n][s+1];float fcmData[MAXDATA][n][s];int clsCenCount[MAXDATA];int currentRow=0;int currentAntCount=0;int updateAfter=50;int heapSum=0;int minAnts=3;int rowMin=5;typedef struct HeapInfo{int total;int classObj[c];} heapInfo;/*heapInfo info[MAXDATA];*//********************************************************************//***Function decelarations*//********************************************************************//***For ant based algorithm*/void readInput();float computeDistance();float computeDistanceBetween2(irisData a,irisData b);float findMax(float *distance);float value(irisData a);int found(int a , int b);void initialise(int flag);int findObject(int a,int b);void initialiseAnts(int flag);void moveNext(ant* a,int flag);void computeHeapParameters(heap* data,int flag);void pickObject1(ant *a,int position,int flag);void pickObject2(ant *a , int position,int flag);void pickObjectn(ant *a,int position,int flag);void pick(ant *a,int flag);void dropObject(ant* a,int flag);int findInNewheaps(irisData object);void dropObject1(ant* a, int position,int flag);void drop(ant* a,int flag);void move(ant* a,int flag);void iterate(int flag);void dropFinal(int flag);int partition(heap a[], int low,int high);void quickSort( heap A[], int low,int high ) ;void writeClusterInformation(int flag);void initialiseNewHeaps(heap newHeaps[]);int findPosition(int i);void harden(heap newHeaps[]);void harden1();int findPosition1(int );void writeInfo();void addObject1(int ,int);void readFCM(FILE *,FILE *);void readOrg();int findInData(irisData input,int iflag);void adjustBoard(int flag);void writeIncremental(int iteration,int flag);/********************************************************************//***For FCM algorithm*/void GET_INPUTS1(char []);void UMAT( matrix,center,objects);BOOLEAN FINISHED(matrix, float);void CLUSTER( matrix, objects);void Output(char[]);void Fcm();/********************************************************************/
Parag Kanade/fuzzy ants/Gauss4/maxData.txt
1.602038
Parag Kanade/fuzzy ants/Gauss5/gauss05.data
Gauss data | |
# | |
-0.46551197 | 1.33961810 |
-0.14154019 | 1.64673550 |
-0.06147374 | 1.91002100 |
-0.00960664 | 1.69592370 |
0.13522751 | 2.33715450 |
0.15816343 | 1.74101000 |
0.16902868 | 1.71459020 |
0.20321506 | 1.32309940 |
0.24094079 | 1.30698460 |
0.25245225 | 2.18395260 |
0.26993324 | 2.54833230 |
0.28680391 | 1.60524320 |
0.31923670 | 2.22768550 |
0.36114833 | 2.80097840 |
0.42440670 | 1.86344490 |
0.46037797 | 1.45327890 |
0.46098959 | 2.35558750 |
0.48936047 | 1.81261980 |
0.49341700 | 0.52432961 |
0.55795860 | 2.00690930 |
0.59517099 | 0.74266104 |
0.60128600 | 2.44774600 |
0.64249205 | 0.22137058 |
0.64603926 | 2.09861200 |
0.68936857 | 2.34366060 |
0.70125847 | 1.98814310 |
0.70954162 | 1.83408840 |
0.71271143 | 1.19116580 |
0.73828501 | 2.91576250 |
0.76121259 | 2.88777400 |
0.76300537 | 3.36236000 |
0.78715506 | 1.79988820 |
0.79603202 | 1.38376310 |
0.81552587 | 0.76593590 |
0.81671088 | 2.02359450 |
0.83646559 | 1.72929280 |
0.84905869 | 0.90959966 |
0.87280583 | 1.91850330 |
0.93911004 | 2.23771490 |
0.94658989 | 1.80993290 |
0.95071896 | 3.35937710 |
0.95477185 | 0.82422933 |
1.04753510 | 3.73589530 |
1.04835550 | 2.62226190 |
1.06632740 | 2.07724580 |
1.07197890 | 2.30511140 |
1.08416590 | 2.89828470 |
1.09173310 | 1.49658350 |
1.12682710 | 1.75417760 |
1.13086730 | 2.13536120 |
1.14284660 | 2.09725790 |
1.14935130 | 1.82271180 |
1.18193490 | 1.87386190 |
1.19003770 | 1.58358310 |
1.21018740 | 1.87969630 |
1.21811180 | 3.01110680 |
1.22779720 | 2.08081830 |
1.23354980 | 2.95731630 |
1.24485620 | 1.60172010 |
1.25554360 | 1.94720670 |
1.25973520 | 0.95874592 |
1.26011950 | 0.81798378 |
1.27152420 | 0.46185734 |
1.27494230 | 3.25923360 |
1.28887590 | 2.41629430 |
1.31946400 | 2.11809770 |
1.32665570 | 1.92493560 |
1.32694610 | 2.87835080 |
1.34589980 | 1.60470480 |
1.34715480 | 2.06603250 |
1.37535150 | 2.40899990 |
1.37934060 | 2.10897930 |
1.38729280 | 3.34550470 |
1.39799660 | 2.38291630 |
1.40017170 | 3.04820380 |
1.40547320 | 1.62152210 |
1.43123920 | 0.79191521 |
1.43548180 | 3.02712970 |
1.44101390 | 2.79862030 |
1.46412020 | 0.58155858 |
1.46461530 | 3.97915160 |
1.50553290 | 1.09901250 |
1.52866150 | 2.69439440 |
1.55340190 | 3.74144500 |
1.57359080 | 1.55710160 |
1.58566390 | 0.99127551 |
1.60834110 | 2.31547220 |
1.61675150 | 3.46413620 |
1.63157910 | 2.94477030 |
1.64858250 | 1.94597150 |
1.65589020 | 1.11547360 |
1.66033180 | 2.48016160 |
1.66570180 | 1.97626460 |
1.67408670 | 2.97515150 |
1.71093120 | 1.57160930 |
1.71729340 | 1.95422650 |
1.72459970 | 2.38705900 |
1.72800160 | 3.21686080 |
1.74073560 | 1.67705870 |
1.74466110 | 3.84404410 |
1.74791670 | 1.39134990 |
1.75073120 | 2.76959900 |
1.75674040 | 1.44477840 |
1.75912620 | 3.99522830 |
1.76102340 | 3.58775810 |
1.77369130 | 1.43998750 |
1.78265180 | 3.18278020 |
1.78823310 | 2.75586820 |
1.80480770 | 1.48943580 |
1.80657800 | 2.29801840 |
1.81057340 | 3.07288630 |
1.81324520 | 0.11900227 |
1.85811620 | 2.38161760 |
1.87359260 | 2.11200870 |
1.87715770 | 1.96065850 |
1.87918670 | 0.81713304 |
1.88668940 | 1.57613630 |
1.88810090 | 0.12698201 |
1.89805160 | 2.46405720 |
1.91165900 | 0.92031474 |
1.91635930 | 2.26590110 |
1.92170440 | 1.94293490 |
1.92406250 | 1.26831480 |
1.93349800 | 0.99443935 |
1.93666920 | 3.04261660 |
1.95720640 | 3.26896210 |
1.98793100 | 4.12877670 |
1.99071160 | 1.64890550 |
1.99301550 | 2.68464830 |
2.00115780 | 2.32360360 |
2.01070860 | 2.18020410 |
2.06509720 | 0.62687304 |
2.07609930 | 1.85641040 |
2.07659500 | 3.14121100 |
2.07970880 | 2.64448160 |
2.08286430 | 2.40266820 |
2.09488370 | 1.86480590 |
2.09856220 | 3.70264650 |
2.09949790 | 4.03821420 |
2.10236420 | 3.28141870 |
2.11024410 | 3.38057690 |
2.15225890 | 1.66258720 |
2.16136260 | 2.64167190 |
2.17609540 | 0.66759943 |
2.18054240 | 2.04423840 |
2.18426850 | 2.59546920 |
2.18914050 | 2.95823910 |
2.19639150 | 2.04300460 |
2.20202640 | 2.17670700 |
2.20468400 | 0.83693931 |
2.20525410 | 1.74999960 |
2.20669260 | 2.72082740 |
2.21098710 | 0.60017807 |
2.21469960 | 1.39912800 |
2.21745540 | 0.72364346 |
2.23041590 | 0.82961734 |
2.24735060 | 1.28753680 |
2.24903970 | 2.17344220 |
2.25198440 | 1.29699870 |
2.26046190 | 0.78269340 |
2.26880210 | 2.04607170 |
2.30821860 | 3.46557130 |
2.33728500 | 2.35864760 |
2.36166570 | 2.94318430 |
2.37269100 | 1.73059750 |
2.37839370 | 1.35358190 |
2.38160210 | 1.90073840 |
2.39673710 | 1.15694860 |
2.40968300 | 2.35955940 |
2.41934690 | 1.08563120 |
2.42345830 | 0.51782552 |
2.43925680 | 3.14634990 |
2.44003700 | 3.26188350 |
2.44993190 | 0.49230030 |
2.45826830 | 1.35888490 |
2.47695310 | 3.58142070 |
2.48443160 | 1.99845110 |
2.48451730 | 1.87370640 |
2.49321870 | 1.66146000 |
2.51610470 | 2.22988430 |
2.52167440 | 2.96074320 |
2.52291390 | 1.49298900 |
2.52707720 | -0.06387469 |
2.53539040 | 0.28615059 |
2.57812250 | 2.50850230 |
2.57890430 | 2.65642470 |
2.59130780 | 3.46783160 |
2.60177950 | 2.33292280 |
2.60836910 | 1.72191070 |
2.60906800 | 2.41048970 |
2.63288540 | 1.45875990 |
2.64696870 | 1.70147090 |
2.69200390 | 1.29565400 |
2.69798380 | 2.93142670 |
2.71265420 | 2.16194930 |
2.71761770 | 2.61848410 |
2.72034200 | 2.75907540 |
2.72880160 | 1.86016060 |
2.77297590 | 2.36490240 |
2.80417770 | 1.89472110 |
2.82975660 | 2.10584710 |
2.85681650 | 3.23983040 |
2.87080060 | 2.53653120 |
2.88845650 | 2.49839960 |
2.89401350 | 0.80718637 |
2.92700990 | 1.47051920 |
2.93324100 | 0.61062000 |
2.97223060 | 1.91058110 |
2.97728540 | 0.05260017 |
2.97737970 | 2.43822920 |
2.98051300 | 0.98434561 |
3.00561200 | 2.88339240 |
3.00897060 | 0.48283347 |
3.02618180 | 2.86961890 |
3.04006880 | 2.23519680 |
3.06476130 | 1.38678580 |
3.09581560 | 4.79770430 |
3.09743610 | 0.61238889 |
3.12340700 | 3.27566110 |
3.14002600 | 1.91049960 |
3.14019960 | 3.00888450 |
3.17433280 | 2.98995780 |
3.18087940 | 2.40854900 |
3.18322030 | 1.07038150 |
3.22764280 | 2.18078200 |
3.23720550 | 1.44137450 |
3.29520690 | 2.90163040 |
3.33879830 | 3.23653160 |
3.35624410 | 3.35958530 |
3.44164230 | 4.73574970 |
3.52192800 | 2.86513240 |
3.52492410 | 2.40565520 |
3.63961210 | 0.74341452 |
3.65258060 | 4.05964180 |
3.67734150 | 0.65264229 |
3.70898120 | 3.47495760 |
3.75704250 | 2.27892970 |
3.79908120 | 1.80310890 |
3.80792120 | 3.26049480 |
3.86355230 | 3.30653510 |
3.88267690 | 2.44348050 |
3.91058010 | 0.07306810 |
4.02758240 | 2.91107290 |
4.26109770 | 3.51507650 |
4.26540320 | 2.58627940 |
4.37722260 | 3.69395380 |
4.38629290 | 1.82723270 |
4.67363320 | 1.48535710 |
3.94355830 | 6.47395710 |
3.97391840 | 4.87866000 |
4.18739700 | 6.34885200 |
4.24071090 | 5.55185350 |
4.24365210 | 6.45412420 |
4.25518380 | 4.55644420 |
4.28524300 | 7.20716730 |
4.32994460 | 6.00003610 |
4.33192370 | 7.09367650 |
4.37355700 | 6.88269120 |
4.46409400 | 6.05818290 |
4.49067420 | 6.32926110 |
4.51153380 | 6.85352870 |
4.56599710 | 7.04864140 |
4.60231750 | 4.95853610 |
4.62348130 | 5.39071570 |
4.64450820 | 6.69985040 |
4.64904500 | 6.88495910 |
4.65841250 | 6.01528070 |
4.66655080 | 6.42825920 |
4.67306050 | 7.59424310 |
4.76372900 | 5.28356040 |
4.77552290 | 7.40746300 |
4.80762540 | 6.65894500 |
4.82763450 | 5.46445960 |
4.84792340 | 4.75686200 |
4.85657400 | 5.50381400 |
4.86225910 | 6.91700090 |
4.93637580 | 4.23195980 |
4.94390900 | 5.48754390 |
4.98892060 | 7.61144900 |
5.01650590 | 6.54753540 |
5.04197050 | 7.85286660 |
5.10227700 | 8.01646130 |
5.12885550 | 5.72556180 |
5.12964740 | 6.90234580 |
5.15532960 | 7.36587300 |
5.17303110 | 5.74274600 |
5.18206350 | 5.03849040 |
5.25604270 | 7.23015750 |
5.29819060 | 8.21814690 |
5.30112180 | 2.96571480 |
5.30196100 | 6.65044240 |
5.31459470 | 5.21750590 |
5.33619550 | 8.04356960 |
5.38039120 | 6.91763440 |
5.40785960 | 6.56722290 |
5.40994000 | 6.69154760 |
5.48501860 | 5.67204300 |
5.49653470 | 7.40854490 |
5.51921830 | 6.16971170 |
5.56473570 | 7.03218950 |
5.56487270 | 7.55897590 |
5.60151890 | 3.09949060 |
5.60358100 | 7.37902530 |
5.60998170 | 4.16380260 |
5.62068070 | 6.60873250 |
5.63459940 | 6.15316390 |
5.64294830 | 7.35420540 |
5.67240780 | 5.46370020 |
5.70923490 | 5.71517630 |
5.71460100 | 4.80898650 |
5.71820870 | 4.83594030 |
5.72450000 | 5.25972780 |
5.73850450 | 5.42471410 |
5.77026500 | 6.74009030 |
5.81107380 | 5.47122920 |
5.83126620 | 4.54184770 |
5.83198380 | 5.99319780 |
5.85787990 | 6.09342090 |
5.88532760 | 6.02345150 |
5.91363800 | 6.54156470 |
5.92674080 | 5.71333250 |
6.01807400 | 6.61400250 |
6.01847440 | 6.04561100 |
6.04122250 | 5.22394930 |
6.04854960 | 6.06328950 |
6.05181170 | 5.00807640 |
6.06648940 | 6.14140220 |
6.09495840 | 6.12569700 |
6.10139500 | 6.87509520 |
6.12351310 | 5.69770350 |
6.13942660 | 5.11012500 |
6.16735070 | 5.73108400 |
6.19581790 | 6.19862080 |
6.22701680 | 7.33421700 |
6.23192510 | 6.51588610 |
6.23274070 | 6.07263650 |
6.27462750 | 5.69395300 |
6.28022480 | 3.34928740 |
6.30797300 | 5.57445750 |
6.40891240 | 5.16520540 |
6.42060610 | 4.19796540 |
6.43322370 | 6.45805660 |
6.44136690 | 5.09146360 |
6.46967490 | 5.85811280 |
6.48306340 | 8.25081740 |
6.48641110 | 4.72902160 |
6.49282010 | 7.74602800 |
6.49526610 | 4.12129000 |
6.49909390 | 7.01082130 |
6.51460560 | 6.64307510 |
6.55219720 | 5.32859600 |
6.57416700 | 6.06793980 |
6.58116560 | 4.00798880 |
6.58182580 | 6.10192730 |
6.60913670 | 5.57521110 |
6.62468490 | 5.53650280 |
6.66421430 | 5.44580030 |
6.66910180 | 7.79154550 |
6.70029220 | 7.63838790 |
6.71206150 | 5.79403900 |
6.76440480 | 5.88082880 |
6.79348260 | 4.49508360 |
6.96845940 | 7.00534870 |
6.97144060 | 4.27568510 |
6.97887120 | 6.94657670 |
7.00296760 | 4.97715130 |
7.02476900 | 3.98307760 |
7.10895500 | 7.00220740 |
7.16675020 | 4.19662350 |
7.20085130 | 8.28069870 |
7.22378650 | 6.32870310 |
7.31577010 | 4.59509450 |
7.36067680 | 9.10867310 |
7.58444910 | 6.86571300 |
7.67335250 | 4.62301640 |
7.68221600 | 6.42338430 |
7.68562080 | 6.31015700 |
7.69069460 | 4.32890800 |
7.72974570 | 7.15472810 |
10.38220400 | 6.69533970 |
-0.53802474 | 9.86702580 |
-0.50977026 | 9.53528050 |
-0.43584458 | 10.83129500 |
-0.04882059 | 8.95037180 |
0.05835481 | 10.55733200 |
0.10288324 | 9.59351740 |
0.17447523 | 8.05402150 |
0.19810974 | 9.12201000 |
0.21934452 | 9.07843940 |
0.23439904 | 9.84479100 |
0.26788561 | 10.20955800 |
0.47250581 | 8.61231020 |
0.51426980 | 8.46140090 |
0.54996643 | 9.27683580 |
0.55418227 | 8.88493900 |
0.60602417 | 10.93646800 |
0.63375978 | 10.20699500 |
0.63673117 | 8.78448430 |
0.72741870 | 9.09766520 |
0.78672127 | 8.61717250 |
0.84069897 | 8.76506070 |
0.88570100 | 10.13743100 |
0.91613686 | 10.23333600 |
0.92942006 | 8.57136260 |
0.95596944 | 10.53530900 |
0.96854857 | 9.80381840 |
1.01456280 | 8.28791640 |
1.01779270 | 10.84433000 |
1.02156340 | 10.76533100 |
1.03196560 | 9.66837340 |
1.06829630 | 9.17620610 |
1.07974110 | 10.49751800 |
1.08903630 | 9.72974150 |
1.10201390 | 9.11047530 |
1.11119650 | 10.97406800 |
1.11187620 | 10.73005100 |
1.11902410 | 10.62602100 |
1.12900530 | 10.70811300 |
1.15670380 | 8.98593880 |
1.16427170 | 10.86776000 |
1.18772870 | 9.02772250 |
1.24177610 | 9.92394220 |
1.26972330 | 10.58267000 |
1.28053590 | 10.83958700 |
1.31503300 | 7.80067800 |
1.33748480 | 9.88473050 |
1.34367870 | 11.16094600 |
1.36016050 | 9.92205470 |
1.38043410 | 9.54642060 |
1.41957600 | 8.56118380 |
1.44766000 | 9.79764190 |
1.44978560 | 10.99242200 |
1.45159130 | 9.24636600 |
1.46291700 | 9.06834910 |
1.46937900 | 11.27737100 |
1.47663500 | 9.70492070 |
1.47897680 | 8.75870350 |
1.48648380 | 7.83678240 |
1.49434700 | 8.41880090 |
1.49775780 | 10.23531600 |
1.51504080 | 11.46943800 |
1.54653760 | 10.10279700 |
1.54817560 | 10.50012400 |
1.56238190 | 11.11233000 |
1.56575230 | 9.86530650 |
1.56805180 | 9.79929020 |
1.57879060 | 9.47959820 |
1.58071100 | 10.63411500 |
1.58827760 | 11.15466100 |
1.61545530 | 9.55612270 |
1.62402770 | 8.15133740 |
1.62710070 | 9.95947450 |
1.64236540 | 9.52075910 |
1.65322140 | 8.92139720 |
1.67089710 | 9.06478230 |
1.68161090 | 10.30733200 |
1.68314950 | 10.75388100 |
1.69092340 | 8.30567430 |
1.69448600 | 8.40313090 |
1.70295680 | 8.78520890 |
1.72092450 | 11.16000900 |
1.75544750 | 9.56356250 |
1.75611050 | 9.14866940 |
1.75916440 | 11.05389900 |
1.78160410 | 11.75470400 |
1.78766310 | 10.69221500 |
1.82344220 | 9.72124790 |
1.82620620 | 10.72714200 |
1.82886270 | 10.67386400 |
1.82977930 | 10.45891600 |
1.83260300 | 11.07471100 |
1.83536280 | 9.08031440 |
1.85562350 | 9.61858110 |
1.85630450 | 10.95031700 |
1.85675330 | 10.23094900 |
1.87558110 | 9.79540000 |
1.88087730 | 11.26157900 |
1.88329880 | 8.97817840 |
1.88430750 | 9.80275410 |
1.89055870 | 12.46976600 |
1.89752820 | 10.28635000 |
1.91098330 | 10.30122500 |
1.91444480 | 8.97405900 |
1.91650830 | 11.67635200 |
1.92091760 | 9.71317550 |
1.97816590 | 11.66490100 |
1.97880630 | 7.96053110 |
1.97957920 | 10.60428500 |
1.99889770 | 9.38730000 |
2.00857470 | 10.70364400 |
2.01968670 | 12.96920800 |
2.02561900 | 10.08143700 |
2.05346190 | 10.70522900 |
2.05475860 | 10.30522800 |
2.05475860 | 10.81687100 |
2.07553920 | 8.35520010 |
2.07556900 | 9.53284230 |
2.10667150 | 8.93102270 |
2.12194210 | 8.07869520 |
2.13253750 | 10.27866700 |
2.13464690 | 9.79297840 |
2.13772280 | 9.31410140 |
2.14245180 | 9.06217820 |
2.16372800 | 8.01264140 |
2.17899090 | 11.54517900 |
2.19104960 | 12.74184000 |
2.19264800 | 11.56782800 |
2.21200420 | 9.51493550 |
2.22368020 | 9.70260450 |
2.23535900 | 11.29138600 |
2.25048880 | 10.25527500 |
2.28499440 | 9.66707670 |
2.29362360 | 10.04094000 |
2.29439620 | 8.60983420 |
2.29729520 | 11.04440500 |
2.31597750 | 8.80252050 |
2.31833880 | 9.71240520 |
2.33127170 | 9.19450210 |
2.33327880 | 9.85855600 |
2.34367510 | 10.27882500 |
2.35101980 | 9.44433780 |
2.35368280 | 9.69186110 |
2.37624870 | 10.00117800 |
2.38733310 | 9.94496600 |
2.40180790 | 11.33634400 |
2.40499310 | 10.35497400 |
2.40693120 | 10.22960600 |
2.41459460 | 11.86536700 |
2.42981750 | 10.17701300 |
2.43040130 | 11.29583100 |
2.43505260 | 9.28143430 |
2.43652240 | 10.60742200 |
2.43859720 | 10.11362900 |
2.43956950 | 10.28759400 |
2.44338670 | 9.56722360 |
2.45810510 | 9.30052690 |
2.48495800 | 9.61228170 |
2.48551370 | 9.74309070 |
2.49617560 | 9.08527480 |
2.49618150 | 9.97747920 |
2.50603670 | 10.62650200 |
2.51112770 | 10.04812500 |
2.53530220 | 11.00603700 |
2.54774550 | 9.52181910 |
2.56467230 | 8.57532880 |
2.60695660 | 9.49283340 |
2.61066100 | 9.23332450 |
2.61106350 | 11.16140900 |
2.61565990 | 12.24306000 |
2.61573630 | 9.62476480 |
2.62311430 | 11.46785100 |
2.63034990 | 11.16658500 |
2.64793630 | 9.49270110 |
2.64984800 | 9.99999970 |
2.67268460 | 11.19640400 |
2.69565560 | 11.33803100 |
2.75079750 | 11.35678000 |
2.80391130 | 10.38172800 |
2.86698840 | 11.92690800 |
2.89529580 | 9.23670160 |
2.93233230 | 9.42533600 |
2.94698180 | 10.62292600 |
2.95247540 | 9.57839520 |
2.97818640 | 10.54284200 |
2.98711940 | 8.43961850 |
3.03198230 | 10.89015400 |
3.05493660 | 9.07937810 |
3.08486570 | 10.44131700 |
3.09086910 | 10.08045400 |
3.12991540 | 9.45931510 |
3.16627520 | 11.24110600 |
3.18161550 | 8.56736250 |
3.20627950 | 9.30813850 |
3.24247530 | 10.28896000 |
3.24252950 | 10.15812300 |
3.29064670 | 11.07275800 |
3.29731200 | 9.84727140 |
3.29751450 | 10.75749900 |
3.30620860 | 10.42134600 |
3.33235060 | 10.51309200 |
3.34481240 | 9.13470460 |
3.34749520 | 10.53669500 |
3.44947090 | 11.90089200 |
3.49865710 | 10.60088500 |
3.51300760 | 11.13617800 |
3.52758750 | 11.16753500 |
3.54582030 | 10.82713200 |
3.63572170 | 11.77784300 |
3.64186710 | 10.28076500 |
3.64262700 | 9.75089300 |
3.76649600 | 10.25604700 |
3.84954880 | 8.07932180 |
4.10374540 | 10.81806500 |
4.22508220 | 12.60704200 |
4.38131550 | 10.09231700 |
4.63405100 | 11.15266000 |
5.02071230 | 10.89582300 |
7.29517410 | 4.95038300 |
7.64268890 | 3.02642500 |
8.37832840 | 1.66775860 |
8.66108260 | 1.28584310 |
8.76586670 | 1.25023720 |
8.87351890 | 3.00700310 |
8.92028780 | 2.37946150 |
9.21573760 | 4.04563490 |
9.28283710 | 4.76142670 |
9.34161730 | 4.73429670 |
9.37286700 | 4.07157300 |
9.37933440 | 3.42884820 |
9.44715130 | 1.02909710 |
9.55074290 | 3.15201080 |
9.57965250 | 2.31375530 |
9.65924290 | 1.90478360 |
9.70270510 | 2.39146600 |
9.70668260 | 2.85758720 |
9.76651980 | 3.65349960 |
9.81668260 | 4.06812080 |
9.83092360 | 3.42345370 |
9.87058370 | 0.95144045 |
9.87065650 | 1.49842450 |
9.87616540 | 3.52875290 |
9.90859480 | 0.91336718 |
9.91639150 | 4.49805260 |
9.93212930 | 4.68844650 |
9.96357740 | 4.15191530 |
9.97741310 | 0.71576669 |
10.00538600 | 3.97253390 |
10.03108000 | 2.18997090 |
10.03130300 | 4.32228250 |
10.03259000 | 4.14975090 |
10.03428000 | 4.04539320 |
10.08044700 | 3.36980570 |
10.08351700 | 5.31544110 |
10.10949800 | 0.69493770 |
10.12784000 | 2.10773240 |
10.14332800 | 4.29328660 |
10.15352700 | 0.14745808 |
10.18516500 | 4.68407520 |
10.18610800 | 2.00950290 |
10.21848600 | 0.86943064 |
10.22578800 | 3.64461980 |
10.23058600 | 2.56652140 |
10.24244600 | 2.08428290 |
10.25005800 | 3.66749810 |
10.25651800 | 4.10251020 |
10.26568300 | 1.00452720 |
10.28218900 | 2.54014490 |
10.30209900 | 2.60527380 |
10.30866800 | 5.06128290 |
10.35145400 | 3.96488170 |
10.35328700 | 1.92069180 |
10.36641000 | 1.04618570 |
10.37211900 | 3.01345330 |
10.37387400 | 3.34794110 |
10.38586300 | 4.87498410 |
10.40975800 | 1.47702490 |
10.42930200 | 3.18560190 |
10.58473700 | 4.51938660 |
10.60713700 | 2.78150470 |
10.61288300 | 0.24133727 |
10.62282000 | 2.85380720 |
10.62670900 | 4.31761610 |
10.63141600 | 3.62342330 |
10.63782500 | 0.13733134 |
10.65045900 | 4.67649570 |
10.65138000 | 4.44121490 |
10.66319100 | 4.15626830 |
10.67136400 | 2.17268420 |
10.67655100 | 2.34284280 |
10.68966800 | 0.11834644 |
10.69309600 | 4.03254720 |
10.69634300 | 3.51755370 |
10.69959300 | 1.87670870 |
10.70364500 | 3.63129500 |
10.79568600 | 1.77216860 |
10.80954200 | 5.56426340 |
10.82584700 | 2.13711490 |
10.84278600 | 3.39047740 |
10.84874000 | 5.35138590 |
10.86028800 | 5.47849070 |
10.86037000 | 1.85849660 |
10.86917100 | 4.23074230 |
10.87205500 | 3.07491120 |
10.87257000 | 0.23464118 |
10.91078800 | 4.26901910 |
10.92863400 | 2.63593660 |
10.97033500 | 2.82427890 |
11.03666100 | 1.70051580 |
11.04934200 | 2.76640640 |
11.06016600 | 3.20088330 |
11.06081400 | 3.99441140 |
11.06851100 | 3.95114850 |
11.07547500 | 2.16238100 |
11.12106900 | 3.02425300 |
11.13520400 | 3.24728770 |
11.13785300 | 2.00208790 |
11.17317400 | 3.14803610 |
11.18638600 | 6.22516560 |
11.20099100 | 1.19015140 |
11.20883900 | 3.42794410 |
11.21894800 | 2.78643090 |
11.22180700 | 2.07195140 |
11.24615200 | 4.43557960 |
11.26246100 | 1.95785590 |
11.26868200 | 2.62892100 |
11.29046500 | 2.28748380 |
11.29332600 | 3.10607900 |
11.30113300 | 3.17774770 |
11.30288200 | 2.21218430 |
11.30746500 | 5.37940840 |
11.31033800 | 2.07920170 |
11.37790300 | 2.56282890 |
11.43262800 | 2.22257980 |
11.43947300 | 2.38576500 |
11.46754700 | 3.77819260 |
11.47712100 | 2.65629050 |
11.50119400 | 1.34805320 |
11.53382400 | 3.91389830 |
11.54175000 | 1.91726030 |
11.54858900 | 3.42249720 |
11.55128100 | 4.03482200 |
11.58000500 | 1.42493230 |
11.62293600 | 1.63509770 |
11.63570300 | 4.08117290 |
11.63576600 | -0.31603070 |
11.63690600 | 4.14853350 |
11.64069300 | 4.00507650 |
11.64464600 | 1.63983550 |
11.65989500 | 2.75988020 |
11.66710000 | 2.08519330 |
11.67212200 | 0.82188274 |
11.79065500 | 2.99906140 |
11.79146600 | 2.99766490 |
11.82391500 | 4.50216090 |
11.83695800 | 1.77045500 |
11.84902300 | 4.04107940 |
11.87579500 | 2.49994310 |
11.90613300 | 4.81234120 |
11.92998700 | 5.01715490 |
11.94321800 | 3.50299350 |
11.94416800 | 3.88805960 |
11.97362800 | 4.39756760 |
11.97788300 | 2.66685530 |
11.98689100 | 2.31567030 |
11.99081600 | 5.09192670 |
11.99801800 | 4.56908950 |
12.00298200 | 1.94237290 |
12.00316700 | 2.17838480 |
12.02293000 | 2.73944570 |
12.04831300 | 4.78784470 |
12.04935000 | 2.91964680 |
12.10296400 | 5.93536230 |
12.10411700 | 1.35530440 |
12.11240800 | 3.44293000 |
12.11691300 | 4.70406270 |
12.11736300 | 4.43799220 |
12.13297500 | 3.72159310 |
12.14842100 | 2.84191770 |
12.15702300 | 2.31892640 |
12.20992600 | 5.06471420 |
12.23174500 | 3.10598390 |
12.24324200 | 4.66598260 |
12.27524400 | 2.45092420 |
12.28363300 | 2.06558290 |
12.31873000 | 2.57653720 |
12.36022800 | 0.30690857 |
12.39010700 | 4.48246780 |
12.39101900 | 4.11104480 |
12.41839700 | 2.60166070 |
12.43804500 | 4.29621460 |
12.50262800 | 1.91294910 |
12.53067800 | 4.27091700 |
12.53177400 | 2.51077500 |
12.53548400 | 5.34961560 |
12.55590600 | 1.88128220 |
12.57487900 | 3.14838260 |
12.57704700 | 5.57486740 |
12.69811900 | 4.56844720 |
12.71266600 | 1.86983480 |
12.75471600 | 1.88424410 |
12.84054600 | 4.17589510 |
12.87563700 | 4.58237630 |
12.91383900 | 3.72360130 |
12.92143500 | 3.99211200 |
12.95051000 | 4.50726300 |
12.96883700 | 2.81026580 |
13.37212300 | 4.10562440 |
13.57001500 | 6.35204170 |
13.87186200 | 1.28395610 |
6.77625400 | 8.93326230 |
6.82853500 | 10.75476800 |
6.99850990 | 12.00625500 |
7.03320130 | 12.17173900 |
7.34958640 | 11.34462900 |
7.36433010 | 10.30722100 |
7.63086440 | 11.72930800 |
7.67429150 | 11.42227600 |
7.67659120 | 11.95716300 |
7.72421250 | 11.60357600 |
7.73093580 | 11.28785800 |
7.82011350 | 10.31780300 |
8.04405000 | 11.32677600 |
8.28438950 | 12.22446700 |
8.33380870 | 13.31556100 |
8.38648740 | 12.43029300 |
8.39185100 | 9.66884460 |
8.41343420 | 12.81313400 |
8.48875950 | 11.33832500 |
8.49273750 | 11.03376200 |
8.56167170 | 12.04155900 |
8.67928500 | 11.29584400 |
8.69809170 | 9.83322040 |
8.72482460 | 10.81320900 |
8.73837900 | 13.51393500 |
8.74470180 | 13.61214400 |
8.75924500 | 13.42558100 |
8.81743790 | 10.38709600 |
8.83182740 | 13.13231400 |
8.84119810 | 11.77572400 |
8.86576390 | 8.18619000 |
8.90450350 | 9.62928520 |
8.90605490 | 10.43295500 |
8.92366520 | 9.50858180 |
8.92461850 | 11.50141400 |
8.93719790 | 11.53834300 |
8.94241620 | 10.66978600 |
8.94366110 | 10.42219800 |
8.95438400 | 9.62107450 |
9.00487450 | 11.64730100 |
9.00932750 | 11.15508100 |
9.04954750 | 11.48330000 |
9.06275560 | 11.23776000 |
9.08488060 | 11.07371900 |
9.09882630 | 11.65037300 |
9.12191410 | 10.02935100 |
9.13666160 | 12.97184800 |
9.14859280 | 11.23678600 |
9.15599420 | 9.92740050 |
9.17842650 | 9.63470770 |
9.20071630 | 13.45879200 |
9.20678430 | 11.87802700 |
9.21262330 | 10.62747800 |
9.27771000 | 11.30113800 |
9.33949500 | 15.14724700 |
9.34216130 | 11.48929200 |
9.35773140 | 10.46045300 |
9.37242510 | 10.83847200 |
9.39966490 | 8.71695000 |
9.40027730 | 7.69134830 |
9.43249590 | 8.59230880 |
9.43916380 | 11.27331100 |
9.47467300 | 9.11875190 |
9.47830740 | 9.74695740 |
9.48281740 | 11.83558400 |
9.50827820 | 10.96041000 |
9.51317460 | 9.12711080 |
9.52261180 | 13.37399000 |
9.54111150 | 11.97061500 |
9.54785290 | 13.08466300 |
9.55937760 | 11.46716800 |
9.56043010 | 9.62510630 |
9.56210660 | 8.61510740 |
9.56398230 | 8.65702010 |
9.57275430 | 9.22845420 |
9.59992340 | 12.38279300 |
9.60973830 | 9.67483190 |
9.63354210 | 10.65987600 |
9.63461790 | 12.12021500 |
9.63945920 | 7.63081420 |
9.64420260 | 12.40297800 |
9.66241460 | 11.51839900 |
9.68242010 | 12.04506200 |
9.69339220 | 11.00063900 |
9.69883150 | 11.71688600 |
9.71803670 | 11.10305400 |
9.75490390 | 9.49743240 |
9.76723360 | 11.16161200 |
9.76750930 | 12.39651300 |
9.79269230 | 11.68457100 |
9.80619560 | 11.13852800 |
9.81615850 | 10.74470900 |
9.84428420 | 9.55646640 |
9.85170830 | 11.04807600 |
9.87986020 | 11.07883400 |
9.89480500 | 10.36432300 |
9.89721700 | 9.25560950 |
9.92740890 | 10.29578200 |
9.95403140 | 10.79053800 |
9.98336060 | 10.01958000 |
10.01012200 | 9.29671780 |
10.01111700 | 10.84965000 |
10.02912000 | 11.48856300 |
10.03676100 | 9.44784850 |
10.03725600 | 11.57415500 |
10.06304900 | 11.15177400 |
10.09006800 | 11.56643000 |
10.09496300 | 11.01877800 |
10.10096000 | 8.81774480 |
10.12291600 | 10.67465600 |
10.12924800 | 11.15839300 |
10.13386000 | 7.75559090 |
10.14981200 | 9.20793890 |
10.15268200 | 13.01178400 |
10.17649100 | 12.07954500 |
10.17853500 | 10.69187300 |
10.18326900 | 11.91063800 |
10.21568700 | 8.88175950 |
10.23572900 | 8.79450410 |
10.25908100 | 10.08731200 |
10.26456100 | 10.02922300 |
10.27433200 | 8.83332490 |
10.33027200 | 9.74311580 |
10.36821900 | 9.02007390 |
10.37908400 | 12.19408900 |
10.37987200 | 11.12424700 |
10.38579200 | 11.17933600 |
10.39836400 | 12.60699600 |
10.40934200 | 10.69361100 |
10.43767800 | 10.92630700 |
10.45558800 | 12.84549200 |
10.47523800 | 11.79169700 |
10.50827100 | 9.46029610 |
10.52768700 | 12.68206400 |
10.53662800 | 10.83112100 |
10.54209400 | 10.56311400 |
10.54550400 | 10.37607000 |
10.54787800 | 10.31993300 |
10.55333600 | 12.56927200 |
10.55766700 | 8.18090900 |
10.58278400 | 12.48336100 |
10.59027900 | 10.14932500 |
10.63466400 | 11.86855000 |
10.63997100 | 14.68132700 |
10.64321500 | 9.52784890 |
10.65061600 | 11.02106800 |
10.65933800 | 12.16096900 |
10.66458500 | 10.42121400 |
10.67864000 | 6.66515350 |
10.70617800 | 12.78859700 |
10.74380400 | 11.33231900 |
10.75448500 | 10.60022400 |
10.77685400 | 11.29950700 |
10.78833200 | 11.46113100 |
10.79731400 | 7.99009390 |
10.81227700 | 9.78778080 |
10.81870800 | 10.76713200 |
10.82536200 | 10.99812600 |
10.82725700 | 10.41179800 |
10.85504900 | 13.06313000 |
10.89524700 | 8.68828820 |
10.89677000 | 11.24108200 |
10.90694000 | 9.38271260 |
10.93177800 | 12.18528700 |
10.93596200 | 10.94716700 |
10.93695400 | 12.25114000 |
10.95811500 | 11.59757000 |
11.02662800 | 12.20506600 |
11.03726100 | 10.78027100 |
11.06118700 | 12.01691100 |
11.09761400 | 11.74076900 |
11.09902700 | 11.79780500 |
11.11450000 | 10.76720300 |
11.13149800 | 10.56213200 |
11.17049500 | 11.46069100 |
11.18867800 | 12.32140700 |
11.19167300 | 8.55565090 |
11.20182100 | 11.44270100 |
11.23707900 | 8.67780690 |
11.25179000 | 11.03054100 |
11.27007900 | 12.04400600 |
11.33391300 | 8.36209630 |
11.35918000 | 10.03382300 |
11.36198600 | 10.35493700 |
11.36505500 | 12.03346400 |
11.36538600 | 9.74743020 |
11.36786400 | 11.96575400 |
11.43284100 | 12.92037400 |
11.45532500 | 10.29329700 |
11.45764800 | 11.58426300 |
11.48207300 | 9.46980720 |
11.49579400 | 8.28693170 |
11.52086800 | 10.98130500 |
11.60164400 | 8.54755950 |
11.62640200 | 10.23781900 |
11.63904800 | 10.63884000 |
11.66431900 | 11.12114000 |
11.67835500 | 11.23485200 |
11.70604100 | 12.34744100 |
11.94617200 | 11.76817300 |
11.95422800 | 10.48019100 |
12.01601300 | 13.79935300 |
12.02522700 | 11.32259500 |
12.06557100 | 12.06146000 |
12.08015800 | 10.62246600 |
12.26012900 | 10.28699400 |
12.38561300 | 12.52658900 |
12.59111600 | 13.43818600 |
12.77498900 | 12.96346700 |
12.97347800 | 11.53976500 |
13.65749400 | 8.70153630 |
Parag Kanade/fuzzy ants/Gauss5/gauss05Full.data
1 | -0.46551197 | 1.33961810 |
1 | -0.14154019 | 1.64673550 |
1 | -0.06147374 | 1.91002100 |
1 | -0.00960664 | 1.69592370 |
1 | 0.13522751 | 2.33715450 |
1 | 0.15816343 | 1.74101000 |
1 | 0.16902868 | 1.71459020 |
1 | 0.20321506 | 1.32309940 |
1 | 0.24094079 | 1.30698460 |
1 | 0.25245225 | 2.18395260 |
1 | 0.26993324 | 2.54833230 |
1 | 0.28680391 | 1.60524320 |
1 | 0.31923670 | 2.22768550 |
1 | 0.36114833 | 2.80097840 |
1 | 0.42440670 | 1.86344490 |
1 | 0.46037797 | 1.45327890 |
1 | 0.46098959 | 2.35558750 |
1 | 0.48936047 | 1.81261980 |
1 | 0.49341700 | 0.52432961 |
1 | 0.55795860 | 2.00690930 |
1 | 0.59517099 | 0.74266104 |
1 | 0.60128600 | 2.44774600 |
1 | 0.64249205 | 0.22137058 |
1 | 0.64603926 | 2.09861200 |
1 | 0.68936857 | 2.34366060 |
1 | 0.70125847 | 1.98814310 |
1 | 0.70954162 | 1.83408840 |
1 | 0.71271143 | 1.19116580 |
1 | 0.73828501 | 2.91576250 |
1 | 0.76121259 | 2.88777400 |
1 | 0.76300537 | 3.36236000 |
1 | 0.78715506 | 1.79988820 |
1 | 0.79603202 | 1.38376310 |
1 | 0.81552587 | 0.76593590 |
1 | 0.81671088 | 2.02359450 |
1 | 0.83646559 | 1.72929280 |
1 | 0.84905869 | 0.90959966 |
1 | 0.87280583 | 1.91850330 |
1 | 0.93911004 | 2.23771490 |
1 | 0.94658989 | 1.80993290 |
1 | 0.95071896 | 3.35937710 |
1 | 0.95477185 | 0.82422933 |
1 | 1.04753510 | 3.73589530 |
1 | 1.04835550 | 2.62226190 |
1 | 1.06632740 | 2.07724580 |
1 | 1.07197890 | 2.30511140 |
1 | 1.08416590 | 2.89828470 |
1 | 1.09173310 | 1.49658350 |
1 | 1.12682710 | 1.75417760 |
1 | 1.13086730 | 2.13536120 |
1 | 1.14284660 | 2.09725790 |
1 | 1.14935130 | 1.82271180 |
1 | 1.18193490 | 1.87386190 |
1 | 1.19003770 | 1.58358310 |
1 | 1.21018740 | 1.87969630 |
1 | 1.21811180 | 3.01110680 |
1 | 1.22779720 | 2.08081830 |
1 | 1.23354980 | 2.95731630 |
1 | 1.24485620 | 1.60172010 |
1 | 1.25554360 | 1.94720670 |
1 | 1.25973520 | 0.95874592 |
1 | 1.26011950 | 0.81798378 |
1 | 1.27152420 | 0.46185734 |
1 | 1.27494230 | 3.25923360 |
1 | 1.28887590 | 2.41629430 |
1 | 1.31946400 | 2.11809770 |
1 | 1.32665570 | 1.92493560 |
1 | 1.32694610 | 2.87835080 |
1 | 1.34589980 | 1.60470480 |
1 | 1.34715480 | 2.06603250 |
1 | 1.37535150 | 2.40899990 |
1 | 1.37934060 | 2.10897930 |
1 | 1.38729280 | 3.34550470 |
1 | 1.39799660 | 2.38291630 |
1 | 1.40017170 | 3.04820380 |
1 | 1.40547320 | 1.62152210 |
1 | 1.43123920 | 0.79191521 |
1 | 1.43548180 | 3.02712970 |
1 | 1.44101390 | 2.79862030 |
1 | 1.46412020 | 0.58155858 |
1 | 1.46461530 | 3.97915160 |
1 | 1.50553290 | 1.09901250 |
1 | 1.52866150 | 2.69439440 |
1 | 1.55340190 | 3.74144500 |
1 | 1.57359080 | 1.55710160 |
1 | 1.58566390 | 0.99127551 |
1 | 1.60834110 | 2.31547220 |
1 | 1.61675150 | 3.46413620 |
1 | 1.63157910 | 2.94477030 |
1 | 1.64858250 | 1.94597150 |
1 | 1.65589020 | 1.11547360 |
1 | 1.66033180 | 2.48016160 |
1 | 1.66570180 | 1.97626460 |
1 | 1.67408670 | 2.97515150 |
1 | 1.71093120 | 1.57160930 |
1 | 1.71729340 | 1.95422650 |
1 | 1.72459970 | 2.38705900 |
1 | 1.72800160 | 3.21686080 |
1 | 1.74073560 | 1.67705870 |
1 | 1.74466110 | 3.84404410 |
1 | 1.74791670 | 1.39134990 |
1 | 1.75073120 | 2.76959900 |
1 | 1.75674040 | 1.44477840 |
1 | 1.75912620 | 3.99522830 |
1 | 1.76102340 | 3.58775810 |
1 | 1.77369130 | 1.43998750 |
1 | 1.78265180 | 3.18278020 |
1 | 1.78823310 | 2.75586820 |
1 | 1.80480770 | 1.48943580 |
1 | 1.80657800 | 2.29801840 |
1 | 1.81057340 | 3.07288630 |
1 | 1.81324520 | 0.11900227 |
1 | 1.85811620 | 2.38161760 |
1 | 1.87359260 | 2.11200870 |
1 | 1.87715770 | 1.96065850 |
1 | 1.87918670 | 0.81713304 |
1 | 1.88668940 | 1.57613630 |
1 | 1.88810090 | 0.12698201 |
1 | 1.89805160 | 2.46405720 |
1 | 1.91165900 | 0.92031474 |
1 | 1.91635930 | 2.26590110 |
1 | 1.92170440 | 1.94293490 |
1 | 1.92406250 | 1.26831480 |
1 | 1.93349800 | 0.99443935 |
1 | 1.93666920 | 3.04261660 |
1 | 1.95720640 | 3.26896210 |
1 | 1.98793100 | 4.12877670 |
1 | 1.99071160 | 1.64890550 |
1 | 1.99301550 | 2.68464830 |
1 | 2.00115780 | 2.32360360 |
1 | 2.01070860 | 2.18020410 |
1 | 2.06509720 | 0.62687304 |
1 | 2.07609930 | 1.85641040 |
1 | 2.07659500 | 3.14121100 |
1 | 2.07970880 | 2.64448160 |
1 | 2.08286430 | 2.40266820 |
1 | 2.09488370 | 1.86480590 |
1 | 2.09856220 | 3.70264650 |
1 | 2.09949790 | 4.03821420 |
1 | 2.10236420 | 3.28141870 |
1 | 2.11024410 | 3.38057690 |
1 | 2.15225890 | 1.66258720 |
1 | 2.16136260 | 2.64167190 |
1 | 2.17609540 | 0.66759943 |
1 | 2.18054240 | 2.04423840 |
1 | 2.18426850 | 2.59546920 |
1 | 2.18914050 | 2.95823910 |
1 | 2.19639150 | 2.04300460 |
1 | 2.20202640 | 2.17670700 |
1 | 2.20468400 | 0.83693931 |
1 | 2.20525410 | 1.74999960 |
1 | 2.20669260 | 2.72082740 |
1 | 2.21098710 | 0.60017807 |
1 | 2.21469960 | 1.39912800 |
1 | 2.21745540 | 0.72364346 |
1 | 2.23041590 | 0.82961734 |
1 | 2.24735060 | 1.28753680 |
1 | 2.24903970 | 2.17344220 |
1 | 2.25198440 | 1.29699870 |
1 | 2.26046190 | 0.78269340 |
1 | 2.26880210 | 2.04607170 |
1 | 2.30821860 | 3.46557130 |
1 | 2.33728500 | 2.35864760 |
1 | 2.36166570 | 2.94318430 |
1 | 2.37269100 | 1.73059750 |
1 | 2.37839370 | 1.35358190 |
1 | 2.38160210 | 1.90073840 |
1 | 2.39673710 | 1.15694860 |
1 | 2.40968300 | 2.35955940 |
1 | 2.41934690 | 1.08563120 |
1 | 2.42345830 | 0.51782552 |
1 | 2.43925680 | 3.14634990 |
1 | 2.44003700 | 3.26188350 |
1 | 2.44993190 | 0.49230030 |
1 | 2.45826830 | 1.35888490 |
1 | 2.47695310 | 3.58142070 |
1 | 2.48443160 | 1.99845110 |
1 | 2.48451730 | 1.87370640 |
1 | 2.49321870 | 1.66146000 |
1 | 2.51610470 | 2.22988430 |
1 | 2.52167440 | 2.96074320 |
1 | 2.52291390 | 1.49298900 |
1 | 2.52707720 | -0.06387469 |
1 | 2.53539040 | 0.28615059 |
1 | 2.57812250 | 2.50850230 |
1 | 2.57890430 | 2.65642470 |
1 | 2.59130780 | 3.46783160 |
1 | 2.60177950 | 2.33292280 |
1 | 2.60836910 | 1.72191070 |
1 | 2.60906800 | 2.41048970 |
1 | 2.63288540 | 1.45875990 |
1 | 2.64696870 | 1.70147090 |
1 | 2.69200390 | 1.29565400 |
1 | 2.69798380 | 2.93142670 |
1 | 2.71265420 | 2.16194930 |
1 | 2.71761770 | 2.61848410 |
1 | 2.72034200 | 2.75907540 |
1 | 2.72880160 | 1.86016060 |
1 | 2.77297590 | 2.36490240 |
1 | 2.80417770 | 1.89472110 |
1 | 2.82975660 | 2.10584710 |
1 | 2.85681650 | 3.23983040 |
1 | 2.87080060 | 2.53653120 |
1 | 2.88845650 | 2.49839960 |
1 | 2.89401350 | 0.80718637 |
1 | 2.92700990 | 1.47051920 |
1 | 2.93324100 | 0.61062000 |
1 | 2.97223060 | 1.91058110 |
1 | 2.97728540 | 0.05260017 |
1 | 2.97737970 | 2.43822920 |
1 | 2.98051300 | 0.98434561 |
1 | 3.00561200 | 2.88339240 |
1 | 3.00897060 | 0.48283347 |
1 | 3.02618180 | 2.86961890 |
1 | 3.04006880 | 2.23519680 |
1 | 3.06476130 | 1.38678580 |
1 | 3.09581560 | 4.79770430 |
1 | 3.09743610 | 0.61238889 |
1 | 3.12340700 | 3.27566110 |
1 | 3.14002600 | 1.91049960 |
1 | 3.14019960 | 3.00888450 |
1 | 3.17433280 | 2.98995780 |
1 | 3.18087940 | 2.40854900 |
1 | 3.18322030 | 1.07038150 |
1 | 3.22764280 | 2.18078200 |
1 | 3.23720550 | 1.44137450 |
1 | 3.29520690 | 2.90163040 |
1 | 3.33879830 | 3.23653160 |
1 | 3.35624410 | 3.35958530 |
1 | 3.44164230 | 4.73574970 |
1 | 3.52192800 | 2.86513240 |
1 | 3.52492410 | 2.40565520 |
1 | 3.63961210 | 0.74341452 |
1 | 3.65258060 | 4.05964180 |
1 | 3.67734150 | 0.65264229 |
1 | 3.70898120 | 3.47495760 |
1 | 3.75704250 | 2.27892970 |
1 | 3.79908120 | 1.80310890 |
1 | 3.80792120 | 3.26049480 |
1 | 3.86355230 | 3.30653510 |
1 | 3.88267690 | 2.44348050 |
1 | 3.91058010 | 0.07306810 |
1 | 4.02758240 | 2.91107290 |
1 | 4.26109770 | 3.51507650 |
1 | 4.26540320 | 2.58627940 |
1 | 4.37722260 | 3.69395380 |
1 | 4.38629290 | 1.82723270 |
1 | 4.67363320 | 1.48535710 |
2 | 3.94355830 | 6.47395710 |
2 | 3.97391840 | 4.87866000 |
2 | 4.18739700 | 6.34885200 |
2 | 4.24071090 | 5.55185350 |
2 | 4.24365210 | 6.45412420 |
2 | 4.25518380 | 4.55644420 |
2 | 4.28524300 | 7.20716730 |
2 | 4.32994460 | 6.00003610 |
2 | 4.33192370 | 7.09367650 |
2 | 4.37355700 | 6.88269120 |
2 | 4.46409400 | 6.05818290 |
2 | 4.49067420 | 6.32926110 |
2 | 4.51153380 | 6.85352870 |
2 | 4.56599710 | 7.04864140 |
2 | 4.60231750 | 4.95853610 |
2 | 4.62348130 | 5.39071570 |
2 | 4.64450820 | 6.69985040 |
2 | 4.64904500 | 6.88495910 |
2 | 4.65841250 | 6.01528070 |
2 | 4.66655080 | 6.42825920 |
2 | 4.67306050 | 7.59424310 |
2 | 4.76372900 | 5.28356040 |
2 | 4.77552290 | 7.40746300 |
2 | 4.80762540 | 6.65894500 |
2 | 4.82763450 | 5.46445960 |
2 | 4.84792340 | 4.75686200 |
2 | 4.85657400 | 5.50381400 |
2 | 4.86225910 | 6.91700090 |
2 | 4.93637580 | 4.23195980 |
2 | 4.94390900 | 5.48754390 |
2 | 4.98892060 | 7.61144900 |
2 | 5.01650590 | 6.54753540 |
2 | 5.04197050 | 7.85286660 |
2 | 5.10227700 | 8.01646130 |
2 | 5.12885550 | 5.72556180 |
2 | 5.12964740 | 6.90234580 |
2 | 5.15532960 | 7.36587300 |
2 | 5.17303110 | 5.74274600 |
2 | 5.18206350 | 5.03849040 |
2 | 5.25604270 | 7.23015750 |
2 | 5.29819060 | 8.21814690 |
2 | 5.30112180 | 2.96571480 |
2 | 5.30196100 | 6.65044240 |
2 | 5.31459470 | 5.21750590 |
2 | 5.33619550 | 8.04356960 |
2 | 5.38039120 | 6.91763440 |
2 | 5.40785960 | 6.56722290 |
2 | 5.40994000 | 6.69154760 |
2 | 5.48501860 | 5.67204300 |
2 | 5.49653470 | 7.40854490 |
2 | 5.51921830 | 6.16971170 |
2 | 5.56473570 | 7.03218950 |
2 | 5.56487270 | 7.55897590 |
2 | 5.60151890 | 3.09949060 |
2 | 5.60358100 | 7.37902530 |
2 | 5.60998170 | 4.16380260 |
2 | 5.62068070 | 6.60873250 |
2 | 5.63459940 | 6.15316390 |
2 | 5.64294830 | 7.35420540 |
2 | 5.67240780 | 5.46370020 |
2 | 5.70923490 | 5.71517630 |
2 | 5.71460100 | 4.80898650 |
2 | 5.71820870 | 4.83594030 |
2 | 5.72450000 | 5.25972780 |
2 | 5.73850450 | 5.42471410 |
2 | 5.77026500 | 6.74009030 |
2 | 5.81107380 | 5.47122920 |
2 | 5.83126620 | 4.54184770 |
2 | 5.83198380 | 5.99319780 |
2 | 5.85787990 | 6.09342090 |
2 | 5.88532760 | 6.02345150 |
2 | 5.91363800 | 6.54156470 |
2 | 5.92674080 | 5.71333250 |
2 | 6.01807400 | 6.61400250 |
2 | 6.01847440 | 6.04561100 |
2 | 6.04122250 | 5.22394930 |
2 | 6.04854960 | 6.06328950 |
2 | 6.05181170 | 5.00807640 |
2 | 6.06648940 | 6.14140220 |
2 | 6.09495840 | 6.12569700 |
2 | 6.10139500 | 6.87509520 |
2 | 6.12351310 | 5.69770350 |
2 | 6.13942660 | 5.11012500 |
2 | 6.16735070 | 5.73108400 |
2 | 6.19581790 | 6.19862080 |
2 | 6.22701680 | 7.33421700 |
2 | 6.23192510 | 6.51588610 |
2 | 6.23274070 | 6.07263650 |
2 | 6.27462750 | 5.69395300 |
2 | 6.28022480 | 3.34928740 |
2 | 6.30797300 | 5.57445750 |
2 | 6.40891240 | 5.16520540 |
2 | 6.42060610 | 4.19796540 |
2 | 6.43322370 | 6.45805660 |
2 | 6.44136690 | 5.09146360 |
2 | 6.46967490 | 5.85811280 |
2 | 6.48306340 | 8.25081740 |
2 | 6.48641110 | 4.72902160 |
2 | 6.49282010 | 7.74602800 |
2 | 6.49526610 | 4.12129000 |
2 | 6.49909390 | 7.01082130 |
2 | 6.51460560 | 6.64307510 |
2 | 6.55219720 | 5.32859600 |
2 | 6.57416700 | 6.06793980 |
2 | 6.58116560 | 4.00798880 |
2 | 6.58182580 | 6.10192730 |
2 | 6.60913670 | 5.57521110 |
2 | 6.62468490 | 5.53650280 |
2 | 6.66421430 | 5.44580030 |
2 | 6.66910180 | 7.79154550 |
2 | 6.70029220 | 7.63838790 |
2 | 6.71206150 | 5.79403900 |
2 | 6.76440480 | 5.88082880 |
2 | 6.79348260 | 4.49508360 |
2 | 6.96845940 | 7.00534870 |
2 | 6.97144060 | 4.27568510 |
2 | 6.97887120 | 6.94657670 |
2 | 7.00296760 | 4.97715130 |
2 | 7.02476900 | 3.98307760 |
2 | 7.10895500 | 7.00220740 |
2 | 7.16675020 | 4.19662350 |
2 | 7.20085130 | 8.28069870 |
2 | 7.22378650 | 6.32870310 |
2 | 7.31577010 | 4.59509450 |
2 | 7.36067680 | 9.10867310 |
2 | 7.58444910 | 6.86571300 |
2 | 7.67335250 | 4.62301640 |
2 | 7.68221600 | 6.42338430 |
2 | 7.68562080 | 6.31015700 |
2 | 7.69069460 | 4.32890800 |
2 | 7.72974570 | 7.15472810 |
2 | 10.38220400 | 6.69533970 |
3 | -0.53802474 | 9.86702580 |
3 | -0.50977026 | 9.53528050 |
3 | -0.43584458 | 10.83129500 |
3 | -0.04882059 | 8.95037180 |
3 | 0.05835481 | 10.55733200 |
3 | 0.10288324 | 9.59351740 |
3 | 0.17447523 | 8.05402150 |
3 | 0.19810974 | 9.12201000 |
3 | 0.21934452 | 9.07843940 |
3 | 0.23439904 | 9.84479100 |
3 | 0.26788561 | 10.20955800 |
3 | 0.47250581 | 8.61231020 |
3 | 0.51426980 | 8.46140090 |
3 | 0.54996643 | 9.27683580 |
3 | 0.55418227 | 8.88493900 |
3 | 0.60602417 | 10.93646800 |
3 | 0.63375978 | 10.20699500 |
3 | 0.63673117 | 8.78448430 |
3 | 0.72741870 | 9.09766520 |
3 | 0.78672127 | 8.61717250 |
3 | 0.84069897 | 8.76506070 |
3 | 0.88570100 | 10.13743100 |
3 | 0.91613686 | 10.23333600 |
3 | 0.92942006 | 8.57136260 |
3 | 0.95596944 | 10.53530900 |
3 | 0.96854857 | 9.80381840 |
3 | 1.01456280 | 8.28791640 |
3 | 1.01779270 | 10.84433000 |
3 | 1.02156340 | 10.76533100 |
3 | 1.03196560 | 9.66837340 |
3 | 1.06829630 | 9.17620610 |
3 | 1.07974110 | 10.49751800 |
3 | 1.08903630 | 9.72974150 |
3 | 1.10201390 | 9.11047530 |
3 | 1.11119650 | 10.97406800 |
3 | 1.11187620 | 10.73005100 |
3 | 1.11902410 | 10.62602100 |
3 | 1.12900530 | 10.70811300 |
3 | 1.15670380 | 8.98593880 |
3 | 1.16427170 | 10.86776000 |
3 | 1.18772870 | 9.02772250 |
3 | 1.24177610 | 9.92394220 |
3 | 1.26972330 | 10.58267000 |
3 | 1.28053590 | 10.83958700 |
3 | 1.31503300 | 7.80067800 |
3 | 1.33748480 | 9.88473050 |
3 | 1.34367870 | 11.16094600 |
3 | 1.36016050 | 9.92205470 |
3 | 1.38043410 | 9.54642060 |
3 | 1.41957600 | 8.56118380 |
3 | 1.44766000 | 9.79764190 |
3 | 1.44978560 | 10.99242200 |
3 | 1.45159130 | 9.24636600 |
3 | 1.46291700 | 9.06834910 |
3 | 1.46937900 | 11.27737100 |
3 | 1.47663500 | 9.70492070 |
3 | 1.47897680 | 8.75870350 |
3 | 1.48648380 | 7.83678240 |
3 | 1.49434700 | 8.41880090 |
3 | 1.49775780 | 10.23531600 |
3 | 1.51504080 | 11.46943800 |
3 | 1.54653760 | 10.10279700 |
3 | 1.54817560 | 10.50012400 |
3 | 1.56238190 | 11.11233000 |
3 | 1.56575230 | 9.86530650 |
3 | 1.56805180 | 9.79929020 |
3 | 1.57879060 | 9.47959820 |
3 | 1.58071100 | 10.63411500 |
3 | 1.58827760 | 11.15466100 |
3 | 1.61545530 | 9.55612270 |
3 | 1.62402770 | 8.15133740 |
3 | 1.62710070 | 9.95947450 |
3 | 1.64236540 | 9.52075910 |
3 | 1.65322140 | 8.92139720 |
3 | 1.67089710 | 9.06478230 |
3 | 1.68161090 | 10.30733200 |
3 | 1.68314950 | 10.75388100 |
3 | 1.69092340 | 8.30567430 |
3 | 1.69448600 | 8.40313090 |
3 | 1.70295680 | 8.78520890 |
3 | 1.72092450 | 11.16000900 |
3 | 1.75544750 | 9.56356250 |
3 | 1.75611050 | 9.14866940 |
3 | 1.75916440 | 11.05389900 |
3 | 1.78160410 | 11.75470400 |
3 | 1.78766310 | 10.69221500 |
3 | 1.82344220 | 9.72124790 |
3 | 1.82620620 | 10.72714200 |
3 | 1.82886270 | 10.67386400 |
3 | 1.82977930 | 10.45891600 |
3 | 1.83260300 | 11.07471100 |
3 | 1.83536280 | 9.08031440 |
3 | 1.85562350 | 9.61858110 |
3 | 1.85630450 | 10.95031700 |
3 | 1.85675330 | 10.23094900 |
3 | 1.87558110 | 9.79540000 |
3 | 1.88087730 | 11.26157900 |
3 | 1.88329880 | 8.97817840 |
3 | 1.88430750 | 9.80275410 |
3 | 1.89055870 | 12.46976600 |
3 | 1.89752820 | 10.28635000 |
3 | 1.91098330 | 10.30122500 |
3 | 1.91444480 | 8.97405900 |
3 | 1.91650830 | 11.67635200 |
3 | 1.92091760 | 9.71317550 |
3 | 1.97816590 | 11.66490100 |
3 | 1.97880630 | 7.96053110 |
3 | 1.97957920 | 10.60428500 |
3 | 1.99889770 | 9.38730000 |
3 | 2.00857470 | 10.70364400 |
3 | 2.01968670 | 12.96920800 |
3 | 2.02561900 | 10.08143700 |
3 | 2.05346190 | 10.70522900 |
3 | 2.05475860 | 10.30522800 |
3 | 2.05475860 | 10.81687100 |
3 | 2.07553920 | 8.35520010 |
3 | 2.07556900 | 9.53284230 |
3 | 2.10667150 | 8.93102270 |
3 | 2.12194210 | 8.07869520 |
3 | 2.13253750 | 10.27866700 |
3 | 2.13464690 | 9.79297840 |
3 | 2.13772280 | 9.31410140 |
3 | 2.14245180 | 9.06217820 |
3 | 2.16372800 | 8.01264140 |
3 | 2.17899090 | 11.54517900 |
3 | 2.19104960 | 12.74184000 |
3 | 2.19264800 | 11.56782800 |
3 | 2.21200420 | 9.51493550 |
3 | 2.22368020 | 9.70260450 |
3 | 2.23535900 | 11.29138600 |
3 | 2.25048880 | 10.25527500 |
3 | 2.28499440 | 9.66707670 |
3 | 2.29362360 | 10.04094000 |
3 | 2.29439620 | 8.60983420 |
3 | 2.29729520 | 11.04440500 |
3 | 2.31597750 | 8.80252050 |
3 | 2.31833880 | 9.71240520 |
3 | 2.33127170 | 9.19450210 |
3 | 2.33327880 | 9.85855600 |
3 | 2.34367510 | 10.27882500 |
3 | 2.35101980 | 9.44433780 |
3 | 2.35368280 | 9.69186110 |
3 | 2.37624870 | 10.00117800 |
3 | 2.38733310 | 9.94496600 |
3 | 2.40180790 | 11.33634400 |
3 | 2.40499310 | 10.35497400 |
3 | 2.40693120 | 10.22960600 |
3 | 2.41459460 | 11.86536700 |
3 | 2.42981750 | 10.17701300 |
3 | 2.43040130 | 11.29583100 |
3 | 2.43505260 | 9.28143430 |
3 | 2.43652240 | 10.60742200 |
3 | 2.43859720 | 10.11362900 |
3 | 2.43956950 | 10.28759400 |
3 | 2.44338670 | 9.56722360 |
3 | 2.45810510 | 9.30052690 |
3 | 2.48495800 | 9.61228170 |
3 | 2.48551370 | 9.74309070 |
3 | 2.49617560 | 9.08527480 |
3 | 2.49618150 | 9.97747920 |
3 | 2.50603670 | 10.62650200 |
3 | 2.51112770 | 10.04812500 |
3 | 2.53530220 | 11.00603700 |
3 | 2.54774550 | 9.52181910 |
3 | 2.56467230 | 8.57532880 |
3 | 2.60695660 | 9.49283340 |
3 | 2.61066100 | 9.23332450 |
3 | 2.61106350 | 11.16140900 |
3 | 2.61565990 | 12.24306000 |
3 | 2.61573630 | 9.62476480 |
3 | 2.62311430 | 11.46785100 |
3 | 2.63034990 | 11.16658500 |
3 | 2.64793630 | 9.49270110 |
3 | 2.64984800 | 9.99999970 |
3 | 2.67268460 | 11.19640400 |
3 | 2.69565560 | 11.33803100 |
3 | 2.75079750 | 11.35678000 |
3 | 2.80391130 | 10.38172800 |
3 | 2.86698840 | 11.92690800 |
3 | 2.89529580 | 9.23670160 |
3 | 2.93233230 | 9.42533600 |
3 | 2.94698180 | 10.62292600 |
3 | 2.95247540 | 9.57839520 |
3 | 2.97818640 | 10.54284200 |
3 | 2.98711940 | 8.43961850 |
3 | 3.03198230 | 10.89015400 |
3 | 3.05493660 | 9.07937810 |
3 | 3.08486570 | 10.44131700 |
3 | 3.09086910 | 10.08045400 |
3 | 3.12991540 | 9.45931510 |
3 | 3.16627520 | 11.24110600 |
3 | 3.18161550 | 8.56736250 |
3 | 3.20627950 | 9.30813850 |
3 | 3.24247530 | 10.28896000 |
3 | 3.24252950 | 10.15812300 |
3 | 3.29064670 | 11.07275800 |
3 | 3.29731200 | 9.84727140 |
3 | 3.29751450 | 10.75749900 |
3 | 3.30620860 | 10.42134600 |
3 | 3.33235060 | 10.51309200 |
3 | 3.34481240 | 9.13470460 |
3 | 3.34749520 | 10.53669500 |
3 | 3.44947090 | 11.90089200 |
3 | 3.49865710 | 10.60088500 |
3 | 3.51300760 | 11.13617800 |
3 | 3.52758750 | 11.16753500 |
3 | 3.54582030 | 10.82713200 |
3 | 3.63572170 | 11.77784300 |
3 | 3.64186710 | 10.28076500 |
3 | 3.64262700 | 9.75089300 |
3 | 3.76649600 | 10.25604700 |
3 | 3.84954880 | 8.07932180 |
3 | 4.10374540 | 10.81806500 |
3 | 4.22508220 | 12.60704200 |
3 | 4.38131550 | 10.09231700 |
3 | 4.63405100 | 11.15266000 |
3 | 5.02071230 | 10.89582300 |
4 | 7.29517410 | 4.95038300 |
4 | 7.64268890 | 3.02642500 |
4 | 8.37832840 | 1.66775860 |
4 | 8.66108260 | 1.28584310 |
4 | 8.76586670 | 1.25023720 |
4 | 8.87351890 | 3.00700310 |
4 | 8.92028780 | 2.37946150 |
4 | 9.21573760 | 4.04563490 |
4 | 9.28283710 | 4.76142670 |
4 | 9.34161730 | 4.73429670 |
4 | 9.37286700 | 4.07157300 |
4 | 9.37933440 | 3.42884820 |
4 | 9.44715130 | 1.02909710 |
4 | 9.55074290 | 3.15201080 |
4 | 9.57965250 | 2.31375530 |
4 | 9.65924290 | 1.90478360 |
4 | 9.70270510 | 2.39146600 |
4 | 9.70668260 | 2.85758720 |
4 | 9.76651980 | 3.65349960 |
4 | 9.81668260 | 4.06812080 |
4 | 9.83092360 | 3.42345370 |
4 | 9.87058370 | 0.95144045 |
4 | 9.87065650 | 1.49842450 |
4 | 9.87616540 | 3.52875290 |
4 | 9.90859480 | 0.91336718 |
4 | 9.91639150 | 4.49805260 |
4 | 9.93212930 | 4.68844650 |
4 | 9.96357740 | 4.15191530 |
4 | 9.97741310 | 0.71576669 |
4 | 10.00538600 | 3.97253390 |
4 | 10.03108000 | 2.18997090 |
4 | 10.03130300 | 4.32228250 |
4 | 10.03259000 | 4.14975090 |
4 | 10.03428000 | 4.04539320 |
4 | 10.08044700 | 3.36980570 |
4 | 10.08351700 | 5.31544110 |
4 | 10.10949800 | 0.69493770 |
4 | 10.12784000 | 2.10773240 |
4 | 10.14332800 | 4.29328660 |
4 | 10.15352700 | 0.14745808 |
4 | 10.18516500 | 4.68407520 |
4 | 10.18610800 | 2.00950290 |
4 | 10.21848600 | 0.86943064 |
4 | 10.22578800 | 3.64461980 |
4 | 10.23058600 | 2.56652140 |
4 | 10.24244600 | 2.08428290 |
4 | 10.25005800 | 3.66749810 |
4 | 10.25651800 | 4.10251020 |
4 | 10.26568300 | 1.00452720 |
4 | 10.28218900 | 2.54014490 |
4 | 10.30209900 | 2.60527380 |
4 | 10.30866800 | 5.06128290 |
4 | 10.35145400 | 3.96488170 |
4 | 10.35328700 | 1.92069180 |
4 | 10.36641000 | 1.04618570 |
4 | 10.37211900 | 3.01345330 |
4 | 10.37387400 | 3.34794110 |
4 | 10.38586300 | 4.87498410 |
4 | 10.40975800 | 1.47702490 |
4 | 10.42930200 | 3.18560190 |
4 | 10.58473700 | 4.51938660 |
4 | 10.60713700 | 2.78150470 |
4 | 10.61288300 | 0.24133727 |
4 | 10.62282000 | 2.85380720 |
4 | 10.62670900 | 4.31761610 |
4 | 10.63141600 | 3.62342330 |
4 | 10.63782500 | 0.13733134 |
4 | 10.65045900 | 4.67649570 |
4 | 10.65138000 | 4.44121490 |
4 | 10.66319100 | 4.15626830 |
4 | 10.67136400 | 2.17268420 |
4 | 10.67655100 | 2.34284280 |
4 | 10.68966800 | 0.11834644 |
4 | 10.69309600 | 4.03254720 |
4 | 10.69634300 | 3.51755370 |
4 | 10.69959300 | 1.87670870 |
4 | 10.70364500 | 3.63129500 |
4 | 10.79568600 | 1.77216860 |
4 | 10.80954200 | 5.56426340 |
4 | 10.82584700 | 2.13711490 |
4 | 10.84278600 | 3.39047740 |
4 | 10.84874000 | 5.35138590 |
4 | 10.86028800 | 5.47849070 |
4 | 10.86037000 | 1.85849660 |
4 | 10.86917100 | 4.23074230 |
4 | 10.87205500 | 3.07491120 |
4 | 10.87257000 | 0.23464118 |
4 | 10.91078800 | 4.26901910 |
4 | 10.92863400 | 2.63593660 |
4 | 10.97033500 | 2.82427890 |
4 | 11.03666100 | 1.70051580 |
4 | 11.04934200 | 2.76640640 |
4 | 11.06016600 | 3.20088330 |
4 | 11.06081400 | 3.99441140 |
4 | 11.06851100 | 3.95114850 |
4 | 11.07547500 | 2.16238100 |
4 | 11.12106900 | 3.02425300 |
4 | 11.13520400 | 3.24728770 |
4 | 11.13785300 | 2.00208790 |
4 | 11.17317400 | 3.14803610 |
4 | 11.18638600 | 6.22516560 |
4 | 11.20099100 | 1.19015140 |
4 | 11.20883900 | 3.42794410 |
4 | 11.21894800 | 2.78643090 |
4 | 11.22180700 | 2.07195140 |
4 | 11.24615200 | 4.43557960 |
4 | 11.26246100 | 1.95785590 |
4 | 11.26868200 | 2.62892100 |
4 | 11.29046500 | 2.28748380 |
4 | 11.29332600 | 3.10607900 |
4 | 11.30113300 | 3.17774770 |
4 | 11.30288200 | 2.21218430 |
4 | 11.30746500 | 5.37940840 |
4 | 11.31033800 | 2.07920170 |
4 | 11.37790300 | 2.56282890 |
4 | 11.43262800 | 2.22257980 |
4 | 11.43947300 | 2.38576500 |
4 | 11.46754700 | 3.77819260 |
4 | 11.47712100 | 2.65629050 |
4 | 11.50119400 | 1.34805320 |
4 | 11.53382400 | 3.91389830 |
4 | 11.54175000 | 1.91726030 |
4 | 11.54858900 | 3.42249720 |
4 | 11.55128100 | 4.03482200 |
4 | 11.58000500 | 1.42493230 |
4 | 11.62293600 | 1.63509770 |
4 | 11.63570300 | 4.08117290 |
4 | 11.63576600 | -0.31603070 |
4 | 11.63690600 | 4.14853350 |
4 | 11.64069300 | 4.00507650 |
4 | 11.64464600 | 1.63983550 |
4 | 11.65989500 | 2.75988020 |
4 | 11.66710000 | 2.08519330 |
4 | 11.67212200 | 0.82188274 |
4 | 11.79065500 | 2.99906140 |
4 | 11.79146600 | 2.99766490 |
4 | 11.82391500 | 4.50216090 |
4 | 11.83695800 | 1.77045500 |
4 | 11.84902300 | 4.04107940 |
4 | 11.87579500 | 2.49994310 |
4 | 11.90613300 | 4.81234120 |
4 | 11.92998700 | 5.01715490 |
4 | 11.94321800 | 3.50299350 |
4 | 11.94416800 | 3.88805960 |
4 | 11.97362800 | 4.39756760 |
4 | 11.97788300 | 2.66685530 |
4 | 11.98689100 | 2.31567030 |
4 | 11.99081600 | 5.09192670 |
4 | 11.99801800 | 4.56908950 |
4 | 12.00298200 | 1.94237290 |
4 | 12.00316700 | 2.17838480 |
4 | 12.02293000 | 2.73944570 |
4 | 12.04831300 | 4.78784470 |
4 | 12.04935000 | 2.91964680 |
4 | 12.10296400 | 5.93536230 |
4 | 12.10411700 | 1.35530440 |
4 | 12.11240800 | 3.44293000 |
4 | 12.11691300 | 4.70406270 |
4 | 12.11736300 | 4.43799220 |
4 | 12.13297500 | 3.72159310 |
4 | 12.14842100 | 2.84191770 |
4 | 12.15702300 | 2.31892640 |
4 | 12.20992600 | 5.06471420 |
4 | 12.23174500 | 3.10598390 |
4 | 12.24324200 | 4.66598260 |
4 | 12.27524400 | 2.45092420 |
4 | 12.28363300 | 2.06558290 |
4 | 12.31873000 | 2.57653720 |
4 | 12.36022800 | 0.30690857 |
4 | 12.39010700 | 4.48246780 |
4 | 12.39101900 | 4.11104480 |
4 | 12.41839700 | 2.60166070 |
4 | 12.43804500 | 4.29621460 |
4 | 12.50262800 | 1.91294910 |
4 | 12.53067800 | 4.27091700 |
4 | 12.53177400 | 2.51077500 |
4 | 12.53548400 | 5.34961560 |
4 | 12.55590600 | 1.88128220 |
4 | 12.57487900 | 3.14838260 |
4 | 12.57704700 | 5.57486740 |
4 | 12.69811900 | 4.56844720 |
4 | 12.71266600 | 1.86983480 |
4 | 12.75471600 | 1.88424410 |
4 | 12.84054600 | 4.17589510 |
4 | 12.87563700 | 4.58237630 |
4 | 12.91383900 | 3.72360130 |
4 | 12.92143500 | 3.99211200 |
4 | 12.95051000 | 4.50726300 |
4 | 12.96883700 | 2.81026580 |
4 | 13.37212300 | 4.10562440 |
4 | 13.57001500 | 6.35204170 |
4 | 13.87186200 | 1.28395610 |
5 | 6.77625400 | 8.93326230 |
5 | 6.82853500 | 10.75476800 |
5 | 6.99850990 | 12.00625500 |
5 | 7.03320130 | 12.17173900 |
5 | 7.34958640 | 11.34462900 |
5 | 7.36433010 | 10.30722100 |
5 | 7.63086440 | 11.72930800 |
5 | 7.67429150 | 11.42227600 |
5 | 7.67659120 | 11.95716300 |
5 | 7.72421250 | 11.60357600 |
5 | 7.73093580 | 11.28785800 |
5 | 7.82011350 | 10.31780300 |
5 | 8.04405000 | 11.32677600 |
5 | 8.28438950 | 12.22446700 |
5 | 8.33380870 | 13.31556100 |
5 | 8.38648740 | 12.43029300 |
5 | 8.39185100 | 9.66884460 |
5 | 8.41343420 | 12.81313400 |
5 | 8.48875950 | 11.33832500 |
5 | 8.49273750 | 11.03376200 |
5 | 8.56167170 | 12.04155900 |
5 | 8.67928500 | 11.29584400 |
5 | 8.69809170 | 9.83322040 |
5 | 8.72482460 | 10.81320900 |
5 | 8.73837900 | 13.51393500 |
5 | 8.74470180 | 13.61214400 |
5 | 8.75924500 | 13.42558100 |
5 | 8.81743790 | 10.38709600 |
5 | 8.83182740 | 13.13231400 |
5 | 8.84119810 | 11.77572400 |
5 | 8.86576390 | 8.18619000 |
5 | 8.90450350 | 9.62928520 |
5 | 8.90605490 | 10.43295500 |
5 | 8.92366520 | 9.50858180 |
5 | 8.92461850 | 11.50141400 |
5 | 8.93719790 | 11.53834300 |
5 | 8.94241620 | 10.66978600 |
5 | 8.94366110 | 10.42219800 |
5 | 8.95438400 | 9.62107450 |
5 | 9.00487450 | 11.64730100 |
5 | 9.00932750 | 11.15508100 |
5 | 9.04954750 | 11.48330000 |
5 | 9.06275560 | 11.23776000 |
5 | 9.08488060 | 11.07371900 |
5 | 9.09882630 | 11.65037300 |
5 | 9.12191410 | 10.02935100 |
5 | 9.13666160 | 12.97184800 |
5 | 9.14859280 | 11.23678600 |
5 | 9.15599420 | 9.92740050 |
5 | 9.17842650 | 9.63470770 |
5 | 9.20071630 | 13.45879200 |
5 | 9.20678430 | 11.87802700 |
5 | 9.21262330 | 10.62747800 |
5 | 9.27771000 | 11.30113800 |
5 | 9.33949500 | 15.14724700 |
5 | 9.34216130 | 11.48929200 |
5 | 9.35773140 | 10.46045300 |
5 | 9.37242510 | 10.83847200 |
5 | 9.39966490 | 8.71695000 |
5 | 9.40027730 | 7.69134830 |
5 | 9.43249590 | 8.59230880 |
5 | 9.43916380 | 11.27331100 |
5 | 9.47467300 | 9.11875190 |
5 | 9.47830740 | 9.74695740 |
5 | 9.48281740 | 11.83558400 |
5 | 9.50827820 | 10.96041000 |
5 | 9.51317460 | 9.12711080 |
5 | 9.52261180 | 13.37399000 |
5 | 9.54111150 | 11.97061500 |
5 | 9.54785290 | 13.08466300 |
5 | 9.55937760 | 11.46716800 |
5 | 9.56043010 | 9.62510630 |
5 | 9.56210660 | 8.61510740 |
5 | 9.56398230 | 8.65702010 |
5 | 9.57275430 | 9.22845420 |
5 | 9.59992340 | 12.38279300 |
5 | 9.60973830 | 9.67483190 |
5 | 9.63354210 | 10.65987600 |
5 | 9.63461790 | 12.12021500 |
5 | 9.63945920 | 7.63081420 |
5 | 9.64420260 | 12.40297800 |
5 | 9.66241460 | 11.51839900 |
5 | 9.68242010 | 12.04506200 |
5 | 9.69339220 | 11.00063900 |
5 | 9.69883150 | 11.71688600 |
5 | 9.71803670 | 11.10305400 |
5 | 9.75490390 | 9.49743240 |
5 | 9.76723360 | 11.16161200 |
5 | 9.76750930 | 12.39651300 |
5 | 9.79269230 | 11.68457100 |
5 | 9.80619560 | 11.13852800 |
5 | 9.81615850 | 10.74470900 |
5 | 9.84428420 | 9.55646640 |
5 | 9.85170830 | 11.04807600 |
5 | 9.87986020 | 11.07883400 |
5 | 9.89480500 | 10.36432300 |
5 | 9.89721700 | 9.25560950 |
5 | 9.92740890 | 10.29578200 |
5 | 9.95403140 | 10.79053800 |
5 | 9.98336060 | 10.01958000 |
5 | 10.01012200 | 9.29671780 |
5 | 10.01111700 | 10.84965000 |
5 | 10.02912000 | 11.48856300 |
5 | 10.03676100 | 9.44784850 |
5 | 10.03725600 | 11.57415500 |
5 | 10.06304900 | 11.15177400 |
5 | 10.09006800 | 11.56643000 |
5 | 10.09496300 | 11.01877800 |
5 | 10.10096000 | 8.81774480 |
5 | 10.12291600 | 10.67465600 |
5 | 10.12924800 | 11.15839300 |
5 | 10.13386000 | 7.75559090 |
5 | 10.14981200 | 9.20793890 |
5 | 10.15268200 | 13.01178400 |
5 | 10.17649100 | 12.07954500 |
5 | 10.17853500 | 10.69187300 |
5 | 10.18326900 | 11.91063800 |
5 | 10.21568700 | 8.88175950 |
5 | 10.23572900 | 8.79450410 |
5 | 10.25908100 | 10.08731200 |
5 | 10.26456100 | 10.02922300 |
5 | 10.27433200 | 8.83332490 |
5 | 10.33027200 | 9.74311580 |
5 | 10.36821900 | 9.02007390 |
5 | 10.37908400 | 12.19408900 |
5 | 10.37987200 | 11.12424700 |
5 | 10.38579200 | 11.17933600 |
5 | 10.39836400 | 12.60699600 |
5 | 10.40934200 | 10.69361100 |
5 | 10.43767800 | 10.92630700 |
5 | 10.45558800 | 12.84549200 |
5 | 10.47523800 | 11.79169700 |
5 | 10.50827100 | 9.46029610 |
5 | 10.52768700 | 12.68206400 |
5 | 10.53662800 | 10.83112100 |
5 | 10.54209400 | 10.56311400 |
5 | 10.54550400 | 10.37607000 |
5 | 10.54787800 | 10.31993300 |
5 | 10.55333600 | 12.56927200 |
5 | 10.55766700 | 8.18090900 |
5 | 10.58278400 | 12.48336100 |
5 | 10.59027900 | 10.14932500 |
5 | 10.63466400 | 11.86855000 |
5 | 10.63997100 | 14.68132700 |
5 | 10.64321500 | 9.52784890 |
5 | 10.65061600 | 11.02106800 |
5 | 10.65933800 | 12.16096900 |
5 | 10.66458500 | 10.42121400 |
5 | 10.67864000 | 6.66515350 |
5 | 10.70617800 | 12.78859700 |
5 | 10.74380400 | 11.33231900 |
5 | 10.75448500 | 10.60022400 |
5 | 10.77685400 | 11.29950700 |
5 | 10.78833200 | 11.46113100 |
5 | 10.79731400 | 7.99009390 |
5 | 10.81227700 | 9.78778080 |
5 | 10.81870800 | 10.76713200 |
5 | 10.82536200 | 10.99812600 |
5 | 10.82725700 | 10.41179800 |
5 | 10.85504900 | 13.06313000 |
5 | 10.89524700 | 8.68828820 |
5 | 10.89677000 | 11.24108200 |
5 | 10.90694000 | 9.38271260 |
5 | 10.93177800 | 12.18528700 |
5 | 10.93596200 | 10.94716700 |
5 | 10.93695400 | 12.25114000 |
5 | 10.95811500 | 11.59757000 |
5 | 11.02662800 | 12.20506600 |
5 | 11.03726100 | 10.78027100 |
5 | 11.06118700 | 12.01691100 |
5 | 11.09761400 | 11.74076900 |
5 | 11.09902700 | 11.79780500 |
5 | 11.11450000 | 10.76720300 |
5 | 11.13149800 | 10.56213200 |
5 | 11.17049500 | 11.46069100 |
5 | 11.18867800 | 12.32140700 |
5 | 11.19167300 | 8.55565090 |
5 | 11.20182100 | 11.44270100 |
5 | 11.23707900 | 8.67780690 |
5 | 11.25179000 | 11.03054100 |
5 | 11.27007900 | 12.04400600 |
5 | 11.33391300 | 8.36209630 |
5 | 11.35918000 | 10.03382300 |
5 | 11.36198600 | 10.35493700 |
5 | 11.36505500 | 12.03346400 |
5 | 11.36538600 | 9.74743020 |
5 | 11.36786400 | 11.96575400 |
5 | 11.43284100 | 12.92037400 |
5 | 11.45532500 | 10.29329700 |
5 | 11.45764800 | 11.58426300 |
5 | 11.48207300 | 9.46980720 |
5 | 11.49579400 | 8.28693170 |
5 | 11.52086800 | 10.98130500 |
5 | 11.60164400 | 8.54755950 |
5 | 11.62640200 | 10.23781900 |
5 | 11.63904800 | 10.63884000 |
5 | 11.66431900 | 11.12114000 |
5 | 11.67835500 | 11.23485200 |
5 | 11.70604100 | 12.34744100 |
5 | 11.94617200 | 11.76817300 |
5 | 11.95422800 | 10.48019100 |
5 | 12.01601300 | 13.79935300 |
5 | 12.02522700 | 11.32259500 |
5 | 12.06557100 | 12.06146000 |
5 | 12.08015800 | 10.62246600 |
5 | 12.26012900 | 10.28699400 |
5 | 12.38561300 | 12.52658900 |
5 | 12.59111600 | 13.43818600 |
5 | 12.77498900 | 12.96346700 |
5 | 12.97347800 | 11.53976500 |
5 | 13.65749400 | 8.70153630 |
Parag Kanade/fuzzy ants/Gauss5/headerStatic.h
/********************************************************************//* Ant Class parameters *//* SPEED # amplitude of moves [1,10] *//* P direction Probability to move in the same direction [.5,1] *//* Max carry : Maximum object carrying time [20,200] *//* P load Probability to pick up a single object [0.4,0.8] *//* P destroy probability to destroy a heap of two objects [0,0.6] *//* T remove min. dissimilarity necessary for removing an object *//* from a heap [.1,.2] *//* T create max dissimilarity permitted for creating a heap[.05,.2]*//********************************************************************/ #include <stdio.h>#include <math.h>#include <string.h>#include<stdlib.h>#include <ctype.h>#include <time.h>#define MAXANTS 334#define MAXDATA 1000#define MAXANTSFORHEAPS 90#define MAXITERATIONS 1000#define MAXROWS 64#define MAXCOLS 64#define EXPRUN 5#define Tremove 1.50#define Tcreate 0.5#define Pdrop 0.2#define Pdestroy 0.3#define Pload 0.3#define normalize 0#define EntireHeaps 1#define TcreateForHeaps 0.22#define features 2#define filename "gauss05"#define errThresh 0.1#define dataDump 1#define maxDist 0#define INITIALOBJECTS 75#define OBJINC 10/* some type definitions to make C code a little more readable */#define TRUE 1#define FALSE 0#define n MAXDATA /* number of input vectors */#define s features /* number of features */#define c 5 /* number of clusters */#define TOTRUNS 1 /* number of V's to write out */#define false 0#define true 1#define maha 0#define square 0extern int count;int debugLevel=0;/* To debug the code and verify the correctness of algorithms*/int currHeapCount=0;typedef int BOOLEAN;typedef short TYPE_IN_DATA; /* Type of input binary data */typedef float feature[s]; /* Type of each input; made up of input features */typedef float irisData[s];typedef feature objects[MAXDATA]; /* Type of array holding all inputs */typedef feature center[MAXDATA]; /* Type of array holding cluster centers */typedef float matrix[MAXDATA][MAXDATA];/* Type of the matrix containing membership grades */typedef struct Heap {float Dmax;//maximum dissimilar distanceirisData Ocenter;//center objectfloat Dmean;//mean of the distance between the center and all the objectsirisData Odissim;//most dissimilar objectint x;//x position on the boardint y;//y position on the boardint count;//number of objects in the heapsint disPosition;//most dissimilar objectint objects[MAXDATA];int objCount;}heap;typedef struct Ant{int x;int y;int carrying;int speed;int dir;irisData data;}ant;float orgData[n][s+1];float fcmData[MAXDATA][n][s];int clsCenCount[MAXDATA];int currentRow=0;int currentAntCount=0;int updateAfter=50;int heapSum=0;int minAnts=3;int rowMin=5;typedef struct HeapInfo{int total;int classObj[c];} heapInfo;/*heapInfo info[MAXDATA];*//********************************************************************//***Function decelarations*//********************************************************************//***For ant based algorithm*/void readInput();float computeDistance();float computeDistanceBetween2(irisData a,irisData b);float findMax(float *distance);float value(irisData a);int found(int a , int b);void initialise(int flag);int findObject(int a,int b);void initialiseAnts(int flag);void moveNext(ant* a,int flag);void computeHeapParameters(heap* data,int flag);void pickObject1(ant *a,int position,int flag);void pickObject2(ant *a , int position,int flag);void pickObjectn(ant *a,int position,int flag);void pick(ant *a,int flag);void dropObject(ant* a,int flag);int findInNewheaps(irisData object);void dropObject1(ant* a, int position,int flag);void drop(ant* a,int flag);void move(ant* a,int flag);void iterate(int flag);void dropFinal(int flag);int partition(heap a[], int low,int high);void quickSort( heap A[], int low,int high ) ;void writeClusterInformation(int flag);void initialiseNewHeaps(heap newHeaps[]);int findPosition(int i);void harden(heap newHeaps[]);void harden1();int findPosition1(int );void writeInfo();void addObject1(int ,int);void readFCM(FILE *,FILE *);void readOrg();int findInData(irisData input,int iflag);void adjustBoard(int flag);void writeIncremental(int iteration,int flag);/********************************************************************//***For FCM algorithm*/void GET_INPUTS1(char []);void UMAT( matrix,center,objects);BOOLEAN FINISHED(matrix, float);void CLUSTER( matrix, objects);void Output(char[]);void Fcm();/********************************************************************/
Parag Kanade/fuzzy ants/Gauss5/maxData.txt
1.688495
Parag Kanade/fuzzy ants/Gauss5/gauss.c
#include "headerStatic.h" /*******************************************************************/ /*** Global Variables ***/ irisData data[MAXDATA]; //To hold the data read from the file int count=0; //Count of the total number of data elements int heapCount=0; // Total number of heaps int heapRow=0; // Rows for the second iteration with heaps int newHeapCount=0; // Count of the heaps for the second iteration heap heaps[MAXDATA]; // Data structure to hold the heap information heap newHeaps[MAXDATA]; // Data Structure to hold the new heap information // For the second iteration int board[MAXROWS][MAXCOLS]; // Board on which the objects are located ant ants[MAXANTS]; // Data structure to hold the ants float Dmax=0; // Distance of the most dissimilar object pair int minHeapCount=100000; // Counter to hold the minimum heap count, used only for academic purpose // no use in the algorithm int minPosition; // the minimum heap iteration , only for academic purpose // no use in the algorithm float clsCen[MAXDATA][MAXDATA][s];//to hold the objects after hardening int cenCount[MAXDATA];//to hold the number of objects after hardening /********************************************************************/ /*** Varaibles to normalize the features between 0 and 1 */ float minInput[features], maxInput[features],scale[features],minForHeaps[features],maxForHeaps[features],scaleForHeaps[features]; /********************************************************************/ /** Variables for the FCM algorithm */ int temp[200]; /* for square matrix tests */ float eps,m; matrix U, U1; BOOLEAN stop; center V; objects X; char fname[80]; FILE *fp; int run; float inv_cov[s+1][s+1]; /* inverse of covariance matrix Y */ float Y[s][s]; long rand_index, Random_seed; long state1[52] = { 9347, 3835, 5194, 8310, 346, 535, 5297, 6711, 77, 3834, 668, 4175, 6868, 5890, 9304, 8462, 5269, 920, 65392, 41600, 70119, 91032, 76220, 26245, 4746, 73608, 32823, 63264, 75641, 99104, 36534, 24704, 98255, 72266, 75336, 65152, 7269, 63163, 88471, 27271, 43641, 76649, 47773, 23777, 27491, 35926, 16651, 48652, 89766, 90921, 6056 }; int z; int mins=0; int aveit =0; float mintab[200]; int mincount[200]; long start,end,total; int lCount;//added by parag /********************************************************************/ /********************************************************************//*int lrand48(){return(rand());}void srand48(int a){return;}*//********************************************************************/ /********************************************************************/ /* Function to read the input data set */ /* The file name is assumed to be itest.data */ /* Status: Tested */ /* Output: Data from the file into the "data" (Global) data structure */ /* Output: Count (Global), the count of the number of objects */ /********************************************************************/ void readInput() { FILE *fp; char fname[80]; int i=0,j=0; char ch; sprintf(fname,"%s.data",filename); /* Check if the input file is opened */ if((fp=fopen(fname,"r"))==NULL) { printf("\n Unable to open input file \n"); exit(0); } /*initialise the minimum maximum and the scale */ for(i=0;i<features;i++) { minInput[i]=1000; maxInput[i]=0; minForHeaps[i]=1000; maxForHeaps[i]=0; scale[i]=0; scaleForHeaps[i]=0; } /* Discard leading comments */ ch = 'c'; while (ch != '#') fscanf (fp, "%c", &ch); i=0; /* Parse the file and populate the data structure */ while(!feof(fp)) { for(j=0;j<features;j++) { fscanf(fp,"%f ",&data[i][j]); } fscanf(fp,"\n"); for(j=0;j<features;j++) { if(data[i][j]<minInput[j]) minInput[j]=data[i][j]; if(data[i][j]>maxInput[j]) maxInput[j]=data[i][j]; } i++; } count=i; /* Normailze the feature values in between 0 and 1 */ for(j=0;j<features;j++) { if(minInput[j]!=maxInput[j]) scale[j]=1.0/(maxInput[j]-minInput[j]); else scale[j]=1.0; } for(i=0;i<count;i++) { for(j=0;j<features;j++) data[i][j]=(data[i][j]-minInput[j])*scale[j]; } fclose(fp); return; }//end of function /********************************************************************/ /*Function to compute the eucldiean distance for all input data set */ /* Output : an array conatining the distance of each object with the other */ /********************************************************************/ float computeDistance() { float distance,dist=0; int i=0,j=0,k=0; distance=0; for(j=0;j<count;j++) for(i=0;i<count;i++) { for(k=0;k<features;k++) dist+=sqrt((data[j][k]-data[i][k])*(data[j][k]-data[i][k])); if(distance<dist)distance=dist; dist=0; } return(distance); } /********************************************************************/ /* Function to compute the distance between two objects */ /* Output : Euclidean d istance between the two input objects */ /********************************************************************/ float computeDistanceBetween2(irisData a,irisData b) { float temp=0; int i=0; for(i=0;i<features;i++) temp+=(a[i]-b[i])*(a[i]-b[i]); temp=sqrt(temp); return(temp); } /********************************************************************/ /* Function to find the maximum distance between the input objects*/ /* Output: the maximum distance */ /* Input : The array of distances between objects */ /********************************************************************/ /*float findMax(float *distance) { int i=0,j=0; float max=distance[0]; for(i=0;i<count;i++) for(j=0;j<count;j++) { if(max<distance[i*count+j]) max=distance[i*count+j]; } return(max); }*/ /********************************************************************/ /* Function to compute the value of an object */ /********************************************************************/ float value(irisData a) { int i=0; float temp=0; for(i=0;i<features;i++) temp+=a[i]*a[i]; return(sqrt(temp)); } /********************************************************************/ /* Function to find the object in the data structure */ /* Output : The position of the object in the data */ /* Input : The object */ /********************************************************************/ int findInData(irisData object,int iFlag) { int i=0,lastCount=0,j,position=-1,flag[features],flg;if(iFlag==1)lastCount=MAXDATA;else{}for(i=0;i<lastCount;i++){ for(j=0;j<features;j++) if(fabs(object[j]-data[i][j])<0.00001) flag[j]=1; else { flag[j]=0; break;} flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /* Function to find whether there is an object on the board at a,b */ /* Output : a flag indicating whether an object is found or not */ /* Input : The row and column indicating the board position */ /********************************************************************/ int found(int a , int b) { if(board[a][b]==9) return 1; else return 0; } /********************************************************************/ /* Function to initialize the initial board */ /* Output : None */ /* Global Structures modified : heaps */ /* Input : Flag indicating the iteration 1: First 0: Second */ /********************************************************************/ void initialise(int flag) { int a,b,i=0,k=0; int loopCount,rowCount,colCount; /* Initialize the row, column and number of heaps */ if(flag==1) { loopCount=count; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=lCount; rowCount=heapRow; colCount=heapRow; } /* Initialize the heaps */ for(i=0;i<loopCount;i++) { heaps[i].count=0; heaps[i].x=0; heaps[i].y=0; heaps[i].disPosition=0; heaps[i].Dmax=0; heaps[i].Dmean=0; } for(i=0;i<loopCount;i++) { /*find a board position which is empty*/ do { a=lrand48()%rowCount; b=lrand48()%colCount; } while(found(a,b)); /*Allocate the object to that place and assign a heap to it*/ heaps[i].x=a; heaps[i].y=b; heaps[i].count=1; heaps[i].Dmax=0; heaps[i].Dmean=0; if(flag==1) { heaps[i].objects[0]=i; for(k=0;k<features;k++)heaps[i].Ocenter[k]=data[i][k]; } else { for(k=0;k<features;k++) heaps[i].Ocenter[k]=newHeaps[i].Ocenter[k]; } heaps[i].disPosition=0; board[a][b]=9; if((debugLevel>0)&&(flag==1))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],data[heaps[i].objects[0]][0]); if((debugLevel>0)&&(flag==0))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],newHeaps[i].Ocenter[0]); } /*initialise the initial heap count*/ heapCount=loopCount; currentRow=rowCount; } /********************************************************************/ /* Function to find whether an heap is present at the location a b */ /* Output : Flag indicating the presencs of the heap */ /* Input : Roe and column indicating the board position */ /********************************************************************/ int findObject(int a,int b) { int i; int position=-1; for(i=0;i<heapCount;i++) { if((heaps[i].x==a)&&(heaps[i].y==b)) { position=i; break; } } return(position); } /********************************************************************/ /* Function initialize the ants */ /* Output : None */ /* Input : Flag indicating the iteration */ /* Global Variables Modified : ant, heapCount, heaps, board */ /********************************************************************/ void initialiseAnts(int flag) { int i=0,a=0,b=0,position,j=0,loopCount=0,rowCount,colCount,k=0; if(flag==1) { loopCount=MAXANTS; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=MAXANTSFORHEAPS; rowCount=heapRow; colCount=heapRow; } for(i=0;i<loopCount;i++) { /*generate random positions for the ants*/ a=lrand48()%rowCount; b=lrand48()%colCount; ants[i].x=a; ants[i].y=b; /*Find if an object is present at that position or not*/ if(board[a][b]==9) { ants[i].carrying=1; /*find the heap at that location*/ position=findObject(a,b); if(position==-1) { printf("\n Error in logic: Ant init \n"); //getchar(); break; } else { /*Assign the heap data to the ant data and decrement the heap count*/ if(flag==1){ for(k=0;k<features;k++)ants[i].data[k]=data[heaps[position].objects[0]][k]; }else{for(k=0;k<features;k++)ants[i].data[k]=heaps[position].Ocenter[k];} for(j=position;j<heapCount-1;j++) heaps[j]=heaps[j+1]; heapCount--; } /*Clear the board position */ board[a][b]=-9; } else ants[i].carrying=-1; ants[i].speed=0; ants[i].dir=lrand48()%8; printf("\n Ant %2d X: %2d Y: %2d Carying : %2d ",i,ants[i].x,ants[i].y,ants[i].carrying); } currentAntCount=loopCount; } /********************************************************************/ /* Function to move the ant */ /* Output: None */ /* Input: Ant to be moved and the flag indicating the iteration */ /********************************************************************/ void moveNext(ant* a,int flag) { int rowCount,colCount; /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; } else { rowCount=heapRow; colCount=heapRow; }*/rowCount=currentRow;colCount=currentRow; /*Depending upon the direction move the ant*/ switch (a->dir) { case 0: a->y++; if(a->y>=colCount)a->y=0; break; case 1: a->x--; a->y++;; if(a->x<0)a->x=rowCount-1; if(a->y>=colCount)a->y=0; break; case 2: a->x--; if(a->x<0)a->x=rowCount-1; break; case 3: a->x--; a->y--; if(a->x<0)a->x=rowCount-1; if(a->y<0)a->y=colCount-1; break; case 4: a->y--; if(a->y<0)a->y=colCount-1; break; case 5: a->x++; a->y--; if(a->x>=rowCount)a->x=0; if(a->y<0)a->y=colCount-1; break; case 6: a->x++; if(a->x>=rowCount) a->x=0; break; case 7: a->x++; a->y++; if(a->x>=rowCount)a->x=0; if(a->y>=colCount)a->y=0; break; } }//end of function /********************************************************************/ /* Function to compute the parameters of the heap */ /* Output: None */ /* Input: The heap whose parameters are to be computed iteration flag*/ /********************************************************************/ void computeHeapParameters(heap* heapData,int flag) { int i=0,j=0,k=0,position=0; float distance=0; float Dmean=0.0; float *dis; float featureSum[features]; float max=0; float sum=0; /* init*/ for(k=0;k<features;k++) featureSum[k]=0; /*Compute the distance of each object and find the maximum distance*/ max=0; if(flag==1){ for(j=0;j<heapData->count;j++) for(i=0;i<heapData->count;i++) { for(k=0;k<features;k++) sum+= (data[heapData->objects[j]][k]-data[heapData->objects[i]][k])*(data[heapData->objects[j]][k]-data[heapData->objects[i]][k]); distance=sqrt(sum); if(max<distance) max=distance; sum=0; } /* Assign the maximum distance to the heap */ heapData->Dmax=max;/*Compute the centre object*/for(i=0;i<heapData->count;i++)for(k=0;k<features;k++) featureSum[k]+=data[heapData->objects[i]][k];for(k=0;k<features;k++)heapData->Ocenter[k]=featureSum[k]*1.0/heapData->count; /* Find the mean distance */if((dis=(float *) calloc(heapData->count,sizeof(float)))==NULL){printf("\nUnable to allocate memory in the compute heap parameters procedure\n");exit(0);} for(i=0;i<heapData->count;i++) { Dmean+=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); dis[i]=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); } heapData->Dmean=Dmean*1.0/heapData->count; /*Compute the most dissimilar object*/ max=dis[0]; for(i=1;i<heapData->count;i++) if(max<dis[i]) { max=dis[i]; position=i; } /*Assign the most dissimilar object to the heap variable*/ for(k=0;k<features;k++) heapData->Odissim[k]=data[heapData->objects[position]][k]; heapData->disPosition=position;free(dis); } else{/* Heap Parameters for the second stage */for(k=0;k<features;k++){ heapData->Odissim[k]=heapData->Ocenter[k];}heapData->disPosition=0;heapData->Dmean=0;heapData->Dmax=0;} }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a single object*/ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject1(ant *a,int position,int flag) { int i,k=0; /*Clear the board*/ board[heaps[position].x][heaps[position].y]=-9; /* Assign the data to the ant*/if(flag==1){ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[0]][k];}else {for(k=0;k<features;k++) a->data[k]=heaps[position].Ocenter[k];} a->carrying=1; /*Copy all the heaps remaining heaps in the structure*/ for(i=position;i<heapCount-1;i++) heaps[i]=heaps[i+1]; /*Decrement the heap count*/ heapCount--; }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a two objects */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject2(ant *a , int position,int flag) { float Pdestroy1=-1; int i=0,k=0; /*Compute the probability to destroy the heap*/ Pdestroy1=lrand48()%13*1.0/12.0; /*If the probability is more than Pdestroy then destroy the heap */ if(Pdestroy1<Pdestroy) { /*pick the object randomly*/ i=lrand48()%2; /* Assign the data to the ant */ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[i]][k]; a->carrying=1; /*Correct the heap parameters*/ heaps[position].count=1; heaps[position].objects[0]=heaps[position].objects[1-i]; computeHeapParameters(&heaps[position],flag); } }//end of function /********************************************************************/ /*Function to pick a object from a heap consisting of more than two object */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /********************************************************************/ void pickObjectn(ant *a,int position,int flag) { int i=0,k=0; /*If the criteria is satsfied then pick the object*/ if((computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)*1.0/heaps[position].Dmean)>Tremove) { a->carrying=1; for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[heaps[position].disPosition]][k]; for(i=heaps[position].disPosition;i<heaps[position].count-1;i++) heaps[position].objects[i]=heaps[position].objects[i+1]; heaps[position].count--; computeHeapParameters(&heaps[position],1); } }//end of function /********************************************************************/ /* Function to pick a object */ /********************************************************************/ void pick(ant *a,int flag) { int position=-1,i=0; float Pload1=-1.0; for(i=0;i<heapCount;i++) { /*Check if a heap is present in the eight neighbouring cells*/ if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if Heap is found*/ if(position!=-1) { /* heap or object found.*/ /*Depending upon the number present in the heap call the corresponding routine*/ switch(heaps[i].count) { case 1: Pload1 = lrand48()%151*1.0/150.0; if(Pload1<Pload) { pickObject1(a,position,flag); } break; case 2: pickObject2(a,position,flag); break; default: pickObjectn(a,position,flag); break; } } } /********************************************************************/ /* Function to drop a object to form a new heap */ /* Output: None */ /* Input: Ant, iteration flag */ /* Global Structure modified : heap, heapCount */ /********************************************************************/ void dropObject(ant* a,int flag) { /*Create a new heap*/ int k=0; heaps[heapCount].count=1; heaps[heapCount].x=a->x; heaps[heapCount].y=a->y; heaps[heapCount].Dmax=0; heaps[heapCount].Dmean=0; heaps[heapCount].disPosition=0; for(k=0;k<features;k++) { heaps[heapCount].Odissim[k]=a->data[k]; heaps[heapCount].Ocenter[k]=a->data[k]; } if(flag==1) {heaps[heapCount].objects[0]=findInData(a->data,flag); /*computeHeapParameters(&heaps[heapCount],flag);*/ } computeHeapParameters(&heaps[heapCount],flag); heapCount++; a->carrying=-1; board[a->x][a->y]=9; }//end of function /********************************************************************/ /* Function to find the heap position during the second iteration */ /* Output: position of the heap */ /* Input: object center of the heap that the ant is carrying */ /* Global Structure modified : none */ /********************************************************************/ int findInNewheaps(irisData object) { int position=-1,i,j=0,flag[features],flg; for(i=0;i<newHeapCount;i++) { for(j=0;j<features;j++) { if(fabs(object[j]-newHeaps[i].Ocenter[j])<0.00001) flag[j]=1; else {flag[j]=0;break;} } flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /*Function to drop a object to a heap consisting of a one or more object */ /* Output: none */ /* Input: Ant, position of the heap , iteration flag */ /* Global Structure modified: heaps,newHeaps */ /********************************************************************/ void dropObject1(ant* a, int position,int flag) { int heapPosition=-1,heapPosition1=-1,i,j,k=0; irisData newData,temp; if(flag==1) { /*Add the object to the heap and compute the heap parameters*/ /*if(heaps[position].count==heaps[position].objCount) {if((junk=(int *)realloc(heaps[position].objects,((heaps[position].objCount+OBJINC)*sizeof(int))))==NULL){printf("\n Cannot Allocate memory to the new object for %d heap",position);exit(0);}heaps[position].objects=junk;heaps[position].objCount+=OBJINC;free(junk); }*/ heaps[position].objects[heaps[position].count]=findInData(a->data,flag); heaps[position].count++; computeHeapParameters(&heaps[position],flag); } else { for(k=0;k<features;k++)temp[k]=heaps[position].Ocenter[k]; heapPosition=findInNewheaps(a->data); heapPosition1=findInNewheaps(heaps[position].Ocenter); if(heapPosition==-1||heapPosition1==-1) { printf("\n error in logic:new heaps\n"); //getchar(); return; } for(k=0;k<features;k++) {newData[k]=(newHeaps[heapPosition].Ocenter[k]*newHeaps[heapPosition].count+newHeaps[heapPosition1].Ocenter[k]*newHeaps[heapPosition1].count)*1.0/(newHeaps[heapPosition].count+newHeaps[heapPosition1].count);newHeaps[heapPosition].Ocenter[k]=newData[k];heaps[position].Ocenter[k]=newData[k]; } computeHeapParameters(&heaps[position],flag); for(i=newHeaps[heapPosition].count,j=0;j<newHeaps[heapPosition1].count;i++,j++) { newHeaps[heapPosition].objects[i]=newHeaps[heapPosition1].objects[j]; } newHeaps[heapPosition].count+=newHeaps[heapPosition1].count; for(i=heapPosition1;i<newHeapCount-1;i++) newHeaps[i]=newHeaps[i+1]; newHeapCount--; } a->carrying=-1; }//end of function /********************************************************************/ /* Function to drop a object */ /* Output: None */ /* Input: Ant, iteration flag */ /********************************************************************/ void drop(ant* a,int flag) { int i, position=-1; float Pdrop1=0.0; /*Find whether we have a heap in the neighbourhood of the cell*/ for(i=0;i<heapCount;i++) { if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if a heap is found*/ if(position!=-1) { /*heap or object found.*/ /*Depending on the number of objects present take action*/ switch(heaps[position].count) { /*If criteria is satisfied then drop the object*/ case 1: if(flag==1) { if((computeDistanceBetween2(a->data,data[heaps[position].objects[0]])*1.0/Dmax)<Tcreate) dropObject1(a,position,flag); } else { if((computeDistanceBetween2(a->data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) dropObject1(a,position,flag); } break; default: if(computeDistanceBetween2(a->data,heaps[position].Ocenter)<computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)) dropObject1(a,position,flag); break; } } else { /*Compute the probability to drop the object*/ Pdrop1 = lrand48()%151*1.0/150; if(Pdrop1<Pdrop) dropObject(a,flag); } }//end of function /********************************************************************/ /* Function to move the ant */ /* Output: none */ /* Input: Ant, iteration flag */ /********************************************************************/ void move(ant* a,int flag) { float pDir; /*Check the speed */ if (a->speed!=0) { /*move in the same direction*/ a->speed--; moveNext(a,flag); } else { /*generate the new direction*/ pDir=lrand48()%17*1.0/16.0; if(pDir<.85) { a->dir=lrand48()%8; } else if(pDir>.95) { a->speed=2; } moveNext(a,flag); } } /********************************************************************/ /* Function to simulate the movement of the ants */ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified: minHeapCount, minHeapPosition */ /********************************************************************/ void iterate(int flag) { int i=0,j=0,k=0,loopCount=0; if (flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS; while (i<MAXITERATIONS) { i++; for(j=0;j<loopCount;j++) { move(&ants[j],flag); if(ants[j].carrying==1) { drop(&ants[j],flag); } else { pick(&ants[j],flag); } } if(debugLevel>0){ for(k=0;k<heapCount;k++) for(j=0;j<heapCount;j++) if((k!=j)&&(heaps[k].x==heaps[j].x)&&(heaps[k].y==heaps[j].y)) { printf("\nerror two heaps with same co ordinates %d %d ",k,j); //getchar(); } k=0; for(j=0;j<heapCount;j++) k+=heaps[j].count; } if(heapCount<minHeapCount) { minHeapCount=heapCount; minPosition=i; } if(debugLevel>0) printf("\n i:%d Heap count %d sum %d",i,heapCount,k); else printf("\n i:%d Heap count %d",i,heapCount); heapSum+=heapCount; /*if(i%updateAfter==0) {adjustBoard(flag); writeIncremental(i,flag);heapSum=0;loopCount=currentAntCount; }*/ } }//end of function /********************************************************************/ /*Function to drop the objects carried by the ants after all the iterations*/ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified:none */ /********************************************************************/ void dropFinal(int flag) { int i=0,j=0,position=-1,loopCount=0; /*if(flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS;*/ loopCount=currentAntCount; for(i=0;i<loopCount;i++) { if(ants[i].carrying==1) { if(flag==1) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position,flag); } } else { /*Find if a heap is present */ do { position=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position,flag); position=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position!=-1); } } } }//end of function /********************************************************************/ /* Function for the implementation of QuickSort */ /* Output: none */ /* Input: data structure, low and high indices */ /* Global structure modified:none */ /********************************************************************/ void quickSort( heap A[], int low,int high ) { int mid=0; if(low<high) { mid=partition(A,low,high); quickSort(A,low,mid); quickSort(A,mid+1,high); } } /********************************************************************/ /* Partition routine used by quick sort */ /* Output: partition location */ /* Input: data , low, high */ /* Global structure modified:none */ /********************************************************************/ int partition(heap a[], int low,int high) { heap temp; int x=0,i=0,j=0; i=low; j=high; x=a[low].count; while (1) { while (a[j].count<x) j=j-1; while (a[i].count>x) i=i+1; if(i<j) { temp=a[i]; a[i]=a[j]; a[j--]=temp; } else return(j); } } /********************************************************************/ /* Function used to write the cluster information */ /* Output: none */ /* Input:iteration flag */ /* Global structure modified:none */ /********************************************************************/ void writeClusterInformation(int flag) { FILE *fp=fopen("center.clt","w"); FILE *fp1; FILE *fp2; FILE *fp3; char temp[80]; int i=0,j=0,k=0; int lastCount=0; int rowCount,colCount,antCount; strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp3=fopen(temp,"a"); if(dataDump) {strcpy(temp,"");sprintf(temp,"%sTot.out",filename);fp1=fopen(temp,"a");strcpy(temp,"");sprintf(temp,"%sObj.out",filename);fp2=fopen(temp,"a");if(fp1==NULL||fp2==NULL)printf("\n Error in opening file in the writer Cluster Information routine\n"); } /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; antCount=MAXANTS; } else { rowCount=heapRow; colCount=heapRow; antCount=MAXANTSFORHEAPS; }*/ rowCount=currentRow; colCount=currentRow; antCount=currentAntCount; if(fp==NULL) { printf("\n Unable to open cluster center output file \n"); /*return;*/ exit(0); } /*sort the array according to the count value and write the value of the top three elements*/ if((flag==1)&&(!EntireHeaps)) quickSort(heaps,0,heapCount); if(EntireHeaps) {if(flag==1) lastCount=heapCount;else lastCount=newHeapCount; } else lastCount=c; for(i=0;i<lastCount;i++) { if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",newHeaps[i].Ocenter[k]); fprintf(fp,"\n"); } else { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); fprintf(fp,"\n"); } } if(dataDump) { fprintf(fp1,"\n Information from the Ant Based Algorithm \n"); fprintf(fp1,"\n Important Parameters : Board %d X %d Ants : %d Iterations %d Total Heaps %d ",rowCount,colCount,antCount,MAXITERATIONS,lastCount); } if(flag==0) { if(dataDump) { fprintf(fp1," TCreateForHeaps %f \n",TcreateForHeaps); fprintf(fp2,"\nTotal Heaps : %d\n",heapCount); fprintf(fp2,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); } fprintf(fp3,"\n@ %d\n",lastCount); } else if(dataDump) fprintf(fp1,"\n");if(dataDump) { fprintf(fp1,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); for(i=0;i<lastCount;i++) if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp2,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); } fprintf(fp1," %5d\n",newHeaps[i].count); fprintf(fp2," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp1," %5d\n",heaps[i].count); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]); fprintf(fp1," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]); fprintf(fp1," %5d\n",heaps[i].count); }} if(flag==0) { if(dataDump) fprintf(fp1,"\n Objects in the heaps \n");for(i=0;i<newHeapCount;i++) { if(dataDump) fprintf(fp1,"\n\n Heap %d\n \n",i+1);fprintf(fp3,"# %d %d\n",i ,newHeaps[i].count); for(j=0;j<newHeaps[i].count;j++){ for(k=0;k<features;k++){ fprintf(fp3,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]); if(dataDump) fprintf(fp1,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]);} if(dataDump) fprintf(fp1,"\n"); fprintf(fp3,"\n"); } } } fclose(fp); fclose(fp3); if(dataDump) { fclose(fp1);fclose(fp2); }}//end of flie /********************************************************************/ /* Function to initialise the new heaps */ /* Output: none */ /* Input:new Heap structure */ /* Global structure modified:none */ /********************************************************************/ void initialiseNewHeaps(heap newHeaps[]) { int i=0,j=0; for(i=0;i<lCount;i++) { newHeaps[i].count=0; for(j=0;j<features;j++) newHeaps[i].Ocenter[j]=V[i][j]; newHeaps[i].x=heaps[i].x; newHeaps[i].y=heaps[i].y; } }//end of function /********************************************************************/ /* Function to initialise the new heaps */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ int findPosition(int i) { int j,position=0; for(j=1;j<lCount;j++) { if(U[j][i]>U[position][i]) position=j; } printf("\n Position %d ",position); return(position); }//end of function find position /********************************************************************/ /* Function to add object */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ void addObject(int object,heap * heapPosition) { heapPosition->objects[heapPosition->count]=object; heapPosition->count++; }//end of function add object /********************************************************************/ /* Function to harden the outputs obtained from fcm */ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/ void harden(heap newHeaps[]) { int i,heapPosition=-1,sum=0,j=0; /*initialise the new heaps*/ initialiseNewHeaps(newHeaps); for(i=0;i<count;i++) { heapPosition=findPosition(i); addObject(i,&newHeaps[heapPosition]); } /* To check for degenerate partitions*/ for(i=0;i<lCount;i++) { if(newHeaps[i].count==0){for(j=i;j<lCount-1;j++){newHeaps[j]=newHeaps[j+1];}lCount--;i--;} } newHeapCount=lCount; for(i=0;i<lCount;i++) computeHeapParameters(&newHeaps[i],1); if(debugLevel>0) { for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\n sum = %d",sum);} }//end of function/********************************************************************/ /* Function to initialize the initial parameters for the ant algorithm*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void init() { int i=0,j=0; for(i=0;i<MAXROWS;i++) for(j=0;j<MAXCOLS;j++) board[i][j]=-9; heapCount=0; newHeapCount=0; heapRow=0; minPosition=-1; minHeapCount=100000; for(i=0;i<MAXANTS;i++) { ants[i].carrying=-1; ants[i].x=-1; ants[i].y=-1; ants[i].speed=-1; ants[i].dir=-1; } } /********************************************************************/ /* Function to initialize the initial board */ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void initialiseBoard() { int i,j; for(i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; }/********************************************************************/ /* Function to harden the outputs obtained from fcm(2nd stage)*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: Cluster center , cluster center count*/ /********************************************************************/void harden1() { int i=0,heapPosition=-1; for(i=0;i<heapCount;i++) cenCount[i]=0; for(i=0;i<n;i++) { heapPosition=findPosition1(i); addObject1(i,heapPosition); } writeInfo(); }//end of function/********************************************************************/ /* Function to find to which class the object belongs */ /* Output: Class number */ /* Input: object position */ /* Global Structure Modified: None */ /********************************************************************/int findPosition1(int i) { int j,position=0; for(j=1;j<heapCount;j++) { if(U[j][i]>U[position][i]) position=j; } return(position); }//end of function find position/********************************************************************/ /* Function to Write the output of the hardened objects to file*/ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/void writeInfo(){int i=0,j=0,k=0;FILE *fp=fopen("fcm.out","a");if(fp==NULL){printf("\n Unable to open fcm output file \n");return;}fprintf(fp,"\n@ %d\n",heapCount);for(i=0;i<heapCount;i++){fprintf(fp,"# %d %d\n",i,cenCount[i]);for(j=0;j<cenCount[i];j++){for(k=0;k<s;k++)fprintf(fp,"%8.2f ",clsCen[i][j][k]/scale[k]+minInput[k]);fprintf(fp,"\n");}}fclose(fp);return;}/********************************************************************/ /* Function to add a object to a cluster (2nd stage) */ /* Output: none */ /* Input: object poistion , cluster position */ /* Global Structure Modified: Cluster object and cluster count*/ /*******************************************************************/void addObject1(int object,int heapPosition) { int k=0; for(k=0;k<features;k++) clsCen[heapPosition][cenCount[heapPosition]][k]=X[object][k]; cenCount[heapPosition]++; return; }//end of function add object/********************************************************************/ /* Function to read the original classification of objects */ /* Output: none */ /* Input: none */ /* Global Structure Modified: None */ /*******************************************************************/void readOrg(){int i=0,k=0;char temp[80];FILE *fp;//= fopen(dataname,"r");strcpy(temp,"");sprintf(temp,"%sFull.data",filename);fp=fopen(temp,"r");if(fp==NULL){printf("\n Unable to open full data input file ");exit(0);}for(i=0;i<n;i++){fscanf(fp,"%f ",&orgData[i][0]);for(k=1;k<s+1;k++)fscanf(fp,"%f ",&orgData[i][k]);}return;}// end of function/********************************************************************/ /* Function to classify the objects in different clusters */ /* Output: none */ /* Input: the cluster objects, the original classification, */ /* number of objects in the cluster,file to write the data */ /* Global Structure Modified: None *//********************************************************************/int analysisData(float data[][s],float orgData[n][s+1],int count,FILE * fp){int i=0,j=0,k=0,type=1,max=0;heapInfo info;for(i=0;i<c;i++){info.classObj[i]=0;}info.total=0;info.total=count;for(i=0;i<count;i++)for(j=0;j<n;j++){type=1;for(k=0;k<s;k++)if(fabs(data[i][k]-orgData[j][k+1])>errThresh){type=-1;break;}if(type!=-1){info.classObj[(int)orgData[j][0]-1]++;break;}}max=0;for(k=0;k<c;k++){if(info.classObj[k]>info.classObj[max])max=k;fprintf(fp,"\nClass %d Objects % d ",k+1,info.classObj[k]);}j=0;for(k=0;k<c;k++){if(k!=max)j+=info.classObj[k];}fprintf(fp,"\n Total errors : %d \n",j);return(j);}//end of analyse/********************************************************************/ /* Function to read the cluster information */ /* Output: none */ /* Input: input file pointer , output file pointer */ /* Global Structure Modified: None *//********************************************************************/void readFCM(FILE* fp,FILE *fp1){int i=0,j=0,k=0,l=0;int totalRuns=0,heapCount=0,junk=0,sum=0;char ch;FILE *fp2=fopen("errors.out","a");ch = 'c'; while (ch != '$') fscanf (fp, "%c", &ch);fscanf(fp,"%d\n",&totalRuns);printf("\n total runs %d ",totalRuns);for(l=0;l<totalRuns;l++){fscanf(fp,"%c",&ch);fscanf(fp,"%d\n",&heapCount);fprintf(fp1,"\n \nExperiment %d \n ",l+1);sum=0;for(i=0;i<heapCount;i++){fscanf(fp,"%c",&ch);fscanf(fp," %d %d\n",&junk,&clsCenCount[i]);for(j=0;j<clsCenCount[i];j++)for(k=0;k<s;k++)fscanf(fp,"%f",&fcmData[i][j][k]);fscanf(fp,"\n");fprintf(fp1,"\n\n Heap %d Total Objects %d \n",i+1,clsCenCount[i]);sum+=analysisData(fcmData[i],orgData,clsCenCount[i],fp1);}fprintf(fp2," %3d %3d %3d \n",l,sum,heapCount);}fprintf(fp2,"\n --------------------------\n");fclose(fp2);return;}//end of function/********************************************************************/ /* Function to update the board parameters */ /* Output: none */ /* Input: none */ /* Global Structure Modified: board size, ant count *//********************************************************************/void adjustBoard(int flag){int newRow=0,newAnt=0,antDiff=0,antsKilled=0,i=0,position[MAXANTS],position1=-1,j=0,k=0,a,b; newRow= (int)ceil(sqrt(4.0*heapSum/updateAfter)); newAnt= (int)ceil((heapSum*1.0/updateAfter)*1.0/3.0); if(newAnt<minAnts)newAnt=minAnts; if(newRow<rowMin)newRow=rowMin;antDiff=currentAntCount-newAnt; if((antDiff>0)&&(newAnt>=minAnts)) {for(i=0;i<currentAntCount;i++){if(ants[i].carrying==-1){position[antsKilled++]=i;}} if(antsKilled>=antDiff){for(i=0;i<antDiff;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1];for(k=i+1;k<antsKilled;k++)position[k]--; } currentAntCount=newAnt; }else {for(i=0;i<antsKilled;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1]; for(k=i+1;k<antsKilled;k++)position[k]--; }if(flag==1) { for(i=currentAntCount-1,k=0;k<antDiff-antsKilled;k++,i--) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position1,flag); }else { dropObject(&ants[i],flag); } } } else { //flag is zero 2nd stage /*Find if a heap is present */ do { position1=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position1].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position1,flag); position1=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position1!=-1); }//end else currentAntCount=newAnt;}//end elsecurrentAntCount=newAnt;}//end iffor(i=0;i<newAnt;i++){if((ants[i].x>=newRow)||(ants[i].y>=newRow)) { a=lrand48()%newRow; b=lrand48()%newRow; ants[i].x=a; ants[i].y=b; }} //Done with ants, now adjust the boardif((currentRow>newRow)&&(newRow>=rowMin)){for(i=0;i<heapCount;i++){if((heaps[i].x>=newRow)||(heaps[i].y>=newRow)) {do { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionheaps[i].x=a;heaps[i].y=b;board[a][b]=9;}//end if}//end for for(i=0;i<currentAntCount;i++){if((ants[i].carrying==1)&&((ants[i].x>=newRow)||(ants[i].y>=newRow))){//adjust the ant locationdo { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionants[i].x=a;ants[i].y=b;}//end if}//end for currentRow=newRow;}//end if }//end of function void writeIncremental(int iteration,int flag){FILE *fp=fopen("dump.txt","w");int i=0,j=0,k=0;fprintf(fp,"Stage %d\n",flag);fprintf(fp,"Board %d\n",currentRow);fprintf(fp,"Ants %d\n",currentAntCount);fprintf(fp,"Iteration %d\n",iteration);fprintf(fp,"Heaps %d\n",heapCount); if(flag==0)fprintf(fp,"NewHeapCount %d\n",newHeapCount); fprintf(fp,"Ants\n");for(i=0;i<currentAntCount;i++){fprintf(fp,"%d %d %d %d %d ",ants[i].x,ants[i].y,ants[i].carrying,ants[i].speed,ants[i].dir);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",ants[i].data[k]);fprintf(fp,"\n");}fprintf(fp,"Heaps\n");for(i=0;i<heapCount;i++){fprintf(fp,"%d %d %d %d %8.2f %8.2f \n",heaps[i].x,heaps[i].y,heaps[i].count,heaps[i].disPosition,heaps[i].Dmax,heaps[i].Dmean);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Ocenter[k]);fprintf(fp,"\n");for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Odissim[k]);fprintf(fp,"\n");if(flag==1){for(j=0;j<heaps[i].count;j++)fprintf(fp,"%d ",heaps[i].objects[j]);fprintf(fp,"\n");}}if(flag==0){fprintf(fp,"newHeaps\n");for(i=0;i<newHeapCount;i++){fprintf(fp,"%d\n",newHeaps[i].count);for(j=0;j<newHeaps[i].count;j++)fprintf(fp,"%d ",newHeaps[i].objects[j]);fprintf(fp,"\n");}}fclose(fp);}//end of function/********************************************************************/ /* Function Main */ /********************************************************************/ int main(int argc ,char** argv) { int sum=0,k=0,i=0,j=0; char temp[80]; FILE *fp=fopen("fcm.out","w"); FILE *fp1; FILE *fp2=fopen("antAnalysis.out","a"); FILE *fp3=fopen("fcmAnalysis.out","a"); FILE *fp4=fopen("errors.out","w"); FILE *fp5; fclose(fp4); sprintf(temp,"%sObj.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sTot.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp1=fopen(temp,"w"); fprintf(fp,"\n$%d",EXPRUN); fprintf(fp1,"\n$%d",EXPRUN); fclose(fp); fclose(fp1); if(argc==2)sscanf(argv[1],"%d",&debugLevel); printf("\n Debug level %d\n",debugLevel); for( i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; //Read from the file readInput(); //Compute the distance of all the points if(maxDist) { Dmax=computeDistance(); //Compute the maximum distance fp5=fopen("maxData.txt","w");fprintf(fp5,"%f",Dmax);fclose(fp5); } else {fp5=fopen("maxData.txt","r");fscanf(fp5,"%f",&Dmax);fclose(fp5); } printf("\n %f \n",Dmax); //Initialise the board for(k=0;k<EXPRUN;k++) { init(); sum=0; srand48(state1[k]); initialiseBoard(); initialise(1); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(1); printf("\n %d \n",heapCount); //Simulate the working of ants iterate(1); //drop the objects after all the iterations dropFinal(1); //to verify the correctness for(i=0;i<heapCount;i++) sum+=heaps[i].count; //write the cluster centers to the file writeClusterInformation(1); printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); //getchar(); //Run FCM // heapCount=2973;/* To be commented */ printf("\n\n k %d \n\n",k); Fcm(data); //compute new board size. lCount=heapCount; heapRow=(int)ceil(sqrt(4*heapCount)); newHeapCount=lCount; printf("\n LCount %d newHeapCount %d heap Row %d \n",lCount,newHeapCount,heapRow); //harden the objects harden(newHeaps); //iterate with the heaps as the objects. initialiseBoard(); initialise(0); for(i=0;i<lCount;i++) computeHeapParameters(&heaps[i],0); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(0); printf("\n %d \n",heapCount); //getchar(); //Simulate the working of ants iterate(0); dropFinal(0); writeClusterInformation(0); sum=0; for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); // getchar(); Fcm(data); harden1(); } fp=fopen("fcm.out","a"); fp1=fopen(temp,"a"); fprintf(fp,"\n"); fprintf(fp1,"\n"); fclose(fp); fclose(fp1); fp=fopen("fcm.out","r"); fp1=fopen(temp,"r");printf("\n Before read org\n");readOrg();printf("\nafter read org\n");readFCM(fp1,fp2);printf("\n After 1st read fcm\n");readFCM(fp,fp3);printf("\n After 2 fcm read \n");return(1); }//end of main /****************************************************************/ float NORM(feature , feature); void find_covar(); void Fcm (irisData Data[MAXDATA]) { int i,j,l; FILE *ofile; char temp[80]; int flag=0;//added by parag FILE *iniClsCen=fopen("center.clt","a+"); if(iniClsCen==NULL) { printf("\n Unable to open the initial cluster center file\n"); printf("\n choosing random cluster centers....\n"); flag=1; } strcpy(temp,""); sprintf(temp,"%s.data",filename); strcpy (fname,temp); /* Read from this file */ m=2.0; /* The exponent */ /*GET_INPUTS1(fname);*/ /* read in feature vectors */ for (j=0; j<n ; j++) /* Read File in row-major */ for (i=0; i<s ; i++) /* format */ X[j][i]=Data[j][i]; Random_seed=state1[run];/*randseed*/ srand48(Random_seed); for (run=0;run<TOTRUNS;run++) { //flag=1;//for testing random values if (EntireHeaps) lCount=heapCount; else lCount=c; for(i=0;i<lCount;i++) for(j=0;j<s;j++) V[i][j]=0; for(i=0;i<lCount;i++) { for(l=0;l<s;l++) { if(flag==1) { rand_index = lrand48() % n; V[i][l] = X[rand_index][l]; } else { fscanf(iniClsCen,"%f ",&V[i][l]); } }//end for } eps=0.001; stop = FALSE; /* This loop finds the final cluster center and the corresponding U values */ z = 0; while (stop == FALSE) { z++; UMAT(U,V,X); /** Update the U matrix **/ stop = FINISHED(U1,eps); CLUSTER(U,X); /** Get new cluster center **/ printf("Iteration: %d\n\n", z); } /* end while */ printf("Number of iterations: %d\n\n", z);strcpy(temp,""); sprintf(temp,"%sFCM.out",filename);if(dataDump) Output(temp); /* output the results */ }/*end for*/ if(dataDump) { ofile=fopen(temp,"a"); for (i=0; i <= mins; i++) fprintf(ofile, "Min %d of %10.3f occurred %d times\n", i, mintab[i], mincount[i]); fprintf(ofile, "Average iterations %f\n", (float)aveit/(float)TOTRUNS); fclose(ofile); } }/* end Main */ /* The GET_INPUTS1 procedure opens an input file, reads the number of input vectors, the number of features per vector, the number of clusters, and epsilon, then it reads the input values */ void GET_INPUTS1(char fname[]) //char fname[]; { /* Parameters: fname -- name of file containing input info. */ FILE *infile ;//*fopen(); //char junk[10][80]; char realfname[80]; char ch; char fileName1[80]; //int temp[10], i, j, inputs, outputs, count; int i,j; sprintf (realfname, "%s", fname); /* open input file */ if(normalize==1) strcpy(fileName1,"gtest1.data"); else strcpy(fileName1,fname); if((infile = fopen (fileName1, "r")) == NULL) printf("\n CAN'T OPEN %s\n",realfname); else { ch = 'c'; /* Discard leading comments */ while (ch != '#') fscanf (infile, "%c", &ch); for (j=0; j<n ; j++) /* Read File in row-major */ { /* format */ for (i=0; i<s ; i++) fscanf (infile, "%f", &X[j][i]); /* fscanf (infile, "%d", &temp[1]); */ /* end for */ } /* end for */ fclose(infile); /* close input file */ }/* end else */ } /* end GET_INPUTS1 */ /* The NORM function computes the norm of two vectors, x and v, of dimension s. This gives an indication of the distance between them */ float NORM( feature x, feature v) //feature x, v; { /* Parameters : x -- a local copy of an input vector v -- a local copy of a cluster center */ int i,j; /* loop variable */ double sum; /* the square root of sum is the norm; sum is the sum of the differences squared */ float mat1[s]; float mat2[s]; if (maha) { for (i=0; i<s; i++) mat1[i]=x[i]-v[i]; for(i=0;i<s;i++) { sum =0; for(j=0;j<s;j++) sum += mat1[j] * inv_cov[j][i]; mat2[i] = sum; } sum =0; for(j=0;j<s;j++) sum += mat1[j]*mat2[j]; } else { sum = 0; for(j=0;j<s;j++) sum += (x[j] - v[j])* (x[j] - v[j]); } return (float)(sqrt(sum)); } /* end NORM */ /* The UMAT procedure calculates the updated U matrix according to Bezdek's formula. Its side-effect is the update of the global array U1 */ void UMAT( matrix U,center V, objects X) /*matrix U; center V; objects X;*/ { /* Parameters: U, V, and X: same as in main program */ int i, j, k,l ;/* loop variables *///, class /* class whose cluster center //is closest to pattern k */; float d1,d2,d; float sum; int exact; for (k=0;k<n;k++) { /*printf("\n k %d ",k);*/ exact=false; for (i=0;i<lCount;i++) { sum=0; for (j=0;j<lCount;j++) { d1=NORM(X[k],V[i]); d2=NORM(X[k],V[j]); if(d2!=0) { d= d1/d2; d= d * d;/* pow(d1/d2,2.0/(m-1.0)); */ sum+=d; } else { exact = true; for(l=0;l<lCount;l++) if (l==j) U1[l][k]=1.0; else U1[l][k]=0.0; break; } } if (exact!=true) U1[i][k]=1.0/sum; } } } /* end UMAT */ /* The function FINISHED determines if a termination occurs. If not it updates U with U1, so its side-effect is the potential modification of U */ BOOLEAN FINISHED( matrix U1,float eps) //matrix U1; float eps; { /* Parameters: U1, eps-- same as in main */ float sum; /* sum of squared differences between corresponding elements of U and U1 */ int i,k; /* loop control variabes */ BOOLEAN finished; /* set to true if all corresponding elements are within epsilon */ finished = TRUE; sum = 0; for (i=0; i<lCount; i++) for (k=0; k<n; k++) sum += (U[i][k] - U1[i][k])*(U[i][k]-U1[i][k]); if (sqrt(sum) > eps) { finished = FALSE; for (i=0; i<lCount; i++) for (k=0; k<n; k++) U[i][k] = U1[i][k]; } /* end if */ return finished; } /* end FINISHED */ /* The CLUSTER procedure determines cluster centers in V for the c classes being searched for. The global array V is updated */ void CLUSTER( matrix U, objects X) //matrix U; objects X; { /* Parameters: U, X -- as in main */ int i, j, k; /* loop control variables */ feature num; /* numerator in the cluster center computation formula presented by Bezdek */ float denum; /* denumenator in the obove formula */ for (i=0; i<lCount; i++) { denum = 0; for (j=0; j<s; j++) { num[j] = 0; for (k=0; k<n; k++) num[j] += U[i][k] * U[i][k] * X[k][j]; /* pow(U[i][k],m) * X[k][j]; */ } /* end for */ for (k=0; k<n; k++) denum += U[i][k] * U[i][k]; /* pow(U[i][k],m); */ for (j=0; j<s; j++) V[i][j] = num[j] / denum; } /* end for */ } /* end CLUSTER */ float Compute_Jm(center V, objects X) //center V; //objects X; { int i, k,found; double Jm_value; float u,dik; Jm_value = 0; for (k=0; k<n; k++) { found = FALSE; for (i=0; i<lCount; i++) { dik=NORM(X[k],V[i]); dik=dik*dik; if (dik==0.0) { if (found == FALSE) { u=1.0; found = TRUE; printf("found the case with dik=0\n"); } else { printf("\n cant proceed with this initialization"); exit(1); } } else { if (found != TRUE) u=U1[i][k]; /* get_Uvalue(V,X,dik,k); */ else u=0.0; } Jm_value += u * u * dik;/* pow(u, m) * dik; */ } } return (Jm_value); } /* end Compute_Jm */ /* The Output procedure outputs the U matrix which gives the fuzzy measure of each feature belonging to a cluster center. It also outputs the cluster center for each class */ void Output(char fname[]) //char fname[80]; /* Parameters: U, V -- same as in main */ { int i, j, found; /* loop control variables */ float J2c; if ((fp=fopen(fname,"a"))==NULL) printf("\n CAN'T OPEN %s\n",fname); else { fprintf(fp,"\n The cluster centers are: \n"); fprintf(fp,"\n \n"); for (i=0; i<lCount; i++) { fprintf(fp,"\nCluster center %d: ",i+1); fprintf(fp,"\n"); for (j=0; j<s; j++) fprintf(fp,"%8.7f ",V[i][j]); } /* end for */ fprintf(fp,"\nThe membership grades for the feature vectors are:\n"); for (j=0; j<n; j++) { fprintf(fp,"\n"); for (i=0; i<lCount; i++) fprintf(fp," %8.7f",U[i][j]); } /* end for */ } /* end if */ J2c= Compute_Jm(V,X); found =0; for (i=0;i<= mins; i++){ if ((found == 0) && ((J2c - mintab[i]) < .001) && ((J2c - mintab[i]) > -.001)){ mincount[i]++; found = 1; } } if (found == 0){ mins++; mintab[mins]=J2c; mincount[mins]=1; } fprintf(fp,"\nJ%3.1f = %f", m,J2c); fprintf(fp, "Number of iterations: %d\n\n", z); aveit=aveit + z; fclose(fp); } /***************************************************************/ void find_covar(int m) //int m; { int i,j,k; float mean[s],sum; for (i=0;i<s;i++) mean[i]=0; for (i=0;i<s;i++) for (j=0;j<m;j++) mean[i]+=X[j][i]; for (i=0;i<s;i++) mean[i]/=m; for (i=0;i<s;i++) for (j=0;j<s;j++) { sum=0; for (k=0;k<m;k++) sum+=(X[k][i]-mean[i])*(X[k][j]-mean[j]); Y[i][j]=sum/m; } }
Parag Kanade/fuzzy ants/Gauss500-1/gauss500_01.data
gauss Data | |
# | |
1.20790910 | 3.72105890 |
1.22318330 | 4.62444200 |
1.27242740 | 3.72119890 |
1.39058610 | 2.85282570 |
1.52632060 | 3.19027090 |
1.54465150 | 2.90923660 |
2.08176410 | 2.29323270 |
2.13295880 | 2.79096560 |
2.20619080 | 2.55876980 |
2.22945410 | 3.70946740 |
2.23116050 | 2.18429310 |
2.37294590 | 2.61465910 |
2.45178300 | 4.09422380 |
2.46312140 | 1.97760290 |
2.46411810 | 3.99186090 |
2.50921260 | 3.20285370 |
2.52496350 | 1.88579450 |
2.54084840 | 3.09384190 |
2.55385850 | 4.13531910 |
2.58099800 | 3.17036370 |
2.62216610 | 4.05325020 |
2.66759260 | 3.50787480 |
2.66931780 | 3.02588030 |
2.67570580 | 1.53863590 |
2.68751670 | 4.39556030 |
2.81365690 | 4.25504410 |
2.83307330 | 4.75222820 |
2.83880630 | 4.80213920 |
2.83944630 | 4.19682650 |
2.85643290 | 1.77432030 |
2.86941540 | 2.24156170 |
2.88384730 | 3.88449670 |
2.91513020 | 2.51188730 |
2.91979180 | 4.40812900 |
2.95465960 | 4.20401090 |
2.97074170 | 2.43121040 |
3.01351070 | 3.94685690 |
3.04563820 | 3.69689970 |
3.06625130 | 3.90264770 |
3.07317570 | 5.06072370 |
3.09401840 | 5.38469030 |
3.09980030 | 3.01968540 |
3.10625880 | 3.86655360 |
3.11135740 | 2.74664260 |
3.14015020 | 2.32282300 |
3.16450400 | 2.37724910 |
3.16772100 | 4.49169200 |
3.17923370 | 3.19213120 |
3.18903400 | 3.92090930 |
3.19233550 | 5.02698590 |
3.24202770 | 2.68666690 |
3.25633940 | 2.63186020 |
3.26466530 | 3.36216560 |
3.27783900 | 3.59039120 |
3.28408270 | 2.39489040 |
3.31341280 | 3.74656750 |
3.34329660 | 2.30249760 |
3.35886880 | 2.63951690 |
3.37731540 | 3.50969100 |
3.39236820 | 3.77047540 |
3.39283960 | 3.93073540 |
3.40973750 | 3.02436640 |
3.42509050 | 4.29578070 |
3.42564670 | 5.19090880 |
3.42985900 | 4.63892740 |
3.43833830 | 4.59459460 |
3.44998160 | 3.34065440 |
3.46489990 | 3.76339640 |
3.51018710 | 3.09220030 |
3.58142780 | 4.47539960 |
3.58831510 | 2.20499400 |
3.60654970 | 3.73048950 |
3.61092180 | 4.41089130 |
3.68002160 | 3.65956820 |
3.68657310 | 2.87362660 |
3.73646180 | 3.11096490 |
3.78348040 | 4.44785110 |
3.80693700 | 2.21548770 |
3.85050150 | 2.74956110 |
3.88946560 | 3.58457720 |
3.89807100 | 4.44213340 |
3.91916380 | 4.13792570 |
3.92325950 | 2.36911640 |
3.92630710 | 2.34994830 |
3.93368750 | 3.54306570 |
3.95610750 | 2.01434500 |
3.95678700 | 2.29137210 |
3.95973750 | 3.92336320 |
3.96472580 | 3.55419380 |
4.00146640 | 1.59593080 |
4.09676130 | 3.34609180 |
4.11136190 | 4.95612900 |
4.13931330 | 3.12903690 |
4.24274510 | 4.32936230 |
4.24473240 | 2.40552780 |
4.28089580 | 4.18497110 |
4.29582480 | 4.52221000 |
4.33338810 | 4.89267550 |
4.37706670 | 4.14826300 |
4.38728110 | 3.08349770 |
4.39438060 | 1.20470410 |
4.42311330 | 5.14285450 |
4.42424630 | 4.74370290 |
4.47371880 | 5.19608090 |
4.54348320 | 2.95401650 |
4.55423010 | 4.65144570 |
4.55661300 | 3.67922140 |
4.55693430 | 4.35570380 |
4.56818780 | 2.73349690 |
4.61544290 | 4.99191540 |
4.65732870 | 3.63231810 |
4.75235850 | 4.67648360 |
4.75303290 | 1.69703220 |
4.88558470 | 3.10924050 |
4.92029430 | 3.68786210 |
5.06929180 | 4.46140430 |
5.09425100 | 4.99866570 |
5.22136030 | 2.88596540 |
5.29025000 | 4.12315510 |
5.30474090 | 4.05297750 |
5.38075760 | 2.88971840 |
5.40225010 | 4.21574110 |
5.52586830 | 4.60779350 |
5.56029020 | 4.02022760 |
5.59284930 | 5.94734880 |
5.63379210 | 2.04773990 |
4.56496330 | 8.81990280 |
4.94924760 | 9.24178310 |
4.96398430 | 8.13018410 |
5.22679600 | 7.08964560 |
5.51604770 | 8.33961800 |
5.54949660 | 9.31870340 |
5.73213920 | 7.30918760 |
5.78872000 | 7.96719220 |
5.80742230 | 8.16041300 |
5.80772180 | 9.28296680 |
5.84010640 | 8.43407780 |
5.88878260 | 9.18261600 |
5.93854940 | 7.08269680 |
6.01732790 | 10.01593400 |
6.13331750 | 9.06412020 |
6.14938460 | 5.58131310 |
6.32476160 | 8.50081580 |
6.35965520 | 8.43000210 |
6.44987570 | 8.46609640 |
6.50398860 | 9.12919810 |
6.55778340 | 6.13529350 |
6.62439690 | 7.18625970 |
6.66533610 | 7.89935120 |
6.67529210 | 7.25224350 |
6.69788670 | 7.91823120 |
6.70500830 | 10.97463400 |
6.74736090 | 7.24850780 |
6.74938060 | 7.51299370 |
6.78877990 | 7.85880770 |
6.83635100 | 7.21746830 |
6.87264510 | 8.08347420 |
6.89035080 | 6.72500990 |
6.89074810 | 8.72978990 |
6.89556320 | 7.21410970 |
6.91331220 | 10.33794100 |
6.98172740 | 7.63455400 |
6.99855530 | 6.02362240 |
7.09174110 | 7.55206390 |
7.11107720 | 8.55369310 |
7.13839200 | 7.24159980 |
7.16242050 | 7.74177850 |
7.16753040 | 8.34244030 |
7.19596080 | 7.67605230 |
7.19600340 | 8.48065380 |
7.20138350 | 9.69803770 |
7.21410180 | 8.68375570 |
7.23488380 | 6.43974970 |
7.24224830 | 7.34937430 |
7.24308230 | 7.76448210 |
7.26136760 | 8.86718760 |
7.29467750 | 7.15935710 |
7.33502880 | 8.46004700 |
7.33583100 | 9.45610450 |
7.34010160 | 9.13983420 |
7.37391630 | 7.92165490 |
7.43575000 | 7.36740770 |
7.47351160 | 7.36219690 |
7.50943180 | 8.74251930 |
7.51927650 | 7.09198750 |
7.52303360 | 7.31811160 |
7.53891530 | 8.37066250 |
7.56902300 | 9.69571210 |
7.68146310 | 7.04343990 |
7.71449540 | 5.19183500 |
7.71988930 | 9.08293360 |
7.78037680 | 7.88613490 |
7.93262710 | 8.18044940 |
7.97323520 | 7.99187600 |
7.98495340 | 7.88536950 |
8.11242610 | 7.37063310 |
8.11544250 | 8.90069810 |
8.12542490 | 6.09283890 |
8.27950630 | 8.55703860 |
8.29758040 | 7.17683620 |
8.38008940 | 7.23224310 |
9.14977290 | 8.41239770 |
0.14794639 | 9.97961100 |
0.87296376 | 12.25967700 |
0.95057589 | 10.25391200 |
1.17749740 | 10.07844500 |
1.22125760 | 11.18073600 |
1.33193920 | 12.25034600 |
1.34172490 | 10.92280400 |
1.36668230 | 11.05772600 |
1.43430450 | 10.84407300 |
1.46370020 | 11.50454500 |
1.57309490 | 12.12008300 |
1.69603260 | 10.71967200 |
1.71769480 | 10.68105200 |
1.73597100 | 12.28138600 |
1.79071270 | 10.97072200 |
1.89341280 | 12.57715300 |
1.90672830 | 11.33818500 |
1.96209270 | 12.09142100 |
1.99673980 | 12.70860600 |
2.00474310 | 11.37161400 |
2.04421500 | 10.68913300 |
2.08722420 | 12.30532500 |
2.08879850 | 11.69753500 |
2.20018500 | 12.66379400 |
2.20085780 | 10.88587900 |
2.25572220 | 10.88979800 |
2.28927610 | 9.60072350 |
2.30283070 | 10.63739200 |
2.34192850 | 10.22409200 |
2.34228770 | 10.20432700 |
2.35837570 | 12.04876100 |
2.38938590 | 11.91840600 |
2.41693470 | 12.29231400 |
2.45767500 | 11.09708100 |
2.45786590 | 11.97433900 |
2.47888920 | 12.15292500 |
2.50464770 | 12.38179100 |
2.50590350 | 12.73737100 |
2.56210210 | 11.85764700 |
2.67207820 | 9.41642710 |
2.69590010 | 12.99519600 |
2.69928480 | 11.47312700 |
2.70662150 | 10.62388600 |
2.72956480 | 11.27896300 |
2.74608850 | 11.57901500 |
2.86995370 | 13.05209000 |
2.87165180 | 13.41363400 |
2.88735720 | 12.96273800 |
2.90458980 | 12.71584900 |
2.94569430 | 11.24886600 |
2.97652460 | 12.88339300 |
2.98191090 | 13.26836000 |
2.99856800 | 12.24334200 |
3.04330960 | 13.34705800 |
3.05960440 | 13.05621500 |
3.07944220 | 11.75840700 |
3.11295220 | 11.22429300 |
3.14139420 | 11.92967100 |
3.16274410 | 13.15897700 |
3.17671860 | 11.18468300 |
3.17819640 | 12.23026600 |
3.24316480 | 12.96259800 |
3.26183990 | 11.53375400 |
3.38296950 | 11.58900800 |
3.39006150 | 12.29883300 |
3.40722920 | 11.45213100 |
3.46309720 | 13.51363000 |
3.48651150 | 11.16625900 |
3.48980800 | 11.30236500 |
3.49857810 | 11.17645400 |
3.49956030 | 12.33953700 |
3.50158880 | 12.54662300 |
3.51269070 | 13.18131800 |
3.51868070 | 11.24392300 |
3.52004940 | 12.60635900 |
3.55460590 | 12.52347500 |
3.55935130 | 13.20819000 |
3.62011300 | 13.04117400 |
3.75619870 | 12.16167200 |
3.77773560 | 11.77477900 |
3.79934290 | 12.86226800 |
3.81080360 | 13.17230500 |
3.81384880 | 14.48241200 |
3.97179070 | 12.81386100 |
3.99469290 | 13.56421500 |
4.00593370 | 12.62987100 |
4.01141640 | 12.94734500 |
4.03763150 | 11.08670200 |
4.13606590 | 11.97887100 |
4.19763770 | 13.45016000 |
4.37603220 | 11.31880000 |
4.42905310 | 12.54053600 |
4.44971780 | 12.76788900 |
4.45278030 | 12.62002400 |
4.63880080 | 12.74506600 |
4.64736980 | 12.45052900 |
4.75663770 | 13.14369800 |
4.79004530 | 12.38207400 |
4.87588930 | 12.90501000 |
4.90238840 | 12.81827300 |
4.97880720 | 11.95991400 |
5.03241930 | 12.25283300 |
5.34790270 | 11.87561800 |
8.46521070 | 2.68311350 |
8.52442550 | 1.11853270 |
8.67661500 | 2.13651330 |
8.70603570 | 4.88009440 |
9.05078220 | 4.93069960 |
9.09261750 | 5.54696160 |
9.16203610 | 3.43624720 |
9.52865900 | 4.96536840 |
9.68202000 | 4.93236340 |
9.81131050 | 5.04474820 |
9.83952930 | 3.28463710 |
9.89044360 | 3.97566880 |
9.90190200 | 4.05961210 |
10.00957000 | 3.83878480 |
10.04175700 | 3.29727220 |
10.07012400 | 3.59750180 |
10.12569800 | 5.21450270 |
10.13737000 | 5.06962500 |
10.17977800 | 2.71180740 |
10.30071400 | 2.81169900 |
10.30258900 | 4.68952940 |
10.31004400 | 3.39047430 |
10.36094800 | 4.04840500 |
10.38777600 | 2.65069700 |
10.40494800 | 2.36508410 |
10.41509700 | 4.01420430 |
10.41704700 | 3.46878260 |
10.44274500 | 5.03026400 |
10.44372100 | 4.14097060 |
10.44794100 | 5.89888690 |
10.47658200 | 3.74385900 |
10.51515800 | 5.10607600 |
10.59575200 | 3.86267340 |
10.61560200 | 3.20222610 |
10.61961000 | 5.76297450 |
10.63234700 | 3.37483350 |
10.65750300 | 3.27475530 |
10.70975800 | 5.02876970 |
10.74794400 | 5.01521760 |
10.75237100 | 4.71894070 |
10.81876900 | 3.78021970 |
10.82088800 | 3.12724520 |
10.83051500 | 5.60152800 |
10.86365600 | 2.65339460 |
10.88482000 | 5.26577010 |
10.90414800 | 4.89656370 |
10.93918700 | 3.15856750 |
10.95262800 | 2.27413580 |
10.97361300 | 4.86119440 |
10.97606000 | 2.95091260 |
11.00025100 | 4.87971710 |
11.00443500 | 2.87298020 |
11.00487400 | 4.99616980 |
11.00894900 | 4.45823450 |
11.02545500 | 4.38707080 |
11.04502200 | 4.99164180 |
11.09629500 | 2.97304400 |
11.19527800 | 2.96275470 |
11.21192000 | 4.38513520 |
11.21560300 | 4.15389300 |
11.36223500 | 2.94083170 |
11.48733800 | 3.45545070 |
11.50706100 | 4.90595590 |
11.54495400 | 3.07483510 |
11.56112500 | 3.31124010 |
11.57547800 | 3.28234880 |
11.61449000 | 4.98729330 |
11.61803700 | 3.91622200 |
11.63065000 | 4.32804290 |
11.66666800 | 4.04761060 |
11.69318900 | 4.54265920 |
11.71092000 | 2.57448550 |
11.71747900 | 3.53853580 |
11.72360300 | 4.82693130 |
11.74095600 | 4.53624170 |
11.81034200 | 3.33452410 |
11.88485200 | 5.29660640 |
11.88918000 | 2.40882330 |
11.90812400 | 4.46929530 |
11.92066900 | 5.10469960 |
12.06688200 | 4.24435140 |
12.11959600 | 3.81954270 |
12.13463800 | 4.05018190 |
12.15121000 | 5.09391660 |
12.17471200 | 1.77235590 |
12.23597000 | 5.82360270 |
12.27071900 | 3.93579920 |
12.41840200 | 5.01047690 |
12.42309100 | 4.65551600 |
12.58717000 | 5.48074750 |
12.60821600 | 5.59588540 |
12.62136500 | 5.10096210 |
12.63983700 | 5.78542180 |
12.67532200 | 3.08836940 |
12.88580600 | 4.53693810 |
13.12371200 | 3.13710230 |
13.31430800 | 4.26492890 |
8.12719180 | 13.29639700 |
9.04106330 | 13.24608600 |
9.07657040 | 12.28166900 |
9.15794410 | 12.82111200 |
9.20492930 | 12.13289400 |
9.25094630 | 11.36860000 |
9.29959740 | 13.31582100 |
9.44880220 | 11.79787900 |
9.47187580 | 13.40053700 |
9.60374990 | 13.16798100 |
9.62998540 | 10.91674400 |
9.63856090 | 13.13439400 |
9.72228300 | 10.34876500 |
9.87687880 | 10.79534100 |
9.88051540 | 11.42727800 |
9.92456650 | 12.17199200 |
9.94197530 | 10.11674000 |
9.94583880 | 11.57250200 |
9.99630910 | 11.91016200 |
9.99776370 | 10.26438300 |
10.12010800 | 12.29802800 |
10.16164200 | 10.23556100 |
10.25961900 | 12.53857900 |
10.27886500 | 11.90784800 |
10.28485100 | 12.78127000 |
10.30212600 | 11.55107700 |
10.41908200 | 11.56086200 |
10.45122900 | 12.87717000 |
10.48102200 | 12.63129500 |
10.48728900 | 11.29968300 |
10.57084400 | 11.07369500 |
10.58737300 | 12.50664700 |
10.62594400 | 11.49938600 |
10.64176100 | 11.15718600 |
10.64511000 | 10.94285200 |
10.66789800 | 13.98203800 |
10.67048500 | 11.95564100 |
10.70635600 | 11.36171500 |
10.71106100 | 12.23674400 |
10.77142800 | 10.76609500 |
10.77560700 | 14.05258700 |
10.88680500 | 11.02355400 |
10.92819600 | 9.22391410 |
10.95017900 | 12.18759200 |
10.96660900 | 11.02039600 |
10.98409700 | 11.00589000 |
10.99799700 | 12.66918500 |
11.08956900 | 12.39886800 |
11.10849400 | 11.91033400 |
11.14779800 | 11.72434200 |
11.15511500 | 14.12141600 |
11.15875800 | 12.71864300 |
11.21317900 | 10.73132600 |
11.22268900 | 11.89486600 |
11.23743900 | 12.72826900 |
11.24774200 | 13.20666200 |
11.25684200 | 12.44251400 |
11.26917800 | 11.62872800 |
11.35049800 | 11.56381600 |
11.46988300 | 12.18857100 |
11.49420000 | 12.38967000 |
11.52686000 | 10.77942800 |
11.55350500 | 12.53957200 |
11.55941800 | 13.57071200 |
11.56770700 | 12.90194800 |
11.63469200 | 10.07494800 |
11.63483700 | 12.23668400 |
11.64180700 | 12.72672800 |
11.67708900 | 12.33253800 |
11.76721500 | 13.09220900 |
11.78101600 | 10.59577900 |
11.87888600 | 12.32909800 |
11.89113700 | 11.18777000 |
11.89519300 | 9.65998290 |
11.94527300 | 11.15652100 |
11.94926100 | 10.94432800 |
11.99813800 | 11.18681500 |
12.01272000 | 12.27014800 |
12.02110800 | 13.49550800 |
12.02660200 | 11.86160900 |
12.05616400 | 11.72890500 |
12.06579400 | 11.84558600 |
12.08769700 | 13.52384800 |
12.10513600 | 11.63889300 |
12.19760400 | 12.02264500 |
12.29602500 | 13.50911500 |
12.34908800 | 12.00290200 |
12.37035300 | 14.05121500 |
12.42581800 | 10.55447000 |
12.46564200 | 10.74513400 |
12.47088300 | 11.28020800 |
12.47389700 | 11.42576900 |
12.51639400 | 11.22290100 |
12.64667100 | 11.88991900 |
12.65157200 | 13.06442800 |
12.88839300 | 10.70949500 |
13.07564100 | 12.57658800 |
14.00985600 | 12.54814700 |
Parag Kanade/fuzzy ants/Gauss500-1/gauss500_01Full.data
1 | 1.2079091 | 3.7210589 |
1 | 1.2231833 | 4.624442 |
1 | 1.2724274 | 3.7211989 |
1 | 1.3905861 | 2.8528257 |
1 | 1.5263206 | 3.1902709 |
1 | 1.5446515 | 2.9092366 |
1 | 2.0817641 | 2.2932327 |
1 | 2.1329588 | 2.7909656 |
1 | 2.2061908 | 2.5587698 |
1 | 2.2294541 | 3.7094674 |
1 | 2.2311605 | 2.1842931 |
1 | 2.3729459 | 2.6146591 |
1 | 2.451783 | 4.0942238 |
1 | 2.4631214 | 1.9776029 |
1 | 2.4641181 | 3.9918609 |
1 | 2.5092126 | 3.2028537 |
1 | 2.5249635 | 1.8857945 |
1 | 2.5408484 | 3.0938419 |
1 | 2.5538585 | 4.1353191 |
1 | 2.580998 | 3.1703637 |
1 | 2.6221661 | 4.0532502 |
1 | 2.6675926 | 3.5078748 |
1 | 2.6693178 | 3.0258803 |
1 | 2.6757058 | 1.5386359 |
1 | 2.6875167 | 4.3955603 |
1 | 2.8136569 | 4.2550441 |
1 | 2.8330733 | 4.7522282 |
1 | 2.8388063 | 4.8021392 |
1 | 2.8394463 | 4.1968265 |
1 | 2.8564329 | 1.7743203 |
1 | 2.8694154 | 2.2415617 |
1 | 2.8838473 | 3.8844967 |
1 | 2.9151302 | 2.5118873 |
1 | 2.9197918 | 4.408129 |
1 | 2.9546596 | 4.2040109 |
1 | 2.9707417 | 2.4312104 |
1 | 3.0135107 | 3.9468569 |
1 | 3.0456382 | 3.6968997 |
1 | 3.0662513 | 3.9026477 |
1 | 3.0731757 | 5.0607237 |
1 | 3.0940184 | 5.3846903 |
1 | 3.0998003 | 3.0196854 |
1 | 3.1062588 | 3.8665536 |
1 | 3.1113574 | 2.7466426 |
1 | 3.1401502 | 2.322823 |
1 | 3.164504 | 2.3772491 |
1 | 3.167721 | 4.491692 |
1 | 3.1792337 | 3.1921312 |
1 | 3.189034 | 3.9209093 |
1 | 3.1923355 | 5.0269859 |
1 | 3.2420277 | 2.6866669 |
1 | 3.2563394 | 2.6318602 |
1 | 3.2646653 | 3.3621656 |
1 | 3.277839 | 3.5903912 |
1 | 3.2840827 | 2.3948904 |
1 | 3.3134128 | 3.7465675 |
1 | 3.3432966 | 2.3024976 |
1 | 3.3588688 | 2.6395169 |
1 | 3.3773154 | 3.509691 |
1 | 3.3923682 | 3.7704754 |
1 | 3.3928396 | 3.9307354 |
1 | 3.4097375 | 3.0243664 |
1 | 3.4250905 | 4.2957807 |
1 | 3.4256467 | 5.1909088 |
1 | 3.429859 | 4.6389274 |
1 | 3.4383383 | 4.5945946 |
1 | 3.4499816 | 3.3406544 |
1 | 3.4648999 | 3.7633964 |
1 | 3.5101871 | 3.0922003 |
1 | 3.5814278 | 4.4753996 |
1 | 3.5883151 | 2.204994 |
1 | 3.6065497 | 3.7304895 |
1 | 3.6109218 | 4.4108913 |
1 | 3.6800216 | 3.6595682 |
1 | 3.6865731 | 2.8736266 |
1 | 3.7364618 | 3.1109649 |
1 | 3.7834804 | 4.4478511 |
1 | 3.806937 | 2.2154877 |
1 | 3.8505015 | 2.7495611 |
1 | 3.8894656 | 3.5845772 |
1 | 3.898071 | 4.4421334 |
1 | 3.9191638 | 4.1379257 |
1 | 3.9232595 | 2.3691164 |
1 | 3.9263071 | 2.3499483 |
1 | 3.9336875 | 3.5430657 |
1 | 3.9561075 | 2.014345 |
1 | 3.956787 | 2.2913721 |
1 | 3.9597375 | 3.9233632 |
1 | 3.9647258 | 3.5541938 |
1 | 4.0014664 | 1.5959308 |
1 | 4.0967613 | 3.3460918 |
1 | 4.1113619 | 4.956129 |
1 | 4.1393133 | 3.1290369 |
1 | 4.2427451 | 4.3293623 |
1 | 4.2447324 | 2.4055278 |
1 | 4.2808958 | 4.1849711 |
1 | 4.2958248 | 4.52221 |
1 | 4.3333881 | 4.8926755 |
1 | 4.3770667 | 4.148263 |
1 | 4.3872811 | 3.0834977 |
1 | 4.3943806 | 1.2047041 |
1 | 4.4231133 | 5.1428545 |
1 | 4.4242463 | 4.7437029 |
1 | 4.4737188 | 5.1960809 |
1 | 4.5434832 | 2.9540165 |
1 | 4.5542301 | 4.6514457 |
1 | 4.556613 | 3.6792214 |
1 | 4.5569343 | 4.3557038 |
1 | 4.5681878 | 2.7334969 |
1 | 4.6154429 | 4.9919154 |
1 | 4.6573287 | 3.6323181 |
1 | 4.7523585 | 4.6764836 |
1 | 4.7530329 | 1.6970322 |
1 | 4.8855847 | 3.1092405 |
1 | 4.9202943 | 3.6878621 |
1 | 5.0692918 | 4.4614043 |
1 | 5.094251 | 4.9986657 |
1 | 5.2213603 | 2.8859654 |
1 | 5.29025 | 4.1231551 |
1 | 5.3047409 | 4.0529775 |
1 | 5.3807576 | 2.8897184 |
1 | 5.4022501 | 4.2157411 |
1 | 5.5258683 | 4.6077935 |
1 | 5.5602902 | 4.0202276 |
1 | 5.5928493 | 5.9473488 |
1 | 5.6337921 | 2.0477399 |
2 | 4.5649633 | 8.8199028 |
2 | 4.9492476 | 9.2417831 |
2 | 4.9639843 | 8.1301841 |
2 | 5.226796 | 7.0896456 |
2 | 5.5160477 | 8.339618 |
2 | 5.5494966 | 9.3187034 |
2 | 5.7321392 | 7.3091876 |
2 | 5.78872 | 7.9671922 |
2 | 5.8074223 | 8.160413 |
2 | 5.8077218 | 9.2829668 |
2 | 5.8401064 | 8.4340778 |
2 | 5.8887826 | 9.182616 |
2 | 5.9385494 | 7.0826968 |
2 | 6.0173279 | 10.015934 |
2 | 6.1333175 | 9.0641202 |
2 | 6.1493846 | 5.5813131 |
2 | 6.3247616 | 8.5008158 |
2 | 6.3596552 | 8.4300021 |
2 | 6.4498757 | 8.4660964 |
2 | 6.5039886 | 9.1291981 |
2 | 6.5577834 | 6.1352935 |
2 | 6.6243969 | 7.1862597 |
2 | 6.6653361 | 7.8993512 |
2 | 6.6752921 | 7.2522435 |
2 | 6.6978867 | 7.9182312 |
2 | 6.7050083 | 10.974634 |
2 | 6.7473609 | 7.2485078 |
2 | 6.7493806 | 7.5129937 |
2 | 6.7887799 | 7.8588077 |
2 | 6.836351 | 7.2174683 |
2 | 6.8726451 | 8.0834742 |
2 | 6.8903508 | 6.7250099 |
2 | 6.8907481 | 8.7297899 |
2 | 6.8955632 | 7.2141097 |
2 | 6.9133122 | 10.337941 |
2 | 6.9817274 | 7.634554 |
2 | 6.9985553 | 6.0236224 |
2 | 7.0917411 | 7.5520639 |
2 | 7.1110772 | 8.5536931 |
2 | 7.138392 | 7.2415998 |
2 | 7.1624205 | 7.7417785 |
2 | 7.1675304 | 8.3424403 |
2 | 7.1959608 | 7.6760523 |
2 | 7.1960034 | 8.4806538 |
2 | 7.2013835 | 9.6980377 |
2 | 7.2141018 | 8.6837557 |
2 | 7.2348838 | 6.4397497 |
2 | 7.2422483 | 7.3493743 |
2 | 7.2430823 | 7.7644821 |
2 | 7.2613676 | 8.8671876 |
2 | 7.2946775 | 7.1593571 |
2 | 7.3350288 | 8.460047 |
2 | 7.335831 | 9.4561045 |
2 | 7.3401016 | 9.1398342 |
2 | 7.3739163 | 7.9216549 |
2 | 7.43575 | 7.3674077 |
2 | 7.4735116 | 7.3621969 |
2 | 7.5094318 | 8.7425193 |
2 | 7.5192765 | 7.0919875 |
2 | 7.5230336 | 7.3181116 |
2 | 7.5389153 | 8.3706625 |
2 | 7.569023 | 9.6957121 |
2 | 7.6814631 | 7.0434399 |
2 | 7.7144954 | 5.191835 |
2 | 7.7198893 | 9.0829336 |
2 | 7.7803768 | 7.8861349 |
2 | 7.9326271 | 8.1804494 |
2 | 7.9732352 | 7.991876 |
2 | 7.9849534 | 7.8853695 |
2 | 8.1124261 | 7.3706331 |
2 | 8.1154425 | 8.9006981 |
2 | 8.1254249 | 6.0928389 |
2 | 8.2795063 | 8.5570386 |
2 | 8.2975804 | 7.1768362 |
2 | 8.3800894 | 7.2322431 |
2 | 9.1497729 | 8.4123977 |
3 | 0.14794639 | 9.979611 |
3 | 0.87296376 | 12.259677 |
3 | 0.95057589 | 10.253912 |
3 | 1.1774974 | 10.078445 |
3 | 1.2212576 | 11.180736 |
3 | 1.3319392 | 12.250346 |
3 | 1.3417249 | 10.922804 |
3 | 1.3666823 | 11.057726 |
3 | 1.4343045 | 10.844073 |
3 | 1.4637002 | 11.504545 |
3 | 1.5730949 | 12.120083 |
3 | 1.6960326 | 10.719672 |
3 | 1.7176948 | 10.681052 |
3 | 1.735971 | 12.281386 |
3 | 1.7907127 | 10.970722 |
3 | 1.8934128 | 12.577153 |
3 | 1.9067283 | 11.338185 |
3 | 1.9620927 | 12.091421 |
3 | 1.9967398 | 12.708606 |
3 | 2.0047431 | 11.371614 |
3 | 2.044215 | 10.689133 |
3 | 2.0872242 | 12.305325 |
3 | 2.0887985 | 11.697535 |
3 | 2.200185 | 12.663794 |
3 | 2.2008578 | 10.885879 |
3 | 2.2557222 | 10.889798 |
3 | 2.2892761 | 9.6007235 |
3 | 2.3028307 | 10.637392 |
3 | 2.3419285 | 10.224092 |
3 | 2.3422877 | 10.204327 |
3 | 2.3583757 | 12.048761 |
3 | 2.3893859 | 11.918406 |
3 | 2.4169347 | 12.292314 |
3 | 2.457675 | 11.097081 |
3 | 2.4578659 | 11.974339 |
3 | 2.4788892 | 12.152925 |
3 | 2.5046477 | 12.381791 |
3 | 2.5059035 | 12.737371 |
3 | 2.5621021 | 11.857647 |
3 | 2.6720782 | 9.4164271 |
3 | 2.6959001 | 12.995196 |
3 | 2.6992848 | 11.473127 |
3 | 2.7066215 | 10.623886 |
3 | 2.7295648 | 11.278963 |
3 | 2.7460885 | 11.579015 |
3 | 2.8699537 | 13.05209 |
3 | 2.8716518 | 13.413634 |
3 | 2.8873572 | 12.962738 |
3 | 2.9045898 | 12.715849 |
3 | 2.9456943 | 11.248866 |
3 | 2.9765246 | 12.883393 |
3 | 2.9819109 | 13.26836 |
3 | 2.998568 | 12.243342 |
3 | 3.0433096 | 13.347058 |
3 | 3.0596044 | 13.056215 |
3 | 3.0794422 | 11.758407 |
3 | 3.1129522 | 11.224293 |
3 | 3.1413942 | 11.929671 |
3 | 3.1627441 | 13.158977 |
3 | 3.1767186 | 11.184683 |
3 | 3.1781964 | 12.230266 |
3 | 3.2431648 | 12.962598 |
3 | 3.2618399 | 11.533754 |
3 | 3.3829695 | 11.589008 |
3 | 3.3900615 | 12.298833 |
3 | 3.4072292 | 11.452131 |
3 | 3.4630972 | 13.51363 |
3 | 3.4865115 | 11.166259 |
3 | 3.489808 | 11.302365 |
3 | 3.4985781 | 11.176454 |
3 | 3.4995603 | 12.339537 |
3 | 3.5015888 | 12.546623 |
3 | 3.5126907 | 13.181318 |
3 | 3.5186807 | 11.243923 |
3 | 3.5200494 | 12.606359 |
3 | 3.5546059 | 12.523475 |
3 | 3.5593513 | 13.20819 |
3 | 3.620113 | 13.041174 |
3 | 3.7561987 | 12.161672 |
3 | 3.7777356 | 11.774779 |
3 | 3.7993429 | 12.862268 |
3 | 3.8108036 | 13.172305 |
3 | 3.8138488 | 14.482412 |
3 | 3.9717907 | 12.813861 |
3 | 3.9946929 | 13.564215 |
3 | 4.0059337 | 12.629871 |
3 | 4.0114164 | 12.947345 |
3 | 4.0376315 | 11.086702 |
3 | 4.1360659 | 11.978871 |
3 | 4.1976377 | 13.45016 |
3 | 4.3760322 | 11.3188 |
3 | 4.4290531 | 12.540536 |
3 | 4.4497178 | 12.767889 |
3 | 4.4527803 | 12.620024 |
3 | 4.6388008 | 12.745066 |
3 | 4.6473698 | 12.450529 |
3 | 4.7566377 | 13.143698 |
3 | 4.7900453 | 12.382074 |
3 | 4.8758893 | 12.90501 |
3 | 4.9023884 | 12.818273 |
3 | 4.9788072 | 11.959914 |
3 | 5.0324193 | 12.252833 |
3 | 5.3479027 | 11.875618 |
4 | 8.4652107 | 2.6831135 |
4 | 8.5244255 | 1.1185327 |
4 | 8.676615 | 2.1365133 |
4 | 8.7060357 | 4.8800944 |
4 | 9.0507822 | 4.9306996 |
4 | 9.0926175 | 5.5469616 |
4 | 9.1620361 | 3.4362472 |
4 | 9.528659 | 4.9653684 |
4 | 9.68202 | 4.9323634 |
4 | 9.8113105 | 5.0447482 |
4 | 9.8395293 | 3.2846371 |
4 | 9.8904436 | 3.9756688 |
4 | 9.901902 | 4.0596121 |
4 | 10.00957 | 3.8387848 |
4 | 10.041757 | 3.2972722 |
4 | 10.070124 | 3.5975018 |
4 | 10.125698 | 5.2145027 |
4 | 10.13737 | 5.069625 |
4 | 10.179778 | 2.7118074 |
4 | 10.300714 | 2.811699 |
4 | 10.302589 | 4.6895294 |
4 | 10.310044 | 3.3904743 |
4 | 10.360948 | 4.048405 |
4 | 10.387776 | 2.650697 |
4 | 10.404948 | 2.3650841 |
4 | 10.415097 | 4.0142043 |
4 | 10.417047 | 3.4687826 |
4 | 10.442745 | 5.030264 |
4 | 10.443721 | 4.1409706 |
4 | 10.447941 | 5.8988869 |
4 | 10.476582 | 3.743859 |
4 | 10.515158 | 5.106076 |
4 | 10.595752 | 3.8626734 |
4 | 10.615602 | 3.2022261 |
4 | 10.61961 | 5.7629745 |
4 | 10.632347 | 3.3748335 |
4 | 10.657503 | 3.2747553 |
4 | 10.709758 | 5.0287697 |
4 | 10.747944 | 5.0152176 |
4 | 10.752371 | 4.7189407 |
4 | 10.818769 | 3.7802197 |
4 | 10.820888 | 3.1272452 |
4 | 10.830515 | 5.601528 |
4 | 10.863656 | 2.6533946 |
4 | 10.88482 | 5.2657701 |
4 | 10.904148 | 4.8965637 |
4 | 10.939187 | 3.1585675 |
4 | 10.952628 | 2.2741358 |
4 | 10.973613 | 4.8611944 |
4 | 10.97606 | 2.9509126 |
4 | 11.000251 | 4.8797171 |
4 | 11.004435 | 2.8729802 |
4 | 11.004874 | 4.9961698 |
4 | 11.008949 | 4.4582345 |
4 | 11.025455 | 4.3870708 |
4 | 11.045022 | 4.9916418 |
4 | 11.096295 | 2.973044 |
4 | 11.195278 | 2.9627547 |
4 | 11.21192 | 4.3851352 |
4 | 11.215603 | 4.153893 |
4 | 11.362235 | 2.9408317 |
4 | 11.487338 | 3.4554507 |
4 | 11.507061 | 4.9059559 |
4 | 11.544954 | 3.0748351 |
4 | 11.561125 | 3.3112401 |
4 | 11.575478 | 3.2823488 |
4 | 11.61449 | 4.9872933 |
4 | 11.618037 | 3.916222 |
4 | 11.63065 | 4.3280429 |
4 | 11.666668 | 4.0476106 |
4 | 11.693189 | 4.5426592 |
4 | 11.71092 | 2.5744855 |
4 | 11.717479 | 3.5385358 |
4 | 11.723603 | 4.8269313 |
4 | 11.740956 | 4.5362417 |
4 | 11.810342 | 3.3345241 |
4 | 11.884852 | 5.2966064 |
4 | 11.88918 | 2.4088233 |
4 | 11.908124 | 4.4692953 |
4 | 11.920669 | 5.1046996 |
4 | 12.066882 | 4.2443514 |
4 | 12.119596 | 3.8195427 |
4 | 12.134638 | 4.0501819 |
4 | 12.15121 | 5.0939166 |
4 | 12.174712 | 1.7723559 |
4 | 12.23597 | 5.8236027 |
4 | 12.270719 | 3.9357992 |
4 | 12.418402 | 5.0104769 |
4 | 12.423091 | 4.655516 |
4 | 12.58717 | 5.4807475 |
4 | 12.608216 | 5.5958854 |
4 | 12.621365 | 5.1009621 |
4 | 12.639837 | 5.7854218 |
4 | 12.675322 | 3.0883694 |
4 | 12.885806 | 4.5369381 |
4 | 13.123712 | 3.1371023 |
4 | 13.314308 | 4.2649289 |
5 | 8.1271918 | 13.296397 |
5 | 9.0410633 | 13.246086 |
5 | 9.0765704 | 12.281669 |
5 | 9.1579441 | 12.821112 |
5 | 9.2049293 | 12.132894 |
5 | 9.2509463 | 11.3686 |
5 | 9.2995974 | 13.315821 |
5 | 9.4488022 | 11.797879 |
5 | 9.4718758 | 13.400537 |
5 | 9.6037499 | 13.167981 |
5 | 9.6299854 | 10.916744 |
5 | 9.6385609 | 13.134394 |
5 | 9.722283 | 10.348765 |
5 | 9.8768788 | 10.795341 |
5 | 9.8805154 | 11.427278 |
5 | 9.9245665 | 12.171992 |
5 | 9.9419753 | 10.11674 |
5 | 9.9458388 | 11.572502 |
5 | 9.9963091 | 11.910162 |
5 | 9.9977637 | 10.264383 |
5 | 10.120108 | 12.298028 |
5 | 10.161642 | 10.235561 |
5 | 10.259619 | 12.538579 |
5 | 10.278865 | 11.907848 |
5 | 10.284851 | 12.78127 |
5 | 10.302126 | 11.551077 |
5 | 10.419082 | 11.560862 |
5 | 10.451229 | 12.87717 |
5 | 10.481022 | 12.631295 |
5 | 10.487289 | 11.299683 |
5 | 10.570844 | 11.073695 |
5 | 10.587373 | 12.506647 |
5 | 10.625944 | 11.499386 |
5 | 10.641761 | 11.157186 |
5 | 10.64511 | 10.942852 |
5 | 10.667898 | 13.982038 |
5 | 10.670485 | 11.955641 |
5 | 10.706356 | 11.361715 |
5 | 10.711061 | 12.236744 |
5 | 10.771428 | 10.766095 |
5 | 10.775607 | 14.052587 |
5 | 10.886805 | 11.023554 |
5 | 10.928196 | 9.2239141 |
5 | 10.950179 | 12.187592 |
5 | 10.966609 | 11.020396 |
5 | 10.984097 | 11.00589 |
5 | 10.997997 | 12.669185 |
5 | 11.089569 | 12.398868 |
5 | 11.108494 | 11.910334 |
5 | 11.147798 | 11.724342 |
5 | 11.155115 | 14.121416 |
5 | 11.158758 | 12.718643 |
5 | 11.213179 | 10.731326 |
5 | 11.222689 | 11.894866 |
5 | 11.237439 | 12.728269 |
5 | 11.247742 | 13.206662 |
5 | 11.256842 | 12.442514 |
5 | 11.269178 | 11.628728 |
5 | 11.350498 | 11.563816 |
5 | 11.469883 | 12.188571 |
5 | 11.4942 | 12.38967 |
5 | 11.52686 | 10.779428 |
5 | 11.553505 | 12.539572 |
5 | 11.559418 | 13.570712 |
5 | 11.567707 | 12.901948 |
5 | 11.634692 | 10.074948 |
5 | 11.634837 | 12.236684 |
5 | 11.641807 | 12.726728 |
5 | 11.677089 | 12.332538 |
5 | 11.767215 | 13.092209 |
5 | 11.781016 | 10.595779 |
5 | 11.878886 | 12.329098 |
5 | 11.891137 | 11.18777 |
5 | 11.895193 | 9.6599829 |
5 | 11.945273 | 11.156521 |
5 | 11.949261 | 10.944328 |
5 | 11.998138 | 11.186815 |
5 | 12.01272 | 12.270148 |
5 | 12.021108 | 13.495508 |
5 | 12.026602 | 11.861609 |
5 | 12.056164 | 11.728905 |
5 | 12.065794 | 11.845586 |
5 | 12.087697 | 13.523848 |
5 | 12.105136 | 11.638893 |
5 | 12.197604 | 12.022645 |
5 | 12.296025 | 13.509115 |
5 | 12.349088 | 12.002902 |
5 | 12.370353 | 14.051215 |
5 | 12.425818 | 10.55447 |
5 | 12.465642 | 10.745134 |
5 | 12.470883 | 11.280208 |
5 | 12.473897 | 11.425769 |
5 | 12.516394 | 11.222901 |
5 | 12.646671 | 11.889919 |
5 | 12.651572 | 13.064428 |
5 | 12.888393 | 10.709495 |
5 | 13.075641 | 12.576588 |
5 | 14.009856 | 12.548147 |
Parag Kanade/fuzzy ants/Gauss500-1/gauss.c
#include "headerStatic.h" /*******************************************************************/ /*** Global Variables ***/ irisData data[MAXDATA]; //To hold the data read from the file int count=0; //Count of the total number of data elements int heapCount=0; // Total number of heaps int heapRow=0; // Rows for the second iteration with heaps int newHeapCount=0; // Count of the heaps for the second iteration heap heaps[MAXDATA]; // Data structure to hold the heap information heap newHeaps[MAXDATA]; // Data Structure to hold the new heap information // For the second iteration int board[MAXROWS][MAXCOLS]; // Board on which the objects are located ant ants[MAXANTS]; // Data structure to hold the ants float Dmax=0; // Distance of the most dissimilar object pair int minHeapCount=100000; // Counter to hold the minimum heap count, used only for academic purpose // no use in the algorithm int minPosition; // the minimum heap iteration , only for academic purpose // no use in the algorithm float clsCen[MAXDATA][MAXDATA][s];//to hold the objects after hardening int cenCount[MAXDATA];//to hold the number of objects after hardening /********************************************************************/ /*** Varaibles to normalize the features between 0 and 1 */ float minInput[features], maxInput[features],scale[features],minForHeaps[features],maxForHeaps[features],scaleForHeaps[features]; /********************************************************************/ /** Variables for the FCM algorithm */ int temp[200]; /* for square matrix tests */ float eps,m; matrix U, U1; BOOLEAN stop; center V; objects X; char fname[80]; FILE *fp; int run; float inv_cov[s+1][s+1]; /* inverse of covariance matrix Y */ float Y[s][s]; long rand_index, Random_seed; long state1[52] = { 9347, 3835, 5194, 8310, 346, 535, 5297, 6711, 77, 3834, 668, 4175, 6868, 5890, 9304, 8462, 5269, 920, 65392, 41600, 70119, 91032, 76220, 26245, 4746, 73608, 32823, 63264, 75641, 99104, 36534, 24704, 98255, 72266, 75336, 65152, 7269, 63163, 88471, 27271, 43641, 76649, 47773, 23777, 27491, 35926, 16651, 48652, 89766, 90921, 6056 }; int z; int mins=0; int aveit =0; float mintab[200]; int mincount[200]; long start,end,total; int lCount;//added by parag /********************************************************************/ /********************************************************************//*int lrand48(){return(rand());}void srand48(int a){return;}*//********************************************************************/ /********************************************************************/ /* Function to read the input data set */ /* The file name is assumed to be itest.data */ /* Status: Tested */ /* Output: Data from the file into the "data" (Global) data structure */ /* Output: Count (Global), the count of the number of objects */ /********************************************************************/ void readInput() { FILE *fp; char fname[80]; int i=0,j=0; char ch; sprintf(fname,"%s.data",filename); /* Check if the input file is opened */ if((fp=fopen(fname,"r"))==NULL) { printf("\n Unable to open input file \n"); exit(0); } /*initialise the minimum maximum and the scale */ for(i=0;i<features;i++) { minInput[i]=1000; maxInput[i]=0; minForHeaps[i]=1000; maxForHeaps[i]=0; scale[i]=0; scaleForHeaps[i]=0; } /* Discard leading comments */ ch = 'c'; while (ch != '#') fscanf (fp, "%c", &ch); i=0; /* Parse the file and populate the data structure */ while(!feof(fp)) { for(j=0;j<features;j++) { fscanf(fp,"%f ",&data[i][j]); } fscanf(fp,"\n"); for(j=0;j<features;j++) { if(data[i][j]<minInput[j]) minInput[j]=data[i][j]; if(data[i][j]>maxInput[j]) maxInput[j]=data[i][j]; } i++; } count=i; /* Normailze the feature values in between 0 and 1 */ for(j=0;j<features;j++) { if(minInput[j]!=maxInput[j]) scale[j]=1.0/(maxInput[j]-minInput[j]); else scale[j]=1.0; } for(i=0;i<count;i++) { for(j=0;j<features;j++) data[i][j]=(data[i][j]-minInput[j])*scale[j]; } fclose(fp); return; }//end of function /********************************************************************/ /*Function to compute the eucldiean distance for all input data set */ /* Output : an array conatining the distance of each object with the other */ /********************************************************************/ float computeDistance() { float distance,dist=0; int i=0,j=0,k=0; distance=0; for(j=0;j<count;j++) for(i=0;i<count;i++) { for(k=0;k<features;k++) dist+=sqrt((data[j][k]-data[i][k])*(data[j][k]-data[i][k])); if(distance<dist)distance=dist; dist=0; } return(distance); } /********************************************************************/ /* Function to compute the distance between two objects */ /* Output : Euclidean d istance between the two input objects */ /********************************************************************/ float computeDistanceBetween2(irisData a,irisData b) { float temp=0; int i=0; for(i=0;i<features;i++) temp+=(a[i]-b[i])*(a[i]-b[i]); temp=sqrt(temp); return(temp); } /********************************************************************/ /* Function to find the maximum distance between the input objects*/ /* Output: the maximum distance */ /* Input : The array of distances between objects */ /********************************************************************/ /*float findMax(float *distance) { int i=0,j=0; float max=distance[0]; for(i=0;i<count;i++) for(j=0;j<count;j++) { if(max<distance[i*count+j]) max=distance[i*count+j]; } return(max); }*/ /********************************************************************/ /* Function to compute the value of an object */ /********************************************************************/ float value(irisData a) { int i=0; float temp=0; for(i=0;i<features;i++) temp+=a[i]*a[i]; return(sqrt(temp)); } /********************************************************************/ /* Function to find the object in the data structure */ /* Output : The position of the object in the data */ /* Input : The object */ /********************************************************************/ int findInData(irisData object,int iFlag) { int i=0,lastCount=0,j,position=-1,flag[features],flg;if(iFlag==1)lastCount=MAXDATA;else{}for(i=0;i<lastCount;i++){ for(j=0;j<features;j++) if(fabs(object[j]-data[i][j])<0.00001) flag[j]=1; else { flag[j]=0; break;} flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /* Function to find whether there is an object on the board at a,b */ /* Output : a flag indicating whether an object is found or not */ /* Input : The row and column indicating the board position */ /********************************************************************/ int found(int a , int b) { if(board[a][b]==9) return 1; else return 0; } /********************************************************************/ /* Function to initialize the initial board */ /* Output : None */ /* Global Structures modified : heaps */ /* Input : Flag indicating the iteration 1: First 0: Second */ /********************************************************************/ void initialise(int flag) { int a,b,i=0,k=0; int loopCount,rowCount,colCount; /* Initialize the row, column and number of heaps */ if(flag==1) { loopCount=count; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=lCount; rowCount=heapRow; colCount=heapRow; } /* Initialize the heaps */ for(i=0;i<loopCount;i++) { heaps[i].count=0; heaps[i].x=0; heaps[i].y=0; heaps[i].disPosition=0; heaps[i].Dmax=0; heaps[i].Dmean=0; } for(i=0;i<loopCount;i++) { /*find a board position which is empty*/ do { a=lrand48()%rowCount; b=lrand48()%colCount; } while(found(a,b)); /*Allocate the object to that place and assign a heap to it*/ heaps[i].x=a; heaps[i].y=b; heaps[i].count=1; heaps[i].Dmax=0; heaps[i].Dmean=0; if(flag==1) { heaps[i].objects[0]=i; for(k=0;k<features;k++)heaps[i].Ocenter[k]=data[i][k]; } else { for(k=0;k<features;k++) heaps[i].Ocenter[k]=newHeaps[i].Ocenter[k]; } heaps[i].disPosition=0; board[a][b]=9; if((debugLevel>0)&&(flag==1))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],data[heaps[i].objects[0]][0]); if((debugLevel>0)&&(flag==0))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],newHeaps[i].Ocenter[0]); } /*initialise the initial heap count*/ heapCount=loopCount; currentRow=rowCount; } /********************************************************************/ /* Function to find whether an heap is present at the location a b */ /* Output : Flag indicating the presencs of the heap */ /* Input : Roe and column indicating the board position */ /********************************************************************/ int findObject(int a,int b) { int i; int position=-1; for(i=0;i<heapCount;i++) { if((heaps[i].x==a)&&(heaps[i].y==b)) { position=i; break; } } return(position); } /********************************************************************/ /* Function initialize the ants */ /* Output : None */ /* Input : Flag indicating the iteration */ /* Global Variables Modified : ant, heapCount, heaps, board */ /********************************************************************/ void initialiseAnts(int flag) { int i=0,a=0,b=0,position,j=0,loopCount=0,rowCount,colCount,k=0; if(flag==1) { loopCount=MAXANTS; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=MAXANTSFORHEAPS; rowCount=heapRow; colCount=heapRow; } for(i=0;i<loopCount;i++) { /*generate random positions for the ants*/ a=lrand48()%rowCount; b=lrand48()%colCount; ants[i].x=a; ants[i].y=b; /*Find if an object is present at that position or not*/ if(board[a][b]==9) { ants[i].carrying=1; /*find the heap at that location*/ position=findObject(a,b); if(position==-1) { printf("\n Error in logic: Ant init \n"); //getchar(); break; } else { /*Assign the heap data to the ant data and decrement the heap count*/ if(flag==1){ for(k=0;k<features;k++)ants[i].data[k]=data[heaps[position].objects[0]][k]; }else{for(k=0;k<features;k++)ants[i].data[k]=heaps[position].Ocenter[k];} for(j=position;j<heapCount-1;j++) heaps[j]=heaps[j+1]; heapCount--; } /*Clear the board position */ board[a][b]=-9; } else ants[i].carrying=-1; ants[i].speed=0; ants[i].dir=lrand48()%8; printf("\n Ant %2d X: %2d Y: %2d Carying : %2d ",i,ants[i].x,ants[i].y,ants[i].carrying); } currentAntCount=loopCount; } /********************************************************************/ /* Function to move the ant */ /* Output: None */ /* Input: Ant to be moved and the flag indicating the iteration */ /********************************************************************/ void moveNext(ant* a,int flag) { int rowCount,colCount; /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; } else { rowCount=heapRow; colCount=heapRow; }*/rowCount=currentRow;colCount=currentRow; /*Depending upon the direction move the ant*/ switch (a->dir) { case 0: a->y++; if(a->y>=colCount)a->y=0; break; case 1: a->x--; a->y++;; if(a->x<0)a->x=rowCount-1; if(a->y>=colCount)a->y=0; break; case 2: a->x--; if(a->x<0)a->x=rowCount-1; break; case 3: a->x--; a->y--; if(a->x<0)a->x=rowCount-1; if(a->y<0)a->y=colCount-1; break; case 4: a->y--; if(a->y<0)a->y=colCount-1; break; case 5: a->x++; a->y--; if(a->x>=rowCount)a->x=0; if(a->y<0)a->y=colCount-1; break; case 6: a->x++; if(a->x>=rowCount) a->x=0; break; case 7: a->x++; a->y++; if(a->x>=rowCount)a->x=0; if(a->y>=colCount)a->y=0; break; } }//end of function /********************************************************************/ /* Function to compute the parameters of the heap */ /* Output: None */ /* Input: The heap whose parameters are to be computed iteration flag*/ /********************************************************************/ void computeHeapParameters(heap* heapData,int flag) { int i=0,j=0,k=0,position=0; float distance=0; float Dmean=0.0; float *dis; float featureSum[features]; float max=0; float sum=0; /* init*/ for(k=0;k<features;k++) featureSum[k]=0; /*Compute the distance of each object and find the maximum distance*/ max=0; if(flag==1){ for(j=0;j<heapData->count;j++) for(i=0;i<heapData->count;i++) { for(k=0;k<features;k++) sum+= (data[heapData->objects[j]][k]-data[heapData->objects[i]][k])*(data[heapData->objects[j]][k]-data[heapData->objects[i]][k]); distance=sqrt(sum); if(max<distance) max=distance; sum=0; } /* Assign the maximum distance to the heap */ heapData->Dmax=max;/*Compute the centre object*/for(i=0;i<heapData->count;i++)for(k=0;k<features;k++) featureSum[k]+=data[heapData->objects[i]][k];for(k=0;k<features;k++)heapData->Ocenter[k]=featureSum[k]*1.0/heapData->count; /* Find the mean distance */if((dis=(float *) calloc(heapData->count,sizeof(float)))==NULL){printf("\nUnable to allocate memory in the compute heap parameters procedure\n");exit(0);} for(i=0;i<heapData->count;i++) { Dmean+=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); dis[i]=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); } heapData->Dmean=Dmean*1.0/heapData->count; /*Compute the most dissimilar object*/ max=dis[0]; for(i=1;i<heapData->count;i++) if(max<dis[i]) { max=dis[i]; position=i; } /*Assign the most dissimilar object to the heap variable*/ for(k=0;k<features;k++) heapData->Odissim[k]=data[heapData->objects[position]][k]; heapData->disPosition=position;free(dis); } else{/* Heap Parameters for the second stage */for(k=0;k<features;k++){ heapData->Odissim[k]=heapData->Ocenter[k];}heapData->disPosition=0;heapData->Dmean=0;heapData->Dmax=0;} }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a single object*/ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject1(ant *a,int position,int flag) { int i,k=0; /*Clear the board*/ board[heaps[position].x][heaps[position].y]=-9; /* Assign the data to the ant*/if(flag==1){ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[0]][k];}else {for(k=0;k<features;k++) a->data[k]=heaps[position].Ocenter[k];} a->carrying=1; /*Copy all the heaps remaining heaps in the structure*/ for(i=position;i<heapCount-1;i++) heaps[i]=heaps[i+1]; /*Decrement the heap count*/ heapCount--; }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a two objects */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject2(ant *a , int position,int flag) { float Pdestroy1=-1; int i=0,k=0; /*Compute the probability to destroy the heap*/ Pdestroy1=lrand48()%13*1.0/12.0; /*If the probability is more than Pdestroy then destroy the heap */ if(Pdestroy1<Pdestroy) { /*pick the object randomly*/ i=lrand48()%2; /* Assign the data to the ant */ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[i]][k]; a->carrying=1; /*Correct the heap parameters*/ heaps[position].count=1; heaps[position].objects[0]=heaps[position].objects[1-i]; computeHeapParameters(&heaps[position],flag); } }//end of function /********************************************************************/ /*Function to pick a object from a heap consisting of more than two object */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /********************************************************************/ void pickObjectn(ant *a,int position,int flag) { int i=0,k=0; /*If the criteria is satsfied then pick the object*/ if((computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)*1.0/heaps[position].Dmean)>Tremove) { a->carrying=1; for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[heaps[position].disPosition]][k]; for(i=heaps[position].disPosition;i<heaps[position].count-1;i++) heaps[position].objects[i]=heaps[position].objects[i+1]; heaps[position].count--; computeHeapParameters(&heaps[position],1); } }//end of function /********************************************************************/ /* Function to pick a object */ /********************************************************************/ void pick(ant *a,int flag) { int position=-1,i=0; float Pload1=-1.0; for(i=0;i<heapCount;i++) { /*Check if a heap is present in the eight neighbouring cells*/ if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if Heap is found*/ if(position!=-1) { /* heap or object found.*/ /*Depending upon the number present in the heap call the corresponding routine*/ switch(heaps[i].count) { case 1: Pload1 = lrand48()%151*1.0/150.0; if(Pload1<Pload) { pickObject1(a,position,flag); } break; case 2: pickObject2(a,position,flag); break; default: pickObjectn(a,position,flag); break; } } } /********************************************************************/ /* Function to drop a object to form a new heap */ /* Output: None */ /* Input: Ant, iteration flag */ /* Global Structure modified : heap, heapCount */ /********************************************************************/ void dropObject(ant* a,int flag) { /*Create a new heap*/ int k=0; heaps[heapCount].count=1; heaps[heapCount].x=a->x; heaps[heapCount].y=a->y; heaps[heapCount].Dmax=0; heaps[heapCount].Dmean=0; heaps[heapCount].disPosition=0; for(k=0;k<features;k++) { heaps[heapCount].Odissim[k]=a->data[k]; heaps[heapCount].Ocenter[k]=a->data[k]; } if(flag==1) {heaps[heapCount].objects[0]=findInData(a->data,flag); /*computeHeapParameters(&heaps[heapCount],flag);*/ } computeHeapParameters(&heaps[heapCount],flag); heapCount++; a->carrying=-1; board[a->x][a->y]=9; }//end of function /********************************************************************/ /* Function to find the heap position during the second iteration */ /* Output: position of the heap */ /* Input: object center of the heap that the ant is carrying */ /* Global Structure modified : none */ /********************************************************************/ int findInNewheaps(irisData object) { int position=-1,i,j=0,flag[features],flg; for(i=0;i<newHeapCount;i++) { for(j=0;j<features;j++) { if(fabs(object[j]-newHeaps[i].Ocenter[j])<0.00001) flag[j]=1; else {flag[j]=0;break;} } flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /*Function to drop a object to a heap consisting of a one or more object */ /* Output: none */ /* Input: Ant, position of the heap , iteration flag */ /* Global Structure modified: heaps,newHeaps */ /********************************************************************/ void dropObject1(ant* a, int position,int flag) { int heapPosition=-1,heapPosition1=-1,i,j,k=0; irisData newData,temp; if(flag==1) { /*Add the object to the heap and compute the heap parameters*/ /*if(heaps[position].count==heaps[position].objCount) {if((junk=(int *)realloc(heaps[position].objects,((heaps[position].objCount+OBJINC)*sizeof(int))))==NULL){printf("\n Cannot Allocate memory to the new object for %d heap",position);exit(0);}heaps[position].objects=junk;heaps[position].objCount+=OBJINC;free(junk); }*/ heaps[position].objects[heaps[position].count]=findInData(a->data,flag); heaps[position].count++; computeHeapParameters(&heaps[position],flag); } else { for(k=0;k<features;k++)temp[k]=heaps[position].Ocenter[k]; heapPosition=findInNewheaps(a->data); heapPosition1=findInNewheaps(heaps[position].Ocenter); if(heapPosition==-1||heapPosition1==-1) { printf("\n error in logic:new heaps\n"); //getchar(); return; } for(k=0;k<features;k++) {newData[k]=(newHeaps[heapPosition].Ocenter[k]*newHeaps[heapPosition].count+newHeaps[heapPosition1].Ocenter[k]*newHeaps[heapPosition1].count)*1.0/(newHeaps[heapPosition].count+newHeaps[heapPosition1].count);newHeaps[heapPosition].Ocenter[k]=newData[k];heaps[position].Ocenter[k]=newData[k]; } computeHeapParameters(&heaps[position],flag); for(i=newHeaps[heapPosition].count,j=0;j<newHeaps[heapPosition1].count;i++,j++) { newHeaps[heapPosition].objects[i]=newHeaps[heapPosition1].objects[j]; } newHeaps[heapPosition].count+=newHeaps[heapPosition1].count; for(i=heapPosition1;i<newHeapCount-1;i++) newHeaps[i]=newHeaps[i+1]; newHeapCount--; } a->carrying=-1; }//end of function /********************************************************************/ /* Function to drop a object */ /* Output: None */ /* Input: Ant, iteration flag */ /********************************************************************/ void drop(ant* a,int flag) { int i, position=-1; float Pdrop1=0.0; /*Find whether we have a heap in the neighbourhood of the cell*/ for(i=0;i<heapCount;i++) { if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if a heap is found*/ if(position!=-1) { /*heap or object found.*/ /*Depending on the number of objects present take action*/ switch(heaps[position].count) { /*If criteria is satisfied then drop the object*/ case 1: if(flag==1) { if((computeDistanceBetween2(a->data,data[heaps[position].objects[0]])*1.0/Dmax)<Tcreate) dropObject1(a,position,flag); } else { if((computeDistanceBetween2(a->data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) dropObject1(a,position,flag); } break; default: if(computeDistanceBetween2(a->data,heaps[position].Ocenter)<computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)) dropObject1(a,position,flag); break; } } else { /*Compute the probability to drop the object*/ Pdrop1 = lrand48()%151*1.0/150; if(Pdrop1<Pdrop) dropObject(a,flag); } }//end of function /********************************************************************/ /* Function to move the ant */ /* Output: none */ /* Input: Ant, iteration flag */ /********************************************************************/ void move(ant* a,int flag) { float pDir; /*Check the speed */ if (a->speed!=0) { /*move in the same direction*/ a->speed--; moveNext(a,flag); } else { /*generate the new direction*/ pDir=lrand48()%17*1.0/16.0; if(pDir<.85) { a->dir=lrand48()%8; } else if(pDir>.95) { a->speed=2; } moveNext(a,flag); } } /********************************************************************/ /* Function to simulate the movement of the ants */ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified: minHeapCount, minHeapPosition */ /********************************************************************/ void iterate(int flag) { int i=0,j=0,k=0,loopCount=0; if (flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS; while (i<MAXITERATIONS) { i++; for(j=0;j<loopCount;j++) { move(&ants[j],flag); if(ants[j].carrying==1) { drop(&ants[j],flag); } else { pick(&ants[j],flag); } } if(debugLevel>0){ for(k=0;k<heapCount;k++) for(j=0;j<heapCount;j++) if((k!=j)&&(heaps[k].x==heaps[j].x)&&(heaps[k].y==heaps[j].y)) { printf("\nerror two heaps with same co ordinates %d %d ",k,j); //getchar(); } k=0; for(j=0;j<heapCount;j++) k+=heaps[j].count; } if(heapCount<minHeapCount) { minHeapCount=heapCount; minPosition=i; } if(debugLevel>0) printf("\n i:%d Heap count %d sum %d",i,heapCount,k); else printf("\n i:%d Heap count %d",i,heapCount); heapSum+=heapCount; /*if(i%updateAfter==0) {adjustBoard(flag); writeIncremental(i,flag);heapSum=0;loopCount=currentAntCount; }*/ } }//end of function /********************************************************************/ /*Function to drop the objects carried by the ants after all the iterations*/ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified:none */ /********************************************************************/ void dropFinal(int flag) { int i=0,j=0,position=-1,loopCount=0; /*if(flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS;*/ loopCount=currentAntCount; for(i=0;i<loopCount;i++) { if(ants[i].carrying==1) { if(flag==1) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position,flag); } } else { /*Find if a heap is present */ do { position=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position,flag); position=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position!=-1); } } } }//end of function /********************************************************************/ /* Function for the implementation of QuickSort */ /* Output: none */ /* Input: data structure, low and high indices */ /* Global structure modified:none */ /********************************************************************/ void quickSort( heap A[], int low,int high ) { int mid=0; if(low<high) { mid=partition(A,low,high); quickSort(A,low,mid); quickSort(A,mid+1,high); } } /********************************************************************/ /* Partition routine used by quick sort */ /* Output: partition location */ /* Input: data , low, high */ /* Global structure modified:none */ /********************************************************************/ int partition(heap a[], int low,int high) { heap temp; int x=0,i=0,j=0; i=low; j=high; x=a[low].count; while (1) { while (a[j].count<x) j=j-1; while (a[i].count>x) i=i+1; if(i<j) { temp=a[i]; a[i]=a[j]; a[j--]=temp; } else return(j); } } /********************************************************************/ /* Function used to write the cluster information */ /* Output: none */ /* Input:iteration flag */ /* Global structure modified:none */ /********************************************************************/ void writeClusterInformation(int flag) { FILE *fp=fopen("center.clt","w"); FILE *fp1; FILE *fp2; FILE *fp3; char temp[80]; int i=0,j=0,k=0; int lastCount=0; int rowCount,colCount,antCount; strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp3=fopen(temp,"a"); if(dataDump) {strcpy(temp,"");sprintf(temp,"%sTot.out",filename);fp1=fopen(temp,"a");strcpy(temp,"");sprintf(temp,"%sObj.out",filename);fp2=fopen(temp,"a");if(fp1==NULL||fp2==NULL)printf("\n Error in opening file in the writer Cluster Information routine\n"); } /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; antCount=MAXANTS; } else { rowCount=heapRow; colCount=heapRow; antCount=MAXANTSFORHEAPS; }*/ rowCount=currentRow; colCount=currentRow; antCount=currentAntCount; if(fp==NULL) { printf("\n Unable to open cluster center output file \n"); /*return;*/ exit(0); } /*sort the array according to the count value and write the value of the top three elements*/ if((flag==1)&&(!EntireHeaps)) quickSort(heaps,0,heapCount); if(EntireHeaps) {if(flag==1) lastCount=heapCount;else lastCount=newHeapCount; } else lastCount=c; for(i=0;i<lastCount;i++) { if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",newHeaps[i].Ocenter[k]); fprintf(fp,"\n"); } else { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); fprintf(fp,"\n"); } } if(dataDump) { fprintf(fp1,"\n Information from the Ant Based Algorithm \n"); fprintf(fp1,"\n Important Parameters : Board %d X %d Ants : %d Iterations %d Total Heaps %d ",rowCount,colCount,antCount,MAXITERATIONS,lastCount); } if(flag==0) { if(dataDump) { fprintf(fp1," TCreateForHeaps %f \n",TcreateForHeaps); fprintf(fp2,"\nTotal Heaps : %d\n",heapCount); fprintf(fp2,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); } fprintf(fp3,"\n@ %d\n",lastCount); } else if(dataDump) fprintf(fp1,"\n");if(dataDump) { fprintf(fp1,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); for(i=0;i<lastCount;i++) if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp2,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); } fprintf(fp1," %5d\n",newHeaps[i].count); fprintf(fp2," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp1," %5d\n",heaps[i].count); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]); fprintf(fp1," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]); fprintf(fp1," %5d\n",heaps[i].count); }} if(flag==0) { if(dataDump) fprintf(fp1,"\n Objects in the heaps \n");for(i=0;i<newHeapCount;i++) { if(dataDump) fprintf(fp1,"\n\n Heap %d\n \n",i+1);fprintf(fp3,"# %d %d\n",i ,newHeaps[i].count); for(j=0;j<newHeaps[i].count;j++){ for(k=0;k<features;k++){ fprintf(fp3,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]); if(dataDump) fprintf(fp1,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]);} if(dataDump) fprintf(fp1,"\n"); fprintf(fp3,"\n"); } } } fclose(fp); fclose(fp3); if(dataDump) { fclose(fp1);fclose(fp2); }}//end of flie /********************************************************************/ /* Function to initialise the new heaps */ /* Output: none */ /* Input:new Heap structure */ /* Global structure modified:none */ /********************************************************************/ void initialiseNewHeaps(heap newHeaps[]) { int i=0,j=0; for(i=0;i<lCount;i++) { newHeaps[i].count=0; for(j=0;j<features;j++) newHeaps[i].Ocenter[j]=V[i][j]; newHeaps[i].x=heaps[i].x; newHeaps[i].y=heaps[i].y; } }//end of function /********************************************************************/ /* Function to initialise the new heaps */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ int findPosition(int i) { int j,position=0; for(j=1;j<lCount;j++) { if(U[j][i]>U[position][i]) position=j; } printf("\n Position %d ",position); return(position); }//end of function find position /********************************************************************/ /* Function to add object */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ void addObject(int object,heap * heapPosition) { heapPosition->objects[heapPosition->count]=object; heapPosition->count++; }//end of function add object /********************************************************************/ /* Function to harden the outputs obtained from fcm */ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/ void harden(heap newHeaps[]) { int i,heapPosition=-1,sum=0,j=0; /*initialise the new heaps*/ initialiseNewHeaps(newHeaps); for(i=0;i<count;i++) { heapPosition=findPosition(i); addObject(i,&newHeaps[heapPosition]); } /* To check for degenerate partitions*/ for(i=0;i<lCount;i++) { if(newHeaps[i].count==0){for(j=i;j<lCount-1;j++){newHeaps[j]=newHeaps[j+1];}lCount--;i--;} } newHeapCount=lCount; for(i=0;i<lCount;i++) computeHeapParameters(&newHeaps[i],1); if(debugLevel>0) { for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\n sum = %d",sum);} }//end of function/********************************************************************/ /* Function to initialize the initial parameters for the ant algorithm*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void init() { int i=0,j=0; for(i=0;i<MAXROWS;i++) for(j=0;j<MAXCOLS;j++) board[i][j]=-9; heapCount=0; newHeapCount=0; heapRow=0; minPosition=-1; minHeapCount=100000; for(i=0;i<MAXANTS;i++) { ants[i].carrying=-1; ants[i].x=-1; ants[i].y=-1; ants[i].speed=-1; ants[i].dir=-1; } } /********************************************************************/ /* Function to initialize the initial board */ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void initialiseBoard() { int i,j; for(i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; }/********************************************************************/ /* Function to harden the outputs obtained from fcm(2nd stage)*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: Cluster center , cluster center count*/ /********************************************************************/void harden1() { int i=0,heapPosition=-1; for(i=0;i<heapCount;i++) cenCount[i]=0; for(i=0;i<n;i++) { heapPosition=findPosition1(i); addObject1(i,heapPosition); } writeInfo(); }//end of function/********************************************************************/ /* Function to find to which class the object belongs */ /* Output: Class number */ /* Input: object position */ /* Global Structure Modified: None */ /********************************************************************/int findPosition1(int i) { int j,position=0; for(j=1;j<heapCount;j++) { if(U[j][i]>U[position][i]) position=j; } return(position); }//end of function find position/********************************************************************/ /* Function to Write the output of the hardened objects to file*/ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/void writeInfo(){int i=0,j=0,k=0;FILE *fp=fopen("fcm.out","a");if(fp==NULL){printf("\n Unable to open fcm output file \n");return;}fprintf(fp,"\n@ %d\n",heapCount);for(i=0;i<heapCount;i++){fprintf(fp,"# %d %d\n",i,cenCount[i]);for(j=0;j<cenCount[i];j++){for(k=0;k<s;k++)fprintf(fp,"%8.2f ",clsCen[i][j][k]/scale[k]+minInput[k]);fprintf(fp,"\n");}}fclose(fp);return;}/********************************************************************/ /* Function to add a object to a cluster (2nd stage) */ /* Output: none */ /* Input: object poistion , cluster position */ /* Global Structure Modified: Cluster object and cluster count*/ /*******************************************************************/void addObject1(int object,int heapPosition) { int k=0; for(k=0;k<features;k++) clsCen[heapPosition][cenCount[heapPosition]][k]=X[object][k]; cenCount[heapPosition]++; return; }//end of function add object/********************************************************************/ /* Function to read the original classification of objects */ /* Output: none */ /* Input: none */ /* Global Structure Modified: None */ /*******************************************************************/void readOrg(){int i=0,k=0;char temp[80];FILE *fp;//= fopen(dataname,"r");strcpy(temp,"");sprintf(temp,"%sFull.data",filename);fp=fopen(temp,"r");if(fp==NULL){printf("\n Unable to open full data input file ");exit(0);}for(i=0;i<n;i++){fscanf(fp,"%f ",&orgData[i][0]);for(k=1;k<s+1;k++)fscanf(fp,"%f ",&orgData[i][k]);}return;}// end of function/********************************************************************/ /* Function to classify the objects in different clusters */ /* Output: none */ /* Input: the cluster objects, the original classification, */ /* number of objects in the cluster,file to write the data */ /* Global Structure Modified: None *//********************************************************************/int analysisData(float data[][s],float orgData[n][s+1],int count,FILE * fp){int i=0,j=0,k=0,type=1,max=0;heapInfo info;for(i=0;i<c;i++){info.classObj[i]=0;}info.total=0;info.total=count;for(i=0;i<count;i++)for(j=0;j<n;j++){type=1;for(k=0;k<s;k++)if(fabs(data[i][k]-orgData[j][k+1])>errThresh){type=-1;break;}if(type!=-1){info.classObj[(int)orgData[j][0]-1]++;break;}}max=0;for(k=0;k<c;k++){if(info.classObj[k]>info.classObj[max])max=k;fprintf(fp,"\nClass %d Objects % d ",k+1,info.classObj[k]);}j=0;for(k=0;k<c;k++){if(k!=max)j+=info.classObj[k];}fprintf(fp,"\n Total errors : %d \n",j);return(j);}//end of analyse/********************************************************************/ /* Function to read the cluster information */ /* Output: none */ /* Input: input file pointer , output file pointer */ /* Global Structure Modified: None *//********************************************************************/void readFCM(FILE* fp,FILE *fp1){int i=0,j=0,k=0,l=0;int totalRuns=0,heapCount=0,junk=0,sum=0;char ch;FILE *fp2=fopen("errors.out","a");ch = 'c'; while (ch != '$') fscanf (fp, "%c", &ch);fscanf(fp,"%d\n",&totalRuns);printf("\n total runs %d ",totalRuns);for(l=0;l<totalRuns;l++){fscanf(fp,"%c",&ch);fscanf(fp,"%d\n",&heapCount);fprintf(fp1,"\n \nExperiment %d \n ",l+1);sum=0;for(i=0;i<heapCount;i++){fscanf(fp,"%c",&ch);fscanf(fp," %d %d\n",&junk,&clsCenCount[i]);for(j=0;j<clsCenCount[i];j++)for(k=0;k<s;k++)fscanf(fp,"%f",&fcmData[i][j][k]);fscanf(fp,"\n");fprintf(fp1,"\n\n Heap %d Total Objects %d \n",i+1,clsCenCount[i]);sum+=analysisData(fcmData[i],orgData,clsCenCount[i],fp1);}fprintf(fp2," %3d %3d %3d \n",l,sum,heapCount);}fprintf(fp2,"\n --------------------------\n");fclose(fp2);return;}//end of function/********************************************************************/ /* Function to update the board parameters */ /* Output: none */ /* Input: none */ /* Global Structure Modified: board size, ant count *//********************************************************************/void adjustBoard(int flag){int newRow=0,newAnt=0,antDiff=0,antsKilled=0,i=0,position[MAXANTS],position1=-1,j=0,k=0,a,b; newRow= (int)ceil(sqrt(4.0*heapSum/updateAfter)); newAnt= (int)ceil((heapSum*1.0/updateAfter)*1.0/3.0); if(newAnt<minAnts)newAnt=minAnts; if(newRow<rowMin)newRow=rowMin;antDiff=currentAntCount-newAnt; if((antDiff>0)&&(newAnt>=minAnts)) {for(i=0;i<currentAntCount;i++){if(ants[i].carrying==-1){position[antsKilled++]=i;}} if(antsKilled>=antDiff){for(i=0;i<antDiff;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1];for(k=i+1;k<antsKilled;k++)position[k]--; } currentAntCount=newAnt; }else {for(i=0;i<antsKilled;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1]; for(k=i+1;k<antsKilled;k++)position[k]--; }if(flag==1) { for(i=currentAntCount-1,k=0;k<antDiff-antsKilled;k++,i--) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position1,flag); }else { dropObject(&ants[i],flag); } } } else { //flag is zero 2nd stage /*Find if a heap is present */ do { position1=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position1].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position1,flag); position1=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position1!=-1); }//end else currentAntCount=newAnt;}//end elsecurrentAntCount=newAnt;}//end iffor(i=0;i<newAnt;i++){if((ants[i].x>=newRow)||(ants[i].y>=newRow)) { a=lrand48()%newRow; b=lrand48()%newRow; ants[i].x=a; ants[i].y=b; }} //Done with ants, now adjust the boardif((currentRow>newRow)&&(newRow>=rowMin)){for(i=0;i<heapCount;i++){if((heaps[i].x>=newRow)||(heaps[i].y>=newRow)) {do { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionheaps[i].x=a;heaps[i].y=b;board[a][b]=9;}//end if}//end for for(i=0;i<currentAntCount;i++){if((ants[i].carrying==1)&&((ants[i].x>=newRow)||(ants[i].y>=newRow))){//adjust the ant locationdo { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionants[i].x=a;ants[i].y=b;}//end if}//end for currentRow=newRow;}//end if }//end of function void writeIncremental(int iteration,int flag){FILE *fp=fopen("dump.txt","w");int i=0,j=0,k=0;fprintf(fp,"Stage %d\n",flag);fprintf(fp,"Board %d\n",currentRow);fprintf(fp,"Ants %d\n",currentAntCount);fprintf(fp,"Iteration %d\n",iteration);fprintf(fp,"Heaps %d\n",heapCount); if(flag==0)fprintf(fp,"NewHeapCount %d\n",newHeapCount); fprintf(fp,"Ants\n");for(i=0;i<currentAntCount;i++){fprintf(fp,"%d %d %d %d %d ",ants[i].x,ants[i].y,ants[i].carrying,ants[i].speed,ants[i].dir);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",ants[i].data[k]);fprintf(fp,"\n");}fprintf(fp,"Heaps\n");for(i=0;i<heapCount;i++){fprintf(fp,"%d %d %d %d %8.2f %8.2f \n",heaps[i].x,heaps[i].y,heaps[i].count,heaps[i].disPosition,heaps[i].Dmax,heaps[i].Dmean);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Ocenter[k]);fprintf(fp,"\n");for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Odissim[k]);fprintf(fp,"\n");if(flag==1){for(j=0;j<heaps[i].count;j++)fprintf(fp,"%d ",heaps[i].objects[j]);fprintf(fp,"\n");}}if(flag==0){fprintf(fp,"newHeaps\n");for(i=0;i<newHeapCount;i++){fprintf(fp,"%d\n",newHeaps[i].count);for(j=0;j<newHeaps[i].count;j++)fprintf(fp,"%d ",newHeaps[i].objects[j]);fprintf(fp,"\n");}}fclose(fp);}//end of function/********************************************************************/ /* Function Main */ /********************************************************************/ int main(int argc ,char** argv) { int sum=0,k=0,i=0,j=0; char temp[80]; FILE *fp=fopen("fcm.out","w"); FILE *fp1; FILE *fp2=fopen("antAnalysis.out","a"); FILE *fp3=fopen("fcmAnalysis.out","a"); FILE *fp4=fopen("errors.out","w"); FILE *fp5; fclose(fp4); sprintf(temp,"%sObj.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sTot.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp1=fopen(temp,"w"); fprintf(fp,"\n$%d",EXPRUN); fprintf(fp1,"\n$%d",EXPRUN); fclose(fp); fclose(fp1); if(argc==2)sscanf(argv[1],"%d",&debugLevel); printf("\n Debug level %d\n",debugLevel); for( i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; //Read from the file readInput(); //Compute the distance of all the points if(maxDist) { Dmax=computeDistance(); //Compute the maximum distance fp5=fopen("maxData.txt","w");fprintf(fp5,"%f",Dmax);fclose(fp5); } else {fp5=fopen("maxData.txt","r");fscanf(fp5,"%f",&Dmax);fclose(fp5); } printf("\n %f \n",Dmax); //Initialise the board for(k=0;k<EXPRUN;k++) { init(); sum=0; srand48(state1[k]); initialiseBoard(); initialise(1); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(1); printf("\n %d \n",heapCount); //Simulate the working of ants iterate(1); //drop the objects after all the iterations dropFinal(1); //to verify the correctness for(i=0;i<heapCount;i++) sum+=heaps[i].count; //write the cluster centers to the file writeClusterInformation(1); printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); //getchar(); //Run FCM // heapCount=2973;/* To be commented */ printf("\n\n k %d \n\n",k); Fcm(data); //compute new board size. lCount=heapCount; heapRow=(int)ceil(sqrt(4*heapCount)); newHeapCount=lCount; printf("\n LCount %d newHeapCount %d heap Row %d \n",lCount,newHeapCount,heapRow); //harden the objects harden(newHeaps); //iterate with the heaps as the objects. initialiseBoard(); initialise(0); for(i=0;i<lCount;i++) computeHeapParameters(&heaps[i],0); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(0); printf("\n %d \n",heapCount); //getchar(); //Simulate the working of ants iterate(0); dropFinal(0); writeClusterInformation(0); sum=0; for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); // getchar(); Fcm(data); harden1(); } fp=fopen("fcm.out","a"); fp1=fopen(temp,"a"); fprintf(fp,"\n"); fprintf(fp1,"\n"); fclose(fp); fclose(fp1); fp=fopen("fcm.out","r"); fp1=fopen(temp,"r");printf("\n Before read org\n");readOrg();printf("\nafter read org\n");readFCM(fp1,fp2);printf("\n After 1st read fcm\n");readFCM(fp,fp3);printf("\n After 2 fcm read \n");return(1); }//end of main /****************************************************************/ float NORM(feature , feature); void find_covar(); void Fcm (irisData Data[MAXDATA]) { int i,j,l; FILE *ofile; char temp[80]; int flag=0;//added by parag FILE *iniClsCen=fopen("center.clt","a+"); if(iniClsCen==NULL) { printf("\n Unable to open the initial cluster center file\n"); printf("\n choosing random cluster centers....\n"); flag=1; } strcpy(temp,""); sprintf(temp,"%s.data",filename); strcpy (fname,temp); /* Read from this file */ m=2.0; /* The exponent */ /*GET_INPUTS1(fname);*/ /* read in feature vectors */ for (j=0; j<n ; j++) /* Read File in row-major */ for (i=0; i<s ; i++) /* format */ X[j][i]=Data[j][i]; Random_seed=state1[run];/*randseed*/ srand48(Random_seed); for (run=0;run<TOTRUNS;run++) { //flag=1;//for testing random values if (EntireHeaps) lCount=heapCount; else lCount=c; for(i=0;i<lCount;i++) for(j=0;j<s;j++) V[i][j]=0; for(i=0;i<lCount;i++) { for(l=0;l<s;l++) { if(flag==1) { rand_index = lrand48() % n; V[i][l] = X[rand_index][l]; } else { fscanf(iniClsCen,"%f ",&V[i][l]); } }//end for } eps=0.001; stop = FALSE; /* This loop finds the final cluster center and the corresponding U values */ z = 0; while (stop == FALSE) { z++; UMAT(U,V,X); /** Update the U matrix **/ stop = FINISHED(U1,eps); CLUSTER(U,X); /** Get new cluster center **/ printf("Iteration: %d\n\n", z); } /* end while */ printf("Number of iterations: %d\n\n", z);strcpy(temp,""); sprintf(temp,"%sFCM.out",filename);if(dataDump) Output(temp); /* output the results */ }/*end for*/ if(dataDump) { ofile=fopen(temp,"a"); for (i=0; i <= mins; i++) fprintf(ofile, "Min %d of %10.3f occurred %d times\n", i, mintab[i], mincount[i]); fprintf(ofile, "Average iterations %f\n", (float)aveit/(float)TOTRUNS); fclose(ofile); } }/* end Main */ /* The GET_INPUTS1 procedure opens an input file, reads the number of input vectors, the number of features per vector, the number of clusters, and epsilon, then it reads the input values */ void GET_INPUTS1(char fname[]) //char fname[]; { /* Parameters: fname -- name of file containing input info. */ FILE *infile ;//*fopen(); //char junk[10][80]; char realfname[80]; char ch; char fileName1[80]; //int temp[10], i, j, inputs, outputs, count; int i,j; sprintf (realfname, "%s", fname); /* open input file */ if(normalize==1) strcpy(fileName1,"gtest1.data"); else strcpy(fileName1,fname); if((infile = fopen (fileName1, "r")) == NULL) printf("\n CAN'T OPEN %s\n",realfname); else { ch = 'c'; /* Discard leading comments */ while (ch != '#') fscanf (infile, "%c", &ch); for (j=0; j<n ; j++) /* Read File in row-major */ { /* format */ for (i=0; i<s ; i++) fscanf (infile, "%f", &X[j][i]); /* fscanf (infile, "%d", &temp[1]); */ /* end for */ } /* end for */ fclose(infile); /* close input file */ }/* end else */ } /* end GET_INPUTS1 */ /* The NORM function computes the norm of two vectors, x and v, of dimension s. This gives an indication of the distance between them */ float NORM( feature x, feature v) //feature x, v; { /* Parameters : x -- a local copy of an input vector v -- a local copy of a cluster center */ int i,j; /* loop variable */ double sum; /* the square root of sum is the norm; sum is the sum of the differences squared */ float mat1[s]; float mat2[s]; if (maha) { for (i=0; i<s; i++) mat1[i]=x[i]-v[i]; for(i=0;i<s;i++) { sum =0; for(j=0;j<s;j++) sum += mat1[j] * inv_cov[j][i]; mat2[i] = sum; } sum =0; for(j=0;j<s;j++) sum += mat1[j]*mat2[j]; } else { sum = 0; for(j=0;j<s;j++) sum += (x[j] - v[j])* (x[j] - v[j]); } return (float)(sqrt(sum)); } /* end NORM */ /* The UMAT procedure calculates the updated U matrix according to Bezdek's formula. Its side-effect is the update of the global array U1 */ void UMAT( matrix U,center V, objects X) /*matrix U; center V; objects X;*/ { /* Parameters: U, V, and X: same as in main program */ int i, j, k,l ;/* loop variables *///, class /* class whose cluster center //is closest to pattern k */; float d1,d2,d; float sum; int exact; for (k=0;k<n;k++) { /*printf("\n k %d ",k);*/ exact=false; for (i=0;i<lCount;i++) { sum=0; for (j=0;j<lCount;j++) { d1=NORM(X[k],V[i]); d2=NORM(X[k],V[j]); if(d2!=0) { d= d1/d2; d= d * d;/* pow(d1/d2,2.0/(m-1.0)); */ sum+=d; } else { exact = true; for(l=0;l<lCount;l++) if (l==j) U1[l][k]=1.0; else U1[l][k]=0.0; break; } } if (exact!=true) U1[i][k]=1.0/sum; } } } /* end UMAT */ /* The function FINISHED determines if a termination occurs. If not it updates U with U1, so its side-effect is the potential modification of U */ BOOLEAN FINISHED( matrix U1,float eps) //matrix U1; float eps; { /* Parameters: U1, eps-- same as in main */ float sum; /* sum of squared differences between corresponding elements of U and U1 */ int i,k; /* loop control variabes */ BOOLEAN finished; /* set to true if all corresponding elements are within epsilon */ finished = TRUE; sum = 0; for (i=0; i<lCount; i++) for (k=0; k<n; k++) sum += (U[i][k] - U1[i][k])*(U[i][k]-U1[i][k]); if (sqrt(sum) > eps) { finished = FALSE; for (i=0; i<lCount; i++) for (k=0; k<n; k++) U[i][k] = U1[i][k]; } /* end if */ return finished; } /* end FINISHED */ /* The CLUSTER procedure determines cluster centers in V for the c classes being searched for. The global array V is updated */ void CLUSTER( matrix U, objects X) //matrix U; objects X; { /* Parameters: U, X -- as in main */ int i, j, k; /* loop control variables */ feature num; /* numerator in the cluster center computation formula presented by Bezdek */ float denum; /* denumenator in the obove formula */ for (i=0; i<lCount; i++) { denum = 0; for (j=0; j<s; j++) { num[j] = 0; for (k=0; k<n; k++) num[j] += U[i][k] * U[i][k] * X[k][j]; /* pow(U[i][k],m) * X[k][j]; */ } /* end for */ for (k=0; k<n; k++) denum += U[i][k] * U[i][k]; /* pow(U[i][k],m); */ for (j=0; j<s; j++) V[i][j] = num[j] / denum; } /* end for */ } /* end CLUSTER */ float Compute_Jm(center V, objects X) //center V; //objects X; { int i, k,found; double Jm_value; float u,dik; Jm_value = 0; for (k=0; k<n; k++) { found = FALSE; for (i=0; i<lCount; i++) { dik=NORM(X[k],V[i]); dik=dik*dik; if (dik==0.0) { if (found == FALSE) { u=1.0; found = TRUE; printf("found the case with dik=0\n"); } else { printf("\n cant proceed with this initialization"); exit(1); } } else { if (found != TRUE) u=U1[i][k]; /* get_Uvalue(V,X,dik,k); */ else u=0.0; } Jm_value += u * u * dik;/* pow(u, m) * dik; */ } } return (Jm_value); } /* end Compute_Jm */ /* The Output procedure outputs the U matrix which gives the fuzzy measure of each feature belonging to a cluster center. It also outputs the cluster center for each class */ void Output(char fname[]) //char fname[80]; /* Parameters: U, V -- same as in main */ { int i, j, found; /* loop control variables */ float J2c; if ((fp=fopen(fname,"a"))==NULL) printf("\n CAN'T OPEN %s\n",fname); else { fprintf(fp,"\n The cluster centers are: \n"); fprintf(fp,"\n \n"); for (i=0; i<lCount; i++) { fprintf(fp,"\nCluster center %d: ",i+1); fprintf(fp,"\n"); for (j=0; j<s; j++) fprintf(fp,"%8.7f ",V[i][j]); } /* end for */ fprintf(fp,"\nThe membership grades for the feature vectors are:\n"); for (j=0; j<n; j++) { fprintf(fp,"\n"); for (i=0; i<lCount; i++) fprintf(fp," %8.7f",U[i][j]); } /* end for */ } /* end if */ J2c= Compute_Jm(V,X); found =0; for (i=0;i<= mins; i++){ if ((found == 0) && ((J2c - mintab[i]) < .001) && ((J2c - mintab[i]) > -.001)){ mincount[i]++; found = 1; } } if (found == 0){ mins++; mintab[mins]=J2c; mincount[mins]=1; } fprintf(fp,"\nJ%3.1f = %f", m,J2c); fprintf(fp, "Number of iterations: %d\n\n", z); aveit=aveit + z; fclose(fp); } /***************************************************************/ void find_covar(int m) //int m; { int i,j,k; float mean[s],sum; for (i=0;i<s;i++) mean[i]=0; for (i=0;i<s;i++) for (j=0;j<m;j++) mean[i]+=X[j][i]; for (i=0;i<s;i++) mean[i]/=m; for (i=0;i<s;i++) for (j=0;j<s;j++) { sum=0; for (k=0;k<m;k++) sum+=(X[k][i]-mean[i])*(X[k][j]-mean[j]); Y[i][j]=sum/m; } }
Parag Kanade/fuzzy ants/Gauss500-1/headerStatic.h
/********************************************************************//* Ant Class parameters *//* SPEED # amplitude of moves [1,10] *//* P direction Probability to move in the same direction [.5,1] *//* Max carry : Maximum object carrying time [20,200] *//* P load Probability to pick up a single object [0.4,0.8] *//* P destroy probability to destroy a heap of two objects [0,0.6] *//* T remove min. dissimilarity necessary for removing an object *//* from a heap [.1,.2] *//* T create max dissimilarity permitted for creating a heap[.05,.2]*//********************************************************************/ #include <stdio.h>#include <math.h>#include <string.h>#include<stdlib.h>#include <ctype.h>#include <time.h>#define MAXANTS 167#define MAXDATA 500#define MAXANTSFORHEAPS 45#define MAXITERATIONS 1000#define MAXROWS 45#define MAXCOLS 45#define EXPRUN 10#define Tremove 1.50#define Tcreate 0.5#define Pdrop 0.2#define Pdestroy 0.3#define Pload 0.3#define normalize 0#define EntireHeaps 1#define TcreateForHeaps 0.19#define features 2#define filename "gauss500_01"#define errThresh 0.1#define dataDump 1#define maxDist 1#define INITIALOBJECTS 75#define OBJINC 10/* some type definitions to make C code a little more readable */#define TRUE 1#define FALSE 0#define n MAXDATA /* number of input vectors */#define s features /* number of features */#define c 5 /* number of clusters */#define TOTRUNS 1 /* number of V's to write out */#define false 0#define true 1#define maha 0#define square 0extern int count;int debugLevel=0;/* To debug the code and verify the correctness of algorithms*/int currHeapCount=0;typedef int BOOLEAN;typedef short TYPE_IN_DATA; /* Type of input binary data */typedef float feature[s]; /* Type of each input; made up of input features */typedef float irisData[s];typedef feature objects[MAXDATA]; /* Type of array holding all inputs */typedef feature center[MAXDATA]; /* Type of array holding cluster centers */typedef float matrix[MAXDATA][MAXDATA];/* Type of the matrix containing membership grades */typedef struct Heap {float Dmax;//maximum dissimilar distanceirisData Ocenter;//center objectfloat Dmean;//mean of the distance between the center and all the objectsirisData Odissim;//most dissimilar objectint x;//x position on the boardint y;//y position on the boardint count;//number of objects in the heapsint disPosition;//most dissimilar objectint objects[MAXDATA];int objCount;}heap;typedef struct Ant{int x;int y;int carrying;int speed;int dir;irisData data;}ant;float orgData[n][s+1];float fcmData[MAXDATA][n][s];int clsCenCount[MAXDATA];int currentRow=0;int currentAntCount=0;int updateAfter=50;int heapSum=0;int minAnts=3;int rowMin=5;typedef struct HeapInfo{int total;int classObj[c];} heapInfo;/*heapInfo info[MAXDATA];*//********************************************************************//***Function decelarations*//********************************************************************//***For ant based algorithm*/void readInput();float computeDistance();float computeDistanceBetween2(irisData a,irisData b);float findMax(float *distance);float value(irisData a);int found(int a , int b);void initialise(int flag);int findObject(int a,int b);void initialiseAnts(int flag);void moveNext(ant* a,int flag);void computeHeapParameters(heap* data,int flag);void pickObject1(ant *a,int position,int flag);void pickObject2(ant *a , int position,int flag);void pickObjectn(ant *a,int position,int flag);void pick(ant *a,int flag);void dropObject(ant* a,int flag);int findInNewheaps(irisData object);void dropObject1(ant* a, int position,int flag);void drop(ant* a,int flag);void move(ant* a,int flag);void iterate(int flag);void dropFinal(int flag);int partition(heap a[], int low,int high);void quickSort( heap A[], int low,int high ) ;void writeClusterInformation(int flag);void initialiseNewHeaps(heap newHeaps[]);int findPosition(int i);void harden(heap newHeaps[]);void harden1();int findPosition1(int );void writeInfo();void addObject1(int ,int);void readFCM(FILE *,FILE *);void readOrg();int findInData(irisData input,int iflag);void adjustBoard(int flag);void writeIncremental(int iteration,int flag);/********************************************************************//***For FCM algorithm*/void GET_INPUTS1(char []);void UMAT( matrix,center,objects);BOOLEAN FINISHED(matrix, float);void CLUSTER( matrix, objects);void Output(char[]);void Fcm();/********************************************************************/
Parag Kanade/fuzzy ants/Gauss500-1/maxData.txt
1.641473
Parag Kanade/fuzzy ants/Gauss500-2/gauss500_02.data
gauss Data | |
# | |
1.2079091 | 3.7210589 |
1.2231833 | 4.624442 |
1.2724274 | 3.7211989 |
1.3905861 | 2.8528257 |
1.5263206 | 3.1902709 |
1.5446515 | 2.9092366 |
2.0817641 | 2.2932327 |
2.1329588 | 2.7909656 |
2.2061908 | 2.5587698 |
2.2294541 | 3.7094674 |
2.2311605 | 2.1842931 |
2.3729459 | 2.6146591 |
2.451783 | 4.0942238 |
2.4631214 | 1.9776029 |
2.4641181 | 3.9918609 |
2.5092126 | 3.2028537 |
2.5249635 | 1.8857945 |
2.5408484 | 3.0938419 |
2.5538585 | 4.1353191 |
2.580998 | 3.1703637 |
2.6221661 | 4.0532502 |
2.6675926 | 3.5078748 |
2.6693178 | 3.0258803 |
2.6757058 | 1.5386359 |
2.6875167 | 4.3955603 |
2.8136569 | 4.2550441 |
2.8330733 | 4.7522282 |
2.8388063 | 4.8021392 |
2.8394463 | 4.1968265 |
2.8564329 | 1.7743203 |
2.8694154 | 2.2415617 |
2.8838473 | 3.8844967 |
2.9151302 | 2.5118873 |
2.9197918 | 4.408129 |
2.9546596 | 4.2040109 |
2.9707417 | 2.4312104 |
3.0135107 | 3.9468569 |
3.0456382 | 3.6968997 |
3.0662513 | 3.9026477 |
3.0731757 | 5.0607237 |
3.0940184 | 5.3846903 |
3.0998003 | 3.0196854 |
3.1062588 | 3.8665536 |
3.1113574 | 2.7466426 |
3.1401502 | 2.322823 |
3.164504 | 2.3772491 |
3.167721 | 4.491692 |
3.1792337 | 3.1921312 |
3.189034 | 3.9209093 |
3.1923355 | 5.0269859 |
3.2420277 | 2.6866669 |
3.2563394 | 2.6318602 |
3.2646653 | 3.3621656 |
3.277839 | 3.5903912 |
3.2840827 | 2.3948904 |
3.3134128 | 3.7465675 |
3.3432966 | 2.3024976 |
3.3588688 | 2.6395169 |
3.3773154 | 3.509691 |
3.3923682 | 3.7704754 |
3.3928396 | 3.9307354 |
3.4097375 | 3.0243664 |
3.4250905 | 4.2957807 |
3.4256467 | 5.1909088 |
3.429859 | 4.6389274 |
3.4383383 | 4.5945946 |
3.4499816 | 3.3406544 |
3.4648999 | 3.7633964 |
3.5101871 | 3.0922003 |
3.5814278 | 4.4753996 |
3.5883151 | 2.204994 |
3.6065497 | 3.7304895 |
3.6109218 | 4.4108913 |
3.6800216 | 3.6595682 |
3.6865731 | 2.8736266 |
3.7364618 | 3.1109649 |
3.7834804 | 4.4478511 |
3.806937 | 2.2154877 |
3.8505015 | 2.7495611 |
3.8894656 | 3.5845772 |
3.898071 | 4.4421334 |
3.9191638 | 4.1379257 |
3.9232595 | 2.3691164 |
3.9263071 | 2.3499483 |
3.9336875 | 3.5430657 |
3.9561075 | 2.014345 |
3.956787 | 2.2913721 |
3.9597375 | 3.9233632 |
3.9647258 | 3.5541938 |
4.0014664 | 1.5959308 |
4.0967613 | 3.3460918 |
4.1113619 | 4.956129 |
4.1393133 | 3.1290369 |
4.2427451 | 4.3293623 |
4.2447324 | 2.4055278 |
4.2808958 | 4.1849711 |
4.2958248 | 4.52221 |
4.3333881 | 4.8926755 |
4.3770667 | 4.148263 |
4.3872811 | 3.0834977 |
4.3943806 | 1.2047041 |
4.4231133 | 5.1428545 |
4.4242463 | 4.7437029 |
4.4737188 | 5.1960809 |
4.5434832 | 2.9540165 |
4.5542301 | 4.6514457 |
4.556613 | 3.6792214 |
4.5569343 | 4.3557038 |
4.5681878 | 2.7334969 |
4.6154429 | 4.9919154 |
4.6573287 | 3.6323181 |
4.7523585 | 4.6764836 |
4.7530329 | 1.6970322 |
4.8855847 | 3.1092405 |
4.9202943 | 3.6878621 |
5.0692918 | 4.4614043 |
5.094251 | 4.9986657 |
5.2213603 | 2.8859654 |
5.29025 | 4.1231551 |
5.3047409 | 4.0529775 |
5.3807576 | 2.8897184 |
5.4022501 | 4.2157411 |
5.5258683 | 4.6077935 |
5.5602902 | 4.0202276 |
5.5928493 | 5.9473488 |
5.6337921 | 2.0477399 |
4.5649633 | 10.8199028 |
4.9492476 | 11.2417831 |
4.9639843 | 10.1301841 |
5.226796 | 9.0896456 |
5.5160477 | 10.339618 |
5.5494966 | 11.3187034 |
5.7321392 | 9.3091876 |
5.78872 | 9.9671922 |
5.8074223 | 10.160413 |
5.8077218 | 11.2829668 |
5.8401064 | 10.4340778 |
5.8887826 | 11.182616 |
5.9385494 | 9.0826968 |
6.0173279 | 12.015934 |
6.1333175 | 11.0641202 |
6.1493846 | 7.5813131 |
6.3247616 | 10.5008158 |
6.3596552 | 10.4300021 |
6.4498757 | 10.4660964 |
6.5039886 | 11.1291981 |
6.5577834 | 8.1352935 |
6.6243969 | 9.1862597 |
6.6653361 | 9.8993512 |
6.6752921 | 9.2522435 |
6.6978867 | 9.9182312 |
6.7050083 | 12.974634 |
6.7473609 | 9.2485078 |
6.7493806 | 9.5129937 |
6.7887799 | 9.8588077 |
6.836351 | 9.2174683 |
6.8726451 | 10.0834742 |
6.8903508 | 8.7250099 |
6.8907481 | 10.7297899 |
6.8955632 | 9.2141097 |
6.9133122 | 12.337941 |
6.9817274 | 9.634554 |
6.9985553 | 8.0236224 |
7.0917411 | 9.5520639 |
7.1110772 | 10.5536931 |
7.138392 | 9.2415998 |
7.1624205 | 9.7417785 |
7.1675304 | 10.3424403 |
7.1959608 | 9.6760523 |
7.1960034 | 10.4806538 |
7.2013835 | 11.6980377 |
7.2141018 | 10.6837557 |
7.2348838 | 8.4397497 |
7.2422483 | 9.3493743 |
7.2430823 | 9.7644821 |
7.2613676 | 10.8671876 |
7.2946775 | 9.1593571 |
7.3350288 | 10.460047 |
7.335831 | 11.4561045 |
7.3401016 | 11.1398342 |
7.3739163 | 9.9216549 |
7.43575 | 9.3674077 |
7.4735116 | 9.3621969 |
7.5094318 | 10.7425193 |
7.5192765 | 9.0919875 |
7.5230336 | 9.3181116 |
7.5389153 | 10.3706625 |
7.569023 | 11.6957121 |
7.6814631 | 9.0434399 |
7.7144954 | 7.191835 |
7.7198893 | 11.0829336 |
7.7803768 | 9.8861349 |
7.9326271 | 10.1804494 |
7.9732352 | 9.991876 |
7.9849534 | 9.8853695 |
8.1124261 | 9.3706331 |
8.1154425 | 10.9006981 |
8.1254249 | 8.0928389 |
8.2795063 | 10.5570386 |
8.2975804 | 9.1768362 |
8.3800894 | 9.2322431 |
9.1497729 | 10.4123977 |
1.14794639 | 13.979611 |
1.87296376 | 16.259677 |
1.95057589 | 14.253912 |
2.1774974 | 14.078445 |
2.2212576 | 15.180736 |
2.3319392 | 16.250346 |
2.3417249 | 14.922804 |
2.3666823 | 15.057726 |
2.4343045 | 14.844073 |
2.4637002 | 15.504545 |
2.5730949 | 16.120083 |
2.6960326 | 14.719672 |
2.7176948 | 14.681052 |
2.735971 | 16.281386 |
2.7907127 | 14.970722 |
2.8934128 | 16.577153 |
2.9067283 | 15.338185 |
2.9620927 | 16.091421 |
2.9967398 | 16.708606 |
3.0047431 | 15.371614 |
3.044215 | 14.689133 |
3.0872242 | 16.305325 |
3.0887985 | 15.697535 |
3.200185 | 16.663794 |
3.2008578 | 14.885879 |
3.2557222 | 14.889798 |
3.2892761 | 13.6007235 |
3.3028307 | 14.637392 |
3.3419285 | 14.224092 |
3.3422877 | 14.204327 |
3.3583757 | 16.048761 |
3.3893859 | 15.918406 |
3.4169347 | 16.292314 |
3.457675 | 15.097081 |
3.4578659 | 15.974339 |
3.4788892 | 16.152925 |
3.5046477 | 16.381791 |
3.5059035 | 16.737371 |
3.5621021 | 15.857647 |
3.6720782 | 13.4164271 |
3.6959001 | 16.995196 |
3.6992848 | 15.473127 |
3.7066215 | 14.623886 |
3.7295648 | 15.278963 |
3.7460885 | 15.579015 |
3.8699537 | 17.05209 |
3.8716518 | 17.413634 |
3.8873572 | 16.962738 |
3.9045898 | 16.715849 |
3.9456943 | 15.248866 |
3.9765246 | 16.883393 |
3.9819109 | 17.26836 |
3.998568 | 16.243342 |
4.0433096 | 17.347058 |
4.0596044 | 17.056215 |
4.0794422 | 15.758407 |
4.1129522 | 15.224293 |
4.1413942 | 15.929671 |
4.1627441 | 17.158977 |
4.1767186 | 15.184683 |
4.1781964 | 16.230266 |
4.2431648 | 16.962598 |
4.2618399 | 15.533754 |
4.3829695 | 15.589008 |
4.3900615 | 16.298833 |
4.4072292 | 15.452131 |
4.4630972 | 17.51363 |
4.4865115 | 15.166259 |
4.489808 | 15.302365 |
4.4985781 | 15.176454 |
4.4995603 | 16.339537 |
4.5015888 | 16.546623 |
4.5126907 | 17.181318 |
4.5186807 | 15.243923 |
4.5200494 | 16.606359 |
4.5546059 | 16.523475 |
4.5593513 | 17.20819 |
4.620113 | 17.041174 |
4.7561987 | 16.161672 |
4.7777356 | 15.774779 |
4.7993429 | 16.862268 |
4.8108036 | 17.172305 |
4.8138488 | 18.482412 |
4.9717907 | 16.813861 |
4.9946929 | 17.564215 |
5.0059337 | 16.629871 |
5.0114164 | 16.947345 |
5.0376315 | 15.086702 |
5.1360659 | 15.978871 |
5.1976377 | 17.45016 |
5.3760322 | 15.3188 |
5.4290531 | 16.540536 |
5.4497178 | 16.767889 |
5.4527803 | 16.620024 |
5.6388008 | 16.745066 |
5.6473698 | 16.450529 |
5.7566377 | 17.143698 |
5.7900453 | 16.382074 |
5.8758893 | 16.90501 |
5.9023884 | 16.818273 |
5.9788072 | 15.959914 |
6.0324193 | 16.252833 |
6.3479027 | 15.875618 |
10.4652107 | 2.6831135 |
10.5244255 | 1.1185327 |
10.676615 | 2.1365133 |
10.7060357 | 4.8800944 |
11.0507822 | 4.9306996 |
11.0926175 | 5.5469616 |
11.1620361 | 3.4362472 |
11.528659 | 4.9653684 |
11.68202 | 4.9323634 |
11.8113105 | 5.0447482 |
11.8395293 | 3.2846371 |
11.8904436 | 3.9756688 |
11.901902 | 4.0596121 |
12.00957 | 3.8387848 |
12.041757 | 3.2972722 |
12.070124 | 3.5975018 |
12.125698 | 5.2145027 |
12.13737 | 5.069625 |
12.179778 | 2.7118074 |
12.300714 | 2.811699 |
12.302589 | 4.6895294 |
12.310044 | 3.3904743 |
12.360948 | 4.048405 |
12.387776 | 2.650697 |
12.404948 | 2.3650841 |
12.415097 | 4.0142043 |
12.417047 | 3.4687826 |
12.442745 | 5.030264 |
12.443721 | 4.1409706 |
12.447941 | 5.8988869 |
12.476582 | 3.743859 |
12.515158 | 5.106076 |
12.595752 | 3.8626734 |
12.615602 | 3.2022261 |
12.61961 | 5.7629745 |
12.632347 | 3.3748335 |
12.657503 | 3.2747553 |
12.709758 | 5.0287697 |
12.747944 | 5.0152176 |
12.752371 | 4.7189407 |
12.818769 | 3.7802197 |
12.820888 | 3.1272452 |
12.830515 | 5.601528 |
12.863656 | 2.6533946 |
12.88482 | 5.2657701 |
12.904148 | 4.8965637 |
12.939187 | 3.1585675 |
12.952628 | 2.2741358 |
12.973613 | 4.8611944 |
12.97606 | 2.9509126 |
13.000251 | 4.8797171 |
13.004435 | 2.8729802 |
13.004874 | 4.9961698 |
13.008949 | 4.4582345 |
13.025455 | 4.3870708 |
13.045022 | 4.9916418 |
13.096295 | 2.973044 |
13.195278 | 2.9627547 |
13.21192 | 4.3851352 |
13.215603 | 4.153893 |
13.362235 | 2.9408317 |
13.487338 | 3.4554507 |
13.507061 | 4.9059559 |
13.544954 | 3.0748351 |
13.561125 | 3.3112401 |
13.575478 | 3.2823488 |
13.61449 | 4.9872933 |
13.618037 | 3.916222 |
13.63065 | 4.3280429 |
13.666668 | 4.0476106 |
13.693189 | 4.5426592 |
13.71092 | 2.5744855 |
13.717479 | 3.5385358 |
13.723603 | 4.8269313 |
13.740956 | 4.5362417 |
13.810342 | 3.3345241 |
13.884852 | 5.2966064 |
13.88918 | 2.4088233 |
13.908124 | 4.4692953 |
13.920669 | 5.1046996 |
14.066882 | 4.2443514 |
14.119596 | 3.8195427 |
14.134638 | 4.0501819 |
14.15121 | 5.0939166 |
14.174712 | 1.7723559 |
14.23597 | 5.8236027 |
14.270719 | 3.9357992 |
14.418402 | 5.0104769 |
14.423091 | 4.655516 |
14.58717 | 5.4807475 |
14.608216 | 5.5958854 |
14.621365 | 5.1009621 |
14.639837 | 5.7854218 |
14.675322 | 3.0883694 |
14.885806 | 4.5369381 |
15.123712 | 3.1371023 |
15.314308 | 4.2649289 |
10.1271918 | 15.296397 |
11.0410633 | 15.246086 |
11.0765704 | 14.281669 |
11.1579441 | 14.821112 |
11.2049293 | 14.132894 |
11.2509463 | 13.3686 |
11.2995974 | 15.315821 |
11.4488022 | 13.797879 |
11.4718758 | 15.400537 |
11.6037499 | 15.167981 |
11.6299854 | 12.916744 |
11.6385609 | 15.134394 |
11.722283 | 12.348765 |
11.8768788 | 12.795341 |
11.8805154 | 13.427278 |
11.9245665 | 14.171992 |
11.9419753 | 12.11674 |
11.9458388 | 13.572502 |
11.9963091 | 13.910162 |
11.9977637 | 12.264383 |
12.120108 | 14.298028 |
12.161642 | 12.235561 |
12.259619 | 14.538579 |
12.278865 | 13.907848 |
12.284851 | 14.78127 |
12.302126 | 13.551077 |
12.419082 | 13.560862 |
12.451229 | 14.87717 |
12.481022 | 14.631295 |
12.487289 | 13.299683 |
12.570844 | 13.073695 |
12.587373 | 14.506647 |
12.625944 | 13.499386 |
12.641761 | 13.157186 |
12.64511 | 12.942852 |
12.667898 | 15.982038 |
12.670485 | 13.955641 |
12.706356 | 13.361715 |
12.711061 | 14.236744 |
12.771428 | 12.766095 |
12.775607 | 16.052587 |
12.886805 | 13.023554 |
12.928196 | 11.2239141 |
12.950179 | 14.187592 |
12.966609 | 13.020396 |
12.984097 | 13.00589 |
12.997997 | 14.669185 |
13.089569 | 14.398868 |
13.108494 | 13.910334 |
13.147798 | 13.724342 |
13.155115 | 16.121416 |
13.158758 | 14.718643 |
13.213179 | 12.731326 |
13.222689 | 13.894866 |
13.237439 | 14.728269 |
13.247742 | 15.206662 |
13.256842 | 14.442514 |
13.269178 | 13.628728 |
13.350498 | 13.563816 |
13.469883 | 14.188571 |
13.4942 | 14.38967 |
13.52686 | 12.779428 |
13.553505 | 14.539572 |
13.559418 | 15.570712 |
13.567707 | 14.901948 |
13.634692 | 12.074948 |
13.634837 | 14.236684 |
13.641807 | 14.726728 |
13.677089 | 14.332538 |
13.767215 | 15.092209 |
13.781016 | 12.595779 |
13.878886 | 14.329098 |
13.891137 | 13.18777 |
13.895193 | 11.6599829 |
13.945273 | 13.156521 |
13.949261 | 12.944328 |
13.998138 | 13.186815 |
14.01272 | 14.270148 |
14.021108 | 15.495508 |
14.026602 | 13.861609 |
14.056164 | 13.728905 |
14.065794 | 13.845586 |
14.087697 | 15.523848 |
14.105136 | 13.638893 |
14.197604 | 14.022645 |
14.296025 | 15.509115 |
14.349088 | 14.002902 |
14.370353 | 16.051215 |
14.425818 | 12.55447 |
14.465642 | 12.745134 |
14.470883 | 13.280208 |
14.473897 | 13.425769 |
14.516394 | 13.222901 |
14.646671 | 13.889919 |
14.651572 | 15.064428 |
14.888393 | 12.709495 |
15.075641 | 14.576588 |
16.009856 | 14.548147 |
Parag Kanade/fuzzy ants/Gauss500-2/gauss500_02Full.data
1 | 1.2079091 | 3.7210589 |
1 | 1.2231833 | 4.624442 |
1 | 1.2724274 | 3.7211989 |
1 | 1.3905861 | 2.8528257 |
1 | 1.5263206 | 3.1902709 |
1 | 1.5446515 | 2.9092366 |
1 | 2.0817641 | 2.2932327 |
1 | 2.1329588 | 2.7909656 |
1 | 2.2061908 | 2.5587698 |
1 | 2.2294541 | 3.7094674 |
1 | 2.2311605 | 2.1842931 |
1 | 2.3729459 | 2.6146591 |
1 | 2.451783 | 4.0942238 |
1 | 2.4631214 | 1.9776029 |
1 | 2.4641181 | 3.9918609 |
1 | 2.5092126 | 3.2028537 |
1 | 2.5249635 | 1.8857945 |
1 | 2.5408484 | 3.0938419 |
1 | 2.5538585 | 4.1353191 |
1 | 2.580998 | 3.1703637 |
1 | 2.6221661 | 4.0532502 |
1 | 2.6675926 | 3.5078748 |
1 | 2.6693178 | 3.0258803 |
1 | 2.6757058 | 1.5386359 |
1 | 2.6875167 | 4.3955603 |
1 | 2.8136569 | 4.2550441 |
1 | 2.8330733 | 4.7522282 |
1 | 2.8388063 | 4.8021392 |
1 | 2.8394463 | 4.1968265 |
1 | 2.8564329 | 1.7743203 |
1 | 2.8694154 | 2.2415617 |
1 | 2.8838473 | 3.8844967 |
1 | 2.9151302 | 2.5118873 |
1 | 2.9197918 | 4.408129 |
1 | 2.9546596 | 4.2040109 |
1 | 2.9707417 | 2.4312104 |
1 | 3.0135107 | 3.9468569 |
1 | 3.0456382 | 3.6968997 |
1 | 3.0662513 | 3.9026477 |
1 | 3.0731757 | 5.0607237 |
1 | 3.0940184 | 5.3846903 |
1 | 3.0998003 | 3.0196854 |
1 | 3.1062588 | 3.8665536 |
1 | 3.1113574 | 2.7466426 |
1 | 3.1401502 | 2.322823 |
1 | 3.164504 | 2.3772491 |
1 | 3.167721 | 4.491692 |
1 | 3.1792337 | 3.1921312 |
1 | 3.189034 | 3.9209093 |
1 | 3.1923355 | 5.0269859 |
1 | 3.2420277 | 2.6866669 |
1 | 3.2563394 | 2.6318602 |
1 | 3.2646653 | 3.3621656 |
1 | 3.277839 | 3.5903912 |
1 | 3.2840827 | 2.3948904 |
1 | 3.3134128 | 3.7465675 |
1 | 3.3432966 | 2.3024976 |
1 | 3.3588688 | 2.6395169 |
1 | 3.3773154 | 3.509691 |
1 | 3.3923682 | 3.7704754 |
1 | 3.3928396 | 3.9307354 |
1 | 3.4097375 | 3.0243664 |
1 | 3.4250905 | 4.2957807 |
1 | 3.4256467 | 5.1909088 |
1 | 3.429859 | 4.6389274 |
1 | 3.4383383 | 4.5945946 |
1 | 3.4499816 | 3.3406544 |
1 | 3.4648999 | 3.7633964 |
1 | 3.5101871 | 3.0922003 |
1 | 3.5814278 | 4.4753996 |
1 | 3.5883151 | 2.204994 |
1 | 3.6065497 | 3.7304895 |
1 | 3.6109218 | 4.4108913 |
1 | 3.6800216 | 3.6595682 |
1 | 3.6865731 | 2.8736266 |
1 | 3.7364618 | 3.1109649 |
1 | 3.7834804 | 4.4478511 |
1 | 3.806937 | 2.2154877 |
1 | 3.8505015 | 2.7495611 |
1 | 3.8894656 | 3.5845772 |
1 | 3.898071 | 4.4421334 |
1 | 3.9191638 | 4.1379257 |
1 | 3.9232595 | 2.3691164 |
1 | 3.9263071 | 2.3499483 |
1 | 3.9336875 | 3.5430657 |
1 | 3.9561075 | 2.014345 |
1 | 3.956787 | 2.2913721 |
1 | 3.9597375 | 3.9233632 |
1 | 3.9647258 | 3.5541938 |
1 | 4.0014664 | 1.5959308 |
1 | 4.0967613 | 3.3460918 |
1 | 4.1113619 | 4.956129 |
1 | 4.1393133 | 3.1290369 |
1 | 4.2427451 | 4.3293623 |
1 | 4.2447324 | 2.4055278 |
1 | 4.2808958 | 4.1849711 |
1 | 4.2958248 | 4.52221 |
1 | 4.3333881 | 4.8926755 |
1 | 4.3770667 | 4.148263 |
1 | 4.3872811 | 3.0834977 |
1 | 4.3943806 | 1.2047041 |
1 | 4.4231133 | 5.1428545 |
1 | 4.4242463 | 4.7437029 |
1 | 4.4737188 | 5.1960809 |
1 | 4.5434832 | 2.9540165 |
1 | 4.5542301 | 4.6514457 |
1 | 4.556613 | 3.6792214 |
1 | 4.5569343 | 4.3557038 |
1 | 4.5681878 | 2.7334969 |
1 | 4.6154429 | 4.9919154 |
1 | 4.6573287 | 3.6323181 |
1 | 4.7523585 | 4.6764836 |
1 | 4.7530329 | 1.6970322 |
1 | 4.8855847 | 3.1092405 |
1 | 4.9202943 | 3.6878621 |
1 | 5.0692918 | 4.4614043 |
1 | 5.094251 | 4.9986657 |
1 | 5.2213603 | 2.8859654 |
1 | 5.29025 | 4.1231551 |
1 | 5.3047409 | 4.0529775 |
1 | 5.3807576 | 2.8897184 |
1 | 5.4022501 | 4.2157411 |
1 | 5.5258683 | 4.6077935 |
1 | 5.5602902 | 4.0202276 |
1 | 5.5928493 | 5.9473488 |
1 | 5.6337921 | 2.0477399 |
2 | 4.5649633 | 10.8199028 |
2 | 4.9492476 | 11.2417831 |
2 | 4.9639843 | 10.1301841 |
2 | 5.226796 | 9.0896456 |
2 | 5.5160477 | 10.339618 |
2 | 5.5494966 | 11.3187034 |
2 | 5.7321392 | 9.3091876 |
2 | 5.78872 | 9.9671922 |
2 | 5.8074223 | 10.160413 |
2 | 5.8077218 | 11.2829668 |
2 | 5.8401064 | 10.4340778 |
2 | 5.8887826 | 11.182616 |
2 | 5.9385494 | 9.0826968 |
2 | 6.0173279 | 12.015934 |
2 | 6.1333175 | 11.0641202 |
2 | 6.1493846 | 7.5813131 |
2 | 6.3247616 | 10.5008158 |
2 | 6.3596552 | 10.4300021 |
2 | 6.4498757 | 10.4660964 |
2 | 6.5039886 | 11.1291981 |
2 | 6.5577834 | 8.1352935 |
2 | 6.6243969 | 9.1862597 |
2 | 6.6653361 | 9.8993512 |
2 | 6.6752921 | 9.2522435 |
2 | 6.6978867 | 9.9182312 |
2 | 6.7050083 | 12.974634 |
2 | 6.7473609 | 9.2485078 |
2 | 6.7493806 | 9.5129937 |
2 | 6.7887799 | 9.8588077 |
2 | 6.836351 | 9.2174683 |
2 | 6.8726451 | 10.0834742 |
2 | 6.8903508 | 8.7250099 |
2 | 6.8907481 | 10.7297899 |
2 | 6.8955632 | 9.2141097 |
2 | 6.9133122 | 12.337941 |
2 | 6.9817274 | 9.634554 |
2 | 6.9985553 | 8.0236224 |
2 | 7.0917411 | 9.5520639 |
2 | 7.1110772 | 10.5536931 |
2 | 7.138392 | 9.2415998 |
2 | 7.1624205 | 9.7417785 |
2 | 7.1675304 | 10.3424403 |
2 | 7.1959608 | 9.6760523 |
2 | 7.1960034 | 10.4806538 |
2 | 7.2013835 | 11.6980377 |
2 | 7.2141018 | 10.6837557 |
2 | 7.2348838 | 8.4397497 |
2 | 7.2422483 | 9.3493743 |
2 | 7.2430823 | 9.7644821 |
2 | 7.2613676 | 10.8671876 |
2 | 7.2946775 | 9.1593571 |
2 | 7.3350288 | 10.460047 |
2 | 7.335831 | 11.4561045 |
2 | 7.3401016 | 11.1398342 |
2 | 7.3739163 | 9.9216549 |
2 | 7.43575 | 9.3674077 |
2 | 7.4735116 | 9.3621969 |
2 | 7.5094318 | 10.7425193 |
2 | 7.5192765 | 9.0919875 |
2 | 7.5230336 | 9.3181116 |
2 | 7.5389153 | 10.3706625 |
2 | 7.569023 | 11.6957121 |
2 | 7.6814631 | 9.0434399 |
2 | 7.7144954 | 7.191835 |
2 | 7.7198893 | 11.0829336 |
2 | 7.7803768 | 9.8861349 |
2 | 7.9326271 | 10.1804494 |
2 | 7.9732352 | 9.991876 |
2 | 7.9849534 | 9.8853695 |
2 | 8.1124261 | 9.3706331 |
2 | 8.1154425 | 10.9006981 |
2 | 8.1254249 | 8.0928389 |
2 | 8.2795063 | 10.5570386 |
2 | 8.2975804 | 9.1768362 |
2 | 8.3800894 | 9.2322431 |
2 | 9.1497729 | 10.4123977 |
3 | 1.14794639 | 13.979611 |
3 | 1.87296376 | 16.259677 |
3 | 1.95057589 | 14.253912 |
3 | 2.1774974 | 14.078445 |
3 | 2.2212576 | 15.180736 |
3 | 2.3319392 | 16.250346 |
3 | 2.3417249 | 14.922804 |
3 | 2.3666823 | 15.057726 |
3 | 2.4343045 | 14.844073 |
3 | 2.4637002 | 15.504545 |
3 | 2.5730949 | 16.120083 |
3 | 2.6960326 | 14.719672 |
3 | 2.7176948 | 14.681052 |
3 | 2.735971 | 16.281386 |
3 | 2.7907127 | 14.970722 |
3 | 2.8934128 | 16.577153 |
3 | 2.9067283 | 15.338185 |
3 | 2.9620927 | 16.091421 |
3 | 2.9967398 | 16.708606 |
3 | 3.0047431 | 15.371614 |
3 | 3.044215 | 14.689133 |
3 | 3.0872242 | 16.305325 |
3 | 3.0887985 | 15.697535 |
3 | 3.200185 | 16.663794 |
3 | 3.2008578 | 14.885879 |
3 | 3.2557222 | 14.889798 |
3 | 3.2892761 | 13.6007235 |
3 | 3.3028307 | 14.637392 |
3 | 3.3419285 | 14.224092 |
3 | 3.3422877 | 14.204327 |
3 | 3.3583757 | 16.048761 |
3 | 3.3893859 | 15.918406 |
3 | 3.4169347 | 16.292314 |
3 | 3.457675 | 15.097081 |
3 | 3.4578659 | 15.974339 |
3 | 3.4788892 | 16.152925 |
3 | 3.5046477 | 16.381791 |
3 | 3.5059035 | 16.737371 |
3 | 3.5621021 | 15.857647 |
3 | 3.6720782 | 13.4164271 |
3 | 3.6959001 | 16.995196 |
3 | 3.6992848 | 15.473127 |
3 | 3.7066215 | 14.623886 |
3 | 3.7295648 | 15.278963 |
3 | 3.7460885 | 15.579015 |
3 | 3.8699537 | 17.05209 |
3 | 3.8716518 | 17.413634 |
3 | 3.8873572 | 16.962738 |
3 | 3.9045898 | 16.715849 |
3 | 3.9456943 | 15.248866 |
3 | 3.9765246 | 16.883393 |
3 | 3.9819109 | 17.26836 |
3 | 3.998568 | 16.243342 |
3 | 4.0433096 | 17.347058 |
3 | 4.0596044 | 17.056215 |
3 | 4.0794422 | 15.758407 |
3 | 4.1129522 | 15.224293 |
3 | 4.1413942 | 15.929671 |
3 | 4.1627441 | 17.158977 |
3 | 4.1767186 | 15.184683 |
3 | 4.1781964 | 16.230266 |
3 | 4.2431648 | 16.962598 |
3 | 4.2618399 | 15.533754 |
3 | 4.3829695 | 15.589008 |
3 | 4.3900615 | 16.298833 |
3 | 4.4072292 | 15.452131 |
3 | 4.4630972 | 17.51363 |
3 | 4.4865115 | 15.166259 |
3 | 4.489808 | 15.302365 |
3 | 4.4985781 | 15.176454 |
3 | 4.4995603 | 16.339537 |
3 | 4.5015888 | 16.546623 |
3 | 4.5126907 | 17.181318 |
3 | 4.5186807 | 15.243923 |
3 | 4.5200494 | 16.606359 |
3 | 4.5546059 | 16.523475 |
3 | 4.5593513 | 17.20819 |
3 | 4.620113 | 17.041174 |
3 | 4.7561987 | 16.161672 |
3 | 4.7777356 | 15.774779 |
3 | 4.7993429 | 16.862268 |
3 | 4.8108036 | 17.172305 |
3 | 4.8138488 | 18.482412 |
3 | 4.9717907 | 16.813861 |
3 | 4.9946929 | 17.564215 |
3 | 5.0059337 | 16.629871 |
3 | 5.0114164 | 16.947345 |
3 | 5.0376315 | 15.086702 |
3 | 5.1360659 | 15.978871 |
3 | 5.1976377 | 17.45016 |
3 | 5.3760322 | 15.3188 |
3 | 5.4290531 | 16.540536 |
3 | 5.4497178 | 16.767889 |
3 | 5.4527803 | 16.620024 |
3 | 5.6388008 | 16.745066 |
3 | 5.6473698 | 16.450529 |
3 | 5.7566377 | 17.143698 |
3 | 5.7900453 | 16.382074 |
3 | 5.8758893 | 16.90501 |
3 | 5.9023884 | 16.818273 |
3 | 5.9788072 | 15.959914 |
3 | 6.0324193 | 16.252833 |
3 | 6.3479027 | 15.875618 |
4 | 10.4652107 | 2.6831135 |
4 | 10.5244255 | 1.1185327 |
4 | 10.676615 | 2.1365133 |
4 | 10.7060357 | 4.8800944 |
4 | 11.0507822 | 4.9306996 |
4 | 11.0926175 | 5.5469616 |
4 | 11.1620361 | 3.4362472 |
4 | 11.528659 | 4.9653684 |
4 | 11.68202 | 4.9323634 |
4 | 11.8113105 | 5.0447482 |
4 | 11.8395293 | 3.2846371 |
4 | 11.8904436 | 3.9756688 |
4 | 11.901902 | 4.0596121 |
4 | 12.00957 | 3.8387848 |
4 | 12.041757 | 3.2972722 |
4 | 12.070124 | 3.5975018 |
4 | 12.125698 | 5.2145027 |
4 | 12.13737 | 5.069625 |
4 | 12.179778 | 2.7118074 |
4 | 12.300714 | 2.811699 |
4 | 12.302589 | 4.6895294 |
4 | 12.310044 | 3.3904743 |
4 | 12.360948 | 4.048405 |
4 | 12.387776 | 2.650697 |
4 | 12.404948 | 2.3650841 |
4 | 12.415097 | 4.0142043 |
4 | 12.417047 | 3.4687826 |
4 | 12.442745 | 5.030264 |
4 | 12.443721 | 4.1409706 |
4 | 12.447941 | 5.8988869 |
4 | 12.476582 | 3.743859 |
4 | 12.515158 | 5.106076 |
4 | 12.595752 | 3.8626734 |
4 | 12.615602 | 3.2022261 |
4 | 12.61961 | 5.7629745 |
4 | 12.632347 | 3.3748335 |
4 | 12.657503 | 3.2747553 |
4 | 12.709758 | 5.0287697 |
4 | 12.747944 | 5.0152176 |
4 | 12.752371 | 4.7189407 |
4 | 12.818769 | 3.7802197 |
4 | 12.820888 | 3.1272452 |
4 | 12.830515 | 5.601528 |
4 | 12.863656 | 2.6533946 |
4 | 12.88482 | 5.2657701 |
4 | 12.904148 | 4.8965637 |
4 | 12.939187 | 3.1585675 |
4 | 12.952628 | 2.2741358 |
4 | 12.973613 | 4.8611944 |
4 | 12.97606 | 2.9509126 |
4 | 13.000251 | 4.8797171 |
4 | 13.004435 | 2.8729802 |
4 | 13.004874 | 4.9961698 |
4 | 13.008949 | 4.4582345 |
4 | 13.025455 | 4.3870708 |
4 | 13.045022 | 4.9916418 |
4 | 13.096295 | 2.973044 |
4 | 13.195278 | 2.9627547 |
4 | 13.21192 | 4.3851352 |
4 | 13.215603 | 4.153893 |
4 | 13.362235 | 2.9408317 |
4 | 13.487338 | 3.4554507 |
4 | 13.507061 | 4.9059559 |
4 | 13.544954 | 3.0748351 |
4 | 13.561125 | 3.3112401 |
4 | 13.575478 | 3.2823488 |
4 | 13.61449 | 4.9872933 |
4 | 13.618037 | 3.916222 |
4 | 13.63065 | 4.3280429 |
4 | 13.666668 | 4.0476106 |
4 | 13.693189 | 4.5426592 |
4 | 13.71092 | 2.5744855 |
4 | 13.717479 | 3.5385358 |
4 | 13.723603 | 4.8269313 |
4 | 13.740956 | 4.5362417 |
4 | 13.810342 | 3.3345241 |
4 | 13.884852 | 5.2966064 |
4 | 13.88918 | 2.4088233 |
4 | 13.908124 | 4.4692953 |
4 | 13.920669 | 5.1046996 |
4 | 14.066882 | 4.2443514 |
4 | 14.119596 | 3.8195427 |
4 | 14.134638 | 4.0501819 |
4 | 14.15121 | 5.0939166 |
4 | 14.174712 | 1.7723559 |
4 | 14.23597 | 5.8236027 |
4 | 14.270719 | 3.9357992 |
4 | 14.418402 | 5.0104769 |
4 | 14.423091 | 4.655516 |
4 | 14.58717 | 5.4807475 |
4 | 14.608216 | 5.5958854 |
4 | 14.621365 | 5.1009621 |
4 | 14.639837 | 5.7854218 |
4 | 14.675322 | 3.0883694 |
4 | 14.885806 | 4.5369381 |
4 | 15.123712 | 3.1371023 |
4 | 15.314308 | 4.2649289 |
5 | 10.1271918 | 15.296397 |
5 | 11.0410633 | 15.246086 |
5 | 11.0765704 | 14.281669 |
5 | 11.1579441 | 14.821112 |
5 | 11.2049293 | 14.132894 |
5 | 11.2509463 | 13.3686 |
5 | 11.2995974 | 15.315821 |
5 | 11.4488022 | 13.797879 |
5 | 11.4718758 | 15.400537 |
5 | 11.6037499 | 15.167981 |
5 | 11.6299854 | 12.916744 |
5 | 11.6385609 | 15.134394 |
5 | 11.722283 | 12.348765 |
5 | 11.8768788 | 12.795341 |
5 | 11.8805154 | 13.427278 |
5 | 11.9245665 | 14.171992 |
5 | 11.9419753 | 12.11674 |
5 | 11.9458388 | 13.572502 |
5 | 11.9963091 | 13.910162 |
5 | 11.9977637 | 12.264383 |
5 | 12.120108 | 14.298028 |
5 | 12.161642 | 12.235561 |
5 | 12.259619 | 14.538579 |
5 | 12.278865 | 13.907848 |
5 | 12.284851 | 14.78127 |
5 | 12.302126 | 13.551077 |
5 | 12.419082 | 13.560862 |
5 | 12.451229 | 14.87717 |
5 | 12.481022 | 14.631295 |
5 | 12.487289 | 13.299683 |
5 | 12.570844 | 13.073695 |
5 | 12.587373 | 14.506647 |
5 | 12.625944 | 13.499386 |
5 | 12.641761 | 13.157186 |
5 | 12.64511 | 12.942852 |
5 | 12.667898 | 15.982038 |
5 | 12.670485 | 13.955641 |
5 | 12.706356 | 13.361715 |
5 | 12.711061 | 14.236744 |
5 | 12.771428 | 12.766095 |
5 | 12.775607 | 16.052587 |
5 | 12.886805 | 13.023554 |
5 | 12.928196 | 11.2239141 |
5 | 12.950179 | 14.187592 |
5 | 12.966609 | 13.020396 |
5 | 12.984097 | 13.00589 |
5 | 12.997997 | 14.669185 |
5 | 13.089569 | 14.398868 |
5 | 13.108494 | 13.910334 |
5 | 13.147798 | 13.724342 |
5 | 13.155115 | 16.121416 |
5 | 13.158758 | 14.718643 |
5 | 13.213179 | 12.731326 |
5 | 13.222689 | 13.894866 |
5 | 13.237439 | 14.728269 |
5 | 13.247742 | 15.206662 |
5 | 13.256842 | 14.442514 |
5 | 13.269178 | 13.628728 |
5 | 13.350498 | 13.563816 |
5 | 13.469883 | 14.188571 |
5 | 13.4942 | 14.38967 |
5 | 13.52686 | 12.779428 |
5 | 13.553505 | 14.539572 |
5 | 13.559418 | 15.570712 |
5 | 13.567707 | 14.901948 |
5 | 13.634692 | 12.074948 |
5 | 13.634837 | 14.236684 |
5 | 13.641807 | 14.726728 |
5 | 13.677089 | 14.332538 |
5 | 13.767215 | 15.092209 |
5 | 13.781016 | 12.595779 |
5 | 13.878886 | 14.329098 |
5 | 13.891137 | 13.18777 |
5 | 13.895193 | 11.6599829 |
5 | 13.945273 | 13.156521 |
5 | 13.949261 | 12.944328 |
5 | 13.998138 | 13.186815 |
5 | 14.01272 | 14.270148 |
5 | 14.021108 | 15.495508 |
5 | 14.026602 | 13.861609 |
5 | 14.056164 | 13.728905 |
5 | 14.065794 | 13.845586 |
5 | 14.087697 | 15.523848 |
5 | 14.105136 | 13.638893 |
5 | 14.197604 | 14.022645 |
5 | 14.296025 | 15.509115 |
5 | 14.349088 | 14.002902 |
5 | 14.370353 | 16.051215 |
5 | 14.425818 | 12.55447 |
5 | 14.465642 | 12.745134 |
5 | 14.470883 | 13.280208 |
5 | 14.473897 | 13.425769 |
5 | 14.516394 | 13.222901 |
5 | 14.646671 | 13.889919 |
5 | 14.651572 | 15.064428 |
5 | 14.888393 | 12.709495 |
5 | 15.075641 | 14.576588 |
5 | 16.009856 | 14.548147 |
Parag Kanade/fuzzy ants/Gauss500-2/gauss.c
#include "headerStatic.h" /*******************************************************************/ /*** Global Variables ***/ irisData data[MAXDATA]; //To hold the data read from the file int count=0; //Count of the total number of data elements int heapCount=0; // Total number of heaps int heapRow=0; // Rows for the second iteration with heaps int newHeapCount=0; // Count of the heaps for the second iteration heap heaps[MAXDATA]; // Data structure to hold the heap information heap newHeaps[MAXDATA]; // Data Structure to hold the new heap information // For the second iteration int board[MAXROWS][MAXCOLS]; // Board on which the objects are located ant ants[MAXANTS]; // Data structure to hold the ants float Dmax=0; // Distance of the most dissimilar object pair int minHeapCount=100000; // Counter to hold the minimum heap count, used only for academic purpose // no use in the algorithm int minPosition; // the minimum heap iteration , only for academic purpose // no use in the algorithm float clsCen[MAXDATA][MAXDATA][s];//to hold the objects after hardening int cenCount[MAXDATA];//to hold the number of objects after hardening /********************************************************************/ /*** Varaibles to normalize the features between 0 and 1 */ float minInput[features], maxInput[features],scale[features],minForHeaps[features],maxForHeaps[features],scaleForHeaps[features]; /********************************************************************/ /** Variables for the FCM algorithm */ int temp[200]; /* for square matrix tests */ float eps,m; matrix U, U1; BOOLEAN stop; center V; objects X; char fname[80]; FILE *fp; int run; float inv_cov[s+1][s+1]; /* inverse of covariance matrix Y */ float Y[s][s]; long rand_index, Random_seed; long state1[52] = { 9347, 3835, 5194, 8310, 346, 535, 5297, 6711, 77, 3834, 668, 4175, 6868, 5890, 9304, 8462, 5269, 920, 65392, 41600, 70119, 91032, 76220, 26245, 4746, 73608, 32823, 63264, 75641, 99104, 36534, 24704, 98255, 72266, 75336, 65152, 7269, 63163, 88471, 27271, 43641, 76649, 47773, 23777, 27491, 35926, 16651, 48652, 89766, 90921, 6056 }; int z; int mins=0; int aveit =0; float mintab[200]; int mincount[200]; long start,end,total; int lCount;//added by parag /********************************************************************/ /********************************************************************//*int lrand48(){return(rand());}void srand48(int a){return;}*//********************************************************************/ /********************************************************************/ /* Function to read the input data set */ /* The file name is assumed to be itest.data */ /* Status: Tested */ /* Output: Data from the file into the "data" (Global) data structure */ /* Output: Count (Global), the count of the number of objects */ /********************************************************************/ void readInput() { FILE *fp; char fname[80]; int i=0,j=0; char ch; sprintf(fname,"%s.data",filename); /* Check if the input file is opened */ if((fp=fopen(fname,"r"))==NULL) { printf("\n Unable to open input file \n"); exit(0); } /*initialise the minimum maximum and the scale */ for(i=0;i<features;i++) { minInput[i]=1000; maxInput[i]=0; minForHeaps[i]=1000; maxForHeaps[i]=0; scale[i]=0; scaleForHeaps[i]=0; } /* Discard leading comments */ ch = 'c'; while (ch != '#') fscanf (fp, "%c", &ch); i=0; /* Parse the file and populate the data structure */ while(!feof(fp)) { for(j=0;j<features;j++) { fscanf(fp,"%f ",&data[i][j]); } fscanf(fp,"\n"); for(j=0;j<features;j++) { if(data[i][j]<minInput[j]) minInput[j]=data[i][j]; if(data[i][j]>maxInput[j]) maxInput[j]=data[i][j]; } i++; } count=i; /* Normailze the feature values in between 0 and 1 */ for(j=0;j<features;j++) { if(minInput[j]!=maxInput[j]) scale[j]=1.0/(maxInput[j]-minInput[j]); else scale[j]=1.0; } for(i=0;i<count;i++) { for(j=0;j<features;j++) data[i][j]=(data[i][j]-minInput[j])*scale[j]; } fclose(fp); return; }//end of function /********************************************************************/ /*Function to compute the eucldiean distance for all input data set */ /* Output : an array conatining the distance of each object with the other */ /********************************************************************/ float computeDistance() { float distance,dist=0; int i=0,j=0,k=0; distance=0; for(j=0;j<count;j++) for(i=0;i<count;i++) { for(k=0;k<features;k++) dist+=sqrt((data[j][k]-data[i][k])*(data[j][k]-data[i][k])); if(distance<dist)distance=dist; dist=0; } return(distance); } /********************************************************************/ /* Function to compute the distance between two objects */ /* Output : Euclidean d istance between the two input objects */ /********************************************************************/ float computeDistanceBetween2(irisData a,irisData b) { float temp=0; int i=0; for(i=0;i<features;i++) temp+=(a[i]-b[i])*(a[i]-b[i]); temp=sqrt(temp); return(temp); } /********************************************************************/ /* Function to find the maximum distance between the input objects*/ /* Output: the maximum distance */ /* Input : The array of distances between objects */ /********************************************************************/ /*float findMax(float *distance) { int i=0,j=0; float max=distance[0]; for(i=0;i<count;i++) for(j=0;j<count;j++) { if(max<distance[i*count+j]) max=distance[i*count+j]; } return(max); }*/ /********************************************************************/ /* Function to compute the value of an object */ /********************************************************************/ float value(irisData a) { int i=0; float temp=0; for(i=0;i<features;i++) temp+=a[i]*a[i]; return(sqrt(temp)); } /********************************************************************/ /* Function to find the object in the data structure */ /* Output : The position of the object in the data */ /* Input : The object */ /********************************************************************/ int findInData(irisData object,int iFlag) { int i=0,lastCount=0,j,position=-1,flag[features],flg;if(iFlag==1)lastCount=MAXDATA;else{}for(i=0;i<lastCount;i++){ for(j=0;j<features;j++) if(fabs(object[j]-data[i][j])<0.00001) flag[j]=1; else { flag[j]=0; break;} flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /* Function to find whether there is an object on the board at a,b */ /* Output : a flag indicating whether an object is found or not */ /* Input : The row and column indicating the board position */ /********************************************************************/ int found(int a , int b) { if(board[a][b]==9) return 1; else return 0; } /********************************************************************/ /* Function to initialize the initial board */ /* Output : None */ /* Global Structures modified : heaps */ /* Input : Flag indicating the iteration 1: First 0: Second */ /********************************************************************/ void initialise(int flag) { int a,b,i=0,k=0; int loopCount,rowCount,colCount; /* Initialize the row, column and number of heaps */ if(flag==1) { loopCount=count; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=lCount; rowCount=heapRow; colCount=heapRow; } /* Initialize the heaps */ for(i=0;i<loopCount;i++) { heaps[i].count=0; heaps[i].x=0; heaps[i].y=0; heaps[i].disPosition=0; heaps[i].Dmax=0; heaps[i].Dmean=0; } for(i=0;i<loopCount;i++) { /*find a board position which is empty*/ do { a=lrand48()%rowCount; b=lrand48()%colCount; } while(found(a,b)); /*Allocate the object to that place and assign a heap to it*/ heaps[i].x=a; heaps[i].y=b; heaps[i].count=1; heaps[i].Dmax=0; heaps[i].Dmean=0; if(flag==1) { heaps[i].objects[0]=i; for(k=0;k<features;k++)heaps[i].Ocenter[k]=data[i][k]; } else { for(k=0;k<features;k++) heaps[i].Ocenter[k]=newHeaps[i].Ocenter[k]; } heaps[i].disPosition=0; board[a][b]=9; if((debugLevel>0)&&(flag==1))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],data[heaps[i].objects[0]][0]); if((debugLevel>0)&&(flag==0))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],newHeaps[i].Ocenter[0]); } /*initialise the initial heap count*/ heapCount=loopCount; currentRow=rowCount; } /********************************************************************/ /* Function to find whether an heap is present at the location a b */ /* Output : Flag indicating the presencs of the heap */ /* Input : Roe and column indicating the board position */ /********************************************************************/ int findObject(int a,int b) { int i; int position=-1; for(i=0;i<heapCount;i++) { if((heaps[i].x==a)&&(heaps[i].y==b)) { position=i; break; } } return(position); } /********************************************************************/ /* Function initialize the ants */ /* Output : None */ /* Input : Flag indicating the iteration */ /* Global Variables Modified : ant, heapCount, heaps, board */ /********************************************************************/ void initialiseAnts(int flag) { int i=0,a=0,b=0,position,j=0,loopCount=0,rowCount,colCount,k=0; if(flag==1) { loopCount=MAXANTS; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=MAXANTSFORHEAPS; rowCount=heapRow; colCount=heapRow; } for(i=0;i<loopCount;i++) { /*generate random positions for the ants*/ a=lrand48()%rowCount; b=lrand48()%colCount; ants[i].x=a; ants[i].y=b; /*Find if an object is present at that position or not*/ if(board[a][b]==9) { ants[i].carrying=1; /*find the heap at that location*/ position=findObject(a,b); if(position==-1) { printf("\n Error in logic: Ant init \n"); //getchar(); break; } else { /*Assign the heap data to the ant data and decrement the heap count*/ if(flag==1){ for(k=0;k<features;k++)ants[i].data[k]=data[heaps[position].objects[0]][k]; }else{for(k=0;k<features;k++)ants[i].data[k]=heaps[position].Ocenter[k];} for(j=position;j<heapCount-1;j++) heaps[j]=heaps[j+1]; heapCount--; } /*Clear the board position */ board[a][b]=-9; } else ants[i].carrying=-1; ants[i].speed=0; ants[i].dir=lrand48()%8; printf("\n Ant %2d X: %2d Y: %2d Carying : %2d ",i,ants[i].x,ants[i].y,ants[i].carrying); } currentAntCount=loopCount; } /********************************************************************/ /* Function to move the ant */ /* Output: None */ /* Input: Ant to be moved and the flag indicating the iteration */ /********************************************************************/ void moveNext(ant* a,int flag) { int rowCount,colCount; /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; } else { rowCount=heapRow; colCount=heapRow; }*/rowCount=currentRow;colCount=currentRow; /*Depending upon the direction move the ant*/ switch (a->dir) { case 0: a->y++; if(a->y>=colCount)a->y=0; break; case 1: a->x--; a->y++;; if(a->x<0)a->x=rowCount-1; if(a->y>=colCount)a->y=0; break; case 2: a->x--; if(a->x<0)a->x=rowCount-1; break; case 3: a->x--; a->y--; if(a->x<0)a->x=rowCount-1; if(a->y<0)a->y=colCount-1; break; case 4: a->y--; if(a->y<0)a->y=colCount-1; break; case 5: a->x++; a->y--; if(a->x>=rowCount)a->x=0; if(a->y<0)a->y=colCount-1; break; case 6: a->x++; if(a->x>=rowCount) a->x=0; break; case 7: a->x++; a->y++; if(a->x>=rowCount)a->x=0; if(a->y>=colCount)a->y=0; break; } }//end of function /********************************************************************/ /* Function to compute the parameters of the heap */ /* Output: None */ /* Input: The heap whose parameters are to be computed iteration flag*/ /********************************************************************/ void computeHeapParameters(heap* heapData,int flag) { int i=0,j=0,k=0,position=0; float distance=0; float Dmean=0.0; float *dis; float featureSum[features]; float max=0; float sum=0; /* init*/ for(k=0;k<features;k++) featureSum[k]=0; /*Compute the distance of each object and find the maximum distance*/ max=0; if(flag==1){ for(j=0;j<heapData->count;j++) for(i=0;i<heapData->count;i++) { for(k=0;k<features;k++) sum+= (data[heapData->objects[j]][k]-data[heapData->objects[i]][k])*(data[heapData->objects[j]][k]-data[heapData->objects[i]][k]); distance=sqrt(sum); if(max<distance) max=distance; sum=0; } /* Assign the maximum distance to the heap */ heapData->Dmax=max;/*Compute the centre object*/for(i=0;i<heapData->count;i++)for(k=0;k<features;k++) featureSum[k]+=data[heapData->objects[i]][k];for(k=0;k<features;k++)heapData->Ocenter[k]=featureSum[k]*1.0/heapData->count; /* Find the mean distance */if((dis=(float *) calloc(heapData->count,sizeof(float)))==NULL){printf("\nUnable to allocate memory in the compute heap parameters procedure\n");exit(0);} for(i=0;i<heapData->count;i++) { Dmean+=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); dis[i]=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); } heapData->Dmean=Dmean*1.0/heapData->count; /*Compute the most dissimilar object*/ max=dis[0]; for(i=1;i<heapData->count;i++) if(max<dis[i]) { max=dis[i]; position=i; } /*Assign the most dissimilar object to the heap variable*/ for(k=0;k<features;k++) heapData->Odissim[k]=data[heapData->objects[position]][k]; heapData->disPosition=position;free(dis); } else{/* Heap Parameters for the second stage */for(k=0;k<features;k++){ heapData->Odissim[k]=heapData->Ocenter[k];}heapData->disPosition=0;heapData->Dmean=0;heapData->Dmax=0;} }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a single object*/ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject1(ant *a,int position,int flag) { int i,k=0; /*Clear the board*/ board[heaps[position].x][heaps[position].y]=-9; /* Assign the data to the ant*/if(flag==1){ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[0]][k];}else {for(k=0;k<features;k++) a->data[k]=heaps[position].Ocenter[k];} a->carrying=1; /*Copy all the heaps remaining heaps in the structure*/ for(i=position;i<heapCount-1;i++) heaps[i]=heaps[i+1]; /*Decrement the heap count*/ heapCount--; }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a two objects */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject2(ant *a , int position,int flag) { float Pdestroy1=-1; int i=0,k=0; /*Compute the probability to destroy the heap*/ Pdestroy1=lrand48()%13*1.0/12.0; /*If the probability is more than Pdestroy then destroy the heap */ if(Pdestroy1<Pdestroy) { /*pick the object randomly*/ i=lrand48()%2; /* Assign the data to the ant */ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[i]][k]; a->carrying=1; /*Correct the heap parameters*/ heaps[position].count=1; heaps[position].objects[0]=heaps[position].objects[1-i]; computeHeapParameters(&heaps[position],flag); } }//end of function /********************************************************************/ /*Function to pick a object from a heap consisting of more than two object */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /********************************************************************/ void pickObjectn(ant *a,int position,int flag) { int i=0,k=0; /*If the criteria is satsfied then pick the object*/ if((computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)*1.0/heaps[position].Dmean)>Tremove) { a->carrying=1; for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[heaps[position].disPosition]][k]; for(i=heaps[position].disPosition;i<heaps[position].count-1;i++) heaps[position].objects[i]=heaps[position].objects[i+1]; heaps[position].count--; computeHeapParameters(&heaps[position],1); } }//end of function /********************************************************************/ /* Function to pick a object */ /********************************************************************/ void pick(ant *a,int flag) { int position=-1,i=0; float Pload1=-1.0; for(i=0;i<heapCount;i++) { /*Check if a heap is present in the eight neighbouring cells*/ if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if Heap is found*/ if(position!=-1) { /* heap or object found.*/ /*Depending upon the number present in the heap call the corresponding routine*/ switch(heaps[i].count) { case 1: Pload1 = lrand48()%151*1.0/150.0; if(Pload1<Pload) { pickObject1(a,position,flag); } break; case 2: pickObject2(a,position,flag); break; default: pickObjectn(a,position,flag); break; } } } /********************************************************************/ /* Function to drop a object to form a new heap */ /* Output: None */ /* Input: Ant, iteration flag */ /* Global Structure modified : heap, heapCount */ /********************************************************************/ void dropObject(ant* a,int flag) { /*Create a new heap*/ int k=0; heaps[heapCount].count=1; heaps[heapCount].x=a->x; heaps[heapCount].y=a->y; heaps[heapCount].Dmax=0; heaps[heapCount].Dmean=0; heaps[heapCount].disPosition=0; for(k=0;k<features;k++) { heaps[heapCount].Odissim[k]=a->data[k]; heaps[heapCount].Ocenter[k]=a->data[k]; } if(flag==1) {heaps[heapCount].objects[0]=findInData(a->data,flag); /*computeHeapParameters(&heaps[heapCount],flag);*/ } computeHeapParameters(&heaps[heapCount],flag); heapCount++; a->carrying=-1; board[a->x][a->y]=9; }//end of function /********************************************************************/ /* Function to find the heap position during the second iteration */ /* Output: position of the heap */ /* Input: object center of the heap that the ant is carrying */ /* Global Structure modified : none */ /********************************************************************/ int findInNewheaps(irisData object) { int position=-1,i,j=0,flag[features],flg; for(i=0;i<newHeapCount;i++) { for(j=0;j<features;j++) { if(fabs(object[j]-newHeaps[i].Ocenter[j])<0.00001) flag[j]=1; else {flag[j]=0;break;} } flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /*Function to drop a object to a heap consisting of a one or more object */ /* Output: none */ /* Input: Ant, position of the heap , iteration flag */ /* Global Structure modified: heaps,newHeaps */ /********************************************************************/ void dropObject1(ant* a, int position,int flag) { int heapPosition=-1,heapPosition1=-1,i,j,k=0; irisData newData,temp; if(flag==1) { /*Add the object to the heap and compute the heap parameters*/ /*if(heaps[position].count==heaps[position].objCount) {if((junk=(int *)realloc(heaps[position].objects,((heaps[position].objCount+OBJINC)*sizeof(int))))==NULL){printf("\n Cannot Allocate memory to the new object for %d heap",position);exit(0);}heaps[position].objects=junk;heaps[position].objCount+=OBJINC;free(junk); }*/ heaps[position].objects[heaps[position].count]=findInData(a->data,flag); heaps[position].count++; computeHeapParameters(&heaps[position],flag); } else { for(k=0;k<features;k++)temp[k]=heaps[position].Ocenter[k]; heapPosition=findInNewheaps(a->data); heapPosition1=findInNewheaps(heaps[position].Ocenter); if(heapPosition==-1||heapPosition1==-1) { printf("\n error in logic:new heaps\n"); //getchar(); return; } for(k=0;k<features;k++) {newData[k]=(newHeaps[heapPosition].Ocenter[k]*newHeaps[heapPosition].count+newHeaps[heapPosition1].Ocenter[k]*newHeaps[heapPosition1].count)*1.0/(newHeaps[heapPosition].count+newHeaps[heapPosition1].count);newHeaps[heapPosition].Ocenter[k]=newData[k];heaps[position].Ocenter[k]=newData[k]; } computeHeapParameters(&heaps[position],flag); for(i=newHeaps[heapPosition].count,j=0;j<newHeaps[heapPosition1].count;i++,j++) { newHeaps[heapPosition].objects[i]=newHeaps[heapPosition1].objects[j]; } newHeaps[heapPosition].count+=newHeaps[heapPosition1].count; for(i=heapPosition1;i<newHeapCount-1;i++) newHeaps[i]=newHeaps[i+1]; newHeapCount--; } a->carrying=-1; }//end of function /********************************************************************/ /* Function to drop a object */ /* Output: None */ /* Input: Ant, iteration flag */ /********************************************************************/ void drop(ant* a,int flag) { int i, position=-1; float Pdrop1=0.0; /*Find whether we have a heap in the neighbourhood of the cell*/ for(i=0;i<heapCount;i++) { if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if a heap is found*/ if(position!=-1) { /*heap or object found.*/ /*Depending on the number of objects present take action*/ switch(heaps[position].count) { /*If criteria is satisfied then drop the object*/ case 1: if(flag==1) { if((computeDistanceBetween2(a->data,data[heaps[position].objects[0]])*1.0/Dmax)<Tcreate) dropObject1(a,position,flag); } else { if((computeDistanceBetween2(a->data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) dropObject1(a,position,flag); } break; default: if(computeDistanceBetween2(a->data,heaps[position].Ocenter)<computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)) dropObject1(a,position,flag); break; } } else { /*Compute the probability to drop the object*/ Pdrop1 = lrand48()%151*1.0/150; if(Pdrop1<Pdrop) dropObject(a,flag); } }//end of function /********************************************************************/ /* Function to move the ant */ /* Output: none */ /* Input: Ant, iteration flag */ /********************************************************************/ void move(ant* a,int flag) { float pDir; /*Check the speed */ if (a->speed!=0) { /*move in the same direction*/ a->speed--; moveNext(a,flag); } else { /*generate the new direction*/ pDir=lrand48()%17*1.0/16.0; if(pDir<.85) { a->dir=lrand48()%8; } else if(pDir>.95) { a->speed=2; } moveNext(a,flag); } } /********************************************************************/ /* Function to simulate the movement of the ants */ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified: minHeapCount, minHeapPosition */ /********************************************************************/ void iterate(int flag) { int i=0,j=0,k=0,loopCount=0; if (flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS; while (i<MAXITERATIONS) { i++; for(j=0;j<loopCount;j++) { move(&ants[j],flag); if(ants[j].carrying==1) { drop(&ants[j],flag); } else { pick(&ants[j],flag); } } if(debugLevel>0){ for(k=0;k<heapCount;k++) for(j=0;j<heapCount;j++) if((k!=j)&&(heaps[k].x==heaps[j].x)&&(heaps[k].y==heaps[j].y)) { printf("\nerror two heaps with same co ordinates %d %d ",k,j); //getchar(); } k=0; for(j=0;j<heapCount;j++) k+=heaps[j].count; } if(heapCount<minHeapCount) { minHeapCount=heapCount; minPosition=i; } if(debugLevel>0) printf("\n i:%d Heap count %d sum %d",i,heapCount,k); else printf("\n i:%d Heap count %d",i,heapCount); heapSum+=heapCount; /*if(i%updateAfter==0) {adjustBoard(flag); writeIncremental(i,flag);heapSum=0;loopCount=currentAntCount; }*/ } }//end of function /********************************************************************/ /*Function to drop the objects carried by the ants after all the iterations*/ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified:none */ /********************************************************************/ void dropFinal(int flag) { int i=0,j=0,position=-1,loopCount=0; /*if(flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS;*/ loopCount=currentAntCount; for(i=0;i<loopCount;i++) { if(ants[i].carrying==1) { if(flag==1) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position,flag); } } else { /*Find if a heap is present */ do { position=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position,flag); position=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position!=-1); } } } }//end of function /********************************************************************/ /* Function for the implementation of QuickSort */ /* Output: none */ /* Input: data structure, low and high indices */ /* Global structure modified:none */ /********************************************************************/ void quickSort( heap A[], int low,int high ) { int mid=0; if(low<high) { mid=partition(A,low,high); quickSort(A,low,mid); quickSort(A,mid+1,high); } } /********************************************************************/ /* Partition routine used by quick sort */ /* Output: partition location */ /* Input: data , low, high */ /* Global structure modified:none */ /********************************************************************/ int partition(heap a[], int low,int high) { heap temp; int x=0,i=0,j=0; i=low; j=high; x=a[low].count; while (1) { while (a[j].count<x) j=j-1; while (a[i].count>x) i=i+1; if(i<j) { temp=a[i]; a[i]=a[j]; a[j--]=temp; } else return(j); } } /********************************************************************/ /* Function used to write the cluster information */ /* Output: none */ /* Input:iteration flag */ /* Global structure modified:none */ /********************************************************************/ void writeClusterInformation(int flag) { FILE *fp=fopen("center.clt","w"); FILE *fp1; FILE *fp2; FILE *fp3; char temp[80]; int i=0,j=0,k=0; int lastCount=0; int rowCount,colCount,antCount; strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp3=fopen(temp,"a"); if(dataDump) {strcpy(temp,"");sprintf(temp,"%sTot.out",filename);fp1=fopen(temp,"a");strcpy(temp,"");sprintf(temp,"%sObj.out",filename);fp2=fopen(temp,"a");if(fp1==NULL||fp2==NULL)printf("\n Error in opening file in the writer Cluster Information routine\n"); } /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; antCount=MAXANTS; } else { rowCount=heapRow; colCount=heapRow; antCount=MAXANTSFORHEAPS; }*/ rowCount=currentRow; colCount=currentRow; antCount=currentAntCount; if(fp==NULL) { printf("\n Unable to open cluster center output file \n"); /*return;*/ exit(0); } /*sort the array according to the count value and write the value of the top three elements*/ if((flag==1)&&(!EntireHeaps)) quickSort(heaps,0,heapCount); if(EntireHeaps) {if(flag==1) lastCount=heapCount;else lastCount=newHeapCount; } else lastCount=c; for(i=0;i<lastCount;i++) { if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",newHeaps[i].Ocenter[k]); fprintf(fp,"\n"); } else { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); fprintf(fp,"\n"); } } if(dataDump) { fprintf(fp1,"\n Information from the Ant Based Algorithm \n"); fprintf(fp1,"\n Important Parameters : Board %d X %d Ants : %d Iterations %d Total Heaps %d ",rowCount,colCount,antCount,MAXITERATIONS,lastCount); } if(flag==0) { if(dataDump) { fprintf(fp1," TCreateForHeaps %f \n",TcreateForHeaps); fprintf(fp2,"\nTotal Heaps : %d\n",heapCount); fprintf(fp2,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); } fprintf(fp3,"\n@ %d\n",lastCount); } else if(dataDump) fprintf(fp1,"\n");if(dataDump) { fprintf(fp1,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); for(i=0;i<lastCount;i++) if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp2,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); } fprintf(fp1," %5d\n",newHeaps[i].count); fprintf(fp2," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp1," %5d\n",heaps[i].count); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]); fprintf(fp1," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]); fprintf(fp1," %5d\n",heaps[i].count); }} if(flag==0) { if(dataDump) fprintf(fp1,"\n Objects in the heaps \n");for(i=0;i<newHeapCount;i++) { if(dataDump) fprintf(fp1,"\n\n Heap %d\n \n",i+1);fprintf(fp3,"# %d %d\n",i ,newHeaps[i].count); for(j=0;j<newHeaps[i].count;j++){ for(k=0;k<features;k++){ fprintf(fp3,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]); if(dataDump) fprintf(fp1,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]);} if(dataDump) fprintf(fp1,"\n"); fprintf(fp3,"\n"); } } } fclose(fp); fclose(fp3); if(dataDump) { fclose(fp1);fclose(fp2); }}//end of flie /********************************************************************/ /* Function to initialise the new heaps */ /* Output: none */ /* Input:new Heap structure */ /* Global structure modified:none */ /********************************************************************/ void initialiseNewHeaps(heap newHeaps[]) { int i=0,j=0; for(i=0;i<lCount;i++) { newHeaps[i].count=0; for(j=0;j<features;j++) newHeaps[i].Ocenter[j]=V[i][j]; newHeaps[i].x=heaps[i].x; newHeaps[i].y=heaps[i].y; } }//end of function /********************************************************************/ /* Function to initialise the new heaps */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ int findPosition(int i) { int j,position=0; for(j=1;j<lCount;j++) { if(U[j][i]>U[position][i]) position=j; } printf("\n Position %d ",position); return(position); }//end of function find position /********************************************************************/ /* Function to add object */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ void addObject(int object,heap * heapPosition) { heapPosition->objects[heapPosition->count]=object; heapPosition->count++; }//end of function add object /********************************************************************/ /* Function to harden the outputs obtained from fcm */ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/ void harden(heap newHeaps[]) { int i,heapPosition=-1,sum=0,j=0; /*initialise the new heaps*/ initialiseNewHeaps(newHeaps); for(i=0;i<count;i++) { heapPosition=findPosition(i); addObject(i,&newHeaps[heapPosition]); } /* To check for degenerate partitions*/ for(i=0;i<lCount;i++) { if(newHeaps[i].count==0){for(j=i;j<lCount-1;j++){newHeaps[j]=newHeaps[j+1];}lCount--;i--;} } newHeapCount=lCount; for(i=0;i<lCount;i++) computeHeapParameters(&newHeaps[i],1); if(debugLevel>0) { for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\n sum = %d",sum);} }//end of function/********************************************************************/ /* Function to initialize the initial parameters for the ant algorithm*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void init() { int i=0,j=0; for(i=0;i<MAXROWS;i++) for(j=0;j<MAXCOLS;j++) board[i][j]=-9; heapCount=0; newHeapCount=0; heapRow=0; minPosition=-1; minHeapCount=100000; for(i=0;i<MAXANTS;i++) { ants[i].carrying=-1; ants[i].x=-1; ants[i].y=-1; ants[i].speed=-1; ants[i].dir=-1; } } /********************************************************************/ /* Function to initialize the initial board */ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void initialiseBoard() { int i,j; for(i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; }/********************************************************************/ /* Function to harden the outputs obtained from fcm(2nd stage)*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: Cluster center , cluster center count*/ /********************************************************************/void harden1() { int i=0,heapPosition=-1; for(i=0;i<heapCount;i++) cenCount[i]=0; for(i=0;i<n;i++) { heapPosition=findPosition1(i); addObject1(i,heapPosition); } writeInfo(); }//end of function/********************************************************************/ /* Function to find to which class the object belongs */ /* Output: Class number */ /* Input: object position */ /* Global Structure Modified: None */ /********************************************************************/int findPosition1(int i) { int j,position=0; for(j=1;j<heapCount;j++) { if(U[j][i]>U[position][i]) position=j; } return(position); }//end of function find position/********************************************************************/ /* Function to Write the output of the hardened objects to file*/ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/void writeInfo(){int i=0,j=0,k=0;FILE *fp=fopen("fcm.out","a");if(fp==NULL){printf("\n Unable to open fcm output file \n");return;}fprintf(fp,"\n@ %d\n",heapCount);for(i=0;i<heapCount;i++){fprintf(fp,"# %d %d\n",i,cenCount[i]);for(j=0;j<cenCount[i];j++){for(k=0;k<s;k++)fprintf(fp,"%8.2f ",clsCen[i][j][k]/scale[k]+minInput[k]);fprintf(fp,"\n");}}fclose(fp);return;}/********************************************************************/ /* Function to add a object to a cluster (2nd stage) */ /* Output: none */ /* Input: object poistion , cluster position */ /* Global Structure Modified: Cluster object and cluster count*/ /*******************************************************************/void addObject1(int object,int heapPosition) { int k=0; for(k=0;k<features;k++) clsCen[heapPosition][cenCount[heapPosition]][k]=X[object][k]; cenCount[heapPosition]++; return; }//end of function add object/********************************************************************/ /* Function to read the original classification of objects */ /* Output: none */ /* Input: none */ /* Global Structure Modified: None */ /*******************************************************************/void readOrg(){int i=0,k=0;char temp[80];FILE *fp;//= fopen(dataname,"r");strcpy(temp,"");sprintf(temp,"%sFull.data",filename);fp=fopen(temp,"r");if(fp==NULL){printf("\n Unable to open full data input file ");exit(0);}for(i=0;i<n;i++){fscanf(fp,"%f ",&orgData[i][0]);for(k=1;k<s+1;k++)fscanf(fp,"%f ",&orgData[i][k]);}return;}// end of function/********************************************************************/ /* Function to classify the objects in different clusters */ /* Output: none */ /* Input: the cluster objects, the original classification, */ /* number of objects in the cluster,file to write the data */ /* Global Structure Modified: None *//********************************************************************/int analysisData(float data[][s],float orgData[n][s+1],int count,FILE * fp){int i=0,j=0,k=0,type=1,max=0;heapInfo info;for(i=0;i<c;i++){info.classObj[i]=0;}info.total=0;info.total=count;for(i=0;i<count;i++)for(j=0;j<n;j++){type=1;for(k=0;k<s;k++)if(fabs(data[i][k]-orgData[j][k+1])>errThresh){type=-1;break;}if(type!=-1){info.classObj[(int)orgData[j][0]-1]++;break;}}max=0;for(k=0;k<c;k++){if(info.classObj[k]>info.classObj[max])max=k;fprintf(fp,"\nClass %d Objects % d ",k+1,info.classObj[k]);}j=0;for(k=0;k<c;k++){if(k!=max)j+=info.classObj[k];}fprintf(fp,"\n Total errors : %d \n",j);return(j);}//end of analyse/********************************************************************/ /* Function to read the cluster information */ /* Output: none */ /* Input: input file pointer , output file pointer */ /* Global Structure Modified: None *//********************************************************************/void readFCM(FILE* fp,FILE *fp1){int i=0,j=0,k=0,l=0;int totalRuns=0,heapCount=0,junk=0,sum=0;char ch;FILE *fp2=fopen("errors.out","a");ch = 'c'; while (ch != '$') fscanf (fp, "%c", &ch);fscanf(fp,"%d\n",&totalRuns);printf("\n total runs %d ",totalRuns);for(l=0;l<totalRuns;l++){fscanf(fp,"%c",&ch);fscanf(fp,"%d\n",&heapCount);fprintf(fp1,"\n \nExperiment %d \n ",l+1);sum=0;for(i=0;i<heapCount;i++){fscanf(fp,"%c",&ch);fscanf(fp," %d %d\n",&junk,&clsCenCount[i]);for(j=0;j<clsCenCount[i];j++)for(k=0;k<s;k++)fscanf(fp,"%f",&fcmData[i][j][k]);fscanf(fp,"\n");fprintf(fp1,"\n\n Heap %d Total Objects %d \n",i+1,clsCenCount[i]);sum+=analysisData(fcmData[i],orgData,clsCenCount[i],fp1);}fprintf(fp2," %3d %3d %3d \n",l,sum,heapCount);}fprintf(fp2,"\n --------------------------\n");fclose(fp2);return;}//end of function/********************************************************************/ /* Function to update the board parameters */ /* Output: none */ /* Input: none */ /* Global Structure Modified: board size, ant count *//********************************************************************/void adjustBoard(int flag){int newRow=0,newAnt=0,antDiff=0,antsKilled=0,i=0,position[MAXANTS],position1=-1,j=0,k=0,a,b; newRow= (int)ceil(sqrt(4.0*heapSum/updateAfter)); newAnt= (int)ceil((heapSum*1.0/updateAfter)*1.0/3.0); if(newAnt<minAnts)newAnt=minAnts; if(newRow<rowMin)newRow=rowMin;antDiff=currentAntCount-newAnt; if((antDiff>0)&&(newAnt>=minAnts)) {for(i=0;i<currentAntCount;i++){if(ants[i].carrying==-1){position[antsKilled++]=i;}} if(antsKilled>=antDiff){for(i=0;i<antDiff;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1];for(k=i+1;k<antsKilled;k++)position[k]--; } currentAntCount=newAnt; }else {for(i=0;i<antsKilled;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1]; for(k=i+1;k<antsKilled;k++)position[k]--; }if(flag==1) { for(i=currentAntCount-1,k=0;k<antDiff-antsKilled;k++,i--) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position1,flag); }else { dropObject(&ants[i],flag); } } } else { //flag is zero 2nd stage /*Find if a heap is present */ do { position1=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position1].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position1,flag); position1=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position1!=-1); }//end else currentAntCount=newAnt;}//end elsecurrentAntCount=newAnt;}//end iffor(i=0;i<newAnt;i++){if((ants[i].x>=newRow)||(ants[i].y>=newRow)) { a=lrand48()%newRow; b=lrand48()%newRow; ants[i].x=a; ants[i].y=b; }} //Done with ants, now adjust the boardif((currentRow>newRow)&&(newRow>=rowMin)){for(i=0;i<heapCount;i++){if((heaps[i].x>=newRow)||(heaps[i].y>=newRow)) {do { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionheaps[i].x=a;heaps[i].y=b;board[a][b]=9;}//end if}//end for for(i=0;i<currentAntCount;i++){if((ants[i].carrying==1)&&((ants[i].x>=newRow)||(ants[i].y>=newRow))){//adjust the ant locationdo { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionants[i].x=a;ants[i].y=b;}//end if}//end for currentRow=newRow;}//end if }//end of function void writeIncremental(int iteration,int flag){FILE *fp=fopen("dump.txt","w");int i=0,j=0,k=0;fprintf(fp,"Stage %d\n",flag);fprintf(fp,"Board %d\n",currentRow);fprintf(fp,"Ants %d\n",currentAntCount);fprintf(fp,"Iteration %d\n",iteration);fprintf(fp,"Heaps %d\n",heapCount); if(flag==0)fprintf(fp,"NewHeapCount %d\n",newHeapCount); fprintf(fp,"Ants\n");for(i=0;i<currentAntCount;i++){fprintf(fp,"%d %d %d %d %d ",ants[i].x,ants[i].y,ants[i].carrying,ants[i].speed,ants[i].dir);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",ants[i].data[k]);fprintf(fp,"\n");}fprintf(fp,"Heaps\n");for(i=0;i<heapCount;i++){fprintf(fp,"%d %d %d %d %8.2f %8.2f \n",heaps[i].x,heaps[i].y,heaps[i].count,heaps[i].disPosition,heaps[i].Dmax,heaps[i].Dmean);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Ocenter[k]);fprintf(fp,"\n");for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Odissim[k]);fprintf(fp,"\n");if(flag==1){for(j=0;j<heaps[i].count;j++)fprintf(fp,"%d ",heaps[i].objects[j]);fprintf(fp,"\n");}}if(flag==0){fprintf(fp,"newHeaps\n");for(i=0;i<newHeapCount;i++){fprintf(fp,"%d\n",newHeaps[i].count);for(j=0;j<newHeaps[i].count;j++)fprintf(fp,"%d ",newHeaps[i].objects[j]);fprintf(fp,"\n");}}fclose(fp);}//end of function/********************************************************************/ /* Function Main */ /********************************************************************/ int main(int argc ,char** argv) { int sum=0,k=0,i=0,j=0; char temp[80]; FILE *fp=fopen("fcm.out","w"); FILE *fp1; FILE *fp2=fopen("antAnalysis.out","a"); FILE *fp3=fopen("fcmAnalysis.out","a"); FILE *fp4=fopen("errors.out","w"); FILE *fp5; fclose(fp4); sprintf(temp,"%sObj.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sTot.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp1=fopen(temp,"w"); fprintf(fp,"\n$%d",EXPRUN); fprintf(fp1,"\n$%d",EXPRUN); fclose(fp); fclose(fp1); if(argc==2)sscanf(argv[1],"%d",&debugLevel); printf("\n Debug level %d\n",debugLevel); for( i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; //Read from the file readInput(); //Compute the distance of all the points if(maxDist) { Dmax=computeDistance(); //Compute the maximum distance fp5=fopen("maxData.txt","w");fprintf(fp5,"%f",Dmax);fclose(fp5); } else {fp5=fopen("maxData.txt","r");fscanf(fp5,"%f",&Dmax);fclose(fp5); } printf("\n %f \n",Dmax); //Initialise the board for(k=0;k<EXPRUN;k++) { init(); sum=0; srand48(state1[k]); initialiseBoard(); initialise(1); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(1); printf("\n %d \n",heapCount); //Simulate the working of ants iterate(1); //drop the objects after all the iterations dropFinal(1); //to verify the correctness for(i=0;i<heapCount;i++) sum+=heaps[i].count; //write the cluster centers to the file writeClusterInformation(1); printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); //getchar(); //Run FCM // heapCount=2973;/* To be commented */ printf("\n\n k %d \n\n",k); Fcm(data); //compute new board size. lCount=heapCount; heapRow=(int)ceil(sqrt(4*heapCount)); newHeapCount=lCount; printf("\n LCount %d newHeapCount %d heap Row %d \n",lCount,newHeapCount,heapRow); //harden the objects harden(newHeaps); //iterate with the heaps as the objects. initialiseBoard(); initialise(0); for(i=0;i<lCount;i++) computeHeapParameters(&heaps[i],0); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(0); printf("\n %d \n",heapCount); //getchar(); //Simulate the working of ants iterate(0); dropFinal(0); writeClusterInformation(0); sum=0; for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); // getchar(); Fcm(data); harden1(); } fp=fopen("fcm.out","a"); fp1=fopen(temp,"a"); fprintf(fp,"\n"); fprintf(fp1,"\n"); fclose(fp); fclose(fp1); fp=fopen("fcm.out","r"); fp1=fopen(temp,"r");printf("\n Before read org\n");readOrg();printf("\nafter read org\n");readFCM(fp1,fp2);printf("\n After 1st read fcm\n");readFCM(fp,fp3);printf("\n After 2 fcm read \n");return(1); }//end of main /****************************************************************/ float NORM(feature , feature); void find_covar(); void Fcm (irisData Data[MAXDATA]) { int i,j,l; FILE *ofile; char temp[80]; int flag=0;//added by parag FILE *iniClsCen=fopen("center.clt","a+"); if(iniClsCen==NULL) { printf("\n Unable to open the initial cluster center file\n"); printf("\n choosing random cluster centers....\n"); flag=1; } strcpy(temp,""); sprintf(temp,"%s.data",filename); strcpy (fname,temp); /* Read from this file */ m=2.0; /* The exponent */ /*GET_INPUTS1(fname);*/ /* read in feature vectors */ for (j=0; j<n ; j++) /* Read File in row-major */ for (i=0; i<s ; i++) /* format */ X[j][i]=Data[j][i]; Random_seed=state1[run];/*randseed*/ srand48(Random_seed); for (run=0;run<TOTRUNS;run++) { //flag=1;//for testing random values if (EntireHeaps) lCount=heapCount; else lCount=c; for(i=0;i<lCount;i++) for(j=0;j<s;j++) V[i][j]=0; for(i=0;i<lCount;i++) { for(l=0;l<s;l++) { if(flag==1) { rand_index = lrand48() % n; V[i][l] = X[rand_index][l]; } else { fscanf(iniClsCen,"%f ",&V[i][l]); } }//end for } eps=0.001; stop = FALSE; /* This loop finds the final cluster center and the corresponding U values */ z = 0; while (stop == FALSE) { z++; UMAT(U,V,X); /** Update the U matrix **/ stop = FINISHED(U1,eps); CLUSTER(U,X); /** Get new cluster center **/ printf("Iteration: %d\n\n", z); } /* end while */ printf("Number of iterations: %d\n\n", z);strcpy(temp,""); sprintf(temp,"%sFCM.out",filename);if(dataDump) Output(temp); /* output the results */ }/*end for*/ if(dataDump) { ofile=fopen(temp,"a"); for (i=0; i <= mins; i++) fprintf(ofile, "Min %d of %10.3f occurred %d times\n", i, mintab[i], mincount[i]); fprintf(ofile, "Average iterations %f\n", (float)aveit/(float)TOTRUNS); fclose(ofile); } }/* end Main */ /* The GET_INPUTS1 procedure opens an input file, reads the number of input vectors, the number of features per vector, the number of clusters, and epsilon, then it reads the input values */ void GET_INPUTS1(char fname[]) //char fname[]; { /* Parameters: fname -- name of file containing input info. */ FILE *infile ;//*fopen(); //char junk[10][80]; char realfname[80]; char ch; char fileName1[80]; //int temp[10], i, j, inputs, outputs, count; int i,j; sprintf (realfname, "%s", fname); /* open input file */ if(normalize==1) strcpy(fileName1,"gtest1.data"); else strcpy(fileName1,fname); if((infile = fopen (fileName1, "r")) == NULL) printf("\n CAN'T OPEN %s\n",realfname); else { ch = 'c'; /* Discard leading comments */ while (ch != '#') fscanf (infile, "%c", &ch); for (j=0; j<n ; j++) /* Read File in row-major */ { /* format */ for (i=0; i<s ; i++) fscanf (infile, "%f", &X[j][i]); /* fscanf (infile, "%d", &temp[1]); */ /* end for */ } /* end for */ fclose(infile); /* close input file */ }/* end else */ } /* end GET_INPUTS1 */ /* The NORM function computes the norm of two vectors, x and v, of dimension s. This gives an indication of the distance between them */ float NORM( feature x, feature v) //feature x, v; { /* Parameters : x -- a local copy of an input vector v -- a local copy of a cluster center */ int i,j; /* loop variable */ double sum; /* the square root of sum is the norm; sum is the sum of the differences squared */ float mat1[s]; float mat2[s]; if (maha) { for (i=0; i<s; i++) mat1[i]=x[i]-v[i]; for(i=0;i<s;i++) { sum =0; for(j=0;j<s;j++) sum += mat1[j] * inv_cov[j][i]; mat2[i] = sum; } sum =0; for(j=0;j<s;j++) sum += mat1[j]*mat2[j]; } else { sum = 0; for(j=0;j<s;j++) sum += (x[j] - v[j])* (x[j] - v[j]); } return (float)(sqrt(sum)); } /* end NORM */ /* The UMAT procedure calculates the updated U matrix according to Bezdek's formula. Its side-effect is the update of the global array U1 */ void UMAT( matrix U,center V, objects X) /*matrix U; center V; objects X;*/ { /* Parameters: U, V, and X: same as in main program */ int i, j, k,l ;/* loop variables *///, class /* class whose cluster center //is closest to pattern k */; float d1,d2,d; float sum; int exact; for (k=0;k<n;k++) { /*printf("\n k %d ",k);*/ exact=false; for (i=0;i<lCount;i++) { sum=0; for (j=0;j<lCount;j++) { d1=NORM(X[k],V[i]); d2=NORM(X[k],V[j]); if(d2!=0) { d= d1/d2; d= d * d;/* pow(d1/d2,2.0/(m-1.0)); */ sum+=d; } else { exact = true; for(l=0;l<lCount;l++) if (l==j) U1[l][k]=1.0; else U1[l][k]=0.0; break; } } if (exact!=true) U1[i][k]=1.0/sum; } } } /* end UMAT */ /* The function FINISHED determines if a termination occurs. If not it updates U with U1, so its side-effect is the potential modification of U */ BOOLEAN FINISHED( matrix U1,float eps) //matrix U1; float eps; { /* Parameters: U1, eps-- same as in main */ float sum; /* sum of squared differences between corresponding elements of U and U1 */ int i,k; /* loop control variabes */ BOOLEAN finished; /* set to true if all corresponding elements are within epsilon */ finished = TRUE; sum = 0; for (i=0; i<lCount; i++) for (k=0; k<n; k++) sum += (U[i][k] - U1[i][k])*(U[i][k]-U1[i][k]); if (sqrt(sum) > eps) { finished = FALSE; for (i=0; i<lCount; i++) for (k=0; k<n; k++) U[i][k] = U1[i][k]; } /* end if */ return finished; } /* end FINISHED */ /* The CLUSTER procedure determines cluster centers in V for the c classes being searched for. The global array V is updated */ void CLUSTER( matrix U, objects X) //matrix U; objects X; { /* Parameters: U, X -- as in main */ int i, j, k; /* loop control variables */ feature num; /* numerator in the cluster center computation formula presented by Bezdek */ float denum; /* denumenator in the obove formula */ for (i=0; i<lCount; i++) { denum = 0; for (j=0; j<s; j++) { num[j] = 0; for (k=0; k<n; k++) num[j] += U[i][k] * U[i][k] * X[k][j]; /* pow(U[i][k],m) * X[k][j]; */ } /* end for */ for (k=0; k<n; k++) denum += U[i][k] * U[i][k]; /* pow(U[i][k],m); */ for (j=0; j<s; j++) V[i][j] = num[j] / denum; } /* end for */ } /* end CLUSTER */ float Compute_Jm(center V, objects X) //center V; //objects X; { int i, k,found; double Jm_value; float u,dik; Jm_value = 0; for (k=0; k<n; k++) { found = FALSE; for (i=0; i<lCount; i++) { dik=NORM(X[k],V[i]); dik=dik*dik; if (dik==0.0) { if (found == FALSE) { u=1.0; found = TRUE; printf("found the case with dik=0\n"); } else { printf("\n cant proceed with this initialization"); exit(1); } } else { if (found != TRUE) u=U1[i][k]; /* get_Uvalue(V,X,dik,k); */ else u=0.0; } Jm_value += u * u * dik;/* pow(u, m) * dik; */ } } return (Jm_value); } /* end Compute_Jm */ /* The Output procedure outputs the U matrix which gives the fuzzy measure of each feature belonging to a cluster center. It also outputs the cluster center for each class */ void Output(char fname[]) //char fname[80]; /* Parameters: U, V -- same as in main */ { int i, j, found; /* loop control variables */ float J2c; if ((fp=fopen(fname,"a"))==NULL) printf("\n CAN'T OPEN %s\n",fname); else { fprintf(fp,"\n The cluster centers are: \n"); fprintf(fp,"\n \n"); for (i=0; i<lCount; i++) { fprintf(fp,"\nCluster center %d: ",i+1); fprintf(fp,"\n"); for (j=0; j<s; j++) fprintf(fp,"%8.7f ",V[i][j]); } /* end for */ fprintf(fp,"\nThe membership grades for the feature vectors are:\n"); for (j=0; j<n; j++) { fprintf(fp,"\n"); for (i=0; i<lCount; i++) fprintf(fp," %8.7f",U[i][j]); } /* end for */ } /* end if */ J2c= Compute_Jm(V,X); found =0; for (i=0;i<= mins; i++){ if ((found == 0) && ((J2c - mintab[i]) < .001) && ((J2c - mintab[i]) > -.001)){ mincount[i]++; found = 1; } } if (found == 0){ mins++; mintab[mins]=J2c; mincount[mins]=1; } fprintf(fp,"\nJ%3.1f = %f", m,J2c); fprintf(fp, "Number of iterations: %d\n\n", z); aveit=aveit + z; fclose(fp); } /***************************************************************/ void find_covar(int m) //int m; { int i,j,k; float mean[s],sum; for (i=0;i<s;i++) mean[i]=0; for (i=0;i<s;i++) for (j=0;j<m;j++) mean[i]+=X[j][i]; for (i=0;i<s;i++) mean[i]/=m; for (i=0;i<s;i++) for (j=0;j<s;j++) { sum=0; for (k=0;k<m;k++) sum+=(X[k][i]-mean[i])*(X[k][j]-mean[j]); Y[i][j]=sum/m; } }
Parag Kanade/fuzzy ants/Gauss500-2/headerStatic.h
/********************************************************************//* Ant Class parameters *//* SPEED # amplitude of moves [1,10] *//* P direction Probability to move in the same direction [.5,1] *//* Max carry : Maximum object carrying time [20,200] *//* P load Probability to pick up a single object [0.4,0.8] *//* P destroy probability to destroy a heap of two objects [0,0.6] *//* T remove min. dissimilarity necessary for removing an object *//* from a heap [.1,.2] *//* T create max dissimilarity permitted for creating a heap[.05,.2]*//********************************************************************/ #include <stdio.h>#include <math.h>#include <string.h>#include<stdlib.h>#include <ctype.h>#include <time.h>#define MAXANTS 167#define MAXDATA 500#define MAXANTSFORHEAPS 45#define MAXITERATIONS 1000#define MAXROWS 45#define MAXCOLS 45#define EXPRUN 10#define Tremove 1.50#define Tcreate 0.5#define Pdrop 0.2#define Pdestroy 0.3#define Pload 0.3#define normalize 0#define EntireHeaps 1#define TcreateForHeaps 0.19#define features 2#define filename "gauss500_02"#define errThresh 0.1#define dataDump 1#define maxDist 1#define INITIALOBJECTS 75#define OBJINC 10/* some type definitions to make C code a little more readable */#define TRUE 1#define FALSE 0#define n MAXDATA /* number of input vectors */#define s features /* number of features */#define c 5 /* number of clusters */#define TOTRUNS 1 /* number of V's to write out */#define false 0#define true 1#define maha 0#define square 0extern int count;int debugLevel=0;/* To debug the code and verify the correctness of algorithms*/int currHeapCount=0;typedef int BOOLEAN;typedef short TYPE_IN_DATA; /* Type of input binary data */typedef float feature[s]; /* Type of each input; made up of input features */typedef float irisData[s];typedef feature objects[MAXDATA]; /* Type of array holding all inputs */typedef feature center[MAXDATA]; /* Type of array holding cluster centers */typedef float matrix[MAXDATA][MAXDATA];/* Type of the matrix containing membership grades */typedef struct Heap {float Dmax;//maximum dissimilar distanceirisData Ocenter;//center objectfloat Dmean;//mean of the distance between the center and all the objectsirisData Odissim;//most dissimilar objectint x;//x position on the boardint y;//y position on the boardint count;//number of objects in the heapsint disPosition;//most dissimilar objectint objects[MAXDATA];int objCount;}heap;typedef struct Ant{int x;int y;int carrying;int speed;int dir;irisData data;}ant;float orgData[n][s+1];float fcmData[MAXDATA][n][s];int clsCenCount[MAXDATA];int currentRow=0;int currentAntCount=0;int updateAfter=50;int heapSum=0;int minAnts=3;int rowMin=5;typedef struct HeapInfo{int total;int classObj[c];} heapInfo;/*heapInfo info[MAXDATA];*//********************************************************************//***Function decelarations*//********************************************************************//***For ant based algorithm*/void readInput();float computeDistance();float computeDistanceBetween2(irisData a,irisData b);float findMax(float *distance);float value(irisData a);int found(int a , int b);void initialise(int flag);int findObject(int a,int b);void initialiseAnts(int flag);void moveNext(ant* a,int flag);void computeHeapParameters(heap* data,int flag);void pickObject1(ant *a,int position,int flag);void pickObject2(ant *a , int position,int flag);void pickObjectn(ant *a,int position,int flag);void pick(ant *a,int flag);void dropObject(ant* a,int flag);int findInNewheaps(irisData object);void dropObject1(ant* a, int position,int flag);void drop(ant* a,int flag);void move(ant* a,int flag);void iterate(int flag);void dropFinal(int flag);int partition(heap a[], int low,int high);void quickSort( heap A[], int low,int high ) ;void writeClusterInformation(int flag);void initialiseNewHeaps(heap newHeaps[]);int findPosition(int i);void harden(heap newHeaps[]);void harden1();int findPosition1(int );void writeInfo();void addObject1(int ,int);void readFCM(FILE *,FILE *);void readOrg();int findInData(irisData input,int iflag);void adjustBoard(int flag);void writeIncremental(int iteration,int flag);/********************************************************************//***For FCM algorithm*/void GET_INPUTS1(char []);void UMAT( matrix,center,objects);BOOLEAN FINISHED(matrix, float);void CLUSTER( matrix, objects);void Output(char[]);void Fcm();/********************************************************************/
Parag Kanade/fuzzy ants/Gauss500-2/maxData.txt
1.662073
Parag Kanade/fuzzy ants/Gauss500-3/gauss500_03.data
gauss Data | |
# | |
1.2079091 | 5.7210589 |
1.2231833 | 6.624442 |
1.2724274 | 5.7211989 |
1.3905861 | 4.8528257 |
1.5263206 | 5.1902709 |
1.5446515 | 4.9092366 |
2.0817641 | 4.2932327 |
2.1329588 | 4.7909656 |
2.2061908 | 4.5587698 |
2.2294541 | 5.7094674 |
2.2311605 | 4.1842931 |
2.3729459 | 4.6146591 |
2.451783 | 6.0942238 |
2.4631214 | 3.9776029 |
2.4641181 | 5.9918609 |
2.5092126 | 5.2028537 |
2.5249635 | 3.8857945 |
2.5408484 | 5.0938419 |
2.5538585 | 6.1353191 |
2.580998 | 5.1703637 |
2.6221661 | 6.0532502 |
2.6675926 | 5.5078748 |
2.6693178 | 5.0258803 |
2.6757058 | 3.5386359 |
2.6875167 | 6.3955603 |
2.8136569 | 6.2550441 |
2.8330733 | 6.7522282 |
2.8388063 | 6.8021392 |
2.8394463 | 6.1968265 |
2.8564329 | 3.7743203 |
2.8694154 | 4.2415617 |
2.8838473 | 5.8844967 |
2.9151302 | 4.5118873 |
2.9197918 | 6.408129 |
2.9546596 | 6.2040109 |
2.9707417 | 4.4312104 |
3.0135107 | 5.9468569 |
3.0456382 | 5.6968997 |
3.0662513 | 5.9026477 |
3.0731757 | 7.0607237 |
3.0940184 | 7.3846903 |
3.0998003 | 5.0196854 |
3.1062588 | 5.8665536 |
3.1113574 | 4.7466426 |
3.1401502 | 4.322823 |
3.164504 | 4.3772491 |
3.167721 | 6.491692 |
3.1792337 | 5.1921312 |
3.189034 | 5.9209093 |
3.1923355 | 7.0269859 |
3.2420277 | 4.6866669 |
3.2563394 | 4.6318602 |
3.2646653 | 5.3621656 |
3.277839 | 5.5903912 |
3.2840827 | 4.3948904 |
3.3134128 | 5.7465675 |
3.3432966 | 4.3024976 |
3.3588688 | 4.6395169 |
3.3773154 | 5.509691 |
3.3923682 | 5.7704754 |
3.3928396 | 5.9307354 |
3.4097375 | 5.0243664 |
3.4250905 | 6.2957807 |
3.4256467 | 7.1909088 |
3.429859 | 6.6389274 |
3.4383383 | 6.5945946 |
3.4499816 | 5.3406544 |
3.4648999 | 5.7633964 |
3.5101871 | 5.0922003 |
3.5814278 | 6.4753996 |
3.5883151 | 4.204994 |
3.6065497 | 5.7304895 |
3.6109218 | 6.4108913 |
3.6800216 | 5.6595682 |
3.6865731 | 4.8736266 |
3.7364618 | 5.1109649 |
3.7834804 | 6.4478511 |
3.806937 | 4.2154877 |
3.8505015 | 4.7495611 |
3.8894656 | 5.5845772 |
3.898071 | 6.4421334 |
3.9191638 | 6.1379257 |
3.9232595 | 4.3691164 |
3.9263071 | 4.3499483 |
3.9336875 | 5.5430657 |
3.9561075 | 4.014345 |
3.956787 | 4.2913721 |
3.9597375 | 5.9233632 |
3.9647258 | 5.5541938 |
4.0014664 | 3.5959308 |
4.0967613 | 5.3460918 |
4.1113619 | 6.956129 |
4.1393133 | 5.1290369 |
4.2427451 | 6.3293623 |
4.2447324 | 4.4055278 |
4.2808958 | 6.1849711 |
4.2958248 | 6.52221 |
4.3333881 | 6.8926755 |
4.3770667 | 6.148263 |
4.3872811 | 5.0834977 |
4.3943806 | 3.2047041 |
4.4231133 | 7.1428545 |
4.4242463 | 6.7437029 |
4.4737188 | 7.1960809 |
4.5434832 | 4.9540165 |
4.5542301 | 6.6514457 |
4.556613 | 5.6792214 |
4.5569343 | 6.3557038 |
4.5681878 | 4.7334969 |
4.6154429 | 6.9919154 |
4.6573287 | 5.6323181 |
4.7523585 | 6.6764836 |
4.7530329 | 3.6970322 |
4.8855847 | 5.1092405 |
4.9202943 | 5.6878621 |
5.0692918 | 6.4614043 |
5.094251 | 6.9986657 |
5.2213603 | 4.8859654 |
5.29025 | 6.1231551 |
5.3047409 | 6.0529775 |
5.3807576 | 4.8897184 |
5.4022501 | 6.2157411 |
5.5258683 | 6.6077935 |
5.5602902 | 6.0202276 |
5.5928493 | 7.9473488 |
5.6337921 | 4.0477399 |
9.5649633 | 15.8199028 |
9.9492476 | 16.2417831 |
9.9639843 | 15.1301841 |
10.226796 | 14.0896456 |
10.5160477 | 15.339618 |
10.5494966 | 16.3187034 |
10.7321392 | 14.3091876 |
10.78872 | 14.9671922 |
10.8074223 | 15.160413 |
10.8077218 | 16.2829668 |
10.8401064 | 15.4340778 |
10.8887826 | 16.182616 |
10.9385494 | 14.0826968 |
11.0173279 | 17.015934 |
11.1333175 | 16.0641202 |
11.1493846 | 12.5813131 |
11.3247616 | 15.5008158 |
11.3596552 | 15.4300021 |
11.4498757 | 15.4660964 |
11.5039886 | 16.1291981 |
11.5577834 | 13.1352935 |
11.6243969 | 14.1862597 |
11.6653361 | 14.8993512 |
11.6752921 | 14.2522435 |
11.6978867 | 14.9182312 |
11.7050083 | 17.974634 |
11.7473609 | 14.2485078 |
11.7493806 | 14.5129937 |
11.7887799 | 14.8588077 |
11.836351 | 14.2174683 |
11.8726451 | 15.0834742 |
11.8903508 | 13.7250099 |
11.8907481 | 15.7297899 |
11.8955632 | 14.2141097 |
11.9133122 | 17.337941 |
11.9817274 | 14.634554 |
11.9985553 | 13.0236224 |
12.0917411 | 14.5520639 |
12.1110772 | 15.5536931 |
12.138392 | 14.2415998 |
12.1624205 | 14.7417785 |
12.1675304 | 15.3424403 |
12.1959608 | 14.6760523 |
12.1960034 | 15.4806538 |
12.2013835 | 16.6980377 |
12.2141018 | 15.6837557 |
12.2348838 | 13.4397497 |
12.2422483 | 14.3493743 |
12.2430823 | 14.7644821 |
12.2613676 | 15.8671876 |
12.2946775 | 14.1593571 |
12.3350288 | 15.460047 |
12.335831 | 16.4561045 |
12.3401016 | 16.1398342 |
12.3739163 | 14.9216549 |
12.43575 | 14.3674077 |
12.4735116 | 14.3621969 |
12.5094318 | 15.7425193 |
12.5192765 | 14.0919875 |
12.5230336 | 14.3181116 |
12.5389153 | 15.3706625 |
12.569023 | 16.6957121 |
12.6814631 | 14.0434399 |
12.7144954 | 12.191835 |
12.7198893 | 16.0829336 |
12.7803768 | 14.8861349 |
12.9326271 | 15.1804494 |
12.9732352 | 14.991876 |
12.9849534 | 14.8853695 |
13.1124261 | 14.3706331 |
13.1154425 | 15.9006981 |
13.1254249 | 13.0928389 |
13.2795063 | 15.5570386 |
13.2975804 | 14.1768362 |
13.3800894 | 14.2322431 |
14.1497729 | 15.4123977 |
1.14794639 | 18.979611 |
1.87296376 | 21.259677 |
1.95057589 | 19.253912 |
2.1774974 | 19.078445 |
2.2212576 | 20.180736 |
2.3319392 | 21.250346 |
2.3417249 | 19.922804 |
2.3666823 | 20.057726 |
2.4343045 | 19.844073 |
2.4637002 | 20.504545 |
2.5730949 | 21.120083 |
2.6960326 | 19.719672 |
2.7176948 | 19.681052 |
2.735971 | 21.281386 |
2.7907127 | 19.970722 |
2.8934128 | 21.577153 |
2.9067283 | 20.338185 |
2.9620927 | 21.091421 |
2.9967398 | 21.708606 |
3.0047431 | 20.371614 |
3.044215 | 19.689133 |
3.0872242 | 21.305325 |
3.0887985 | 20.697535 |
3.200185 | 21.663794 |
3.2008578 | 19.885879 |
3.2557222 | 19.889798 |
3.2892761 | 18.6007235 |
3.3028307 | 19.637392 |
3.3419285 | 19.224092 |
3.3422877 | 19.204327 |
3.3583757 | 21.048761 |
3.3893859 | 20.918406 |
3.4169347 | 21.292314 |
3.457675 | 20.097081 |
3.4578659 | 20.974339 |
3.4788892 | 21.152925 |
3.5046477 | 21.381791 |
3.5059035 | 21.737371 |
3.5621021 | 20.857647 |
3.6720782 | 18.4164271 |
3.6959001 | 21.995196 |
3.6992848 | 20.473127 |
3.7066215 | 19.623886 |
3.7295648 | 20.278963 |
3.7460885 | 20.579015 |
3.8699537 | 22.05209 |
3.8716518 | 22.413634 |
3.8873572 | 21.962738 |
3.9045898 | 21.715849 |
3.9456943 | 20.248866 |
3.9765246 | 21.883393 |
3.9819109 | 22.26836 |
3.998568 | 21.243342 |
4.0433096 | 22.347058 |
4.0596044 | 22.056215 |
4.0794422 | 20.758407 |
4.1129522 | 20.224293 |
4.1413942 | 20.929671 |
4.1627441 | 22.158977 |
4.1767186 | 20.184683 |
4.1781964 | 21.230266 |
4.2431648 | 21.962598 |
4.2618399 | 20.533754 |
4.3829695 | 20.589008 |
4.3900615 | 21.298833 |
4.4072292 | 20.452131 |
4.4630972 | 22.51363 |
4.4865115 | 20.166259 |
4.489808 | 20.302365 |
4.4985781 | 20.176454 |
4.4995603 | 21.339537 |
4.5015888 | 21.546623 |
4.5126907 | 22.181318 |
4.5186807 | 20.243923 |
4.5200494 | 21.606359 |
4.5546059 | 21.523475 |
4.5593513 | 22.20819 |
4.620113 | 22.041174 |
4.7561987 | 21.161672 |
4.7777356 | 20.774779 |
4.7993429 | 21.862268 |
4.8108036 | 22.172305 |
4.8138488 | 23.482412 |
4.9717907 | 21.813861 |
4.9946929 | 22.564215 |
5.0059337 | 21.629871 |
5.0114164 | 21.947345 |
5.0376315 | 20.086702 |
5.1360659 | 20.978871 |
5.1976377 | 22.45016 |
5.3760322 | 20.3188 |
5.4290531 | 21.540536 |
5.4497178 | 21.767889 |
5.4527803 | 21.620024 |
5.6388008 | 21.745066 |
5.6473698 | 21.450529 |
5.7566377 | 22.143698 |
5.7900453 | 21.382074 |
5.8758893 | 21.90501 |
5.9023884 | 21.818273 |
5.9788072 | 20.959914 |
6.0324193 | 21.252833 |
6.3479027 | 20.875618 |
10.4652107 | 2.6831135 |
10.5244255 | 1.1185327 |
10.676615 | 2.1365133 |
10.7060357 | 4.8800944 |
11.0507822 | 4.9306996 |
11.0926175 | 5.5469616 |
11.1620361 | 3.4362472 |
11.528659 | 4.9653684 |
11.68202 | 4.9323634 |
11.8113105 | 5.0447482 |
11.8395293 | 3.2846371 |
11.8904436 | 3.9756688 |
11.901902 | 4.0596121 |
12.00957 | 3.8387848 |
12.041757 | 3.2972722 |
12.070124 | 3.5975018 |
12.125698 | 5.2145027 |
12.13737 | 5.069625 |
12.179778 | 2.7118074 |
12.300714 | 2.811699 |
12.302589 | 4.6895294 |
12.310044 | 3.3904743 |
12.360948 | 4.048405 |
12.387776 | 2.650697 |
12.404948 | 2.3650841 |
12.415097 | 4.0142043 |
12.417047 | 3.4687826 |
12.442745 | 5.030264 |
12.443721 | 4.1409706 |
12.447941 | 5.8988869 |
12.476582 | 3.743859 |
12.515158 | 5.106076 |
12.595752 | 3.8626734 |
12.615602 | 3.2022261 |
12.61961 | 5.7629745 |
12.632347 | 3.3748335 |
12.657503 | 3.2747553 |
12.709758 | 5.0287697 |
12.747944 | 5.0152176 |
12.752371 | 4.7189407 |
12.818769 | 3.7802197 |
12.820888 | 3.1272452 |
12.830515 | 5.601528 |
12.863656 | 2.6533946 |
12.88482 | 5.2657701 |
12.904148 | 4.8965637 |
12.939187 | 3.1585675 |
12.952628 | 2.2741358 |
12.973613 | 4.8611944 |
12.97606 | 2.9509126 |
13.000251 | 4.8797171 |
13.004435 | 2.8729802 |
13.004874 | 4.9961698 |
13.008949 | 4.4582345 |
13.025455 | 4.3870708 |
13.045022 | 4.9916418 |
13.096295 | 2.973044 |
13.195278 | 2.9627547 |
13.21192 | 4.3851352 |
13.215603 | 4.153893 |
13.362235 | 2.9408317 |
13.487338 | 3.4554507 |
13.507061 | 4.9059559 |
13.544954 | 3.0748351 |
13.561125 | 3.3112401 |
13.575478 | 3.2823488 |
13.61449 | 4.9872933 |
13.618037 | 3.916222 |
13.63065 | 4.3280429 |
13.666668 | 4.0476106 |
13.693189 | 4.5426592 |
13.71092 | 2.5744855 |
13.717479 | 3.5385358 |
13.723603 | 4.8269313 |
13.740956 | 4.5362417 |
13.810342 | 3.3345241 |
13.884852 | 5.2966064 |
13.88918 | 2.4088233 |
13.908124 | 4.4692953 |
13.920669 | 5.1046996 |
14.066882 | 4.2443514 |
14.119596 | 3.8195427 |
14.134638 | 4.0501819 |
14.15121 | 5.0939166 |
14.174712 | 1.7723559 |
14.23597 | 5.8236027 |
14.270719 | 3.9357992 |
14.418402 | 5.0104769 |
14.423091 | 4.655516 |
14.58717 | 5.4807475 |
14.608216 | 5.5958854 |
14.621365 | 5.1009621 |
14.639837 | 5.7854218 |
14.675322 | 3.0883694 |
14.885806 | 4.5369381 |
15.123712 | 3.1371023 |
15.314308 | 4.2649289 |
15.1271918 | 15.296397 |
16.0410633 | 15.246086 |
16.0765704 | 14.281669 |
16.1579441 | 14.821112 |
16.2049293 | 14.132894 |
16.2509463 | 13.3686 |
16.2995974 | 15.315821 |
16.4488022 | 13.797879 |
16.4718758 | 15.400537 |
16.6037499 | 15.167981 |
16.6299854 | 12.916744 |
16.6385609 | 15.134394 |
16.722283 | 12.348765 |
16.8768788 | 12.795341 |
16.8805154 | 13.427278 |
16.9245665 | 14.171992 |
16.9419753 | 12.11674 |
16.9458388 | 13.572502 |
16.9963091 | 13.910162 |
16.9977637 | 12.264383 |
17.120108 | 14.298028 |
17.161642 | 12.235561 |
17.259619 | 14.538579 |
17.278865 | 13.907848 |
17.284851 | 14.78127 |
17.302126 | 13.551077 |
17.419082 | 13.560862 |
17.451229 | 14.87717 |
17.481022 | 14.631295 |
17.487289 | 13.299683 |
17.570844 | 13.073695 |
17.587373 | 14.506647 |
17.625944 | 13.499386 |
17.641761 | 13.157186 |
17.64511 | 12.942852 |
17.667898 | 15.982038 |
17.670485 | 13.955641 |
17.706356 | 13.361715 |
17.711061 | 14.236744 |
17.771428 | 12.766095 |
17.775607 | 16.052587 |
17.886805 | 13.023554 |
17.928196 | 11.2239141 |
17.950179 | 14.187592 |
17.966609 | 13.020396 |
17.984097 | 13.00589 |
17.997997 | 14.669185 |
18.089569 | 14.398868 |
18.108494 | 13.910334 |
18.147798 | 13.724342 |
18.155115 | 16.121416 |
18.158758 | 14.718643 |
18.213179 | 12.731326 |
18.222689 | 13.894866 |
18.237439 | 14.728269 |
18.247742 | 15.206662 |
18.256842 | 14.442514 |
18.269178 | 13.628728 |
18.350498 | 13.563816 |
18.469883 | 14.188571 |
18.4942 | 14.38967 |
18.52686 | 12.779428 |
18.553505 | 14.539572 |
18.559418 | 15.570712 |
18.567707 | 14.901948 |
18.634692 | 12.074948 |
18.634837 | 14.236684 |
18.641807 | 14.726728 |
18.677089 | 14.332538 |
18.767215 | 15.092209 |
18.781016 | 12.595779 |
18.878886 | 14.329098 |
18.891137 | 13.18777 |
18.895193 | 11.6599829 |
18.945273 | 13.156521 |
18.949261 | 12.944328 |
18.998138 | 13.186815 |
19.01272 | 14.270148 |
19.021108 | 15.495508 |
19.026602 | 13.861609 |
19.056164 | 13.728905 |
19.065794 | 13.845586 |
19.087697 | 15.523848 |
19.105136 | 13.638893 |
19.197604 | 14.022645 |
19.296025 | 15.509115 |
19.349088 | 14.002902 |
19.370353 | 16.051215 |
19.425818 | 12.55447 |
19.465642 | 12.745134 |
19.470883 | 13.280208 |
19.473897 | 13.425769 |
19.516394 | 13.222901 |
19.646671 | 13.889919 |
19.651572 | 15.064428 |
19.888393 | 12.709495 |
20.075641 | 14.576588 |
21.009856 | 14.548147 |
Parag Kanade/fuzzy ants/Gauss500-3/gauss500_03Full.data
1 | 1.2079091 | 5.7210589 |
1 | 1.2231833 | 6.624442 |
1 | 1.2724274 | 5.7211989 |
1 | 1.3905861 | 4.8528257 |
1 | 1.5263206 | 5.1902709 |
1 | 1.5446515 | 4.9092366 |
1 | 2.0817641 | 4.2932327 |
1 | 2.1329588 | 4.7909656 |
1 | 2.2061908 | 4.5587698 |
1 | 2.2294541 | 5.7094674 |
1 | 2.2311605 | 4.1842931 |
1 | 2.3729459 | 4.6146591 |
1 | 2.451783 | 6.0942238 |
1 | 2.4631214 | 3.9776029 |
1 | 2.4641181 | 5.9918609 |
1 | 2.5092126 | 5.2028537 |
1 | 2.5249635 | 3.8857945 |
1 | 2.5408484 | 5.0938419 |
1 | 2.5538585 | 6.1353191 |
1 | 2.580998 | 5.1703637 |
1 | 2.6221661 | 6.0532502 |
1 | 2.6675926 | 5.5078748 |
1 | 2.6693178 | 5.0258803 |
1 | 2.6757058 | 3.5386359 |
1 | 2.6875167 | 6.3955603 |
1 | 2.8136569 | 6.2550441 |
1 | 2.8330733 | 6.7522282 |
1 | 2.8388063 | 6.8021392 |
1 | 2.8394463 | 6.1968265 |
1 | 2.8564329 | 3.7743203 |
1 | 2.8694154 | 4.2415617 |
1 | 2.8838473 | 5.8844967 |
1 | 2.9151302 | 4.5118873 |
1 | 2.9197918 | 6.408129 |
1 | 2.9546596 | 6.2040109 |
1 | 2.9707417 | 4.4312104 |
1 | 3.0135107 | 5.9468569 |
1 | 3.0456382 | 5.6968997 |
1 | 3.0662513 | 5.9026477 |
1 | 3.0731757 | 7.0607237 |
1 | 3.0940184 | 7.3846903 |
1 | 3.0998003 | 5.0196854 |
1 | 3.1062588 | 5.8665536 |
1 | 3.1113574 | 4.7466426 |
1 | 3.1401502 | 4.322823 |
1 | 3.164504 | 4.3772491 |
1 | 3.167721 | 6.491692 |
1 | 3.1792337 | 5.1921312 |
1 | 3.189034 | 5.9209093 |
1 | 3.1923355 | 7.0269859 |
1 | 3.2420277 | 4.6866669 |
1 | 3.2563394 | 4.6318602 |
1 | 3.2646653 | 5.3621656 |
1 | 3.277839 | 5.5903912 |
1 | 3.2840827 | 4.3948904 |
1 | 3.3134128 | 5.7465675 |
1 | 3.3432966 | 4.3024976 |
1 | 3.3588688 | 4.6395169 |
1 | 3.3773154 | 5.509691 |
1 | 3.3923682 | 5.7704754 |
1 | 3.3928396 | 5.9307354 |
1 | 3.4097375 | 5.0243664 |
1 | 3.4250905 | 6.2957807 |
1 | 3.4256467 | 7.1909088 |
1 | 3.429859 | 6.6389274 |
1 | 3.4383383 | 6.5945946 |
1 | 3.4499816 | 5.3406544 |
1 | 3.4648999 | 5.7633964 |
1 | 3.5101871 | 5.0922003 |
1 | 3.5814278 | 6.4753996 |
1 | 3.5883151 | 4.204994 |
1 | 3.6065497 | 5.7304895 |
1 | 3.6109218 | 6.4108913 |
1 | 3.6800216 | 5.6595682 |
1 | 3.6865731 | 4.8736266 |
1 | 3.7364618 | 5.1109649 |
1 | 3.7834804 | 6.4478511 |
1 | 3.806937 | 4.2154877 |
1 | 3.8505015 | 4.7495611 |
1 | 3.8894656 | 5.5845772 |
1 | 3.898071 | 6.4421334 |
1 | 3.9191638 | 6.1379257 |
1 | 3.9232595 | 4.3691164 |
1 | 3.9263071 | 4.3499483 |
1 | 3.9336875 | 5.5430657 |
1 | 3.9561075 | 4.014345 |
1 | 3.956787 | 4.2913721 |
1 | 3.9597375 | 5.9233632 |
1 | 3.9647258 | 5.5541938 |
1 | 4.0014664 | 3.5959308 |
1 | 4.0967613 | 5.3460918 |
1 | 4.1113619 | 6.956129 |
1 | 4.1393133 | 5.1290369 |
1 | 4.2427451 | 6.3293623 |
1 | 4.2447324 | 4.4055278 |
1 | 4.2808958 | 6.1849711 |
1 | 4.2958248 | 6.52221 |
1 | 4.3333881 | 6.8926755 |
1 | 4.3770667 | 6.148263 |
1 | 4.3872811 | 5.0834977 |
1 | 4.3943806 | 3.2047041 |
1 | 4.4231133 | 7.1428545 |
1 | 4.4242463 | 6.7437029 |
1 | 4.4737188 | 7.1960809 |
1 | 4.5434832 | 4.9540165 |
1 | 4.5542301 | 6.6514457 |
1 | 4.556613 | 5.6792214 |
1 | 4.5569343 | 6.3557038 |
1 | 4.5681878 | 4.7334969 |
1 | 4.6154429 | 6.9919154 |
1 | 4.6573287 | 5.6323181 |
1 | 4.7523585 | 6.6764836 |
1 | 4.7530329 | 3.6970322 |
1 | 4.8855847 | 5.1092405 |
1 | 4.9202943 | 5.6878621 |
1 | 5.0692918 | 6.4614043 |
1 | 5.094251 | 6.9986657 |
1 | 5.2213603 | 4.8859654 |
1 | 5.29025 | 6.1231551 |
1 | 5.3047409 | 6.0529775 |
1 | 5.3807576 | 4.8897184 |
1 | 5.4022501 | 6.2157411 |
1 | 5.5258683 | 6.6077935 |
1 | 5.5602902 | 6.0202276 |
1 | 5.5928493 | 7.9473488 |
1 | 5.6337921 | 4.0477399 |
2 | 9.5649633 | 15.8199028 |
2 | 9.9492476 | 16.2417831 |
2 | 9.9639843 | 15.1301841 |
2 | 10.226796 | 14.0896456 |
2 | 10.5160477 | 15.339618 |
2 | 10.5494966 | 16.3187034 |
2 | 10.7321392 | 14.3091876 |
2 | 10.78872 | 14.9671922 |
2 | 10.8074223 | 15.160413 |
2 | 10.8077218 | 16.2829668 |
2 | 10.8401064 | 15.4340778 |
2 | 10.8887826 | 16.182616 |
2 | 10.9385494 | 14.0826968 |
2 | 11.0173279 | 17.015934 |
2 | 11.1333175 | 16.0641202 |
2 | 11.1493846 | 12.5813131 |
2 | 11.3247616 | 15.5008158 |
2 | 11.3596552 | 15.4300021 |
2 | 11.4498757 | 15.4660964 |
2 | 11.5039886 | 16.1291981 |
2 | 11.5577834 | 13.1352935 |
2 | 11.6243969 | 14.1862597 |
2 | 11.6653361 | 14.8993512 |
2 | 11.6752921 | 14.2522435 |
2 | 11.6978867 | 14.9182312 |
2 | 11.7050083 | 17.974634 |
2 | 11.7473609 | 14.2485078 |
2 | 11.7493806 | 14.5129937 |
2 | 11.7887799 | 14.8588077 |
2 | 11.836351 | 14.2174683 |
2 | 11.8726451 | 15.0834742 |
2 | 11.8903508 | 13.7250099 |
2 | 11.8907481 | 15.7297899 |
2 | 11.8955632 | 14.2141097 |
2 | 11.9133122 | 17.337941 |
2 | 11.9817274 | 14.634554 |
2 | 11.9985553 | 13.0236224 |
2 | 12.0917411 | 14.5520639 |
2 | 12.1110772 | 15.5536931 |
2 | 12.138392 | 14.2415998 |
2 | 12.1624205 | 14.7417785 |
2 | 12.1675304 | 15.3424403 |
2 | 12.1959608 | 14.6760523 |
2 | 12.1960034 | 15.4806538 |
2 | 12.2013835 | 16.6980377 |
2 | 12.2141018 | 15.6837557 |
2 | 12.2348838 | 13.4397497 |
2 | 12.2422483 | 14.3493743 |
2 | 12.2430823 | 14.7644821 |
2 | 12.2613676 | 15.8671876 |
2 | 12.2946775 | 14.1593571 |
2 | 12.3350288 | 15.460047 |
2 | 12.335831 | 16.4561045 |
2 | 12.3401016 | 16.1398342 |
2 | 12.3739163 | 14.9216549 |
2 | 12.43575 | 14.3674077 |
2 | 12.4735116 | 14.3621969 |
2 | 12.5094318 | 15.7425193 |
2 | 12.5192765 | 14.0919875 |
2 | 12.5230336 | 14.3181116 |
2 | 12.5389153 | 15.3706625 |
2 | 12.569023 | 16.6957121 |
2 | 12.6814631 | 14.0434399 |
2 | 12.7144954 | 12.191835 |
2 | 12.7198893 | 16.0829336 |
2 | 12.7803768 | 14.8861349 |
2 | 12.9326271 | 15.1804494 |
2 | 12.9732352 | 14.991876 |
2 | 12.9849534 | 14.8853695 |
2 | 13.1124261 | 14.3706331 |
2 | 13.1154425 | 15.9006981 |
2 | 13.1254249 | 13.0928389 |
2 | 13.2795063 | 15.5570386 |
2 | 13.2975804 | 14.1768362 |
2 | 13.3800894 | 14.2322431 |
2 | 14.1497729 | 15.4123977 |
3 | 1.14794639 | 18.979611 |
3 | 1.87296376 | 21.259677 |
3 | 1.95057589 | 19.253912 |
3 | 2.1774974 | 19.078445 |
3 | 2.2212576 | 20.180736 |
3 | 2.3319392 | 21.250346 |
3 | 2.3417249 | 19.922804 |
3 | 2.3666823 | 20.057726 |
3 | 2.4343045 | 19.844073 |
3 | 2.4637002 | 20.504545 |
3 | 2.5730949 | 21.120083 |
3 | 2.6960326 | 19.719672 |
3 | 2.7176948 | 19.681052 |
3 | 2.735971 | 21.281386 |
3 | 2.7907127 | 19.970722 |
3 | 2.8934128 | 21.577153 |
3 | 2.9067283 | 20.338185 |
3 | 2.9620927 | 21.091421 |
3 | 2.9967398 | 21.708606 |
3 | 3.0047431 | 20.371614 |
3 | 3.044215 | 19.689133 |
3 | 3.0872242 | 21.305325 |
3 | 3.0887985 | 20.697535 |
3 | 3.200185 | 21.663794 |
3 | 3.2008578 | 19.885879 |
3 | 3.2557222 | 19.889798 |
3 | 3.2892761 | 18.6007235 |
3 | 3.3028307 | 19.637392 |
3 | 3.3419285 | 19.224092 |
3 | 3.3422877 | 19.204327 |
3 | 3.3583757 | 21.048761 |
3 | 3.3893859 | 20.918406 |
3 | 3.4169347 | 21.292314 |
3 | 3.457675 | 20.097081 |
3 | 3.4578659 | 20.974339 |
3 | 3.4788892 | 21.152925 |
3 | 3.5046477 | 21.381791 |
3 | 3.5059035 | 21.737371 |
3 | 3.5621021 | 20.857647 |
3 | 3.6720782 | 18.4164271 |
3 | 3.6959001 | 21.995196 |
3 | 3.6992848 | 20.473127 |
3 | 3.7066215 | 19.623886 |
3 | 3.7295648 | 20.278963 |
3 | 3.7460885 | 20.579015 |
3 | 3.8699537 | 22.05209 |
3 | 3.8716518 | 22.413634 |
3 | 3.8873572 | 21.962738 |
3 | 3.9045898 | 21.715849 |
3 | 3.9456943 | 20.248866 |
3 | 3.9765246 | 21.883393 |
3 | 3.9819109 | 22.26836 |
3 | 3.998568 | 21.243342 |
3 | 4.0433096 | 22.347058 |
3 | 4.0596044 | 22.056215 |
3 | 4.0794422 | 20.758407 |
3 | 4.1129522 | 20.224293 |
3 | 4.1413942 | 20.929671 |
3 | 4.1627441 | 22.158977 |
3 | 4.1767186 | 20.184683 |
3 | 4.1781964 | 21.230266 |
3 | 4.2431648 | 21.962598 |
3 | 4.2618399 | 20.533754 |
3 | 4.3829695 | 20.589008 |
3 | 4.3900615 | 21.298833 |
3 | 4.4072292 | 20.452131 |
3 | 4.4630972 | 22.51363 |
3 | 4.4865115 | 20.166259 |
3 | 4.489808 | 20.302365 |
3 | 4.4985781 | 20.176454 |
3 | 4.4995603 | 21.339537 |
3 | 4.5015888 | 21.546623 |
3 | 4.5126907 | 22.181318 |
3 | 4.5186807 | 20.243923 |
3 | 4.5200494 | 21.606359 |
3 | 4.5546059 | 21.523475 |
3 | 4.5593513 | 22.20819 |
3 | 4.620113 | 22.041174 |
3 | 4.7561987 | 21.161672 |
3 | 4.7777356 | 20.774779 |
3 | 4.7993429 | 21.862268 |
3 | 4.8108036 | 22.172305 |
3 | 4.8138488 | 23.482412 |
3 | 4.9717907 | 21.813861 |
3 | 4.9946929 | 22.564215 |
3 | 5.0059337 | 21.629871 |
3 | 5.0114164 | 21.947345 |
3 | 5.0376315 | 20.086702 |
3 | 5.1360659 | 20.978871 |
3 | 5.1976377 | 22.45016 |
3 | 5.3760322 | 20.3188 |
3 | 5.4290531 | 21.540536 |
3 | 5.4497178 | 21.767889 |
3 | 5.4527803 | 21.620024 |
3 | 5.6388008 | 21.745066 |
3 | 5.6473698 | 21.450529 |
3 | 5.7566377 | 22.143698 |
3 | 5.7900453 | 21.382074 |
3 | 5.8758893 | 21.90501 |
3 | 5.9023884 | 21.818273 |
3 | 5.9788072 | 20.959914 |
3 | 6.0324193 | 21.252833 |
3 | 6.3479027 | 20.875618 |
4 | 10.4652107 | 2.6831135 |
4 | 10.5244255 | 1.1185327 |
4 | 10.676615 | 2.1365133 |
4 | 10.7060357 | 4.8800944 |
4 | 11.0507822 | 4.9306996 |
4 | 11.0926175 | 5.5469616 |
4 | 11.1620361 | 3.4362472 |
4 | 11.528659 | 4.9653684 |
4 | 11.68202 | 4.9323634 |
4 | 11.8113105 | 5.0447482 |
4 | 11.8395293 | 3.2846371 |
4 | 11.8904436 | 3.9756688 |
4 | 11.901902 | 4.0596121 |
4 | 12.00957 | 3.8387848 |
4 | 12.041757 | 3.2972722 |
4 | 12.070124 | 3.5975018 |
4 | 12.125698 | 5.2145027 |
4 | 12.13737 | 5.069625 |
4 | 12.179778 | 2.7118074 |
4 | 12.300714 | 2.811699 |
4 | 12.302589 | 4.6895294 |
4 | 12.310044 | 3.3904743 |
4 | 12.360948 | 4.048405 |
4 | 12.387776 | 2.650697 |
4 | 12.404948 | 2.3650841 |
4 | 12.415097 | 4.0142043 |
4 | 12.417047 | 3.4687826 |
4 | 12.442745 | 5.030264 |
4 | 12.443721 | 4.1409706 |
4 | 12.447941 | 5.8988869 |
4 | 12.476582 | 3.743859 |
4 | 12.515158 | 5.106076 |
4 | 12.595752 | 3.8626734 |
4 | 12.615602 | 3.2022261 |
4 | 12.61961 | 5.7629745 |
4 | 12.632347 | 3.3748335 |
4 | 12.657503 | 3.2747553 |
4 | 12.709758 | 5.0287697 |
4 | 12.747944 | 5.0152176 |
4 | 12.752371 | 4.7189407 |
4 | 12.818769 | 3.7802197 |
4 | 12.820888 | 3.1272452 |
4 | 12.830515 | 5.601528 |
4 | 12.863656 | 2.6533946 |
4 | 12.88482 | 5.2657701 |
4 | 12.904148 | 4.8965637 |
4 | 12.939187 | 3.1585675 |
4 | 12.952628 | 2.2741358 |
4 | 12.973613 | 4.8611944 |
4 | 12.97606 | 2.9509126 |
4 | 13.000251 | 4.8797171 |
4 | 13.004435 | 2.8729802 |
4 | 13.004874 | 4.9961698 |
4 | 13.008949 | 4.4582345 |
4 | 13.025455 | 4.3870708 |
4 | 13.045022 | 4.9916418 |
4 | 13.096295 | 2.973044 |
4 | 13.195278 | 2.9627547 |
4 | 13.21192 | 4.3851352 |
4 | 13.215603 | 4.153893 |
4 | 13.362235 | 2.9408317 |
4 | 13.487338 | 3.4554507 |
4 | 13.507061 | 4.9059559 |
4 | 13.544954 | 3.0748351 |
4 | 13.561125 | 3.3112401 |
4 | 13.575478 | 3.2823488 |
4 | 13.61449 | 4.9872933 |
4 | 13.618037 | 3.916222 |
4 | 13.63065 | 4.3280429 |
4 | 13.666668 | 4.0476106 |
4 | 13.693189 | 4.5426592 |
4 | 13.71092 | 2.5744855 |
4 | 13.717479 | 3.5385358 |
4 | 13.723603 | 4.8269313 |
4 | 13.740956 | 4.5362417 |
4 | 13.810342 | 3.3345241 |
4 | 13.884852 | 5.2966064 |
4 | 13.88918 | 2.4088233 |
4 | 13.908124 | 4.4692953 |
4 | 13.920669 | 5.1046996 |
4 | 14.066882 | 4.2443514 |
4 | 14.119596 | 3.8195427 |
4 | 14.134638 | 4.0501819 |
4 | 14.15121 | 5.0939166 |
4 | 14.174712 | 1.7723559 |
4 | 14.23597 | 5.8236027 |
4 | 14.270719 | 3.9357992 |
4 | 14.418402 | 5.0104769 |
4 | 14.423091 | 4.655516 |
4 | 14.58717 | 5.4807475 |
4 | 14.608216 | 5.5958854 |
4 | 14.621365 | 5.1009621 |
4 | 14.639837 | 5.7854218 |
4 | 14.675322 | 3.0883694 |
4 | 14.885806 | 4.5369381 |
4 | 15.123712 | 3.1371023 |
4 | 15.314308 | 4.2649289 |
5 | 15.1271918 | 15.296397 |
5 | 16.0410633 | 15.246086 |
5 | 16.0765704 | 14.281669 |
5 | 16.1579441 | 14.821112 |
5 | 16.2049293 | 14.132894 |
5 | 16.2509463 | 13.3686 |
5 | 16.2995974 | 15.315821 |
5 | 16.4488022 | 13.797879 |
5 | 16.4718758 | 15.400537 |
5 | 16.6037499 | 15.167981 |
5 | 16.6299854 | 12.916744 |
5 | 16.6385609 | 15.134394 |
5 | 16.722283 | 12.348765 |
5 | 16.8768788 | 12.795341 |
5 | 16.8805154 | 13.427278 |
5 | 16.9245665 | 14.171992 |
5 | 16.9419753 | 12.11674 |
5 | 16.9458388 | 13.572502 |
5 | 16.9963091 | 13.910162 |
5 | 16.9977637 | 12.264383 |
5 | 17.120108 | 14.298028 |
5 | 17.161642 | 12.235561 |
5 | 17.259619 | 14.538579 |
5 | 17.278865 | 13.907848 |
5 | 17.284851 | 14.78127 |
5 | 17.302126 | 13.551077 |
5 | 17.419082 | 13.560862 |
5 | 17.451229 | 14.87717 |
5 | 17.481022 | 14.631295 |
5 | 17.487289 | 13.299683 |
5 | 17.570844 | 13.073695 |
5 | 17.587373 | 14.506647 |
5 | 17.625944 | 13.499386 |
5 | 17.641761 | 13.157186 |
5 | 17.64511 | 12.942852 |
5 | 17.667898 | 15.982038 |
5 | 17.670485 | 13.955641 |
5 | 17.706356 | 13.361715 |
5 | 17.711061 | 14.236744 |
5 | 17.771428 | 12.766095 |
5 | 17.775607 | 16.052587 |
5 | 17.886805 | 13.023554 |
5 | 17.928196 | 11.2239141 |
5 | 17.950179 | 14.187592 |
5 | 17.966609 | 13.020396 |
5 | 17.984097 | 13.00589 |
5 | 17.997997 | 14.669185 |
5 | 18.089569 | 14.398868 |
5 | 18.108494 | 13.910334 |
5 | 18.147798 | 13.724342 |
5 | 18.155115 | 16.121416 |
5 | 18.158758 | 14.718643 |
5 | 18.213179 | 12.731326 |
5 | 18.222689 | 13.894866 |
5 | 18.237439 | 14.728269 |
5 | 18.247742 | 15.206662 |
5 | 18.256842 | 14.442514 |
5 | 18.269178 | 13.628728 |
5 | 18.350498 | 13.563816 |
5 | 18.469883 | 14.188571 |
5 | 18.4942 | 14.38967 |
5 | 18.52686 | 12.779428 |
5 | 18.553505 | 14.539572 |
5 | 18.559418 | 15.570712 |
5 | 18.567707 | 14.901948 |
5 | 18.634692 | 12.074948 |
5 | 18.634837 | 14.236684 |
5 | 18.641807 | 14.726728 |
5 | 18.677089 | 14.332538 |
5 | 18.767215 | 15.092209 |
5 | 18.781016 | 12.595779 |
5 | 18.878886 | 14.329098 |
5 | 18.891137 | 13.18777 |
5 | 18.895193 | 11.6599829 |
5 | 18.945273 | 13.156521 |
5 | 18.949261 | 12.944328 |
5 | 18.998138 | 13.186815 |
5 | 19.01272 | 14.270148 |
5 | 19.021108 | 15.495508 |
5 | 19.026602 | 13.861609 |
5 | 19.056164 | 13.728905 |
5 | 19.065794 | 13.845586 |
5 | 19.087697 | 15.523848 |
5 | 19.105136 | 13.638893 |
5 | 19.197604 | 14.022645 |
5 | 19.296025 | 15.509115 |
5 | 19.349088 | 14.002902 |
5 | 19.370353 | 16.051215 |
5 | 19.425818 | 12.55447 |
5 | 19.465642 | 12.745134 |
5 | 19.470883 | 13.280208 |
5 | 19.473897 | 13.425769 |
5 | 19.516394 | 13.222901 |
5 | 19.646671 | 13.889919 |
5 | 19.651572 | 15.064428 |
5 | 19.888393 | 12.709495 |
5 | 20.075641 | 14.576588 |
5 | 21.009856 | 14.548147 |
Parag Kanade/fuzzy ants/Gauss500-3/gauss.c
#include "headerStatic.h" /*******************************************************************/ /*** Global Variables ***/ irisData data[MAXDATA]; //To hold the data read from the file int count=0; //Count of the total number of data elements int heapCount=0; // Total number of heaps int heapRow=0; // Rows for the second iteration with heaps int newHeapCount=0; // Count of the heaps for the second iteration heap heaps[MAXDATA]; // Data structure to hold the heap information heap newHeaps[MAXDATA]; // Data Structure to hold the new heap information // For the second iteration int board[MAXROWS][MAXCOLS]; // Board on which the objects are located ant ants[MAXANTS]; // Data structure to hold the ants float Dmax=0; // Distance of the most dissimilar object pair int minHeapCount=100000; // Counter to hold the minimum heap count, used only for academic purpose // no use in the algorithm int minPosition; // the minimum heap iteration , only for academic purpose // no use in the algorithm float clsCen[MAXDATA][MAXDATA][s];//to hold the objects after hardening int cenCount[MAXDATA];//to hold the number of objects after hardening /********************************************************************/ /*** Varaibles to normalize the features between 0 and 1 */ float minInput[features], maxInput[features],scale[features],minForHeaps[features],maxForHeaps[features],scaleForHeaps[features]; /********************************************************************/ /** Variables for the FCM algorithm */ int temp[200]; /* for square matrix tests */ float eps,m; matrix U, U1; BOOLEAN stop; center V; objects X; char fname[80]; FILE *fp; int run; float inv_cov[s+1][s+1]; /* inverse of covariance matrix Y */ float Y[s][s]; long rand_index, Random_seed; long state1[52] = { 9347, 3835, 5194, 8310, 346, 535, 5297, 6711, 77, 3834, 668, 4175, 6868, 5890, 9304, 8462, 5269, 920, 65392, 41600, 70119, 91032, 76220, 26245, 4746, 73608, 32823, 63264, 75641, 99104, 36534, 24704, 98255, 72266, 75336, 65152, 7269, 63163, 88471, 27271, 43641, 76649, 47773, 23777, 27491, 35926, 16651, 48652, 89766, 90921, 6056 }; int z; int mins=0; int aveit =0; float mintab[200]; int mincount[200]; long start,end,total; int lCount;//added by parag /********************************************************************/ /********************************************************************//*int lrand48(){return(rand());}void srand48(int a){return;}*//********************************************************************/ /********************************************************************/ /* Function to read the input data set */ /* The file name is assumed to be itest.data */ /* Status: Tested */ /* Output: Data from the file into the "data" (Global) data structure */ /* Output: Count (Global), the count of the number of objects */ /********************************************************************/ void readInput() { FILE *fp; char fname[80]; int i=0,j=0; char ch; sprintf(fname,"%s.data",filename); /* Check if the input file is opened */ if((fp=fopen(fname,"r"))==NULL) { printf("\n Unable to open input file \n"); exit(0); } /*initialise the minimum maximum and the scale */ for(i=0;i<features;i++) { minInput[i]=1000; maxInput[i]=0; minForHeaps[i]=1000; maxForHeaps[i]=0; scale[i]=0; scaleForHeaps[i]=0; } /* Discard leading comments */ ch = 'c'; while (ch != '#') fscanf (fp, "%c", &ch); i=0; /* Parse the file and populate the data structure */ while(!feof(fp)) { for(j=0;j<features;j++) { fscanf(fp,"%f ",&data[i][j]); } fscanf(fp,"\n"); for(j=0;j<features;j++) { if(data[i][j]<minInput[j]) minInput[j]=data[i][j]; if(data[i][j]>maxInput[j]) maxInput[j]=data[i][j]; } i++; } count=i; /* Normailze the feature values in between 0 and 1 */ for(j=0;j<features;j++) { if(minInput[j]!=maxInput[j]) scale[j]=1.0/(maxInput[j]-minInput[j]); else scale[j]=1.0; } for(i=0;i<count;i++) { for(j=0;j<features;j++) data[i][j]=(data[i][j]-minInput[j])*scale[j]; } fclose(fp); return; }//end of function /********************************************************************/ /*Function to compute the eucldiean distance for all input data set */ /* Output : an array conatining the distance of each object with the other */ /********************************************************************/ float computeDistance() { float distance,dist=0; int i=0,j=0,k=0; distance=0; for(j=0;j<count;j++) for(i=0;i<count;i++) { for(k=0;k<features;k++) dist+=sqrt((data[j][k]-data[i][k])*(data[j][k]-data[i][k])); if(distance<dist)distance=dist; dist=0; } return(distance); } /********************************************************************/ /* Function to compute the distance between two objects */ /* Output : Euclidean d istance between the two input objects */ /********************************************************************/ float computeDistanceBetween2(irisData a,irisData b) { float temp=0; int i=0; for(i=0;i<features;i++) temp+=(a[i]-b[i])*(a[i]-b[i]); temp=sqrt(temp); return(temp); } /********************************************************************/ /* Function to find the maximum distance between the input objects*/ /* Output: the maximum distance */ /* Input : The array of distances between objects */ /********************************************************************/ /*float findMax(float *distance) { int i=0,j=0; float max=distance[0]; for(i=0;i<count;i++) for(j=0;j<count;j++) { if(max<distance[i*count+j]) max=distance[i*count+j]; } return(max); }*/ /********************************************************************/ /* Function to compute the value of an object */ /********************************************************************/ float value(irisData a) { int i=0; float temp=0; for(i=0;i<features;i++) temp+=a[i]*a[i]; return(sqrt(temp)); } /********************************************************************/ /* Function to find the object in the data structure */ /* Output : The position of the object in the data */ /* Input : The object */ /********************************************************************/ int findInData(irisData object,int iFlag) { int i=0,lastCount=0,j,position=-1,flag[features],flg;if(iFlag==1)lastCount=MAXDATA;else{}for(i=0;i<lastCount;i++){ for(j=0;j<features;j++) if(fabs(object[j]-data[i][j])<0.00001) flag[j]=1; else { flag[j]=0; break;} flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /* Function to find whether there is an object on the board at a,b */ /* Output : a flag indicating whether an object is found or not */ /* Input : The row and column indicating the board position */ /********************************************************************/ int found(int a , int b) { if(board[a][b]==9) return 1; else return 0; } /********************************************************************/ /* Function to initialize the initial board */ /* Output : None */ /* Global Structures modified : heaps */ /* Input : Flag indicating the iteration 1: First 0: Second */ /********************************************************************/ void initialise(int flag) { int a,b,i=0,k=0; int loopCount,rowCount,colCount; /* Initialize the row, column and number of heaps */ if(flag==1) { loopCount=count; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=lCount; rowCount=heapRow; colCount=heapRow; } /* Initialize the heaps */ for(i=0;i<loopCount;i++) { heaps[i].count=0; heaps[i].x=0; heaps[i].y=0; heaps[i].disPosition=0; heaps[i].Dmax=0; heaps[i].Dmean=0; } for(i=0;i<loopCount;i++) { /*find a board position which is empty*/ do { a=lrand48()%rowCount; b=lrand48()%colCount; } while(found(a,b)); /*Allocate the object to that place and assign a heap to it*/ heaps[i].x=a; heaps[i].y=b; heaps[i].count=1; heaps[i].Dmax=0; heaps[i].Dmean=0; if(flag==1) { heaps[i].objects[0]=i; for(k=0;k<features;k++)heaps[i].Ocenter[k]=data[i][k]; } else { for(k=0;k<features;k++) heaps[i].Ocenter[k]=newHeaps[i].Ocenter[k]; } heaps[i].disPosition=0; board[a][b]=9; if((debugLevel>0)&&(flag==1))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],data[heaps[i].objects[0]][0]); if((debugLevel>0)&&(flag==0))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],newHeaps[i].Ocenter[0]); } /*initialise the initial heap count*/ heapCount=loopCount; currentRow=rowCount; } /********************************************************************/ /* Function to find whether an heap is present at the location a b */ /* Output : Flag indicating the presencs of the heap */ /* Input : Roe and column indicating the board position */ /********************************************************************/ int findObject(int a,int b) { int i; int position=-1; for(i=0;i<heapCount;i++) { if((heaps[i].x==a)&&(heaps[i].y==b)) { position=i; break; } } return(position); } /********************************************************************/ /* Function initialize the ants */ /* Output : None */ /* Input : Flag indicating the iteration */ /* Global Variables Modified : ant, heapCount, heaps, board */ /********************************************************************/ void initialiseAnts(int flag) { int i=0,a=0,b=0,position,j=0,loopCount=0,rowCount,colCount,k=0; if(flag==1) { loopCount=MAXANTS; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=MAXANTSFORHEAPS; rowCount=heapRow; colCount=heapRow; } for(i=0;i<loopCount;i++) { /*generate random positions for the ants*/ a=lrand48()%rowCount; b=lrand48()%colCount; ants[i].x=a; ants[i].y=b; /*Find if an object is present at that position or not*/ if(board[a][b]==9) { ants[i].carrying=1; /*find the heap at that location*/ position=findObject(a,b); if(position==-1) { printf("\n Error in logic: Ant init \n"); //getchar(); break; } else { /*Assign the heap data to the ant data and decrement the heap count*/ if(flag==1){ for(k=0;k<features;k++)ants[i].data[k]=data[heaps[position].objects[0]][k]; }else{for(k=0;k<features;k++)ants[i].data[k]=heaps[position].Ocenter[k];} for(j=position;j<heapCount-1;j++) heaps[j]=heaps[j+1]; heapCount--; } /*Clear the board position */ board[a][b]=-9; } else ants[i].carrying=-1; ants[i].speed=0; ants[i].dir=lrand48()%8; printf("\n Ant %2d X: %2d Y: %2d Carying : %2d ",i,ants[i].x,ants[i].y,ants[i].carrying); } currentAntCount=loopCount; } /********************************************************************/ /* Function to move the ant */ /* Output: None */ /* Input: Ant to be moved and the flag indicating the iteration */ /********************************************************************/ void moveNext(ant* a,int flag) { int rowCount,colCount; /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; } else { rowCount=heapRow; colCount=heapRow; }*/rowCount=currentRow;colCount=currentRow; /*Depending upon the direction move the ant*/ switch (a->dir) { case 0: a->y++; if(a->y>=colCount)a->y=0; break; case 1: a->x--; a->y++;; if(a->x<0)a->x=rowCount-1; if(a->y>=colCount)a->y=0; break; case 2: a->x--; if(a->x<0)a->x=rowCount-1; break; case 3: a->x--; a->y--; if(a->x<0)a->x=rowCount-1; if(a->y<0)a->y=colCount-1; break; case 4: a->y--; if(a->y<0)a->y=colCount-1; break; case 5: a->x++; a->y--; if(a->x>=rowCount)a->x=0; if(a->y<0)a->y=colCount-1; break; case 6: a->x++; if(a->x>=rowCount) a->x=0; break; case 7: a->x++; a->y++; if(a->x>=rowCount)a->x=0; if(a->y>=colCount)a->y=0; break; } }//end of function /********************************************************************/ /* Function to compute the parameters of the heap */ /* Output: None */ /* Input: The heap whose parameters are to be computed iteration flag*/ /********************************************************************/ void computeHeapParameters(heap* heapData,int flag) { int i=0,j=0,k=0,position=0; float distance=0; float Dmean=0.0; float *dis; float featureSum[features]; float max=0; float sum=0; /* init*/ for(k=0;k<features;k++) featureSum[k]=0; /*Compute the distance of each object and find the maximum distance*/ max=0; if(flag==1){ for(j=0;j<heapData->count;j++) for(i=0;i<heapData->count;i++) { for(k=0;k<features;k++) sum+= (data[heapData->objects[j]][k]-data[heapData->objects[i]][k])*(data[heapData->objects[j]][k]-data[heapData->objects[i]][k]); distance=sqrt(sum); if(max<distance) max=distance; sum=0; } /* Assign the maximum distance to the heap */ heapData->Dmax=max;/*Compute the centre object*/for(i=0;i<heapData->count;i++)for(k=0;k<features;k++) featureSum[k]+=data[heapData->objects[i]][k];for(k=0;k<features;k++)heapData->Ocenter[k]=featureSum[k]*1.0/heapData->count; /* Find the mean distance */if((dis=(float *) calloc(heapData->count,sizeof(float)))==NULL){printf("\nUnable to allocate memory in the compute heap parameters procedure\n");exit(0);} for(i=0;i<heapData->count;i++) { Dmean+=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); dis[i]=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); } heapData->Dmean=Dmean*1.0/heapData->count; /*Compute the most dissimilar object*/ max=dis[0]; for(i=1;i<heapData->count;i++) if(max<dis[i]) { max=dis[i]; position=i; } /*Assign the most dissimilar object to the heap variable*/ for(k=0;k<features;k++) heapData->Odissim[k]=data[heapData->objects[position]][k]; heapData->disPosition=position;free(dis); } else{/* Heap Parameters for the second stage */for(k=0;k<features;k++){ heapData->Odissim[k]=heapData->Ocenter[k];}heapData->disPosition=0;heapData->Dmean=0;heapData->Dmax=0;} }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a single object*/ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject1(ant *a,int position,int flag) { int i,k=0; /*Clear the board*/ board[heaps[position].x][heaps[position].y]=-9; /* Assign the data to the ant*/if(flag==1){ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[0]][k];}else {for(k=0;k<features;k++) a->data[k]=heaps[position].Ocenter[k];} a->carrying=1; /*Copy all the heaps remaining heaps in the structure*/ for(i=position;i<heapCount-1;i++) heaps[i]=heaps[i+1]; /*Decrement the heap count*/ heapCount--; }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a two objects */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject2(ant *a , int position,int flag) { float Pdestroy1=-1; int i=0,k=0; /*Compute the probability to destroy the heap*/ Pdestroy1=lrand48()%13*1.0/12.0; /*If the probability is more than Pdestroy then destroy the heap */ if(Pdestroy1<Pdestroy) { /*pick the object randomly*/ i=lrand48()%2; /* Assign the data to the ant */ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[i]][k]; a->carrying=1; /*Correct the heap parameters*/ heaps[position].count=1; heaps[position].objects[0]=heaps[position].objects[1-i]; computeHeapParameters(&heaps[position],flag); } }//end of function /********************************************************************/ /*Function to pick a object from a heap consisting of more than two object */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /********************************************************************/ void pickObjectn(ant *a,int position,int flag) { int i=0,k=0; /*If the criteria is satsfied then pick the object*/ if((computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)*1.0/heaps[position].Dmean)>Tremove) { a->carrying=1; for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[heaps[position].disPosition]][k]; for(i=heaps[position].disPosition;i<heaps[position].count-1;i++) heaps[position].objects[i]=heaps[position].objects[i+1]; heaps[position].count--; computeHeapParameters(&heaps[position],1); } }//end of function /********************************************************************/ /* Function to pick a object */ /********************************************************************/ void pick(ant *a,int flag) { int position=-1,i=0; float Pload1=-1.0; for(i=0;i<heapCount;i++) { /*Check if a heap is present in the eight neighbouring cells*/ if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if Heap is found*/ if(position!=-1) { /* heap or object found.*/ /*Depending upon the number present in the heap call the corresponding routine*/ switch(heaps[i].count) { case 1: Pload1 = lrand48()%151*1.0/150.0; if(Pload1<Pload) { pickObject1(a,position,flag); } break; case 2: pickObject2(a,position,flag); break; default: pickObjectn(a,position,flag); break; } } } /********************************************************************/ /* Function to drop a object to form a new heap */ /* Output: None */ /* Input: Ant, iteration flag */ /* Global Structure modified : heap, heapCount */ /********************************************************************/ void dropObject(ant* a,int flag) { /*Create a new heap*/ int k=0; heaps[heapCount].count=1; heaps[heapCount].x=a->x; heaps[heapCount].y=a->y; heaps[heapCount].Dmax=0; heaps[heapCount].Dmean=0; heaps[heapCount].disPosition=0; for(k=0;k<features;k++) { heaps[heapCount].Odissim[k]=a->data[k]; heaps[heapCount].Ocenter[k]=a->data[k]; } if(flag==1) {heaps[heapCount].objects[0]=findInData(a->data,flag); /*computeHeapParameters(&heaps[heapCount],flag);*/ } computeHeapParameters(&heaps[heapCount],flag); heapCount++; a->carrying=-1; board[a->x][a->y]=9; }//end of function /********************************************************************/ /* Function to find the heap position during the second iteration */ /* Output: position of the heap */ /* Input: object center of the heap that the ant is carrying */ /* Global Structure modified : none */ /********************************************************************/ int findInNewheaps(irisData object) { int position=-1,i,j=0,flag[features],flg; for(i=0;i<newHeapCount;i++) { for(j=0;j<features;j++) { if(fabs(object[j]-newHeaps[i].Ocenter[j])<0.00001) flag[j]=1; else {flag[j]=0;break;} } flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /*Function to drop a object to a heap consisting of a one or more object */ /* Output: none */ /* Input: Ant, position of the heap , iteration flag */ /* Global Structure modified: heaps,newHeaps */ /********************************************************************/ void dropObject1(ant* a, int position,int flag) { int heapPosition=-1,heapPosition1=-1,i,j,k=0; irisData newData,temp; if(flag==1) { /*Add the object to the heap and compute the heap parameters*/ /*if(heaps[position].count==heaps[position].objCount) {if((junk=(int *)realloc(heaps[position].objects,((heaps[position].objCount+OBJINC)*sizeof(int))))==NULL){printf("\n Cannot Allocate memory to the new object for %d heap",position);exit(0);}heaps[position].objects=junk;heaps[position].objCount+=OBJINC;free(junk); }*/ heaps[position].objects[heaps[position].count]=findInData(a->data,flag); heaps[position].count++; computeHeapParameters(&heaps[position],flag); } else { for(k=0;k<features;k++)temp[k]=heaps[position].Ocenter[k]; heapPosition=findInNewheaps(a->data); heapPosition1=findInNewheaps(heaps[position].Ocenter); if(heapPosition==-1||heapPosition1==-1) { printf("\n error in logic:new heaps\n"); //getchar(); return; } for(k=0;k<features;k++) {newData[k]=(newHeaps[heapPosition].Ocenter[k]*newHeaps[heapPosition].count+newHeaps[heapPosition1].Ocenter[k]*newHeaps[heapPosition1].count)*1.0/(newHeaps[heapPosition].count+newHeaps[heapPosition1].count);newHeaps[heapPosition].Ocenter[k]=newData[k];heaps[position].Ocenter[k]=newData[k]; } computeHeapParameters(&heaps[position],flag); for(i=newHeaps[heapPosition].count,j=0;j<newHeaps[heapPosition1].count;i++,j++) { newHeaps[heapPosition].objects[i]=newHeaps[heapPosition1].objects[j]; } newHeaps[heapPosition].count+=newHeaps[heapPosition1].count; for(i=heapPosition1;i<newHeapCount-1;i++) newHeaps[i]=newHeaps[i+1]; newHeapCount--; } a->carrying=-1; }//end of function /********************************************************************/ /* Function to drop a object */ /* Output: None */ /* Input: Ant, iteration flag */ /********************************************************************/ void drop(ant* a,int flag) { int i, position=-1; float Pdrop1=0.0; /*Find whether we have a heap in the neighbourhood of the cell*/ for(i=0;i<heapCount;i++) { if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if a heap is found*/ if(position!=-1) { /*heap or object found.*/ /*Depending on the number of objects present take action*/ switch(heaps[position].count) { /*If criteria is satisfied then drop the object*/ case 1: if(flag==1) { if((computeDistanceBetween2(a->data,data[heaps[position].objects[0]])*1.0/Dmax)<Tcreate) dropObject1(a,position,flag); } else { if((computeDistanceBetween2(a->data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) dropObject1(a,position,flag); } break; default: if(computeDistanceBetween2(a->data,heaps[position].Ocenter)<computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)) dropObject1(a,position,flag); break; } } else { /*Compute the probability to drop the object*/ Pdrop1 = lrand48()%151*1.0/150; if(Pdrop1<Pdrop) dropObject(a,flag); } }//end of function /********************************************************************/ /* Function to move the ant */ /* Output: none */ /* Input: Ant, iteration flag */ /********************************************************************/ void move(ant* a,int flag) { float pDir; /*Check the speed */ if (a->speed!=0) { /*move in the same direction*/ a->speed--; moveNext(a,flag); } else { /*generate the new direction*/ pDir=lrand48()%17*1.0/16.0; if(pDir<.85) { a->dir=lrand48()%8; } else if(pDir>.95) { a->speed=2; } moveNext(a,flag); } } /********************************************************************/ /* Function to simulate the movement of the ants */ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified: minHeapCount, minHeapPosition */ /********************************************************************/ void iterate(int flag) { int i=0,j=0,k=0,loopCount=0; if (flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS; while (i<MAXITERATIONS) { i++; for(j=0;j<loopCount;j++) { move(&ants[j],flag); if(ants[j].carrying==1) { drop(&ants[j],flag); } else { pick(&ants[j],flag); } } if(debugLevel>0){ for(k=0;k<heapCount;k++) for(j=0;j<heapCount;j++) if((k!=j)&&(heaps[k].x==heaps[j].x)&&(heaps[k].y==heaps[j].y)) { printf("\nerror two heaps with same co ordinates %d %d ",k,j); //getchar(); } k=0; for(j=0;j<heapCount;j++) k+=heaps[j].count; } if(heapCount<minHeapCount) { minHeapCount=heapCount; minPosition=i; } if(debugLevel>0) printf("\n i:%d Heap count %d sum %d",i,heapCount,k); else printf("\n i:%d Heap count %d",i,heapCount); heapSum+=heapCount; /*if(i%updateAfter==0) {adjustBoard(flag); writeIncremental(i,flag);heapSum=0;loopCount=currentAntCount; }*/ } }//end of function /********************************************************************/ /*Function to drop the objects carried by the ants after all the iterations*/ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified:none */ /********************************************************************/ void dropFinal(int flag) { int i=0,j=0,position=-1,loopCount=0; /*if(flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS;*/ loopCount=currentAntCount; for(i=0;i<loopCount;i++) { if(ants[i].carrying==1) { if(flag==1) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position,flag); } } else { /*Find if a heap is present */ do { position=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position,flag); position=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position!=-1); } } } }//end of function /********************************************************************/ /* Function for the implementation of QuickSort */ /* Output: none */ /* Input: data structure, low and high indices */ /* Global structure modified:none */ /********************************************************************/ void quickSort( heap A[], int low,int high ) { int mid=0; if(low<high) { mid=partition(A,low,high); quickSort(A,low,mid); quickSort(A,mid+1,high); } } /********************************************************************/ /* Partition routine used by quick sort */ /* Output: partition location */ /* Input: data , low, high */ /* Global structure modified:none */ /********************************************************************/ int partition(heap a[], int low,int high) { heap temp; int x=0,i=0,j=0; i=low; j=high; x=a[low].count; while (1) { while (a[j].count<x) j=j-1; while (a[i].count>x) i=i+1; if(i<j) { temp=a[i]; a[i]=a[j]; a[j--]=temp; } else return(j); } } /********************************************************************/ /* Function used to write the cluster information */ /* Output: none */ /* Input:iteration flag */ /* Global structure modified:none */ /********************************************************************/ void writeClusterInformation(int flag) { FILE *fp=fopen("center.clt","w"); FILE *fp1; FILE *fp2; FILE *fp3; char temp[80]; int i=0,j=0,k=0; int lastCount=0; int rowCount,colCount,antCount; strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp3=fopen(temp,"a"); if(dataDump) {strcpy(temp,"");sprintf(temp,"%sTot.out",filename);fp1=fopen(temp,"a");strcpy(temp,"");sprintf(temp,"%sObj.out",filename);fp2=fopen(temp,"a");if(fp1==NULL||fp2==NULL)printf("\n Error in opening file in the writer Cluster Information routine\n"); } /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; antCount=MAXANTS; } else { rowCount=heapRow; colCount=heapRow; antCount=MAXANTSFORHEAPS; }*/ rowCount=currentRow; colCount=currentRow; antCount=currentAntCount; if(fp==NULL) { printf("\n Unable to open cluster center output file \n"); /*return;*/ exit(0); } /*sort the array according to the count value and write the value of the top three elements*/ if((flag==1)&&(!EntireHeaps)) quickSort(heaps,0,heapCount); if(EntireHeaps) {if(flag==1) lastCount=heapCount;else lastCount=newHeapCount; } else lastCount=c; for(i=0;i<lastCount;i++) { if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",newHeaps[i].Ocenter[k]); fprintf(fp,"\n"); } else { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); fprintf(fp,"\n"); } } if(dataDump) { fprintf(fp1,"\n Information from the Ant Based Algorithm \n"); fprintf(fp1,"\n Important Parameters : Board %d X %d Ants : %d Iterations %d Total Heaps %d ",rowCount,colCount,antCount,MAXITERATIONS,lastCount); } if(flag==0) { if(dataDump) { fprintf(fp1," TCreateForHeaps %f \n",TcreateForHeaps); fprintf(fp2,"\nTotal Heaps : %d\n",heapCount); fprintf(fp2,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); } fprintf(fp3,"\n@ %d\n",lastCount); } else if(dataDump) fprintf(fp1,"\n");if(dataDump) { fprintf(fp1,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); for(i=0;i<lastCount;i++) if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp2,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); } fprintf(fp1," %5d\n",newHeaps[i].count); fprintf(fp2," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp1," %5d\n",heaps[i].count); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]); fprintf(fp1," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]); fprintf(fp1," %5d\n",heaps[i].count); }} if(flag==0) { if(dataDump) fprintf(fp1,"\n Objects in the heaps \n");for(i=0;i<newHeapCount;i++) { if(dataDump) fprintf(fp1,"\n\n Heap %d\n \n",i+1);fprintf(fp3,"# %d %d\n",i ,newHeaps[i].count); for(j=0;j<newHeaps[i].count;j++){ for(k=0;k<features;k++){ fprintf(fp3,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]); if(dataDump) fprintf(fp1,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]);} if(dataDump) fprintf(fp1,"\n"); fprintf(fp3,"\n"); } } } fclose(fp); fclose(fp3); if(dataDump) { fclose(fp1);fclose(fp2); }}//end of flie /********************************************************************/ /* Function to initialise the new heaps */ /* Output: none */ /* Input:new Heap structure */ /* Global structure modified:none */ /********************************************************************/ void initialiseNewHeaps(heap newHeaps[]) { int i=0,j=0; for(i=0;i<lCount;i++) { newHeaps[i].count=0; for(j=0;j<features;j++) newHeaps[i].Ocenter[j]=V[i][j]; newHeaps[i].x=heaps[i].x; newHeaps[i].y=heaps[i].y; } }//end of function /********************************************************************/ /* Function to initialise the new heaps */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ int findPosition(int i) { int j,position=0; for(j=1;j<lCount;j++) { if(U[j][i]>U[position][i]) position=j; } printf("\n Position %d ",position); return(position); }//end of function find position /********************************************************************/ /* Function to add object */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ void addObject(int object,heap * heapPosition) { heapPosition->objects[heapPosition->count]=object; heapPosition->count++; }//end of function add object /********************************************************************/ /* Function to harden the outputs obtained from fcm */ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/ void harden(heap newHeaps[]) { int i,heapPosition=-1,sum=0,j=0; /*initialise the new heaps*/ initialiseNewHeaps(newHeaps); for(i=0;i<count;i++) { heapPosition=findPosition(i); addObject(i,&newHeaps[heapPosition]); } /* To check for degenerate partitions*/ for(i=0;i<lCount;i++) { if(newHeaps[i].count==0){for(j=i;j<lCount-1;j++){newHeaps[j]=newHeaps[j+1];}lCount--;i--;} } newHeapCount=lCount; for(i=0;i<lCount;i++) computeHeapParameters(&newHeaps[i],1); if(debugLevel>0) { for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\n sum = %d",sum);} }//end of function/********************************************************************/ /* Function to initialize the initial parameters for the ant algorithm*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void init() { int i=0,j=0; for(i=0;i<MAXROWS;i++) for(j=0;j<MAXCOLS;j++) board[i][j]=-9; heapCount=0; newHeapCount=0; heapRow=0; minPosition=-1; minHeapCount=100000; for(i=0;i<MAXANTS;i++) { ants[i].carrying=-1; ants[i].x=-1; ants[i].y=-1; ants[i].speed=-1; ants[i].dir=-1; } } /********************************************************************/ /* Function to initialize the initial board */ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void initialiseBoard() { int i,j; for(i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; }/********************************************************************/ /* Function to harden the outputs obtained from fcm(2nd stage)*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: Cluster center , cluster center count*/ /********************************************************************/void harden1() { int i=0,heapPosition=-1; for(i=0;i<heapCount;i++) cenCount[i]=0; for(i=0;i<n;i++) { heapPosition=findPosition1(i); addObject1(i,heapPosition); } writeInfo(); }//end of function/********************************************************************/ /* Function to find to which class the object belongs */ /* Output: Class number */ /* Input: object position */ /* Global Structure Modified: None */ /********************************************************************/int findPosition1(int i) { int j,position=0; for(j=1;j<heapCount;j++) { if(U[j][i]>U[position][i]) position=j; } return(position); }//end of function find position/********************************************************************/ /* Function to Write the output of the hardened objects to file*/ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/void writeInfo(){int i=0,j=0,k=0;FILE *fp=fopen("fcm.out","a");if(fp==NULL){printf("\n Unable to open fcm output file \n");return;}fprintf(fp,"\n@ %d\n",heapCount);for(i=0;i<heapCount;i++){fprintf(fp,"# %d %d\n",i,cenCount[i]);for(j=0;j<cenCount[i];j++){for(k=0;k<s;k++)fprintf(fp,"%8.2f ",clsCen[i][j][k]/scale[k]+minInput[k]);fprintf(fp,"\n");}}fclose(fp);return;}/********************************************************************/ /* Function to add a object to a cluster (2nd stage) */ /* Output: none */ /* Input: object poistion , cluster position */ /* Global Structure Modified: Cluster object and cluster count*/ /*******************************************************************/void addObject1(int object,int heapPosition) { int k=0; for(k=0;k<features;k++) clsCen[heapPosition][cenCount[heapPosition]][k]=X[object][k]; cenCount[heapPosition]++; return; }//end of function add object/********************************************************************/ /* Function to read the original classification of objects */ /* Output: none */ /* Input: none */ /* Global Structure Modified: None */ /*******************************************************************/void readOrg(){int i=0,k=0;char temp[80];FILE *fp;//= fopen(dataname,"r");strcpy(temp,"");sprintf(temp,"%sFull.data",filename);fp=fopen(temp,"r");if(fp==NULL){printf("\n Unable to open full data input file ");exit(0);}for(i=0;i<n;i++){fscanf(fp,"%f ",&orgData[i][0]);for(k=1;k<s+1;k++)fscanf(fp,"%f ",&orgData[i][k]);}return;}// end of function/********************************************************************/ /* Function to classify the objects in different clusters */ /* Output: none */ /* Input: the cluster objects, the original classification, */ /* number of objects in the cluster,file to write the data */ /* Global Structure Modified: None *//********************************************************************/int analysisData(float data[][s],float orgData[n][s+1],int count,FILE * fp){int i=0,j=0,k=0,type=1,max=0;heapInfo info;for(i=0;i<c;i++){info.classObj[i]=0;}info.total=0;info.total=count;for(i=0;i<count;i++)for(j=0;j<n;j++){type=1;for(k=0;k<s;k++)if(fabs(data[i][k]-orgData[j][k+1])>errThresh){type=-1;break;}if(type!=-1){info.classObj[(int)orgData[j][0]-1]++;break;}}max=0;for(k=0;k<c;k++){if(info.classObj[k]>info.classObj[max])max=k;fprintf(fp,"\nClass %d Objects % d ",k+1,info.classObj[k]);}j=0;for(k=0;k<c;k++){if(k!=max)j+=info.classObj[k];}fprintf(fp,"\n Total errors : %d \n",j);return(j);}//end of analyse/********************************************************************/ /* Function to read the cluster information */ /* Output: none */ /* Input: input file pointer , output file pointer */ /* Global Structure Modified: None *//********************************************************************/void readFCM(FILE* fp,FILE *fp1){int i=0,j=0,k=0,l=0;int totalRuns=0,heapCount=0,junk=0,sum=0;char ch;FILE *fp2=fopen("errors.out","a");ch = 'c'; while (ch != '$') fscanf (fp, "%c", &ch);fscanf(fp,"%d\n",&totalRuns);printf("\n total runs %d ",totalRuns);for(l=0;l<totalRuns;l++){fscanf(fp,"%c",&ch);fscanf(fp,"%d\n",&heapCount);fprintf(fp1,"\n \nExperiment %d \n ",l+1);sum=0;for(i=0;i<heapCount;i++){fscanf(fp,"%c",&ch);fscanf(fp," %d %d\n",&junk,&clsCenCount[i]);for(j=0;j<clsCenCount[i];j++)for(k=0;k<s;k++)fscanf(fp,"%f",&fcmData[i][j][k]);fscanf(fp,"\n");fprintf(fp1,"\n\n Heap %d Total Objects %d \n",i+1,clsCenCount[i]);sum+=analysisData(fcmData[i],orgData,clsCenCount[i],fp1);}fprintf(fp2," %3d %3d %3d \n",l,sum,heapCount);}fprintf(fp2,"\n --------------------------\n");fclose(fp2);return;}//end of function/********************************************************************/ /* Function to update the board parameters */ /* Output: none */ /* Input: none */ /* Global Structure Modified: board size, ant count *//********************************************************************/void adjustBoard(int flag){int newRow=0,newAnt=0,antDiff=0,antsKilled=0,i=0,position[MAXANTS],position1=-1,j=0,k=0,a,b; newRow= (int)ceil(sqrt(4.0*heapSum/updateAfter)); newAnt= (int)ceil((heapSum*1.0/updateAfter)*1.0/3.0); if(newAnt<minAnts)newAnt=minAnts; if(newRow<rowMin)newRow=rowMin;antDiff=currentAntCount-newAnt; if((antDiff>0)&&(newAnt>=minAnts)) {for(i=0;i<currentAntCount;i++){if(ants[i].carrying==-1){position[antsKilled++]=i;}} if(antsKilled>=antDiff){for(i=0;i<antDiff;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1];for(k=i+1;k<antsKilled;k++)position[k]--; } currentAntCount=newAnt; }else {for(i=0;i<antsKilled;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1]; for(k=i+1;k<antsKilled;k++)position[k]--; }if(flag==1) { for(i=currentAntCount-1,k=0;k<antDiff-antsKilled;k++,i--) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position1,flag); }else { dropObject(&ants[i],flag); } } } else { //flag is zero 2nd stage /*Find if a heap is present */ do { position1=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position1].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position1,flag); position1=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position1!=-1); }//end else currentAntCount=newAnt;}//end elsecurrentAntCount=newAnt;}//end iffor(i=0;i<newAnt;i++){if((ants[i].x>=newRow)||(ants[i].y>=newRow)) { a=lrand48()%newRow; b=lrand48()%newRow; ants[i].x=a; ants[i].y=b; }} //Done with ants, now adjust the boardif((currentRow>newRow)&&(newRow>=rowMin)){for(i=0;i<heapCount;i++){if((heaps[i].x>=newRow)||(heaps[i].y>=newRow)) {do { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionheaps[i].x=a;heaps[i].y=b;board[a][b]=9;}//end if}//end for for(i=0;i<currentAntCount;i++){if((ants[i].carrying==1)&&((ants[i].x>=newRow)||(ants[i].y>=newRow))){//adjust the ant locationdo { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionants[i].x=a;ants[i].y=b;}//end if}//end for currentRow=newRow;}//end if }//end of function void writeIncremental(int iteration,int flag){FILE *fp=fopen("dump.txt","w");int i=0,j=0,k=0;fprintf(fp,"Stage %d\n",flag);fprintf(fp,"Board %d\n",currentRow);fprintf(fp,"Ants %d\n",currentAntCount);fprintf(fp,"Iteration %d\n",iteration);fprintf(fp,"Heaps %d\n",heapCount); if(flag==0)fprintf(fp,"NewHeapCount %d\n",newHeapCount); fprintf(fp,"Ants\n");for(i=0;i<currentAntCount;i++){fprintf(fp,"%d %d %d %d %d ",ants[i].x,ants[i].y,ants[i].carrying,ants[i].speed,ants[i].dir);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",ants[i].data[k]);fprintf(fp,"\n");}fprintf(fp,"Heaps\n");for(i=0;i<heapCount;i++){fprintf(fp,"%d %d %d %d %8.2f %8.2f \n",heaps[i].x,heaps[i].y,heaps[i].count,heaps[i].disPosition,heaps[i].Dmax,heaps[i].Dmean);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Ocenter[k]);fprintf(fp,"\n");for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Odissim[k]);fprintf(fp,"\n");if(flag==1){for(j=0;j<heaps[i].count;j++)fprintf(fp,"%d ",heaps[i].objects[j]);fprintf(fp,"\n");}}if(flag==0){fprintf(fp,"newHeaps\n");for(i=0;i<newHeapCount;i++){fprintf(fp,"%d\n",newHeaps[i].count);for(j=0;j<newHeaps[i].count;j++)fprintf(fp,"%d ",newHeaps[i].objects[j]);fprintf(fp,"\n");}}fclose(fp);}//end of function/********************************************************************/ /* Function Main */ /********************************************************************/ int main(int argc ,char** argv) { int sum=0,k=0,i=0,j=0; char temp[80]; FILE *fp=fopen("fcm.out","w"); FILE *fp1; FILE *fp2=fopen("antAnalysis.out","a"); FILE *fp3=fopen("fcmAnalysis.out","a"); FILE *fp4=fopen("errors.out","w"); FILE *fp5; fclose(fp4); sprintf(temp,"%sObj.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sTot.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp1=fopen(temp,"w"); fprintf(fp,"\n$%d",EXPRUN); fprintf(fp1,"\n$%d",EXPRUN); fclose(fp); fclose(fp1); if(argc==2)sscanf(argv[1],"%d",&debugLevel); printf("\n Debug level %d\n",debugLevel); for( i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; //Read from the file readInput(); //Compute the distance of all the points if(maxDist) { Dmax=computeDistance(); //Compute the maximum distance fp5=fopen("maxData.txt","w");fprintf(fp5,"%f",Dmax);fclose(fp5); } else {fp5=fopen("maxData.txt","r");fscanf(fp5,"%f",&Dmax);fclose(fp5); } printf("\n %f \n",Dmax); //Initialise the board for(k=0;k<EXPRUN;k++) { init(); sum=0; srand48(state1[k]); initialiseBoard(); initialise(1); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(1); printf("\n %d \n",heapCount); //Simulate the working of ants iterate(1); //drop the objects after all the iterations dropFinal(1); //to verify the correctness for(i=0;i<heapCount;i++) sum+=heaps[i].count; //write the cluster centers to the file writeClusterInformation(1); printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); //getchar(); //Run FCM // heapCount=2973;/* To be commented */ printf("\n\n k %d \n\n",k); Fcm(data); //compute new board size. lCount=heapCount; heapRow=(int)ceil(sqrt(4*heapCount)); newHeapCount=lCount; printf("\n LCount %d newHeapCount %d heap Row %d \n",lCount,newHeapCount,heapRow); //harden the objects harden(newHeaps); //iterate with the heaps as the objects. initialiseBoard(); initialise(0); for(i=0;i<lCount;i++) computeHeapParameters(&heaps[i],0); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(0); printf("\n %d \n",heapCount); //getchar(); //Simulate the working of ants iterate(0); dropFinal(0); writeClusterInformation(0); sum=0; for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); // getchar(); Fcm(data); harden1(); } fp=fopen("fcm.out","a"); fp1=fopen(temp,"a"); fprintf(fp,"\n"); fprintf(fp1,"\n"); fclose(fp); fclose(fp1); fp=fopen("fcm.out","r"); fp1=fopen(temp,"r");printf("\n Before read org\n");readOrg();printf("\nafter read org\n");readFCM(fp1,fp2);printf("\n After 1st read fcm\n");readFCM(fp,fp3);printf("\n After 2 fcm read \n");return(1); }//end of main /****************************************************************/ float NORM(feature , feature); void find_covar(); void Fcm (irisData Data[MAXDATA]) { int i,j,l; FILE *ofile; char temp[80]; int flag=0;//added by parag FILE *iniClsCen=fopen("center.clt","a+"); if(iniClsCen==NULL) { printf("\n Unable to open the initial cluster center file\n"); printf("\n choosing random cluster centers....\n"); flag=1; } strcpy(temp,""); sprintf(temp,"%s.data",filename); strcpy (fname,temp); /* Read from this file */ m=2.0; /* The exponent */ /*GET_INPUTS1(fname);*/ /* read in feature vectors */ for (j=0; j<n ; j++) /* Read File in row-major */ for (i=0; i<s ; i++) /* format */ X[j][i]=Data[j][i]; Random_seed=state1[run];/*randseed*/ srand48(Random_seed); for (run=0;run<TOTRUNS;run++) { //flag=1;//for testing random values if (EntireHeaps) lCount=heapCount; else lCount=c; for(i=0;i<lCount;i++) for(j=0;j<s;j++) V[i][j]=0; for(i=0;i<lCount;i++) { for(l=0;l<s;l++) { if(flag==1) { rand_index = lrand48() % n; V[i][l] = X[rand_index][l]; } else { fscanf(iniClsCen,"%f ",&V[i][l]); } }//end for } eps=0.001; stop = FALSE; /* This loop finds the final cluster center and the corresponding U values */ z = 0; while (stop == FALSE) { z++; UMAT(U,V,X); /** Update the U matrix **/ stop = FINISHED(U1,eps); CLUSTER(U,X); /** Get new cluster center **/ printf("Iteration: %d\n\n", z); } /* end while */ printf("Number of iterations: %d\n\n", z);strcpy(temp,""); sprintf(temp,"%sFCM.out",filename);if(dataDump) Output(temp); /* output the results */ }/*end for*/ if(dataDump) { ofile=fopen(temp,"a"); for (i=0; i <= mins; i++) fprintf(ofile, "Min %d of %10.3f occurred %d times\n", i, mintab[i], mincount[i]); fprintf(ofile, "Average iterations %f\n", (float)aveit/(float)TOTRUNS); fclose(ofile); } }/* end Main */ /* The GET_INPUTS1 procedure opens an input file, reads the number of input vectors, the number of features per vector, the number of clusters, and epsilon, then it reads the input values */ void GET_INPUTS1(char fname[]) //char fname[]; { /* Parameters: fname -- name of file containing input info. */ FILE *infile ;//*fopen(); //char junk[10][80]; char realfname[80]; char ch; char fileName1[80]; //int temp[10], i, j, inputs, outputs, count; int i,j; sprintf (realfname, "%s", fname); /* open input file */ if(normalize==1) strcpy(fileName1,"gtest1.data"); else strcpy(fileName1,fname); if((infile = fopen (fileName1, "r")) == NULL) printf("\n CAN'T OPEN %s\n",realfname); else { ch = 'c'; /* Discard leading comments */ while (ch != '#') fscanf (infile, "%c", &ch); for (j=0; j<n ; j++) /* Read File in row-major */ { /* format */ for (i=0; i<s ; i++) fscanf (infile, "%f", &X[j][i]); /* fscanf (infile, "%d", &temp[1]); */ /* end for */ } /* end for */ fclose(infile); /* close input file */ }/* end else */ } /* end GET_INPUTS1 */ /* The NORM function computes the norm of two vectors, x and v, of dimension s. This gives an indication of the distance between them */ float NORM( feature x, feature v) //feature x, v; { /* Parameters : x -- a local copy of an input vector v -- a local copy of a cluster center */ int i,j; /* loop variable */ double sum; /* the square root of sum is the norm; sum is the sum of the differences squared */ float mat1[s]; float mat2[s]; if (maha) { for (i=0; i<s; i++) mat1[i]=x[i]-v[i]; for(i=0;i<s;i++) { sum =0; for(j=0;j<s;j++) sum += mat1[j] * inv_cov[j][i]; mat2[i] = sum; } sum =0; for(j=0;j<s;j++) sum += mat1[j]*mat2[j]; } else { sum = 0; for(j=0;j<s;j++) sum += (x[j] - v[j])* (x[j] - v[j]); } return (float)(sqrt(sum)); } /* end NORM */ /* The UMAT procedure calculates the updated U matrix according to Bezdek's formula. Its side-effect is the update of the global array U1 */ void UMAT( matrix U,center V, objects X) /*matrix U; center V; objects X;*/ { /* Parameters: U, V, and X: same as in main program */ int i, j, k,l ;/* loop variables *///, class /* class whose cluster center //is closest to pattern k */; float d1,d2,d; float sum; int exact; for (k=0;k<n;k++) { /*printf("\n k %d ",k);*/ exact=false; for (i=0;i<lCount;i++) { sum=0; for (j=0;j<lCount;j++) { d1=NORM(X[k],V[i]); d2=NORM(X[k],V[j]); if(d2!=0) { d= d1/d2; d= d * d;/* pow(d1/d2,2.0/(m-1.0)); */ sum+=d; } else { exact = true; for(l=0;l<lCount;l++) if (l==j) U1[l][k]=1.0; else U1[l][k]=0.0; break; } } if (exact!=true) U1[i][k]=1.0/sum; } } } /* end UMAT */ /* The function FINISHED determines if a termination occurs. If not it updates U with U1, so its side-effect is the potential modification of U */ BOOLEAN FINISHED( matrix U1,float eps) //matrix U1; float eps; { /* Parameters: U1, eps-- same as in main */ float sum; /* sum of squared differences between corresponding elements of U and U1 */ int i,k; /* loop control variabes */ BOOLEAN finished; /* set to true if all corresponding elements are within epsilon */ finished = TRUE; sum = 0; for (i=0; i<lCount; i++) for (k=0; k<n; k++) sum += (U[i][k] - U1[i][k])*(U[i][k]-U1[i][k]); if (sqrt(sum) > eps) { finished = FALSE; for (i=0; i<lCount; i++) for (k=0; k<n; k++) U[i][k] = U1[i][k]; } /* end if */ return finished; } /* end FINISHED */ /* The CLUSTER procedure determines cluster centers in V for the c classes being searched for. The global array V is updated */ void CLUSTER( matrix U, objects X) //matrix U; objects X; { /* Parameters: U, X -- as in main */ int i, j, k; /* loop control variables */ feature num; /* numerator in the cluster center computation formula presented by Bezdek */ float denum; /* denumenator in the obove formula */ for (i=0; i<lCount; i++) { denum = 0; for (j=0; j<s; j++) { num[j] = 0; for (k=0; k<n; k++) num[j] += U[i][k] * U[i][k] * X[k][j]; /* pow(U[i][k],m) * X[k][j]; */ } /* end for */ for (k=0; k<n; k++) denum += U[i][k] * U[i][k]; /* pow(U[i][k],m); */ for (j=0; j<s; j++) V[i][j] = num[j] / denum; } /* end for */ } /* end CLUSTER */ float Compute_Jm(center V, objects X) //center V; //objects X; { int i, k,found; double Jm_value; float u,dik; Jm_value = 0; for (k=0; k<n; k++) { found = FALSE; for (i=0; i<lCount; i++) { dik=NORM(X[k],V[i]); dik=dik*dik; if (dik==0.0) { if (found == FALSE) { u=1.0; found = TRUE; printf("found the case with dik=0\n"); } else { printf("\n cant proceed with this initialization"); exit(1); } } else { if (found != TRUE) u=U1[i][k]; /* get_Uvalue(V,X,dik,k); */ else u=0.0; } Jm_value += u * u * dik;/* pow(u, m) * dik; */ } } return (Jm_value); } /* end Compute_Jm */ /* The Output procedure outputs the U matrix which gives the fuzzy measure of each feature belonging to a cluster center. It also outputs the cluster center for each class */ void Output(char fname[]) //char fname[80]; /* Parameters: U, V -- same as in main */ { int i, j, found; /* loop control variables */ float J2c; if ((fp=fopen(fname,"a"))==NULL) printf("\n CAN'T OPEN %s\n",fname); else { fprintf(fp,"\n The cluster centers are: \n"); fprintf(fp,"\n \n"); for (i=0; i<lCount; i++) { fprintf(fp,"\nCluster center %d: ",i+1); fprintf(fp,"\n"); for (j=0; j<s; j++) fprintf(fp,"%8.7f ",V[i][j]); } /* end for */ fprintf(fp,"\nThe membership grades for the feature vectors are:\n"); for (j=0; j<n; j++) { fprintf(fp,"\n"); for (i=0; i<lCount; i++) fprintf(fp," %8.7f",U[i][j]); } /* end for */ } /* end if */ J2c= Compute_Jm(V,X); found =0; for (i=0;i<= mins; i++){ if ((found == 0) && ((J2c - mintab[i]) < .001) && ((J2c - mintab[i]) > -.001)){ mincount[i]++; found = 1; } } if (found == 0){ mins++; mintab[mins]=J2c; mincount[mins]=1; } fprintf(fp,"\nJ%3.1f = %f", m,J2c); fprintf(fp, "Number of iterations: %d\n\n", z); aveit=aveit + z; fclose(fp); } /***************************************************************/ void find_covar(int m) //int m; { int i,j,k; float mean[s],sum; for (i=0;i<s;i++) mean[i]=0; for (i=0;i<s;i++) for (j=0;j<m;j++) mean[i]+=X[j][i]; for (i=0;i<s;i++) mean[i]/=m; for (i=0;i<s;i++) for (j=0;j<s;j++) { sum=0; for (k=0;k<m;k++) sum+=(X[k][i]-mean[i])*(X[k][j]-mean[j]); Y[i][j]=sum/m; } }
Parag Kanade/fuzzy ants/Gauss500-3/headerStatic.h
/********************************************************************//* Ant Class parameters *//* SPEED # amplitude of moves [1,10] *//* P direction Probability to move in the same direction [.5,1] *//* Max carry : Maximum object carrying time [20,200] *//* P load Probability to pick up a single object [0.4,0.8] *//* P destroy probability to destroy a heap of two objects [0,0.6] *//* T remove min. dissimilarity necessary for removing an object *//* from a heap [.1,.2] *//* T create max dissimilarity permitted for creating a heap[.05,.2]*//********************************************************************/ #include <stdio.h>#include <math.h>#include <string.h>#include<stdlib.h>#include <ctype.h>#include <time.h>#define MAXANTS 167#define MAXDATA 500#define MAXANTSFORHEAPS 45#define MAXITERATIONS 1000#define MAXROWS 45#define MAXCOLS 45#define EXPRUN 10#define Tremove 1.50#define Tcreate 0.5#define Pdrop 0.2#define Pdestroy 0.3#define Pload 0.3#define normalize 0#define EntireHeaps 1#define TcreateForHeaps 0.19#define features 2#define filename "gauss500_03"#define errThresh 0.1#define dataDump 1#define maxDist 1#define INITIALOBJECTS 75#define OBJINC 10/* some type definitions to make C code a little more readable */#define TRUE 1#define FALSE 0#define n MAXDATA /* number of input vectors */#define s features /* number of features */#define c 5 /* number of clusters */#define TOTRUNS 1 /* number of V's to write out */#define false 0#define true 1#define maha 0#define square 0extern int count;int debugLevel=0;/* To debug the code and verify the correctness of algorithms*/int currHeapCount=0;typedef int BOOLEAN;typedef short TYPE_IN_DATA; /* Type of input binary data */typedef float feature[s]; /* Type of each input; made up of input features */typedef float irisData[s];typedef feature objects[MAXDATA]; /* Type of array holding all inputs */typedef feature center[MAXDATA]; /* Type of array holding cluster centers */typedef float matrix[MAXDATA][MAXDATA];/* Type of the matrix containing membership grades */typedef struct Heap {float Dmax;//maximum dissimilar distanceirisData Ocenter;//center objectfloat Dmean;//mean of the distance between the center and all the objectsirisData Odissim;//most dissimilar objectint x;//x position on the boardint y;//y position on the boardint count;//number of objects in the heapsint disPosition;//most dissimilar objectint objects[MAXDATA];int objCount;}heap;typedef struct Ant{int x;int y;int carrying;int speed;int dir;irisData data;}ant;float orgData[n][s+1];float fcmData[MAXDATA][n][s];int clsCenCount[MAXDATA];int currentRow=0;int currentAntCount=0;int updateAfter=50;int heapSum=0;int minAnts=3;int rowMin=5;typedef struct HeapInfo{int total;int classObj[c];} heapInfo;/*heapInfo info[MAXDATA];*//********************************************************************//***Function decelarations*//********************************************************************//***For ant based algorithm*/void readInput();float computeDistance();float computeDistanceBetween2(irisData a,irisData b);float findMax(float *distance);float value(irisData a);int found(int a , int b);void initialise(int flag);int findObject(int a,int b);void initialiseAnts(int flag);void moveNext(ant* a,int flag);void computeHeapParameters(heap* data,int flag);void pickObject1(ant *a,int position,int flag);void pickObject2(ant *a , int position,int flag);void pickObjectn(ant *a,int position,int flag);void pick(ant *a,int flag);void dropObject(ant* a,int flag);int findInNewheaps(irisData object);void dropObject1(ant* a, int position,int flag);void drop(ant* a,int flag);void move(ant* a,int flag);void iterate(int flag);void dropFinal(int flag);int partition(heap a[], int low,int high);void quickSort( heap A[], int low,int high ) ;void writeClusterInformation(int flag);void initialiseNewHeaps(heap newHeaps[]);int findPosition(int i);void harden(heap newHeaps[]);void harden1();int findPosition1(int );void writeInfo();void addObject1(int ,int);void readFCM(FILE *,FILE *);void readOrg();int findInData(irisData input,int iflag);void adjustBoard(int flag);void writeIncremental(int iteration,int flag);/********************************************************************//***For FCM algorithm*/void GET_INPUTS1(char []);void UMAT( matrix,center,objects);BOOLEAN FINISHED(matrix, float);void CLUSTER( matrix, objects);void Output(char[]);void Fcm();/********************************************************************/
Parag Kanade/fuzzy ants/Gauss500-3/maxData.txt
1.490739
Parag Kanade/fuzzy ants/Gauss500-4/gauss500_04.data
gauss Data | |
# | |
1.2079091 | 5.7210589 |
1.2231833 | 6.624442 |
1.2724274 | 5.7211989 |
1.3905861 | 4.8528257 |
1.5263206 | 5.1902709 |
1.5446515 | 4.9092366 |
2.0817641 | 4.2932327 |
2.1329588 | 4.7909656 |
2.2061908 | 4.5587698 |
2.2294541 | 5.7094674 |
2.2311605 | 4.1842931 |
2.3729459 | 4.6146591 |
2.451783 | 6.0942238 |
2.4631214 | 3.9776029 |
2.4641181 | 5.9918609 |
2.5092126 | 5.2028537 |
2.5249635 | 3.8857945 |
2.5408484 | 5.0938419 |
2.5538585 | 6.1353191 |
2.580998 | 5.1703637 |
2.6221661 | 6.0532502 |
2.6675926 | 5.5078748 |
2.6693178 | 5.0258803 |
2.6757058 | 3.5386359 |
2.6875167 | 6.3955603 |
2.8136569 | 6.2550441 |
2.8330733 | 6.7522282 |
2.8388063 | 6.8021392 |
2.8394463 | 6.1968265 |
2.8564329 | 3.7743203 |
2.8694154 | 4.2415617 |
2.8838473 | 5.8844967 |
2.9151302 | 4.5118873 |
2.9197918 | 6.408129 |
2.9546596 | 6.2040109 |
2.9707417 | 4.4312104 |
3.0135107 | 5.9468569 |
3.0456382 | 5.6968997 |
3.0662513 | 5.9026477 |
3.0731757 | 7.0607237 |
3.0940184 | 7.3846903 |
3.0998003 | 5.0196854 |
3.1062588 | 5.8665536 |
3.1113574 | 4.7466426 |
3.1401502 | 4.322823 |
3.164504 | 4.3772491 |
3.167721 | 6.491692 |
3.1792337 | 5.1921312 |
3.189034 | 5.9209093 |
3.1923355 | 7.0269859 |
3.2420277 | 4.6866669 |
3.2563394 | 4.6318602 |
3.2646653 | 5.3621656 |
3.277839 | 5.5903912 |
3.2840827 | 4.3948904 |
3.3134128 | 5.7465675 |
3.3432966 | 4.3024976 |
3.3588688 | 4.6395169 |
3.3773154 | 5.509691 |
3.3923682 | 5.7704754 |
3.3928396 | 5.9307354 |
3.4097375 | 5.0243664 |
3.4250905 | 6.2957807 |
3.4256467 | 7.1909088 |
3.429859 | 6.6389274 |
3.4383383 | 6.5945946 |
3.4499816 | 5.3406544 |
3.4648999 | 5.7633964 |
3.5101871 | 5.0922003 |
3.5814278 | 6.4753996 |
3.5883151 | 4.204994 |
3.6065497 | 5.7304895 |
3.6109218 | 6.4108913 |
3.6800216 | 5.6595682 |
3.6865731 | 4.8736266 |
3.7364618 | 5.1109649 |
3.7834804 | 6.4478511 |
3.806937 | 4.2154877 |
3.8505015 | 4.7495611 |
3.8894656 | 5.5845772 |
3.898071 | 6.4421334 |
3.9191638 | 6.1379257 |
3.9232595 | 4.3691164 |
3.9263071 | 4.3499483 |
3.9336875 | 5.5430657 |
3.9561075 | 4.014345 |
3.956787 | 4.2913721 |
3.9597375 | 5.9233632 |
3.9647258 | 5.5541938 |
4.0014664 | 3.5959308 |
4.0967613 | 5.3460918 |
4.1113619 | 6.956129 |
4.1393133 | 5.1290369 |
4.2427451 | 6.3293623 |
4.2447324 | 4.4055278 |
4.2808958 | 6.1849711 |
4.2958248 | 6.52221 |
4.3333881 | 6.8926755 |
4.3770667 | 6.148263 |
4.3872811 | 5.0834977 |
4.3943806 | 3.2047041 |
4.4231133 | 7.1428545 |
4.4242463 | 6.7437029 |
4.4737188 | 7.1960809 |
4.5434832 | 4.9540165 |
4.5542301 | 6.6514457 |
4.556613 | 5.6792214 |
4.5569343 | 6.3557038 |
4.5681878 | 4.7334969 |
4.6154429 | 6.9919154 |
4.6573287 | 5.6323181 |
4.7523585 | 6.6764836 |
4.7530329 | 3.6970322 |
4.8855847 | 5.1092405 |
4.9202943 | 5.6878621 |
5.0692918 | 6.4614043 |
5.094251 | 6.9986657 |
5.2213603 | 4.8859654 |
5.29025 | 6.1231551 |
5.3047409 | 6.0529775 |
5.3807576 | 4.8897184 |
5.4022501 | 6.2157411 |
5.5258683 | 6.6077935 |
5.5602902 | 6.0202276 |
5.5928493 | 7.9473488 |
5.6337921 | 4.0477399 |
9.5649633 | 15.8199028 |
9.9492476 | 16.2417831 |
9.9639843 | 15.1301841 |
10.226796 | 14.0896456 |
10.5160477 | 15.339618 |
10.5494966 | 16.3187034 |
10.7321392 | 14.3091876 |
10.78872 | 14.9671922 |
10.8074223 | 15.160413 |
10.8077218 | 16.2829668 |
10.8401064 | 15.4340778 |
10.8887826 | 16.182616 |
10.9385494 | 14.0826968 |
11.0173279 | 17.015934 |
11.1333175 | 16.0641202 |
11.1493846 | 12.5813131 |
11.3247616 | 15.5008158 |
11.3596552 | 15.4300021 |
11.4498757 | 15.4660964 |
11.5039886 | 16.1291981 |
11.5577834 | 13.1352935 |
11.6243969 | 14.1862597 |
11.6653361 | 14.8993512 |
11.6752921 | 14.2522435 |
11.6978867 | 14.9182312 |
11.7050083 | 17.974634 |
11.7473609 | 14.2485078 |
11.7493806 | 14.5129937 |
11.7887799 | 14.8588077 |
11.836351 | 14.2174683 |
11.8726451 | 15.0834742 |
11.8903508 | 13.7250099 |
11.8907481 | 15.7297899 |
11.8955632 | 14.2141097 |
11.9133122 | 17.337941 |
11.9817274 | 14.634554 |
11.9985553 | 13.0236224 |
12.0917411 | 14.5520639 |
12.1110772 | 15.5536931 |
12.138392 | 14.2415998 |
12.1624205 | 14.7417785 |
12.1675304 | 15.3424403 |
12.1959608 | 14.6760523 |
12.1960034 | 15.4806538 |
12.2013835 | 16.6980377 |
12.2141018 | 15.6837557 |
12.2348838 | 13.4397497 |
12.2422483 | 14.3493743 |
12.2430823 | 14.7644821 |
12.2613676 | 15.8671876 |
12.2946775 | 14.1593571 |
12.3350288 | 15.460047 |
12.335831 | 16.4561045 |
12.3401016 | 16.1398342 |
12.3739163 | 14.9216549 |
12.43575 | 14.3674077 |
12.4735116 | 14.3621969 |
12.5094318 | 15.7425193 |
12.5192765 | 14.0919875 |
12.5230336 | 14.3181116 |
12.5389153 | 15.3706625 |
12.569023 | 16.6957121 |
12.6814631 | 14.0434399 |
12.7144954 | 12.191835 |
12.7198893 | 16.0829336 |
12.7803768 | 14.8861349 |
12.9326271 | 15.1804494 |
12.9732352 | 14.991876 |
12.9849534 | 14.8853695 |
13.1124261 | 14.3706331 |
13.1154425 | 15.9006981 |
13.1254249 | 13.0928389 |
13.2795063 | 15.5570386 |
13.2975804 | 14.1768362 |
13.3800894 | 14.2322431 |
14.1497729 | 15.4123977 |
1.14794639 | 18.979611 |
1.87296376 | 21.259677 |
1.95057589 | 19.253912 |
2.1774974 | 19.078445 |
2.2212576 | 20.180736 |
2.3319392 | 21.250346 |
2.3417249 | 19.922804 |
2.3666823 | 20.057726 |
2.4343045 | 19.844073 |
2.4637002 | 20.504545 |
2.5730949 | 21.120083 |
2.6960326 | 19.719672 |
2.7176948 | 19.681052 |
2.735971 | 21.281386 |
2.7907127 | 19.970722 |
2.8934128 | 21.577153 |
2.9067283 | 20.338185 |
2.9620927 | 21.091421 |
2.9967398 | 21.708606 |
3.0047431 | 20.371614 |
3.044215 | 19.689133 |
3.0872242 | 21.305325 |
3.0887985 | 20.697535 |
3.200185 | 21.663794 |
3.2008578 | 19.885879 |
3.2557222 | 19.889798 |
3.2892761 | 18.6007235 |
3.3028307 | 19.637392 |
3.3419285 | 19.224092 |
3.3422877 | 19.204327 |
3.3583757 | 21.048761 |
3.3893859 | 20.918406 |
3.4169347 | 21.292314 |
3.457675 | 20.097081 |
3.4578659 | 20.974339 |
3.4788892 | 21.152925 |
3.5046477 | 21.381791 |
3.5059035 | 21.737371 |
3.5621021 | 20.857647 |
3.6720782 | 18.4164271 |
3.6959001 | 21.995196 |
3.6992848 | 20.473127 |
3.7066215 | 19.623886 |
3.7295648 | 20.278963 |
3.7460885 | 20.579015 |
3.8699537 | 22.05209 |
3.8716518 | 22.413634 |
3.8873572 | 21.962738 |
3.9045898 | 21.715849 |
3.9456943 | 20.248866 |
3.9765246 | 21.883393 |
3.9819109 | 22.26836 |
3.998568 | 21.243342 |
4.0433096 | 22.347058 |
4.0596044 | 22.056215 |
4.0794422 | 20.758407 |
4.1129522 | 20.224293 |
4.1413942 | 20.929671 |
4.1627441 | 22.158977 |
4.1767186 | 20.184683 |
4.1781964 | 21.230266 |
4.2431648 | 21.962598 |
4.2618399 | 20.533754 |
4.3829695 | 20.589008 |
4.3900615 | 21.298833 |
4.4072292 | 20.452131 |
4.4630972 | 22.51363 |
4.4865115 | 20.166259 |
4.489808 | 20.302365 |
4.4985781 | 20.176454 |
4.4995603 | 21.339537 |
4.5015888 | 21.546623 |
4.5126907 | 22.181318 |
4.5186807 | 20.243923 |
4.5200494 | 21.606359 |
4.5546059 | 21.523475 |
4.5593513 | 22.20819 |
4.620113 | 22.041174 |
4.7561987 | 21.161672 |
4.7777356 | 20.774779 |
4.7993429 | 21.862268 |
4.8108036 | 22.172305 |
4.8138488 | 23.482412 |
4.9717907 | 21.813861 |
4.9946929 | 22.564215 |
5.0059337 | 21.629871 |
5.0114164 | 21.947345 |
5.0376315 | 20.086702 |
5.1360659 | 20.978871 |
5.1976377 | 22.45016 |
5.3760322 | 20.3188 |
5.4290531 | 21.540536 |
5.4497178 | 21.767889 |
5.4527803 | 21.620024 |
5.6388008 | 21.745066 |
5.6473698 | 21.450529 |
5.7566377 | 22.143698 |
5.7900453 | 21.382074 |
5.8758893 | 21.90501 |
5.9023884 | 21.818273 |
5.9788072 | 20.959914 |
6.0324193 | 21.252833 |
6.3479027 | 20.875618 |
10.4652107 | 2.6831135 |
10.5244255 | 1.1185327 |
10.676615 | 2.1365133 |
10.7060357 | 4.8800944 |
11.0507822 | 4.9306996 |
11.0926175 | 5.5469616 |
11.1620361 | 3.4362472 |
11.528659 | 4.9653684 |
11.68202 | 4.9323634 |
11.8113105 | 5.0447482 |
11.8395293 | 3.2846371 |
11.8904436 | 3.9756688 |
11.901902 | 4.0596121 |
12.00957 | 3.8387848 |
12.041757 | 3.2972722 |
12.070124 | 3.5975018 |
12.125698 | 5.2145027 |
12.13737 | 5.069625 |
12.179778 | 2.7118074 |
12.300714 | 2.811699 |
12.302589 | 4.6895294 |
12.310044 | 3.3904743 |
12.360948 | 4.048405 |
12.387776 | 2.650697 |
12.404948 | 2.3650841 |
12.415097 | 4.0142043 |
12.417047 | 3.4687826 |
12.442745 | 5.030264 |
12.443721 | 4.1409706 |
12.447941 | 5.8988869 |
12.476582 | 3.743859 |
12.515158 | 5.106076 |
12.595752 | 3.8626734 |
12.615602 | 3.2022261 |
12.61961 | 5.7629745 |
12.632347 | 3.3748335 |
12.657503 | 3.2747553 |
12.709758 | 5.0287697 |
12.747944 | 5.0152176 |
12.752371 | 4.7189407 |
12.818769 | 3.7802197 |
12.820888 | 3.1272452 |
12.830515 | 5.601528 |
12.863656 | 2.6533946 |
12.88482 | 5.2657701 |
12.904148 | 4.8965637 |
12.939187 | 3.1585675 |
12.952628 | 2.2741358 |
12.973613 | 4.8611944 |
12.97606 | 2.9509126 |
13.000251 | 4.8797171 |
13.004435 | 2.8729802 |
13.004874 | 4.9961698 |
13.008949 | 4.4582345 |
13.025455 | 4.3870708 |
13.045022 | 4.9916418 |
13.096295 | 2.973044 |
13.195278 | 2.9627547 |
13.21192 | 4.3851352 |
13.215603 | 4.153893 |
13.362235 | 2.9408317 |
13.487338 | 3.4554507 |
13.507061 | 4.9059559 |
13.544954 | 3.0748351 |
13.561125 | 3.3112401 |
13.575478 | 3.2823488 |
13.61449 | 4.9872933 |
13.618037 | 3.916222 |
13.63065 | 4.3280429 |
13.666668 | 4.0476106 |
13.693189 | 4.5426592 |
13.71092 | 2.5744855 |
13.717479 | 3.5385358 |
13.723603 | 4.8269313 |
13.740956 | 4.5362417 |
13.810342 | 3.3345241 |
13.884852 | 5.2966064 |
13.88918 | 2.4088233 |
13.908124 | 4.4692953 |
13.920669 | 5.1046996 |
14.066882 | 4.2443514 |
14.119596 | 3.8195427 |
14.134638 | 4.0501819 |
14.15121 | 5.0939166 |
14.174712 | 1.7723559 |
14.23597 | 5.8236027 |
14.270719 | 3.9357992 |
14.418402 | 5.0104769 |
14.423091 | 4.655516 |
14.58717 | 5.4807475 |
14.608216 | 5.5958854 |
14.621365 | 5.1009621 |
14.639837 | 5.7854218 |
14.675322 | 3.0883694 |
14.885806 | 4.5369381 |
15.123712 | 3.1371023 |
15.314308 | 4.2649289 |
20.1271918 | 15.296397 |
21.0410633 | 15.246086 |
21.0765704 | 14.281669 |
21.1579441 | 14.821112 |
21.2049293 | 14.132894 |
21.2509463 | 13.3686 |
21.2995974 | 15.315821 |
21.4488022 | 13.797879 |
21.4718758 | 15.400537 |
21.6037499 | 15.167981 |
21.6299854 | 12.916744 |
21.6385609 | 15.134394 |
21.722283 | 12.348765 |
21.8768788 | 12.795341 |
21.8805154 | 13.427278 |
21.9245665 | 14.171992 |
21.9419753 | 12.11674 |
21.9458388 | 13.572502 |
21.9963091 | 13.910162 |
21.9977637 | 12.264383 |
22.120108 | 14.298028 |
22.161642 | 12.235561 |
22.259619 | 14.538579 |
22.278865 | 13.907848 |
22.284851 | 14.78127 |
22.302126 | 13.551077 |
22.419082 | 13.560862 |
22.451229 | 14.87717 |
22.481022 | 14.631295 |
22.487289 | 13.299683 |
22.570844 | 13.073695 |
22.587373 | 14.506647 |
22.625944 | 13.499386 |
22.641761 | 13.157186 |
22.64511 | 12.942852 |
22.667898 | 15.982038 |
22.670485 | 13.955641 |
22.706356 | 13.361715 |
22.711061 | 14.236744 |
22.771428 | 12.766095 |
22.775607 | 16.052587 |
22.886805 | 13.023554 |
22.928196 | 11.2239141 |
22.950179 | 14.187592 |
22.966609 | 13.020396 |
22.984097 | 13.00589 |
22.997997 | 14.669185 |
23.089569 | 14.398868 |
23.108494 | 13.910334 |
23.147798 | 13.724342 |
23.155115 | 16.121416 |
23.158758 | 14.718643 |
23.213179 | 12.731326 |
23.222689 | 13.894866 |
23.237439 | 14.728269 |
23.247742 | 15.206662 |
23.256842 | 14.442514 |
23.269178 | 13.628728 |
23.350498 | 13.563816 |
23.469883 | 14.188571 |
23.4942 | 14.38967 |
23.52686 | 12.779428 |
23.553505 | 14.539572 |
23.559418 | 15.570712 |
23.567707 | 14.901948 |
23.634692 | 12.074948 |
23.634837 | 14.236684 |
23.641807 | 14.726728 |
23.677089 | 14.332538 |
23.767215 | 15.092209 |
23.781016 | 12.595779 |
23.878886 | 14.329098 |
23.891137 | 13.18777 |
23.895193 | 11.6599829 |
23.945273 | 13.156521 |
23.949261 | 12.944328 |
23.998138 | 13.186815 |
24.01272 | 14.270148 |
24.021108 | 15.495508 |
24.026602 | 13.861609 |
24.056164 | 13.728905 |
24.065794 | 13.845586 |
24.087697 | 15.523848 |
24.105136 | 13.638893 |
24.197604 | 14.022645 |
24.296025 | 15.509115 |
24.349088 | 14.002902 |
24.370353 | 16.051215 |
24.425818 | 12.55447 |
24.465642 | 12.745134 |
24.470883 | 13.280208 |
24.473897 | 13.425769 |
24.516394 | 13.222901 |
24.646671 | 13.889919 |
24.651572 | 15.064428 |
24.888393 | 12.709495 |
25.075641 | 14.576588 |
26.009856 | 14.548147 |
Parag Kanade/fuzzy ants/Gauss500-4/gauss500_04Full.data
1 | 1.2079091 | 5.7210589 |
1 | 1.2231833 | 6.624442 |
1 | 1.2724274 | 5.7211989 |
1 | 1.3905861 | 4.8528257 |
1 | 1.5263206 | 5.1902709 |
1 | 1.5446515 | 4.9092366 |
1 | 2.0817641 | 4.2932327 |
1 | 2.1329588 | 4.7909656 |
1 | 2.2061908 | 4.5587698 |
1 | 2.2294541 | 5.7094674 |
1 | 2.2311605 | 4.1842931 |
1 | 2.3729459 | 4.6146591 |
1 | 2.451783 | 6.0942238 |
1 | 2.4631214 | 3.9776029 |
1 | 2.4641181 | 5.9918609 |
1 | 2.5092126 | 5.2028537 |
1 | 2.5249635 | 3.8857945 |
1 | 2.5408484 | 5.0938419 |
1 | 2.5538585 | 6.1353191 |
1 | 2.580998 | 5.1703637 |
1 | 2.6221661 | 6.0532502 |
1 | 2.6675926 | 5.5078748 |
1 | 2.6693178 | 5.0258803 |
1 | 2.6757058 | 3.5386359 |
1 | 2.6875167 | 6.3955603 |
1 | 2.8136569 | 6.2550441 |
1 | 2.8330733 | 6.7522282 |
1 | 2.8388063 | 6.8021392 |
1 | 2.8394463 | 6.1968265 |
1 | 2.8564329 | 3.7743203 |
1 | 2.8694154 | 4.2415617 |
1 | 2.8838473 | 5.8844967 |
1 | 2.9151302 | 4.5118873 |
1 | 2.9197918 | 6.408129 |
1 | 2.9546596 | 6.2040109 |
1 | 2.9707417 | 4.4312104 |
1 | 3.0135107 | 5.9468569 |
1 | 3.0456382 | 5.6968997 |
1 | 3.0662513 | 5.9026477 |
1 | 3.0731757 | 7.0607237 |
1 | 3.0940184 | 7.3846903 |
1 | 3.0998003 | 5.0196854 |
1 | 3.1062588 | 5.8665536 |
1 | 3.1113574 | 4.7466426 |
1 | 3.1401502 | 4.322823 |
1 | 3.164504 | 4.3772491 |
1 | 3.167721 | 6.491692 |
1 | 3.1792337 | 5.1921312 |
1 | 3.189034 | 5.9209093 |
1 | 3.1923355 | 7.0269859 |
1 | 3.2420277 | 4.6866669 |
1 | 3.2563394 | 4.6318602 |
1 | 3.2646653 | 5.3621656 |
1 | 3.277839 | 5.5903912 |
1 | 3.2840827 | 4.3948904 |
1 | 3.3134128 | 5.7465675 |
1 | 3.3432966 | 4.3024976 |
1 | 3.3588688 | 4.6395169 |
1 | 3.3773154 | 5.509691 |
1 | 3.3923682 | 5.7704754 |
1 | 3.3928396 | 5.9307354 |
1 | 3.4097375 | 5.0243664 |
1 | 3.4250905 | 6.2957807 |
1 | 3.4256467 | 7.1909088 |
1 | 3.429859 | 6.6389274 |
1 | 3.4383383 | 6.5945946 |
1 | 3.4499816 | 5.3406544 |
1 | 3.4648999 | 5.7633964 |
1 | 3.5101871 | 5.0922003 |
1 | 3.5814278 | 6.4753996 |
1 | 3.5883151 | 4.204994 |
1 | 3.6065497 | 5.7304895 |
1 | 3.6109218 | 6.4108913 |
1 | 3.6800216 | 5.6595682 |
1 | 3.6865731 | 4.8736266 |
1 | 3.7364618 | 5.1109649 |
1 | 3.7834804 | 6.4478511 |
1 | 3.806937 | 4.2154877 |
1 | 3.8505015 | 4.7495611 |
1 | 3.8894656 | 5.5845772 |
1 | 3.898071 | 6.4421334 |
1 | 3.9191638 | 6.1379257 |
1 | 3.9232595 | 4.3691164 |
1 | 3.9263071 | 4.3499483 |
1 | 3.9336875 | 5.5430657 |
1 | 3.9561075 | 4.014345 |
1 | 3.956787 | 4.2913721 |
1 | 3.9597375 | 5.9233632 |
1 | 3.9647258 | 5.5541938 |
1 | 4.0014664 | 3.5959308 |
1 | 4.0967613 | 5.3460918 |
1 | 4.1113619 | 6.956129 |
1 | 4.1393133 | 5.1290369 |
1 | 4.2427451 | 6.3293623 |
1 | 4.2447324 | 4.4055278 |
1 | 4.2808958 | 6.1849711 |
1 | 4.2958248 | 6.52221 |
1 | 4.3333881 | 6.8926755 |
1 | 4.3770667 | 6.148263 |
1 | 4.3872811 | 5.0834977 |
1 | 4.3943806 | 3.2047041 |
1 | 4.4231133 | 7.1428545 |
1 | 4.4242463 | 6.7437029 |
1 | 4.4737188 | 7.1960809 |
1 | 4.5434832 | 4.9540165 |
1 | 4.5542301 | 6.6514457 |
1 | 4.556613 | 5.6792214 |
1 | 4.5569343 | 6.3557038 |
1 | 4.5681878 | 4.7334969 |
1 | 4.6154429 | 6.9919154 |
1 | 4.6573287 | 5.6323181 |
1 | 4.7523585 | 6.6764836 |
1 | 4.7530329 | 3.6970322 |
1 | 4.8855847 | 5.1092405 |
1 | 4.9202943 | 5.6878621 |
1 | 5.0692918 | 6.4614043 |
1 | 5.094251 | 6.9986657 |
1 | 5.2213603 | 4.8859654 |
1 | 5.29025 | 6.1231551 |
1 | 5.3047409 | 6.0529775 |
1 | 5.3807576 | 4.8897184 |
1 | 5.4022501 | 6.2157411 |
1 | 5.5258683 | 6.6077935 |
1 | 5.5602902 | 6.0202276 |
1 | 5.5928493 | 7.9473488 |
1 | 5.6337921 | 4.0477399 |
2 | 9.5649633 | 15.8199028 |
2 | 9.9492476 | 16.2417831 |
2 | 9.9639843 | 15.1301841 |
2 | 10.226796 | 14.0896456 |
2 | 10.5160477 | 15.339618 |
2 | 10.5494966 | 16.3187034 |
2 | 10.7321392 | 14.3091876 |
2 | 10.78872 | 14.9671922 |
2 | 10.8074223 | 15.160413 |
2 | 10.8077218 | 16.2829668 |
2 | 10.8401064 | 15.4340778 |
2 | 10.8887826 | 16.182616 |
2 | 10.9385494 | 14.0826968 |
2 | 11.0173279 | 17.015934 |
2 | 11.1333175 | 16.0641202 |
2 | 11.1493846 | 12.5813131 |
2 | 11.3247616 | 15.5008158 |
2 | 11.3596552 | 15.4300021 |
2 | 11.4498757 | 15.4660964 |
2 | 11.5039886 | 16.1291981 |
2 | 11.5577834 | 13.1352935 |
2 | 11.6243969 | 14.1862597 |
2 | 11.6653361 | 14.8993512 |
2 | 11.6752921 | 14.2522435 |
2 | 11.6978867 | 14.9182312 |
2 | 11.7050083 | 17.974634 |
2 | 11.7473609 | 14.2485078 |
2 | 11.7493806 | 14.5129937 |
2 | 11.7887799 | 14.8588077 |
2 | 11.836351 | 14.2174683 |
2 | 11.8726451 | 15.0834742 |
2 | 11.8903508 | 13.7250099 |
2 | 11.8907481 | 15.7297899 |
2 | 11.8955632 | 14.2141097 |
2 | 11.9133122 | 17.337941 |
2 | 11.9817274 | 14.634554 |
2 | 11.9985553 | 13.0236224 |
2 | 12.0917411 | 14.5520639 |
2 | 12.1110772 | 15.5536931 |
2 | 12.138392 | 14.2415998 |
2 | 12.1624205 | 14.7417785 |
2 | 12.1675304 | 15.3424403 |
2 | 12.1959608 | 14.6760523 |
2 | 12.1960034 | 15.4806538 |
2 | 12.2013835 | 16.6980377 |
2 | 12.2141018 | 15.6837557 |
2 | 12.2348838 | 13.4397497 |
2 | 12.2422483 | 14.3493743 |
2 | 12.2430823 | 14.7644821 |
2 | 12.2613676 | 15.8671876 |
2 | 12.2946775 | 14.1593571 |
2 | 12.3350288 | 15.460047 |
2 | 12.335831 | 16.4561045 |
2 | 12.3401016 | 16.1398342 |
2 | 12.3739163 | 14.9216549 |
2 | 12.43575 | 14.3674077 |
2 | 12.4735116 | 14.3621969 |
2 | 12.5094318 | 15.7425193 |
2 | 12.5192765 | 14.0919875 |
2 | 12.5230336 | 14.3181116 |
2 | 12.5389153 | 15.3706625 |
2 | 12.569023 | 16.6957121 |
2 | 12.6814631 | 14.0434399 |
2 | 12.7144954 | 12.191835 |
2 | 12.7198893 | 16.0829336 |
2 | 12.7803768 | 14.8861349 |
2 | 12.9326271 | 15.1804494 |
2 | 12.9732352 | 14.991876 |
2 | 12.9849534 | 14.8853695 |
2 | 13.1124261 | 14.3706331 |
2 | 13.1154425 | 15.9006981 |
2 | 13.1254249 | 13.0928389 |
2 | 13.2795063 | 15.5570386 |
2 | 13.2975804 | 14.1768362 |
2 | 13.3800894 | 14.2322431 |
2 | 14.1497729 | 15.4123977 |
3 | 1.14794639 | 18.979611 |
3 | 1.87296376 | 21.259677 |
3 | 1.95057589 | 19.253912 |
3 | 2.1774974 | 19.078445 |
3 | 2.2212576 | 20.180736 |
3 | 2.3319392 | 21.250346 |
3 | 2.3417249 | 19.922804 |
3 | 2.3666823 | 20.057726 |
3 | 2.4343045 | 19.844073 |
3 | 2.4637002 | 20.504545 |
3 | 2.5730949 | 21.120083 |
3 | 2.6960326 | 19.719672 |
3 | 2.7176948 | 19.681052 |
3 | 2.735971 | 21.281386 |
3 | 2.7907127 | 19.970722 |
3 | 2.8934128 | 21.577153 |
3 | 2.9067283 | 20.338185 |
3 | 2.9620927 | 21.091421 |
3 | 2.9967398 | 21.708606 |
3 | 3.0047431 | 20.371614 |
3 | 3.044215 | 19.689133 |
3 | 3.0872242 | 21.305325 |
3 | 3.0887985 | 20.697535 |
3 | 3.200185 | 21.663794 |
3 | 3.2008578 | 19.885879 |
3 | 3.2557222 | 19.889798 |
3 | 3.2892761 | 18.6007235 |
3 | 3.3028307 | 19.637392 |
3 | 3.3419285 | 19.224092 |
3 | 3.3422877 | 19.204327 |
3 | 3.3583757 | 21.048761 |
3 | 3.3893859 | 20.918406 |
3 | 3.4169347 | 21.292314 |
3 | 3.457675 | 20.097081 |
3 | 3.4578659 | 20.974339 |
3 | 3.4788892 | 21.152925 |
3 | 3.5046477 | 21.381791 |
3 | 3.5059035 | 21.737371 |
3 | 3.5621021 | 20.857647 |
3 | 3.6720782 | 18.4164271 |
3 | 3.6959001 | 21.995196 |
3 | 3.6992848 | 20.473127 |
3 | 3.7066215 | 19.623886 |
3 | 3.7295648 | 20.278963 |
3 | 3.7460885 | 20.579015 |
3 | 3.8699537 | 22.05209 |
3 | 3.8716518 | 22.413634 |
3 | 3.8873572 | 21.962738 |
3 | 3.9045898 | 21.715849 |
3 | 3.9456943 | 20.248866 |
3 | 3.9765246 | 21.883393 |
3 | 3.9819109 | 22.26836 |
3 | 3.998568 | 21.243342 |
3 | 4.0433096 | 22.347058 |
3 | 4.0596044 | 22.056215 |
3 | 4.0794422 | 20.758407 |
3 | 4.1129522 | 20.224293 |
3 | 4.1413942 | 20.929671 |
3 | 4.1627441 | 22.158977 |
3 | 4.1767186 | 20.184683 |
3 | 4.1781964 | 21.230266 |
3 | 4.2431648 | 21.962598 |
3 | 4.2618399 | 20.533754 |
3 | 4.3829695 | 20.589008 |
3 | 4.3900615 | 21.298833 |
3 | 4.4072292 | 20.452131 |
3 | 4.4630972 | 22.51363 |
3 | 4.4865115 | 20.166259 |
3 | 4.489808 | 20.302365 |
3 | 4.4985781 | 20.176454 |
3 | 4.4995603 | 21.339537 |
3 | 4.5015888 | 21.546623 |
3 | 4.5126907 | 22.181318 |
3 | 4.5186807 | 20.243923 |
3 | 4.5200494 | 21.606359 |
3 | 4.5546059 | 21.523475 |
3 | 4.5593513 | 22.20819 |
3 | 4.620113 | 22.041174 |
3 | 4.7561987 | 21.161672 |
3 | 4.7777356 | 20.774779 |
3 | 4.7993429 | 21.862268 |
3 | 4.8108036 | 22.172305 |
3 | 4.8138488 | 23.482412 |
3 | 4.9717907 | 21.813861 |
3 | 4.9946929 | 22.564215 |
3 | 5.0059337 | 21.629871 |
3 | 5.0114164 | 21.947345 |
3 | 5.0376315 | 20.086702 |
3 | 5.1360659 | 20.978871 |
3 | 5.1976377 | 22.45016 |
3 | 5.3760322 | 20.3188 |
3 | 5.4290531 | 21.540536 |
3 | 5.4497178 | 21.767889 |
3 | 5.4527803 | 21.620024 |
3 | 5.6388008 | 21.745066 |
3 | 5.6473698 | 21.450529 |
3 | 5.7566377 | 22.143698 |
3 | 5.7900453 | 21.382074 |
3 | 5.8758893 | 21.90501 |
3 | 5.9023884 | 21.818273 |
3 | 5.9788072 | 20.959914 |
3 | 6.0324193 | 21.252833 |
3 | 6.3479027 | 20.875618 |
4 | 10.4652107 | 2.6831135 |
4 | 10.5244255 | 1.1185327 |
4 | 10.676615 | 2.1365133 |
4 | 10.7060357 | 4.8800944 |
4 | 11.0507822 | 4.9306996 |
4 | 11.0926175 | 5.5469616 |
4 | 11.1620361 | 3.4362472 |
4 | 11.528659 | 4.9653684 |
4 | 11.68202 | 4.9323634 |
4 | 11.8113105 | 5.0447482 |
4 | 11.8395293 | 3.2846371 |
4 | 11.8904436 | 3.9756688 |
4 | 11.901902 | 4.0596121 |
4 | 12.00957 | 3.8387848 |
4 | 12.041757 | 3.2972722 |
4 | 12.070124 | 3.5975018 |
4 | 12.125698 | 5.2145027 |
4 | 12.13737 | 5.069625 |
4 | 12.179778 | 2.7118074 |
4 | 12.300714 | 2.811699 |
4 | 12.302589 | 4.6895294 |
4 | 12.310044 | 3.3904743 |
4 | 12.360948 | 4.048405 |
4 | 12.387776 | 2.650697 |
4 | 12.404948 | 2.3650841 |
4 | 12.415097 | 4.0142043 |
4 | 12.417047 | 3.4687826 |
4 | 12.442745 | 5.030264 |
4 | 12.443721 | 4.1409706 |
4 | 12.447941 | 5.8988869 |
4 | 12.476582 | 3.743859 |
4 | 12.515158 | 5.106076 |
4 | 12.595752 | 3.8626734 |
4 | 12.615602 | 3.2022261 |
4 | 12.61961 | 5.7629745 |
4 | 12.632347 | 3.3748335 |
4 | 12.657503 | 3.2747553 |
4 | 12.709758 | 5.0287697 |
4 | 12.747944 | 5.0152176 |
4 | 12.752371 | 4.7189407 |
4 | 12.818769 | 3.7802197 |
4 | 12.820888 | 3.1272452 |
4 | 12.830515 | 5.601528 |
4 | 12.863656 | 2.6533946 |
4 | 12.88482 | 5.2657701 |
4 | 12.904148 | 4.8965637 |
4 | 12.939187 | 3.1585675 |
4 | 12.952628 | 2.2741358 |
4 | 12.973613 | 4.8611944 |
4 | 12.97606 | 2.9509126 |
4 | 13.000251 | 4.8797171 |
4 | 13.004435 | 2.8729802 |
4 | 13.004874 | 4.9961698 |
4 | 13.008949 | 4.4582345 |
4 | 13.025455 | 4.3870708 |
4 | 13.045022 | 4.9916418 |
4 | 13.096295 | 2.973044 |
4 | 13.195278 | 2.9627547 |
4 | 13.21192 | 4.3851352 |
4 | 13.215603 | 4.153893 |
4 | 13.362235 | 2.9408317 |
4 | 13.487338 | 3.4554507 |
4 | 13.507061 | 4.9059559 |
4 | 13.544954 | 3.0748351 |
4 | 13.561125 | 3.3112401 |
4 | 13.575478 | 3.2823488 |
4 | 13.61449 | 4.9872933 |
4 | 13.618037 | 3.916222 |
4 | 13.63065 | 4.3280429 |
4 | 13.666668 | 4.0476106 |
4 | 13.693189 | 4.5426592 |
4 | 13.71092 | 2.5744855 |
4 | 13.717479 | 3.5385358 |
4 | 13.723603 | 4.8269313 |
4 | 13.740956 | 4.5362417 |
4 | 13.810342 | 3.3345241 |
4 | 13.884852 | 5.2966064 |
4 | 13.88918 | 2.4088233 |
4 | 13.908124 | 4.4692953 |
4 | 13.920669 | 5.1046996 |
4 | 14.066882 | 4.2443514 |
4 | 14.119596 | 3.8195427 |
4 | 14.134638 | 4.0501819 |
4 | 14.15121 | 5.0939166 |
4 | 14.174712 | 1.7723559 |
4 | 14.23597 | 5.8236027 |
4 | 14.270719 | 3.9357992 |
4 | 14.418402 | 5.0104769 |
4 | 14.423091 | 4.655516 |
4 | 14.58717 | 5.4807475 |
4 | 14.608216 | 5.5958854 |
4 | 14.621365 | 5.1009621 |
4 | 14.639837 | 5.7854218 |
4 | 14.675322 | 3.0883694 |
4 | 14.885806 | 4.5369381 |
4 | 15.123712 | 3.1371023 |
4 | 15.314308 | 4.2649289 |
5 | 20.1271918 | 15.296397 |
5 | 21.0410633 | 15.246086 |
5 | 21.0765704 | 14.281669 |
5 | 21.1579441 | 14.821112 |
5 | 21.2049293 | 14.132894 |
5 | 21.2509463 | 13.3686 |
5 | 21.2995974 | 15.315821 |
5 | 21.4488022 | 13.797879 |
5 | 21.4718758 | 15.400537 |
5 | 21.6037499 | 15.167981 |
5 | 21.6299854 | 12.916744 |
5 | 21.6385609 | 15.134394 |
5 | 21.722283 | 12.348765 |
5 | 21.8768788 | 12.795341 |
5 | 21.8805154 | 13.427278 |
5 | 21.9245665 | 14.171992 |
5 | 21.9419753 | 12.11674 |
5 | 21.9458388 | 13.572502 |
5 | 21.9963091 | 13.910162 |
5 | 21.9977637 | 12.264383 |
5 | 22.120108 | 14.298028 |
5 | 22.161642 | 12.235561 |
5 | 22.259619 | 14.538579 |
5 | 22.278865 | 13.907848 |
5 | 22.284851 | 14.78127 |
5 | 22.302126 | 13.551077 |
5 | 22.419082 | 13.560862 |
5 | 22.451229 | 14.87717 |
5 | 22.481022 | 14.631295 |
5 | 22.487289 | 13.299683 |
5 | 22.570844 | 13.073695 |
5 | 22.587373 | 14.506647 |
5 | 22.625944 | 13.499386 |
5 | 22.641761 | 13.157186 |
5 | 22.64511 | 12.942852 |
5 | 22.667898 | 15.982038 |
5 | 22.670485 | 13.955641 |
5 | 22.706356 | 13.361715 |
5 | 22.711061 | 14.236744 |
5 | 22.771428 | 12.766095 |
5 | 22.775607 | 16.052587 |
5 | 22.886805 | 13.023554 |
5 | 22.928196 | 11.2239141 |
5 | 22.950179 | 14.187592 |
5 | 22.966609 | 13.020396 |
5 | 22.984097 | 13.00589 |
5 | 22.997997 | 14.669185 |
5 | 23.089569 | 14.398868 |
5 | 23.108494 | 13.910334 |
5 | 23.147798 | 13.724342 |
5 | 23.155115 | 16.121416 |
5 | 23.158758 | 14.718643 |
5 | 23.213179 | 12.731326 |
5 | 23.222689 | 13.894866 |
5 | 23.237439 | 14.728269 |
5 | 23.247742 | 15.206662 |
5 | 23.256842 | 14.442514 |
5 | 23.269178 | 13.628728 |
5 | 23.350498 | 13.563816 |
5 | 23.469883 | 14.188571 |
5 | 23.4942 | 14.38967 |
5 | 23.52686 | 12.779428 |
5 | 23.553505 | 14.539572 |
5 | 23.559418 | 15.570712 |
5 | 23.567707 | 14.901948 |
5 | 23.634692 | 12.074948 |
5 | 23.634837 | 14.236684 |
5 | 23.641807 | 14.726728 |
5 | 23.677089 | 14.332538 |
5 | 23.767215 | 15.092209 |
5 | 23.781016 | 12.595779 |
5 | 23.878886 | 14.329098 |
5 | 23.891137 | 13.18777 |
5 | 23.895193 | 11.6599829 |
5 | 23.945273 | 13.156521 |
5 | 23.949261 | 12.944328 |
5 | 23.998138 | 13.186815 |
5 | 24.01272 | 14.270148 |
5 | 24.021108 | 15.495508 |
5 | 24.026602 | 13.861609 |
5 | 24.056164 | 13.728905 |
5 | 24.065794 | 13.845586 |
5 | 24.087697 | 15.523848 |
5 | 24.105136 | 13.638893 |
5 | 24.197604 | 14.022645 |
5 | 24.296025 | 15.509115 |
5 | 24.349088 | 14.002902 |
5 | 24.370353 | 16.051215 |
5 | 24.425818 | 12.55447 |
5 | 24.465642 | 12.745134 |
5 | 24.470883 | 13.280208 |
5 | 24.473897 | 13.425769 |
5 | 24.516394 | 13.222901 |
5 | 24.646671 | 13.889919 |
5 | 24.651572 | 15.064428 |
5 | 24.888393 | 12.709495 |
5 | 25.075641 | 14.576588 |
5 | 26.009856 | 14.548147 |
Parag Kanade/fuzzy ants/Gauss500-4/gauss.c
#include "headerStatic.h" /*******************************************************************/ /*** Global Variables ***/ irisData data[MAXDATA]; //To hold the data read from the file int count=0; //Count of the total number of data elements int heapCount=0; // Total number of heaps int heapRow=0; // Rows for the second iteration with heaps int newHeapCount=0; // Count of the heaps for the second iteration heap heaps[MAXDATA]; // Data structure to hold the heap information heap newHeaps[MAXDATA]; // Data Structure to hold the new heap information // For the second iteration int board[MAXROWS][MAXCOLS]; // Board on which the objects are located ant ants[MAXANTS]; // Data structure to hold the ants float Dmax=0; // Distance of the most dissimilar object pair int minHeapCount=100000; // Counter to hold the minimum heap count, used only for academic purpose // no use in the algorithm int minPosition; // the minimum heap iteration , only for academic purpose // no use in the algorithm float clsCen[MAXDATA][MAXDATA][s];//to hold the objects after hardening int cenCount[MAXDATA];//to hold the number of objects after hardening /********************************************************************/ /*** Varaibles to normalize the features between 0 and 1 */ float minInput[features], maxInput[features],scale[features],minForHeaps[features],maxForHeaps[features],scaleForHeaps[features]; /********************************************************************/ /** Variables for the FCM algorithm */ int temp[200]; /* for square matrix tests */ float eps,m; matrix U, U1; BOOLEAN stop; center V; objects X; char fname[80]; FILE *fp; int run; float inv_cov[s+1][s+1]; /* inverse of covariance matrix Y */ float Y[s][s]; long rand_index, Random_seed; long state1[52] = { 9347, 3835, 5194, 8310, 346, 535, 5297, 6711, 77, 3834, 668, 4175, 6868, 5890, 9304, 8462, 5269, 920, 65392, 41600, 70119, 91032, 76220, 26245, 4746, 73608, 32823, 63264, 75641, 99104, 36534, 24704, 98255, 72266, 75336, 65152, 7269, 63163, 88471, 27271, 43641, 76649, 47773, 23777, 27491, 35926, 16651, 48652, 89766, 90921, 6056 }; int z; int mins=0; int aveit =0; float mintab[200]; int mincount[200]; long start,end,total; int lCount;//added by parag /********************************************************************/ /********************************************************************//*int lrand48(){return(rand());}void srand48(int a){return;}*//********************************************************************/ /********************************************************************/ /* Function to read the input data set */ /* The file name is assumed to be itest.data */ /* Status: Tested */ /* Output: Data from the file into the "data" (Global) data structure */ /* Output: Count (Global), the count of the number of objects */ /********************************************************************/ void readInput() { FILE *fp; char fname[80]; int i=0,j=0; char ch; sprintf(fname,"%s.data",filename); /* Check if the input file is opened */ if((fp=fopen(fname,"r"))==NULL) { printf("\n Unable to open input file \n"); exit(0); } /*initialise the minimum maximum and the scale */ for(i=0;i<features;i++) { minInput[i]=1000; maxInput[i]=0; minForHeaps[i]=1000; maxForHeaps[i]=0; scale[i]=0; scaleForHeaps[i]=0; } /* Discard leading comments */ ch = 'c'; while (ch != '#') fscanf (fp, "%c", &ch); i=0; /* Parse the file and populate the data structure */ while(!feof(fp)) { for(j=0;j<features;j++) { fscanf(fp,"%f ",&data[i][j]); } fscanf(fp,"\n"); for(j=0;j<features;j++) { if(data[i][j]<minInput[j]) minInput[j]=data[i][j]; if(data[i][j]>maxInput[j]) maxInput[j]=data[i][j]; } i++; } count=i; /* Normailze the feature values in between 0 and 1 */ for(j=0;j<features;j++) { if(minInput[j]!=maxInput[j]) scale[j]=1.0/(maxInput[j]-minInput[j]); else scale[j]=1.0; } for(i=0;i<count;i++) { for(j=0;j<features;j++) data[i][j]=(data[i][j]-minInput[j])*scale[j]; } fclose(fp); return; }//end of function /********************************************************************/ /*Function to compute the eucldiean distance for all input data set */ /* Output : an array conatining the distance of each object with the other */ /********************************************************************/ float computeDistance() { float distance,dist=0; int i=0,j=0,k=0; distance=0; for(j=0;j<count;j++) for(i=0;i<count;i++) { for(k=0;k<features;k++) dist+=sqrt((data[j][k]-data[i][k])*(data[j][k]-data[i][k])); if(distance<dist)distance=dist; dist=0; } return(distance); } /********************************************************************/ /* Function to compute the distance between two objects */ /* Output : Euclidean d istance between the two input objects */ /********************************************************************/ float computeDistanceBetween2(irisData a,irisData b) { float temp=0; int i=0; for(i=0;i<features;i++) temp+=(a[i]-b[i])*(a[i]-b[i]); temp=sqrt(temp); return(temp); } /********************************************************************/ /* Function to find the maximum distance between the input objects*/ /* Output: the maximum distance */ /* Input : The array of distances between objects */ /********************************************************************/ /*float findMax(float *distance) { int i=0,j=0; float max=distance[0]; for(i=0;i<count;i++) for(j=0;j<count;j++) { if(max<distance[i*count+j]) max=distance[i*count+j]; } return(max); }*/ /********************************************************************/ /* Function to compute the value of an object */ /********************************************************************/ float value(irisData a) { int i=0; float temp=0; for(i=0;i<features;i++) temp+=a[i]*a[i]; return(sqrt(temp)); } /********************************************************************/ /* Function to find the object in the data structure */ /* Output : The position of the object in the data */ /* Input : The object */ /********************************************************************/ int findInData(irisData object,int iFlag) { int i=0,lastCount=0,j,position=-1,flag[features],flg;if(iFlag==1)lastCount=MAXDATA;else{}for(i=0;i<lastCount;i++){ for(j=0;j<features;j++) if(fabs(object[j]-data[i][j])<0.00001) flag[j]=1; else { flag[j]=0; break;} flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /* Function to find whether there is an object on the board at a,b */ /* Output : a flag indicating whether an object is found or not */ /* Input : The row and column indicating the board position */ /********************************************************************/ int found(int a , int b) { if(board[a][b]==9) return 1; else return 0; } /********************************************************************/ /* Function to initialize the initial board */ /* Output : None */ /* Global Structures modified : heaps */ /* Input : Flag indicating the iteration 1: First 0: Second */ /********************************************************************/ void initialise(int flag) { int a,b,i=0,k=0; int loopCount,rowCount,colCount; /* Initialize the row, column and number of heaps */ if(flag==1) { loopCount=count; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=lCount; rowCount=heapRow; colCount=heapRow; } /* Initialize the heaps */ for(i=0;i<loopCount;i++) { heaps[i].count=0; heaps[i].x=0; heaps[i].y=0; heaps[i].disPosition=0; heaps[i].Dmax=0; heaps[i].Dmean=0; } for(i=0;i<loopCount;i++) { /*find a board position which is empty*/ do { a=lrand48()%rowCount; b=lrand48()%colCount; } while(found(a,b)); /*Allocate the object to that place and assign a heap to it*/ heaps[i].x=a; heaps[i].y=b; heaps[i].count=1; heaps[i].Dmax=0; heaps[i].Dmean=0; if(flag==1) { heaps[i].objects[0]=i; for(k=0;k<features;k++)heaps[i].Ocenter[k]=data[i][k]; } else { for(k=0;k<features;k++) heaps[i].Ocenter[k]=newHeaps[i].Ocenter[k]; } heaps[i].disPosition=0; board[a][b]=9; if((debugLevel>0)&&(flag==1))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],data[heaps[i].objects[0]][0]); if((debugLevel>0)&&(flag==0))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],newHeaps[i].Ocenter[0]); } /*initialise the initial heap count*/ heapCount=loopCount; currentRow=rowCount; } /********************************************************************/ /* Function to find whether an heap is present at the location a b */ /* Output : Flag indicating the presencs of the heap */ /* Input : Roe and column indicating the board position */ /********************************************************************/ int findObject(int a,int b) { int i; int position=-1; for(i=0;i<heapCount;i++) { if((heaps[i].x==a)&&(heaps[i].y==b)) { position=i; break; } } return(position); } /********************************************************************/ /* Function initialize the ants */ /* Output : None */ /* Input : Flag indicating the iteration */ /* Global Variables Modified : ant, heapCount, heaps, board */ /********************************************************************/ void initialiseAnts(int flag) { int i=0,a=0,b=0,position,j=0,loopCount=0,rowCount,colCount,k=0; if(flag==1) { loopCount=MAXANTS; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=MAXANTSFORHEAPS; rowCount=heapRow; colCount=heapRow; } for(i=0;i<loopCount;i++) { /*generate random positions for the ants*/ a=lrand48()%rowCount; b=lrand48()%colCount; ants[i].x=a; ants[i].y=b; /*Find if an object is present at that position or not*/ if(board[a][b]==9) { ants[i].carrying=1; /*find the heap at that location*/ position=findObject(a,b); if(position==-1) { printf("\n Error in logic: Ant init \n"); //getchar(); break; } else { /*Assign the heap data to the ant data and decrement the heap count*/ if(flag==1){ for(k=0;k<features;k++)ants[i].data[k]=data[heaps[position].objects[0]][k]; }else{for(k=0;k<features;k++)ants[i].data[k]=heaps[position].Ocenter[k];} for(j=position;j<heapCount-1;j++) heaps[j]=heaps[j+1]; heapCount--; } /*Clear the board position */ board[a][b]=-9; } else ants[i].carrying=-1; ants[i].speed=0; ants[i].dir=lrand48()%8; printf("\n Ant %2d X: %2d Y: %2d Carying : %2d ",i,ants[i].x,ants[i].y,ants[i].carrying); } currentAntCount=loopCount; } /********************************************************************/ /* Function to move the ant */ /* Output: None */ /* Input: Ant to be moved and the flag indicating the iteration */ /********************************************************************/ void moveNext(ant* a,int flag) { int rowCount,colCount; /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; } else { rowCount=heapRow; colCount=heapRow; }*/rowCount=currentRow;colCount=currentRow; /*Depending upon the direction move the ant*/ switch (a->dir) { case 0: a->y++; if(a->y>=colCount)a->y=0; break; case 1: a->x--; a->y++;; if(a->x<0)a->x=rowCount-1; if(a->y>=colCount)a->y=0; break; case 2: a->x--; if(a->x<0)a->x=rowCount-1; break; case 3: a->x--; a->y--; if(a->x<0)a->x=rowCount-1; if(a->y<0)a->y=colCount-1; break; case 4: a->y--; if(a->y<0)a->y=colCount-1; break; case 5: a->x++; a->y--; if(a->x>=rowCount)a->x=0; if(a->y<0)a->y=colCount-1; break; case 6: a->x++; if(a->x>=rowCount) a->x=0; break; case 7: a->x++; a->y++; if(a->x>=rowCount)a->x=0; if(a->y>=colCount)a->y=0; break; } }//end of function /********************************************************************/ /* Function to compute the parameters of the heap */ /* Output: None */ /* Input: The heap whose parameters are to be computed iteration flag*/ /********************************************************************/ void computeHeapParameters(heap* heapData,int flag) { int i=0,j=0,k=0,position=0; float distance=0; float Dmean=0.0; float *dis; float featureSum[features]; float max=0; float sum=0; /* init*/ for(k=0;k<features;k++) featureSum[k]=0; /*Compute the distance of each object and find the maximum distance*/ max=0; if(flag==1){ for(j=0;j<heapData->count;j++) for(i=0;i<heapData->count;i++) { for(k=0;k<features;k++) sum+= (data[heapData->objects[j]][k]-data[heapData->objects[i]][k])*(data[heapData->objects[j]][k]-data[heapData->objects[i]][k]); distance=sqrt(sum); if(max<distance) max=distance; sum=0; } /* Assign the maximum distance to the heap */ heapData->Dmax=max;/*Compute the centre object*/for(i=0;i<heapData->count;i++)for(k=0;k<features;k++) featureSum[k]+=data[heapData->objects[i]][k];for(k=0;k<features;k++)heapData->Ocenter[k]=featureSum[k]*1.0/heapData->count; /* Find the mean distance */if((dis=(float *) calloc(heapData->count,sizeof(float)))==NULL){printf("\nUnable to allocate memory in the compute heap parameters procedure\n");exit(0);} for(i=0;i<heapData->count;i++) { Dmean+=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); dis[i]=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); } heapData->Dmean=Dmean*1.0/heapData->count; /*Compute the most dissimilar object*/ max=dis[0]; for(i=1;i<heapData->count;i++) if(max<dis[i]) { max=dis[i]; position=i; } /*Assign the most dissimilar object to the heap variable*/ for(k=0;k<features;k++) heapData->Odissim[k]=data[heapData->objects[position]][k]; heapData->disPosition=position;free(dis); } else{/* Heap Parameters for the second stage */for(k=0;k<features;k++){ heapData->Odissim[k]=heapData->Ocenter[k];}heapData->disPosition=0;heapData->Dmean=0;heapData->Dmax=0;} }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a single object*/ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject1(ant *a,int position,int flag) { int i,k=0; /*Clear the board*/ board[heaps[position].x][heaps[position].y]=-9; /* Assign the data to the ant*/if(flag==1){ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[0]][k];}else {for(k=0;k<features;k++) a->data[k]=heaps[position].Ocenter[k];} a->carrying=1; /*Copy all the heaps remaining heaps in the structure*/ for(i=position;i<heapCount-1;i++) heaps[i]=heaps[i+1]; /*Decrement the heap count*/ heapCount--; }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a two objects */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject2(ant *a , int position,int flag) { float Pdestroy1=-1; int i=0,k=0; /*Compute the probability to destroy the heap*/ Pdestroy1=lrand48()%13*1.0/12.0; /*If the probability is more than Pdestroy then destroy the heap */ if(Pdestroy1<Pdestroy) { /*pick the object randomly*/ i=lrand48()%2; /* Assign the data to the ant */ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[i]][k]; a->carrying=1; /*Correct the heap parameters*/ heaps[position].count=1; heaps[position].objects[0]=heaps[position].objects[1-i]; computeHeapParameters(&heaps[position],flag); } }//end of function /********************************************************************/ /*Function to pick a object from a heap consisting of more than two object */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /********************************************************************/ void pickObjectn(ant *a,int position,int flag) { int i=0,k=0; /*If the criteria is satsfied then pick the object*/ if((computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)*1.0/heaps[position].Dmean)>Tremove) { a->carrying=1; for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[heaps[position].disPosition]][k]; for(i=heaps[position].disPosition;i<heaps[position].count-1;i++) heaps[position].objects[i]=heaps[position].objects[i+1]; heaps[position].count--; computeHeapParameters(&heaps[position],1); } }//end of function /********************************************************************/ /* Function to pick a object */ /********************************************************************/ void pick(ant *a,int flag) { int position=-1,i=0; float Pload1=-1.0; for(i=0;i<heapCount;i++) { /*Check if a heap is present in the eight neighbouring cells*/ if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if Heap is found*/ if(position!=-1) { /* heap or object found.*/ /*Depending upon the number present in the heap call the corresponding routine*/ switch(heaps[i].count) { case 1: Pload1 = lrand48()%151*1.0/150.0; if(Pload1<Pload) { pickObject1(a,position,flag); } break; case 2: pickObject2(a,position,flag); break; default: pickObjectn(a,position,flag); break; } } } /********************************************************************/ /* Function to drop a object to form a new heap */ /* Output: None */ /* Input: Ant, iteration flag */ /* Global Structure modified : heap, heapCount */ /********************************************************************/ void dropObject(ant* a,int flag) { /*Create a new heap*/ int k=0; heaps[heapCount].count=1; heaps[heapCount].x=a->x; heaps[heapCount].y=a->y; heaps[heapCount].Dmax=0; heaps[heapCount].Dmean=0; heaps[heapCount].disPosition=0; for(k=0;k<features;k++) { heaps[heapCount].Odissim[k]=a->data[k]; heaps[heapCount].Ocenter[k]=a->data[k]; } if(flag==1) {heaps[heapCount].objects[0]=findInData(a->data,flag); /*computeHeapParameters(&heaps[heapCount],flag);*/ } computeHeapParameters(&heaps[heapCount],flag); heapCount++; a->carrying=-1; board[a->x][a->y]=9; }//end of function /********************************************************************/ /* Function to find the heap position during the second iteration */ /* Output: position of the heap */ /* Input: object center of the heap that the ant is carrying */ /* Global Structure modified : none */ /********************************************************************/ int findInNewheaps(irisData object) { int position=-1,i,j=0,flag[features],flg; for(i=0;i<newHeapCount;i++) { for(j=0;j<features;j++) { if(fabs(object[j]-newHeaps[i].Ocenter[j])<0.00001) flag[j]=1; else {flag[j]=0;break;} } flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /*Function to drop a object to a heap consisting of a one or more object */ /* Output: none */ /* Input: Ant, position of the heap , iteration flag */ /* Global Structure modified: heaps,newHeaps */ /********************************************************************/ void dropObject1(ant* a, int position,int flag) { int heapPosition=-1,heapPosition1=-1,i,j,k=0; irisData newData,temp; if(flag==1) { /*Add the object to the heap and compute the heap parameters*/ /*if(heaps[position].count==heaps[position].objCount) {if((junk=(int *)realloc(heaps[position].objects,((heaps[position].objCount+OBJINC)*sizeof(int))))==NULL){printf("\n Cannot Allocate memory to the new object for %d heap",position);exit(0);}heaps[position].objects=junk;heaps[position].objCount+=OBJINC;free(junk); }*/ heaps[position].objects[heaps[position].count]=findInData(a->data,flag); heaps[position].count++; computeHeapParameters(&heaps[position],flag); } else { for(k=0;k<features;k++)temp[k]=heaps[position].Ocenter[k]; heapPosition=findInNewheaps(a->data); heapPosition1=findInNewheaps(heaps[position].Ocenter); if(heapPosition==-1||heapPosition1==-1) { printf("\n error in logic:new heaps\n"); //getchar(); return; } for(k=0;k<features;k++) {newData[k]=(newHeaps[heapPosition].Ocenter[k]*newHeaps[heapPosition].count+newHeaps[heapPosition1].Ocenter[k]*newHeaps[heapPosition1].count)*1.0/(newHeaps[heapPosition].count+newHeaps[heapPosition1].count);newHeaps[heapPosition].Ocenter[k]=newData[k];heaps[position].Ocenter[k]=newData[k]; } computeHeapParameters(&heaps[position],flag); for(i=newHeaps[heapPosition].count,j=0;j<newHeaps[heapPosition1].count;i++,j++) { newHeaps[heapPosition].objects[i]=newHeaps[heapPosition1].objects[j]; } newHeaps[heapPosition].count+=newHeaps[heapPosition1].count; for(i=heapPosition1;i<newHeapCount-1;i++) newHeaps[i]=newHeaps[i+1]; newHeapCount--; } a->carrying=-1; }//end of function /********************************************************************/ /* Function to drop a object */ /* Output: None */ /* Input: Ant, iteration flag */ /********************************************************************/ void drop(ant* a,int flag) { int i, position=-1; float Pdrop1=0.0; /*Find whether we have a heap in the neighbourhood of the cell*/ for(i=0;i<heapCount;i++) { if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if a heap is found*/ if(position!=-1) { /*heap or object found.*/ /*Depending on the number of objects present take action*/ switch(heaps[position].count) { /*If criteria is satisfied then drop the object*/ case 1: if(flag==1) { if((computeDistanceBetween2(a->data,data[heaps[position].objects[0]])*1.0/Dmax)<Tcreate) dropObject1(a,position,flag); } else { if((computeDistanceBetween2(a->data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) dropObject1(a,position,flag); } break; default: if(computeDistanceBetween2(a->data,heaps[position].Ocenter)<computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)) dropObject1(a,position,flag); break; } } else { /*Compute the probability to drop the object*/ Pdrop1 = lrand48()%151*1.0/150; if(Pdrop1<Pdrop) dropObject(a,flag); } }//end of function /********************************************************************/ /* Function to move the ant */ /* Output: none */ /* Input: Ant, iteration flag */ /********************************************************************/ void move(ant* a,int flag) { float pDir; /*Check the speed */ if (a->speed!=0) { /*move in the same direction*/ a->speed--; moveNext(a,flag); } else { /*generate the new direction*/ pDir=lrand48()%17*1.0/16.0; if(pDir<.85) { a->dir=lrand48()%8; } else if(pDir>.95) { a->speed=2; } moveNext(a,flag); } } /********************************************************************/ /* Function to simulate the movement of the ants */ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified: minHeapCount, minHeapPosition */ /********************************************************************/ void iterate(int flag) { int i=0,j=0,k=0,loopCount=0; if (flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS; while (i<MAXITERATIONS) { i++; for(j=0;j<loopCount;j++) { move(&ants[j],flag); if(ants[j].carrying==1) { drop(&ants[j],flag); } else { pick(&ants[j],flag); } } if(debugLevel>0){ for(k=0;k<heapCount;k++) for(j=0;j<heapCount;j++) if((k!=j)&&(heaps[k].x==heaps[j].x)&&(heaps[k].y==heaps[j].y)) { printf("\nerror two heaps with same co ordinates %d %d ",k,j); //getchar(); } k=0; for(j=0;j<heapCount;j++) k+=heaps[j].count; } if(heapCount<minHeapCount) { minHeapCount=heapCount; minPosition=i; } if(debugLevel>0) printf("\n i:%d Heap count %d sum %d",i,heapCount,k); else printf("\n i:%d Heap count %d",i,heapCount); heapSum+=heapCount; /*if(i%updateAfter==0) {adjustBoard(flag); writeIncremental(i,flag);heapSum=0;loopCount=currentAntCount; }*/ } }//end of function /********************************************************************/ /*Function to drop the objects carried by the ants after all the iterations*/ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified:none */ /********************************************************************/ void dropFinal(int flag) { int i=0,j=0,position=-1,loopCount=0; /*if(flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS;*/ loopCount=currentAntCount; for(i=0;i<loopCount;i++) { if(ants[i].carrying==1) { if(flag==1) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position,flag); } } else { /*Find if a heap is present */ do { position=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position,flag); position=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position!=-1); } } } }//end of function /********************************************************************/ /* Function for the implementation of QuickSort */ /* Output: none */ /* Input: data structure, low and high indices */ /* Global structure modified:none */ /********************************************************************/ void quickSort( heap A[], int low,int high ) { int mid=0; if(low<high) { mid=partition(A,low,high); quickSort(A,low,mid); quickSort(A,mid+1,high); } } /********************************************************************/ /* Partition routine used by quick sort */ /* Output: partition location */ /* Input: data , low, high */ /* Global structure modified:none */ /********************************************************************/ int partition(heap a[], int low,int high) { heap temp; int x=0,i=0,j=0; i=low; j=high; x=a[low].count; while (1) { while (a[j].count<x) j=j-1; while (a[i].count>x) i=i+1; if(i<j) { temp=a[i]; a[i]=a[j]; a[j--]=temp; } else return(j); } } /********************************************************************/ /* Function used to write the cluster information */ /* Output: none */ /* Input:iteration flag */ /* Global structure modified:none */ /********************************************************************/ void writeClusterInformation(int flag) { FILE *fp=fopen("center.clt","w"); FILE *fp1; FILE *fp2; FILE *fp3; char temp[80]; int i=0,j=0,k=0; int lastCount=0; int rowCount,colCount,antCount; strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp3=fopen(temp,"a"); if(dataDump) {strcpy(temp,"");sprintf(temp,"%sTot.out",filename);fp1=fopen(temp,"a");strcpy(temp,"");sprintf(temp,"%sObj.out",filename);fp2=fopen(temp,"a");if(fp1==NULL||fp2==NULL)printf("\n Error in opening file in the writer Cluster Information routine\n"); } /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; antCount=MAXANTS; } else { rowCount=heapRow; colCount=heapRow; antCount=MAXANTSFORHEAPS; }*/ rowCount=currentRow; colCount=currentRow; antCount=currentAntCount; if(fp==NULL) { printf("\n Unable to open cluster center output file \n"); /*return;*/ exit(0); } /*sort the array according to the count value and write the value of the top three elements*/ if((flag==1)&&(!EntireHeaps)) quickSort(heaps,0,heapCount); if(EntireHeaps) {if(flag==1) lastCount=heapCount;else lastCount=newHeapCount; } else lastCount=c; for(i=0;i<lastCount;i++) { if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",newHeaps[i].Ocenter[k]); fprintf(fp,"\n"); } else { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); fprintf(fp,"\n"); } } if(dataDump) { fprintf(fp1,"\n Information from the Ant Based Algorithm \n"); fprintf(fp1,"\n Important Parameters : Board %d X %d Ants : %d Iterations %d Total Heaps %d ",rowCount,colCount,antCount,MAXITERATIONS,lastCount); } if(flag==0) { if(dataDump) { fprintf(fp1," TCreateForHeaps %f \n",TcreateForHeaps); fprintf(fp2,"\nTotal Heaps : %d\n",heapCount); fprintf(fp2,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); } fprintf(fp3,"\n@ %d\n",lastCount); } else if(dataDump) fprintf(fp1,"\n");if(dataDump) { fprintf(fp1,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); for(i=0;i<lastCount;i++) if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp2,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); } fprintf(fp1," %5d\n",newHeaps[i].count); fprintf(fp2," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp1," %5d\n",heaps[i].count); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]); fprintf(fp1," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]); fprintf(fp1," %5d\n",heaps[i].count); }} if(flag==0) { if(dataDump) fprintf(fp1,"\n Objects in the heaps \n");for(i=0;i<newHeapCount;i++) { if(dataDump) fprintf(fp1,"\n\n Heap %d\n \n",i+1);fprintf(fp3,"# %d %d\n",i ,newHeaps[i].count); for(j=0;j<newHeaps[i].count;j++){ for(k=0;k<features;k++){ fprintf(fp3,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]); if(dataDump) fprintf(fp1,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]);} if(dataDump) fprintf(fp1,"\n"); fprintf(fp3,"\n"); } } } fclose(fp); fclose(fp3); if(dataDump) { fclose(fp1);fclose(fp2); }}//end of flie /********************************************************************/ /* Function to initialise the new heaps */ /* Output: none */ /* Input:new Heap structure */ /* Global structure modified:none */ /********************************************************************/ void initialiseNewHeaps(heap newHeaps[]) { int i=0,j=0; for(i=0;i<lCount;i++) { newHeaps[i].count=0; for(j=0;j<features;j++) newHeaps[i].Ocenter[j]=V[i][j]; newHeaps[i].x=heaps[i].x; newHeaps[i].y=heaps[i].y; } }//end of function /********************************************************************/ /* Function to initialise the new heaps */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ int findPosition(int i) { int j,position=0; for(j=1;j<lCount;j++) { if(U[j][i]>U[position][i]) position=j; } printf("\n Position %d ",position); return(position); }//end of function find position /********************************************************************/ /* Function to add object */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ void addObject(int object,heap * heapPosition) { heapPosition->objects[heapPosition->count]=object; heapPosition->count++; }//end of function add object /********************************************************************/ /* Function to harden the outputs obtained from fcm */ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/ void harden(heap newHeaps[]) { int i,heapPosition=-1,sum=0,j=0; /*initialise the new heaps*/ initialiseNewHeaps(newHeaps); for(i=0;i<count;i++) { heapPosition=findPosition(i); addObject(i,&newHeaps[heapPosition]); } /* To check for degenerate partitions*/ for(i=0;i<lCount;i++) { if(newHeaps[i].count==0){for(j=i;j<lCount-1;j++){newHeaps[j]=newHeaps[j+1];}lCount--;i--;} } newHeapCount=lCount; for(i=0;i<lCount;i++) computeHeapParameters(&newHeaps[i],1); if(debugLevel>0) { for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\n sum = %d",sum);} }//end of function/********************************************************************/ /* Function to initialize the initial parameters for the ant algorithm*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void init() { int i=0,j=0; for(i=0;i<MAXROWS;i++) for(j=0;j<MAXCOLS;j++) board[i][j]=-9; heapCount=0; newHeapCount=0; heapRow=0; minPosition=-1; minHeapCount=100000; for(i=0;i<MAXANTS;i++) { ants[i].carrying=-1; ants[i].x=-1; ants[i].y=-1; ants[i].speed=-1; ants[i].dir=-1; } } /********************************************************************/ /* Function to initialize the initial board */ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void initialiseBoard() { int i,j; for(i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; }/********************************************************************/ /* Function to harden the outputs obtained from fcm(2nd stage)*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: Cluster center , cluster center count*/ /********************************************************************/void harden1() { int i=0,heapPosition=-1; for(i=0;i<heapCount;i++) cenCount[i]=0; for(i=0;i<n;i++) { heapPosition=findPosition1(i); addObject1(i,heapPosition); } writeInfo(); }//end of function/********************************************************************/ /* Function to find to which class the object belongs */ /* Output: Class number */ /* Input: object position */ /* Global Structure Modified: None */ /********************************************************************/int findPosition1(int i) { int j,position=0; for(j=1;j<heapCount;j++) { if(U[j][i]>U[position][i]) position=j; } return(position); }//end of function find position/********************************************************************/ /* Function to Write the output of the hardened objects to file*/ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/void writeInfo(){int i=0,j=0,k=0;FILE *fp=fopen("fcm.out","a");if(fp==NULL){printf("\n Unable to open fcm output file \n");return;}fprintf(fp,"\n@ %d\n",heapCount);for(i=0;i<heapCount;i++){fprintf(fp,"# %d %d\n",i,cenCount[i]);for(j=0;j<cenCount[i];j++){for(k=0;k<s;k++)fprintf(fp,"%8.2f ",clsCen[i][j][k]/scale[k]+minInput[k]);fprintf(fp,"\n");}}fclose(fp);return;}/********************************************************************/ /* Function to add a object to a cluster (2nd stage) */ /* Output: none */ /* Input: object poistion , cluster position */ /* Global Structure Modified: Cluster object and cluster count*/ /*******************************************************************/void addObject1(int object,int heapPosition) { int k=0; for(k=0;k<features;k++) clsCen[heapPosition][cenCount[heapPosition]][k]=X[object][k]; cenCount[heapPosition]++; return; }//end of function add object/********************************************************************/ /* Function to read the original classification of objects */ /* Output: none */ /* Input: none */ /* Global Structure Modified: None */ /*******************************************************************/void readOrg(){int i=0,k=0;char temp[80];FILE *fp;//= fopen(dataname,"r");strcpy(temp,"");sprintf(temp,"%sFull.data",filename);fp=fopen(temp,"r");if(fp==NULL){printf("\n Unable to open full data input file ");exit(0);}for(i=0;i<n;i++){fscanf(fp,"%f ",&orgData[i][0]);for(k=1;k<s+1;k++)fscanf(fp,"%f ",&orgData[i][k]);}return;}// end of function/********************************************************************/ /* Function to classify the objects in different clusters */ /* Output: none */ /* Input: the cluster objects, the original classification, */ /* number of objects in the cluster,file to write the data */ /* Global Structure Modified: None *//********************************************************************/int analysisData(float data[][s],float orgData[n][s+1],int count,FILE * fp){int i=0,j=0,k=0,type=1,max=0;heapInfo info;for(i=0;i<c;i++){info.classObj[i]=0;}info.total=0;info.total=count;for(i=0;i<count;i++)for(j=0;j<n;j++){type=1;for(k=0;k<s;k++)if(fabs(data[i][k]-orgData[j][k+1])>errThresh){type=-1;break;}if(type!=-1){info.classObj[(int)orgData[j][0]-1]++;break;}}max=0;for(k=0;k<c;k++){if(info.classObj[k]>info.classObj[max])max=k;fprintf(fp,"\nClass %d Objects % d ",k+1,info.classObj[k]);}j=0;for(k=0;k<c;k++){if(k!=max)j+=info.classObj[k];}fprintf(fp,"\n Total errors : %d \n",j);return(j);}//end of analyse/********************************************************************/ /* Function to read the cluster information */ /* Output: none */ /* Input: input file pointer , output file pointer */ /* Global Structure Modified: None *//********************************************************************/void readFCM(FILE* fp,FILE *fp1){int i=0,j=0,k=0,l=0;int totalRuns=0,heapCount=0,junk=0,sum=0;char ch;FILE *fp2=fopen("errors.out","a");ch = 'c'; while (ch != '$') fscanf (fp, "%c", &ch);fscanf(fp,"%d\n",&totalRuns);printf("\n total runs %d ",totalRuns);for(l=0;l<totalRuns;l++){fscanf(fp,"%c",&ch);fscanf(fp,"%d\n",&heapCount);fprintf(fp1,"\n \nExperiment %d \n ",l+1);sum=0;for(i=0;i<heapCount;i++){fscanf(fp,"%c",&ch);fscanf(fp," %d %d\n",&junk,&clsCenCount[i]);for(j=0;j<clsCenCount[i];j++)for(k=0;k<s;k++)fscanf(fp,"%f",&fcmData[i][j][k]);fscanf(fp,"\n");fprintf(fp1,"\n\n Heap %d Total Objects %d \n",i+1,clsCenCount[i]);sum+=analysisData(fcmData[i],orgData,clsCenCount[i],fp1);}fprintf(fp2," %3d %3d %3d \n",l,sum,heapCount);}fprintf(fp2,"\n --------------------------\n");fclose(fp2);return;}//end of function/********************************************************************/ /* Function to update the board parameters */ /* Output: none */ /* Input: none */ /* Global Structure Modified: board size, ant count *//********************************************************************/void adjustBoard(int flag){int newRow=0,newAnt=0,antDiff=0,antsKilled=0,i=0,position[MAXANTS],position1=-1,j=0,k=0,a,b; newRow= (int)ceil(sqrt(4.0*heapSum/updateAfter)); newAnt= (int)ceil((heapSum*1.0/updateAfter)*1.0/3.0); if(newAnt<minAnts)newAnt=minAnts; if(newRow<rowMin)newRow=rowMin;antDiff=currentAntCount-newAnt; if((antDiff>0)&&(newAnt>=minAnts)) {for(i=0;i<currentAntCount;i++){if(ants[i].carrying==-1){position[antsKilled++]=i;}} if(antsKilled>=antDiff){for(i=0;i<antDiff;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1];for(k=i+1;k<antsKilled;k++)position[k]--; } currentAntCount=newAnt; }else {for(i=0;i<antsKilled;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1]; for(k=i+1;k<antsKilled;k++)position[k]--; }if(flag==1) { for(i=currentAntCount-1,k=0;k<antDiff-antsKilled;k++,i--) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position1,flag); }else { dropObject(&ants[i],flag); } } } else { //flag is zero 2nd stage /*Find if a heap is present */ do { position1=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position1].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position1,flag); position1=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position1!=-1); }//end else currentAntCount=newAnt;}//end elsecurrentAntCount=newAnt;}//end iffor(i=0;i<newAnt;i++){if((ants[i].x>=newRow)||(ants[i].y>=newRow)) { a=lrand48()%newRow; b=lrand48()%newRow; ants[i].x=a; ants[i].y=b; }} //Done with ants, now adjust the boardif((currentRow>newRow)&&(newRow>=rowMin)){for(i=0;i<heapCount;i++){if((heaps[i].x>=newRow)||(heaps[i].y>=newRow)) {do { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionheaps[i].x=a;heaps[i].y=b;board[a][b]=9;}//end if}//end for for(i=0;i<currentAntCount;i++){if((ants[i].carrying==1)&&((ants[i].x>=newRow)||(ants[i].y>=newRow))){//adjust the ant locationdo { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionants[i].x=a;ants[i].y=b;}//end if}//end for currentRow=newRow;}//end if }//end of function void writeIncremental(int iteration,int flag){FILE *fp=fopen("dump.txt","w");int i=0,j=0,k=0;fprintf(fp,"Stage %d\n",flag);fprintf(fp,"Board %d\n",currentRow);fprintf(fp,"Ants %d\n",currentAntCount);fprintf(fp,"Iteration %d\n",iteration);fprintf(fp,"Heaps %d\n",heapCount); if(flag==0)fprintf(fp,"NewHeapCount %d\n",newHeapCount); fprintf(fp,"Ants\n");for(i=0;i<currentAntCount;i++){fprintf(fp,"%d %d %d %d %d ",ants[i].x,ants[i].y,ants[i].carrying,ants[i].speed,ants[i].dir);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",ants[i].data[k]);fprintf(fp,"\n");}fprintf(fp,"Heaps\n");for(i=0;i<heapCount;i++){fprintf(fp,"%d %d %d %d %8.2f %8.2f \n",heaps[i].x,heaps[i].y,heaps[i].count,heaps[i].disPosition,heaps[i].Dmax,heaps[i].Dmean);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Ocenter[k]);fprintf(fp,"\n");for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Odissim[k]);fprintf(fp,"\n");if(flag==1){for(j=0;j<heaps[i].count;j++)fprintf(fp,"%d ",heaps[i].objects[j]);fprintf(fp,"\n");}}if(flag==0){fprintf(fp,"newHeaps\n");for(i=0;i<newHeapCount;i++){fprintf(fp,"%d\n",newHeaps[i].count);for(j=0;j<newHeaps[i].count;j++)fprintf(fp,"%d ",newHeaps[i].objects[j]);fprintf(fp,"\n");}}fclose(fp);}//end of function/********************************************************************/ /* Function Main */ /********************************************************************/ int main(int argc ,char** argv) { int sum=0,k=0,i=0,j=0; char temp[80]; FILE *fp=fopen("fcm.out","w"); FILE *fp1; FILE *fp2=fopen("antAnalysis.out","a"); FILE *fp3=fopen("fcmAnalysis.out","a"); FILE *fp4=fopen("errors.out","w"); FILE *fp5; fclose(fp4); sprintf(temp,"%sObj.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sTot.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp1=fopen(temp,"w"); fprintf(fp,"\n$%d",EXPRUN); fprintf(fp1,"\n$%d",EXPRUN); fclose(fp); fclose(fp1); if(argc==2)sscanf(argv[1],"%d",&debugLevel); printf("\n Debug level %d\n",debugLevel); for( i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; //Read from the file readInput(); //Compute the distance of all the points if(maxDist) { Dmax=computeDistance(); //Compute the maximum distance fp5=fopen("maxData.txt","w");fprintf(fp5,"%f",Dmax);fclose(fp5); } else {fp5=fopen("maxData.txt","r");fscanf(fp5,"%f",&Dmax);fclose(fp5); } printf("\n %f \n",Dmax); //Initialise the board for(k=0;k<EXPRUN;k++) { init(); sum=0; srand48(state1[k]); initialiseBoard(); initialise(1); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(1); printf("\n %d \n",heapCount); //Simulate the working of ants iterate(1); //drop the objects after all the iterations dropFinal(1); //to verify the correctness for(i=0;i<heapCount;i++) sum+=heaps[i].count; //write the cluster centers to the file writeClusterInformation(1); printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); //getchar(); //Run FCM // heapCount=2973;/* To be commented */ printf("\n\n k %d \n\n",k); Fcm(data); //compute new board size. lCount=heapCount; heapRow=(int)ceil(sqrt(4*heapCount)); newHeapCount=lCount; printf("\n LCount %d newHeapCount %d heap Row %d \n",lCount,newHeapCount,heapRow); //harden the objects harden(newHeaps); //iterate with the heaps as the objects. initialiseBoard(); initialise(0); for(i=0;i<lCount;i++) computeHeapParameters(&heaps[i],0); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(0); printf("\n %d \n",heapCount); //getchar(); //Simulate the working of ants iterate(0); dropFinal(0); writeClusterInformation(0); sum=0; for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); // getchar(); Fcm(data); harden1(); } fp=fopen("fcm.out","a"); fp1=fopen(temp,"a"); fprintf(fp,"\n"); fprintf(fp1,"\n"); fclose(fp); fclose(fp1); fp=fopen("fcm.out","r"); fp1=fopen(temp,"r");printf("\n Before read org\n");readOrg();printf("\nafter read org\n");readFCM(fp1,fp2);printf("\n After 1st read fcm\n");readFCM(fp,fp3);printf("\n After 2 fcm read \n");return(1); }//end of main /****************************************************************/ float NORM(feature , feature); void find_covar(); void Fcm (irisData Data[MAXDATA]) { int i,j,l; FILE *ofile; char temp[80]; int flag=0;//added by parag FILE *iniClsCen=fopen("center.clt","a+"); if(iniClsCen==NULL) { printf("\n Unable to open the initial cluster center file\n"); printf("\n choosing random cluster centers....\n"); flag=1; } strcpy(temp,""); sprintf(temp,"%s.data",filename); strcpy (fname,temp); /* Read from this file */ m=2.0; /* The exponent */ /*GET_INPUTS1(fname);*/ /* read in feature vectors */ for (j=0; j<n ; j++) /* Read File in row-major */ for (i=0; i<s ; i++) /* format */ X[j][i]=Data[j][i]; Random_seed=state1[run];/*randseed*/ srand48(Random_seed); for (run=0;run<TOTRUNS;run++) { //flag=1;//for testing random values if (EntireHeaps) lCount=heapCount; else lCount=c; for(i=0;i<lCount;i++) for(j=0;j<s;j++) V[i][j]=0; for(i=0;i<lCount;i++) { for(l=0;l<s;l++) { if(flag==1) { rand_index = lrand48() % n; V[i][l] = X[rand_index][l]; } else { fscanf(iniClsCen,"%f ",&V[i][l]); } }//end for } eps=0.001; stop = FALSE; /* This loop finds the final cluster center and the corresponding U values */ z = 0; while (stop == FALSE) { z++; UMAT(U,V,X); /** Update the U matrix **/ stop = FINISHED(U1,eps); CLUSTER(U,X); /** Get new cluster center **/ printf("Iteration: %d\n\n", z); } /* end while */ printf("Number of iterations: %d\n\n", z);strcpy(temp,""); sprintf(temp,"%sFCM.out",filename);if(dataDump) Output(temp); /* output the results */ }/*end for*/ if(dataDump) { ofile=fopen(temp,"a"); for (i=0; i <= mins; i++) fprintf(ofile, "Min %d of %10.3f occurred %d times\n", i, mintab[i], mincount[i]); fprintf(ofile, "Average iterations %f\n", (float)aveit/(float)TOTRUNS); fclose(ofile); } }/* end Main */ /* The GET_INPUTS1 procedure opens an input file, reads the number of input vectors, the number of features per vector, the number of clusters, and epsilon, then it reads the input values */ void GET_INPUTS1(char fname[]) //char fname[]; { /* Parameters: fname -- name of file containing input info. */ FILE *infile ;//*fopen(); //char junk[10][80]; char realfname[80]; char ch; char fileName1[80]; //int temp[10], i, j, inputs, outputs, count; int i,j; sprintf (realfname, "%s", fname); /* open input file */ if(normalize==1) strcpy(fileName1,"gtest1.data"); else strcpy(fileName1,fname); if((infile = fopen (fileName1, "r")) == NULL) printf("\n CAN'T OPEN %s\n",realfname); else { ch = 'c'; /* Discard leading comments */ while (ch != '#') fscanf (infile, "%c", &ch); for (j=0; j<n ; j++) /* Read File in row-major */ { /* format */ for (i=0; i<s ; i++) fscanf (infile, "%f", &X[j][i]); /* fscanf (infile, "%d", &temp[1]); */ /* end for */ } /* end for */ fclose(infile); /* close input file */ }/* end else */ } /* end GET_INPUTS1 */ /* The NORM function computes the norm of two vectors, x and v, of dimension s. This gives an indication of the distance between them */ float NORM( feature x, feature v) //feature x, v; { /* Parameters : x -- a local copy of an input vector v -- a local copy of a cluster center */ int i,j; /* loop variable */ double sum; /* the square root of sum is the norm; sum is the sum of the differences squared */ float mat1[s]; float mat2[s]; if (maha) { for (i=0; i<s; i++) mat1[i]=x[i]-v[i]; for(i=0;i<s;i++) { sum =0; for(j=0;j<s;j++) sum += mat1[j] * inv_cov[j][i]; mat2[i] = sum; } sum =0; for(j=0;j<s;j++) sum += mat1[j]*mat2[j]; } else { sum = 0; for(j=0;j<s;j++) sum += (x[j] - v[j])* (x[j] - v[j]); } return (float)(sqrt(sum)); } /* end NORM */ /* The UMAT procedure calculates the updated U matrix according to Bezdek's formula. Its side-effect is the update of the global array U1 */ void UMAT( matrix U,center V, objects X) /*matrix U; center V; objects X;*/ { /* Parameters: U, V, and X: same as in main program */ int i, j, k,l ;/* loop variables *///, class /* class whose cluster center //is closest to pattern k */; float d1,d2,d; float sum; int exact; for (k=0;k<n;k++) { /*printf("\n k %d ",k);*/ exact=false; for (i=0;i<lCount;i++) { sum=0; for (j=0;j<lCount;j++) { d1=NORM(X[k],V[i]); d2=NORM(X[k],V[j]); if(d2!=0) { d= d1/d2; d= d * d;/* pow(d1/d2,2.0/(m-1.0)); */ sum+=d; } else { exact = true; for(l=0;l<lCount;l++) if (l==j) U1[l][k]=1.0; else U1[l][k]=0.0; break; } } if (exact!=true) U1[i][k]=1.0/sum; } } } /* end UMAT */ /* The function FINISHED determines if a termination occurs. If not it updates U with U1, so its side-effect is the potential modification of U */ BOOLEAN FINISHED( matrix U1,float eps) //matrix U1; float eps; { /* Parameters: U1, eps-- same as in main */ float sum; /* sum of squared differences between corresponding elements of U and U1 */ int i,k; /* loop control variabes */ BOOLEAN finished; /* set to true if all corresponding elements are within epsilon */ finished = TRUE; sum = 0; for (i=0; i<lCount; i++) for (k=0; k<n; k++) sum += (U[i][k] - U1[i][k])*(U[i][k]-U1[i][k]); if (sqrt(sum) > eps) { finished = FALSE; for (i=0; i<lCount; i++) for (k=0; k<n; k++) U[i][k] = U1[i][k]; } /* end if */ return finished; } /* end FINISHED */ /* The CLUSTER procedure determines cluster centers in V for the c classes being searched for. The global array V is updated */ void CLUSTER( matrix U, objects X) //matrix U; objects X; { /* Parameters: U, X -- as in main */ int i, j, k; /* loop control variables */ feature num; /* numerator in the cluster center computation formula presented by Bezdek */ float denum; /* denumenator in the obove formula */ for (i=0; i<lCount; i++) { denum = 0; for (j=0; j<s; j++) { num[j] = 0; for (k=0; k<n; k++) num[j] += U[i][k] * U[i][k] * X[k][j]; /* pow(U[i][k],m) * X[k][j]; */ } /* end for */ for (k=0; k<n; k++) denum += U[i][k] * U[i][k]; /* pow(U[i][k],m); */ for (j=0; j<s; j++) V[i][j] = num[j] / denum; } /* end for */ } /* end CLUSTER */ float Compute_Jm(center V, objects X) //center V; //objects X; { int i, k,found; double Jm_value; float u,dik; Jm_value = 0; for (k=0; k<n; k++) { found = FALSE; for (i=0; i<lCount; i++) { dik=NORM(X[k],V[i]); dik=dik*dik; if (dik==0.0) { if (found == FALSE) { u=1.0; found = TRUE; printf("found the case with dik=0\n"); } else { printf("\n cant proceed with this initialization"); exit(1); } } else { if (found != TRUE) u=U1[i][k]; /* get_Uvalue(V,X,dik,k); */ else u=0.0; } Jm_value += u * u * dik;/* pow(u, m) * dik; */ } } return (Jm_value); } /* end Compute_Jm */ /* The Output procedure outputs the U matrix which gives the fuzzy measure of each feature belonging to a cluster center. It also outputs the cluster center for each class */ void Output(char fname[]) //char fname[80]; /* Parameters: U, V -- same as in main */ { int i, j, found; /* loop control variables */ float J2c; if ((fp=fopen(fname,"a"))==NULL) printf("\n CAN'T OPEN %s\n",fname); else { fprintf(fp,"\n The cluster centers are: \n"); fprintf(fp,"\n \n"); for (i=0; i<lCount; i++) { fprintf(fp,"\nCluster center %d: ",i+1); fprintf(fp,"\n"); for (j=0; j<s; j++) fprintf(fp,"%8.7f ",V[i][j]); } /* end for */ fprintf(fp,"\nThe membership grades for the feature vectors are:\n"); for (j=0; j<n; j++) { fprintf(fp,"\n"); for (i=0; i<lCount; i++) fprintf(fp," %8.7f",U[i][j]); } /* end for */ } /* end if */ J2c= Compute_Jm(V,X); found =0; for (i=0;i<= mins; i++){ if ((found == 0) && ((J2c - mintab[i]) < .001) && ((J2c - mintab[i]) > -.001)){ mincount[i]++; found = 1; } } if (found == 0){ mins++; mintab[mins]=J2c; mincount[mins]=1; } fprintf(fp,"\nJ%3.1f = %f", m,J2c); fprintf(fp, "Number of iterations: %d\n\n", z); aveit=aveit + z; fclose(fp); } /***************************************************************/ void find_covar(int m) //int m; { int i,j,k; float mean[s],sum; for (i=0;i<s;i++) mean[i]=0; for (i=0;i<s;i++) for (j=0;j<m;j++) mean[i]+=X[j][i]; for (i=0;i<s;i++) mean[i]/=m; for (i=0;i<s;i++) for (j=0;j<s;j++) { sum=0; for (k=0;k<m;k++) sum+=(X[k][i]-mean[i])*(X[k][j]-mean[j]); Y[i][j]=sum/m; } }
Parag Kanade/fuzzy ants/Gauss500-4/headerStatic.h
/********************************************************************//* Ant Class parameters *//* SPEED # amplitude of moves [1,10] *//* P direction Probability to move in the same direction [.5,1] *//* Max carry : Maximum object carrying time [20,200] *//* P load Probability to pick up a single object [0.4,0.8] *//* P destroy probability to destroy a heap of two objects [0,0.6] *//* T remove min. dissimilarity necessary for removing an object *//* from a heap [.1,.2] *//* T create max dissimilarity permitted for creating a heap[.05,.2]*//********************************************************************/ #include <stdio.h>#include <math.h>#include <string.h>#include<stdlib.h>#include <ctype.h>#include <time.h>#define MAXANTS 167#define MAXDATA 500#define MAXANTSFORHEAPS 45#define MAXITERATIONS 1000#define MAXROWS 45#define MAXCOLS 45#define EXPRUN 10#define Tremove 1.50#define Tcreate 0.5#define Pdrop 0.2#define Pdestroy 0.3#define Pload 0.3#define normalize 0#define EntireHeaps 1#define TcreateForHeaps 0.19#define features 2#define filename "gauss500_04"#define errThresh 0.1#define dataDump 1#define maxDist 1#define INITIALOBJECTS 75#define OBJINC 10/* some type definitions to make C code a little more readable */#define TRUE 1#define FALSE 0#define n MAXDATA /* number of input vectors */#define s features /* number of features */#define c 5 /* number of clusters */#define TOTRUNS 1 /* number of V's to write out */#define false 0#define true 1#define maha 0#define square 0extern int count;int debugLevel=0;/* To debug the code and verify the correctness of algorithms*/int currHeapCount=0;typedef int BOOLEAN;typedef short TYPE_IN_DATA; /* Type of input binary data */typedef float feature[s]; /* Type of each input; made up of input features */typedef float irisData[s];typedef feature objects[MAXDATA]; /* Type of array holding all inputs */typedef feature center[MAXDATA]; /* Type of array holding cluster centers */typedef float matrix[MAXDATA][MAXDATA];/* Type of the matrix containing membership grades */typedef struct Heap {float Dmax;//maximum dissimilar distanceirisData Ocenter;//center objectfloat Dmean;//mean of the distance between the center and all the objectsirisData Odissim;//most dissimilar objectint x;//x position on the boardint y;//y position on the boardint count;//number of objects in the heapsint disPosition;//most dissimilar objectint objects[MAXDATA];int objCount;}heap;typedef struct Ant{int x;int y;int carrying;int speed;int dir;irisData data;}ant;float orgData[n][s+1];float fcmData[MAXDATA][n][s];int clsCenCount[MAXDATA];int currentRow=0;int currentAntCount=0;int updateAfter=50;int heapSum=0;int minAnts=3;int rowMin=5;typedef struct HeapInfo{int total;int classObj[c];} heapInfo;/*heapInfo info[MAXDATA];*//********************************************************************//***Function decelarations*//********************************************************************//***For ant based algorithm*/void readInput();float computeDistance();float computeDistanceBetween2(irisData a,irisData b);float findMax(float *distance);float value(irisData a);int found(int a , int b);void initialise(int flag);int findObject(int a,int b);void initialiseAnts(int flag);void moveNext(ant* a,int flag);void computeHeapParameters(heap* data,int flag);void pickObject1(ant *a,int position,int flag);void pickObject2(ant *a , int position,int flag);void pickObjectn(ant *a,int position,int flag);void pick(ant *a,int flag);void dropObject(ant* a,int flag);int findInNewheaps(irisData object);void dropObject1(ant* a, int position,int flag);void drop(ant* a,int flag);void move(ant* a,int flag);void iterate(int flag);void dropFinal(int flag);int partition(heap a[], int low,int high);void quickSort( heap A[], int low,int high ) ;void writeClusterInformation(int flag);void initialiseNewHeaps(heap newHeaps[]);int findPosition(int i);void harden(heap newHeaps[]);void harden1();int findPosition1(int );void writeInfo();void addObject1(int ,int);void readFCM(FILE *,FILE *);void readOrg();int findInData(irisData input,int iflag);void adjustBoard(int flag);void writeIncremental(int iteration,int flag);/********************************************************************//***For FCM algorithm*/void GET_INPUTS1(char []);void UMAT( matrix,center,objects);BOOLEAN FINISHED(matrix, float);void CLUSTER( matrix, objects);void Output(char[]);void Fcm();/********************************************************************/
Parag Kanade/fuzzy ants/Gauss500-4/maxData.txt
1.432105
Parag Kanade/fuzzy ants/Gauss500-5/gauss500_05.data
gauss Data | |
# | |
3.2079091 | 7.7210589 |
3.2231833 | 8.624442 |
3.2724274 | 7.7211989 |
3.3905861 | 6.8528257 |
3.5263206 | 7.1902709 |
3.5446515 | 6.9092366 |
4.0817641 | 6.2932327 |
4.1329588 | 6.7909656 |
4.2061908 | 6.5587698 |
4.2294541 | 7.7094674 |
4.2311605 | 6.1842931 |
4.3729459 | 6.6146591 |
4.451783 | 8.0942238 |
4.4631214 | 5.9776029 |
4.4641181 | 7.9918609 |
4.5092126 | 7.2028537 |
4.5249635 | 5.8857945 |
4.5408484 | 7.0938419 |
4.5538585 | 8.1353191 |
4.580998 | 7.1703637 |
4.6221661 | 8.0532502 |
4.6675926 | 7.5078748 |
4.6693178 | 7.0258803 |
4.6757058 | 5.5386359 |
4.6875167 | 8.3955603 |
4.8136569 | 8.2550441 |
4.8330733 | 8.7522282 |
4.8388063 | 8.8021392 |
4.8394463 | 8.1968265 |
4.8564329 | 5.7743203 |
4.8694154 | 6.2415617 |
4.8838473 | 7.8844967 |
4.9151302 | 6.5118873 |
4.9197918 | 8.408129 |
4.9546596 | 8.2040109 |
4.9707417 | 6.4312104 |
5.0135107 | 7.9468569 |
5.0456382 | 7.6968997 |
5.0662513 | 7.9026477 |
5.0731757 | 9.0607237 |
5.0940184 | 9.3846903 |
5.0998003 | 7.0196854 |
5.1062588 | 7.8665536 |
5.1113574 | 6.7466426 |
5.1401502 | 6.322823 |
5.164504 | 6.3772491 |
5.167721 | 8.491692 |
5.1792337 | 7.1921312 |
5.189034 | 7.9209093 |
5.1923355 | 9.0269859 |
5.2420277 | 6.6866669 |
5.2563394 | 6.6318602 |
5.2646653 | 7.3621656 |
5.277839 | 7.5903912 |
5.2840827 | 6.3948904 |
5.3134128 | 7.7465675 |
5.3432966 | 6.3024976 |
5.3588688 | 6.6395169 |
5.3773154 | 7.509691 |
5.3923682 | 7.7704754 |
5.3928396 | 7.9307354 |
5.4097375 | 7.0243664 |
5.4250905 | 8.2957807 |
5.4256467 | 9.1909088 |
5.429859 | 8.6389274 |
5.4383383 | 8.5945946 |
5.4499816 | 7.3406544 |
5.4648999 | 7.7633964 |
5.5101871 | 7.0922003 |
5.5814278 | 8.4753996 |
5.5883151 | 6.204994 |
5.6065497 | 7.7304895 |
5.6109218 | 8.4108913 |
5.6800216 | 7.6595682 |
5.6865731 | 6.8736266 |
5.7364618 | 7.1109649 |
5.7834804 | 8.4478511 |
5.806937 | 6.2154877 |
5.8505015 | 6.7495611 |
5.8894656 | 7.5845772 |
5.898071 | 8.4421334 |
5.9191638 | 8.1379257 |
5.9232595 | 6.3691164 |
5.9263071 | 6.3499483 |
5.9336875 | 7.5430657 |
5.9561075 | 6.014345 |
5.956787 | 6.2913721 |
5.9597375 | 7.9233632 |
5.9647258 | 7.5541938 |
6.0014664 | 5.5959308 |
6.0967613 | 7.3460918 |
6.1113619 | 8.956129 |
6.1393133 | 7.1290369 |
6.2427451 | 8.3293623 |
6.2447324 | 6.4055278 |
6.2808958 | 8.1849711 |
6.2958248 | 8.52221 |
6.3333881 | 8.8926755 |
6.3770667 | 8.148263 |
6.3872811 | 7.0834977 |
6.3943806 | 5.2047041 |
6.4231133 | 9.1428545 |
6.4242463 | 8.7437029 |
6.4737188 | 9.1960809 |
6.5434832 | 6.9540165 |
6.5542301 | 8.6514457 |
6.556613 | 7.6792214 |
6.5569343 | 8.3557038 |
6.5681878 | 6.7334969 |
6.6154429 | 8.9919154 |
6.6573287 | 7.6323181 |
6.7523585 | 8.6764836 |
6.7530329 | 5.6970322 |
6.8855847 | 7.1092405 |
6.9202943 | 7.6878621 |
7.0692918 | 8.4614043 |
7.094251 | 8.9986657 |
7.2213603 | 6.8859654 |
7.29025 | 8.1231551 |
7.3047409 | 8.0529775 |
7.3807576 | 6.8897184 |
7.4022501 | 8.2157411 |
7.5258683 | 8.6077935 |
7.5602902 | 8.0202276 |
7.5928493 | 9.9473488 |
7.6337921 | 6.0477399 |
12.5649633 | 14.8199028 |
12.9492476 | 15.2417831 |
12.9639843 | 14.1301841 |
13.226796 | 13.0896456 |
13.5160477 | 14.339618 |
13.5494966 | 15.3187034 |
13.7321392 | 13.3091876 |
13.78872 | 13.9671922 |
13.8074223 | 14.160413 |
13.8077218 | 15.2829668 |
13.8401064 | 14.4340778 |
13.8887826 | 15.182616 |
13.9385494 | 13.0826968 |
14.0173279 | 16.015934 |
14.1333175 | 15.0641202 |
14.1493846 | 11.5813131 |
14.3247616 | 14.5008158 |
14.3596552 | 14.4300021 |
14.4498757 | 14.4660964 |
14.5039886 | 15.1291981 |
14.5577834 | 12.1352935 |
14.6243969 | 13.1862597 |
14.6653361 | 13.8993512 |
14.6752921 | 13.2522435 |
14.6978867 | 13.9182312 |
14.7050083 | 16.974634 |
14.7473609 | 13.2485078 |
14.7493806 | 13.5129937 |
14.7887799 | 13.8588077 |
14.836351 | 13.2174683 |
14.8726451 | 14.0834742 |
14.8903508 | 12.7250099 |
14.8907481 | 14.7297899 |
14.8955632 | 13.2141097 |
14.9133122 | 16.337941 |
14.9817274 | 13.634554 |
14.9985553 | 12.0236224 |
15.0917411 | 13.5520639 |
15.1110772 | 14.5536931 |
15.138392 | 13.2415998 |
15.1624205 | 13.7417785 |
15.1675304 | 14.3424403 |
15.1959608 | 13.6760523 |
15.1960034 | 14.4806538 |
15.2013835 | 15.6980377 |
15.2141018 | 14.6837557 |
15.2348838 | 12.4397497 |
15.2422483 | 13.3493743 |
15.2430823 | 13.7644821 |
15.2613676 | 14.8671876 |
15.2946775 | 13.1593571 |
15.3350288 | 14.460047 |
15.335831 | 15.4561045 |
15.3401016 | 15.1398342 |
15.3739163 | 13.9216549 |
15.43575 | 13.3674077 |
15.4735116 | 13.3621969 |
15.5094318 | 14.7425193 |
15.5192765 | 13.0919875 |
15.5230336 | 13.3181116 |
15.5389153 | 14.3706625 |
15.569023 | 15.6957121 |
15.6814631 | 13.0434399 |
15.7144954 | 11.191835 |
15.7198893 | 15.0829336 |
15.7803768 | 13.8861349 |
15.9326271 | 14.1804494 |
15.9732352 | 13.991876 |
15.9849534 | 13.8853695 |
16.1124261 | 13.3706331 |
16.1154425 | 14.9006981 |
16.1254249 | 12.0928389 |
16.2795063 | 14.5570386 |
16.2975804 | 13.1768362 |
16.3800894 | 13.2322431 |
17.1497729 | 14.4123977 |
6.14794639 | 18.979611 |
6.87296376 | 21.259677 |
6.95057589 | 19.253912 |
7.1774974 | 19.078445 |
7.2212576 | 20.180736 |
7.3319392 | 21.250346 |
7.3417249 | 19.922804 |
7.3666823 | 20.057726 |
7.4343045 | 19.844073 |
7.4637002 | 20.504545 |
7.5730949 | 21.120083 |
7.6960326 | 19.719672 |
7.7176948 | 19.681052 |
7.735971 | 21.281386 |
7.7907127 | 19.970722 |
7.8934128 | 21.577153 |
7.9067283 | 20.338185 |
7.9620927 | 21.091421 |
7.9967398 | 21.708606 |
8.0047431 | 20.371614 |
8.044215 | 19.689133 |
8.0872242 | 21.305325 |
8.0887985 | 20.697535 |
8.200185 | 21.663794 |
8.2008578 | 19.885879 |
8.2557222 | 19.889798 |
8.2892761 | 18.6007235 |
8.3028307 | 19.637392 |
8.3419285 | 19.224092 |
8.3422877 | 19.204327 |
8.3583757 | 21.048761 |
8.3893859 | 20.918406 |
8.4169347 | 21.292314 |
8.457675 | 20.097081 |
8.4578659 | 20.974339 |
8.4788892 | 21.152925 |
8.5046477 | 21.381791 |
8.5059035 | 21.737371 |
8.5621021 | 20.857647 |
8.6720782 | 18.4164271 |
8.6959001 | 21.995196 |
8.6992848 | 20.473127 |
8.7066215 | 19.623886 |
8.7295648 | 20.278963 |
8.7460885 | 20.579015 |
8.8699537 | 22.05209 |
8.8716518 | 22.413634 |
8.8873572 | 21.962738 |
8.9045898 | 21.715849 |
8.9456943 | 20.248866 |
8.9765246 | 21.883393 |
8.9819109 | 22.26836 |
8.998568 | 21.243342 |
9.0433096 | 22.347058 |
9.0596044 | 22.056215 |
9.0794422 | 20.758407 |
9.1129522 | 20.224293 |
9.1413942 | 20.929671 |
9.1627441 | 22.158977 |
9.1767186 | 20.184683 |
9.1781964 | 21.230266 |
9.2431648 | 21.962598 |
9.2618399 | 20.533754 |
9.3829695 | 20.589008 |
9.3900615 | 21.298833 |
9.4072292 | 20.452131 |
9.4630972 | 22.51363 |
9.4865115 | 20.166259 |
9.489808 | 20.302365 |
9.4985781 | 20.176454 |
9.4995603 | 21.339537 |
9.5015888 | 21.546623 |
9.5126907 | 22.181318 |
9.5186807 | 20.243923 |
9.5200494 | 21.606359 |
9.5546059 | 21.523475 |
9.5593513 | 22.20819 |
9.620113 | 22.041174 |
9.7561987 | 21.161672 |
9.7777356 | 20.774779 |
9.7993429 | 21.862268 |
9.8108036 | 22.172305 |
9.8138488 | 23.482412 |
9.9717907 | 21.813861 |
9.9946929 | 22.564215 |
10.0059337 | 21.629871 |
10.0114164 | 21.947345 |
10.0376315 | 20.086702 |
10.1360659 | 20.978871 |
10.1976377 | 22.45016 |
10.3760322 | 20.3188 |
10.4290531 | 21.540536 |
10.4497178 | 21.767889 |
10.4527803 | 21.620024 |
10.6388008 | 21.745066 |
10.6473698 | 21.450529 |
10.7566377 | 22.143698 |
10.7900453 | 21.382074 |
10.8758893 | 21.90501 |
10.9023884 | 21.818273 |
10.9788072 | 20.959914 |
11.0324193 | 21.252833 |
11.3479027 | 20.875618 |
13.4652107 | 2.6831135 |
13.5244255 | 1.1185327 |
13.676615 | 2.1365133 |
13.7060357 | 4.8800944 |
14.0507822 | 4.9306996 |
14.0926175 | 5.5469616 |
14.1620361 | 3.4362472 |
14.528659 | 4.9653684 |
14.68202 | 4.9323634 |
14.8113105 | 5.0447482 |
14.8395293 | 3.2846371 |
14.8904436 | 3.9756688 |
14.901902 | 4.0596121 |
15.00957 | 3.8387848 |
15.041757 | 3.2972722 |
15.070124 | 3.5975018 |
15.125698 | 5.2145027 |
15.13737 | 5.069625 |
15.179778 | 2.7118074 |
15.300714 | 2.811699 |
15.302589 | 4.6895294 |
15.310044 | 3.3904743 |
15.360948 | 4.048405 |
15.387776 | 2.650697 |
15.404948 | 2.3650841 |
15.415097 | 4.0142043 |
15.417047 | 3.4687826 |
15.442745 | 5.030264 |
15.443721 | 4.1409706 |
15.447941 | 5.8988869 |
15.476582 | 3.743859 |
15.515158 | 5.106076 |
15.595752 | 3.8626734 |
15.615602 | 3.2022261 |
15.61961 | 5.7629745 |
15.632347 | 3.3748335 |
15.657503 | 3.2747553 |
15.709758 | 5.0287697 |
15.747944 | 5.0152176 |
15.752371 | 4.7189407 |
15.818769 | 3.7802197 |
15.820888 | 3.1272452 |
15.830515 | 5.601528 |
15.863656 | 2.6533946 |
15.88482 | 5.2657701 |
15.904148 | 4.8965637 |
15.939187 | 3.1585675 |
15.952628 | 2.2741358 |
15.973613 | 4.8611944 |
15.97606 | 2.9509126 |
16.000251 | 4.8797171 |
16.004435 | 2.8729802 |
16.004874 | 4.9961698 |
16.008949 | 4.4582345 |
16.025455 | 4.3870708 |
16.045022 | 4.9916418 |
16.096295 | 2.973044 |
16.195278 | 2.9627547 |
16.21192 | 4.3851352 |
16.215603 | 4.153893 |
16.362235 | 2.9408317 |
16.487338 | 3.4554507 |
16.507061 | 4.9059559 |
16.544954 | 3.0748351 |
16.561125 | 3.3112401 |
16.575478 | 3.2823488 |
16.61449 | 4.9872933 |
16.618037 | 3.916222 |
16.63065 | 4.3280429 |
16.666668 | 4.0476106 |
16.693189 | 4.5426592 |
16.71092 | 2.5744855 |
16.717479 | 3.5385358 |
16.723603 | 4.8269313 |
16.740956 | 4.5362417 |
16.810342 | 3.3345241 |
16.884852 | 5.2966064 |
16.88918 | 2.4088233 |
16.908124 | 4.4692953 |
16.920669 | 5.1046996 |
17.066882 | 4.2443514 |
17.119596 | 3.8195427 |
17.134638 | 4.0501819 |
17.15121 | 5.0939166 |
17.174712 | 1.7723559 |
17.23597 | 5.8236027 |
17.270719 | 3.9357992 |
17.418402 | 5.0104769 |
17.423091 | 4.655516 |
17.58717 | 5.4807475 |
17.608216 | 5.5958854 |
17.621365 | 5.1009621 |
17.639837 | 5.7854218 |
17.675322 | 3.0883694 |
17.885806 | 4.5369381 |
18.123712 | 3.1371023 |
18.314308 | 4.2649289 |
24.1271918 | 19.296397 |
25.0410633 | 19.246086 |
25.0765704 | 18.281669 |
25.1579441 | 18.821112 |
25.2049293 | 18.132894 |
25.2509463 | 17.3686 |
25.2995974 | 19.315821 |
25.4488022 | 17.797879 |
25.4718758 | 19.400537 |
25.6037499 | 19.167981 |
25.6299854 | 16.916744 |
25.6385609 | 19.134394 |
25.722283 | 16.348765 |
25.8768788 | 16.795341 |
25.8805154 | 17.427278 |
25.9245665 | 18.171992 |
25.9419753 | 16.11674 |
25.9458388 | 17.572502 |
25.9963091 | 17.910162 |
25.9977637 | 16.264383 |
26.120108 | 18.298028 |
26.161642 | 16.235561 |
26.259619 | 18.538579 |
26.278865 | 17.907848 |
26.284851 | 18.78127 |
26.302126 | 17.551077 |
26.419082 | 17.560862 |
26.451229 | 18.87717 |
26.481022 | 18.631295 |
26.487289 | 17.299683 |
26.570844 | 17.073695 |
26.587373 | 18.506647 |
26.625944 | 17.499386 |
26.641761 | 17.157186 |
26.64511 | 16.942852 |
26.667898 | 19.982038 |
26.670485 | 17.955641 |
26.706356 | 17.361715 |
26.711061 | 18.236744 |
26.771428 | 16.766095 |
26.775607 | 20.052587 |
26.886805 | 17.023554 |
26.928196 | 15.2239141 |
26.950179 | 18.187592 |
26.966609 | 17.020396 |
26.984097 | 17.00589 |
26.997997 | 18.669185 |
27.089569 | 18.398868 |
27.108494 | 17.910334 |
27.147798 | 17.724342 |
27.155115 | 20.121416 |
27.158758 | 18.718643 |
27.213179 | 16.731326 |
27.222689 | 17.894866 |
27.237439 | 18.728269 |
27.247742 | 19.206662 |
27.256842 | 18.442514 |
27.269178 | 17.628728 |
27.350498 | 17.563816 |
27.469883 | 18.188571 |
27.4942 | 18.38967 |
27.52686 | 16.779428 |
27.553505 | 18.539572 |
27.559418 | 19.570712 |
27.567707 | 18.901948 |
27.634692 | 16.074948 |
27.634837 | 18.236684 |
27.641807 | 18.726728 |
27.677089 | 18.332538 |
27.767215 | 19.092209 |
27.781016 | 16.595779 |
27.878886 | 18.329098 |
27.891137 | 17.18777 |
27.895193 | 15.6599829 |
27.945273 | 17.156521 |
27.949261 | 16.944328 |
27.998138 | 17.186815 |
28.01272 | 18.270148 |
28.021108 | 19.495508 |
28.026602 | 17.861609 |
28.056164 | 17.728905 |
28.065794 | 17.845586 |
28.087697 | 19.523848 |
28.105136 | 17.638893 |
28.197604 | 18.022645 |
28.296025 | 19.509115 |
28.349088 | 18.002902 |
28.370353 | 20.051215 |
28.425818 | 16.55447 |
28.465642 | 16.745134 |
28.470883 | 17.280208 |
28.473897 | 17.425769 |
28.516394 | 17.222901 |
28.646671 | 17.889919 |
28.651572 | 19.064428 |
28.888393 | 16.709495 |
29.075641 | 18.576588 |
30.009856 | 18.548147 |
Parag Kanade/fuzzy ants/Gauss500-5/gauss500_05Full.data
1 | 3.2079091 | 7.7210589 |
1 | 3.2231833 | 8.624442 |
1 | 3.2724274 | 7.7211989 |
1 | 3.3905861 | 6.8528257 |
1 | 3.5263206 | 7.1902709 |
1 | 3.5446515 | 6.9092366 |
1 | 4.0817641 | 6.2932327 |
1 | 4.1329588 | 6.7909656 |
1 | 4.2061908 | 6.5587698 |
1 | 4.2294541 | 7.7094674 |
1 | 4.2311605 | 6.1842931 |
1 | 4.3729459 | 6.6146591 |
1 | 4.451783 | 8.0942238 |
1 | 4.4631214 | 5.9776029 |
1 | 4.4641181 | 7.9918609 |
1 | 4.5092126 | 7.2028537 |
1 | 4.5249635 | 5.8857945 |
1 | 4.5408484 | 7.0938419 |
1 | 4.5538585 | 8.1353191 |
1 | 4.580998 | 7.1703637 |
1 | 4.6221661 | 8.0532502 |
1 | 4.6675926 | 7.5078748 |
1 | 4.6693178 | 7.0258803 |
1 | 4.6757058 | 5.5386359 |
1 | 4.6875167 | 8.3955603 |
1 | 4.8136569 | 8.2550441 |
1 | 4.8330733 | 8.7522282 |
1 | 4.8388063 | 8.8021392 |
1 | 4.8394463 | 8.1968265 |
1 | 4.8564329 | 5.7743203 |
1 | 4.8694154 | 6.2415617 |
1 | 4.8838473 | 7.8844967 |
1 | 4.9151302 | 6.5118873 |
1 | 4.9197918 | 8.408129 |
1 | 4.9546596 | 8.2040109 |
1 | 4.9707417 | 6.4312104 |
1 | 5.0135107 | 7.9468569 |
1 | 5.0456382 | 7.6968997 |
1 | 5.0662513 | 7.9026477 |
1 | 5.0731757 | 9.0607237 |
1 | 5.0940184 | 9.3846903 |
1 | 5.0998003 | 7.0196854 |
1 | 5.1062588 | 7.8665536 |
1 | 5.1113574 | 6.7466426 |
1 | 5.1401502 | 6.322823 |
1 | 5.164504 | 6.3772491 |
1 | 5.167721 | 8.491692 |
1 | 5.1792337 | 7.1921312 |
1 | 5.189034 | 7.9209093 |
1 | 5.1923355 | 9.0269859 |
1 | 5.2420277 | 6.6866669 |
1 | 5.2563394 | 6.6318602 |
1 | 5.2646653 | 7.3621656 |
1 | 5.277839 | 7.5903912 |
1 | 5.2840827 | 6.3948904 |
1 | 5.3134128 | 7.7465675 |
1 | 5.3432966 | 6.3024976 |
1 | 5.3588688 | 6.6395169 |
1 | 5.3773154 | 7.509691 |
1 | 5.3923682 | 7.7704754 |
1 | 5.3928396 | 7.9307354 |
1 | 5.4097375 | 7.0243664 |
1 | 5.4250905 | 8.2957807 |
1 | 5.4256467 | 9.1909088 |
1 | 5.429859 | 8.6389274 |
1 | 5.4383383 | 8.5945946 |
1 | 5.4499816 | 7.3406544 |
1 | 5.4648999 | 7.7633964 |
1 | 5.5101871 | 7.0922003 |
1 | 5.5814278 | 8.4753996 |
1 | 5.5883151 | 6.204994 |
1 | 5.6065497 | 7.7304895 |
1 | 5.6109218 | 8.4108913 |
1 | 5.6800216 | 7.6595682 |
1 | 5.6865731 | 6.8736266 |
1 | 5.7364618 | 7.1109649 |
1 | 5.7834804 | 8.4478511 |
1 | 5.806937 | 6.2154877 |
1 | 5.8505015 | 6.7495611 |
1 | 5.8894656 | 7.5845772 |
1 | 5.898071 | 8.4421334 |
1 | 5.9191638 | 8.1379257 |
1 | 5.9232595 | 6.3691164 |
1 | 5.9263071 | 6.3499483 |
1 | 5.9336875 | 7.5430657 |
1 | 5.9561075 | 6.014345 |
1 | 5.956787 | 6.2913721 |
1 | 5.9597375 | 7.9233632 |
1 | 5.9647258 | 7.5541938 |
1 | 6.0014664 | 5.5959308 |
1 | 6.0967613 | 7.3460918 |
1 | 6.1113619 | 8.956129 |
1 | 6.1393133 | 7.1290369 |
1 | 6.2427451 | 8.3293623 |
1 | 6.2447324 | 6.4055278 |
1 | 6.2808958 | 8.1849711 |
1 | 6.2958248 | 8.52221 |
1 | 6.3333881 | 8.8926755 |
1 | 6.3770667 | 8.148263 |
1 | 6.3872811 | 7.0834977 |
1 | 6.3943806 | 5.2047041 |
1 | 6.4231133 | 9.1428545 |
1 | 6.4242463 | 8.7437029 |
1 | 6.4737188 | 9.1960809 |
1 | 6.5434832 | 6.9540165 |
1 | 6.5542301 | 8.6514457 |
1 | 6.556613 | 7.6792214 |
1 | 6.5569343 | 8.3557038 |
1 | 6.5681878 | 6.7334969 |
1 | 6.6154429 | 8.9919154 |
1 | 6.6573287 | 7.6323181 |
1 | 6.7523585 | 8.6764836 |
1 | 6.7530329 | 5.6970322 |
1 | 6.8855847 | 7.1092405 |
1 | 6.9202943 | 7.6878621 |
1 | 7.0692918 | 8.4614043 |
1 | 7.094251 | 8.9986657 |
1 | 7.2213603 | 6.8859654 |
1 | 7.29025 | 8.1231551 |
1 | 7.3047409 | 8.0529775 |
1 | 7.3807576 | 6.8897184 |
1 | 7.4022501 | 8.2157411 |
1 | 7.5258683 | 8.6077935 |
1 | 7.5602902 | 8.0202276 |
1 | 7.5928493 | 9.9473488 |
1 | 7.6337921 | 6.0477399 |
2 | 12.5649633 | 14.8199028 |
2 | 12.9492476 | 15.2417831 |
2 | 12.9639843 | 14.1301841 |
2 | 13.226796 | 13.0896456 |
2 | 13.5160477 | 14.339618 |
2 | 13.5494966 | 15.3187034 |
2 | 13.7321392 | 13.3091876 |
2 | 13.78872 | 13.9671922 |
2 | 13.8074223 | 14.160413 |
2 | 13.8077218 | 15.2829668 |
2 | 13.8401064 | 14.4340778 |
2 | 13.8887826 | 15.182616 |
2 | 13.9385494 | 13.0826968 |
2 | 14.0173279 | 16.015934 |
2 | 14.1333175 | 15.0641202 |
2 | 14.1493846 | 11.5813131 |
2 | 14.3247616 | 14.5008158 |
2 | 14.3596552 | 14.4300021 |
2 | 14.4498757 | 14.4660964 |
2 | 14.5039886 | 15.1291981 |
2 | 14.5577834 | 12.1352935 |
2 | 14.6243969 | 13.1862597 |
2 | 14.6653361 | 13.8993512 |
2 | 14.6752921 | 13.2522435 |
2 | 14.6978867 | 13.9182312 |
2 | 14.7050083 | 16.974634 |
2 | 14.7473609 | 13.2485078 |
2 | 14.7493806 | 13.5129937 |
2 | 14.7887799 | 13.8588077 |
2 | 14.836351 | 13.2174683 |
2 | 14.8726451 | 14.0834742 |
2 | 14.8903508 | 12.7250099 |
2 | 14.8907481 | 14.7297899 |
2 | 14.8955632 | 13.2141097 |
2 | 14.9133122 | 16.337941 |
2 | 14.9817274 | 13.634554 |
2 | 14.9985553 | 12.0236224 |
2 | 15.0917411 | 13.5520639 |
2 | 15.1110772 | 14.5536931 |
2 | 15.138392 | 13.2415998 |
2 | 15.1624205 | 13.7417785 |
2 | 15.1675304 | 14.3424403 |
2 | 15.1959608 | 13.6760523 |
2 | 15.1960034 | 14.4806538 |
2 | 15.2013835 | 15.6980377 |
2 | 15.2141018 | 14.6837557 |
2 | 15.2348838 | 12.4397497 |
2 | 15.2422483 | 13.3493743 |
2 | 15.2430823 | 13.7644821 |
2 | 15.2613676 | 14.8671876 |
2 | 15.2946775 | 13.1593571 |
2 | 15.3350288 | 14.460047 |
2 | 15.335831 | 15.4561045 |
2 | 15.3401016 | 15.1398342 |
2 | 15.3739163 | 13.9216549 |
2 | 15.43575 | 13.3674077 |
2 | 15.4735116 | 13.3621969 |
2 | 15.5094318 | 14.7425193 |
2 | 15.5192765 | 13.0919875 |
2 | 15.5230336 | 13.3181116 |
2 | 15.5389153 | 14.3706625 |
2 | 15.569023 | 15.6957121 |
2 | 15.6814631 | 13.0434399 |
2 | 15.7144954 | 11.191835 |
2 | 15.7198893 | 15.0829336 |
2 | 15.7803768 | 13.8861349 |
2 | 15.9326271 | 14.1804494 |
2 | 15.9732352 | 13.991876 |
2 | 15.9849534 | 13.8853695 |
2 | 16.1124261 | 13.3706331 |
2 | 16.1154425 | 14.9006981 |
2 | 16.1254249 | 12.0928389 |
2 | 16.2795063 | 14.5570386 |
2 | 16.2975804 | 13.1768362 |
2 | 16.3800894 | 13.2322431 |
2 | 17.1497729 | 14.4123977 |
3 | 6.14794639 | 18.979611 |
3 | 6.87296376 | 21.259677 |
3 | 6.95057589 | 19.253912 |
3 | 7.1774974 | 19.078445 |
3 | 7.2212576 | 20.180736 |
3 | 7.3319392 | 21.250346 |
3 | 7.3417249 | 19.922804 |
3 | 7.3666823 | 20.057726 |
3 | 7.4343045 | 19.844073 |
3 | 7.4637002 | 20.504545 |
3 | 7.5730949 | 21.120083 |
3 | 7.6960326 | 19.719672 |
3 | 7.7176948 | 19.681052 |
3 | 7.735971 | 21.281386 |
3 | 7.7907127 | 19.970722 |
3 | 7.8934128 | 21.577153 |
3 | 7.9067283 | 20.338185 |
3 | 7.9620927 | 21.091421 |
3 | 7.9967398 | 21.708606 |
3 | 8.0047431 | 20.371614 |
3 | 8.044215 | 19.689133 |
3 | 8.0872242 | 21.305325 |
3 | 8.0887985 | 20.697535 |
3 | 8.200185 | 21.663794 |
3 | 8.2008578 | 19.885879 |
3 | 8.2557222 | 19.889798 |
3 | 8.2892761 | 18.6007235 |
3 | 8.3028307 | 19.637392 |
3 | 8.3419285 | 19.224092 |
3 | 8.3422877 | 19.204327 |
3 | 8.3583757 | 21.048761 |
3 | 8.3893859 | 20.918406 |
3 | 8.4169347 | 21.292314 |
3 | 8.457675 | 20.097081 |
3 | 8.4578659 | 20.974339 |
3 | 8.4788892 | 21.152925 |
3 | 8.5046477 | 21.381791 |
3 | 8.5059035 | 21.737371 |
3 | 8.5621021 | 20.857647 |
3 | 8.6720782 | 18.4164271 |
3 | 8.6959001 | 21.995196 |
3 | 8.6992848 | 20.473127 |
3 | 8.7066215 | 19.623886 |
3 | 8.7295648 | 20.278963 |
3 | 8.7460885 | 20.579015 |
3 | 8.8699537 | 22.05209 |
3 | 8.8716518 | 22.413634 |
3 | 8.8873572 | 21.962738 |
3 | 8.9045898 | 21.715849 |
3 | 8.9456943 | 20.248866 |
3 | 8.9765246 | 21.883393 |
3 | 8.9819109 | 22.26836 |
3 | 8.998568 | 21.243342 |
3 | 9.0433096 | 22.347058 |
3 | 9.0596044 | 22.056215 |
3 | 9.0794422 | 20.758407 |
3 | 9.1129522 | 20.224293 |
3 | 9.1413942 | 20.929671 |
3 | 9.1627441 | 22.158977 |
3 | 9.1767186 | 20.184683 |
3 | 9.1781964 | 21.230266 |
3 | 9.2431648 | 21.962598 |
3 | 9.2618399 | 20.533754 |
3 | 9.3829695 | 20.589008 |
3 | 9.3900615 | 21.298833 |
3 | 9.4072292 | 20.452131 |
3 | 9.4630972 | 22.51363 |
3 | 9.4865115 | 20.166259 |
3 | 9.489808 | 20.302365 |
3 | 9.4985781 | 20.176454 |
3 | 9.4995603 | 21.339537 |
3 | 9.5015888 | 21.546623 |
3 | 9.5126907 | 22.181318 |
3 | 9.5186807 | 20.243923 |
3 | 9.5200494 | 21.606359 |
3 | 9.5546059 | 21.523475 |
3 | 9.5593513 | 22.20819 |
3 | 9.620113 | 22.041174 |
3 | 9.7561987 | 21.161672 |
3 | 9.7777356 | 20.774779 |
3 | 9.7993429 | 21.862268 |
3 | 9.8108036 | 22.172305 |
3 | 9.8138488 | 23.482412 |
3 | 9.9717907 | 21.813861 |
3 | 9.9946929 | 22.564215 |
3 | 10.0059337 | 21.629871 |
3 | 10.0114164 | 21.947345 |
3 | 10.0376315 | 20.086702 |
3 | 10.1360659 | 20.978871 |
3 | 10.1976377 | 22.45016 |
3 | 10.3760322 | 20.3188 |
3 | 10.4290531 | 21.540536 |
3 | 10.4497178 | 21.767889 |
3 | 10.4527803 | 21.620024 |
3 | 10.6388008 | 21.745066 |
3 | 10.6473698 | 21.450529 |
3 | 10.7566377 | 22.143698 |
3 | 10.7900453 | 21.382074 |
3 | 10.8758893 | 21.90501 |
3 | 10.9023884 | 21.818273 |
3 | 10.9788072 | 20.959914 |
3 | 11.0324193 | 21.252833 |
3 | 11.3479027 | 20.875618 |
4 | 13.4652107 | 2.6831135 |
4 | 13.5244255 | 1.1185327 |
4 | 13.676615 | 2.1365133 |
4 | 13.7060357 | 4.8800944 |
4 | 14.0507822 | 4.9306996 |
4 | 14.0926175 | 5.5469616 |
4 | 14.1620361 | 3.4362472 |
4 | 14.528659 | 4.9653684 |
4 | 14.68202 | 4.9323634 |
4 | 14.8113105 | 5.0447482 |
4 | 14.8395293 | 3.2846371 |
4 | 14.8904436 | 3.9756688 |
4 | 14.901902 | 4.0596121 |
4 | 15.00957 | 3.8387848 |
4 | 15.041757 | 3.2972722 |
4 | 15.070124 | 3.5975018 |
4 | 15.125698 | 5.2145027 |
4 | 15.13737 | 5.069625 |
4 | 15.179778 | 2.7118074 |
4 | 15.300714 | 2.811699 |
4 | 15.302589 | 4.6895294 |
4 | 15.310044 | 3.3904743 |
4 | 15.360948 | 4.048405 |
4 | 15.387776 | 2.650697 |
4 | 15.404948 | 2.3650841 |
4 | 15.415097 | 4.0142043 |
4 | 15.417047 | 3.4687826 |
4 | 15.442745 | 5.030264 |
4 | 15.443721 | 4.1409706 |
4 | 15.447941 | 5.8988869 |
4 | 15.476582 | 3.743859 |
4 | 15.515158 | 5.106076 |
4 | 15.595752 | 3.8626734 |
4 | 15.615602 | 3.2022261 |
4 | 15.61961 | 5.7629745 |
4 | 15.632347 | 3.3748335 |
4 | 15.657503 | 3.2747553 |
4 | 15.709758 | 5.0287697 |
4 | 15.747944 | 5.0152176 |
4 | 15.752371 | 4.7189407 |
4 | 15.818769 | 3.7802197 |
4 | 15.820888 | 3.1272452 |
4 | 15.830515 | 5.601528 |
4 | 15.863656 | 2.6533946 |
4 | 15.88482 | 5.2657701 |
4 | 15.904148 | 4.8965637 |
4 | 15.939187 | 3.1585675 |
4 | 15.952628 | 2.2741358 |
4 | 15.973613 | 4.8611944 |
4 | 15.97606 | 2.9509126 |
4 | 16.000251 | 4.8797171 |
4 | 16.004435 | 2.8729802 |
4 | 16.004874 | 4.9961698 |
4 | 16.008949 | 4.4582345 |
4 | 16.025455 | 4.3870708 |
4 | 16.045022 | 4.9916418 |
4 | 16.096295 | 2.973044 |
4 | 16.195278 | 2.9627547 |
4 | 16.21192 | 4.3851352 |
4 | 16.215603 | 4.153893 |
4 | 16.362235 | 2.9408317 |
4 | 16.487338 | 3.4554507 |
4 | 16.507061 | 4.9059559 |
4 | 16.544954 | 3.0748351 |
4 | 16.561125 | 3.3112401 |
4 | 16.575478 | 3.2823488 |
4 | 16.61449 | 4.9872933 |
4 | 16.618037 | 3.916222 |
4 | 16.63065 | 4.3280429 |
4 | 16.666668 | 4.0476106 |
4 | 16.693189 | 4.5426592 |
4 | 16.71092 | 2.5744855 |
4 | 16.717479 | 3.5385358 |
4 | 16.723603 | 4.8269313 |
4 | 16.740956 | 4.5362417 |
4 | 16.810342 | 3.3345241 |
4 | 16.884852 | 5.2966064 |
4 | 16.88918 | 2.4088233 |
4 | 16.908124 | 4.4692953 |
4 | 16.920669 | 5.1046996 |
4 | 17.066882 | 4.2443514 |
4 | 17.119596 | 3.8195427 |
4 | 17.134638 | 4.0501819 |
4 | 17.15121 | 5.0939166 |
4 | 17.174712 | 1.7723559 |
4 | 17.23597 | 5.8236027 |
4 | 17.270719 | 3.9357992 |
4 | 17.418402 | 5.0104769 |
4 | 17.423091 | 4.655516 |
4 | 17.58717 | 5.4807475 |
4 | 17.608216 | 5.5958854 |
4 | 17.621365 | 5.1009621 |
4 | 17.639837 | 5.7854218 |
4 | 17.675322 | 3.0883694 |
4 | 17.885806 | 4.5369381 |
4 | 18.123712 | 3.1371023 |
4 | 18.314308 | 4.2649289 |
5 | 24.1271918 | 19.296397 |
5 | 25.0410633 | 19.246086 |
5 | 25.0765704 | 18.281669 |
5 | 25.1579441 | 18.821112 |
5 | 25.2049293 | 18.132894 |
5 | 25.2509463 | 17.3686 |
5 | 25.2995974 | 19.315821 |
5 | 25.4488022 | 17.797879 |
5 | 25.4718758 | 19.400537 |
5 | 25.6037499 | 19.167981 |
5 | 25.6299854 | 16.916744 |
5 | 25.6385609 | 19.134394 |
5 | 25.722283 | 16.348765 |
5 | 25.8768788 | 16.795341 |
5 | 25.8805154 | 17.427278 |
5 | 25.9245665 | 18.171992 |
5 | 25.9419753 | 16.11674 |
5 | 25.9458388 | 17.572502 |
5 | 25.9963091 | 17.910162 |
5 | 25.9977637 | 16.264383 |
5 | 26.120108 | 18.298028 |
5 | 26.161642 | 16.235561 |
5 | 26.259619 | 18.538579 |
5 | 26.278865 | 17.907848 |
5 | 26.284851 | 18.78127 |
5 | 26.302126 | 17.551077 |
5 | 26.419082 | 17.560862 |
5 | 26.451229 | 18.87717 |
5 | 26.481022 | 18.631295 |
5 | 26.487289 | 17.299683 |
5 | 26.570844 | 17.073695 |
5 | 26.587373 | 18.506647 |
5 | 26.625944 | 17.499386 |
5 | 26.641761 | 17.157186 |
5 | 26.64511 | 16.942852 |
5 | 26.667898 | 19.982038 |
5 | 26.670485 | 17.955641 |
5 | 26.706356 | 17.361715 |
5 | 26.711061 | 18.236744 |
5 | 26.771428 | 16.766095 |
5 | 26.775607 | 20.052587 |
5 | 26.886805 | 17.023554 |
5 | 26.928196 | 15.2239141 |
5 | 26.950179 | 18.187592 |
5 | 26.966609 | 17.020396 |
5 | 26.984097 | 17.00589 |
5 | 26.997997 | 18.669185 |
5 | 27.089569 | 18.398868 |
5 | 27.108494 | 17.910334 |
5 | 27.147798 | 17.724342 |
5 | 27.155115 | 20.121416 |
5 | 27.158758 | 18.718643 |
5 | 27.213179 | 16.731326 |
5 | 27.222689 | 17.894866 |
5 | 27.237439 | 18.728269 |
5 | 27.247742 | 19.206662 |
5 | 27.256842 | 18.442514 |
5 | 27.269178 | 17.628728 |
5 | 27.350498 | 17.563816 |
5 | 27.469883 | 18.188571 |
5 | 27.4942 | 18.38967 |
5 | 27.52686 | 16.779428 |
5 | 27.553505 | 18.539572 |
5 | 27.559418 | 19.570712 |
5 | 27.567707 | 18.901948 |
5 | 27.634692 | 16.074948 |
5 | 27.634837 | 18.236684 |
5 | 27.641807 | 18.726728 |
5 | 27.677089 | 18.332538 |
5 | 27.767215 | 19.092209 |
5 | 27.781016 | 16.595779 |
5 | 27.878886 | 18.329098 |
5 | 27.891137 | 17.18777 |
5 | 27.895193 | 15.6599829 |
5 | 27.945273 | 17.156521 |
5 | 27.949261 | 16.944328 |
5 | 27.998138 | 17.186815 |
5 | 28.01272 | 18.270148 |
5 | 28.021108 | 19.495508 |
5 | 28.026602 | 17.861609 |
5 | 28.056164 | 17.728905 |
5 | 28.065794 | 17.845586 |
5 | 28.087697 | 19.523848 |
5 | 28.105136 | 17.638893 |
5 | 28.197604 | 18.022645 |
5 | 28.296025 | 19.509115 |
5 | 28.349088 | 18.002902 |
5 | 28.370353 | 20.051215 |
5 | 28.425818 | 16.55447 |
5 | 28.465642 | 16.745134 |
5 | 28.470883 | 17.280208 |
5 | 28.473897 | 17.425769 |
5 | 28.516394 | 17.222901 |
5 | 28.646671 | 17.889919 |
5 | 28.651572 | 19.064428 |
5 | 28.888393 | 16.709495 |
5 | 29.075641 | 18.576588 |
5 | 30.009856 | 18.548147 |
Parag Kanade/fuzzy ants/Gauss500-5/gauss.c
#include "headerStatic.h" /*******************************************************************/ /*** Global Variables ***/ irisData data[MAXDATA]; //To hold the data read from the file int count=0; //Count of the total number of data elements int heapCount=0; // Total number of heaps int heapRow=0; // Rows for the second iteration with heaps int newHeapCount=0; // Count of the heaps for the second iteration heap heaps[MAXDATA]; // Data structure to hold the heap information heap newHeaps[MAXDATA]; // Data Structure to hold the new heap information // For the second iteration int board[MAXROWS][MAXCOLS]; // Board on which the objects are located ant ants[MAXANTS]; // Data structure to hold the ants float Dmax=0; // Distance of the most dissimilar object pair int minHeapCount=100000; // Counter to hold the minimum heap count, used only for academic purpose // no use in the algorithm int minPosition; // the minimum heap iteration , only for academic purpose // no use in the algorithm float clsCen[MAXDATA][MAXDATA][s];//to hold the objects after hardening int cenCount[MAXDATA];//to hold the number of objects after hardening /********************************************************************/ /*** Varaibles to normalize the features between 0 and 1 */ float minInput[features], maxInput[features],scale[features],minForHeaps[features],maxForHeaps[features],scaleForHeaps[features]; /********************************************************************/ /** Variables for the FCM algorithm */ int temp[200]; /* for square matrix tests */ float eps,m; matrix U, U1; BOOLEAN stop; center V; objects X; char fname[80]; FILE *fp; int run; float inv_cov[s+1][s+1]; /* inverse of covariance matrix Y */ float Y[s][s]; long rand_index, Random_seed; long state1[52] = { 9347, 3835, 5194, 8310, 346, 535, 5297, 6711, 77, 3834, 668, 4175, 6868, 5890, 9304, 8462, 5269, 920, 65392, 41600, 70119, 91032, 76220, 26245, 4746, 73608, 32823, 63264, 75641, 99104, 36534, 24704, 98255, 72266, 75336, 65152, 7269, 63163, 88471, 27271, 43641, 76649, 47773, 23777, 27491, 35926, 16651, 48652, 89766, 90921, 6056 }; int z; int mins=0; int aveit =0; float mintab[200]; int mincount[200]; long start,end,total; int lCount;//added by parag /********************************************************************/ /********************************************************************//*int lrand48(){return(rand());}void srand48(int a){return;}*//********************************************************************/ /********************************************************************/ /* Function to read the input data set */ /* The file name is assumed to be itest.data */ /* Status: Tested */ /* Output: Data from the file into the "data" (Global) data structure */ /* Output: Count (Global), the count of the number of objects */ /********************************************************************/ void readInput() { FILE *fp; char fname[80]; int i=0,j=0; char ch; sprintf(fname,"%s.data",filename); /* Check if the input file is opened */ if((fp=fopen(fname,"r"))==NULL) { printf("\n Unable to open input file \n"); exit(0); } /*initialise the minimum maximum and the scale */ for(i=0;i<features;i++) { minInput[i]=1000; maxInput[i]=0; minForHeaps[i]=1000; maxForHeaps[i]=0; scale[i]=0; scaleForHeaps[i]=0; } /* Discard leading comments */ ch = 'c'; while (ch != '#') fscanf (fp, "%c", &ch); i=0; /* Parse the file and populate the data structure */ while(!feof(fp)) { for(j=0;j<features;j++) { fscanf(fp,"%f ",&data[i][j]); } fscanf(fp,"\n"); for(j=0;j<features;j++) { if(data[i][j]<minInput[j]) minInput[j]=data[i][j]; if(data[i][j]>maxInput[j]) maxInput[j]=data[i][j]; } i++; } count=i; /* Normailze the feature values in between 0 and 1 */ for(j=0;j<features;j++) { if(minInput[j]!=maxInput[j]) scale[j]=1.0/(maxInput[j]-minInput[j]); else scale[j]=1.0; } for(i=0;i<count;i++) { for(j=0;j<features;j++) data[i][j]=(data[i][j]-minInput[j])*scale[j]; } fclose(fp); return; }//end of function /********************************************************************/ /*Function to compute the eucldiean distance for all input data set */ /* Output : an array conatining the distance of each object with the other */ /********************************************************************/ float computeDistance() { float distance,dist=0; int i=0,j=0,k=0; distance=0; for(j=0;j<count;j++) for(i=0;i<count;i++) { for(k=0;k<features;k++) dist+=sqrt((data[j][k]-data[i][k])*(data[j][k]-data[i][k])); if(distance<dist)distance=dist; dist=0; } return(distance); } /********************************************************************/ /* Function to compute the distance between two objects */ /* Output : Euclidean d istance between the two input objects */ /********************************************************************/ float computeDistanceBetween2(irisData a,irisData b) { float temp=0; int i=0; for(i=0;i<features;i++) temp+=(a[i]-b[i])*(a[i]-b[i]); temp=sqrt(temp); return(temp); } /********************************************************************/ /* Function to find the maximum distance between the input objects*/ /* Output: the maximum distance */ /* Input : The array of distances between objects */ /********************************************************************/ /*float findMax(float *distance) { int i=0,j=0; float max=distance[0]; for(i=0;i<count;i++) for(j=0;j<count;j++) { if(max<distance[i*count+j]) max=distance[i*count+j]; } return(max); }*/ /********************************************************************/ /* Function to compute the value of an object */ /********************************************************************/ float value(irisData a) { int i=0; float temp=0; for(i=0;i<features;i++) temp+=a[i]*a[i]; return(sqrt(temp)); } /********************************************************************/ /* Function to find the object in the data structure */ /* Output : The position of the object in the data */ /* Input : The object */ /********************************************************************/ int findInData(irisData object,int iFlag) { int i=0,lastCount=0,j,position=-1,flag[features],flg;if(iFlag==1)lastCount=MAXDATA;else{}for(i=0;i<lastCount;i++){ for(j=0;j<features;j++) if(fabs(object[j]-data[i][j])<0.00001) flag[j]=1; else { flag[j]=0; break;} flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /* Function to find whether there is an object on the board at a,b */ /* Output : a flag indicating whether an object is found or not */ /* Input : The row and column indicating the board position */ /********************************************************************/ int found(int a , int b) { if(board[a][b]==9) return 1; else return 0; } /********************************************************************/ /* Function to initialize the initial board */ /* Output : None */ /* Global Structures modified : heaps */ /* Input : Flag indicating the iteration 1: First 0: Second */ /********************************************************************/ void initialise(int flag) { int a,b,i=0,k=0; int loopCount,rowCount,colCount; /* Initialize the row, column and number of heaps */ if(flag==1) { loopCount=count; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=lCount; rowCount=heapRow; colCount=heapRow; } /* Initialize the heaps */ for(i=0;i<loopCount;i++) { heaps[i].count=0; heaps[i].x=0; heaps[i].y=0; heaps[i].disPosition=0; heaps[i].Dmax=0; heaps[i].Dmean=0; } for(i=0;i<loopCount;i++) { /*find a board position which is empty*/ do { a=lrand48()%rowCount; b=lrand48()%colCount; } while(found(a,b)); /*Allocate the object to that place and assign a heap to it*/ heaps[i].x=a; heaps[i].y=b; heaps[i].count=1; heaps[i].Dmax=0; heaps[i].Dmean=0; if(flag==1) { heaps[i].objects[0]=i; for(k=0;k<features;k++)heaps[i].Ocenter[k]=data[i][k]; } else { for(k=0;k<features;k++) heaps[i].Ocenter[k]=newHeaps[i].Ocenter[k]; } heaps[i].disPosition=0; board[a][b]=9; if((debugLevel>0)&&(flag==1))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],data[heaps[i].objects[0]][0]); if((debugLevel>0)&&(flag==0))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],newHeaps[i].Ocenter[0]); } /*initialise the initial heap count*/ heapCount=loopCount; currentRow=rowCount; } /********************************************************************/ /* Function to find whether an heap is present at the location a b */ /* Output : Flag indicating the presencs of the heap */ /* Input : Roe and column indicating the board position */ /********************************************************************/ int findObject(int a,int b) { int i; int position=-1; for(i=0;i<heapCount;i++) { if((heaps[i].x==a)&&(heaps[i].y==b)) { position=i; break; } } return(position); } /********************************************************************/ /* Function initialize the ants */ /* Output : None */ /* Input : Flag indicating the iteration */ /* Global Variables Modified : ant, heapCount, heaps, board */ /********************************************************************/ void initialiseAnts(int flag) { int i=0,a=0,b=0,position,j=0,loopCount=0,rowCount,colCount,k=0; if(flag==1) { loopCount=MAXANTS; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=MAXANTSFORHEAPS; rowCount=heapRow; colCount=heapRow; } for(i=0;i<loopCount;i++) { /*generate random positions for the ants*/ a=lrand48()%rowCount; b=lrand48()%colCount; ants[i].x=a; ants[i].y=b; /*Find if an object is present at that position or not*/ if(board[a][b]==9) { ants[i].carrying=1; /*find the heap at that location*/ position=findObject(a,b); if(position==-1) { printf("\n Error in logic: Ant init \n"); //getchar(); break; } else { /*Assign the heap data to the ant data and decrement the heap count*/ if(flag==1){ for(k=0;k<features;k++)ants[i].data[k]=data[heaps[position].objects[0]][k]; }else{for(k=0;k<features;k++)ants[i].data[k]=heaps[position].Ocenter[k];} for(j=position;j<heapCount-1;j++) heaps[j]=heaps[j+1]; heapCount--; } /*Clear the board position */ board[a][b]=-9; } else ants[i].carrying=-1; ants[i].speed=0; ants[i].dir=lrand48()%8; printf("\n Ant %2d X: %2d Y: %2d Carying : %2d ",i,ants[i].x,ants[i].y,ants[i].carrying); } currentAntCount=loopCount; } /********************************************************************/ /* Function to move the ant */ /* Output: None */ /* Input: Ant to be moved and the flag indicating the iteration */ /********************************************************************/ void moveNext(ant* a,int flag) { int rowCount,colCount; /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; } else { rowCount=heapRow; colCount=heapRow; }*/rowCount=currentRow;colCount=currentRow; /*Depending upon the direction move the ant*/ switch (a->dir) { case 0: a->y++; if(a->y>=colCount)a->y=0; break; case 1: a->x--; a->y++;; if(a->x<0)a->x=rowCount-1; if(a->y>=colCount)a->y=0; break; case 2: a->x--; if(a->x<0)a->x=rowCount-1; break; case 3: a->x--; a->y--; if(a->x<0)a->x=rowCount-1; if(a->y<0)a->y=colCount-1; break; case 4: a->y--; if(a->y<0)a->y=colCount-1; break; case 5: a->x++; a->y--; if(a->x>=rowCount)a->x=0; if(a->y<0)a->y=colCount-1; break; case 6: a->x++; if(a->x>=rowCount) a->x=0; break; case 7: a->x++; a->y++; if(a->x>=rowCount)a->x=0; if(a->y>=colCount)a->y=0; break; } }//end of function /********************************************************************/ /* Function to compute the parameters of the heap */ /* Output: None */ /* Input: The heap whose parameters are to be computed iteration flag*/ /********************************************************************/ void computeHeapParameters(heap* heapData,int flag) { int i=0,j=0,k=0,position=0; float distance=0; float Dmean=0.0; float *dis; float featureSum[features]; float max=0; float sum=0; /* init*/ for(k=0;k<features;k++) featureSum[k]=0; /*Compute the distance of each object and find the maximum distance*/ max=0; if(flag==1){ for(j=0;j<heapData->count;j++) for(i=0;i<heapData->count;i++) { for(k=0;k<features;k++) sum+= (data[heapData->objects[j]][k]-data[heapData->objects[i]][k])*(data[heapData->objects[j]][k]-data[heapData->objects[i]][k]); distance=sqrt(sum); if(max<distance) max=distance; sum=0; } /* Assign the maximum distance to the heap */ heapData->Dmax=max;/*Compute the centre object*/for(i=0;i<heapData->count;i++)for(k=0;k<features;k++) featureSum[k]+=data[heapData->objects[i]][k];for(k=0;k<features;k++)heapData->Ocenter[k]=featureSum[k]*1.0/heapData->count; /* Find the mean distance */if((dis=(float *) calloc(heapData->count,sizeof(float)))==NULL){printf("\nUnable to allocate memory in the compute heap parameters procedure\n");exit(0);} for(i=0;i<heapData->count;i++) { Dmean+=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); dis[i]=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); } heapData->Dmean=Dmean*1.0/heapData->count; /*Compute the most dissimilar object*/ max=dis[0]; for(i=1;i<heapData->count;i++) if(max<dis[i]) { max=dis[i]; position=i; } /*Assign the most dissimilar object to the heap variable*/ for(k=0;k<features;k++) heapData->Odissim[k]=data[heapData->objects[position]][k]; heapData->disPosition=position;free(dis); } else{/* Heap Parameters for the second stage */for(k=0;k<features;k++){ heapData->Odissim[k]=heapData->Ocenter[k];}heapData->disPosition=0;heapData->Dmean=0;heapData->Dmax=0;} }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a single object*/ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject1(ant *a,int position,int flag) { int i,k=0; /*Clear the board*/ board[heaps[position].x][heaps[position].y]=-9; /* Assign the data to the ant*/if(flag==1){ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[0]][k];}else {for(k=0;k<features;k++) a->data[k]=heaps[position].Ocenter[k];} a->carrying=1; /*Copy all the heaps remaining heaps in the structure*/ for(i=position;i<heapCount-1;i++) heaps[i]=heaps[i+1]; /*Decrement the heap count*/ heapCount--; }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a two objects */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject2(ant *a , int position,int flag) { float Pdestroy1=-1; int i=0,k=0; /*Compute the probability to destroy the heap*/ Pdestroy1=lrand48()%13*1.0/12.0; /*If the probability is more than Pdestroy then destroy the heap */ if(Pdestroy1<Pdestroy) { /*pick the object randomly*/ i=lrand48()%2; /* Assign the data to the ant */ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[i]][k]; a->carrying=1; /*Correct the heap parameters*/ heaps[position].count=1; heaps[position].objects[0]=heaps[position].objects[1-i]; computeHeapParameters(&heaps[position],flag); } }//end of function /********************************************************************/ /*Function to pick a object from a heap consisting of more than two object */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /********************************************************************/ void pickObjectn(ant *a,int position,int flag) { int i=0,k=0; /*If the criteria is satsfied then pick the object*/ if((computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)*1.0/heaps[position].Dmean)>Tremove) { a->carrying=1; for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[heaps[position].disPosition]][k]; for(i=heaps[position].disPosition;i<heaps[position].count-1;i++) heaps[position].objects[i]=heaps[position].objects[i+1]; heaps[position].count--; computeHeapParameters(&heaps[position],1); } }//end of function /********************************************************************/ /* Function to pick a object */ /********************************************************************/ void pick(ant *a,int flag) { int position=-1,i=0; float Pload1=-1.0; for(i=0;i<heapCount;i++) { /*Check if a heap is present in the eight neighbouring cells*/ if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if Heap is found*/ if(position!=-1) { /* heap or object found.*/ /*Depending upon the number present in the heap call the corresponding routine*/ switch(heaps[i].count) { case 1: Pload1 = lrand48()%151*1.0/150.0; if(Pload1<Pload) { pickObject1(a,position,flag); } break; case 2: pickObject2(a,position,flag); break; default: pickObjectn(a,position,flag); break; } } } /********************************************************************/ /* Function to drop a object to form a new heap */ /* Output: None */ /* Input: Ant, iteration flag */ /* Global Structure modified : heap, heapCount */ /********************************************************************/ void dropObject(ant* a,int flag) { /*Create a new heap*/ int k=0; heaps[heapCount].count=1; heaps[heapCount].x=a->x; heaps[heapCount].y=a->y; heaps[heapCount].Dmax=0; heaps[heapCount].Dmean=0; heaps[heapCount].disPosition=0; for(k=0;k<features;k++) { heaps[heapCount].Odissim[k]=a->data[k]; heaps[heapCount].Ocenter[k]=a->data[k]; } if(flag==1) {heaps[heapCount].objects[0]=findInData(a->data,flag); /*computeHeapParameters(&heaps[heapCount],flag);*/ } computeHeapParameters(&heaps[heapCount],flag); heapCount++; a->carrying=-1; board[a->x][a->y]=9; }//end of function /********************************************************************/ /* Function to find the heap position during the second iteration */ /* Output: position of the heap */ /* Input: object center of the heap that the ant is carrying */ /* Global Structure modified : none */ /********************************************************************/ int findInNewheaps(irisData object) { int position=-1,i,j=0,flag[features],flg; for(i=0;i<newHeapCount;i++) { for(j=0;j<features;j++) { if(fabs(object[j]-newHeaps[i].Ocenter[j])<0.00001) flag[j]=1; else {flag[j]=0;break;} } flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /*Function to drop a object to a heap consisting of a one or more object */ /* Output: none */ /* Input: Ant, position of the heap , iteration flag */ /* Global Structure modified: heaps,newHeaps */ /********************************************************************/ void dropObject1(ant* a, int position,int flag) { int heapPosition=-1,heapPosition1=-1,i,j,k=0; irisData newData,temp; if(flag==1) { /*Add the object to the heap and compute the heap parameters*/ /*if(heaps[position].count==heaps[position].objCount) {if((junk=(int *)realloc(heaps[position].objects,((heaps[position].objCount+OBJINC)*sizeof(int))))==NULL){printf("\n Cannot Allocate memory to the new object for %d heap",position);exit(0);}heaps[position].objects=junk;heaps[position].objCount+=OBJINC;free(junk); }*/ heaps[position].objects[heaps[position].count]=findInData(a->data,flag); heaps[position].count++; computeHeapParameters(&heaps[position],flag); } else { for(k=0;k<features;k++)temp[k]=heaps[position].Ocenter[k]; heapPosition=findInNewheaps(a->data); heapPosition1=findInNewheaps(heaps[position].Ocenter); if(heapPosition==-1||heapPosition1==-1) { printf("\n error in logic:new heaps\n"); //getchar(); return; } for(k=0;k<features;k++) {newData[k]=(newHeaps[heapPosition].Ocenter[k]*newHeaps[heapPosition].count+newHeaps[heapPosition1].Ocenter[k]*newHeaps[heapPosition1].count)*1.0/(newHeaps[heapPosition].count+newHeaps[heapPosition1].count);newHeaps[heapPosition].Ocenter[k]=newData[k];heaps[position].Ocenter[k]=newData[k]; } computeHeapParameters(&heaps[position],flag); for(i=newHeaps[heapPosition].count,j=0;j<newHeaps[heapPosition1].count;i++,j++) { newHeaps[heapPosition].objects[i]=newHeaps[heapPosition1].objects[j]; } newHeaps[heapPosition].count+=newHeaps[heapPosition1].count; for(i=heapPosition1;i<newHeapCount-1;i++) newHeaps[i]=newHeaps[i+1]; newHeapCount--; } a->carrying=-1; }//end of function /********************************************************************/ /* Function to drop a object */ /* Output: None */ /* Input: Ant, iteration flag */ /********************************************************************/ void drop(ant* a,int flag) { int i, position=-1; float Pdrop1=0.0; /*Find whether we have a heap in the neighbourhood of the cell*/ for(i=0;i<heapCount;i++) { if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if a heap is found*/ if(position!=-1) { /*heap or object found.*/ /*Depending on the number of objects present take action*/ switch(heaps[position].count) { /*If criteria is satisfied then drop the object*/ case 1: if(flag==1) { if((computeDistanceBetween2(a->data,data[heaps[position].objects[0]])*1.0/Dmax)<Tcreate) dropObject1(a,position,flag); } else { if((computeDistanceBetween2(a->data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) dropObject1(a,position,flag); } break; default: if(computeDistanceBetween2(a->data,heaps[position].Ocenter)<computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)) dropObject1(a,position,flag); break; } } else { /*Compute the probability to drop the object*/ Pdrop1 = lrand48()%151*1.0/150; if(Pdrop1<Pdrop) dropObject(a,flag); } }//end of function /********************************************************************/ /* Function to move the ant */ /* Output: none */ /* Input: Ant, iteration flag */ /********************************************************************/ void move(ant* a,int flag) { float pDir; /*Check the speed */ if (a->speed!=0) { /*move in the same direction*/ a->speed--; moveNext(a,flag); } else { /*generate the new direction*/ pDir=lrand48()%17*1.0/16.0; if(pDir<.85) { a->dir=lrand48()%8; } else if(pDir>.95) { a->speed=2; } moveNext(a,flag); } } /********************************************************************/ /* Function to simulate the movement of the ants */ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified: minHeapCount, minHeapPosition */ /********************************************************************/ void iterate(int flag) { int i=0,j=0,k=0,loopCount=0; if (flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS; while (i<MAXITERATIONS) { i++; for(j=0;j<loopCount;j++) { move(&ants[j],flag); if(ants[j].carrying==1) { drop(&ants[j],flag); } else { pick(&ants[j],flag); } } if(debugLevel>0){ for(k=0;k<heapCount;k++) for(j=0;j<heapCount;j++) if((k!=j)&&(heaps[k].x==heaps[j].x)&&(heaps[k].y==heaps[j].y)) { printf("\nerror two heaps with same co ordinates %d %d ",k,j); //getchar(); } k=0; for(j=0;j<heapCount;j++) k+=heaps[j].count; } if(heapCount<minHeapCount) { minHeapCount=heapCount; minPosition=i; } if(debugLevel>0) printf("\n i:%d Heap count %d sum %d",i,heapCount,k); else printf("\n i:%d Heap count %d",i,heapCount); heapSum+=heapCount; /*if(i%updateAfter==0) {adjustBoard(flag); writeIncremental(i,flag);heapSum=0;loopCount=currentAntCount; }*/ } }//end of function /********************************************************************/ /*Function to drop the objects carried by the ants after all the iterations*/ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified:none */ /********************************************************************/ void dropFinal(int flag) { int i=0,j=0,position=-1,loopCount=0; /*if(flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS;*/ loopCount=currentAntCount; for(i=0;i<loopCount;i++) { if(ants[i].carrying==1) { if(flag==1) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position,flag); } } else { /*Find if a heap is present */ do { position=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position,flag); position=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position!=-1); } } } }//end of function /********************************************************************/ /* Function for the implementation of QuickSort */ /* Output: none */ /* Input: data structure, low and high indices */ /* Global structure modified:none */ /********************************************************************/ void quickSort( heap A[], int low,int high ) { int mid=0; if(low<high) { mid=partition(A,low,high); quickSort(A,low,mid); quickSort(A,mid+1,high); } } /********************************************************************/ /* Partition routine used by quick sort */ /* Output: partition location */ /* Input: data , low, high */ /* Global structure modified:none */ /********************************************************************/ int partition(heap a[], int low,int high) { heap temp; int x=0,i=0,j=0; i=low; j=high; x=a[low].count; while (1) { while (a[j].count<x) j=j-1; while (a[i].count>x) i=i+1; if(i<j) { temp=a[i]; a[i]=a[j]; a[j--]=temp; } else return(j); } } /********************************************************************/ /* Function used to write the cluster information */ /* Output: none */ /* Input:iteration flag */ /* Global structure modified:none */ /********************************************************************/ void writeClusterInformation(int flag) { FILE *fp=fopen("center.clt","w"); FILE *fp1; FILE *fp2; FILE *fp3; char temp[80]; int i=0,j=0,k=0; int lastCount=0; int rowCount,colCount,antCount; strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp3=fopen(temp,"a"); if(dataDump) {strcpy(temp,"");sprintf(temp,"%sTot.out",filename);fp1=fopen(temp,"a");strcpy(temp,"");sprintf(temp,"%sObj.out",filename);fp2=fopen(temp,"a");if(fp1==NULL||fp2==NULL)printf("\n Error in opening file in the writer Cluster Information routine\n"); } /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; antCount=MAXANTS; } else { rowCount=heapRow; colCount=heapRow; antCount=MAXANTSFORHEAPS; }*/ rowCount=currentRow; colCount=currentRow; antCount=currentAntCount; if(fp==NULL) { printf("\n Unable to open cluster center output file \n"); /*return;*/ exit(0); } /*sort the array according to the count value and write the value of the top three elements*/ if((flag==1)&&(!EntireHeaps)) quickSort(heaps,0,heapCount); if(EntireHeaps) {if(flag==1) lastCount=heapCount;else lastCount=newHeapCount; } else lastCount=c; for(i=0;i<lastCount;i++) { if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",newHeaps[i].Ocenter[k]); fprintf(fp,"\n"); } else { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); fprintf(fp,"\n"); } } if(dataDump) { fprintf(fp1,"\n Information from the Ant Based Algorithm \n"); fprintf(fp1,"\n Important Parameters : Board %d X %d Ants : %d Iterations %d Total Heaps %d ",rowCount,colCount,antCount,MAXITERATIONS,lastCount); } if(flag==0) { if(dataDump) { fprintf(fp1," TCreateForHeaps %f \n",TcreateForHeaps); fprintf(fp2,"\nTotal Heaps : %d\n",heapCount); fprintf(fp2,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); } fprintf(fp3,"\n@ %d\n",lastCount); } else if(dataDump) fprintf(fp1,"\n");if(dataDump) { fprintf(fp1,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); for(i=0;i<lastCount;i++) if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp2,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); } fprintf(fp1," %5d\n",newHeaps[i].count); fprintf(fp2," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp1," %5d\n",heaps[i].count); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]); fprintf(fp1," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]); fprintf(fp1," %5d\n",heaps[i].count); }} if(flag==0) { if(dataDump) fprintf(fp1,"\n Objects in the heaps \n");for(i=0;i<newHeapCount;i++) { if(dataDump) fprintf(fp1,"\n\n Heap %d\n \n",i+1);fprintf(fp3,"# %d %d\n",i ,newHeaps[i].count); for(j=0;j<newHeaps[i].count;j++){ for(k=0;k<features;k++){ fprintf(fp3,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]); if(dataDump) fprintf(fp1,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]);} if(dataDump) fprintf(fp1,"\n"); fprintf(fp3,"\n"); } } } fclose(fp); fclose(fp3); if(dataDump) { fclose(fp1);fclose(fp2); }}//end of flie /********************************************************************/ /* Function to initialise the new heaps */ /* Output: none */ /* Input:new Heap structure */ /* Global structure modified:none */ /********************************************************************/ void initialiseNewHeaps(heap newHeaps[]) { int i=0,j=0; for(i=0;i<lCount;i++) { newHeaps[i].count=0; for(j=0;j<features;j++) newHeaps[i].Ocenter[j]=V[i][j]; newHeaps[i].x=heaps[i].x; newHeaps[i].y=heaps[i].y; } }//end of function /********************************************************************/ /* Function to initialise the new heaps */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ int findPosition(int i) { int j,position=0; for(j=1;j<lCount;j++) { if(U[j][i]>U[position][i]) position=j; } printf("\n Position %d ",position); return(position); }//end of function find position /********************************************************************/ /* Function to add object */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ void addObject(int object,heap * heapPosition) { heapPosition->objects[heapPosition->count]=object; heapPosition->count++; }//end of function add object /********************************************************************/ /* Function to harden the outputs obtained from fcm */ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/ void harden(heap newHeaps[]) { int i,heapPosition=-1,sum=0,j=0; /*initialise the new heaps*/ initialiseNewHeaps(newHeaps); for(i=0;i<count;i++) { heapPosition=findPosition(i); addObject(i,&newHeaps[heapPosition]); } /* To check for degenerate partitions*/ for(i=0;i<lCount;i++) { if(newHeaps[i].count==0){for(j=i;j<lCount-1;j++){newHeaps[j]=newHeaps[j+1];}lCount--;i--;} } newHeapCount=lCount; for(i=0;i<lCount;i++) computeHeapParameters(&newHeaps[i],1); if(debugLevel>0) { for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\n sum = %d",sum);} }//end of function/********************************************************************/ /* Function to initialize the initial parameters for the ant algorithm*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void init() { int i=0,j=0; for(i=0;i<MAXROWS;i++) for(j=0;j<MAXCOLS;j++) board[i][j]=-9; heapCount=0; newHeapCount=0; heapRow=0; minPosition=-1; minHeapCount=100000; for(i=0;i<MAXANTS;i++) { ants[i].carrying=-1; ants[i].x=-1; ants[i].y=-1; ants[i].speed=-1; ants[i].dir=-1; } } /********************************************************************/ /* Function to initialize the initial board */ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void initialiseBoard() { int i,j; for(i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; }/********************************************************************/ /* Function to harden the outputs obtained from fcm(2nd stage)*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: Cluster center , cluster center count*/ /********************************************************************/void harden1() { int i=0,heapPosition=-1; for(i=0;i<heapCount;i++) cenCount[i]=0; for(i=0;i<n;i++) { heapPosition=findPosition1(i); addObject1(i,heapPosition); } writeInfo(); }//end of function/********************************************************************/ /* Function to find to which class the object belongs */ /* Output: Class number */ /* Input: object position */ /* Global Structure Modified: None */ /********************************************************************/int findPosition1(int i) { int j,position=0; for(j=1;j<heapCount;j++) { if(U[j][i]>U[position][i]) position=j; } return(position); }//end of function find position/********************************************************************/ /* Function to Write the output of the hardened objects to file*/ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/void writeInfo(){int i=0,j=0,k=0;FILE *fp=fopen("fcm.out","a");if(fp==NULL){printf("\n Unable to open fcm output file \n");return;}fprintf(fp,"\n@ %d\n",heapCount);for(i=0;i<heapCount;i++){fprintf(fp,"# %d %d\n",i,cenCount[i]);for(j=0;j<cenCount[i];j++){for(k=0;k<s;k++)fprintf(fp,"%8.2f ",clsCen[i][j][k]/scale[k]+minInput[k]);fprintf(fp,"\n");}}fclose(fp);return;}/********************************************************************/ /* Function to add a object to a cluster (2nd stage) */ /* Output: none */ /* Input: object poistion , cluster position */ /* Global Structure Modified: Cluster object and cluster count*/ /*******************************************************************/void addObject1(int object,int heapPosition) { int k=0; for(k=0;k<features;k++) clsCen[heapPosition][cenCount[heapPosition]][k]=X[object][k]; cenCount[heapPosition]++; return; }//end of function add object/********************************************************************/ /* Function to read the original classification of objects */ /* Output: none */ /* Input: none */ /* Global Structure Modified: None */ /*******************************************************************/void readOrg(){int i=0,k=0;char temp[80];FILE *fp;//= fopen(dataname,"r");strcpy(temp,"");sprintf(temp,"%sFull.data",filename);fp=fopen(temp,"r");if(fp==NULL){printf("\n Unable to open full data input file ");exit(0);}for(i=0;i<n;i++){fscanf(fp,"%f ",&orgData[i][0]);for(k=1;k<s+1;k++)fscanf(fp,"%f ",&orgData[i][k]);}return;}// end of function/********************************************************************/ /* Function to classify the objects in different clusters */ /* Output: none */ /* Input: the cluster objects, the original classification, */ /* number of objects in the cluster,file to write the data */ /* Global Structure Modified: None *//********************************************************************/int analysisData(float data[][s],float orgData[n][s+1],int count,FILE * fp){int i=0,j=0,k=0,type=1,max=0;heapInfo info;for(i=0;i<c;i++){info.classObj[i]=0;}info.total=0;info.total=count;for(i=0;i<count;i++)for(j=0;j<n;j++){type=1;for(k=0;k<s;k++)if(fabs(data[i][k]-orgData[j][k+1])>errThresh){type=-1;break;}if(type!=-1){info.classObj[(int)orgData[j][0]-1]++;break;}}max=0;for(k=0;k<c;k++){if(info.classObj[k]>info.classObj[max])max=k;fprintf(fp,"\nClass %d Objects % d ",k+1,info.classObj[k]);}j=0;for(k=0;k<c;k++){if(k!=max)j+=info.classObj[k];}fprintf(fp,"\n Total errors : %d \n",j);return(j);}//end of analyse/********************************************************************/ /* Function to read the cluster information */ /* Output: none */ /* Input: input file pointer , output file pointer */ /* Global Structure Modified: None *//********************************************************************/void readFCM(FILE* fp,FILE *fp1){int i=0,j=0,k=0,l=0;int totalRuns=0,heapCount=0,junk=0,sum=0;char ch;FILE *fp2=fopen("errors.out","a");ch = 'c'; while (ch != '$') fscanf (fp, "%c", &ch);fscanf(fp,"%d\n",&totalRuns);printf("\n total runs %d ",totalRuns);for(l=0;l<totalRuns;l++){fscanf(fp,"%c",&ch);fscanf(fp,"%d\n",&heapCount);fprintf(fp1,"\n \nExperiment %d \n ",l+1);sum=0;for(i=0;i<heapCount;i++){fscanf(fp,"%c",&ch);fscanf(fp," %d %d\n",&junk,&clsCenCount[i]);for(j=0;j<clsCenCount[i];j++)for(k=0;k<s;k++)fscanf(fp,"%f",&fcmData[i][j][k]);fscanf(fp,"\n");fprintf(fp1,"\n\n Heap %d Total Objects %d \n",i+1,clsCenCount[i]);sum+=analysisData(fcmData[i],orgData,clsCenCount[i],fp1);}fprintf(fp2," %3d %3d %3d \n",l,sum,heapCount);}fprintf(fp2,"\n --------------------------\n");fclose(fp2);return;}//end of function/********************************************************************/ /* Function to update the board parameters */ /* Output: none */ /* Input: none */ /* Global Structure Modified: board size, ant count *//********************************************************************/void adjustBoard(int flag){int newRow=0,newAnt=0,antDiff=0,antsKilled=0,i=0,position[MAXANTS],position1=-1,j=0,k=0,a,b; newRow= (int)ceil(sqrt(4.0*heapSum/updateAfter)); newAnt= (int)ceil((heapSum*1.0/updateAfter)*1.0/3.0); if(newAnt<minAnts)newAnt=minAnts; if(newRow<rowMin)newRow=rowMin;antDiff=currentAntCount-newAnt; if((antDiff>0)&&(newAnt>=minAnts)) {for(i=0;i<currentAntCount;i++){if(ants[i].carrying==-1){position[antsKilled++]=i;}} if(antsKilled>=antDiff){for(i=0;i<antDiff;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1];for(k=i+1;k<antsKilled;k++)position[k]--; } currentAntCount=newAnt; }else {for(i=0;i<antsKilled;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1]; for(k=i+1;k<antsKilled;k++)position[k]--; }if(flag==1) { for(i=currentAntCount-1,k=0;k<antDiff-antsKilled;k++,i--) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position1,flag); }else { dropObject(&ants[i],flag); } } } else { //flag is zero 2nd stage /*Find if a heap is present */ do { position1=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position1].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position1,flag); position1=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position1!=-1); }//end else currentAntCount=newAnt;}//end elsecurrentAntCount=newAnt;}//end iffor(i=0;i<newAnt;i++){if((ants[i].x>=newRow)||(ants[i].y>=newRow)) { a=lrand48()%newRow; b=lrand48()%newRow; ants[i].x=a; ants[i].y=b; }} //Done with ants, now adjust the boardif((currentRow>newRow)&&(newRow>=rowMin)){for(i=0;i<heapCount;i++){if((heaps[i].x>=newRow)||(heaps[i].y>=newRow)) {do { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionheaps[i].x=a;heaps[i].y=b;board[a][b]=9;}//end if}//end for for(i=0;i<currentAntCount;i++){if((ants[i].carrying==1)&&((ants[i].x>=newRow)||(ants[i].y>=newRow))){//adjust the ant locationdo { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionants[i].x=a;ants[i].y=b;}//end if}//end for currentRow=newRow;}//end if }//end of function void writeIncremental(int iteration,int flag){FILE *fp=fopen("dump.txt","w");int i=0,j=0,k=0;fprintf(fp,"Stage %d\n",flag);fprintf(fp,"Board %d\n",currentRow);fprintf(fp,"Ants %d\n",currentAntCount);fprintf(fp,"Iteration %d\n",iteration);fprintf(fp,"Heaps %d\n",heapCount); if(flag==0)fprintf(fp,"NewHeapCount %d\n",newHeapCount); fprintf(fp,"Ants\n");for(i=0;i<currentAntCount;i++){fprintf(fp,"%d %d %d %d %d ",ants[i].x,ants[i].y,ants[i].carrying,ants[i].speed,ants[i].dir);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",ants[i].data[k]);fprintf(fp,"\n");}fprintf(fp,"Heaps\n");for(i=0;i<heapCount;i++){fprintf(fp,"%d %d %d %d %8.2f %8.2f \n",heaps[i].x,heaps[i].y,heaps[i].count,heaps[i].disPosition,heaps[i].Dmax,heaps[i].Dmean);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Ocenter[k]);fprintf(fp,"\n");for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Odissim[k]);fprintf(fp,"\n");if(flag==1){for(j=0;j<heaps[i].count;j++)fprintf(fp,"%d ",heaps[i].objects[j]);fprintf(fp,"\n");}}if(flag==0){fprintf(fp,"newHeaps\n");for(i=0;i<newHeapCount;i++){fprintf(fp,"%d\n",newHeaps[i].count);for(j=0;j<newHeaps[i].count;j++)fprintf(fp,"%d ",newHeaps[i].objects[j]);fprintf(fp,"\n");}}fclose(fp);}//end of function/********************************************************************/ /* Function Main */ /********************************************************************/ int main(int argc ,char** argv) { int sum=0,k=0,i=0,j=0; char temp[80]; FILE *fp=fopen("fcm.out","w"); FILE *fp1; FILE *fp2=fopen("antAnalysis.out","a"); FILE *fp3=fopen("fcmAnalysis.out","a"); FILE *fp4=fopen("errors.out","w"); FILE *fp5; fclose(fp4); sprintf(temp,"%sObj.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sTot.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp1=fopen(temp,"w"); fprintf(fp,"\n$%d",EXPRUN); fprintf(fp1,"\n$%d",EXPRUN); fclose(fp); fclose(fp1); if(argc==2)sscanf(argv[1],"%d",&debugLevel); printf("\n Debug level %d\n",debugLevel); for( i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; //Read from the file readInput(); //Compute the distance of all the points if(maxDist) { Dmax=computeDistance(); //Compute the maximum distance fp5=fopen("maxData.txt","w");fprintf(fp5,"%f",Dmax);fclose(fp5); } else {fp5=fopen("maxData.txt","r");fscanf(fp5,"%f",&Dmax);fclose(fp5); } printf("\n %f \n",Dmax); //Initialise the board for(k=0;k<EXPRUN;k++) { init(); sum=0; srand48(state1[k]); initialiseBoard(); initialise(1); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(1); printf("\n %d \n",heapCount); //Simulate the working of ants iterate(1); //drop the objects after all the iterations dropFinal(1); //to verify the correctness for(i=0;i<heapCount;i++) sum+=heaps[i].count; //write the cluster centers to the file writeClusterInformation(1); printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); //getchar(); //Run FCM // heapCount=2973;/* To be commented */ printf("\n\n k %d \n\n",k); Fcm(data); //compute new board size. lCount=heapCount; heapRow=(int)ceil(sqrt(4*heapCount)); newHeapCount=lCount; printf("\n LCount %d newHeapCount %d heap Row %d \n",lCount,newHeapCount,heapRow); //harden the objects harden(newHeaps); //iterate with the heaps as the objects. initialiseBoard(); initialise(0); for(i=0;i<lCount;i++) computeHeapParameters(&heaps[i],0); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(0); printf("\n %d \n",heapCount); //getchar(); //Simulate the working of ants iterate(0); dropFinal(0); writeClusterInformation(0); sum=0; for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); // getchar(); Fcm(data); harden1(); } fp=fopen("fcm.out","a"); fp1=fopen(temp,"a"); fprintf(fp,"\n"); fprintf(fp1,"\n"); fclose(fp); fclose(fp1); fp=fopen("fcm.out","r"); fp1=fopen(temp,"r");printf("\n Before read org\n");readOrg();printf("\nafter read org\n");readFCM(fp1,fp2);printf("\n After 1st read fcm\n");readFCM(fp,fp3);printf("\n After 2 fcm read \n");return(1); }//end of main /****************************************************************/ float NORM(feature , feature); void find_covar(); void Fcm (irisData Data[MAXDATA]) { int i,j,l; FILE *ofile; char temp[80]; int flag=0;//added by parag FILE *iniClsCen=fopen("center.clt","a+"); if(iniClsCen==NULL) { printf("\n Unable to open the initial cluster center file\n"); printf("\n choosing random cluster centers....\n"); flag=1; } strcpy(temp,""); sprintf(temp,"%s.data",filename); strcpy (fname,temp); /* Read from this file */ m=2.0; /* The exponent */ /*GET_INPUTS1(fname);*/ /* read in feature vectors */ for (j=0; j<n ; j++) /* Read File in row-major */ for (i=0; i<s ; i++) /* format */ X[j][i]=Data[j][i]; Random_seed=state1[run];/*randseed*/ srand48(Random_seed); for (run=0;run<TOTRUNS;run++) { //flag=1;//for testing random values if (EntireHeaps) lCount=heapCount; else lCount=c; for(i=0;i<lCount;i++) for(j=0;j<s;j++) V[i][j]=0; for(i=0;i<lCount;i++) { for(l=0;l<s;l++) { if(flag==1) { rand_index = lrand48() % n; V[i][l] = X[rand_index][l]; } else { fscanf(iniClsCen,"%f ",&V[i][l]); } }//end for } eps=0.001; stop = FALSE; /* This loop finds the final cluster center and the corresponding U values */ z = 0; while (stop == FALSE) { z++; UMAT(U,V,X); /** Update the U matrix **/ stop = FINISHED(U1,eps); CLUSTER(U,X); /** Get new cluster center **/ printf("Iteration: %d\n\n", z); } /* end while */ printf("Number of iterations: %d\n\n", z);strcpy(temp,""); sprintf(temp,"%sFCM.out",filename);if(dataDump) Output(temp); /* output the results */ }/*end for*/ if(dataDump) { ofile=fopen(temp,"a"); for (i=0; i <= mins; i++) fprintf(ofile, "Min %d of %10.3f occurred %d times\n", i, mintab[i], mincount[i]); fprintf(ofile, "Average iterations %f\n", (float)aveit/(float)TOTRUNS); fclose(ofile); } }/* end Main */ /* The GET_INPUTS1 procedure opens an input file, reads the number of input vectors, the number of features per vector, the number of clusters, and epsilon, then it reads the input values */ void GET_INPUTS1(char fname[]) //char fname[]; { /* Parameters: fname -- name of file containing input info. */ FILE *infile ;//*fopen(); //char junk[10][80]; char realfname[80]; char ch; char fileName1[80]; //int temp[10], i, j, inputs, outputs, count; int i,j; sprintf (realfname, "%s", fname); /* open input file */ if(normalize==1) strcpy(fileName1,"gtest1.data"); else strcpy(fileName1,fname); if((infile = fopen (fileName1, "r")) == NULL) printf("\n CAN'T OPEN %s\n",realfname); else { ch = 'c'; /* Discard leading comments */ while (ch != '#') fscanf (infile, "%c", &ch); for (j=0; j<n ; j++) /* Read File in row-major */ { /* format */ for (i=0; i<s ; i++) fscanf (infile, "%f", &X[j][i]); /* fscanf (infile, "%d", &temp[1]); */ /* end for */ } /* end for */ fclose(infile); /* close input file */ }/* end else */ } /* end GET_INPUTS1 */ /* The NORM function computes the norm of two vectors, x and v, of dimension s. This gives an indication of the distance between them */ float NORM( feature x, feature v) //feature x, v; { /* Parameters : x -- a local copy of an input vector v -- a local copy of a cluster center */ int i,j; /* loop variable */ double sum; /* the square root of sum is the norm; sum is the sum of the differences squared */ float mat1[s]; float mat2[s]; if (maha) { for (i=0; i<s; i++) mat1[i]=x[i]-v[i]; for(i=0;i<s;i++) { sum =0; for(j=0;j<s;j++) sum += mat1[j] * inv_cov[j][i]; mat2[i] = sum; } sum =0; for(j=0;j<s;j++) sum += mat1[j]*mat2[j]; } else { sum = 0; for(j=0;j<s;j++) sum += (x[j] - v[j])* (x[j] - v[j]); } return (float)(sqrt(sum)); } /* end NORM */ /* The UMAT procedure calculates the updated U matrix according to Bezdek's formula. Its side-effect is the update of the global array U1 */ void UMAT( matrix U,center V, objects X) /*matrix U; center V; objects X;*/ { /* Parameters: U, V, and X: same as in main program */ int i, j, k,l ;/* loop variables *///, class /* class whose cluster center //is closest to pattern k */; float d1,d2,d; float sum; int exact; for (k=0;k<n;k++) { /*printf("\n k %d ",k);*/ exact=false; for (i=0;i<lCount;i++) { sum=0; for (j=0;j<lCount;j++) { d1=NORM(X[k],V[i]); d2=NORM(X[k],V[j]); if(d2!=0) { d= d1/d2; d= d * d;/* pow(d1/d2,2.0/(m-1.0)); */ sum+=d; } else { exact = true; for(l=0;l<lCount;l++) if (l==j) U1[l][k]=1.0; else U1[l][k]=0.0; break; } } if (exact!=true) U1[i][k]=1.0/sum; } } } /* end UMAT */ /* The function FINISHED determines if a termination occurs. If not it updates U with U1, so its side-effect is the potential modification of U */ BOOLEAN FINISHED( matrix U1,float eps) //matrix U1; float eps; { /* Parameters: U1, eps-- same as in main */ float sum; /* sum of squared differences between corresponding elements of U and U1 */ int i,k; /* loop control variabes */ BOOLEAN finished; /* set to true if all corresponding elements are within epsilon */ finished = TRUE; sum = 0; for (i=0; i<lCount; i++) for (k=0; k<n; k++) sum += (U[i][k] - U1[i][k])*(U[i][k]-U1[i][k]); if (sqrt(sum) > eps) { finished = FALSE; for (i=0; i<lCount; i++) for (k=0; k<n; k++) U[i][k] = U1[i][k]; } /* end if */ return finished; } /* end FINISHED */ /* The CLUSTER procedure determines cluster centers in V for the c classes being searched for. The global array V is updated */ void CLUSTER( matrix U, objects X) //matrix U; objects X; { /* Parameters: U, X -- as in main */ int i, j, k; /* loop control variables */ feature num; /* numerator in the cluster center computation formula presented by Bezdek */ float denum; /* denumenator in the obove formula */ for (i=0; i<lCount; i++) { denum = 0; for (j=0; j<s; j++) { num[j] = 0; for (k=0; k<n; k++) num[j] += U[i][k] * U[i][k] * X[k][j]; /* pow(U[i][k],m) * X[k][j]; */ } /* end for */ for (k=0; k<n; k++) denum += U[i][k] * U[i][k]; /* pow(U[i][k],m); */ for (j=0; j<s; j++) V[i][j] = num[j] / denum; } /* end for */ } /* end CLUSTER */ float Compute_Jm(center V, objects X) //center V; //objects X; { int i, k,found; double Jm_value; float u,dik; Jm_value = 0; for (k=0; k<n; k++) { found = FALSE; for (i=0; i<lCount; i++) { dik=NORM(X[k],V[i]); dik=dik*dik; if (dik==0.0) { if (found == FALSE) { u=1.0; found = TRUE; printf("found the case with dik=0\n"); } else { printf("\n cant proceed with this initialization"); exit(1); } } else { if (found != TRUE) u=U1[i][k]; /* get_Uvalue(V,X,dik,k); */ else u=0.0; } Jm_value += u * u * dik;/* pow(u, m) * dik; */ } } return (Jm_value); } /* end Compute_Jm */ /* The Output procedure outputs the U matrix which gives the fuzzy measure of each feature belonging to a cluster center. It also outputs the cluster center for each class */ void Output(char fname[]) //char fname[80]; /* Parameters: U, V -- same as in main */ { int i, j, found; /* loop control variables */ float J2c; if ((fp=fopen(fname,"a"))==NULL) printf("\n CAN'T OPEN %s\n",fname); else { fprintf(fp,"\n The cluster centers are: \n"); fprintf(fp,"\n \n"); for (i=0; i<lCount; i++) { fprintf(fp,"\nCluster center %d: ",i+1); fprintf(fp,"\n"); for (j=0; j<s; j++) fprintf(fp,"%8.7f ",V[i][j]); } /* end for */ fprintf(fp,"\nThe membership grades for the feature vectors are:\n"); for (j=0; j<n; j++) { fprintf(fp,"\n"); for (i=0; i<lCount; i++) fprintf(fp," %8.7f",U[i][j]); } /* end for */ } /* end if */ J2c= Compute_Jm(V,X); found =0; for (i=0;i<= mins; i++){ if ((found == 0) && ((J2c - mintab[i]) < .001) && ((J2c - mintab[i]) > -.001)){ mincount[i]++; found = 1; } } if (found == 0){ mins++; mintab[mins]=J2c; mincount[mins]=1; } fprintf(fp,"\nJ%3.1f = %f", m,J2c); fprintf(fp, "Number of iterations: %d\n\n", z); aveit=aveit + z; fclose(fp); } /***************************************************************/ void find_covar(int m) //int m; { int i,j,k; float mean[s],sum; for (i=0;i<s;i++) mean[i]=0; for (i=0;i<s;i++) for (j=0;j<m;j++) mean[i]+=X[j][i]; for (i=0;i<s;i++) mean[i]/=m; for (i=0;i<s;i++) for (j=0;j<s;j++) { sum=0; for (k=0;k<m;k++) sum+=(X[k][i]-mean[i])*(X[k][j]-mean[j]); Y[i][j]=sum/m; } }
Parag Kanade/fuzzy ants/Gauss500-5/headerStatic.h
/********************************************************************//* Ant Class parameters *//* SPEED # amplitude of moves [1,10] *//* P direction Probability to move in the same direction [.5,1] *//* Max carry : Maximum object carrying time [20,200] *//* P load Probability to pick up a single object [0.4,0.8] *//* P destroy probability to destroy a heap of two objects [0,0.6] *//* T remove min. dissimilarity necessary for removing an object *//* from a heap [.1,.2] *//* T create max dissimilarity permitted for creating a heap[.05,.2]*//********************************************************************/ #include <stdio.h>#include <math.h>#include <string.h>#include<stdlib.h>#include <ctype.h>#include <time.h>#define MAXANTS 167#define MAXDATA 500#define MAXANTSFORHEAPS 45#define MAXITERATIONS 1000#define MAXROWS 45#define MAXCOLS 45#define EXPRUN 10#define Tremove 1.50#define Tcreate 0.5#define Pdrop 0.2#define Pdestroy 0.3#define Pload 0.3#define normalize 0#define EntireHeaps 1#define TcreateForHeaps 0.19#define features 2#define filename "gauss500_05"#define errThresh 0.1#define dataDump 1#define maxDist 1#define INITIALOBJECTS 75#define OBJINC 10/* some type definitions to make C code a little more readable */#define TRUE 1#define FALSE 0#define n MAXDATA /* number of input vectors */#define s features /* number of features */#define c 5 /* number of clusters */#define TOTRUNS 1 /* number of V's to write out */#define false 0#define true 1#define maha 0#define square 0extern int count;int debugLevel=0;/* To debug the code and verify the correctness of algorithms*/int currHeapCount=0;typedef int BOOLEAN;typedef short TYPE_IN_DATA; /* Type of input binary data */typedef float feature[s]; /* Type of each input; made up of input features */typedef float irisData[s];typedef feature objects[MAXDATA]; /* Type of array holding all inputs */typedef feature center[MAXDATA]; /* Type of array holding cluster centers */typedef float matrix[MAXDATA][MAXDATA];/* Type of the matrix containing membership grades */typedef struct Heap {float Dmax;//maximum dissimilar distanceirisData Ocenter;//center objectfloat Dmean;//mean of the distance between the center and all the objectsirisData Odissim;//most dissimilar objectint x;//x position on the boardint y;//y position on the boardint count;//number of objects in the heapsint disPosition;//most dissimilar objectint objects[MAXDATA];int objCount;}heap;typedef struct Ant{int x;int y;int carrying;int speed;int dir;irisData data;}ant;float orgData[n][s+1];float fcmData[MAXDATA][n][s];int clsCenCount[MAXDATA];int currentRow=0;int currentAntCount=0;int updateAfter=50;int heapSum=0;int minAnts=3;int rowMin=5;typedef struct HeapInfo{int total;int classObj[c];} heapInfo;/*heapInfo info[MAXDATA];*//********************************************************************//***Function decelarations*//********************************************************************//***For ant based algorithm*/void readInput();float computeDistance();float computeDistanceBetween2(irisData a,irisData b);float findMax(float *distance);float value(irisData a);int found(int a , int b);void initialise(int flag);int findObject(int a,int b);void initialiseAnts(int flag);void moveNext(ant* a,int flag);void computeHeapParameters(heap* data,int flag);void pickObject1(ant *a,int position,int flag);void pickObject2(ant *a , int position,int flag);void pickObjectn(ant *a,int position,int flag);void pick(ant *a,int flag);void dropObject(ant* a,int flag);int findInNewheaps(irisData object);void dropObject1(ant* a, int position,int flag);void drop(ant* a,int flag);void move(ant* a,int flag);void iterate(int flag);void dropFinal(int flag);int partition(heap a[], int low,int high);void quickSort( heap A[], int low,int high ) ;void writeClusterInformation(int flag);void initialiseNewHeaps(heap newHeaps[]);int findPosition(int i);void harden(heap newHeaps[]);void harden1();int findPosition1(int );void writeInfo();void addObject1(int ,int);void readFCM(FILE *,FILE *);void readOrg();int findInData(irisData input,int iflag);void adjustBoard(int flag);void writeIncremental(int iteration,int flag);/********************************************************************//***For FCM algorithm*/void GET_INPUTS1(char []);void UMAT( matrix,center,objects);BOOLEAN FINISHED(matrix, float);void CLUSTER( matrix, objects);void Output(char[]);void Fcm();/********************************************************************/
Parag Kanade/fuzzy ants/Gauss500-5/maxData.txt
1.532994
Parag Kanade/fuzzy ants/Multiple Sclerosis/headerStatic.h
/********************************************************************//* Ant Class parameters *//* SPEED # amplitude of moves [1,10] *//* P direction Probability to move in the same direction [.5,1] *//* Max carry : Maximum object carrying time [20,200] *//* P load Probability to pick up a single object [0.4,0.8] *//* P destroy probability to destroy a heap of two objects [0,0.6] *//* T remove min. dissimilarity necessary for removing an object *//* from a heap [.1,.2] *//* T create max dissimilarity permitted for creating a heap[.05,.2]*//********************************************************************/ #include <stdio.h>#include <math.h>#include <string.h>#include<stdlib.h>#include <ctype.h>#include <time.h>#define MAXANTS 31#define MAXDATA 98#define MAXANTSFORHEAPS 10#define MAXITERATIONS 1000#define MAXROWS 20#define MAXCOLS 20#define EXPRUN 50#define Tremove 2.50#define Tcreate 0.5#define Pdrop 0.2#define Pdestroy 0.3#define Pload 0.3#define normalize 0#define EntireHeaps 1#define TcreateForHeaps 0.22#define features 5#define filename "ms"#define errThresh 0.1#define dataDump 1#define maxDist 0#define INITIALOBJECTS 75#define OBJINC 10/* some type definitions to make C code a little more readable */#define TRUE 1#define FALSE 0#define n MAXDATA /* number of input vectors */#define s features /* number of features */#define c 2 /* number of clusters */#define TOTRUNS 1 /* number of V's to write out */#define false 0#define true 1#define maha 0#define square 0extern int count;int debugLevel=0;/* To debug the code and verify the correctness of algorithms*/int currHeapCount=0;typedef int BOOLEAN;typedef short TYPE_IN_DATA; /* Type of input binary data */typedef float feature[s]; /* Type of each input; made up of input features */typedef float irisData[s];typedef feature objects[MAXDATA]; /* Type of array holding all inputs */typedef feature center[MAXDATA]; /* Type of array holding cluster centers */typedef float matrix[MAXDATA][MAXDATA];/* Type of the matrix containing membership grades */typedef struct Heap {float Dmax;//maximum dissimilar distanceirisData Ocenter;//center objectfloat Dmean;//mean of the distance between the center and all the objectsirisData Odissim;//most dissimilar objectint x;//x position on the boardint y;//y position on the boardint count;//number of objects in the heapsint disPosition;//most dissimilar objectint objects[MAXDATA];int objCount;}heap;typedef struct Ant{int x;int y;int carrying;int speed;int dir;irisData data;}ant;float orgData[n][s+1];float fcmData[260][n][s];int clsCenCount[260];int currentRow=0;int currentAntCount=0;int updateAfter=50;int heapSum=0;int minAnts=3;int rowMin=5;typedef struct HeapInfo{int total;int classObj[c];} heapInfo;/*heapInfo info[MAXDATA];*//********************************************************************//***Function decelarations*//********************************************************************//***For ant based algorithm*/void readInput();float computeDistance();float computeDistanceBetween2(irisData a,irisData b);float findMax(float *distance);float value(irisData a);int found(int a , int b);void initialise(int flag);int findObject(int a,int b);void initialiseAnts(int flag);void moveNext(ant* a,int flag);void computeHeapParameters(heap* data,int flag);void pickObject1(ant *a,int position,int flag);void pickObject2(ant *a , int position,int flag);void pickObjectn(ant *a,int position,int flag);void pick(ant *a,int flag);void dropObject(ant* a,int flag);int findInNewheaps(irisData object);void dropObject1(ant* a, int position,int flag);void drop(ant* a,int flag);void move(ant* a,int flag);void iterate(int flag);void dropFinal(int flag);int partition(heap a[], int low,int high);void quickSort( heap A[], int low,int high ) ;void writeClusterInformation(int flag);void initialiseNewHeaps(heap newHeaps[]);int findPosition(int i);void harden(heap newHeaps[]);void harden1();int findPosition1(int );void writeInfo();void addObject1(int ,int);void readFCM(FILE *,FILE *);void readOrg();int findInData(irisData input,int iflag);void adjustBoard(int flag);void writeIncremental(int iteration,int flag);/********************************************************************//***For FCM algorithm*/void GET_INPUTS1(char []);void UMAT( matrix,center,objects);BOOLEAN FINISHED(matrix, float);void CLUSTER( matrix, objects);void Output(char[]);void Fcm();/********************************************************************/
Parag Kanade/fuzzy ants/Multiple Sclerosis/maxData.txt
3.829970
Parag Kanade/fuzzy ants/Multiple Sclerosis/ms.c
#include "headerStatic.h" /*******************************************************************/ /*** Global Variables ***/ irisData data[MAXDATA]; //To hold the data read from the file int count=0; //Count of the total number of data elements int heapCount=0; // Total number of heaps int heapRow=0; // Rows for the second iteration with heaps int newHeapCount=0; // Count of the heaps for the second iteration heap heaps[MAXDATA]; // Data structure to hold the heap information heap newHeaps[MAXDATA]; // Data Structure to hold the new heap information // For the second iteration int board[MAXROWS][MAXCOLS]; // Board on which the objects are located ant ants[MAXANTS]; // Data structure to hold the ants float Dmax=0; // Distance of the most dissimilar object pair int minHeapCount=100000; // Counter to hold the minimum heap count, used only for academic purpose // no use in the algorithm int minPosition; // the minimum heap iteration , only for academic purpose // no use in the algorithm float clsCen[MAXDATA][MAXDATA][s];//to hold the objects after hardening int cenCount[MAXDATA];//to hold the number of objects after hardening /********************************************************************/ /*** Varaibles to normalize the features between 0 and 1 */ float minInput[features], maxInput[features],scale[features],minForHeaps[features],maxForHeaps[features],scaleForHeaps[features]; /********************************************************************/ /** Variables for the FCM algorithm */ int temp[200]; /* for square matrix tests */ float eps,m; matrix U, U1; BOOLEAN stop; center V; objects X; char fname[80]; FILE *fp; int run; float inv_cov[s+1][s+1]; /* inverse of covariance matrix Y */ float Y[s][s]; long rand_index, Random_seed; long state1[52] = { 9347, 3835, 5194, 8310, 346, 535, 5297, 6711, 77, 3834, 668, 4175, 6868, 5890, 9304, 8462, 5269, 920, 65392, 41600, 70119, 91032, 76220, 26245, 4746, 73608, 32823, 63264, 75641, 99104, 36534, 24704, 98255, 72266, 75336, 65152, 7269, 63163, 88471, 27271, 43641, 76649, 47773, 23777, 27491, 35926, 16651, 48652, 89766, 90921, 6056 }; int z; int mins=0; int aveit =0; float mintab[200]; int mincount[200]; long start,end,total; int lCount;//added by parag /********************************************************************/ /********************************************************************//*int lrand48(){return(rand());}void srand48(int a){return;}*//********************************************************************/ /********************************************************************/ /* Function to read the input data set */ /* The file name is assumed to be itest.data */ /* Status: Tested */ /* Output: Data from the file into the "data" (Global) data structure */ /* Output: Count (Global), the count of the number of objects */ /********************************************************************/ void readInput() { FILE *fp; char fname[80]; int i=0,j=0; char ch; sprintf(fname,"%s.data",filename); /* Check if the input file is opened */ if((fp=fopen(fname,"r"))==NULL) { printf("\n Unable to open input file \n"); exit(0); } /*initialise the minimum maximum and the scale */ for(i=0;i<features;i++) { minInput[i]=1000; maxInput[i]=0; minForHeaps[i]=1000; maxForHeaps[i]=0; scale[i]=0; scaleForHeaps[i]=0; } /* Discard leading comments */ ch = 'c'; while (ch != '#') fscanf (fp, "%c", &ch); i=0; /* Parse the file and populate the data structure */ while(!feof(fp)) { for(j=0;j<features;j++) { fscanf(fp,"%f ",&data[i][j]); } fscanf(fp,"\n"); for(j=0;j<features;j++) { if(data[i][j]<minInput[j]) minInput[j]=data[i][j]; if(data[i][j]>maxInput[j]) maxInput[j]=data[i][j]; } i++; } count=i; /* Normailze the feature values in between 0 and 1 */ for(j=0;j<features;j++) { if(minInput[j]!=maxInput[j]) scale[j]=1.0/(maxInput[j]-minInput[j]); else scale[j]=1.0; } for(i=0;i<count;i++) { for(j=0;j<features;j++) data[i][j]=(data[i][j]-minInput[j])*scale[j]; } fclose(fp); return; }//end of function /********************************************************************/ /*Function to compute the eucldiean distance for all input data set */ /* Output : an array conatining the distance of each object with the other */ /********************************************************************/ float computeDistance() { float distance,dist=0; int i=0,j=0,k=0; distance=0; for(j=0;j<count;j++) for(i=0;i<count;i++) { for(k=0;k<features;k++) dist+=sqrt((data[j][k]-data[i][k])*(data[j][k]-data[i][k])); if(distance<dist)distance=dist; dist=0; } return(distance); } /********************************************************************/ /* Function to compute the distance between two objects */ /* Output : Euclidean d istance between the two input objects */ /********************************************************************/ float computeDistanceBetween2(irisData a,irisData b) { float temp=0; int i=0; for(i=0;i<features;i++) temp+=(a[i]-b[i])*(a[i]-b[i]); temp=sqrt(temp); return(temp); } /********************************************************************/ /* Function to find the maximum distance between the input objects*/ /* Output: the maximum distance */ /* Input : The array of distances between objects */ /********************************************************************/ /*float findMax(float *distance) { int i=0,j=0; float max=distance[0]; for(i=0;i<count;i++) for(j=0;j<count;j++) { if(max<distance[i*count+j]) max=distance[i*count+j]; } return(max); }*/ /********************************************************************/ /* Function to compute the value of an object */ /********************************************************************/ float value(irisData a) { int i=0; float temp=0; for(i=0;i<features;i++) temp+=a[i]*a[i]; return(sqrt(temp)); } /********************************************************************/ /* Function to find the object in the data structure */ /* Output : The position of the object in the data */ /* Input : The object */ /********************************************************************/ int findInData(irisData object,int iFlag) { int i=0,lastCount=0,j,position=-1,flag[features],flg;if(iFlag==1)lastCount=MAXDATA;else{}for(i=0;i<lastCount;i++){ for(j=0;j<features;j++) if(fabs(object[j]-data[i][j])<0.00001) flag[j]=1; else { flag[j]=0; break;} flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /* Function to find whether there is an object on the board at a,b */ /* Output : a flag indicating whether an object is found or not */ /* Input : The row and column indicating the board position */ /********************************************************************/ int found(int a , int b) { if(board[a][b]==9) return 1; else return 0; } /********************************************************************/ /* Function to initialize the initial board */ /* Output : None */ /* Global Structures modified : heaps */ /* Input : Flag indicating the iteration 1: First 0: Second */ /********************************************************************/ void initialise(int flag) { int a,b,i=0,k=0; int loopCount,rowCount,colCount; /* Initialize the row, column and number of heaps */ if(flag==1) { loopCount=count; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=lCount; rowCount=heapRow; colCount=heapRow; } /* Initialize the heaps */ for(i=0;i<loopCount;i++) { heaps[i].count=0; heaps[i].x=0; heaps[i].y=0; heaps[i].disPosition=0; heaps[i].Dmax=0; heaps[i].Dmean=0; } for(i=0;i<loopCount;i++) { /*find a board position which is empty*/ do { a=lrand48()%rowCount; b=lrand48()%colCount; } while(found(a,b)); /*Allocate the object to that place and assign a heap to it*/ heaps[i].x=a; heaps[i].y=b; heaps[i].count=1; heaps[i].Dmax=0; heaps[i].Dmean=0; if(flag==1) { heaps[i].objects[0]=i; for(k=0;k<features;k++)heaps[i].Ocenter[k]=data[i][k]; } else { for(k=0;k<features;k++) heaps[i].Ocenter[k]=newHeaps[i].Ocenter[k]; } heaps[i].disPosition=0; board[a][b]=9; if((debugLevel>0)&&(flag==1))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],data[heaps[i].objects[0]][0]); if((debugLevel>0)&&(flag==0))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],newHeaps[i].Ocenter[0]); } /*initialise the initial heap count*/ heapCount=loopCount; currentRow=rowCount; } /********************************************************************/ /* Function to find whether an heap is present at the location a b */ /* Output : Flag indicating the presencs of the heap */ /* Input : Roe and column indicating the board position */ /********************************************************************/ int findObject(int a,int b) { int i; int position=-1; for(i=0;i<heapCount;i++) { if((heaps[i].x==a)&&(heaps[i].y==b)) { position=i; break; } } return(position); } /********************************************************************/ /* Function initialize the ants */ /* Output : None */ /* Input : Flag indicating the iteration */ /* Global Variables Modified : ant, heapCount, heaps, board */ /********************************************************************/ void initialiseAnts(int flag) { int i=0,a=0,b=0,position,j=0,loopCount=0,rowCount,colCount,k=0; if(flag==1) { loopCount=MAXANTS; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=MAXANTSFORHEAPS; rowCount=heapRow; colCount=heapRow; } for(i=0;i<loopCount;i++) { /*generate random positions for the ants*/ a=lrand48()%rowCount; b=lrand48()%colCount; ants[i].x=a; ants[i].y=b; /*Find if an object is present at that position or not*/ if(board[a][b]==9) { ants[i].carrying=1; /*find the heap at that location*/ position=findObject(a,b); if(position==-1) { printf("\n Error in logic: Ant init \n"); //getchar(); break; } else { /*Assign the heap data to the ant data and decrement the heap count*/ if(flag==1){ for(k=0;k<features;k++)ants[i].data[k]=data[heaps[position].objects[0]][k]; }else{for(k=0;k<features;k++)ants[i].data[k]=heaps[position].Ocenter[k];} for(j=position;j<heapCount-1;j++) heaps[j]=heaps[j+1]; heapCount--; } /*Clear the board position */ board[a][b]=-9; } else ants[i].carrying=-1; ants[i].speed=0; ants[i].dir=lrand48()%8; printf("\n Ant %2d X: %2d Y: %2d Carying : %2d ",i,ants[i].x,ants[i].y,ants[i].carrying); } currentAntCount=loopCount; } /********************************************************************/ /* Function to move the ant */ /* Output: None */ /* Input: Ant to be moved and the flag indicating the iteration */ /********************************************************************/ void moveNext(ant* a,int flag) { int rowCount,colCount; /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; } else { rowCount=heapRow; colCount=heapRow; }*/rowCount=currentRow;colCount=currentRow; /*Depending upon the direction move the ant*/ switch (a->dir) { case 0: a->y++; if(a->y>=colCount)a->y=0; break; case 1: a->x--; a->y++;; if(a->x<0)a->x=rowCount-1; if(a->y>=colCount)a->y=0; break; case 2: a->x--; if(a->x<0)a->x=rowCount-1; break; case 3: a->x--; a->y--; if(a->x<0)a->x=rowCount-1; if(a->y<0)a->y=colCount-1; break; case 4: a->y--; if(a->y<0)a->y=colCount-1; break; case 5: a->x++; a->y--; if(a->x>=rowCount)a->x=0; if(a->y<0)a->y=colCount-1; break; case 6: a->x++; if(a->x>=rowCount) a->x=0; break; case 7: a->x++; a->y++; if(a->x>=rowCount)a->x=0; if(a->y>=colCount)a->y=0; break; } }//end of function /********************************************************************/ /* Function to compute the parameters of the heap */ /* Output: None */ /* Input: The heap whose parameters are to be computed iteration flag*/ /********************************************************************/ void computeHeapParameters(heap* heapData,int flag) { int i=0,j=0,k=0,position=0; float distance=0; float Dmean=0.0; float *dis; float featureSum[features]; float max=0; float sum=0; /* init*/ for(k=0;k<features;k++) featureSum[k]=0; /*Compute the distance of each object and find the maximum distance*/ max=0; if(flag==1){ for(j=0;j<heapData->count;j++) for(i=0;i<heapData->count;i++) { for(k=0;k<features;k++) sum+= (data[heapData->objects[j]][k]-data[heapData->objects[i]][k])*(data[heapData->objects[j]][k]-data[heapData->objects[i]][k]); distance=sqrt(sum); if(max<distance) max=distance; sum=0; } /* Assign the maximum distance to the heap */ heapData->Dmax=max;/*Compute the centre object*/for(i=0;i<heapData->count;i++)for(k=0;k<features;k++) featureSum[k]+=data[heapData->objects[i]][k];for(k=0;k<features;k++)heapData->Ocenter[k]=featureSum[k]*1.0/heapData->count; /* Find the mean distance */if((dis=(float *) calloc(heapData->count,sizeof(float)))==NULL){printf("\nUnable to allocate memory in the compute heap parameters procedure\n");exit(0);} for(i=0;i<heapData->count;i++) { Dmean+=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); dis[i]=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); } heapData->Dmean=Dmean*1.0/heapData->count; /*Compute the most dissimilar object*/ max=dis[0]; for(i=1;i<heapData->count;i++) if(max<dis[i]) { max=dis[i]; position=i; } /*Assign the most dissimilar object to the heap variable*/ for(k=0;k<features;k++) heapData->Odissim[k]=data[heapData->objects[position]][k]; heapData->disPosition=position;free(dis); } else{/* Heap Parameters for the second stage */for(k=0;k<features;k++){ heapData->Odissim[k]=heapData->Ocenter[k];}heapData->disPosition=0;heapData->Dmean=0;heapData->Dmax=0;} }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a single object*/ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject1(ant *a,int position,int flag) { int i,k=0; /*Clear the board*/ board[heaps[position].x][heaps[position].y]=-9; /* Assign the data to the ant*/if(flag==1){ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[0]][k];}else {for(k=0;k<features;k++) a->data[k]=heaps[position].Ocenter[k];} a->carrying=1; /*Copy all the heaps remaining heaps in the structure*/ for(i=position;i<heapCount-1;i++) heaps[i]=heaps[i+1]; /*Decrement the heap count*/ heapCount--; }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a two objects */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject2(ant *a , int position,int flag) { float Pdestroy1=-1; int i=0,k=0; /*Compute the probability to destroy the heap*/ Pdestroy1=lrand48()%13*1.0/12.0; /*If the probability is more than Pdestroy then destroy the heap */ if(Pdestroy1<Pdestroy) { /*pick the object randomly*/ i=lrand48()%2; /* Assign the data to the ant */ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[i]][k]; a->carrying=1; /*Correct the heap parameters*/ heaps[position].count=1; heaps[position].objects[0]=heaps[position].objects[1-i]; computeHeapParameters(&heaps[position],flag); } }//end of function /********************************************************************/ /*Function to pick a object from a heap consisting of more than two object */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /********************************************************************/ void pickObjectn(ant *a,int position,int flag) { int i=0,k=0; /*If the criteria is satsfied then pick the object*/ if((computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)*1.0/heaps[position].Dmean)>Tremove) { a->carrying=1; for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[heaps[position].disPosition]][k]; for(i=heaps[position].disPosition;i<heaps[position].count-1;i++) heaps[position].objects[i]=heaps[position].objects[i+1]; heaps[position].count--; computeHeapParameters(&heaps[position],1); } }//end of function /********************************************************************/ /* Function to pick a object */ /********************************************************************/ void pick(ant *a,int flag) { int position=-1,i=0; float Pload1=-1.0; for(i=0;i<heapCount;i++) { /*Check if a heap is present in the eight neighbouring cells*/ if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if Heap is found*/ if(position!=-1) { /* heap or object found.*/ /*Depending upon the number present in the heap call the corresponding routine*/ switch(heaps[i].count) { case 1: Pload1 = lrand48()%151*1.0/150.0; if(Pload1<Pload) { pickObject1(a,position,flag); } break; case 2: pickObject2(a,position,flag); break; default: pickObjectn(a,position,flag); break; } } } /********************************************************************/ /* Function to drop a object to form a new heap */ /* Output: None */ /* Input: Ant, iteration flag */ /* Global Structure modified : heap, heapCount */ /********************************************************************/ void dropObject(ant* a,int flag) { /*Create a new heap*/ int k=0; heaps[heapCount].count=1; heaps[heapCount].x=a->x; heaps[heapCount].y=a->y; heaps[heapCount].Dmax=0; heaps[heapCount].Dmean=0; heaps[heapCount].disPosition=0; for(k=0;k<features;k++) { heaps[heapCount].Odissim[k]=a->data[k]; heaps[heapCount].Ocenter[k]=a->data[k]; } if(flag==1) {heaps[heapCount].objects[0]=findInData(a->data,flag); /*computeHeapParameters(&heaps[heapCount],flag);*/ } computeHeapParameters(&heaps[heapCount],flag); heapCount++; a->carrying=-1; board[a->x][a->y]=9; }//end of function /********************************************************************/ /* Function to find the heap position during the second iteration */ /* Output: position of the heap */ /* Input: object center of the heap that the ant is carrying */ /* Global Structure modified : none */ /********************************************************************/ int findInNewheaps(irisData object) { int position=-1,i,j=0,flag[features],flg; for(i=0;i<newHeapCount;i++) { for(j=0;j<features;j++) { if(fabs(object[j]-newHeaps[i].Ocenter[j])<0.00001) flag[j]=1; else {flag[j]=0;break;} } flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /*Function to drop a object to a heap consisting of a one or more object */ /* Output: none */ /* Input: Ant, position of the heap , iteration flag */ /* Global Structure modified: heaps,newHeaps */ /********************************************************************/ void dropObject1(ant* a, int position,int flag) { int heapPosition=-1,heapPosition1=-1,i,j,k=0; irisData newData,temp; if(flag==1) { /*Add the object to the heap and compute the heap parameters*/ /*if(heaps[position].count==heaps[position].objCount) {if((junk=(int *)realloc(heaps[position].objects,((heaps[position].objCount+OBJINC)*sizeof(int))))==NULL){printf("\n Cannot Allocate memory to the new object for %d heap",position);exit(0);}heaps[position].objects=junk;heaps[position].objCount+=OBJINC;free(junk); }*/ heaps[position].objects[heaps[position].count]=findInData(a->data,flag); heaps[position].count++; computeHeapParameters(&heaps[position],flag); } else { for(k=0;k<features;k++)temp[k]=heaps[position].Ocenter[k]; heapPosition=findInNewheaps(a->data); heapPosition1=findInNewheaps(heaps[position].Ocenter); if(heapPosition==-1||heapPosition1==-1) { printf("\n error in logic:new heaps\n"); //getchar(); return; } for(k=0;k<features;k++) {newData[k]=(newHeaps[heapPosition].Ocenter[k]*newHeaps[heapPosition].count+newHeaps[heapPosition1].Ocenter[k]*newHeaps[heapPosition1].count)*1.0/(newHeaps[heapPosition].count+newHeaps[heapPosition1].count);newHeaps[heapPosition].Ocenter[k]=newData[k];heaps[position].Ocenter[k]=newData[k]; } computeHeapParameters(&heaps[position],flag); for(i=newHeaps[heapPosition].count,j=0;j<newHeaps[heapPosition1].count;i++,j++) { newHeaps[heapPosition].objects[i]=newHeaps[heapPosition1].objects[j]; } newHeaps[heapPosition].count+=newHeaps[heapPosition1].count; for(i=heapPosition1;i<newHeapCount-1;i++) newHeaps[i]=newHeaps[i+1]; newHeapCount--; } a->carrying=-1; }//end of function /********************************************************************/ /* Function to drop a object */ /* Output: None */ /* Input: Ant, iteration flag */ /********************************************************************/ void drop(ant* a,int flag) { int i, position=-1; float Pdrop1=0.0; /*Find whether we have a heap in the neighbourhood of the cell*/ for(i=0;i<heapCount;i++) { if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if a heap is found*/ if(position!=-1) { /*heap or object found.*/ /*Depending on the number of objects present take action*/ switch(heaps[position].count) { /*If criteria is satisfied then drop the object*/ case 1: if(flag==1) { if((computeDistanceBetween2(a->data,data[heaps[position].objects[0]])*1.0/Dmax)<Tcreate) dropObject1(a,position,flag); } else { if((computeDistanceBetween2(a->data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) dropObject1(a,position,flag); } break; default: if(computeDistanceBetween2(a->data,heaps[position].Ocenter)<computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)) dropObject1(a,position,flag); break; } } else { /*Compute the probability to drop the object*/ Pdrop1 = lrand48()%151*1.0/150; if(Pdrop1<Pdrop) dropObject(a,flag); } }//end of function /********************************************************************/ /* Function to move the ant */ /* Output: none */ /* Input: Ant, iteration flag */ /********************************************************************/ void move(ant* a,int flag) { float pDir; /*Check the speed */ if (a->speed!=0) { /*move in the same direction*/ a->speed--; moveNext(a,flag); } else { /*generate the new direction*/ pDir=lrand48()%17*1.0/16.0; if(pDir<.85) { a->dir=lrand48()%8; } else if(pDir>.95) { a->speed=2; } moveNext(a,flag); } } /********************************************************************/ /* Function to simulate the movement of the ants */ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified: minHeapCount, minHeapPosition */ /********************************************************************/ void iterate(int flag) { int i=0,j=0,k=0,loopCount=0; if (flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS; while (i<MAXITERATIONS) { i++; for(j=0;j<loopCount;j++) { move(&ants[j],flag); if(ants[j].carrying==1) { drop(&ants[j],flag); } else { pick(&ants[j],flag); } } if(debugLevel>0){ for(k=0;k<heapCount;k++) for(j=0;j<heapCount;j++) if((k!=j)&&(heaps[k].x==heaps[j].x)&&(heaps[k].y==heaps[j].y)) { printf("\nerror two heaps with same co ordinates %d %d ",k,j); //getchar(); } k=0; for(j=0;j<heapCount;j++) k+=heaps[j].count; } if(heapCount<minHeapCount) { minHeapCount=heapCount; minPosition=i; } if(debugLevel>0) printf("\n i:%d Heap count %d sum %d",i,heapCount,k); else printf("\n i:%d Heap count %d",i,heapCount); heapSum+=heapCount; /*if(i%updateAfter==0) {adjustBoard(flag); writeIncremental(i,flag);heapSum=0;loopCount=currentAntCount; }*/ } }//end of function /********************************************************************/ /*Function to drop the objects carried by the ants after all the iterations*/ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified:none */ /********************************************************************/ void dropFinal(int flag) { int i=0,j=0,position=-1,loopCount=0; /*if(flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS;*/ loopCount=currentAntCount; for(i=0;i<loopCount;i++) { if(ants[i].carrying==1) { if(flag==1) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position,flag); } } else { /*Find if a heap is present */ do { position=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position,flag); position=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position!=-1); } } } }//end of function /********************************************************************/ /* Function for the implementation of QuickSort */ /* Output: none */ /* Input: data structure, low and high indices */ /* Global structure modified:none */ /********************************************************************/ void quickSort( heap A[], int low,int high ) { int mid=0; if(low<high) { mid=partition(A,low,high); quickSort(A,low,mid); quickSort(A,mid+1,high); } } /********************************************************************/ /* Partition routine used by quick sort */ /* Output: partition location */ /* Input: data , low, high */ /* Global structure modified:none */ /********************************************************************/ int partition(heap a[], int low,int high) { heap temp; int x=0,i=0,j=0; i=low; j=high; x=a[low].count; while (1) { while (a[j].count<x) j=j-1; while (a[i].count>x) i=i+1; if(i<j) { temp=a[i]; a[i]=a[j]; a[j--]=temp; } else return(j); } } /********************************************************************/ /* Function used to write the cluster information */ /* Output: none */ /* Input:iteration flag */ /* Global structure modified:none */ /********************************************************************/ void writeClusterInformation(int flag) { FILE *fp=fopen("center.clt","w"); FILE *fp1; FILE *fp2; FILE *fp3; char temp[80]; int i=0,j=0,k=0; int lastCount=0; int rowCount,colCount,antCount; strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp3=fopen(temp,"a"); if(dataDump) {strcpy(temp,"");sprintf(temp,"%sTot.out",filename);fp1=fopen(temp,"a");strcpy(temp,"");sprintf(temp,"%sObj.out",filename);fp2=fopen(temp,"a");if(fp1==NULL||fp2==NULL)printf("\n Error in opening file in the writer Cluster Information routine\n"); } /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; antCount=MAXANTS; } else { rowCount=heapRow; colCount=heapRow; antCount=MAXANTSFORHEAPS; }*/ rowCount=currentRow; colCount=currentRow; antCount=currentAntCount; if(fp==NULL) { printf("\n Unable to open cluster center output file \n"); /*return;*/ exit(0); } /*sort the array according to the count value and write the value of the top three elements*/ if((flag==1)&&(!EntireHeaps)) quickSort(heaps,0,heapCount); if(EntireHeaps) {if(flag==1) lastCount=heapCount;else lastCount=newHeapCount; } else lastCount=c; for(i=0;i<lastCount;i++) { if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",newHeaps[i].Ocenter[k]); fprintf(fp,"\n"); } else { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); fprintf(fp,"\n"); } } if(dataDump) { fprintf(fp1,"\n Information from the Ant Based Algorithm \n"); fprintf(fp1,"\n Important Parameters : Board %d X %d Ants : %d Iterations %d Total Heaps %d ",rowCount,colCount,antCount,MAXITERATIONS,lastCount); } if(flag==0) { if(dataDump) { fprintf(fp1," TCreateForHeaps %f \n",TcreateForHeaps); fprintf(fp2,"\nTotal Heaps : %d\n",heapCount); fprintf(fp2,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); } fprintf(fp3,"\n@ %d\n",lastCount); } else if(dataDump) fprintf(fp1,"\n");if(dataDump) { fprintf(fp1,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); for(i=0;i<lastCount;i++) if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp2,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); } fprintf(fp1," %5d\n",newHeaps[i].count); fprintf(fp2," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp1," %5d\n",heaps[i].count); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]); fprintf(fp1," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]); fprintf(fp1," %5d\n",heaps[i].count); }} if(flag==0) { if(dataDump) fprintf(fp1,"\n Objects in the heaps \n");for(i=0;i<newHeapCount;i++) { if(dataDump) fprintf(fp1,"\n\n Heap %d\n \n",i+1);fprintf(fp3,"# %d %d\n",i ,newHeaps[i].count); for(j=0;j<newHeaps[i].count;j++){ for(k=0;k<features;k++){ fprintf(fp3,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]); if(dataDump) fprintf(fp1,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]);} if(dataDump) fprintf(fp1,"\n"); fprintf(fp3,"\n"); } } } fclose(fp); fclose(fp3); if(dataDump) { fclose(fp1);fclose(fp2); }}//end of flie /********************************************************************/ /* Function to initialise the new heaps */ /* Output: none */ /* Input:new Heap structure */ /* Global structure modified:none */ /********************************************************************/ void initialiseNewHeaps(heap newHeaps[]) { int i=0,j=0; for(i=0;i<lCount;i++) { newHeaps[i].count=0; for(j=0;j<features;j++) newHeaps[i].Ocenter[j]=V[i][j]; newHeaps[i].x=heaps[i].x; newHeaps[i].y=heaps[i].y; } }//end of function /********************************************************************/ /* Function to initialise the new heaps */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ int findPosition(int i) { int j,position=0; for(j=1;j<lCount;j++) { if(U[j][i]>U[position][i]) position=j; } printf("\n Position %d ",position); return(position); }//end of function find position /********************************************************************/ /* Function to add object */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ void addObject(int object,heap * heapPosition) { heapPosition->objects[heapPosition->count]=object; heapPosition->count++; }//end of function add object /********************************************************************/ /* Function to harden the outputs obtained from fcm */ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/ void harden(heap newHeaps[]) { int i,heapPosition=-1,sum=0,j=0; /*initialise the new heaps*/ initialiseNewHeaps(newHeaps); for(i=0;i<count;i++) { heapPosition=findPosition(i); addObject(i,&newHeaps[heapPosition]); } /* To check for degenerate partitions*/ for(i=0;i<lCount;i++) { if(newHeaps[i].count==0){for(j=i;j<lCount-1;j++){newHeaps[j]=newHeaps[j+1];}lCount--;i--;} } newHeapCount=lCount; for(i=0;i<lCount;i++) computeHeapParameters(&newHeaps[i],1); if(debugLevel>0) { for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\n sum = %d",sum);} }//end of function/********************************************************************/ /* Function to initialize the initial parameters for the ant algorithm*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void init() { int i=0,j=0; for(i=0;i<MAXROWS;i++) for(j=0;j<MAXCOLS;j++) board[i][j]=-9; heapCount=0; newHeapCount=0; heapRow=0; minPosition=-1; minHeapCount=100000; for(i=0;i<MAXANTS;i++) { ants[i].carrying=-1; ants[i].x=-1; ants[i].y=-1; ants[i].speed=-1; ants[i].dir=-1; } } /********************************************************************/ /* Function to initialize the initial board */ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void initialiseBoard() { int i,j; for(i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; }/********************************************************************/ /* Function to harden the outputs obtained from fcm(2nd stage)*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: Cluster center , cluster center count*/ /********************************************************************/void harden1() { int i=0,heapPosition=-1; for(i=0;i<heapCount;i++) cenCount[i]=0; for(i=0;i<n;i++) { heapPosition=findPosition1(i); addObject1(i,heapPosition); } writeInfo(); }//end of function/********************************************************************/ /* Function to find to which class the object belongs */ /* Output: Class number */ /* Input: object position */ /* Global Structure Modified: None */ /********************************************************************/int findPosition1(int i) { int j,position=0; for(j=1;j<heapCount;j++) { if(U[j][i]>U[position][i]) position=j; } return(position); }//end of function find position/********************************************************************/ /* Function to Write the output of the hardened objects to file*/ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/void writeInfo(){int i=0,j=0,k=0;FILE *fp=fopen("fcm.out","a");if(fp==NULL){printf("\n Unable to open fcm output file \n");return;}fprintf(fp,"\n@ %d\n",heapCount);for(i=0;i<heapCount;i++){fprintf(fp,"# %d %d\n",i,cenCount[i]);for(j=0;j<cenCount[i];j++){for(k=0;k<s;k++)fprintf(fp,"%8.2f ",clsCen[i][j][k]/scale[k]+minInput[k]);fprintf(fp,"\n");}}fclose(fp);return;}/********************************************************************/ /* Function to add a object to a cluster (2nd stage) */ /* Output: none */ /* Input: object poistion , cluster position */ /* Global Structure Modified: Cluster object and cluster count*/ /*******************************************************************/void addObject1(int object,int heapPosition) { int k=0; for(k=0;k<features;k++) clsCen[heapPosition][cenCount[heapPosition]][k]=X[object][k]; cenCount[heapPosition]++; return; }//end of function add object/********************************************************************/ /* Function to read the original classification of objects */ /* Output: none */ /* Input: none */ /* Global Structure Modified: None */ /*******************************************************************/void readOrg(){int i=0,k=0;char temp[80];FILE *fp;//= fopen(dataname,"r");strcpy(temp,"");sprintf(temp,"%sFull.data",filename);fp=fopen(temp,"r");if(fp==NULL){printf("\n Unable to open full data input file ");exit(0);}for(i=0;i<n;i++){fscanf(fp,"%f ",&orgData[i][0]);for(k=1;k<s+1;k++)fscanf(fp,"%f ",&orgData[i][k]);}return;}// end of function/********************************************************************/ /* Function to classify the objects in different clusters */ /* Output: none */ /* Input: the cluster objects, the original classification, */ /* number of objects in the cluster,file to write the data */ /* Global Structure Modified: None *//********************************************************************/int analysisData(float data[][s],float orgData[n][s+1],int count,FILE * fp){int i=0,j=0,k=0,type=1,max=0;heapInfo info;for(i=0;i<c;i++){info.classObj[i]=0;}info.total=0;info.total=count;for(i=0;i<count;i++)for(j=0;j<n;j++){type=1;for(k=0;k<s;k++)if(fabs(data[i][k]-orgData[j][k+1])>errThresh){type=-1;break;}if(type!=-1){info.classObj[(int)orgData[j][0]-1]++;break;}}max=0;for(k=0;k<c;k++){if(info.classObj[k]>info.classObj[max])max=k;fprintf(fp,"\nClass %d Objects % d ",k+1,info.classObj[k]);}j=0;for(k=0;k<c;k++){if(k!=max)j+=info.classObj[k];}fprintf(fp,"\n Total errors : %d \n",j);return(j);}//end of analyse/********************************************************************/ /* Function to read the cluster information */ /* Output: none */ /* Input: input file pointer , output file pointer */ /* Global Structure Modified: None *//********************************************************************/void readFCM(FILE* fp,FILE *fp1){int i=0,j=0,k=0,l=0;int totalRuns=0,heapCount=0,junk=0,sum=0;char ch;FILE *fp2=fopen("errors.out","a");ch = 'c'; while (ch != '$') fscanf (fp, "%c", &ch);fscanf(fp,"%d\n",&totalRuns);printf("\n total runs %d ",totalRuns);for(l=0;l<totalRuns;l++){fscanf(fp,"%c",&ch);fscanf(fp,"%d\n",&heapCount);fprintf(fp1,"\n \nExperiment %d \n ",l+1);sum=0;for(i=0;i<heapCount;i++){fscanf(fp,"%c",&ch);fscanf(fp," %d %d\n",&junk,&clsCenCount[i]);for(j=0;j<clsCenCount[i];j++)for(k=0;k<s;k++)fscanf(fp,"%f",&fcmData[i][j][k]);fscanf(fp,"\n");fprintf(fp1,"\n\n Heap %d Total Objects %d \n",i+1,clsCenCount[i]);sum+=analysisData(fcmData[i],orgData,clsCenCount[i],fp1);}fprintf(fp2," %3d %3d %3d \n",l,sum,heapCount);}fprintf(fp2,"\n --------------------------\n");fclose(fp2);return;}//end of function/********************************************************************/ /* Function to update the board parameters */ /* Output: none */ /* Input: none */ /* Global Structure Modified: board size, ant count *//********************************************************************/void adjustBoard(int flag){int newRow=0,newAnt=0,antDiff=0,antsKilled=0,i=0,position[MAXANTS],position1=-1,j=0,k=0,a,b; newRow= (int)ceil(sqrt(4.0*heapSum/updateAfter)); newAnt= (int)ceil((heapSum*1.0/updateAfter)*1.0/3.0); if(newAnt<minAnts)newAnt=minAnts; if(newRow<rowMin)newRow=rowMin;antDiff=currentAntCount-newAnt; if((antDiff>0)&&(newAnt>=minAnts)) {for(i=0;i<currentAntCount;i++){if(ants[i].carrying==-1){position[antsKilled++]=i;}} if(antsKilled>=antDiff){for(i=0;i<antDiff;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1];for(k=i+1;k<antsKilled;k++)position[k]--; } currentAntCount=newAnt; }else {for(i=0;i<antsKilled;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1]; for(k=i+1;k<antsKilled;k++)position[k]--; }if(flag==1) { for(i=currentAntCount-1,k=0;k<antDiff-antsKilled;k++,i--) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position1,flag); }else { dropObject(&ants[i],flag); } } } else { //flag is zero 2nd stage /*Find if a heap is present */ do { position1=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position1].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position1,flag); position1=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position1!=-1); }//end else currentAntCount=newAnt;}//end elsecurrentAntCount=newAnt;}//end iffor(i=0;i<newAnt;i++){if((ants[i].x>=newRow)||(ants[i].y>=newRow)) { a=lrand48()%newRow; b=lrand48()%newRow; ants[i].x=a; ants[i].y=b; }} //Done with ants, now adjust the boardif((currentRow>newRow)&&(newRow>=rowMin)){for(i=0;i<heapCount;i++){if((heaps[i].x>=newRow)||(heaps[i].y>=newRow)) {do { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionheaps[i].x=a;heaps[i].y=b;board[a][b]=9;}//end if}//end for for(i=0;i<currentAntCount;i++){if((ants[i].carrying==1)&&((ants[i].x>=newRow)||(ants[i].y>=newRow))){//adjust the ant locationdo { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionants[i].x=a;ants[i].y=b;}//end if}//end for currentRow=newRow;}//end if }//end of function void writeIncremental(int iteration,int flag){FILE *fp=fopen("dump.txt","w");int i=0,j=0,k=0;fprintf(fp,"Stage %d\n",flag);fprintf(fp,"Board %d\n",currentRow);fprintf(fp,"Ants %d\n",currentAntCount);fprintf(fp,"Iteration %d\n",iteration);fprintf(fp,"Heaps %d\n",heapCount); if(flag==0)fprintf(fp,"NewHeapCount %d\n",newHeapCount); fprintf(fp,"Ants\n");for(i=0;i<currentAntCount;i++){fprintf(fp,"%d %d %d %d %d ",ants[i].x,ants[i].y,ants[i].carrying,ants[i].speed,ants[i].dir);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",ants[i].data[k]);fprintf(fp,"\n");}fprintf(fp,"Heaps\n");for(i=0;i<heapCount;i++){fprintf(fp,"%d %d %d %d %8.2f %8.2f \n",heaps[i].x,heaps[i].y,heaps[i].count,heaps[i].disPosition,heaps[i].Dmax,heaps[i].Dmean);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Ocenter[k]);fprintf(fp,"\n");for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Odissim[k]);fprintf(fp,"\n");if(flag==1){for(j=0;j<heaps[i].count;j++)fprintf(fp,"%d ",heaps[i].objects[j]);fprintf(fp,"\n");}}if(flag==0){fprintf(fp,"newHeaps\n");for(i=0;i<newHeapCount;i++){fprintf(fp,"%d\n",newHeaps[i].count);for(j=0;j<newHeaps[i].count;j++)fprintf(fp,"%d ",newHeaps[i].objects[j]);fprintf(fp,"\n");}}fclose(fp);}//end of function/********************************************************************/ /* Function Main */ /********************************************************************/ int main(int argc ,char** argv) { int sum=0,k=0,i=0,j=0; char temp[80]; FILE *fp=fopen("fcm.out","w"); FILE *fp1; FILE *fp2=fopen("antAnalysis.out","a"); FILE *fp3=fopen("fcmAnalysis.out","a"); FILE *fp4=fopen("errors.out","w"); FILE *fp5; fclose(fp4); sprintf(temp,"%sObj.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sTot.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp1=fopen(temp,"w"); fprintf(fp,"\n$%d",EXPRUN); fprintf(fp1,"\n$%d",EXPRUN); fclose(fp); fclose(fp1); if(argc==2)sscanf(argv[1],"%d",&debugLevel); printf("\n Debug level %d\n",debugLevel); for( i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; //Read from the file readInput(); //Compute the distance of all the points if(maxDist) { Dmax=computeDistance(); //Compute the maximum distance fp5=fopen("maxData.txt","w");fprintf(fp5,"%f",Dmax);fclose(fp5); } else {fp5=fopen("maxData.txt","r");fscanf(fp5,"%f",&Dmax);fclose(fp5); } printf("\n %f \n",Dmax); //Initialise the board for(k=0;k<EXPRUN;k++) { init(); sum=0; srand48(state1[k]); initialiseBoard(); initialise(1); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(1); printf("\n %d \n",heapCount); //Simulate the working of ants iterate(1); //drop the objects after all the iterations dropFinal(1); //to verify the correctness for(i=0;i<heapCount;i++) sum+=heaps[i].count; //write the cluster centers to the file writeClusterInformation(1); printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); //getchar(); //Run FCM // heapCount=2973;/* To be commented */ printf("\n\n k %d \n\n",k); Fcm(data); //compute new board size. lCount=heapCount; heapRow=(int)ceil(sqrt(4*heapCount)); newHeapCount=lCount; printf("\n LCount %d newHeapCount %d heap Row %d \n",lCount,newHeapCount,heapRow); //harden the objects harden(newHeaps); //iterate with the heaps as the objects. initialiseBoard(); initialise(0); for(i=0;i<lCount;i++) computeHeapParameters(&heaps[i],0); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(0); printf("\n %d \n",heapCount); //getchar(); //Simulate the working of ants iterate(0); dropFinal(0); writeClusterInformation(0); sum=0; for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); // getchar(); Fcm(data); harden1(); } fp=fopen("fcm.out","a"); fp1=fopen(temp,"a"); fprintf(fp,"\n"); fprintf(fp1,"\n"); fclose(fp); fclose(fp1); fp=fopen("fcm.out","r"); fp1=fopen(temp,"r");printf("\n Before read org\n");readOrg();printf("\nafter read org\n");readFCM(fp1,fp2);printf("\n After 1st read fcm\n");readFCM(fp,fp3);printf("\n After 2 fcm read \n");return(1); }//end of main /****************************************************************/ float NORM(feature , feature); void find_covar(); void Fcm (irisData Data[MAXDATA]) { int i,j,l; FILE *ofile; char temp[80]; int flag=0;//added by parag FILE *iniClsCen=fopen("center.clt","a+"); if(iniClsCen==NULL) { printf("\n Unable to open the initial cluster center file\n"); printf("\n choosing random cluster centers....\n"); flag=1; } strcpy(temp,""); sprintf(temp,"%s.data",filename); strcpy (fname,temp); /* Read from this file */ m=2.0; /* The exponent */ /*GET_INPUTS1(fname);*/ /* read in feature vectors */ for (j=0; j<n ; j++) /* Read File in row-major */ for (i=0; i<s ; i++) /* format */ X[j][i]=Data[j][i]; Random_seed=state1[run];/*randseed*/ srand48(Random_seed); for (run=0;run<TOTRUNS;run++) { //flag=1;//for testing random values if (EntireHeaps) lCount=heapCount; else lCount=c; for(i=0;i<lCount;i++) for(j=0;j<s;j++) V[i][j]=0; for(i=0;i<lCount;i++) { for(l=0;l<s;l++) { if(flag==1) { rand_index = lrand48() % n; V[i][l] = X[rand_index][l]; } else { fscanf(iniClsCen,"%f ",&V[i][l]); } }//end for } eps=0.001; stop = FALSE; /* This loop finds the final cluster center and the corresponding U values */ z = 0; while (stop == FALSE) { z++; UMAT(U,V,X); /** Update the U matrix **/ stop = FINISHED(U1,eps); CLUSTER(U,X); /** Get new cluster center **/ printf("Iteration: %d\n\n", z); } /* end while */ printf("Number of iterations: %d\n\n", z);strcpy(temp,""); sprintf(temp,"%sFCM.out",filename);if(dataDump) Output(temp); /* output the results */ }/*end for*/ if(dataDump) { ofile=fopen(temp,"a"); for (i=0; i <= mins; i++) fprintf(ofile, "Min %d of %10.3f occurred %d times\n", i, mintab[i], mincount[i]); fprintf(ofile, "Average iterations %f\n", (float)aveit/(float)TOTRUNS); fclose(ofile); } }/* end Main */ /* The GET_INPUTS1 procedure opens an input file, reads the number of input vectors, the number of features per vector, the number of clusters, and epsilon, then it reads the input values */ void GET_INPUTS1(char fname[]) //char fname[]; { /* Parameters: fname -- name of file containing input info. */ FILE *infile ;//*fopen(); //char junk[10][80]; char realfname[80]; char ch; char fileName1[80]; //int temp[10], i, j, inputs, outputs, count; int i,j; sprintf (realfname, "%s", fname); /* open input file */ if(normalize==1) strcpy(fileName1,"gtest1.data"); else strcpy(fileName1,fname); if((infile = fopen (fileName1, "r")) == NULL) printf("\n CAN'T OPEN %s\n",realfname); else { ch = 'c'; /* Discard leading comments */ while (ch != '#') fscanf (infile, "%c", &ch); for (j=0; j<n ; j++) /* Read File in row-major */ { /* format */ for (i=0; i<s ; i++) fscanf (infile, "%f", &X[j][i]); /* fscanf (infile, "%d", &temp[1]); */ /* end for */ } /* end for */ fclose(infile); /* close input file */ }/* end else */ } /* end GET_INPUTS1 */ /* The NORM function computes the norm of two vectors, x and v, of dimension s. This gives an indication of the distance between them */ float NORM( feature x, feature v) //feature x, v; { /* Parameters : x -- a local copy of an input vector v -- a local copy of a cluster center */ int i,j; /* loop variable */ double sum; /* the square root of sum is the norm; sum is the sum of the differences squared */ float mat1[s]; float mat2[s]; if (maha) { for (i=0; i<s; i++) mat1[i]=x[i]-v[i]; for(i=0;i<s;i++) { sum =0; for(j=0;j<s;j++) sum += mat1[j] * inv_cov[j][i]; mat2[i] = sum; } sum =0; for(j=0;j<s;j++) sum += mat1[j]*mat2[j]; } else { sum = 0; for(j=0;j<s;j++) sum += (x[j] - v[j])* (x[j] - v[j]); } return (float)(sqrt(sum)); } /* end NORM */ /* The UMAT procedure calculates the updated U matrix according to Bezdek's formula. Its side-effect is the update of the global array U1 */ void UMAT( matrix U,center V, objects X) /*matrix U; center V; objects X;*/ { /* Parameters: U, V, and X: same as in main program */ int i, j, k,l ;/* loop variables *///, class /* class whose cluster center //is closest to pattern k */; float d1,d2,d; float sum; int exact; for (k=0;k<n;k++) { /*printf("\n k %d ",k);*/ exact=false; for (i=0;i<lCount;i++) { sum=0; for (j=0;j<lCount;j++) { d1=NORM(X[k],V[i]); d2=NORM(X[k],V[j]); if(d2!=0) { d= d1/d2; d= d * d;/* pow(d1/d2,2.0/(m-1.0)); */ sum+=d; } else { exact = true; for(l=0;l<lCount;l++) if (l==j) U1[l][k]=1.0; else U1[l][k]=0.0; break; } } if (exact!=true) U1[i][k]=1.0/sum; } } } /* end UMAT */ /* The function FINISHED determines if a termination occurs. If not it updates U with U1, so its side-effect is the potential modification of U */ BOOLEAN FINISHED( matrix U1,float eps) //matrix U1; float eps; { /* Parameters: U1, eps-- same as in main */ float sum; /* sum of squared differences between corresponding elements of U and U1 */ int i,k; /* loop control variabes */ BOOLEAN finished; /* set to true if all corresponding elements are within epsilon */ finished = TRUE; sum = 0; for (i=0; i<lCount; i++) for (k=0; k<n; k++) sum += (U[i][k] - U1[i][k])*(U[i][k]-U1[i][k]); if (sqrt(sum) > eps) { finished = FALSE; for (i=0; i<lCount; i++) for (k=0; k<n; k++) U[i][k] = U1[i][k]; } /* end if */ return finished; } /* end FINISHED */ /* The CLUSTER procedure determines cluster centers in V for the c classes being searched for. The global array V is updated */ void CLUSTER( matrix U, objects X) //matrix U; objects X; { /* Parameters: U, X -- as in main */ int i, j, k; /* loop control variables */ feature num; /* numerator in the cluster center computation formula presented by Bezdek */ float denum; /* denumenator in the obove formula */ for (i=0; i<lCount; i++) { denum = 0; for (j=0; j<s; j++) { num[j] = 0; for (k=0; k<n; k++) num[j] += U[i][k] * U[i][k] * X[k][j]; /* pow(U[i][k],m) * X[k][j]; */ } /* end for */ for (k=0; k<n; k++) denum += U[i][k] * U[i][k]; /* pow(U[i][k],m); */ for (j=0; j<s; j++) V[i][j] = num[j] / denum; } /* end for */ } /* end CLUSTER */ float Compute_Jm(center V, objects X) //center V; //objects X; { int i, k,found; double Jm_value; float u,dik; Jm_value = 0; for (k=0; k<n; k++) { found = FALSE; for (i=0; i<lCount; i++) { dik=NORM(X[k],V[i]); dik=dik*dik; if (dik==0.0) { if (found == FALSE) { u=1.0; found = TRUE; printf("found the case with dik=0\n"); } else { printf("\n cant proceed with this initialization"); exit(1); } } else { if (found != TRUE) u=U1[i][k]; /* get_Uvalue(V,X,dik,k); */ else u=0.0; } Jm_value += u * u * dik;/* pow(u, m) * dik; */ } } return (Jm_value); } /* end Compute_Jm */ /* The Output procedure outputs the U matrix which gives the fuzzy measure of each feature belonging to a cluster center. It also outputs the cluster center for each class */ void Output(char fname[]) //char fname[80]; /* Parameters: U, V -- same as in main */ { int i, j, found; /* loop control variables */ float J2c; if ((fp=fopen(fname,"a"))==NULL) printf("\n CAN'T OPEN %s\n",fname); else { fprintf(fp,"\n The cluster centers are: \n"); fprintf(fp,"\n \n"); for (i=0; i<lCount; i++) { fprintf(fp,"\nCluster center %d: ",i+1); fprintf(fp,"\n"); for (j=0; j<s; j++) fprintf(fp,"%8.7f ",V[i][j]); } /* end for */ fprintf(fp,"\nThe membership grades for the feature vectors are:\n"); for (j=0; j<n; j++) { fprintf(fp,"\n"); for (i=0; i<lCount; i++) fprintf(fp," %8.7f",U[i][j]); } /* end for */ } /* end if */ J2c= Compute_Jm(V,X); found =0; for (i=0;i<= mins; i++){ if ((found == 0) && ((J2c - mintab[i]) < .001) && ((J2c - mintab[i]) > -.001)){ mincount[i]++; found = 1; } } if (found == 0){ mins++; mintab[mins]=J2c; mincount[mins]=1; } fprintf(fp,"\nJ%3.1f = %f", m,J2c); fprintf(fp, "Number of iterations: %d\n\n", z); aveit=aveit + z; fclose(fp); } /***************************************************************/ void find_covar(int m) //int m; { int i,j,k; float mean[s],sum; for (i=0;i<s;i++) mean[i]=0; for (i=0;i<s;i++) for (j=0;j<m;j++) mean[i]+=X[j][i]; for (i=0;i<s;i++) mean[i]/=m; for (i=0;i<s;i++) for (j=0;j<s;j++) { sum=0; for (k=0;k<m;k++) sum+=(X[k][i]-mean[i])*(X[k][j]-mean[j]); Y[i][j]=sum/m; } }
Parag Kanade/fuzzy ants/Multiple Sclerosis/ms.data
Multiple Sclerosis Group Data#18.0 152.0 1.6 198.4 0.019.0 138.0 0.4 180.8 1.620.0 144.0 0.0 186.4 0.820.0 143.6 3.2 194.8 0.020.0 148.8 0.0 217.6 0.021.0 141.6 0.8 181.6 0.821.0 136.0 1.6 180.0 0.821.0 137.6 1.6 185.6 3.222.0 140.4 3.2 182.0 3.222.0 137.2 0.0 181.8 0.222.0 125.4 1.0 169.2 0.022.0 142.4 4.8 185.6 0.022.0 150.4 0.0 214.4 3.222.0 145.6 1.6 203.6 5.223.0 147.2 3.2 196.8 1.623.0 139.2 1.6 179.2 0.024.0 169.6 0.0 204.8 0.024.0 139.2 1.6 176.0 3.224.0 153.6 0.0 212.0 0.825.0 146.8 0.0 194.8 3.225.0 139.2 1.6 198.4 3.225.0 136.0 1.6 181.6 2.426.0 138.8 1.6 191.6 0.026.0 150.4 0.0 205.2 0.426.0 139.0 1.4 178.6 0.227.0 133.8 0.2 180.8 0.027.0 139.0 1.8 190.4 1.628.0 136.0 1.6 193.2 3.628.0 146.4 0.8 195.6 2.829.0 145.2 4.8 194.2 3.829.0 146.4 0.8 208.2 0.229.0 138.0 2.8 181.2 0.430.0 148.8 1.6 196.4 1.631.0 137.2 0.0 184.0 0.031.0 147.2 0.0 197.6 0.832.0 144.0 0.0 185.8 0.232.0 156.0 0.0 192.8 2.434.0 137.0 0.2 182.4 0.035.0 143.2 2.4 184.0 1.636.0 141.6 0.8 187.2 1.637.0 152.0 1.6 189.2 2.839.0 157.4 3.4 227.0 2.640.0 141.4 0.6 209.2 1.642.0 156.0 2.4 195.2 3.243.0 150.4 1.6 180.0 0.843.0 142.4 1.6 188.8 0.046.0 158.0 2.0 192.0 3.248.0 130.0 3.6 190.0 0.449.0 152.2 1.4 200.0 4.849.0 150.0 3.2 206.6 2.250.0 146.4 2.4 191.6 2.854.0 146.0 1.2 203.2 1.655.0 140.8 0.0 184.0 1.656.0 140.0 0.4 203.2 1.656.0 155.8 3.0 187.8 2.656.0 141.6 0.8 196.8 1.657.0 144.8 0.8 188.0 0.857.0 146.8 3.2 191.6 0.059.0 176.8 2.4 232.8 0.860.0 171.0 1.8 202.0 3.660.0 163.2 0.0 224.0 0.060.0 171.6 1.2 213.8 3.460.0 146.4 4.0 203.2 4.862.0 146.8 3.6 201.6 3.267.0 154.4 2.4 205.2 6.069.0 171.2 1.6 210.4 0.873.0 157.2 0.4 204.8 0.074.0 176.2 5.6 236.6 0.479.0 155.0 1.4 204.4 0.023.0 148.0 0.8 205.4 0.625.0 195.2 3.2 262.8 0.425.0 158.0 8.0 209.8 12.228.0 134.4 0.0 198.4 3.229.0 190.2 14.2 243.8 10.629.0 160.4 18.4 222.8 31.231.0 227.8 90.2 270.2 83.034.0 211.0 3.0 250.8 5.235.0 204.8 12.8 254.4 11.236.0 141.2 6.8 194.4 21.639.0 157.4 3.4 227.0 2.642.0 166.4 0.0 226.0 0.043.0 191.8 35.4 243.6 40.844.0 156.8 0.0 203.2 0.044.0 202.8 29.2 246.4 24.844.0 165.2 18.4 254.0 46.445.0 162.0 5.6 224.4 8.845.0 138.4 0.8 176.8 4.045.0 158.4 1.6 214.4 0.046.0 155.4 1.8 201.2 6.046.0 214.8 9.2 290.6 0.647.0 185.0 19.0 274.4 7.648.0 236.0 20.0 328.0 0.057.0 170.8 24.0 228.4 33.657.0 165.6 16.8 229.2 15.658.0 238.4 8.0 304.4 6.058.0 164.0 0.8 216.8 0.858.0 169.8 0.0 219.2 1.659.0 199.8 4.6 250.2 1.0
Parag Kanade/fuzzy ants/Multiple Sclerosis/msFull.data
1 18 152 1.6 198.4 01 19 138 0.4 180.8 1.61 20 144 0 186.4 0.81 20 143.6 3.2 194.8 01 20 148.8 0 217.6 01 21 141.6 0.8 181.6 0.81 21 136 1.6 180 0.81 21 137.6 1.6 185.6 3.21 22 140.4 3.2 182 3.21 22 137.2 0 181.8 0.21 22 125.4 1 169.2 01 22 142.4 4.8 185.6 01 22 150.4 0 214.4 3.21 22 145.6 1.6 203.6 5.21 23 147.2 3.2 196.8 1.61 23 139.2 1.6 179.2 01 24 169.6 0 204.8 01 24 139.2 1.6 176 3.21 24 153.6 0 212 0.81 25 146.8 0 194.8 3.21 25 139.2 1.6 198.4 3.21 25 136 1.6 181.6 2.41 26 138.8 1.6 191.6 01 26 150.4 0 205.2 0.41 26 139 1.4 178.6 0.21 27 133.8 0.2 180.8 01 27 139 1.8 190.4 1.61 28 136 1.6 193.2 3.61 28 146.4 0.8 195.6 2.81 29 145.2 4.8 194.2 3.81 29 146.4 0.8 208.2 0.21 29 138 2.8 181.2 0.41 30 148.8 1.6 196.4 1.61 31 137.2 0 184 01 31 147.2 0 197.6 0.81 32 144 0 185.8 0.21 32 156 0 192.8 2.41 34 137 0.2 182.4 01 35 143.2 2.4 184 1.61 36 141.6 0.8 187.2 1.61 37 152 1.6 189.2 2.81 39 157.4 3.4 227 2.61 40 141.4 0.6 209.2 1.61 42 156 2.4 195.2 3.21 43 150.4 1.6 180 0.81 43 142.4 1.6 188.8 01 46 158 2 192 3.21 48 130 3.6 190 0.41 49 152.2 1.4 200 4.81 49 150 3.2 206.6 2.21 50 146.4 2.4 191.6 2.81 54 146 1.2 203.2 1.61 55 140.8 0 184 1.61 56 140 0.4 203.2 1.61 56 155.8 3 187.8 2.61 56 141.6 0.8 196.8 1.61 57 144.8 0.8 188 0.81 57 146.8 3.2 191.6 01 59 176.8 2.4 232.8 0.81 60 171 1.8 202 3.61 60 163.2 0 224 01 60 171.6 1.2 213.8 3.41 60 146.4 4 203.2 4.81 62 146.8 3.6 201.6 3.21 67 154.4 2.4 205.2 61 69 171.2 1.6 210.4 0.81 73 157.2 0.4 204.8 01 74 176.2 5.6 236.6 0.41 79 155 1.4 204.4 02 23 148 0.8 205.4 0.62 25 195.2 3.2 262.8 0.42 25 158 8 209.8 12.22 28 134.4 0 198.4 3.22 29 190.2 14.2 243.8 10.62 29 160.4 18.4 222.8 31.22 31 227.8 90.2 270.2 832 34 211 3 250.8 5.22 35 204.8 12.8 254.4 11.22 36 141.2 6.8 194.4 21.62 39 157.4 3.4 227 2.62 42 166.4 0 226 02 43 191.8 35.4 243.6 40.82 44 156.8 0 203.2 02 44 202.8 29.2 246.4 24.82 44 165.2 18.4 254 46.42 45 162 5.6 224.4 8.82 45 138.4 0.8 176.8 42 45 158.4 1.6 214.4 0 2 46 155.4 1.8 201.2 62 46 214.8 9.2 290.6 0.62 47 185 19 274.4 7.62 48 236 20 328 02 57 170.8 24 228.4 33.62 57 165.6 16.8 229.2 15.62 58 238.4 8 304.4 62 58 164 0.8 216.8 0.82 58 169.8 0 219.2 1.62 59 199.8 4.6 250.2 1
Parag Kanade/fuzzy ants/Multiple Sclerosis/ignoring age/headerStatic.h
/********************************************************************//* Ant Class parameters *//* SPEED # amplitude of moves [1,10] *//* P direction Probability to move in the same direction [.5,1] *//* Max carry : Maximum object carrying time [20,200] *//* P load Probability to pick up a single object [0.4,0.8] *//* P destroy probability to destroy a heap of two objects [0,0.6] *//* T remove min. dissimilarity necessary for removing an object *//* from a heap [.1,.2] *//* T create max dissimilarity permitted for creating a heap[.05,.2]*//********************************************************************/ #include <stdio.h>#include <math.h>#include <string.h>#include<stdlib.h>#include <ctype.h>#include <time.h>#define MAXANTS 31#define MAXDATA 98#define MAXANTSFORHEAPS 10#define MAXITERATIONS 1000#define MAXROWS 20#define MAXCOLS 20#define EXPRUN 50#define Tremove 2.50#define Tcreate 0.5#define Pdrop 0.2#define Pdestroy 0.3#define Pload 0.3#define normalize 0#define EntireHeaps 1#define TcreateForHeaps 0.24#define features 4#define filename "ms"#define errThresh 0.1#define dataDump 1#define maxDist 0#define INITIALOBJECTS 75#define OBJINC 10/* some type definitions to make C code a little more readable */#define TRUE 1#define FALSE 0#define n MAXDATA /* number of input vectors */#define s features /* number of features */#define c 2 /* number of clusters */#define TOTRUNS 1 /* number of V's to write out */#define false 0#define true 1#define maha 0#define square 0extern int count;int debugLevel=0;/* To debug the code and verify the correctness of algorithms*/int currHeapCount=0;typedef int BOOLEAN;typedef short TYPE_IN_DATA; /* Type of input binary data */typedef float feature[s]; /* Type of each input; made up of input features */typedef float irisData[s];typedef feature objects[MAXDATA]; /* Type of array holding all inputs */typedef feature center[MAXDATA]; /* Type of array holding cluster centers */typedef float matrix[MAXDATA][MAXDATA];/* Type of the matrix containing membership grades */typedef struct Heap {float Dmax;//maximum dissimilar distanceirisData Ocenter;//center objectfloat Dmean;//mean of the distance between the center and all the objectsirisData Odissim;//most dissimilar objectint x;//x position on the boardint y;//y position on the boardint count;//number of objects in the heapsint disPosition;//most dissimilar objectint objects[MAXDATA];int objCount;}heap;typedef struct Ant{int x;int y;int carrying;int speed;int dir;irisData data;}ant;float orgData[n][s+1];float fcmData[260][n][s];int clsCenCount[260];int currentRow=0;int currentAntCount=0;int updateAfter=50;int heapSum=0;int minAnts=3;int rowMin=5;typedef struct HeapInfo{int total;int classObj[c];} heapInfo;/*heapInfo info[MAXDATA];*//********************************************************************//***Function decelarations*//********************************************************************//***For ant based algorithm*/void readInput();float computeDistance();float computeDistanceBetween2(irisData a,irisData b);float findMax(float *distance);float value(irisData a);int found(int a , int b);void initialise(int flag);int findObject(int a,int b);void initialiseAnts(int flag);void moveNext(ant* a,int flag);void computeHeapParameters(heap* data,int flag);void pickObject1(ant *a,int position,int flag);void pickObject2(ant *a , int position,int flag);void pickObjectn(ant *a,int position,int flag);void pick(ant *a,int flag);void dropObject(ant* a,int flag);int findInNewheaps(irisData object);void dropObject1(ant* a, int position,int flag);void drop(ant* a,int flag);void move(ant* a,int flag);void iterate(int flag);void dropFinal(int flag);int partition(heap a[], int low,int high);void quickSort( heap A[], int low,int high ) ;void writeClusterInformation(int flag);void initialiseNewHeaps(heap newHeaps[]);int findPosition(int i);void harden(heap newHeaps[]);void harden1();int findPosition1(int );void writeInfo();void addObject1(int ,int);void readFCM(FILE *,FILE *);void readOrg();int findInData(irisData input,int iflag);void adjustBoard(int flag);void writeIncremental(int iteration,int flag);/********************************************************************//***For FCM algorithm*/void GET_INPUTS1(char []);void UMAT( matrix,center,objects);BOOLEAN FINISHED(matrix, float);void CLUSTER( matrix, objects);void Output(char[]);void Fcm();/********************************************************************/
Parag Kanade/fuzzy ants/Multiple Sclerosis/ignoring age/ms.data
Multiple Sclerosis Group Data#152.0 1.6 198.4 0.0138.0 0.4 180.8 1.6144.0 0.0 186.4 0.8143.6 3.2 194.8 0.0148.8 0.0 217.6 0.0141.6 0.8 181.6 0.8136.0 1.6 180.0 0.8137.6 1.6 185.6 3.2140.4 3.2 182.0 3.2137.2 0.0 181.8 0.2125.4 1.0 169.2 0.0142.4 4.8 185.6 0.0150.4 0.0 214.4 3.2145.6 1.6 203.6 5.2147.2 3.2 196.8 1.6139.2 1.6 179.2 0.0169.6 0.0 204.8 0.0139.2 1.6 176.0 3.2153.6 0.0 212.0 0.8146.8 0.0 194.8 3.2139.2 1.6 198.4 3.2136.0 1.6 181.6 2.4138.8 1.6 191.6 0.0150.4 0.0 205.2 0.4139.0 1.4 178.6 0.2133.8 0.2 180.8 0.0139.0 1.8 190.4 1.6136.0 1.6 193.2 3.6146.4 0.8 195.6 2.8145.2 4.8 194.2 3.8146.4 0.8 208.2 0.2138.0 2.8 181.2 0.4148.8 1.6 196.4 1.6137.2 0.0 184.0 0.0147.2 0.0 197.6 0.8144.0 0.0 185.8 0.2156.0 0.0 192.8 2.4137.0 0.2 182.4 0.0143.2 2.4 184.0 1.6141.6 0.8 187.2 1.6152.0 1.6 189.2 2.8157.4 3.4 227.0 2.6141.4 0.6 209.2 1.6156.0 2.4 195.2 3.2150.4 1.6 180.0 0.8142.4 1.6 188.8 0.0158.0 2.0 192.0 3.2130.0 3.6 190.0 0.4152.2 1.4 200.0 4.8150.0 3.2 206.6 2.2146.4 2.4 191.6 2.8146.0 1.2 203.2 1.6140.8 0.0 184.0 1.6140.0 0.4 203.2 1.6155.8 3.0 187.8 2.6141.6 0.8 196.8 1.6144.8 0.8 188.0 0.8146.8 3.2 191.6 0.0176.8 2.4 232.8 0.8171.0 1.8 202.0 3.6163.2 0.0 224.0 0.0171.6 1.2 213.8 3.4146.4 4.0 203.2 4.8146.8 3.6 201.6 3.2154.4 2.4 205.2 6.0171.2 1.6 210.4 0.8157.2 0.4 204.8 0.0176.2 5.6 236.6 0.4155.0 1.4 204.4 0.0148.0 0.8 205.4 0.6195.2 3.2 262.8 0.4158.0 8.0 209.8 12.2134.4 0.0 198.4 3.2190.2 14.2 243.8 10.6160.4 18.4 222.8 31.2227.8 90.2 270.2 83.0211.0 3.0 250.8 5.2204.8 12.8 254.4 11.2141.2 6.8 194.4 21.6157.4 3.4 227.0 2.6166.4 0.0 226.0 0.0191.8 35.4 243.6 40.8156.8 0.0 203.2 0.0202.8 29.2 246.4 24.8165.2 18.4 254.0 46.4162.0 5.6 224.4 8.8138.4 0.8 176.8 4.0158.4 1.6 214.4 0.0155.4 1.8 201.2 6.0214.8 9.2 290.6 0.6185.0 19.0 274.4 7.6236.0 20.0 328.0 0.0170.8 24.0 228.4 33.6165.6 16.8 229.2 15.6238.4 8.0 304.4 6.0164.0 0.8 216.8 0.8169.8 0.0 219.2 1.6199.8 4.6 250.2 1.0
Parag Kanade/fuzzy ants/Multiple Sclerosis/ignoring age/msFull.data
1 152 1.6 198.4 01 138 0.4 180.8 1.61 144 0 186.4 0.81 143.6 3.2 194.8 01 148.8 0 217.6 01 141.6 0.8 181.6 0.81 136 1.6 180 0.81 137.6 1.6 185.6 3.21 140.4 3.2 182 3.21 137.2 0 181.8 0.21 125.4 1 169.2 01 142.4 4.8 185.6 01 150.4 0 214.4 3.21 145.6 1.6 203.6 5.21 147.2 3.2 196.8 1.61 139.2 1.6 179.2 01 169.6 0 204.8 01 139.2 1.6 176 3.21 153.6 0 212 0.81 146.8 0 194.8 3.21 139.2 1.6 198.4 3.21 136 1.6 181.6 2.41 138.8 1.6 191.6 01 150.4 0 205.2 0.41 139 1.4 178.6 0.21 133.8 0.2 180.8 01 139 1.8 190.4 1.61 136 1.6 193.2 3.61 146.4 0.8 195.6 2.81 145.2 4.8 194.2 3.81 146.4 0.8 208.2 0.21 138 2.8 181.2 0.41 148.8 1.6 196.4 1.61 137.2 0 184 01 147.2 0 197.6 0.81 144 0 185.8 0.21 156 0 192.8 2.41 137 0.2 182.4 01 143.2 2.4 184 1.61 141.6 0.8 187.2 1.61 152 1.6 189.2 2.81 157.4 3.4 227 2.61 141.4 0.6 209.2 1.61 156 2.4 195.2 3.21 150.4 1.6 180 0.81 142.4 1.6 188.8 01 158 2 192 3.21 130 3.6 190 0.41 152.2 1.4 200 4.81 150 3.2 206.6 2.21 146.4 2.4 191.6 2.81 146 1.2 203.2 1.61 140.8 0 184 1.61 140 0.4 203.2 1.61 155.8 3 187.8 2.61 141.6 0.8 196.8 1.61 144.8 0.8 188 0.81 146.8 3.2 191.6 01 176.8 2.4 232.8 0.81 171 1.8 202 3.61 163.2 0 224 01 171.6 1.2 213.8 3.41 146.4 4 203.2 4.81 146.8 3.6 201.6 3.21 154.4 2.4 205.2 61 171.2 1.6 210.4 0.81 157.2 0.4 204.8 01 176.2 5.6 236.6 0.41 155 1.4 204.4 02 148 0.8 205.4 0.62 195.2 3.2 262.8 0.42 158 8 209.8 12.22 134.4 0 198.4 3.22 190.2 14.2 243.8 10.62 160.4 18.4 222.8 31.22 227.8 90.2 270.2 832 211 3 250.8 5.22 204.8 12.8 254.4 11.22 141.2 6.8 194.4 21.62 157.4 3.4 227 2.62 166.4 0 226 02 191.8 35.4 243.6 40.82 156.8 0 203.2 02 202.8 29.2 246.4 24.82 165.2 18.4 254 46.42 162 5.6 224.4 8.82 138.4 0.8 176.8 42 158.4 1.6 214.4 0 2 155.4 1.8 201.2 62 214.8 9.2 290.6 0.62 185 19 274.4 7.62 236 20 328 02 170.8 24 228.4 33.62 165.6 16.8 229.2 15.62 238.4 8 304.4 62 164 0.8 216.8 0.82 169.8 0 219.2 1.62 199.8 4.6 250.2 1
Parag Kanade/fuzzy ants/Multiple Sclerosis/ignoring age/ms.c
#include "headerStatic.h" /*******************************************************************/ /*** Global Variables ***/ irisData data[MAXDATA]; //To hold the data read from the file int count=0; //Count of the total number of data elements int heapCount=0; // Total number of heaps int heapRow=0; // Rows for the second iteration with heaps int newHeapCount=0; // Count of the heaps for the second iteration heap heaps[MAXDATA]; // Data structure to hold the heap information heap newHeaps[MAXDATA]; // Data Structure to hold the new heap information // For the second iteration int board[MAXROWS][MAXCOLS]; // Board on which the objects are located ant ants[MAXANTS]; // Data structure to hold the ants float Dmax=0; // Distance of the most dissimilar object pair int minHeapCount=100000; // Counter to hold the minimum heap count, used only for academic purpose // no use in the algorithm int minPosition; // the minimum heap iteration , only for academic purpose // no use in the algorithm float clsCen[MAXDATA][MAXDATA][s];//to hold the objects after hardening int cenCount[MAXDATA];//to hold the number of objects after hardening /********************************************************************/ /*** Varaibles to normalize the features between 0 and 1 */ float minInput[features], maxInput[features],scale[features],minForHeaps[features],maxForHeaps[features],scaleForHeaps[features]; /********************************************************************/ /** Variables for the FCM algorithm */ int temp[200]; /* for square matrix tests */ float eps,m; matrix U, U1; BOOLEAN stop; center V; objects X; char fname[80]; FILE *fp; int run; float inv_cov[s+1][s+1]; /* inverse of covariance matrix Y */ float Y[s][s]; long rand_index, Random_seed; long state1[52] = { 9347, 3835, 5194, 8310, 346, 535, 5297, 6711, 77, 3834, 668, 4175, 6868, 5890, 9304, 8462, 5269, 920, 65392, 41600, 70119, 91032, 76220, 26245, 4746, 73608, 32823, 63264, 75641, 99104, 36534, 24704, 98255, 72266, 75336, 65152, 7269, 63163, 88471, 27271, 43641, 76649, 47773, 23777, 27491, 35926, 16651, 48652, 89766, 90921, 6056 }; int z; int mins=0; int aveit =0; float mintab[200]; int mincount[200]; long start,end,total; int lCount;//added by parag /********************************************************************/ /********************************************************************//*int lrand48(){return(rand());}void srand48(int a){return;}*//********************************************************************/ /********************************************************************/ /* Function to read the input data set */ /* The file name is assumed to be itest.data */ /* Status: Tested */ /* Output: Data from the file into the "data" (Global) data structure */ /* Output: Count (Global), the count of the number of objects */ /********************************************************************/ void readInput() { FILE *fp; char fname[80]; int i=0,j=0; char ch; sprintf(fname,"%s.data",filename); /* Check if the input file is opened */ if((fp=fopen(fname,"r"))==NULL) { printf("\n Unable to open input file \n"); exit(0); } /*initialise the minimum maximum and the scale */ for(i=0;i<features;i++) { minInput[i]=1000; maxInput[i]=0; minForHeaps[i]=1000; maxForHeaps[i]=0; scale[i]=0; scaleForHeaps[i]=0; } /* Discard leading comments */ ch = 'c'; while (ch != '#') fscanf (fp, "%c", &ch); i=0; /* Parse the file and populate the data structure */ while(!feof(fp)) { for(j=0;j<features;j++) { fscanf(fp,"%f ",&data[i][j]); } fscanf(fp,"\n"); for(j=0;j<features;j++) { if(data[i][j]<minInput[j]) minInput[j]=data[i][j]; if(data[i][j]>maxInput[j]) maxInput[j]=data[i][j]; } i++; } count=i; /* Normailze the feature values in between 0 and 1 */ for(j=0;j<features;j++) { if(minInput[j]!=maxInput[j]) scale[j]=1.0/(maxInput[j]-minInput[j]); else scale[j]=1.0; } for(i=0;i<count;i++) { for(j=0;j<features;j++) data[i][j]=(data[i][j]-minInput[j])*scale[j]; } fclose(fp); return; }//end of function /********************************************************************/ /*Function to compute the eucldiean distance for all input data set */ /* Output : an array conatining the distance of each object with the other */ /********************************************************************/ float computeDistance() { float distance,dist=0; int i=0,j=0,k=0; distance=0; for(j=0;j<count;j++) for(i=0;i<count;i++) { for(k=0;k<features;k++) dist+=sqrt((data[j][k]-data[i][k])*(data[j][k]-data[i][k])); if(distance<dist)distance=dist; dist=0; } return(distance); } /********************************************************************/ /* Function to compute the distance between two objects */ /* Output : Euclidean d istance between the two input objects */ /********************************************************************/ float computeDistanceBetween2(irisData a,irisData b) { float temp=0; int i=0; for(i=0;i<features;i++) temp+=(a[i]-b[i])*(a[i]-b[i]); temp=sqrt(temp); return(temp); } /********************************************************************/ /* Function to find the maximum distance between the input objects*/ /* Output: the maximum distance */ /* Input : The array of distances between objects */ /********************************************************************/ /*float findMax(float *distance) { int i=0,j=0; float max=distance[0]; for(i=0;i<count;i++) for(j=0;j<count;j++) { if(max<distance[i*count+j]) max=distance[i*count+j]; } return(max); }*/ /********************************************************************/ /* Function to compute the value of an object */ /********************************************************************/ float value(irisData a) { int i=0; float temp=0; for(i=0;i<features;i++) temp+=a[i]*a[i]; return(sqrt(temp)); } /********************************************************************/ /* Function to find the object in the data structure */ /* Output : The position of the object in the data */ /* Input : The object */ /********************************************************************/ int findInData(irisData object,int iFlag) { int i=0,lastCount=0,j,position=-1,flag[features],flg;if(iFlag==1)lastCount=MAXDATA;else{}for(i=0;i<lastCount;i++){ for(j=0;j<features;j++) if(fabs(object[j]-data[i][j])<0.00001) flag[j]=1; else { flag[j]=0; break;} flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /* Function to find whether there is an object on the board at a,b */ /* Output : a flag indicating whether an object is found or not */ /* Input : The row and column indicating the board position */ /********************************************************************/ int found(int a , int b) { if(board[a][b]==9) return 1; else return 0; } /********************************************************************/ /* Function to initialize the initial board */ /* Output : None */ /* Global Structures modified : heaps */ /* Input : Flag indicating the iteration 1: First 0: Second */ /********************************************************************/ void initialise(int flag) { int a,b,i=0,k=0; int loopCount,rowCount,colCount; /* Initialize the row, column and number of heaps */ if(flag==1) { loopCount=count; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=lCount; rowCount=heapRow; colCount=heapRow; } /* Initialize the heaps */ for(i=0;i<loopCount;i++) { heaps[i].count=0; heaps[i].x=0; heaps[i].y=0; heaps[i].disPosition=0; heaps[i].Dmax=0; heaps[i].Dmean=0; } for(i=0;i<loopCount;i++) { /*find a board position which is empty*/ do { a=lrand48()%rowCount; b=lrand48()%colCount; } while(found(a,b)); /*Allocate the object to that place and assign a heap to it*/ heaps[i].x=a; heaps[i].y=b; heaps[i].count=1; heaps[i].Dmax=0; heaps[i].Dmean=0; if(flag==1) { heaps[i].objects[0]=i; for(k=0;k<features;k++)heaps[i].Ocenter[k]=data[i][k]; } else { for(k=0;k<features;k++) heaps[i].Ocenter[k]=newHeaps[i].Ocenter[k]; } heaps[i].disPosition=0; board[a][b]=9; if((debugLevel>0)&&(flag==1))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],data[heaps[i].objects[0]][0]); if((debugLevel>0)&&(flag==0))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],newHeaps[i].Ocenter[0]); } /*initialise the initial heap count*/ heapCount=loopCount; currentRow=rowCount; } /********************************************************************/ /* Function to find whether an heap is present at the location a b */ /* Output : Flag indicating the presencs of the heap */ /* Input : Roe and column indicating the board position */ /********************************************************************/ int findObject(int a,int b) { int i; int position=-1; for(i=0;i<heapCount;i++) { if((heaps[i].x==a)&&(heaps[i].y==b)) { position=i; break; } } return(position); } /********************************************************************/ /* Function initialize the ants */ /* Output : None */ /* Input : Flag indicating the iteration */ /* Global Variables Modified : ant, heapCount, heaps, board */ /********************************************************************/ void initialiseAnts(int flag) { int i=0,a=0,b=0,position,j=0,loopCount=0,rowCount,colCount,k=0; if(flag==1) { loopCount=MAXANTS; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=MAXANTSFORHEAPS; rowCount=heapRow; colCount=heapRow; } for(i=0;i<loopCount;i++) { /*generate random positions for the ants*/ a=lrand48()%rowCount; b=lrand48()%colCount; ants[i].x=a; ants[i].y=b; /*Find if an object is present at that position or not*/ if(board[a][b]==9) { ants[i].carrying=1; /*find the heap at that location*/ position=findObject(a,b); if(position==-1) { printf("\n Error in logic: Ant init \n"); //getchar(); break; } else { /*Assign the heap data to the ant data and decrement the heap count*/ if(flag==1){ for(k=0;k<features;k++)ants[i].data[k]=data[heaps[position].objects[0]][k]; }else{for(k=0;k<features;k++)ants[i].data[k]=heaps[position].Ocenter[k];} for(j=position;j<heapCount-1;j++) heaps[j]=heaps[j+1]; heapCount--; } /*Clear the board position */ board[a][b]=-9; } else ants[i].carrying=-1; ants[i].speed=0; ants[i].dir=lrand48()%8; printf("\n Ant %2d X: %2d Y: %2d Carying : %2d ",i,ants[i].x,ants[i].y,ants[i].carrying); } currentAntCount=loopCount; } /********************************************************************/ /* Function to move the ant */ /* Output: None */ /* Input: Ant to be moved and the flag indicating the iteration */ /********************************************************************/ void moveNext(ant* a,int flag) { int rowCount,colCount; /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; } else { rowCount=heapRow; colCount=heapRow; }*/rowCount=currentRow;colCount=currentRow; /*Depending upon the direction move the ant*/ switch (a->dir) { case 0: a->y++; if(a->y>=colCount)a->y=0; break; case 1: a->x--; a->y++;; if(a->x<0)a->x=rowCount-1; if(a->y>=colCount)a->y=0; break; case 2: a->x--; if(a->x<0)a->x=rowCount-1; break; case 3: a->x--; a->y--; if(a->x<0)a->x=rowCount-1; if(a->y<0)a->y=colCount-1; break; case 4: a->y--; if(a->y<0)a->y=colCount-1; break; case 5: a->x++; a->y--; if(a->x>=rowCount)a->x=0; if(a->y<0)a->y=colCount-1; break; case 6: a->x++; if(a->x>=rowCount) a->x=0; break; case 7: a->x++; a->y++; if(a->x>=rowCount)a->x=0; if(a->y>=colCount)a->y=0; break; } }//end of function /********************************************************************/ /* Function to compute the parameters of the heap */ /* Output: None */ /* Input: The heap whose parameters are to be computed iteration flag*/ /********************************************************************/ void computeHeapParameters(heap* heapData,int flag) { int i=0,j=0,k=0,position=0; float distance=0; float Dmean=0.0; float *dis; float featureSum[features]; float max=0; float sum=0; /* init*/ for(k=0;k<features;k++) featureSum[k]=0; /*Compute the distance of each object and find the maximum distance*/ max=0; if(flag==1){ for(j=0;j<heapData->count;j++) for(i=0;i<heapData->count;i++) { for(k=0;k<features;k++) sum+= (data[heapData->objects[j]][k]-data[heapData->objects[i]][k])*(data[heapData->objects[j]][k]-data[heapData->objects[i]][k]); distance=sqrt(sum); if(max<distance) max=distance; sum=0; } /* Assign the maximum distance to the heap */ heapData->Dmax=max;/*Compute the centre object*/for(i=0;i<heapData->count;i++)for(k=0;k<features;k++) featureSum[k]+=data[heapData->objects[i]][k];for(k=0;k<features;k++)heapData->Ocenter[k]=featureSum[k]*1.0/heapData->count; /* Find the mean distance */if((dis=(float *) calloc(heapData->count,sizeof(float)))==NULL){printf("\nUnable to allocate memory in the compute heap parameters procedure\n");exit(0);} for(i=0;i<heapData->count;i++) { Dmean+=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); dis[i]=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); } heapData->Dmean=Dmean*1.0/heapData->count; /*Compute the most dissimilar object*/ max=dis[0]; for(i=1;i<heapData->count;i++) if(max<dis[i]) { max=dis[i]; position=i; } /*Assign the most dissimilar object to the heap variable*/ for(k=0;k<features;k++) heapData->Odissim[k]=data[heapData->objects[position]][k]; heapData->disPosition=position;free(dis); } else{/* Heap Parameters for the second stage */for(k=0;k<features;k++){ heapData->Odissim[k]=heapData->Ocenter[k];}heapData->disPosition=0;heapData->Dmean=0;heapData->Dmax=0;} }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a single object*/ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject1(ant *a,int position,int flag) { int i,k=0; /*Clear the board*/ board[heaps[position].x][heaps[position].y]=-9; /* Assign the data to the ant*/if(flag==1){ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[0]][k];}else {for(k=0;k<features;k++) a->data[k]=heaps[position].Ocenter[k];} a->carrying=1; /*Copy all the heaps remaining heaps in the structure*/ for(i=position;i<heapCount-1;i++) heaps[i]=heaps[i+1]; /*Decrement the heap count*/ heapCount--; }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a two objects */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject2(ant *a , int position,int flag) { float Pdestroy1=-1; int i=0,k=0; /*Compute the probability to destroy the heap*/ Pdestroy1=lrand48()%13*1.0/12.0; /*If the probability is more than Pdestroy then destroy the heap */ if(Pdestroy1<Pdestroy) { /*pick the object randomly*/ i=lrand48()%2; /* Assign the data to the ant */ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[i]][k]; a->carrying=1; /*Correct the heap parameters*/ heaps[position].count=1; heaps[position].objects[0]=heaps[position].objects[1-i]; computeHeapParameters(&heaps[position],flag); } }//end of function /********************************************************************/ /*Function to pick a object from a heap consisting of more than two object */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /********************************************************************/ void pickObjectn(ant *a,int position,int flag) { int i=0,k=0; /*If the criteria is satsfied then pick the object*/ if((computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)*1.0/heaps[position].Dmean)>Tremove) { a->carrying=1; for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[heaps[position].disPosition]][k]; for(i=heaps[position].disPosition;i<heaps[position].count-1;i++) heaps[position].objects[i]=heaps[position].objects[i+1]; heaps[position].count--; computeHeapParameters(&heaps[position],1); } }//end of function /********************************************************************/ /* Function to pick a object */ /********************************************************************/ void pick(ant *a,int flag) { int position=-1,i=0; float Pload1=-1.0; for(i=0;i<heapCount;i++) { /*Check if a heap is present in the eight neighbouring cells*/ if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if Heap is found*/ if(position!=-1) { /* heap or object found.*/ /*Depending upon the number present in the heap call the corresponding routine*/ switch(heaps[i].count) { case 1: Pload1 = lrand48()%151*1.0/150.0; if(Pload1<Pload) { pickObject1(a,position,flag); } break; case 2: pickObject2(a,position,flag); break; default: pickObjectn(a,position,flag); break; } } } /********************************************************************/ /* Function to drop a object to form a new heap */ /* Output: None */ /* Input: Ant, iteration flag */ /* Global Structure modified : heap, heapCount */ /********************************************************************/ void dropObject(ant* a,int flag) { /*Create a new heap*/ int k=0; heaps[heapCount].count=1; heaps[heapCount].x=a->x; heaps[heapCount].y=a->y; heaps[heapCount].Dmax=0; heaps[heapCount].Dmean=0; heaps[heapCount].disPosition=0; for(k=0;k<features;k++) { heaps[heapCount].Odissim[k]=a->data[k]; heaps[heapCount].Ocenter[k]=a->data[k]; } if(flag==1) {heaps[heapCount].objects[0]=findInData(a->data,flag); /*computeHeapParameters(&heaps[heapCount],flag);*/ } computeHeapParameters(&heaps[heapCount],flag); heapCount++; a->carrying=-1; board[a->x][a->y]=9; }//end of function /********************************************************************/ /* Function to find the heap position during the second iteration */ /* Output: position of the heap */ /* Input: object center of the heap that the ant is carrying */ /* Global Structure modified : none */ /********************************************************************/ int findInNewheaps(irisData object) { int position=-1,i,j=0,flag[features],flg; for(i=0;i<newHeapCount;i++) { for(j=0;j<features;j++) { if(fabs(object[j]-newHeaps[i].Ocenter[j])<0.00001) flag[j]=1; else {flag[j]=0;break;} } flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /*Function to drop a object to a heap consisting of a one or more object */ /* Output: none */ /* Input: Ant, position of the heap , iteration flag */ /* Global Structure modified: heaps,newHeaps */ /********************************************************************/ void dropObject1(ant* a, int position,int flag) { int heapPosition=-1,heapPosition1=-1,i,j,k=0; irisData newData,temp; if(flag==1) { /*Add the object to the heap and compute the heap parameters*/ /*if(heaps[position].count==heaps[position].objCount) {if((junk=(int *)realloc(heaps[position].objects,((heaps[position].objCount+OBJINC)*sizeof(int))))==NULL){printf("\n Cannot Allocate memory to the new object for %d heap",position);exit(0);}heaps[position].objects=junk;heaps[position].objCount+=OBJINC;free(junk); }*/ heaps[position].objects[heaps[position].count]=findInData(a->data,flag); heaps[position].count++; computeHeapParameters(&heaps[position],flag); } else { for(k=0;k<features;k++)temp[k]=heaps[position].Ocenter[k]; heapPosition=findInNewheaps(a->data); heapPosition1=findInNewheaps(heaps[position].Ocenter); if(heapPosition==-1||heapPosition1==-1) { printf("\n error in logic:new heaps\n"); //getchar(); return; } for(k=0;k<features;k++) {newData[k]=(newHeaps[heapPosition].Ocenter[k]*newHeaps[heapPosition].count+newHeaps[heapPosition1].Ocenter[k]*newHeaps[heapPosition1].count)*1.0/(newHeaps[heapPosition].count+newHeaps[heapPosition1].count);newHeaps[heapPosition].Ocenter[k]=newData[k];heaps[position].Ocenter[k]=newData[k]; } computeHeapParameters(&heaps[position],flag); for(i=newHeaps[heapPosition].count,j=0;j<newHeaps[heapPosition1].count;i++,j++) { newHeaps[heapPosition].objects[i]=newHeaps[heapPosition1].objects[j]; } newHeaps[heapPosition].count+=newHeaps[heapPosition1].count; for(i=heapPosition1;i<newHeapCount-1;i++) newHeaps[i]=newHeaps[i+1]; newHeapCount--; } a->carrying=-1; }//end of function /********************************************************************/ /* Function to drop a object */ /* Output: None */ /* Input: Ant, iteration flag */ /********************************************************************/ void drop(ant* a,int flag) { int i, position=-1; float Pdrop1=0.0; /*Find whether we have a heap in the neighbourhood of the cell*/ for(i=0;i<heapCount;i++) { if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if a heap is found*/ if(position!=-1) { /*heap or object found.*/ /*Depending on the number of objects present take action*/ switch(heaps[position].count) { /*If criteria is satisfied then drop the object*/ case 1: if(flag==1) { if((computeDistanceBetween2(a->data,data[heaps[position].objects[0]])*1.0/Dmax)<Tcreate) dropObject1(a,position,flag); } else { if((computeDistanceBetween2(a->data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) dropObject1(a,position,flag); } break; default: if(computeDistanceBetween2(a->data,heaps[position].Ocenter)<computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)) dropObject1(a,position,flag); break; } } else { /*Compute the probability to drop the object*/ Pdrop1 = lrand48()%151*1.0/150; if(Pdrop1<Pdrop) dropObject(a,flag); } }//end of function /********************************************************************/ /* Function to move the ant */ /* Output: none */ /* Input: Ant, iteration flag */ /********************************************************************/ void move(ant* a,int flag) { float pDir; /*Check the speed */ if (a->speed!=0) { /*move in the same direction*/ a->speed--; moveNext(a,flag); } else { /*generate the new direction*/ pDir=lrand48()%17*1.0/16.0; if(pDir<.85) { a->dir=lrand48()%8; } else if(pDir>.95) { a->speed=2; } moveNext(a,flag); } } /********************************************************************/ /* Function to simulate the movement of the ants */ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified: minHeapCount, minHeapPosition */ /********************************************************************/ void iterate(int flag) { int i=0,j=0,k=0,loopCount=0; if (flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS; while (i<MAXITERATIONS) { i++; for(j=0;j<loopCount;j++) { move(&ants[j],flag); if(ants[j].carrying==1) { drop(&ants[j],flag); } else { pick(&ants[j],flag); } } if(debugLevel>0){ for(k=0;k<heapCount;k++) for(j=0;j<heapCount;j++) if((k!=j)&&(heaps[k].x==heaps[j].x)&&(heaps[k].y==heaps[j].y)) { printf("\nerror two heaps with same co ordinates %d %d ",k,j); //getchar(); } k=0; for(j=0;j<heapCount;j++) k+=heaps[j].count; } if(heapCount<minHeapCount) { minHeapCount=heapCount; minPosition=i; } if(debugLevel>0) printf("\n i:%d Heap count %d sum %d",i,heapCount,k); else printf("\n i:%d Heap count %d",i,heapCount); heapSum+=heapCount; /*if(i%updateAfter==0) {adjustBoard(flag); writeIncremental(i,flag);heapSum=0;loopCount=currentAntCount; }*/ } }//end of function /********************************************************************/ /*Function to drop the objects carried by the ants after all the iterations*/ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified:none */ /********************************************************************/ void dropFinal(int flag) { int i=0,j=0,position=-1,loopCount=0; /*if(flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS;*/ loopCount=currentAntCount; for(i=0;i<loopCount;i++) { if(ants[i].carrying==1) { if(flag==1) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position,flag); } } else { /*Find if a heap is present */ do { position=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position,flag); position=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position!=-1); } } } }//end of function /********************************************************************/ /* Function for the implementation of QuickSort */ /* Output: none */ /* Input: data structure, low and high indices */ /* Global structure modified:none */ /********************************************************************/ void quickSort( heap A[], int low,int high ) { int mid=0; if(low<high) { mid=partition(A,low,high); quickSort(A,low,mid); quickSort(A,mid+1,high); } } /********************************************************************/ /* Partition routine used by quick sort */ /* Output: partition location */ /* Input: data , low, high */ /* Global structure modified:none */ /********************************************************************/ int partition(heap a[], int low,int high) { heap temp; int x=0,i=0,j=0; i=low; j=high; x=a[low].count; while (1) { while (a[j].count<x) j=j-1; while (a[i].count>x) i=i+1; if(i<j) { temp=a[i]; a[i]=a[j]; a[j--]=temp; } else return(j); } } /********************************************************************/ /* Function used to write the cluster information */ /* Output: none */ /* Input:iteration flag */ /* Global structure modified:none */ /********************************************************************/ void writeClusterInformation(int flag) { FILE *fp=fopen("center.clt","w"); FILE *fp1; FILE *fp2; FILE *fp3; char temp[80]; int i=0,j=0,k=0; int lastCount=0; int rowCount,colCount,antCount; strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp3=fopen(temp,"a"); if(dataDump) {strcpy(temp,"");sprintf(temp,"%sTot.out",filename);fp1=fopen(temp,"a");strcpy(temp,"");sprintf(temp,"%sObj.out",filename);fp2=fopen(temp,"a");if(fp1==NULL||fp2==NULL)printf("\n Error in opening file in the writer Cluster Information routine\n"); } /*if(flag==1) { rowCount=MAXROWS; colCount=MAXCOLS; antCount=MAXANTS; } else { rowCount=heapRow; colCount=heapRow; antCount=MAXANTSFORHEAPS; }*/ rowCount=currentRow; colCount=currentRow; antCount=currentAntCount; if(fp==NULL) { printf("\n Unable to open cluster center output file \n"); /*return;*/ exit(0); } /*sort the array according to the count value and write the value of the top three elements*/ if((flag==1)&&(!EntireHeaps)) quickSort(heaps,0,heapCount); if(EntireHeaps) {if(flag==1) lastCount=heapCount;else lastCount=newHeapCount; } else lastCount=c; for(i=0;i<lastCount;i++) { if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else { for(k=0;k<features;k++) { /*fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]/scale[k]+minInput[k]);*/ fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",newHeaps[i].Ocenter[k]); fprintf(fp,"\n"); } else { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); fprintf(fp,"\n"); } } if(dataDump) { fprintf(fp1,"\n Information from the Ant Based Algorithm \n"); fprintf(fp1,"\n Important Parameters : Board %d X %d Ants : %d Iterations %d Total Heaps %d ",rowCount,colCount,antCount,MAXITERATIONS,lastCount); } if(flag==0) { if(dataDump) { fprintf(fp1," TCreateForHeaps %f \n",TcreateForHeaps); fprintf(fp2,"\nTotal Heaps : %d\n",heapCount); fprintf(fp2,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); } fprintf(fp3,"\n@ %d\n",lastCount); } else if(dataDump) fprintf(fp1,"\n");if(dataDump) { fprintf(fp1,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); for(i=0;i<lastCount;i++) if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp2,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); } fprintf(fp1," %5d\n",newHeaps[i].count); fprintf(fp2," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp1," %5d\n",heaps[i].count); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]); fprintf(fp1," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]); fprintf(fp1," %5d\n",heaps[i].count); }} if(flag==0) { if(dataDump) fprintf(fp1,"\n Objects in the heaps \n");for(i=0;i<newHeapCount;i++) { if(dataDump) fprintf(fp1,"\n\n Heap %d\n \n",i+1);fprintf(fp3,"# %d %d\n",i ,newHeaps[i].count); for(j=0;j<newHeaps[i].count;j++){ for(k=0;k<features;k++){ fprintf(fp3,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]); if(dataDump) fprintf(fp1,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]);} if(dataDump) fprintf(fp1,"\n"); fprintf(fp3,"\n"); } } } fclose(fp); fclose(fp3); if(dataDump) { fclose(fp1);fclose(fp2); }}//end of flie /********************************************************************/ /* Function to initialise the new heaps */ /* Output: none */ /* Input:new Heap structure */ /* Global structure modified:none */ /********************************************************************/ void initialiseNewHeaps(heap newHeaps[]) { int i=0,j=0; for(i=0;i<lCount;i++) { newHeaps[i].count=0; for(j=0;j<features;j++) newHeaps[i].Ocenter[j]=V[i][j]; newHeaps[i].x=heaps[i].x; newHeaps[i].y=heaps[i].y; } }//end of function /********************************************************************/ /* Function to initialise the new heaps */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ int findPosition(int i) { int j,position=0; for(j=1;j<lCount;j++) { if(U[j][i]>U[position][i]) position=j; } printf("\n Position %d ",position); return(position); }//end of function find position /********************************************************************/ /* Function to add object */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ void addObject(int object,heap * heapPosition) { heapPosition->objects[heapPosition->count]=object; heapPosition->count++; }//end of function add object /********************************************************************/ /* Function to harden the outputs obtained from fcm */ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/ void harden(heap newHeaps[]) { int i,heapPosition=-1,sum=0,j=0; /*initialise the new heaps*/ initialiseNewHeaps(newHeaps); for(i=0;i<count;i++) { heapPosition=findPosition(i); addObject(i,&newHeaps[heapPosition]); } /* To check for degenerate partitions*/ for(i=0;i<lCount;i++) { if(newHeaps[i].count==0){for(j=i;j<lCount-1;j++){newHeaps[j]=newHeaps[j+1];}lCount--;i--;} } newHeapCount=lCount; for(i=0;i<lCount;i++) computeHeapParameters(&newHeaps[i],1); if(debugLevel>0) { for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\n sum = %d",sum);} }//end of function/********************************************************************/ /* Function to initialize the initial parameters for the ant algorithm*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void init() { int i=0,j=0; for(i=0;i<MAXROWS;i++) for(j=0;j<MAXCOLS;j++) board[i][j]=-9; heapCount=0; newHeapCount=0; heapRow=0; minPosition=-1; minHeapCount=100000; for(i=0;i<MAXANTS;i++) { ants[i].carrying=-1; ants[i].x=-1; ants[i].y=-1; ants[i].speed=-1; ants[i].dir=-1; } } /********************************************************************/ /* Function to initialize the initial board */ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void initialiseBoard() { int i,j; for(i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; }/********************************************************************/ /* Function to harden the outputs obtained from fcm(2nd stage)*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: Cluster center , cluster center count*/ /********************************************************************/void harden1() { int i=0,heapPosition=-1; for(i=0;i<heapCount;i++) cenCount[i]=0; for(i=0;i<n;i++) { heapPosition=findPosition1(i); addObject1(i,heapPosition); } writeInfo(); }//end of function/********************************************************************/ /* Function to find to which class the object belongs */ /* Output: Class number */ /* Input: object position */ /* Global Structure Modified: None */ /********************************************************************/int findPosition1(int i) { int j,position=0; for(j=1;j<heapCount;j++) { if(U[j][i]>U[position][i]) position=j; } return(position); }//end of function find position/********************************************************************/ /* Function to Write the output of the hardened objects to file*/ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/void writeInfo(){int i=0,j=0,k=0;FILE *fp=fopen("fcm.out","a");if(fp==NULL){printf("\n Unable to open fcm output file \n");return;}fprintf(fp,"\n@ %d\n",heapCount);for(i=0;i<heapCount;i++){fprintf(fp,"# %d %d\n",i,cenCount[i]);for(j=0;j<cenCount[i];j++){for(k=0;k<s;k++)fprintf(fp,"%8.2f ",clsCen[i][j][k]/scale[k]+minInput[k]);fprintf(fp,"\n");}}fclose(fp);return;}/********************************************************************/ /* Function to add a object to a cluster (2nd stage) */ /* Output: none */ /* Input: object poistion , cluster position */ /* Global Structure Modified: Cluster object and cluster count*/ /*******************************************************************/void addObject1(int object,int heapPosition) { int k=0; for(k=0;k<features;k++) clsCen[heapPosition][cenCount[heapPosition]][k]=X[object][k]; cenCount[heapPosition]++; return; }//end of function add object/********************************************************************/ /* Function to read the original classification of objects */ /* Output: none */ /* Input: none */ /* Global Structure Modified: None */ /*******************************************************************/void readOrg(){int i=0,k=0;char temp[80];FILE *fp;//= fopen(dataname,"r");strcpy(temp,"");sprintf(temp,"%sFull.data",filename);fp=fopen(temp,"r");if(fp==NULL){printf("\n Unable to open full data input file ");exit(0);}for(i=0;i<n;i++){fscanf(fp,"%f ",&orgData[i][0]);for(k=1;k<s+1;k++)fscanf(fp,"%f ",&orgData[i][k]);}return;}// end of function/********************************************************************/ /* Function to classify the objects in different clusters */ /* Output: none */ /* Input: the cluster objects, the original classification, */ /* number of objects in the cluster,file to write the data */ /* Global Structure Modified: None *//********************************************************************/int analysisData(float data[][s],float orgData[n][s+1],int count,FILE * fp){int i=0,j=0,k=0,type=1,max=0;heapInfo info;for(i=0;i<c;i++){info.classObj[i]=0;}info.total=0;info.total=count;for(i=0;i<count;i++)for(j=0;j<n;j++){type=1;for(k=0;k<s;k++)if(fabs(data[i][k]-orgData[j][k+1])>errThresh){type=-1;break;}if(type!=-1){info.classObj[(int)orgData[j][0]-1]++;break;}}max=0;for(k=0;k<c;k++){if(info.classObj[k]>info.classObj[max])max=k;fprintf(fp,"\nClass %d Objects % d ",k+1,info.classObj[k]);}j=0;for(k=0;k<c;k++){if(k!=max)j+=info.classObj[k];}fprintf(fp,"\n Total errors : %d \n",j);return(j);}//end of analyse/********************************************************************/ /* Function to read the cluster information */ /* Output: none */ /* Input: input file pointer , output file pointer */ /* Global Structure Modified: None *//********************************************************************/void readFCM(FILE* fp,FILE *fp1){int i=0,j=0,k=0,l=0;int totalRuns=0,heapCount=0,junk=0,sum=0;char ch;FILE *fp2=fopen("errors.out","a");ch = 'c'; while (ch != '$') fscanf (fp, "%c", &ch);fscanf(fp,"%d\n",&totalRuns);printf("\n total runs %d ",totalRuns);for(l=0;l<totalRuns;l++){fscanf(fp,"%c",&ch);fscanf(fp,"%d\n",&heapCount);fprintf(fp1,"\n \nExperiment %d \n ",l+1);sum=0;for(i=0;i<heapCount;i++){fscanf(fp,"%c",&ch);fscanf(fp," %d %d\n",&junk,&clsCenCount[i]);for(j=0;j<clsCenCount[i];j++)for(k=0;k<s;k++)fscanf(fp,"%f",&fcmData[i][j][k]);fscanf(fp,"\n");fprintf(fp1,"\n\n Heap %d Total Objects %d \n",i+1,clsCenCount[i]);sum+=analysisData(fcmData[i],orgData,clsCenCount[i],fp1);}fprintf(fp2," %3d %3d %3d \n",l,sum,heapCount);}fprintf(fp2,"\n --------------------------\n");fclose(fp2);return;}//end of function/********************************************************************/ /* Function to update the board parameters */ /* Output: none */ /* Input: none */ /* Global Structure Modified: board size, ant count *//********************************************************************/void adjustBoard(int flag){int newRow=0,newAnt=0,antDiff=0,antsKilled=0,i=0,position[MAXANTS],position1=-1,j=0,k=0,a,b; newRow= (int)ceil(sqrt(4.0*heapSum/updateAfter)); newAnt= (int)ceil((heapSum*1.0/updateAfter)*1.0/3.0); if(newAnt<minAnts)newAnt=minAnts; if(newRow<rowMin)newRow=rowMin;antDiff=currentAntCount-newAnt; if((antDiff>0)&&(newAnt>=minAnts)) {for(i=0;i<currentAntCount;i++){if(ants[i].carrying==-1){position[antsKilled++]=i;}} if(antsKilled>=antDiff){for(i=0;i<antDiff;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1];for(k=i+1;k<antsKilled;k++)position[k]--; } currentAntCount=newAnt; }else {for(i=0;i<antsKilled;i++){for(j=position[i];j<currentAntCount-1;j++)ants[j]=ants[j+1]; for(k=i+1;k<antsKilled;k++)position[k]--; }if(flag==1) { for(i=currentAntCount-1,k=0;k<antDiff-antsKilled;k++,i--) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position1,flag); }else { dropObject(&ants[i],flag); } } } else { //flag is zero 2nd stage /*Find if a heap is present */ do { position1=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position1=i; break; } } if(position1!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position1].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position1,flag); position1=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position1!=-1); }//end else currentAntCount=newAnt;}//end elsecurrentAntCount=newAnt;}//end iffor(i=0;i<newAnt;i++){if((ants[i].x>=newRow)||(ants[i].y>=newRow)) { a=lrand48()%newRow; b=lrand48()%newRow; ants[i].x=a; ants[i].y=b; }} //Done with ants, now adjust the boardif((currentRow>newRow)&&(newRow>=rowMin)){for(i=0;i<heapCount;i++){if((heaps[i].x>=newRow)||(heaps[i].y>=newRow)) {do { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionheaps[i].x=a;heaps[i].y=b;board[a][b]=9;}//end if}//end for for(i=0;i<currentAntCount;i++){if((ants[i].carrying==1)&&((ants[i].x>=newRow)||(ants[i].y>=newRow))){//adjust the ant locationdo { a=lrand48()%newRow; b=lrand48()%newRow; } while(found(a,b));//adjust the heap poistionants[i].x=a;ants[i].y=b;}//end if}//end for currentRow=newRow;}//end if }//end of function void writeIncremental(int iteration,int flag){FILE *fp=fopen("dump.txt","w");int i=0,j=0,k=0;fprintf(fp,"Stage %d\n",flag);fprintf(fp,"Board %d\n",currentRow);fprintf(fp,"Ants %d\n",currentAntCount);fprintf(fp,"Iteration %d\n",iteration);fprintf(fp,"Heaps %d\n",heapCount); if(flag==0)fprintf(fp,"NewHeapCount %d\n",newHeapCount); fprintf(fp,"Ants\n");for(i=0;i<currentAntCount;i++){fprintf(fp,"%d %d %d %d %d ",ants[i].x,ants[i].y,ants[i].carrying,ants[i].speed,ants[i].dir);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",ants[i].data[k]);fprintf(fp,"\n");}fprintf(fp,"Heaps\n");for(i=0;i<heapCount;i++){fprintf(fp,"%d %d %d %d %8.2f %8.2f \n",heaps[i].x,heaps[i].y,heaps[i].count,heaps[i].disPosition,heaps[i].Dmax,heaps[i].Dmean);for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Ocenter[k]);fprintf(fp,"\n");for(k=0;k<features;k++)fprintf(fp,"%8.4f ",heaps[i].Odissim[k]);fprintf(fp,"\n");if(flag==1){for(j=0;j<heaps[i].count;j++)fprintf(fp,"%d ",heaps[i].objects[j]);fprintf(fp,"\n");}}if(flag==0){fprintf(fp,"newHeaps\n");for(i=0;i<newHeapCount;i++){fprintf(fp,"%d\n",newHeaps[i].count);for(j=0;j<newHeaps[i].count;j++)fprintf(fp,"%d ",newHeaps[i].objects[j]);fprintf(fp,"\n");}}fclose(fp);}//end of function/********************************************************************/ /* Function Main */ /********************************************************************/ int main(int argc ,char** argv) { int sum=0,k=0,i=0,j=0; char temp[80]; FILE *fp=fopen("fcm.out","w"); FILE *fp1; FILE *fp2=fopen("antAnalysis.out","a"); FILE *fp3=fopen("fcmAnalysis.out","a"); FILE *fp4=fopen("errors.out","w"); FILE *fp5; fclose(fp4); sprintf(temp,"%sObj.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sTot.out",filename); fp5=fopen(temp,"w"); fclose(fp5); strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp1=fopen(temp,"w"); fprintf(fp,"\n$%d",EXPRUN); fprintf(fp1,"\n$%d",EXPRUN); fclose(fp); fclose(fp1); if(argc==2)sscanf(argv[1],"%d",&debugLevel); printf("\n Debug level %d\n",debugLevel); for( i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; //Read from the file readInput(); //Compute the distance of all the points if(maxDist) { Dmax=computeDistance(); //Compute the maximum distance fp5=fopen("maxData.txt","w");fprintf(fp5,"%f",Dmax);fclose(fp5); } else {fp5=fopen("maxData.txt","r");fscanf(fp5,"%f",&Dmax);fclose(fp5); } printf("\n %f \n",Dmax); //Initialise the board for(k=0;k<EXPRUN;k++) { init(); sum=0; srand48(state1[k]); initialiseBoard(); initialise(1); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(1); printf("\n %d \n",heapCount); //Simulate the working of ants iterate(1); //drop the objects after all the iterations dropFinal(1); //to verify the correctness for(i=0;i<heapCount;i++) sum+=heaps[i].count; //write the cluster centers to the file writeClusterInformation(1); printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); //getchar(); //Run FCM // heapCount=2973;/* To be commented */ printf("\n\n k %d \n\n",k); Fcm(data); //compute new board size. lCount=heapCount; heapRow=(int)ceil(sqrt(4*heapCount)); newHeapCount=lCount; printf("\n LCount %d newHeapCount %d heap Row %d \n",lCount,newHeapCount,heapRow); //harden the objects harden(newHeaps); //iterate with the heaps as the objects. initialiseBoard(); initialise(0); for(i=0;i<lCount;i++) computeHeapParameters(&heaps[i],0); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(0); printf("\n %d \n",heapCount); //getchar(); //Simulate the working of ants iterate(0); dropFinal(0); writeClusterInformation(0); sum=0; for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); // getchar(); Fcm(data); harden1(); } fp=fopen("fcm.out","a"); fp1=fopen(temp,"a"); fprintf(fp,"\n"); fprintf(fp1,"\n"); fclose(fp); fclose(fp1); fp=fopen("fcm.out","r"); fp1=fopen(temp,"r");printf("\n Before read org\n");readOrg();printf("\nafter read org\n");readFCM(fp1,fp2);printf("\n After 1st read fcm\n");readFCM(fp,fp3);printf("\n After 2 fcm read \n");return(1); }//end of main /****************************************************************/ float NORM(feature , feature); void find_covar(); void Fcm (irisData Data[MAXDATA]) { int i,j,l; FILE *ofile; char temp[80]; int flag=0;//added by parag FILE *iniClsCen=fopen("center.clt","a+"); if(iniClsCen==NULL) { printf("\n Unable to open the initial cluster center file\n"); printf("\n choosing random cluster centers....\n"); flag=1; } strcpy(temp,""); sprintf(temp,"%s.data",filename); strcpy (fname,temp); /* Read from this file */ m=2.0; /* The exponent */ /*GET_INPUTS1(fname);*/ /* read in feature vectors */ for (j=0; j<n ; j++) /* Read File in row-major */ for (i=0; i<s ; i++) /* format */ X[j][i]=Data[j][i]; Random_seed=state1[run];/*randseed*/ srand48(Random_seed); for (run=0;run<TOTRUNS;run++) { //flag=1;//for testing random values if (EntireHeaps) lCount=heapCount; else lCount=c; for(i=0;i<lCount;i++) for(j=0;j<s;j++) V[i][j]=0; for(i=0;i<lCount;i++) { for(l=0;l<s;l++) { if(flag==1) { rand_index = lrand48() % n; V[i][l] = X[rand_index][l]; } else { fscanf(iniClsCen,"%f ",&V[i][l]); } }//end for } eps=0.001; stop = FALSE; /* This loop finds the final cluster center and the corresponding U values */ z = 0; while (stop == FALSE) { z++; UMAT(U,V,X); /** Update the U matrix **/ stop = FINISHED(U1,eps); CLUSTER(U,X); /** Get new cluster center **/ printf("Iteration: %d\n\n", z); } /* end while */ printf("Number of iterations: %d\n\n", z);strcpy(temp,""); sprintf(temp,"%sFCM.out",filename);if(dataDump) Output(temp); /* output the results */ }/*end for*/ if(dataDump) { ofile=fopen(temp,"a"); for (i=0; i <= mins; i++) fprintf(ofile, "Min %d of %10.3f occurred %d times\n", i, mintab[i], mincount[i]); fprintf(ofile, "Average iterations %f\n", (float)aveit/(float)TOTRUNS); fclose(ofile); } }/* end Main */ /* The GET_INPUTS1 procedure opens an input file, reads the number of input vectors, the number of features per vector, the number of clusters, and epsilon, then it reads the input values */ void GET_INPUTS1(char fname[]) //char fname[]; { /* Parameters: fname -- name of file containing input info. */ FILE *infile ;//*fopen(); //char junk[10][80]; char realfname[80]; char ch; char fileName1[80]; //int temp[10], i, j, inputs, outputs, count; int i,j; sprintf (realfname, "%s", fname); /* open input file */ if(normalize==1) strcpy(fileName1,"gtest1.data"); else strcpy(fileName1,fname); if((infile = fopen (fileName1, "r")) == NULL) printf("\n CAN'T OPEN %s\n",realfname); else { ch = 'c'; /* Discard leading comments */ while (ch != '#') fscanf (infile, "%c", &ch); for (j=0; j<n ; j++) /* Read File in row-major */ { /* format */ for (i=0; i<s ; i++) fscanf (infile, "%f", &X[j][i]); /* fscanf (infile, "%d", &temp[1]); */ /* end for */ } /* end for */ fclose(infile); /* close input file */ }/* end else */ } /* end GET_INPUTS1 */ /* The NORM function computes the norm of two vectors, x and v, of dimension s. This gives an indication of the distance between them */ float NORM( feature x, feature v) //feature x, v; { /* Parameters : x -- a local copy of an input vector v -- a local copy of a cluster center */ int i,j; /* loop variable */ double sum; /* the square root of sum is the norm; sum is the sum of the differences squared */ float mat1[s]; float mat2[s]; if (maha) { for (i=0; i<s; i++) mat1[i]=x[i]-v[i]; for(i=0;i<s;i++) { sum =0; for(j=0;j<s;j++) sum += mat1[j] * inv_cov[j][i]; mat2[i] = sum; } sum =0; for(j=0;j<s;j++) sum += mat1[j]*mat2[j]; } else { sum = 0; for(j=0;j<s;j++) sum += (x[j] - v[j])* (x[j] - v[j]); } return (float)(sqrt(sum)); } /* end NORM */ /* The UMAT procedure calculates the updated U matrix according to Bezdek's formula. Its side-effect is the update of the global array U1 */ void UMAT( matrix U,center V, objects X) /*matrix U; center V; objects X;*/ { /* Parameters: U, V, and X: same as in main program */ int i, j, k,l ;/* loop variables *///, class /* class whose cluster center //is closest to pattern k */; float d1,d2,d; float sum; int exact; for (k=0;k<n;k++) { /*printf("\n k %d ",k);*/ exact=false; for (i=0;i<lCount;i++) { sum=0; for (j=0;j<lCount;j++) { d1=NORM(X[k],V[i]); d2=NORM(X[k],V[j]); if(d2!=0) { d= d1/d2; d= d * d;/* pow(d1/d2,2.0/(m-1.0)); */ sum+=d; } else { exact = true; for(l=0;l<lCount;l++) if (l==j) U1[l][k]=1.0; else U1[l][k]=0.0; break; } } if (exact!=true) U1[i][k]=1.0/sum; } } } /* end UMAT */ /* The function FINISHED determines if a termination occurs. If not it updates U with U1, so its side-effect is the potential modification of U */ BOOLEAN FINISHED( matrix U1,float eps) //matrix U1; float eps; { /* Parameters: U1, eps-- same as in main */ float sum; /* sum of squared differences between corresponding elements of U and U1 */ int i,k; /* loop control variabes */ BOOLEAN finished; /* set to true if all corresponding elements are within epsilon */ finished = TRUE; sum = 0; for (i=0; i<lCount; i++) for (k=0; k<n; k++) sum += (U[i][k] - U1[i][k])*(U[i][k]-U1[i][k]); if (sqrt(sum) > eps) { finished = FALSE; for (i=0; i<lCount; i++) for (k=0; k<n; k++) U[i][k] = U1[i][k]; } /* end if */ return finished; } /* end FINISHED */ /* The CLUSTER procedure determines cluster centers in V for the c classes being searched for. The global array V is updated */ void CLUSTER( matrix U, objects X) //matrix U; objects X; { /* Parameters: U, X -- as in main */ int i, j, k; /* loop control variables */ feature num; /* numerator in the cluster center computation formula presented by Bezdek */ float denum; /* denumenator in the obove formula */ for (i=0; i<lCount; i++) { denum = 0; for (j=0; j<s; j++) { num[j] = 0; for (k=0; k<n; k++) num[j] += U[i][k] * U[i][k] * X[k][j]; /* pow(U[i][k],m) * X[k][j]; */ } /* end for */ for (k=0; k<n; k++) denum += U[i][k] * U[i][k]; /* pow(U[i][k],m); */ for (j=0; j<s; j++) V[i][j] = num[j] / denum; } /* end for */ } /* end CLUSTER */ float Compute_Jm(center V, objects X) //center V; //objects X; { int i, k,found; double Jm_value; float u,dik; Jm_value = 0; for (k=0; k<n; k++) { found = FALSE; for (i=0; i<lCount; i++) { dik=NORM(X[k],V[i]); dik=dik*dik; if (dik==0.0) { if (found == FALSE) { u=1.0; found = TRUE; printf("found the case with dik=0\n"); } else { printf("\n cant proceed with this initialization"); exit(1); } } else { if (found != TRUE) u=U1[i][k]; /* get_Uvalue(V,X,dik,k); */ else u=0.0; } Jm_value += u * u * dik;/* pow(u, m) * dik; */ } } return (Jm_value); } /* end Compute_Jm */ /* The Output procedure outputs the U matrix which gives the fuzzy measure of each feature belonging to a cluster center. It also outputs the cluster center for each class */ void Output(char fname[]) //char fname[80]; /* Parameters: U, V -- same as in main */ { int i, j, found; /* loop control variables */ float J2c; if ((fp=fopen(fname,"a"))==NULL) printf("\n CAN'T OPEN %s\n",fname); else { fprintf(fp,"\n The cluster centers are: \n"); fprintf(fp,"\n \n"); for (i=0; i<lCount; i++) { fprintf(fp,"\nCluster center %d: ",i+1); fprintf(fp,"\n"); for (j=0; j<s; j++) fprintf(fp,"%8.7f ",V[i][j]); } /* end for */ fprintf(fp,"\nThe membership grades for the feature vectors are:\n"); for (j=0; j<n; j++) { fprintf(fp,"\n"); for (i=0; i<lCount; i++) fprintf(fp," %8.7f",U[i][j]); } /* end for */ } /* end if */ J2c= Compute_Jm(V,X); found =0; for (i=0;i<= mins; i++){ if ((found == 0) && ((J2c - mintab[i]) < .001) && ((J2c - mintab[i]) > -.001)){ mincount[i]++; found = 1; } } if (found == 0){ mins++; mintab[mins]=J2c; mincount[mins]=1; } fprintf(fp,"\nJ%3.1f = %f", m,J2c); fprintf(fp, "Number of iterations: %d\n\n", z); aveit=aveit + z; fclose(fp); } /***************************************************************/ void find_covar(int m) //int m; { int i,j,k; float mean[s],sum; for (i=0;i<s;i++) mean[i]=0; for (i=0;i<s;i++) for (j=0;j<m;j++) mean[i]+=X[j][i]; for (i=0;i<s;i++) mean[i]/=m; for (i=0;i<s;i++) for (j=0;j<s;j++) { sum=0; for (k=0;k<m;k++) sum+=(X[k][i]-mean[i])*(X[k][j]-mean[j]); Y[i][j]=sum/m; } }
Parag Kanade/Partition with centroids/FCM/british.c
#include "header.h"/***************************************************************************//* Function to read the input data set *//* The input data is in filename.data *//* Status: under developement *//* Output: Data from the file into the "data" (Global) data structure *//* Output: Count (Global), the count of the number of objects *//***************************************************************************/void readInput() { FILE *fp; char fname[80]; int i=0,j=0; char ch; sprintf(fname,"%s.data",filename); /* Check if the input file is opened */ if((fp=fopen(fname,"r"))==NULL) { printf("\n Unable to open input file %s \n",fname); exit(0); } /*initialise the minimum maximum and the scale */ for(i=0;i<features;i++) { minInput[i]=1000.0; maxInput[i]=0.0; scale[i]=0.0; } /* Discard leading comments */ ch = 'c'; while (ch != '#') fscanf (fp, "%c", &ch); i=0; /* Parse the file and populate the data structure */ while(!feof(fp)) { for(j=0;j<features;j++) { fscanf(fp,"%f ",&data[i][j]); } fscanf(fp,"\n"); for(j=0;j<features;j++) { if(data[i][j]<minInput[j]) minInput[j]=data[i][j]; if(data[i][j]>maxInput[j]) maxInput[j]=data[i][j]; } i++; } count=i; /* Normailze the feature values in between 0 and 1 */ for(j=0;j<features;j++) { if(minInput[j]!=maxInput[j]) scale[j]=1.0/(maxInput[j]-minInput[j]); else scale[j]=1.0; } for(i=0;i<count;i++) { for(j=0;j<features;j++) data[i][j]=(data[i][j]-minInput[j])*scale[j]; } fclose(fp); return; }/*end of function*//***************************************************************************//* Function to initialise the ants *//* Status: under developement *//* Output: the ant structure is modified with initial random values *//* Input : Ant structure (this is modified) *//***************************************************************************/void initializeAnts(antdata ants[antCount]){int i,j,k;/* Initialize all the ants with initial values and the rest and direction*/for(i=0;i<antCount;i++){ants[i].currPos=drand48();for(j=0;j<memory;j++){ants[i].Rm[j]=inf;for(k=0;k<antsPerFeature;k++)Rm[k][j]=inf;}ants[i].rest=1;ants[i].direction=drand48()<0.5?1:-1;}}/*end of function*//***************************************************************************//* Function that runs one epoch *//* Status: under developement *//* Output: the ant structure is modified with according to the epoch *//* Input : Ant structure (this is modified) *//***************************************************************************/void epoch(antdata ants[antCount]){int i,j;float Trest=0,Tcontinue=0,Tinc=0;float dDiff=0.0;float temp=0;dDiff=Dmax-Dmin;for(j=0;j<iterations;j++){for(i=0;i<antCount;i++){if(ants[i].rest!=0){Trest=drand48();if(Trest<Prest){ants[i].rest=0;continue;}Tcontinue=drand48();if(Tcontinue>Pcontinue)ants[i].direction=-1*ants[i].direction;Tinc=drand48();temp=ants[i].currPos+ants[i].direction*(Dmin+Tinc*dDiff);if(temp>1||temp<0)ants[i].direction=-1*ants[i].direction;ants[i].currPos+=ants[i].direction*(Dmin+Tinc*dDiff);}}}for(i=0;i<antCount;i++)ants[i].rest=1;}/*end of function*//***************************************************************************//* Function that computes Rm *//* Status: under developement *//* Output: the ant structure is modified, the worst Rm is removed *//* Input : Ant structure (this is modified) *//***************************************************************************/void computeRm(antdata ants[antCount],float data[MAXDATA][features],float newRm[antsPerFeature]){int i,j,k=0,l;float clsCenters[antsPerFeature][classes][features];float Rm=0.0,temp=0.0,Dik=0;for(k=0;k<antsPerFeature;k++)for(j=0;j<features;j++)for(i=0;i<classes;i++){clsCenters[k][i][j]=ants[k*classes*features+j*classes+i].currPos;}for(k=0;k<antsPerFeature;k++){Rm=0;for(i=0;i<count;i++){Dik=0;for(j=0;j<classes;j++){temp=0;for(l=0;l<features;l++)temp+=(data[i][l]-clsCenters[k][j][l])*(data[i][l]-clsCenters[k][j][l]);/*temp=sqrt(temp);*/Dik+=pow(temp,1.0/(1-m));}Rm+=pow(Dik,(1-m));}newRm[k]=Rm;}return;}/*end of function*//********************************************************************//* Function to read the original classification of objects *//* Output: none *//* Input: none *//* Global Structure Modified: OrgData *//********************************************************************/void readOrg(){int i=0,k=0;char temp[80];FILE *fp;strcpy(temp,"");sprintf(temp,"%sFull.data",filename);fp=fopen(temp,"r");if(fp==NULL){printf("\n Unable to open %s file\n",temp);exit(-1);}for(i=0;i<count;i++){fscanf(fp,"%f ",&orgData[i][0]);for(k=1;k<features+1;k++)fscanf(fp,"%f ",&orgData[i][k]);}return;}/*end of function*//********************************************************************//* Function to update the memory of the ants *//* Output: none *//* Input: ant structure and the new Rm, old memory *//* Global Structure Modified: none *//********************************************************************/void updateMemory(antdata ants[antCount],float newRm[antsPerFeature],float Rm[antsPerFeature][memory]){int i,minPosition[antsPerFeature],maxPosition[antsPerFeature],flag[antsPerFeature],k,j,b[memory],infCount=0;float temp=0,tempRm[memory],tChoose=0;for(i=0;i<antsPerFeature;i++){minPosition[i]=0;maxPosition[i]=0;flag[i]=1;}for(k=0;k<antsPerFeature;k++){b[0]=0;for(i=1;i<memory;i++){if(Rm[k][i]<Rm[k][minPosition[k]])minPosition[k]=i;if(Rm[k][i]>Rm[k][maxPosition[k]])maxPosition[k]=i;if(Rm[k][i]==newRm[k]){flag[k]=0;break;}temp=(newRm[k]-Rm[k][i])*1.0/Rm[k][i];if(temp<0) temp=-1*temp;if(temp<minChange){flag[k]=0;break;}b[i]=i;}if(flag[k]==1){if(newRm[k]<Rm[k][maxPosition[k]]){for(j=0;j<features;j++)for(i=0;i<classes;i++){ants[k*classes*features+j*classes+i].Rm[maxPosition[k]]=ants[k*classes*features+j*classes+i].currPos;}Rm[k][maxPosition[k]]=newRm[k];}else{/* find min Rm and restore its position*/infCount=0;for(i=0;i<memory;i++){tempRm[i]=Rm[k][i];if(Rm[k][i]==inf) infCount++;}for(i=0;i<memory;i++)for(j=0;j<memory-1-i;j++){if(tempRm[j]>tempRm[j+1]){temp=tempRm[j];tempRm[j]=tempRm[j+1];tempRm[j+1]=temp;temp=b[j];b[j]=b[j+1];b[j+1]=temp;}}tChoose=drand48();if(tChoose<0.6){minPosition[k]=b[0];}else if (tChoose<0.8){minPosition[k]=b[1];}else if(tChoose<0.9){minPosition[k]=b[2];}else if(tChoose<0.975){minPosition[k]=b[3];}else {minPosition[k]=b[4];}if(Rm[k][minPosition[k]]!=inf)for(j=0;j<features;j++)for(i=0;i<classes;i++){ants[k*classes*features+j*classes+i].currPos=ants[k*classes*features+j*classes+i].Rm[minPosition[k]];}}}}}/* end of function *//********************************************************************//* Function to cluster according to the cluster centroids *//* Output: none *//* Input: ant structure and the data points *//* Global Structure Modified: none *//********************************************************************/void finalCluster(antdata ants[antCount],float data[MAXDATA][features],float Rm[antsPerFeature][memory]){int i,j,position[MAXDATA],minPosition=0,k=0,l=0,minRm=0;float clsCenters[antsPerFeature][classes][features];float distance[classes];int cenCount[classes],classCount[classes][classes];float temp=0;int clsObjects[classes][MAXDATA],label[classes];int minPosition1[antsPerFeature],maxPosition1[antsPerFeature];FILE *fp,*fpOut,*fpCls,*fpMinRm,*fpOrgClass,*fpRm;fp=fopen("fcm.out","a");fpOut=fopen("ClassData.out","a");fpCls=fopen("clsCenters.out","a");fpMinRm=fopen("minRm.out","a");fpOrgClass=fopen("orgClass.out","a");fpRm=fopen("Rm.out","a");if(fp==NULL){printf("\n Unable to open fcm output file \n");return;}for(k=0;k<antsPerFeature;k++){for(j=0;j<features;j++)for(i=0;i<classes;i++)clsCenters[k][i][j]=ants[k*classes*features+j*classes+i].currPos;minPosition1[k]=0;maxPosition1[k]=0;}for(k=0;k<antsPerFeature;k++){for(i=1;i<memory;i++){if(Rm[l][i]<Rm[l][minPosition1[l]])minPosition1[l]=i;if(Rm[l][i]>Rm[l][maxPosition1[l]])maxPosition1[l]=i;}}minRm=0;for(k=1;k<antsPerFeature;k++){if(Rm[k][minPosition1[k]]<Rm[minRm][minPosition1[minRm]])minRm=k;}fprintf(fpRm,"Rm %8.4f\n",Rm[minRm][minPosition1[minRm]]);fclose(fpRm);Fcm(clsCenters[minRm],data);for(l=0;l<antsPerFeature;l++){fprintf(fpCls,"Cluster number %2d\n",l);for(j=0;j<classes;j++){distance[j]=inf;cenCount[j]=0;for(k=0;k<classes;k++)classCount[j][k]=0;}fprintf(fp,"* %d\n",l);if(l==minRm)fprintf(fpMinRm,"* %d\n",l);for(i=0;i<count;i++){minPosition=0;for(k=0;k<classes;k++){temp=0.0;for(j=0;j<features;j++)temp+= (clsCenters[l][k][j]-data[i][j])*(clsCenters[l][k][j]-data[i][j]);temp=sqrt(temp);distance[k]=temp;if(distance[k]<distance[minPosition])minPosition=k;}position[i]=minPosition;clsObjects[minPosition][cenCount[minPosition]]=i;cenCount[minPosition]++;}for(j=0;j<classes;j++){for(i=0;i<cenCount[j];i++)classCount[j][(int)orgData[clsObjects[j][i]][0]-1]++;}/* minPosition varaible re used , now minPosition denotes the maximum class of the cluster*/fprintf(fpOrgClass,"\nCluster number: %2d \n",l);for(j=0;j<classes;j++){minPosition=0;fprintf(fpOrgClass,"\n Cluster %2d \n",j+1);fprintf(fpOrgClass,"%2d %2d\n",1,classCount[j][0]);for(i=1;i<classes;i++){if(classCount[j][i]>classCount[j][minPosition]) minPosition=i;label[j]=minPosition;fprintf(fpOrgClass,"%2d %2d\n",i+1,classCount[j][i]);}}for(i=0;i<count;i++){for(j=0;j<classes;j++)for(k=0;k<cenCount[j];k++)if(clsObjects[j][k]==i){fprintf(fp,"%d ",label[j]+1);break;}}fprintf(fp,"\n");fprintf(fpOut,"\nCluster number: %2d \n",l);for(i=0;i<classes;i++){fprintf(fpOut,"%2d %4d\n",label[i]+1,cenCount[i]);for(j=0;j<features;j++)fprintf(fpCls,"%8.7f ",clsCenters[l][i][j]/scale[j]+minInput[j]);fprintf(fpCls,"\n");}}/* Write the data to the file */fclose(fp);fclose(fpOut);fclose(fpCls);fclose(fpMinRm);fclose(fpOrgClass);}/* end of function *//********************************************************************//* Function to amnalyze the results *//* Output: none *//* Input: *//* Global Structure Modified: none *//********************************************************************/void analysis(){int i,j,k,temp;char junk;int totalRuns=0,errors[antsPerFeature],epoch=0,position=0,antsperfeature=0,clsNumber=0,min=0,currMinRm;FILE *fp,*fpError,*fpMin,*fpMinRm,*fpMinIp;fp=fopen("fcm.out","r");fpMinIp=fopen("minRm.out","r");fpMinRm=fopen("minRmError.out","w");fpError=fopen("error.out","w");fpMin=fopen("minError.out","w");if(fp==NULL||fpError==NULL){printf("\n unable to open files in the analysis module \n");return;}fscanf(fp,"%c %d\n",&junk,&totalRuns);fscanf(fp,"%c %d\n",&junk,&antsperfeature);fscanf(fpMinIp,"%c %d\n",&junk,&temp);fscanf(fpMinIp,"%c %d\n",&junk,&temp);for(i=0;i<totalRuns;i++){for(j=0;j<antsPerFeature;j++){errors[j]=0;}fscanf(fp,"%c %d\n",&junk,&epoch);fscanf(fpMinIp,"%c %d\n",&junk,&temp);fscanf(fpMinIp,"%c %d\n",&junk,&currMinRm);fprintf(fpError,"Experiment %3d \n",i);for(k=0;k<antsperfeature;k++){fscanf(fp,"%c %d\n",&junk,&clsNumber);for(j=0;j<count;j++){fscanf(fp,"%d ",&position);if(orgData[j][0]!=position)errors[k]++;}fscanf(fp,"\n");fprintf(fpError,"Cluster %3d Errors %5d \n",k,errors[k]);if(k==currMinRm){fprintf(fpMinRm,"Cluster %2d Errors %5d\n",k,errors[k]);}}min=0;for(j=1;j<antsPerFeature;j++){if(errors[j]<errors[min])min=j;}fprintf(fpMin,"Exp %2d Min Error %5d\n",i,errors[min]);}fclose(fp);fclose(fpError);fclose(fpMin);fclose(fpMinRm);fclose(fpMinIp);}/* end of function */int main(){int k=0,i=0,flag[antsPerFeature],j=0,flg;float newRm[antsPerFeature],oldRm[antsPerFeature],temp;FILE *fp=fopen("fcm.out","w");FILE *fpOut=fopen("ClassData.out","w");FILE *fpCls=fopen("clsCenters.out","w");FILE *fpMinRm=fopen("minRm.out","w");FILE *fpOrgClass=fopen("orgClass.out","w");FILE *fpRm=fopen("Rm.out","w");FILE *fpJm=fopen("Jm.out","w");fclose(fpJm);fprintf(fp,"# %d\n",EXPRUN);fprintf(fp,"@ %d\n",antsPerFeature);fclose(fp);fprintf(fpMinRm,"# %d\n",EXPRUN);fprintf(fpMinRm,"@ %d\n",antsPerFeature);fclose(fpMinRm);fclose(fpOut);fclose(fpCls);fclose(fpOrgClass);fclose(fpRm);readInput();/*readOrg();*/for(k=0;k<EXPRUN;k++){srand48(state1[k]);fp=fopen("fcm.out","a");fpOut=fopen("ClassData.out","a");fpCls=fopen("clsCenters.out","a");fpOrgClass=fopen("orgClass.out","a");fpMinRm=fopen("minRm.out","a");fpRm=fopen("Rm.out","a");fprintf(fpRm,"Exp: %2d ",k);fclose(fpRm);fprintf(fpCls,"EXP No %2d \n",k);fclose(fpCls);fprintf(fp,"$ %d\n",k);fprintf(fpMinRm,"$ %d\n",k);fprintf(fpOut,"Experiment %d\n",k);fprintf(fpOrgClass,"Experiment %d\n",k);fclose(fp);fclose(fpOut);fclose(fpMinRm);fclose(fpOrgClass);initializeAnts(ants);for(i=0;i<antsPerFeature;i++){oldRm[i]=inf;newRm[i]=inf;}flg=1;i=0;while(i<maxEpocs){epoch(ants);for(j=0;j<antsPerFeature;j++){oldRm[j]=newRm[j];flag[j]=1;}computeRm(ants,data,newRm);updateMemory(ants,newRm,Rm);flg=0;for(j=0;j<antsPerFeature;j++){if(newRm[j]!=inf){if(oldRm[j]!=inf){temp=0;temp=newRm[j]-oldRm[j]<0? (oldRm[j]-newRm[j]):(newRm[j]-oldRm[j]);/*printf("\n new %f old %f temp %f ",newRm[j],oldRm[j],temp);*/if(temp/oldRm[j]>minChange){flg=1;break;}}else flg=1;}}i++;printf("\nExp %d Epoch %d ",k,i);}/* Do the final clustering*/finalCluster(ants,data,Rm);/* Compute the error */}/* end for*//*analysis();*/printf("\n");return 0;}/* End of main */ void Fcm (center V,objects X) { int i; FILE *ofile; char temp[80]; Random_seed=state1[run];/*randseed*/ srand48(Random_seed); for (run=0;run<TOTRUNS;run++) { eps=0.001; stop = FALSE; /* This loop finds the final cluster center and the corresponding U values */ z = 0; while (stop == FALSE) { z++; UMAT(U,V,X); /** Update the U matrix **/stop = FINISHED(U1,eps); CLUSTER(U,X,V); /** Get new cluster center **/printf("\nIteration: %d \n",z); } /* end while */ printf("Number of iterations: %d\n\n", z);strcpy(temp,""); sprintf(temp,"%sFCM.out",filename); Output(temp,V,X); /* output the results */ }/*end for*/ ofile=fopen(temp,"a"); for (i=0; i <= mins; i++) fprintf(ofile, "Min %d of %10.3f occurred %d times\n", i, mintab[i], mincount[i]); fprintf(ofile, "Average iterations %f\n", (float)aveit/(float)TOTRUNS); fclose(ofile); }/* end Main */ /* The NORM function computes the norm of two vectors, x and v, of dimension s. This gives an indication of the distance between them */ float NORM( feature x, feature v) //feature x, v; { /* Parameters : x -- a local copy of an input vector v -- a local copy of a cluster center */ int i,j; /* loop variable */ double sum; /* the square root of sum is the norm; sum is the sum of the differences squared */ float mat1[features]; float mat2[features]; if (maha) { for (i=0; i<features; i++) mat1[i]=x[i]-v[i]; for(i=0;i<features;i++) { sum =0; for(j=0;j<features;j++) sum += mat1[j] * inv_cov[j][i]; mat2[i] = sum; } sum =0; for(j=0;j<features;j++) sum += mat1[j]*mat2[j]; } else { sum = 0; for(j=0;j<features;j++) sum += (x[j] - v[j])* (x[j] - v[j]); } return (float)(sqrt(sum)); } /* end NORM */ /* The UMAT procedure calculates the updated U matrix according to Bezdek's formula. Its side-effect is the update of the global array U1 */ void UMAT( matrix U,center V, objects X) /*matrix U; center V; objects X;*/ { /* Parameters: U, V, and X: same as in main program */ int i, j, k,l ;/* loop variables *///, class /* class whose cluster center //is closest to pattern k */; float d1,d2,d; float sum; int exact; for (k=0;k<MAXDATA;k++) { /*printf("\n k %d ",k);*/ exact=false; for (i=0;i<classes;i++) { sum=0; for (j=0;j<classes;j++) { d1=NORM(X[k],V[i]); d2=NORM(X[k],V[j]); if(d2!=0) { d= d1/d2; d= d * d;/* pow(d1/d2,2.0/(m-1.0)); */ sum+=d; } else { exact = true; for(l=0;l<classes;l++) if (l==j) U1[l][k]=1.0; else U1[l][k]=0.0; break; } } if (exact!=true) U1[i][k]=1.0/sum; } } } /* end UMAT */ /* The function FINISHED determines if a termination occurs. If not it updates U with U1, so its side-effect is the potential modification of U */ BOOLEAN FINISHED( matrix U1,float eps) //matrix U1; float eps; { /* Parameters: U1, eps-- same as in main */ float sum; /* sum of squared differences between corresponding elements of U and U1 */ int i,k; /* loop control variabes */ BOOLEAN finished; /* set to true if all corresponding elements are within epsilon */ finished = TRUE; sum = 0; for (i=0; i<classes; i++) for (k=0; k<MAXDATA; k++) sum += (U[i][k] - U1[i][k])*(U[i][k]-U1[i][k]); if (sqrt(sum) > eps) { finished = FALSE; for (i=0; i<classes; i++) for (k=0; k<MAXDATA; k++) U[i][k] = U1[i][k]; } /* end if */ return finished; } /* end FINISHED */ /* The CLUSTER procedure determines cluster centers in V for the c classes being searched for. The global array V is updated */ void CLUSTER( matrix U, objects X,center V) //matrix U; objects X; { /* Parameters: U, X -- as in main */ int i, j, k; /* loop control variables */ feature num; /* numerator in the cluster center computation formula presented by Bezdek */ float denum; /* denumenator in the obove formula */ for (i=0; i<classes; i++) { denum = 0; for (j=0; j<features; j++) { num[j] = 0; for (k=0; k<MAXDATA; k++) num[j] += U[i][k] * U[i][k] * X[k][j]; /* pow(U[i][k],m) * X[k][j]; */ } /* end for */ for (k=0; k<MAXDATA; k++) denum += U[i][k] * U[i][k]; /* pow(U[i][k],m); */ for (j=0; j<features; j++) V[i][j] = num[j] / denum; } /* end for */ } /* end CLUSTER */ float Compute_Jm(center V, objects X) //center V; //objects X; { int i, k,found; double Jm_value; float u,dik; Jm_value = 0; for (k=0; k<MAXDATA; k++) { found = FALSE; for (i=0; i<classes; i++) { dik=NORM(X[k],V[i]); dik=dik*dik; if (dik==0.0) { if (found == FALSE) { u=1.0; found = TRUE; printf("found the case with dik=0\n"); } else { printf("\n cant proceed with this initialization"); exit(1); } } else { if (found != TRUE) u=U1[i][k]; /* get_Uvalue(V,X,dik,k); */ else u=0.0; } Jm_value += u * u * dik;/* pow(u, m) * dik; */ } } return (Jm_value); } /* end Compute_Jm */ /* The Output procedure outputs the U matrix which gives the fuzzy measure of each feature belonging to a cluster center. It also outputs the cluster center for each class */ void Output(char fname[],center V,objects X) //char fname[80]; /* Parameters: U, V -- same as in main */ { int i, j, found; /* loop control variables */ float J2c,R2c; FILE *fpJm=fopen("Jm.out","a"); if ((fp=fopen(fname,"a"))==NULL) printf("\n CAN'T OPEN %s\n",fname); else { fprintf(fp,"\n \n"); for (i=0; i<classes; i++) { fprintf(fp,"\n"); for (j=0; j<features; j++) fprintf(fp,"%4.3f ",V[i][j]); } /* end for */ } /* end if */ J2c= Compute_Jm(V,X); R2c=Compute_Rm(V,X); fprintf(fpJm,"Jm: %10.6f Rm: %10.6f \n",J2c,R2c); found =0; for (i=0;i<= mins; i++) { if ((found == 0) && ((J2c - mintab[i]) < .001) && ((J2c - mintab[i]) > -.001)){ mincount[i]++; found = 1; } } if (found == 0) { mins++; mintab[mins]=J2c; mincount[mins]=1; } fprintf(fp,"\nJ%2d = %f", m,J2c); fprintf(fp, "Number of iterations: %d\n\n", z); aveit=aveit + z; fclose(fp); fclose(fpJm); } /***************************************************************/ void find_covar( ) { int i,j,k; float mean[features],sum; for (i=0;i<features;i++) mean[i]=0; for (i=0;i<features;i++) for (j=0;j<m;j++) mean[i]+=X[j][i]; for (i=0;i<features;i++) mean[i]/=m; for (i=0;i<features;i++) for (j=0;j<features;j++) { sum=0; for (k=0;k<m;k++) sum+=(X[k][i]-mean[i])*(X[k][j]-mean[j]); Y[i][j]=sum/m; } }float Compute_Rm(center V, objects X){int i=0,j=0,l;float Dik=0,temp=0,Rm=0;Rm=0;for(i=0;i<MAXDATA;i++){Dik=0;for(j=0;j<classes;j++){temp=0;for(l=0;l<features;l++)temp+=(X[i][l]-V[j][l])*(X[i][l]-V[j][l]);/*temp=sqrt(temp);*/Dik+=pow(temp,1.0/(1-m));}Rm+=pow(Dik,(1-m));}return(Rm);}/* End of function */
Parag Kanade/Partition with centroids/FCM/header.h
/********************************************************************//* Ant Class parameters *//* Prest: Probability that the ant rests for this epoch *//* Pcontinue:Probability that the ant continues in the current *//* direction *//* *//********************************************************************/ #include <stdio.h>#include <math.h>#include <string.h>#include <stdlib.h>#include <ctype.h>#include <time.h>#define Prest 0.01#define Pcontinue 0.75#define Dmin 0.00001#define Dmax 0.0001#define MAXDATA 50#define classes 5#define features 4#define filename "british"#define iterations 50#define memory 5#define antsPerFeature 30#define antCount antsPerFeature*features*classes#define inf 10e100#define m 2#define TRUE 1#define maxEpocs 1000#define EXPRUN 50#define minChange 0.00075#define maha 0#define FALSE 0#define true 1#define false 0#define TOTRUNS 1 /* number of V's to write out */typedef struct a{float Rm[memory];int rest;int direction;float currPos;}antdata;typedef struct HeapInfo{int total;int classObj[MAXDATA];} heapInfo;typedef int BOOLEAN;typedef float feature[features]; /* Type of each input; made up of input features */typedef float irisData[features];typedef feature objects[MAXDATA]; /* Type of array holding all inputs */typedef feature center[MAXDATA]; /* Type of array holding cluster centers */typedef float matrix[MAXDATA][MAXDATA];/* Type of the matrix containing membership grades */antdata ants[antCount]; /* Ants */float data[MAXDATA][features]; /* Normailzed input data points */ float minInput[features]; /* Minimum value for all features */float maxInput[features]; /* Maximum value for all features */float scale[features]; /* Scale value for all features */int count; /* Number of data points */float orgData[MAXDATA][features+1];/* Original Data */float Rm[antsPerFeature][memory];long state1[52] = { 9347, 3835, 5194, 8310, 346, 535, 5297, 6711, 77, 3834, 668, 4175, 6868, 5890, 9304, 8462, 5269, 920, 65392, 41600, 70119, 91032, 76220, 26245, 4746, 73608, 32823, 63264, 75641, 99104, 36534, 24704, 98255, 72266, 75336, 65152, 7269, 63163, 88471, 27271, 43641, 76649, 47773, 23777, 27491, 35926, 16651, 48652, 89766, 90921, 6056 }; matrix U, U1; float inv_cov[features+1][features+1]; int temp[200]; /* for square matrix tests */ float eps; BOOLEAN stop; center V; objects X; char fname[80]; FILE *fp; int run; float Y[features][features]; long rand_index, Random_seed; int z; int mins=0; int aveit =0; float mintab[200]; int mincount[200]; long start,end,total; void readInput();void initializeAnts(antdata ants[antCount]);void epoch(antdata ants[antCount]);void computeRm(antdata ants[antCount],float data[MAXDATA][features],float newRm[antsPerFeature]);void updateMemory(antdata ants[antCount],float newRm[antsPerFeature], float Rm[antsPerFeature][memory]);void analysis();void GET_INPUTS1(char []);void UMAT( matrix,center,objects);BOOLEAN FINISHED(matrix, float);void CLUSTER( matrix, objects,center);void Output(char[],center V,objects X);void Fcm(center V,objects X);float Compute_Jm(center V, objects X);float Compute_Rm(center V, objects X);
Parag Kanade/Partition with centroids/HCM/header.h
/********************************************************************//* Ant Class parameters *//* Prest: Probability that the ant rests for this epoch *//* Pcontinue:Probability that the ant continues in the current *//* direction *//* *//********************************************************************/ #include <stdio.h>#include <math.h>#include <string.h>#include <stdlib.h>#include <ctype.h>#include <time.h>#define Prest 0.01#define Pcontinue 0.75#define tContinueCurr 0.2#define Dmin 0.00001#define Dmax 0.0001#define MAXDATA 50#define classes 5#define features 4#define filename "british"#define iterations 50#define memory 5#define antsPerFeature 75#define antCount antsPerFeature*features*classes#define inf 10e100#define m 2#define TRUE 1#define maxEpocs 2000#define EXPRUN 50#define minChange 0.00075#define maha 0#define FALSE 0#define true 1#define false 0#define TOTRUNS 1 /* number of V's to write out */typedef struct a{float Rm[memory];int rest;int direction;float currPos;}antdata;typedef struct HeapInfo{int total;int classObj[MAXDATA];} heapInfo;typedef int BOOLEAN;typedef float feature[features]; /* Type of each input; made up of input features */typedef float irisData[features];typedef feature objects[MAXDATA]; /* Type of array holding all inputs */typedef feature center[MAXDATA]; /* Type of array holding cluster centers */typedef float matrix[MAXDATA][MAXDATA];/* Type of the matrix containing membership grades */antdata ants[antCount]; /* Ants */float data[MAXDATA][features]; /* Normailzed input data points */ float minInput[features]; /* Minimum value for all features */float maxInput[features]; /* Maximum value for all features */float scale[features]; /* Scale value for all features */int count; /* Number of data points */float orgData[MAXDATA][features+1];/* Original Data */float Rm[antsPerFeature][memory];long state1[52] = { 9347, 3835, 5194, 8310, 346, 535, 5297, 6711, 77, 3834, 668, 4175, 6868, 5890, 9304, 8462, 5269, 920, 65392, 41600, 70119, 91032, 76220, 26245, 4746, 73608, 32823, 63264, 75641, 99104, 36534, 24704, 98255, 72266, 75336, 65152, 7269, 63163, 88471, 27271, 43641, 76649, 47773, 23777, 27491, 35926, 16651, 48652, 89766, 90921, 6056 }; matrix U, U1; float inv_cov[features+1][features+1]; int degenerate[classes]; int temp[200]; /* for square matrix tests */ float eps; BOOLEAN stop; center V; objects X; char fname[80]; FILE *fp; int run; float Y[features][features]; long rand_index, Random_seed; int z; int mins=0; int aveit =0; float mintab[200]; int mincount[200]; long start,end,total; void readInput();void initializeAnts(antdata ants[antCount]);void epoch(antdata ants[antCount]);void computeRm(antdata ants[antCount],float data[MAXDATA][features],float newRm[antsPerFeature]);void updateMemory(antdata ants[antCount],float newRm[antsPerFeature], float Rm[antsPerFeature][memory]);void analysis();void GET_INPUTS1(char []);void UMAT( matrix,center,objects);BOOLEAN FINISHED(matrix, float);void CLUSTER( matrix, objects,center);void Output(char[],center V,objects X);void Fcm(center V,objects X);float Compute_Jm(center V, objects X);float Compute_Rm(center V, objects X);void harden();int findPosition(int i);
Parag Kanade/Partition with centroids/HCM/british.c
#include "header.h"/***************************************************************************//* Function to read the input data set *//* The input data is in filename.data *//* Status: under developement *//* Output: Data from the file into the "data" (Global) data structure *//* Output: Count (Global), the count of the number of objects *//***************************************************************************/void readInput() { FILE *fp; char fname[80]; int i=0,j=0; char ch; sprintf(fname,"%s.data",filename); /* Check if the input file is opened */ if((fp=fopen(fname,"r"))==NULL) { printf("\n Unable to open input file %s \n",fname); exit(0); } /*initialise the minimum maximum and the scale */ for(i=0;i<features;i++) { minInput[i]=1000.0; maxInput[i]=0.0; scale[i]=0.0; } /* Discard leading comments */ ch = 'c'; while (ch != '#') fscanf (fp, "%c", &ch); i=0; /* Parse the file and populate the data structure */ while(!feof(fp)) { for(j=0;j<features;j++) { fscanf(fp,"%f ",&data[i][j]); } fscanf(fp,"\n"); for(j=0;j<features;j++) { if(data[i][j]<minInput[j]) minInput[j]=data[i][j]; if(data[i][j]>maxInput[j]) maxInput[j]=data[i][j]; } i++; } count=i; /* Normailze the feature values in between 0 and 1 */ for(j=0;j<features;j++) { if(minInput[j]!=maxInput[j]) scale[j]=1.0/(maxInput[j]-minInput[j]); else scale[j]=1.0; } for(i=0;i<count;i++) { for(j=0;j<features;j++) data[i][j]=(data[i][j]-minInput[j])*scale[j]; } fclose(fp); return; }/*end of function*//***************************************************************************//* Function to initialise the ants *//* Status: under developement *//* Output: the ant structure is modified with initial random values *//* Input : Ant structure (this is modified) *//***************************************************************************/void initializeAnts(antdata ants[antCount]){int i,j,k;/* Initialize all the ants with initial values and the rest and direction*/for(i=0;i<antCount;i++){ants[i].currPos=drand48();for(j=0;j<memory;j++){ants[i].Rm[j]=inf;for(k=0;k<antsPerFeature;k++)Rm[k][j]=inf;}ants[i].rest=1;ants[i].direction=drand48()<0.5?1:-1;}}/*end of function*//***************************************************************************//* Function that runs one epoch *//* Status: under developement *//* Output: the ant structure is modified with according to the epoch *//* Input : Ant structure (this is modified) *//***************************************************************************/void epoch(antdata ants[antCount]){int i,j;float Trest=0,Tcontinue=0,Tinc=0;float dDiff=0.0;float temp=0;dDiff=Dmax-Dmin;for(j=0;j<iterations;j++){for(i=0;i<antCount;i++){if(ants[i].rest!=0){Trest=drand48();if(Trest<Prest){ants[i].rest=0;continue;}Tcontinue=drand48();if(Tcontinue>Pcontinue)ants[i].direction=-1*ants[i].direction;Tinc=drand48();temp=ants[i].currPos+ants[i].direction*(Dmin+Tinc*dDiff);if(temp>1||temp<0)ants[i].direction=-1*ants[i].direction;ants[i].currPos+=ants[i].direction*(Dmin+Tinc*dDiff);}}}for(i=0;i<antCount;i++)ants[i].rest=1;}/*end of function*//***************************************************************************//* Function that computes Rm *//* Status: under developement *//* Output: the ant structure is modified, the worst Rm is removed *//* Input : Ant structure (this is modified) *//***************************************************************************/void computeRm(antdata ants[antCount],float data[MAXDATA][features],float newRm[antsPerFeature]){int i,j,k=0,l=0,minPos=0;float clsCenters[antsPerFeature][classes][features];double Rm=0.0,temp=0.0,Dik=0,min=0;for(k=0;k<antsPerFeature;k++)for(j=0;j<features;j++)for(i=0;i<classes;i++){clsCenters[k][i][j]=ants[k*classes*features+j*classes+i].currPos;}for(k=0;k<antsPerFeature;k++){Rm=0;for(i=0;i<count;i++){Dik=0;min=10e10;minPos=0;for(j=0;j<classes;j++){temp=0;for(l=0;l<features;l++)temp+=(data[i][l]-clsCenters[k][j][l])*(data[i][l]-clsCenters[k][j][l]);if(temp<min){min=temp;minPos=j;}}Rm+=min;}newRm[k]=Rm;}return;}/*end of function*//********************************************************************//* Function to read the original classification of objects *//* Output: none *//* Input: none *//* Global Structure Modified: OrgData *//********************************************************************/void readOrg(){int i=0,k=0;char temp[80];FILE *fp;strcpy(temp,"");sprintf(temp,"%sFull.data",filename);fp=fopen(temp,"r");if(fp==NULL){printf("\n Unable to open %s file\n",temp);exit(-1);}for(i=0;i<count;i++){fscanf(fp,"%f ",&orgData[i][0]);for(k=1;k<features+1;k++)fscanf(fp,"%f ",&orgData[i][k]);}return;}/*end of function*//********************************************************************//* Function to update the memory of the ants *//* Output: none *//* Input: ant structure and the new Rm, old memory *//* Global Structure Modified: none *//********************************************************************/void updateMemory(antdata ants[antCount],float newRm[antsPerFeature],float Rm[antsPerFeature][memory]){int i,minPosition[antsPerFeature],maxPosition[antsPerFeature],flag[antsPerFeature],k,j,b[memory],infCount=0;float temp=0,tempRm[memory],tChoose=0,pContinueCurr=0;for(i=0;i<antsPerFeature;i++){minPosition[i]=0;maxPosition[i]=0;flag[i]=1;}for(k=0;k<antsPerFeature;k++){b[0]=0;for(i=1;i<memory;i++){if(Rm[k][i]<Rm[k][minPosition[k]])minPosition[k]=i;if(Rm[k][i]>Rm[k][maxPosition[k]])maxPosition[k]=i;if(Rm[k][i]==newRm[k]){flag[k]=0;break;}temp=(newRm[k]-Rm[k][i])*1.0/Rm[k][i];if(temp<0) temp=-1*temp;if(temp<minChange){flag[k]=0;break;}b[i]=i;}if(flag[k]==1){if(newRm[k]<Rm[k][maxPosition[k]]){for(j=0;j<features;j++)for(i=0;i<classes;i++){ants[k*classes*features+j*classes+i].Rm[maxPosition[k]]=ants[k*classes*features+j*classes+i].currPos;}Rm[k][maxPosition[k]]=newRm[k];}else{/* find min Rm and restore its position*/infCount=0;for(i=0;i<memory;i++){tempRm[i]=Rm[k][i];if(Rm[k][i]==inf) infCount++;}for(i=0;i<memory;i++)for(j=0;j<memory-1-i;j++){if(tempRm[j]>tempRm[j+1]){temp=tempRm[j];tempRm[j]=tempRm[j+1];tempRm[j+1]=temp;temp=b[j];b[j]=b[j+1];b[j+1]=temp;}}tChoose=drand48();if(tChoose<0.6){minPosition[k]=b[0];}else if (tChoose<0.8){minPosition[k]=b[1];}else if(tChoose<0.9){minPosition[k]=b[2];}else if(tChoose<0.975){minPosition[k]=b[3];}else {minPosition[k]=b[4];}pContinueCurr=drand48();if(pContinueCurr<tContinueCurr){/*for(j=0;j<features;j++)for(i=0;i<classes;i++){ants[k*classes*features+j*classes+i].Rm[maxPosition[k]]=ants[k*classes*features+j*classes+i].currPos;}Rm[k][maxPosition[k]]=newRm[k];*/}else if(Rm[k][minPosition[k]]!=inf)for(j=0;j<features;j++)for(i=0;i<classes;i++){ants[k*classes*features+j*classes+i].currPos=ants[k*classes*features+j*classes+i].Rm[minPosition[k]];}}}}}/* end of function *//********************************************************************//* Function to cluster according to the cluster centroids *//* Output: none *//* Input: ant structure and the data points *//* Global Structure Modified: none *//********************************************************************/void finalCluster(antdata ants[antCount],float data[MAXDATA][features],float Rm[antsPerFeature][memory]){int i,j,position[MAXDATA],minPosition=0,k=0,l=0,minRm=0;float clsCenters[antsPerFeature][classes][features];float distance[classes];int cenCount[classes],classCount[classes][classes];float temp=0;int clsObjects[classes][MAXDATA],label[classes];int minPosition1[antsPerFeature],maxPosition1[antsPerFeature];FILE *fp,*fpOut,*fpCls,*fpMinRm,*fpOrgClass,*fpRm;fp=fopen("fcm.out","a");fpOut=fopen("ClassData.out","a");fpCls=fopen("clsCenters.out","a");fpMinRm=fopen("minRm.out","a");fpOrgClass=fopen("orgClass.out","a");fpRm=fopen("Rm.out","a");if(fp==NULL){printf("\n Unable to open fcm output file \n");return;}for(k=0;k<antsPerFeature;k++){for(j=0;j<features;j++)for(i=0;i<classes;i++)clsCenters[k][i][j]=ants[k*classes*features+j*classes+i].currPos;minPosition1[k]=0;maxPosition1[k]=0;}for(k=0;k<antsPerFeature;k++){for(i=1;i<memory;i++){if(Rm[l][i]<Rm[l][minPosition1[l]])minPosition1[l]=i;if(Rm[l][i]>Rm[l][maxPosition1[l]])maxPosition1[l]=i;}}minRm=0;for(k=1;k<antsPerFeature;k++){if(Rm[k][minPosition1[k]]<Rm[minRm][minPosition1[minRm]])minRm=k;}fprintf(fpRm,"Rm %8.4f\n",Rm[minRm][minPosition1[minRm]]);fclose(fpRm);Fcm(clsCenters[minRm],data);harden();for(l=0;l<antsPerFeature;l++){fprintf(fpCls,"Cluster number %2d\n",l);for(j=0;j<classes;j++){distance[j]=inf;cenCount[j]=0;for(k=0;k<classes;k++)classCount[j][k]=0;}fprintf(fp,"* %d\n",l);if(l==minRm)fprintf(fpMinRm,"* %d\n",l);for(i=0;i<count;i++){minPosition=0;for(k=0;k<classes;k++){temp=0.0;for(j=0;j<features;j++)temp+= (clsCenters[l][k][j]-data[i][j])*(clsCenters[l][k][j]-data[i][j]);temp=sqrt(temp);distance[k]=temp;if(distance[k]<distance[minPosition])minPosition=k;}position[i]=minPosition;clsObjects[minPosition][cenCount[minPosition]]=i;cenCount[minPosition]++;}for(j=0;j<classes;j++){for(i=0;i<cenCount[j];i++)classCount[j][(int)orgData[clsObjects[j][i]][0]-1]++;}/* minPosition varaible re used , now minPosition denotes the maximum class of the cluster*/fprintf(fpOrgClass,"\nCluster number: %2d \n",l);for(j=0;j<classes;j++){minPosition=0;fprintf(fpOrgClass,"\n Cluster %2d \n",j+1);fprintf(fpOrgClass,"%2d %2d\n",1,classCount[j][0]);for(i=1;i<classes;i++){if(classCount[j][i]>classCount[j][minPosition]) minPosition=i;label[j]=minPosition;fprintf(fpOrgClass,"%2d %2d\n",i+1,classCount[j][i]);}}for(i=0;i<count;i++){for(j=0;j<classes;j++)for(k=0;k<cenCount[j];k++)if(clsObjects[j][k]==i){fprintf(fp,"%d ",label[j]+1);break;}}fprintf(fp,"\n");fprintf(fpOut,"\nCluster number: %2d \n",l);for(i=0;i<classes;i++){fprintf(fpOut,"%2d %4d\n",label[i]+1,cenCount[i]);for(j=0;j<features;j++)fprintf(fpCls,"%8.7f ",clsCenters[l][i][j]/scale[j]+minInput[j]);fprintf(fpCls,"\n");}}/* Write the data to the file */fclose(fp);fclose(fpOut);fclose(fpCls);fclose(fpMinRm);fclose(fpOrgClass);}/* end of function *//********************************************************************//* Function to amnalyze the results *//* Output: none *//* Input: *//* Global Structure Modified: none *//********************************************************************/void analysis(int flag){int i,j,k,temp;char junk;int totalRuns=0,errors[antsPerFeature],epoch=0,position=0,antsperfeature=0,clsNumber=0,min=0,currMinRm;FILE *fp,*fpError,*fpMin,*fpMinRm,*fpMinIp;if(flag==1){fp=fopen("fcm.out","r");fpMinIp=fopen("minRm.out","r");fpMinRm=fopen("minRmError.out","w");fpError=fopen("error.out","w");fpMin=fopen("minError.out","w");}else{fp=fopen("fcmFCM.out","r");fpError=fopen("errorFCM.out","w");}if(fp==NULL||fpError==NULL){printf("\n unable to open files in the analysis module \n");return;}fscanf(fp,"%c %d\n",&junk,&totalRuns);fscanf(fp,"%c %d\n",&junk,&antsperfeature);if(flag==1){fscanf(fpMinIp,"%c %d\n",&junk,&temp);fscanf(fpMinIp,"%c %d\n",&junk,&temp);}for(i=0;i<totalRuns;i++){for(j=0;j<antsperfeature;j++){errors[j]=0;}fscanf(fp,"%c %d\n",&junk,&epoch);if(flag==1){fscanf(fpMinIp,"%c %d\n",&junk,&temp);fscanf(fpMinIp,"%c %d\n",&junk,&currMinRm);fprintf(fpError,"\n");}fprintf(fpError,"Experiment %3d ",i);for(k=0;k<antsperfeature;k++){fscanf(fp,"%c %d\n",&junk,&clsNumber);for(j=0;j<count;j++){fscanf(fp,"%d ",&position);if(orgData[j][0]!=position)errors[k]++;}fscanf(fp,"\n");if(flag==1){fprintf(fpError,"\nCluster %3d Errors %5d",k,errors[k]);if(k==currMinRm){fprintf(fpMinRm,"Cluster %2d Errors %5d\n",k,errors[k]);}}else fprintf(fpError," Errors %5d\n",errors[k]);}if(flag==1){min=0;for(j=1;j<antsPerFeature;j++){if(errors[j]<errors[min])min=j;}fprintf(fpMin,"Exp %2d Min Error %5d\n",i,errors[min]);}}fclose(fp);fclose(fpError);if(flag==1){fclose(fpMin);fclose(fpMinRm);fclose(fpMinIp);}}/* end of function */int main(){int k=0,i=0,flag[antsPerFeature],j=0,flg;float newRm[antsPerFeature],oldRm[antsPerFeature],temp;FILE *fp=fopen("fcm.out","w");FILE *fpFCM=fopen("fcmFCM.out","w");FILE *fpOut=fopen("ClassData.out","w");FILE *fpCls=fopen("clsCenters.out","w");FILE *fpMinRm=fopen("minRm.out","w");FILE *fpOrgClass=fopen("orgClass.out","w");FILE *fpRm=fopen("Rm.out","w");FILE *fpJm=fopen("Jm.out","w");FILE *fpTime=fopen("time.out","w");struct rusage start_usage, end_usage,epoch_start_usage, epoch_end_usage;double *perf_times;fprintf(fpTime,"Experiments %d\n",EXPRUN);fclose(fpJm);fprintf(fp,"# %d\n",EXPRUN);fprintf(fp,"@ %d\n",antsPerFeature);fclose(fp);fprintf(fpFCM,"# %d\n",EXPRUN);fprintf(fpFCM,"@ %d\n",1);fclose(fpFCM);fprintf(fpMinRm,"# %d\n",EXPRUN);fprintf(fpMinRm,"@ %d\n",antsPerFeature);fclose(fpMinRm);fclose(fpOut);fclose(fpCls);fclose(fpOrgClass);fclose(fpRm);readInput();/*readOrg();*/for(k=0;k<EXPRUN;k++){srand48(state1[k]);fp=fopen("fcm.out","a");fpFCM=fopen("fcmFCM.out","a");fpOut=fopen("ClassData.out","a");fpCls=fopen("clsCenters.out","a");fpOrgClass=fopen("orgClass.out","a");fpMinRm=fopen("minRm.out","a");fpRm=fopen("Rm.out","a");fprintf(fpRm,"Exp: %2d ",k);fclose(fpRm);fprintf(fpCls,"EXP No %2d \n",k);fclose(fpCls);fprintf(fp,"$ %d\n",k);fprintf(fpFCM,"$ %d\n",k);fprintf(fpMinRm,"$ %d\n",k);fprintf(fpOut,"Experiment %d\n",k);fprintf(fpOrgClass,"Experiment %d\n",k);fclose(fp);fclose(fpFCM);fclose(fpOut);fclose(fpMinRm);fclose(fpOrgClass);initializeAnts(ants);for(i=0;i<antsPerFeature;i++){oldRm[i]=inf;newRm[i]=inf;}flg=1;i=0;getrusage(RUSAGE_SELF, &start_usage);while(i<maxEpocs){getrusage(RUSAGE_SELF, &epoch_start_usage);epoch(ants);getrusage(RUSAGE_SELF, &epoch_end_usage);perf_times=timing_of(epoch_start_usage,epoch_end_usage); fprintf(fpTime,"Epoch %3d Timing: %f user, %f system, %f total.\n",i, perf_times[0], perf_times[1], perf_times[0] +perf_times[1]);for(j=0;j<antsPerFeature;j++){oldRm[j]=newRm[j];flag[j]=1;}computeRm(ants,data,newRm);updateMemory(ants,newRm,Rm);flg=0;for(j=0;j<antsPerFeature;j++){if(newRm[j]!=inf){if(oldRm[j]!=inf){temp=0;temp=newRm[j]-oldRm[j]<0? (oldRm[j]-newRm[j]):(newRm[j]-oldRm[j]);/*printf("\n new %f old %f temp %f ",newRm[j],oldRm[j],temp);*/if(temp/oldRm[j]>minChange){flg=1;break;}}else flg=1;}}i++;printf("\nExp %d Epoch %d ",k,i);}/* Do the final clustering*/finalCluster(ants,data,Rm);getrusage(RUSAGE_SELF, &end_usage);perf_times=timing_of(start_usage,end_usage); fprintf(fpTime,"Exp %3d Timing: %f user, %f system, %f total.\n",k, perf_times[0], perf_times[1], perf_times[0] +perf_times[1]);/* Compute the error */}/* end for*//*analysis(1);analysis(0);*/printf("\n");fclose(fpTime);return 0;}/* End of main */ void Fcm (center V,objects X) { int i,k; FILE *ofile; char temp[80]; Random_seed=state1[run];/*randseed*/ srand48(Random_seed); for(k=0;k<MAXDATA;k++) for(i=0;i<classes;i++){U[i][k]=0;U1[i][k]=0;} for(i=0;i<classes;i++) degenerate[i]=0; for (run=0;run<TOTRUNS;run++) { eps=0.00001; stop = FALSE; /* This loop finds the final cluster center and the corresponding U values */ z = 0; while (stop == FALSE) { z++; UMAT(U,V,X); /** Update the U matrix **/stop = FINISHED(U1,eps); CLUSTER(U,X,V); /** Get new cluster center **/printf("\nIteration: %d \n",z); } /* end while */ printf("Number of iterations: %d\n\n", z);strcpy(temp,""); sprintf(temp,"%sFCM.out",filename); Output(temp,V,X); /* output the results */ }/*end for*/ ofile=fopen(temp,"a"); for (i=0; i <= mins; i++) fprintf(ofile, "Min %d of %10.3f occurred %d times\n", i, mintab[i], mincount[i]); fprintf(ofile, "Average iterations %f\n", (float)aveit/(float)TOTRUNS); fclose(ofile); }/* end Main */ /* The NORM function computes the norm of two vectors, x and v, of dimension s. This gives an indication of the distance between them */ float NORM( feature x, feature v) //feature x, v; { /* Parameters : x -- a local copy of an input vector v -- a local copy of a cluster center */ int i,j; /* loop variable */ double sum; /* the square root of sum is the norm; sum is the sum of the differences squared */ float mat1[features]; float mat2[features]; if (maha) { for (i=0; i<features; i++) mat1[i]=x[i]-v[i]; for(i=0;i<features;i++) { sum =0; for(j=0;j<features;j++) sum += mat1[j] * inv_cov[j][i]; mat2[i] = sum; } sum =0; for(j=0;j<features;j++) sum += mat1[j]*mat2[j]; } else { sum = 0; for(j=0;j<features;j++) sum += (x[j] - v[j])* (x[j] - v[j]); } return (float)(sqrt(sum)); } /* end NORM */ /* The UMAT procedure calculates the updated U matrix according to Bezdek's formula. Its side-effect is the update of the global array U1 */ void UMAT( matrix U,center V, objects X) /*matrix U; center V; objects X;*/ { /* Parameters: U, V, and X: same as in main program */ int i, k ;/* loop variables *///, class /* class whose cluster center //is closest to pattern k */; int minPos; float distance[classes],min; for (i=0;i<classes;i++) distance[i]=0; for (k=0;k<MAXDATA;k++) { min=10e10;minPos=0;for (i=0;i<classes;i++) { distance[i]=NORM(X[k],V[i]);if(distance[i]==0)printf("\n Found a case with Dik =0\n");if(distance[i]<min){min=distance[i];minPos=i;}U1[i][k]=0; } U1[minPos][k]=1.0; } } /* end UMAT */ /* The function FINISHED determines if a termination occurs. If not it updates U with U1, so its side-effect is the potential modification of U */ BOOLEAN FINISHED( matrix U1,float eps) //matrix U1; float eps; { /* Parameters: U1, eps-- same as in main */ float sum; /* sum of squared differences between corresponding elements of U and U1 */ int i,k; /* loop control variabes */ BOOLEAN finished; /* set to true if all corresponding elements are within epsilon */ finished = TRUE; sum = 0; for (i=0; i<classes; i++) for (k=0; k<MAXDATA; k++) sum += (U[i][k] - U1[i][k])*(U[i][k]-U1[i][k]); if (sqrt(sum) > eps) { finished = FALSE; for (i=0; i<classes; i++) for (k=0; k<MAXDATA; k++) U[i][k] = U1[i][k]; } /* end if */ return finished; } /* end FINISHED */ /* The CLUSTER procedure determines cluster centers in V for the c classes being searched for. The global array V is updated */ void CLUSTER( matrix U, objects X,center V) //matrix U; objects X; { /* Parameters: U, X -- as in main */ int i, j, k; /* loop control variables */ feature num; /* numerator in the cluster center computation formula presented by Bezdek */ float denum; /* denumenator in the obove formula */ for (i=0; i<classes; i++) { denum = 0; for (j=0; j<features; j++) { num[j] = 0; for (k=0; k<MAXDATA; k++) num[j] += U[i][k] * X[k][j]; /* pow(U[i][k],m) * X[k][j]; */ } /* end for */ for (k=0; k<MAXDATA; k++) denum += U[i][k]; /* pow(U[i][k],m); */ if(denum==0)degenerate[i]=1; for (j=0; j<features; j++) { if(denum!=0) V[i][j] = num[j] / denum;else V[i][j] = inf; } } /* end for */ } /* end CLUSTER */ /* The Output procedure outputs the U matrix which gives the fuzzy measure of each feature belonging to a cluster center. It also outputs the cluster center for each class */ void Output(char fname[],center V,objects X) //char fname[80]; /* Parameters: U, V -- same as in main */ { int i, j, found; /* loop control variables */ float J2c,R2c; FILE *fpJm=fopen("Jm.out","a"); if ((fp=fopen(fname,"a"))==NULL) printf("\n CAN'T OPEN %s\n",fname); else { fprintf(fp,"\n \n"); for (i=0; i<classes; i++) { fprintf(fp,"\n"); for (j=0; j<features; j++) fprintf(fp,"%4.3f ",V[i][j]); } /* end for */ } /* end if */ J2c= Compute_Jm(V,X); R2c=Compute_Rm(V,X); fprintf(fpJm,"Jm: %10.6f Rm: %10.6f \n",J2c,R2c); found =0; for (i=0;i<= mins; i++) { if ((found == 0) && ((J2c - mintab[i]) < .001) && ((J2c - mintab[i]) > -.001)){ mincount[i]++; found = 1; } } if (found == 0) { mins++; mintab[mins]=J2c; mincount[mins]=1; } fprintf(fp,"\nJ%2d = %f", m,J2c); fprintf(fp, "Number of iterations: %d\n\n", z); aveit=aveit + z; fclose(fp); fclose(fpJm); } /***************************************************************/ void find_covar( ) { int i,j,k; float mean[features],sum; for (i=0;i<features;i++) mean[i]=0; for (i=0;i<features;i++) for (j=0;j<m;j++) mean[i]+=X[j][i]; for (i=0;i<features;i++) mean[i]/=m; for (i=0;i<features;i++) for (j=0;j<features;j++) { sum=0; for (k=0;k<m;k++) sum+=(X[k][i]-mean[i])*(X[k][j]-mean[j]); Y[i][j]=sum/m; } } float Compute_Jm(center V, objects X) //center V; //objects X; { int i, k,found; double Jm_value; float u,dik; Jm_value = 0; for (k=0; k<MAXDATA; k++) { found = FALSE; for (i=0; i<classes; i++) { if(degenerate[i]==1)continue; dik=NORM(X[k],V[i]); dik=dik*dik; u=0; if (dik==0.0) { if (found == FALSE) { u=1.0; found = TRUE; printf("found the case with dik=0\n"); } else { printf("\n cant proceed with this initialization"); exit(1); } } else { if (found != TRUE) u=U1[i][k]; /* get_Uvalue(V,X,dik,k); */ else u=0.0; } Jm_value += u * dik;/* pow(u, m) * dik; */ } } return (Jm_value); } /* end Compute_Jm */float Compute_Rm(center V, objects X){int i=0,j=0,l=0;double dik=0,temp=0,Rm=0,min=0;Rm=0;for(i=0;i<MAXDATA;i++){dik=0;min=10e10;for(j=0;j<classes;j++){temp=0;for(l=0;l<features;l++)temp+=(X[i][l]-V[j][l])*(X[i][l]-V[j][l]); /*dik=NORM(X[i],V[j]); dik=dik*dik;*/if(temp<min)min=temp;}Rm+=min;}return(Rm);}/* End of function *//********************************************************************/ /* Function to harden the outputs obtained from fcm(2nd stage)*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: Cluster center , cluster center count*/ /********************************************************************/void harden() { FILE *fp=fopen("fcmFCM.out","a"); FILE *fpOut=fopen("ClassDataFCM.out","a"); int i=0,minPosition=-1,position[MAXDATA],j=0,k=0; int cenCount[classes],classCount[classes][classes],label[classes], clsObjects[classes][MAXDATA]; for(j=0;j<classes;j++) {cenCount[j]=0;for(k=0;k<classes;k++)classCount[j][k]=0; } for(i=0;i<MAXDATA;i++) { minPosition=findPosition(i); position[i]=minPosition;clsObjects[minPosition][cenCount[minPosition]]=i;cenCount[minPosition]++; } for(j=0;j<classes;j++) {for(i=0;i<cenCount[j];i++)classCount[j][(int)orgData[clsObjects[j][i]][0]-1]++; } /* minPosition varaible re used , now minPosition denotes the maximum class of the cluster*/for(j=0;j<classes;j++){minPosition=0;for(i=1;i<classes;i++){if(classCount[j][i]>classCount[j][minPosition]) minPosition=i;label[j]=minPosition;}}fprintf(fp,"* %d\n",0);for(i=0;i<count;i++){for(j=0;j<classes;j++)for(k=0;k<cenCount[j];k++)if(clsObjects[j][k]==i){fprintf(fp,"%d ",label[j]+1);break;}}fprintf(fp,"\n");for(i=0;i<classes;i++){fprintf(fpOut,"%2d %4d\n",label[i]+1,cenCount[i]);}fclose(fpOut);fclose(fp);return; }/*end of function*/ /********************************************************************/ /* Function to find to which class the object belongs */ /* Output: Class number */ /* Input: object position */ /* Global Structure Modified: None */ /********************************************************************/int findPosition(int i) { int j,position=0; for(j=1;j<classes;j++) { if(U[j][i]>U[position][i]) position=j; } return(position); }/*end of function find position*/
Parag Kanade/Partition with centroids/HCM/british.data
Normalized British towns data. Each feature is normalized to start at 0.# 12.5900 1.4400 4.4700 4.7100 11.7600 0.1100 0.5800 6.4200 8.9400 0.4000 3.1900 4.8700 10.6200 1.5000 2.7200 2.9200 10.2800 0 2.6800 6.0400 9.5500 0.9700 2.6200 5.1700 9.7800 1.9600 0.5400 4.2500 10.0900 1.3200 2.7300 4.5900 6.5300 0.9200 2.5100 5.4500 8.3000 2.3300 1.2800 3.9300 6.8000 3.6800 2.0900 2.8700 5.0900 2.0700 4.8200 4.0000 5.7200 5.6600 4.0800 2.3900 5.2300 3.9400 1.7800 2.3000 6.7100 3.8600 3.3600 2.1000 5.4800 3.6800 3.5500 2.5000 5.1100 4.3700 3.7300 2.2300 4.9700 4.6500 3.6900 1.4600 4.9700 4.4700 5.1500 0.6500 7.8300 4.4700 2.6000 4.2100 2.1800 5.1200 4.5500 3.2400 3.3200 4.2300 3.6000 2.2100 2.2400 4.5200 3.8200 2.9100 3.4400 5.1100 1.8000 2.6600 2.6800 4.8200 3.6500 2.0200 3.2400 3.1900 4.1800 0.7400 3.5300 3.2400 3.0700 1.1400 3.2800 5.0300 4.2700 0.6700 2.3100 4.0000 3.9900 0.7600 3.0100 4.1600 4.0500 1.0900 3.4600 4.2600 2.8000 2.5300 3.6800 4.5900 1.0800 0.4300 2.5200 3.7800 2.3700 2.5700 2.9500 4.1200 2.7400 2.5300 3.4800 5.0900 2.2700 0.8500 2.0200 5.1000 2.6400 4.4400 0.4300 6.2800 1.6600 0 1.5600 5.3400 2.0400 2.4900 1.3600 5.3800 4.7400 0.9800 1.4100 5.7500 3.3600 0.8500 0.2500 4.4700 1.3400 0.4500 1.1300 4.7400 3.1100 3.1200 0.9000 6.2300 2.7800 1.6300 0.6000 6.2600 2.3200 1.7200 0.6100 5.4900 3.1800 1.0300 0 6.9500 2.8200 0.9900 0.5000 5.6600 0 2.4200 0.7700 4.5000 2.5400 2.1700 2.0100 5.0200 0.3500 1.7600 0.4600 7.6900 2.9800 1.6700
Parag Kanade/Combined Algorithm/combErr.c
#include "headerStatic.h" /********************************************************************/ /********************************************************************/ /* Function to read the input data set */ /* The file name is assumed to be itest.data */ /* Status: Tested */ /* Output: Data from the file into the "data" (Global) data structure */ /* Output: Count (Global), the count of the number of objects */ /********************************************************************/ void readInput() { FILE *fp; char fname[80]; int i=0,j=0; char ch; sprintf(fname,"%s.data",filename); /* Check if the input file is opened */ if((fp=fopen(fname,"r"))==NULL) { printf("\n Unable to open input file \n"); exit(0); } /*initialise the minimum maximum and the scale */ for(i=0;i<features;i++) { minInput[i]=1000; maxInput[i]=0; minForHeaps[i]=1000; maxForHeaps[i]=0; scale[i]=0; scaleForHeaps[i]=0; } /* Discard leading comments */ ch = 'c'; while (ch != '#') fscanf (fp, "%c", &ch); i=0; /* Parse the file and populate the data structure */ while(!feof(fp)) { for(j=0;j<features;j++) { fscanf(fp,"%f ",&data[i][j]); } fscanf(fp,"\n"); for(j=0;j<features;j++) { if(data[i][j]<minInput[j]) minInput[j]=data[i][j]; if(data[i][j]>maxInput[j]) maxInput[j]=data[i][j]; } i++; } count=i; /* Normailze the feature values in between 0 and 1 */ for(j=0;j<features;j++) { if(minInput[j]!=maxInput[j]) scale[j]=1.0/(maxInput[j]-minInput[j]); else scale[j]=1.0; } for(i=0;i<count;i++) { for(j=0;j<features;j++) data[i][j]=(data[i][j]-minInput[j])*scale[j]; } fclose(fp); return; }//end of function /********************************************************************/ /*Function to compute the eucldiean distance for all input data set */ /* Output : an array conatining the distance of each object with the other */ /********************************************************************/ float computeDistance() { float distance,dist=0; int i=0,j=0,k=0; distance=0; for(j=0;j<count;j++) for(i=0;i<count;i++) { for(k=0;k<features;k++) dist+=sqrt((data[j][k]-data[i][k])*(data[j][k]-data[i][k])); if(distance<dist)distance=dist; dist=0; } return(distance); } /********************************************************************/ /* Function to compute the distance between two objects */ /* Output : Euclidean d istance between the two input objects */ /********************************************************************/ float computeDistanceBetween2(irisData a,irisData b) { float temp=0; int i=0; for(i=0;i<features;i++) temp+=(a[i]-b[i])*(a[i]-b[i]); temp=sqrt(temp); return(temp); } /********************************************************************/ /* Function to compute the value of an object */ /********************************************************************/ float value(irisData a) { int i=0; float temp=0; for(i=0;i<features;i++) temp+=a[i]*a[i]; return(sqrt(temp)); } /********************************************************************/ /* Function to find the object in the data structure */ /* Output : The position of the object in the data */ /* Input : The object */ /********************************************************************/ int findInData(irisData object,int iFlag) { int i=0,lastCount=0,j,position=-1,flag[features],flg;if(iFlag==1)lastCount=MAXDATA;else{}for(i=0;i<lastCount;i++){ for(j=0;j<features;j++) if(fabs(object[j]-data[i][j])<0.00001) flag[j]=1; else { flag[j]=0; break;} flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /* Function to find whether there is an object on the board at a,b */ /* Output : a flag indicating whether an object is found or not */ /* Input : The row and column indicating the board position */ /********************************************************************/ int found(int a , int b) { if(board[a][b]==9) return 1; else return 0; } /********************************************************************/ /* Function to initialize the initial board */ /* Output : None */ /* Global Structures modified : heaps */ /* Input : Flag indicating the iteration 1: First 0: Second */ /********************************************************************/ void initialise(int flag) { int a,b,i=0,k=0; int loopCount,rowCount,colCount; /* Initialize the row, column and number of heaps */ if(flag==1) { loopCount=count; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=lCount; rowCount=heapRow; colCount=heapRow; } /* Initialize the heaps */ for(i=0;i<loopCount;i++) { heaps[i].count=0; heaps[i].x=0; heaps[i].y=0; heaps[i].disPosition=0; heaps[i].Dmax=0; heaps[i].Dmean=0; } for(i=0;i<loopCount;i++) { /*find a board position which is empty*/ do { a=lrand48()%rowCount; b=lrand48()%colCount; } while(found(a,b)); /*Allocate the object to that place and assign a heap to it*/ heaps[i].x=a; heaps[i].y=b; heaps[i].count=1; heaps[i].Dmax=0; heaps[i].Dmean=0; if(flag==1) { heaps[i].objects[0]=i; for(k=0;k<features;k++)heaps[i].Ocenter[k]=data[i][k]; } else { for(k=0;k<features;k++) heaps[i].Ocenter[k]=newHeaps[i].Ocenter[k]; } heaps[i].disPosition=0; board[a][b]=9; if((debugLevel>0)&&(flag==1))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],data[heaps[i].objects[0]][0]); if((debugLevel>0)&&(flag==0))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],newHeaps[i].Ocenter[0]); } /*initialise the initial heap count*/ heapCount=loopCount; currentRow=rowCount; } /********************************************************************/ /* Function to find whether an heap is present at the location a b */ /* Output : Flag indicating the presencs of the heap */ /* Input : Roe and column indicating the board position */ /********************************************************************/ int findObject(int a,int b) { int i; int position=-1; for(i=0;i<heapCount;i++) { if((heaps[i].x==a)&&(heaps[i].y==b)) { position=i; break; } } return(position); } /********************************************************************/ /* Function initialize the ants */ /* Output : None */ /* Input : Flag indicating the iteration */ /* Global Variables Modified : ant, heapCount, heaps, board */ /********************************************************************/ void initialiseAnts(int flag) { int i=0,a=0,b=0,position,j=0,loopCount=0,rowCount,colCount,k=0; if(flag==1) { loopCount=MAXANTS; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=MAXANTSFORHEAPS; rowCount=heapRow; colCount=heapRow; } for(i=0;i<loopCount;i++) { /*generate random positions for the ants*/ a=lrand48()%rowCount; b=lrand48()%colCount; ants[i].x=a; ants[i].y=b; /*Find if an object is present at that position or not*/ if(board[a][b]==9) { ants[i].carrying=1; /*find the heap at that location*/ position=findObject(a,b); if(position==-1) { printf("\n Error in logic: Ant init \n"); //getchar(); break; } else { /*Assign the heap data to the ant data and decrement the heap count*/ if(flag==1){ for(k=0;k<features;k++)ants[i].data[k]=data[heaps[position].objects[0]][k]; }else{for(k=0;k<features;k++)ants[i].data[k]=heaps[position].Ocenter[k];} for(j=position;j<heapCount-1;j++) heaps[j]=heaps[j+1]; heapCount--; } /*Clear the board position */ board[a][b]=-9; } else ants[i].carrying=-1; ants[i].speed=0; ants[i].dir=lrand48()%8; printf("\n Ant %2d X: %2d Y: %2d Carying : %2d ",i,ants[i].x,ants[i].y,ants[i].carrying); } currentAntCount=loopCount; } /********************************************************************/ /* Function to move the ant */ /* Output: None */ /* Input: Ant to be moved and the flag indicating the iteration */ /********************************************************************/ void moveNext(ant* a,int flag) { int rowCount,colCount; rowCount=currentRow;colCount=currentRow; /*Depending upon the direction move the ant*/ switch (a->dir) { case 0: a->y++; if(a->y>=colCount)a->y=0; break; case 1: a->x--; a->y++;; if(a->x<0)a->x=rowCount-1; if(a->y>=colCount)a->y=0; break; case 2: a->x--; if(a->x<0)a->x=rowCount-1; break; case 3: a->x--; a->y--; if(a->x<0)a->x=rowCount-1; if(a->y<0)a->y=colCount-1; break; case 4: a->y--; if(a->y<0)a->y=colCount-1; break; case 5: a->x++; a->y--; if(a->x>=rowCount)a->x=0; if(a->y<0)a->y=colCount-1; break; case 6: a->x++; if(a->x>=rowCount) a->x=0; break; case 7: a->x++; a->y++; if(a->x>=rowCount)a->x=0; if(a->y>=colCount)a->y=0; break; } }//end of function /********************************************************************/ /* Function to compute the parameters of the heap */ /* Output: None */ /* Input: The heap whose parameters are to be computed iteration flag*/ /********************************************************************/ void computeHeapParameters(heap* heapData,int flag) { int i=0,j=0,k=0,position=0; float distance=0; float Dmean=0.0; float *dis; float featureSum[features]; float max=0; float sum=0; /* init*/ for(k=0;k<features;k++) featureSum[k]=0; /*Compute the distance of each object and find the maximum distance*/ max=0; if(flag==1){ for(j=0;j<heapData->count;j++) for(i=0;i<heapData->count;i++) { for(k=0;k<features;k++) sum+= (data[heapData->objects[j]][k]-data[heapData->objects[i]][k])*(data[heapData->objects[j]][k]-data[heapData->objects[i]][k]); distance=sqrt(sum); if(max<distance) max=distance; sum=0; } /* Assign the maximum distance to the heap */ heapData->Dmax=max;/*Compute the centre object*/for(i=0;i<heapData->count;i++)for(k=0;k<features;k++) featureSum[k]+=data[heapData->objects[i]][k];for(k=0;k<features;k++)heapData->Ocenter[k]=featureSum[k]*1.0/heapData->count; /* Find the mean distance */if((dis=(float *) calloc(heapData->count,sizeof(float)))==NULL){printf("\nUnable to allocate memory in the compute heap parameters procedure\n");exit(0);} for(i=0;i<heapData->count;i++) { Dmean+=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); dis[i]=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); } heapData->Dmean=Dmean*1.0/heapData->count; /*Compute the most dissimilar object*/ max=dis[0]; for(i=1;i<heapData->count;i++) if(max<dis[i]) { max=dis[i]; position=i; } /*Assign the most dissimilar object to the heap variable*/ for(k=0;k<features;k++) heapData->Odissim[k]=data[heapData->objects[position]][k]; heapData->disPosition=position;free(dis); } else{/* Heap Parameters for the second stage */for(k=0;k<features;k++){ heapData->Odissim[k]=heapData->Ocenter[k];}heapData->disPosition=0;heapData->Dmean=0;heapData->Dmax=0;} }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a single object*/ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject1(ant *a,int position,int flag) { int i,k=0; /*Clear the board*/ board[heaps[position].x][heaps[position].y]=-9; /* Assign the data to the ant*/if(flag==1){ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[0]][k];}else {for(k=0;k<features;k++) a->data[k]=heaps[position].Ocenter[k];} a->carrying=1; /*Copy all the heaps remaining heaps in the structure*/ for(i=position;i<heapCount-1;i++) heaps[i]=heaps[i+1]; /*Decrement the heap count*/ heapCount--; }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a two objects */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject2(ant *a , int position,int flag) { float Pdestroy1=-1; int i=0,k=0; /*Compute the probability to destroy the heap*/ Pdestroy1=lrand48()%13*1.0/12.0; /*If the probability is more than Pdestroy then destroy the heap */ if(Pdestroy1<Pdestroy) { /*pick the object randomly*/ i=lrand48()%2; /* Assign the data to the ant */ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[i]][k]; a->carrying=1; /*Correct the heap parameters*/ heaps[position].count=1; heaps[position].objects[0]=heaps[position].objects[1-i]; computeHeapParameters(&heaps[position],flag); } }//end of function /********************************************************************/ /*Function to pick a object from a heap consisting of more than two object */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /********************************************************************/ void pickObjectn(ant *a,int position,int flag) { int i=0,k=0; /*If the criteria is satsfied then pick the object*/ if((computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)*1.0/heaps[position].Dmean)>Tremove) { a->carrying=1; for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[heaps[position].disPosition]][k]; for(i=heaps[position].disPosition;i<heaps[position].count-1;i++) heaps[position].objects[i]=heaps[position].objects[i+1]; heaps[position].count--; computeHeapParameters(&heaps[position],1); } }//end of function /********************************************************************/ /* Function to pick a object */ /********************************************************************/ void pick(ant *a,int flag) { int position=-1,i=0; float Pload1=-1.0; for(i=0;i<heapCount;i++) { /*Check if a heap is present in the eight neighbouring cells*/ if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if Heap is found*/ if(position!=-1) { /* heap or object found.*/ /*Depending upon the number present in the heap call the corresponding routine*/ switch(heaps[i].count) { case 1: Pload1 = lrand48()%151*1.0/150.0; if(Pload1<Pload) { pickObject1(a,position,flag); } break; case 2: pickObject2(a,position,flag); break; default: pickObjectn(a,position,flag); break; } } } /********************************************************************/ /* Function to drop a object to form a new heap */ /* Output: None */ /* Input: Ant, iteration flag */ /* Global Structure modified : heap, heapCount */ /********************************************************************/ void dropObject(ant* a,int flag) { /*Create a new heap*/ int k=0; heaps[heapCount].count=1; heaps[heapCount].x=a->x; heaps[heapCount].y=a->y; heaps[heapCount].Dmax=0; heaps[heapCount].Dmean=0; heaps[heapCount].disPosition=0; for(k=0;k<features;k++) { heaps[heapCount].Odissim[k]=a->data[k]; heaps[heapCount].Ocenter[k]=a->data[k]; } if(flag==1) {heaps[heapCount].objects[0]=findInData(a->data,flag); /*computeHeapParameters(&heaps[heapCount],flag);*/ } computeHeapParameters(&heaps[heapCount],flag); heapCount++; a->carrying=-1; board[a->x][a->y]=9; }//end of function /********************************************************************/ /* Function to find the heap position during the second iteration */ /* Output: position of the heap */ /* Input: object center of the heap that the ant is carrying */ /* Global Structure modified : none */ /********************************************************************/ int findInNewheaps(irisData object) { int position=-1,i,j=0,flag[features],flg; for(i=0;i<newHeapCount;i++) { for(j=0;j<features;j++) { if(fabs(object[j]-newHeaps[i].Ocenter[j])<0.00001) flag[j]=1; else {flag[j]=0;break;} } flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /*Function to drop a object to a heap consisting of a one or more object */ /* Output: none */ /* Input: Ant, position of the heap , iteration flag */ /* Global Structure modified: heaps,newHeaps */ /********************************************************************/ void dropObject1(ant* a, int position,int flag) { int heapPosition=-1,heapPosition1=-1,i,j,k=0; irisData newData,temp; if(flag==1) { heaps[position].objects[heaps[position].count]=findInData(a->data,flag); heaps[position].count++; computeHeapParameters(&heaps[position],flag); } else { for(k=0;k<features;k++)temp[k]=heaps[position].Ocenter[k]; heapPosition=findInNewheaps(a->data); heapPosition1=findInNewheaps(heaps[position].Ocenter); if(heapPosition==-1||heapPosition1==-1) { printf("\n error in logic:new heaps\n"); //getchar(); return; } for(k=0;k<features;k++) {newData[k]=(newHeaps[heapPosition].Ocenter[k]*newHeaps[heapPosition].count+newHeaps[heapPosition1].Ocenter[k]*newHeaps[heapPosition1].count)*1.0/(newHeaps[heapPosition].count+newHeaps[heapPosition1].count);newHeaps[heapPosition].Ocenter[k]=newData[k];heaps[position].Ocenter[k]=newData[k]; } computeHeapParameters(&heaps[position],flag); for(i=newHeaps[heapPosition].count,j=0;j<newHeaps[heapPosition1].count;i++,j++) { newHeaps[heapPosition].objects[i]=newHeaps[heapPosition1].objects[j]; } newHeaps[heapPosition].count+=newHeaps[heapPosition1].count; for(i=heapPosition1;i<newHeapCount-1;i++) newHeaps[i]=newHeaps[i+1]; newHeapCount--; } a->carrying=-1; }//end of function /********************************************************************/ /* Function to drop a object */ /* Output: None */ /* Input: Ant, iteration flag */ /********************************************************************/ void drop(ant* a,int flag) { int i, position=-1; float Pdrop1=0.0; /*Find whether we have a heap in the neighbourhood of the cell*/ for(i=0;i<heapCount;i++) { if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if a heap is found*/ if(position!=-1) { /*heap or object found.*/ /*Depending on the number of objects present take action*/ switch(heaps[position].count) { /*If criteria is satisfied then drop the object*/ case 1: if(flag==1) { if((computeDistanceBetween2(a->data,data[heaps[position].objects[0]])*1.0/Dmax)<Tcreate) dropObject1(a,position,flag); } else { if((computeDistanceBetween2(a->data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) dropObject1(a,position,flag); } break; default: if(computeDistanceBetween2(a->data,heaps[position].Ocenter)<computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)) dropObject1(a,position,flag); break; } } else { /*Compute the probability to drop the object*/ Pdrop1 = lrand48()%151*1.0/150; if(Pdrop1<Pdrop) dropObject(a,flag); } }//end of function /********************************************************************/ /* Function to move the ant */ /* Output: none */ /* Input: Ant, iteration flag */ /********************************************************************/ void move(ant* a,int flag) { float pDir; /*Check the speed */ if (a->speed!=0) { /*move in the same direction*/ a->speed--; moveNext(a,flag); } else { /*generate the new direction*/ pDir=lrand48()%17*1.0/16.0; if(pDir<.85) { a->dir=lrand48()%8; } else if(pDir>.95) { a->speed=2; } moveNext(a,flag); } } /********************************************************************/ /* Function to simulate the movement of the ants */ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified: minHeapCount, minHeapPosition */ /********************************************************************/ void iterate(int flag) { int i=0,j=0,k=0,loopCount=0; if (flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS; while (i<MAXITERATIONS) { i++; for(j=0;j<loopCount;j++) { move(&ants[j],flag); if(ants[j].carrying==1) { drop(&ants[j],flag); } else { pick(&ants[j],flag); } } if(debugLevel>0){ for(k=0;k<heapCount;k++) for(j=0;j<heapCount;j++) if((k!=j)&&(heaps[k].x==heaps[j].x)&&(heaps[k].y==heaps[j].y)) { printf("\nerror two heaps with same co ordinates %d %d ",k,j); //getchar(); } k=0; for(j=0;j<heapCount;j++) k+=heaps[j].count; } if(heapCount<minHeapCount) { minHeapCount=heapCount; minPosition=i; } if(debugLevel>0) printf("\n i:%d Heap count %d sum %d",i,heapCount,k); else printf("\n i:%d Heap count %d",i,heapCount); heapSum+=heapCount; } }//end of function /********************************************************************/ /*Function to drop the objects carried by the ants after all the iterations*/ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified:none */ /********************************************************************/ void dropFinal(int flag) { int i=0,j=0,position=-1,loopCount=0; loopCount=currentAntCount; for(i=0;i<loopCount;i++) { if(ants[i].carrying==1) { if(flag==1) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position,flag); } } else { /*Find if a heap is present */ do { position=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position,flag); position=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position!=-1); } } } }//end of function /********************************************************************/ /* Function for the implementation of QuickSort */ /* Output: none */ /* Input: data structure, low and high indices */ /* Global structure modified:none */ /********************************************************************/ void quickSort( heap A[], int low,int high ) { int mid=0; if(low<high) { mid=partition(A,low,high); quickSort(A,low,mid); quickSort(A,mid+1,high); } } /********************************************************************/ /* Partition routine used by quick sort */ /* Output: partition location */ /* Input: data , low, high */ /* Global structure modified:none */ /********************************************************************/ int partition(heap a[], int low,int high) { heap temp; int x=0,i=0,j=0; i=low; j=high; x=a[low].count; while (1) { while (a[j].count<x) j=j-1; while (a[i].count>x) i=i+1; if(i<j) { temp=a[i]; a[i]=a[j]; a[j--]=temp; } else return(j); } } /********************************************************************/ /* Function used to write the cluster information */ /* Output: none */ /* Input:iteration flag */ /* Global structure modified:none */ /********************************************************************/ void writeClusterInformation(int flag) { FILE *fp=fopen("center.clt","w"); FILE *fp1; FILE *fp2; FILE *fp3; char temp[80]; int i=0,j=0,k=0; int lastCount=0; int rowCount,colCount,antCount; strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp3=fopen(temp,"a"); if(dataDump) {strcpy(temp,"");sprintf(temp,"%sTot.out",filename);fp1=fopen(temp,"a");strcpy(temp,"");sprintf(temp,"%sObj.out",filename);fp2=fopen(temp,"a");if(fp1==NULL||fp2==NULL)printf("\n Error in opening file in the writer Cluster Information routine\n"); } rowCount=currentRow; colCount=currentRow; antCount=currentAntCount; if(fp==NULL) { printf("\n Unable to open cluster center output file \n"); /*return;*/ exit(0); } /*sort the array according to the count value and write the value of the top three elements*/ if((flag==1)&&(!EntireHeaps)) quickSort(heaps,0,heapCount); if(EntireHeaps) {if(flag==1) lastCount=heapCount;else lastCount=newHeapCount; } else lastCount=c; for(i=0;i<lastCount;i++) { if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else { for(k=0;k<features;k++) { fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",newHeaps[i].Ocenter[k]); fprintf(fp,"\n"); } else { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); fprintf(fp,"\n"); } } if(dataDump) { fprintf(fp1,"\n Information from the Ant Based Algorithm \n"); fprintf(fp1,"\n Important Parameters : Board %d X %d Ants : %d Iterations %d Total Heaps %d ",rowCount,colCount,antCount,MAXITERATIONS,lastCount); } if(flag==0) { if(dataDump) { fprintf(fp1," TCreateForHeaps %f \n",TcreateForHeaps); fprintf(fp2,"\nTotal Heaps : %d\n",heapCount); fprintf(fp2,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); } fprintf(fp3,"\n@ %d\n",lastCount); } else if(dataDump) fprintf(fp1,"\n");if(dataDump) { fprintf(fp1,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); for(i=0;i<lastCount;i++) if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp2,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); } fprintf(fp1," %5d\n",newHeaps[i].count); fprintf(fp2," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp1," %5d\n",heaps[i].count); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]); fprintf(fp1," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]); fprintf(fp1," %5d\n",heaps[i].count); }} if(flag==0) { if(dataDump) fprintf(fp1,"\n Objects in the heaps \n");for(i=0;i<newHeapCount;i++) { if(dataDump) fprintf(fp1,"\n\n Heap %d\n \n",i+1);fprintf(fp3,"# %d %d\n",i ,newHeaps[i].count); for(j=0;j<newHeaps[i].count;j++){ for(k=0;k<features;k++){ fprintf(fp3,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]); if(dataDump) fprintf(fp1,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]);} if(dataDump) fprintf(fp1,"\n"); fprintf(fp3,"\n"); } } } fclose(fp); fclose(fp3); if(dataDump) { fclose(fp1);fclose(fp2); }}//end of flie /********************************************************************/ /* Function to initialise the new heaps */ /* Output: none */ /* Input:new Heap structure */ /* Global structure modified:none */ /********************************************************************/ void initialiseNewHeaps(heap newHeaps[]) { int i=0,j=0; for(i=0;i<lCount;i++) { newHeaps[i].count=0; for(j=0;j<features;j++) newHeaps[i].Ocenter[j]=V[i][j]; newHeaps[i].x=heaps[i].x; newHeaps[i].y=heaps[i].y; } }//end of function /********************************************************************/ /* Function to initialise the new heaps */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ int findPosition(int i) { int j,position=0; for(j=1;j<lCount;j++) { if(U[j][i]>U[position][i]) position=j; } /*printf("\n Position %d ",position);*/ return(position); }//end of function find position /********************************************************************/ /* Function to add object */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ void addObject(int object,heap * heapPosition) { heapPosition->objects[heapPosition->count]=object; heapPosition->count++; }//end of function add object /********************************************************************/ /* Function to harden the outputs obtained from fcm */ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/ void harden(heap newHeaps[]) { int i,heapPosition=-1,sum=0,j=0; /*initialise the new heaps*/ initialiseNewHeaps(newHeaps); for(i=0;i<count;i++) { heapPosition=findPosition(i); addObject(i,&newHeaps[heapPosition]); } /* To check for degenerate partitions*/ for(i=0;i<lCount;i++) { if(newHeaps[i].count==0){for(j=i;j<lCount-1;j++){newHeaps[j]=newHeaps[j+1];}lCount--;i--;} } newHeapCount=lCount; for(i=0;i<lCount;i++) computeHeapParameters(&newHeaps[i],1); if(debugLevel>0) { for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\n sum = %d",sum);} }//end of function/********************************************************************/ /* Function to initialize the initial parameters for the ant algorithm*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void init() { int i=0,j=0; for(i=0;i<MAXROWS;i++) for(j=0;j<MAXCOLS;j++) board[i][j]=-9; heapCount=0; newHeapCount=0; heapRow=0; minPosition=-1; minHeapCount=100000; for(i=0;i<MAXANTS;i++) { ants[i].carrying=-1; ants[i].x=-1; ants[i].y=-1; ants[i].speed=-1; ants[i].dir=-1; } } /********************************************************************/ /* Function to initialize the initial board */ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void initialiseBoard() { int i,j; for(i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; }/********************************************************************/ /* Function to harden the outputs obtained from fcm(2nd stage)*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: Cluster center , cluster center count*/ /********************************************************************/void harden1() { int i=0,heapPosition=-1; for(i=0;i<heapCount;i++) cenCount[i]=0; for(i=0;i<n;i++) { heapPosition=findPosition1(i); addObject1(i,heapPosition); } writeInfo(); }//end of function/********************************************************************/ /* Function to find to which class the object belongs */ /* Output: Class number */ /* Input: object position */ /* Global Structure Modified: None */ /********************************************************************/int findPosition1(int i) { int j,position=0; for(j=1;j<heapCount;j++) { if(U[j][i]>U[position][i]) position=j; } return(position); }//end of function find position/********************************************************************/ /* Function to Write the output of the hardened objects to file*/ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/void writeInfo(){int i=0,j=0,k=0;FILE *fp=fopen("fcm.out","a");if(fp==NULL){printf("\n Unable to open fcm output file \n");return;}fprintf(fp,"\n@ %d\n",heapCount);for(i=0;i<heapCount;i++){fprintf(fp,"# %d %d\n",i,cenCount[i]);for(j=0;j<cenCount[i];j++){for(k=0;k<s;k++)fprintf(fp,"%8.2f ",clsCen[i][j][k]/scale[k]+minInput[k]);fprintf(fp,"\n");}}fclose(fp);return;}/********************************************************************/ /* Function to add a object to a cluster (2nd stage) */ /* Output: none */ /* Input: object poistion , cluster position */ /* Global Structure Modified: Cluster object and cluster count*/ /*******************************************************************/void addObject1(int object,int heapPosition) { int k=0; for(k=0;k<features;k++) clsCen[heapPosition][cenCount[heapPosition]][k]=X[object][k]; cenCount[heapPosition]++; return; }//end of function add object/********************************************************************/ /* Function to read the original classification of objects */ /* Output: none */ /* Input: none */ /* Global Structure Modified: None */ /*******************************************************************/void readOrg(){int i=0,k=0;char temp[80];FILE *fp;strcpy(temp,"");sprintf(temp,"%sFull.data",filename);fp=fopen(temp,"r");if(fp==NULL){printf("\n Unable to open full data input file ");exit(0);}for(i=0;i<n;i++){fscanf(fp,"%f ",&orgData[i][0]);for(k=1;k<s+1;k++)fscanf(fp,"%f ",&orgData[i][k]);}return;}// end of function/********************************************************************/ /* Function to classify the objects in different clusters */ /* Output: none */ /* Input: the cluster objects, the original classification, */ /* number of objects in the cluster,file to write the data */ /* Global Structure Modified: None *//********************************************************************/int analysisData(float data[][s],float orgData[n][s+1],int count,FILE * fp){int i=0,j=0,k=0,type=1,max=0;heapInfo info;for(i=0;i<c;i++){info.classObj[i]=0;}info.total=0;info.total=count;for(i=0;i<count;i++)for(j=0;j<n;j++){type=1;for(k=0;k<s;k++)if(fabs(data[i][k]-orgData[j][k+1])>errThresh){type=-1;break;}if(type!=-1){info.classObj[(int)orgData[j][0]-1]++;break;}}max=0;for(k=0;k<c;k++){if(info.classObj[k]>info.classObj[max])max=k;fprintf(fp,"\nClass %d Objects % d ",k+1,info.classObj[k]);}j=0;for(k=0;k<c;k++){if(k!=max)j+=info.classObj[k];}fprintf(fp,"\n Total errors : %d \n",j);return(j);}//end of analyse/********************************************************************/ /* Function to read the cluster information */ /* Output: none */ /* Input: input file pointer , output file pointer */ /* Global Structure Modified: None *//********************************************************************/void readFCM(FILE* fp,FILE *fp1){int i=0,j=0,k=0,l=0;int totalRuns=0,heapCount=0,junk=0,sum=0;char ch;FILE *fp2=fopen("errors.out","a");ch = 'c'; while (ch != '$') fscanf (fp, "%c", &ch);fscanf(fp,"%d\n",&totalRuns);printf("\n total runs %d ",totalRuns);for(l=0;l<totalRuns;l++){fscanf(fp,"%c",&ch);fscanf(fp,"%d\n",&heapCount);fprintf(fp1,"\n \nExperiment %d \n ",l+1);sum=0;for(i=0;i<heapCount;i++){fscanf(fp,"%c",&ch);fscanf(fp," %d %d\n",&junk,&clsCenCount[i]);for(j=0;j<clsCenCount[i];j++)for(k=0;k<s;k++)fscanf(fp,"%f",&fcmData[i][j][k]);fscanf(fp,"\n");fprintf(fp1,"\n\n Heap %d Total Objects %d \n",i+1,clsCenCount[i]);sum+=analysisData(fcmData[i],orgData,clsCenCount[i],fp1);}fprintf(fp2," %3d %3d %3d \n",l,sum,heapCount);}fprintf(fp2,"\n --------------------------\n");fclose(fp2);return;}//end of functionvoid initRm(int heapCount) { antCount=heapCount*antsPerFeature*features;classes=heapCount;newAnts=(antdata*) calloc(antCount,sizeof(antdata));if(ants==NULL){printf("\n Cannot allocate memory to ants in Rm stage");printf("\n Exiting ... ");exit(-1);}} /***************************************************************************//* Function to initialise the ants *//* Status: under developement *//* Output: the ant structure is modified with initial random values *//* Input : Ant structure (this is modified) *//***************************************************************************/void initializeAntsRm(antdata* ants,center clsCen){int i,j,k;/* Initialize all the ants with initial values and the rest and direction*/for(i=0;i<antCount;i++){ants[i].currPos=drand48();for(j=0;j<memory;j++){ants[i].Rm[j]=inf;for(k=0;k<antsPerFeature;k++)Rm[k][j]=inf;}ants[i].rest=1;ants[i].direction=drand48()<0.5?1:-1;}for(j=0;j<features;j++)for(i=0;i<classes;i++){ants[j*classes+i].currPos=clsCen[i][j];}}/*end of function*//***************************************************************************//* Function that runs one epoch *//* Status: under developement *//* Output: the ant structure is modified with according to the epoch *//* Input : Ant structure (this is modified) *//***************************************************************************/void epoch(antdata* ants){int i,j;float Trest=0,Tcontinue=0,Tinc=0;float dDiff=0.0;float temp=0;dDiff=DmaxRm-Dmin;for(j=0;j<iterations;j++){for(i=0;i<antCount;i++){if(ants[i].rest!=0){Trest=drand48();if(Trest<Prest){ants[i].rest=0;continue;}Tcontinue=drand48();if(Tcontinue>Pcontinue)ants[i].direction=-1*ants[i].direction;Tinc=drand48();temp=ants[i].currPos+ants[i].direction*(Dmin+Tinc*dDiff);if(temp>1||temp<0)ants[i].direction=-1*ants[i].direction;ants[i].currPos+=ants[i].direction*(Dmin+Tinc*dDiff);}}}for(i=0;i<antCount;i++)ants[i].rest=1;}/*end of function*//***************************************************************************//* Function that computes Rm *//* Status: under developement *//* Output: the ant structure is modified, the worst Rm is removed *//* Input : Ant structure (this is modified) *//***************************************************************************/void computeRm(antdata* ants,float data[MAXDATA][features],float newRm[antsPerFeature]){int i,j,k=0,l=0;float clsCenters[antsPerFeature][MAXDATA][features];double Rm=0.0,temp=0.0,Dik=0;for(k=0;k<antsPerFeature;k++)for(j=0;j<features;j++)for(i=0;i<classes;i++){clsCenters[k][i][j]=ants[k*classes*features+j*classes+i].currPos;}for(k=0;k<antsPerFeature;k++){Rm=0;for(i=0;i<count;i++){Dik=0;for(j=0;j<classes;j++){temp=0;for(l=0;l<features;l++)temp+=(data[i][l]-clsCenters[k][j][l])*(data[i][l]-clsCenters[k][j][l]);/*temp=sqrt(temp);*//*temp=NORM(data[i],clsCenters[k][j]);temp=temp*temp;*/Dik+=pow(temp,1.0/(1-m));}Rm+=pow(Dik,(1-m));}newRm[k]=Rm;}return;}/*end of function*//********************************************************************//* Function to update the memory of the ants *//* Output: none *//* Input: ant structure and the new Rm, old memory *//* Global Structure Modified: none *//********************************************************************/void updateMemory(antdata* ants,float newRm[antsPerFeature],float Rm[antsPerFeature][memory]){int i,minPosition[antsPerFeature],maxPosition[antsPerFeature],flag[antsPerFeature],k,j,b[memory],infCount=0;float temp=0,tempRm[memory],tChoose=0,pContinueCurr=0;for(i=0;i<antsPerFeature;i++){minPosition[i]=0;maxPosition[i]=0;flag[i]=1;}for(k=0;k<antsPerFeature;k++){b[0]=0;for(i=1;i<memory;i++){if(Rm[k][i]<Rm[k][minPosition[k]])minPosition[k]=i;if(Rm[k][i]>Rm[k][maxPosition[k]])maxPosition[k]=i;if(Rm[k][i]==newRm[k]){flag[k]=0;break;}temp=(newRm[k]-Rm[k][i])*1.0/Rm[k][i];if(temp<0) temp=-1*temp;if(temp<minChange){flag[k]=0;break;}b[i]=i;}if(flag[k]==1){if(newRm[k]<Rm[k][maxPosition[k]]){for(j=0;j<features;j++)for(i=0;i<classes;i++){ants[k*classes*features+j*classes+i].Rm[maxPosition[k]]=ants[k*classes*features+j*classes+i].currPos;}Rm[k][maxPosition[k]]=newRm[k];}else{/* find min Rm and restore its position*/infCount=0;for(i=0;i<memory;i++){tempRm[i]=Rm[k][i];if(Rm[k][i]==inf) infCount++;}for(i=0;i<memory;i++)for(j=0;j<memory-1-i;j++){if(tempRm[j]>tempRm[j+1]){temp=tempRm[j];tempRm[j]=tempRm[j+1];tempRm[j+1]=temp;temp=b[j];b[j]=b[j+1];b[j+1]=temp;}}tChoose=drand48();if(tChoose<0.6){minPosition[k]=b[0];}else if (tChoose<0.8){minPosition[k]=b[1];}else if(tChoose<0.9){minPosition[k]=b[2];}else if(tChoose<0.975){minPosition[k]=b[3];}else {minPosition[k]=b[4];}pContinueCurr=drand48();if(pContinueCurr<tContinueCurr){/*for(j=0;j<features;j++)for(i=0;i<classes;i++){ants[k*classes*features+j*classes+i].Rm[maxPosition[k]]=ants[k*classes*features+j*classes+i].currPos;}Rm[k][maxPosition[k]]=newRm[k];*/}else if(Rm[k][minPosition[k]]!=inf)for(j=0;j<features;j++)for(i=0;i<classes;i++){ants[k*classes*features+j*classes+i].currPos=ants[k*classes*features+j*classes+i].Rm[minPosition[k]];}}}}}/* end of function *//********************************************************************//* Function to cluster according to the cluster centroids *//* Output: none *//* Input: ant structure and the data points *//* Global Structure Modified: none *//********************************************************************/void finalCluster(antdata* ants,float data[MAXDATA][features],float Rm[antsPerFeature][memory]){int i,j,position[MAXDATA],minPosition=0,k=0,l=0,minRm=0;float clsCenters[antsPerFeature][MAXDATA][features];float distance[MAXDATA];int cenCount[MAXDATA],classCount[MAXDATA][c];float temp=0;int clsObjects[MAXDATA][MAXDATA],label[MAXDATA];int minPosition1[antsPerFeature],maxPosition1[antsPerFeature];FILE *fp,*fpOut,*fpCls,*fpMinRm,*fpOrgClass,*fpRm;fp=fopen("fcmRm.out","a");fpOut=fopen("ClassData.out","a");fpCls=fopen("clsCenters.out","a");fpMinRm=fopen("minRm.out","a");fpOrgClass=fopen("orgClass.out","a");fpRm=fopen("Rm.out","a");if(fp==NULL){printf("\n Unable to open fcm output file \n");return;}for(k=0;k<antsPerFeature;k++){for(j=0;j<features;j++)for(i=0;i<classes;i++)clsCenters[k][i][j]=ants[k*classes*features+j*classes+i].currPos;minPosition1[k]=0;maxPosition1[k]=0;}for(k=0;k<antsPerFeature;k++){for(i=1;i<memory;i++){if(Rm[l][i]<Rm[l][minPosition1[l]])minPosition1[l]=i;if(Rm[l][i]>Rm[l][maxPosition1[l]])maxPosition1[l]=i;}}minRm=0;for(k=1;k<antsPerFeature;k++){if(Rm[k][minPosition1[k]]<Rm[minRm][minPosition1[minRm]])minRm=k;}fprintf(fpRm,"Rm %8.4f\n",Rm[minRm][minPosition1[minRm]]);fclose(fpRm);Fcm(data,clsCenters[minRm],2);hardenRm();for(l=0;l<antsPerFeature;l++){fprintf(fpCls,"Cluster number %2d\n",l);for(j=0;j<classes;j++){distance[j]=inf;cenCount[j]=0;for(k=0;k<c;k++)classCount[j][k]=0;}fprintf(fp,"* %d\n",l);if(l==minRm)fprintf(fpMinRm,"* %d\n",l);for(i=0;i<count;i++){minPosition=0;for(k=0;k<classes;k++){temp=0.0;for(j=0;j<features;j++)temp+= (clsCenters[l][k][j]-data[i][j])*(clsCenters[l][k][j]-data[i][j]);temp=sqrt(temp);distance[k]=temp;if(distance[k]<distance[minPosition])minPosition=k;}position[i]=minPosition;clsObjects[minPosition][cenCount[minPosition]]=i;cenCount[minPosition]++;}for(j=0;j<classes;j++){for(i=0;i<cenCount[j];i++)classCount[j][(int)orgData[clsObjects[j][i]][0]-1]++;}/* minPosition varaible re used , now minPosition denotes the maximum class of the cluster*/fprintf(fpOrgClass,"\nCluster number: %2d \n",l);for(j=0;j<classes;j++){minPosition=0;fprintf(fpOrgClass,"\n Cluster %2d \n",j+1);fprintf(fpOrgClass,"%2d %2d\n",1,classCount[j][0]);for(i=1;i<c;i++){if(classCount[j][i]>classCount[j][minPosition]) minPosition=i;label[j]=minPosition;fprintf(fpOrgClass,"%2d %2d\n",i+1,classCount[j][i]);}}for(i=0;i<count;i++){for(j=0;j<classes;j++)for(k=0;k<cenCount[j];k++)if(clsObjects[j][k]==i){fprintf(fp,"%d ",label[j]+1);break;}}fprintf(fp,"\n");fprintf(fpOut,"\nCluster number: %2d \n",l);for(i=0;i<classes;i++){fprintf(fpOut,"%2d %4d\n",label[i]+1,cenCount[i]);for(j=0;j<features;j++)fprintf(fpCls,"%8.7f ",clsCenters[l][i][j]/scale[j]+minInput[j]);fprintf(fpCls,"\n");}}/* Write the data to the file */fclose(fp);fclose(fpOut);fclose(fpCls);fclose(fpMinRm);fclose(fpOrgClass);}/* end of function *//********************************************************************//* Function to amnalyze the results *//* Output: none *//* Input: *//* Global Structure Modified: none *//********************************************************************/void analysis(int flag){int i,j,k,temp;char junk;int totalRuns=0,errors[antsPerFeature],epoch=0,position=0,antsperfeature=0,clsNumber=0,min=0,currMinRm;FILE *fp,*fpError,*fpMin,*fpMinRm,*fpMinIp;if(flag==1){fp=fopen("fcmRm.out","r");fpMinIp=fopen("minRm.out","r");fpMinRm=fopen("minRmError.out","w");fpError=fopen("error.out","w");fpMin=fopen("minError.out","w");}else{fp=fopen("fcmFCM.out","r");fpError=fopen("errorFCM.out","w");}if(fp==NULL||fpError==NULL){printf("\n unable to open files in the analysis module \n");return;}fscanf(fp,"%c %d\n",&junk,&totalRuns);fscanf(fp,"%c %d\n",&junk,&antsperfeature);if(flag==1){fscanf(fpMinIp,"%c %d\n",&junk,&temp);fscanf(fpMinIp,"%c %d\n",&junk,&temp);}for(i=0;i<totalRuns;i++){for(j=0;j<antsperfeature;j++){errors[j]=0;}fscanf(fp,"%c %d\n",&junk,&epoch);if(flag==1){fscanf(fpMinIp,"%c %d\n",&junk,&temp);fscanf(fpMinIp,"%c %d\n",&junk,&currMinRm);}fprintf(fpError,"Experiment %3d ",i);for(k=0;k<antsperfeature;k++){fscanf(fp,"%c %d\n",&junk,&clsNumber);for(j=0;j<count;j++){fscanf(fp,"%d ",&position);if(orgData[j][0]!=position)errors[k]++;}fscanf(fp,"\n");if(flag==1){fprintf(fpError,"\nCluster %3d Errors %5d",k,errors[k]);if(k==currMinRm){fprintf(fpMinRm,"Cluster %2d Errors %5d\n",k,errors[k]);}}else fprintf(fpError," Errors %5d\n",errors[k]);}if(flag==1){min=0;for(j=1;j<antsPerFeature;j++){if(errors[j]<errors[min])min=j;}fprintf(fpMin,"Exp %2d Min Error %5d\n",i,errors[min]);}}fclose(fp);fclose(fpError);if(flag==1){fclose(fpMin);fclose(fpMinRm);fclose(fpMinIp);}}/* end of function */ void RmStage(int heapCount,center clsCen) { FILE *fpTime=fopen("time.out","a");int flag[antsPerFeature],flg;struct rusage start_usage, end_usage,epoch_start_usage, epoch_end_usage;double *perf_times;float newRm[antsPerFeature],oldRm[antsPerFeature],temp;int i=0,j=0,k=0;initRm(heapCount);initializeAntsRm(newAnts,clsCen);for(i=0;i<antsPerFeature;i++){oldRm[i]=inf;newRm[i]=inf;}flg=1;i=0;getrusage(RUSAGE_SELF, &start_usage);while(i<maxEpocs){getrusage(RUSAGE_SELF, &epoch_start_usage);epoch(newAnts);getrusage(RUSAGE_SELF, &epoch_end_usage);perf_times=timing_of(epoch_start_usage,epoch_end_usage); fprintf(fpTime,"Epoch %3d Timing: %f user, %f system, %f total.\n",i, perf_times[0], perf_times[1], perf_times[0] +perf_times[1]);for(j=0;j<antsPerFeature;j++){oldRm[j]=newRm[j];flag[j]=1;}computeRm(newAnts,data,newRm);updateMemory(newAnts,newRm,Rm);flg=0;for(j=0;j<antsPerFeature;j++){if(newRm[j]!=inf){if(oldRm[j]!=inf){temp=0;temp=newRm[j]-oldRm[j]<0? (oldRm[j]-newRm[j]):(newRm[j]-oldRm[j]);/*printf("\n new %f old %f temp %f ",newRm[j],oldRm[j],temp);*/if(temp/oldRm[j]>minChange){flg=1;break;}}else flg=1;}}i++;printf("\n Epoch %d ",i);}/* Do the final clustering*/finalCluster(newAnts,data,Rm);getrusage(RUSAGE_SELF, &end_usage);perf_times=timing_of(start_usage,end_usage); fprintf(fpTime,"Exp %3d Timing: %f user, %f system, %f total.\n",k, perf_times[0], perf_times[1], perf_times[0] +perf_times[1]);/* Compute the error */} /****************************************************************/ void Fcm (objects X1,center V,int flag) { int i,j,l; FILE *ofile,*fpJm; FILE *iniClsCen=fopen("center.clt","a+"); char temp[80]; float jmFinal=0,rmFinal=0; Random_seed=state1[run];/*randseed*/ srand48(Random_seed); for(i=0;i<MAXDATA;i++) for(j=0;j<features;j++)X[i][j]=X1[i][j]; if(iniClsCen==NULL) { printf("\n Unable to open the initial cluster center file\n"); printf("\n choosing random cluster centers....\n"); flag=1; } for (run=0;run<TOTRUNS;run++) { if(flag!=2) { if (EntireHeaps) lCount=heapCount; else lCount=c; for(i=0;i<lCount;i++) for(j=0;j<s;j++) V[i][j]=0; for(i=0;i<lCount;i++) { for(l=0;l<s;l++) { if(flag==1) { rand_index = lrand48() % n; V[i][l] = X[rand_index][l]; } else { fscanf(iniClsCen,"%f ",&V[i][l]); } }//end for }}else lCount=heapCount;eps=0.001; stop = FALSE; /* This loop finds the final cluster center and the corresponding U values */ z = 0; while (stop == FALSE) { z++; UMAT(U,V,X); /** Update the U matrix **/stop = FINISHED(U1,eps); CLUSTER(U,X,V); /** Get new cluster center **/printf("\nIteration: %d \n",z); } /* end while */ printf("Number of iterations: %d\n\n", z);strcpy(temp,""); sprintf(temp,"%sFCM.out",filename);if(flag==1){jmFinal=Compute_Jm(V,X);rmFinal=Compute_Rm(V,X);fpJm=fopen("jm.out","a");fprintf(fpJm," classes %2d Jm: %10.6f Rm: %10.6f\n",lCount,jmFinal,rmFinal);fclose(fpJm);} if(flag==2) Output(temp,V,X); /* output the results */ }/*end for*/ ofile=fopen(temp,"a"); for (i=0; i <= mins; i++) fprintf(ofile, "Min %d of %10.3f occurred %d times\n", i, mintab[i], mincount[i]); fprintf(ofile, "Average iterations %f\n", (float)aveit/(float)TOTRUNS); fclose(ofile); }/* end Main */ /* The NORM function computes the norm of two vectors, x and v, of dimension s. This gives an indication of the distance between them */ float NORM( feature x, feature v) //feature x, v; { /* Parameters : x -- a local copy of an input vector v -- a local copy of a cluster center */ int i,j; /* loop variable */ double sum; /* the square root of sum is the norm; sum is the sum of the differences squared */ float mat1[features]; float mat2[features]; if (maha) { for (i=0; i<features; i++) mat1[i]=x[i]-v[i]; for(i=0;i<features;i++) { sum =0; for(j=0;j<features;j++) sum += mat1[j] * inv_cov[j][i]; mat2[i] = sum; } sum =0; for(j=0;j<features;j++) sum += mat1[j]*mat2[j]; } else { sum = 0; for(j=0;j<features;j++) sum += (x[j] - v[j])* (x[j] - v[j]); } return (float)(sqrt(sum)); } /* end NORM */ /* The UMAT procedure calculates the updated U matrix according to Bezdek's formula. Its side-effect is the update of the global array U1 */ void UMAT( matrix U,center V, objects X) /*matrix U; center V; objects X;*/ { /* Parameters: U, V, and X: same as in main program */ int i, j, k,l ;/* loop variables *///, class /* class whose cluster center //is closest to pattern k */; float d1,d2,d; float sum; int exact; for (k=0;k<MAXDATA;k++) { /*printf("\n k %d ",k);*/ exact=false; for (i=0;i<lCount;i++) { sum=0; for (j=0;j<lCount;j++) { d1=NORM(X[k],V[i]); d2=NORM(X[k],V[j]); if(d2!=0) { d= d1/d2; d= d * d;/* pow(d1/d2,2.0/(m-1.0)); */ sum+=d; } else { exact = true; for(l=0;l<lCount;l++) if (l==j) U1[l][k]=1.0; else U1[l][k]=0.0; break; } } if (exact!=true) U1[i][k]=1.0/sum; } } } /* end UMAT */ /* The function FINISHED determines if a termination occurs. If not it updates U with U1, so its side-effect is the potential modification of U */ BOOLEAN FINISHED( matrix U1,float eps) //matrix U1; float eps; { /* Parameters: U1, eps-- same as in main */ float sum; /* sum of squared differences between corresponding elements of U and U1 */ int i,k; /* loop control variabes */ BOOLEAN finished; /* set to true if all corresponding elements are within epsilon */ finished = TRUE; sum = 0; for (i=0; i<lCount; i++) for (k=0; k<MAXDATA; k++) sum += (U[i][k] - U1[i][k])*(U[i][k]-U1[i][k]); if (sqrt(sum) > eps) { finished = FALSE; for (i=0; i<lCount; i++) for (k=0; k<MAXDATA; k++) U[i][k] = U1[i][k]; } /* end if */ return finished; } /* end FINISHED */ /* The CLUSTER procedure determines cluster centers in V for the c classes being searched for. The global array V is updated */ void CLUSTER( matrix U, objects X,center V) //matrix U; objects X; { /* Parameters: U, X -- as in main */ int i, j, k; /* loop control variables */ feature num; /* numerator in the cluster center computation formula presented by Bezdek */ float denum; /* denumenator in the obove formula */ for (i=0; i<lCount; i++) { denum = 0; for (j=0; j<features; j++) { num[j] = 0; for (k=0; k<MAXDATA; k++) num[j] += U[i][k] * U[i][k] * X[k][j]; /* pow(U[i][k],m) * X[k][j]; */ } /* end for */ for (k=0; k<MAXDATA; k++) denum += U[i][k] * U[i][k]; /* pow(U[i][k],m); */ for (j=0; j<features; j++) V[i][j] = num[j] / denum; } /* end for */ } /* end CLUSTER */ float Compute_Jm(center V, objects X) //center V; //objects X; { int i, k,found; double Jm_value; float u,dik; Jm_value = 0; for (k=0; k<MAXDATA; k++) { found = FALSE; for (i=0; i<lCount; i++) { dik=NORM(X[k],V[i]); dik=dik*dik; if (dik==0.0) { if (found == FALSE) { u=1.0; found = TRUE; printf("found the case with dik=0\n"); } else { printf("\n cant proceed with this initialization"); exit(1); } } else { if (found != TRUE) u=U1[i][k]; /* get_Uvalue(V,X,dik,k); */ else u=0.0; } Jm_value += u * u * dik;/* pow(u, m) * dik; */ } } return (Jm_value); } /* end Compute_Jm */ /* The Output procedure outputs the U matrix which gives the fuzzy measure of each feature belonging to a cluster center. It also outputs the cluster center for each class */ void Output(char fname[],center V,objects X) //char fname[80]; /* Parameters: U, V -- same as in main */ { int i, j, found; /* loop control variables */ float J2c,R2c; FILE *fpJm=fopen("JmRm.out","a"),*fp; if ((fp=fopen(fname,"a"))==NULL) printf("\n CAN'T OPEN %s\n",fname); else { fprintf(fp,"\n \n"); for (i=0; i<lCount; i++) { fprintf(fp,"\n"); for (j=0; j<features; j++) fprintf(fp,"%4.3f ",V[i][j]); } /* end for */ } /* end if */ J2c= Compute_Jm(V,X); R2c=Compute_Rm(V,X); fprintf(fpJm,"Classes: %3d Jm: %10.6f Rm: %10.6f \n",lCount,J2c,R2c); found =0; for (i=0;i<= mins; i++) { if ((found == 0) && ((J2c - mintab[i]) < .001) && ((J2c - mintab[i]) > -.001)){ mincount[i]++; found = 1; } } if (found == 0) { mins++; mintab[mins]=J2c; mincount[mins]=1; } fprintf(fp,"\nJ%2d = %f", m,J2c); fprintf(fp, "Number of iterations: %d\n\n", z); aveit=aveit + z; fclose(fp); fclose(fpJm); } /***************************************************************/ void find_covar( ) { int i,j,k; float mean[features],sum; for (i=0;i<features;i++) mean[i]=0; for (i=0;i<features;i++) for (j=0;j<m;j++) mean[i]+=X[j][i]; for (i=0;i<features;i++) mean[i]/=m; for (i=0;i<features;i++) for (j=0;j<features;j++) { sum=0; for (k=0;k<m;k++) sum+=(X[k][i]-mean[i])*(X[k][j]-mean[j]); Y[i][j]=sum/m; } }float Compute_Rm(center V, objects X){int i=0,j=0,l=0;double Dik=0,temp=0,Rm=0;Rm=0;for(i=0;i<MAXDATA;i++){Dik=0;for(j=0;j<lCount;j++){temp=0;for(l=0;l<features;l++)temp+=(X[i][l]-V[j][l])*(X[i][l]-V[j][l]);/*temp=sqrt(temp);*//*temp=NORM(X[i],V[j]);temp=temp*temp;*/Dik+=pow(temp,1.0/(1-m));}Rm+=pow(Dik,(1-m));}return(Rm);}/* End of function *//********************************************************************/ /* Function to harden the outputs obtained from fcm(2nd stage)*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: Cluster center , cluster center count*/ /********************************************************************/void hardenRm() { FILE *fp=fopen("fcmFCM.out","a"); FILE *fpOut=fopen("ClassDataFCM.out","a"); int i=0,minPosition=-1,position[MAXDATA],j=0,k=0; int cenCount[MAXDATA],classCount[MAXDATA][c],label[c], clsObjects[MAXDATA][MAXDATA]; for(j=0;j<classes;j++) {cenCount[j]=0;for(k=0;k<classes;k++)classCount[j][k]=0; } for(i=0;i<MAXDATA;i++) { minPosition=findPosition(i); position[i]=minPosition;clsObjects[minPosition][cenCount[minPosition]]=i;cenCount[minPosition]++; } for(j=0;j<classes;j++) {for(i=0;i<cenCount[j];i++)classCount[j][(int)orgData[clsObjects[j][i]][0]-1]++; } /* minPosition varaible re used , now minPosition denotes the maximum class of the cluster*/for(j=0;j<classes;j++){minPosition=0;for(i=1;i<c;i++){if(classCount[j][i]>classCount[j][minPosition]) minPosition=i;label[j]=minPosition;}}fprintf(fp,"* %d\n",0);for(i=0;i<count;i++){for(j=0;j<classes;j++)for(k=0;k<cenCount[j];k++)if(clsObjects[j][k]==i){fprintf(fp,"%d ",label[j]+1);break;}}fprintf(fp,"\n");for(i=0;i<classes;i++){fprintf(fpOut,"%2d %4d\n",label[i]+1,cenCount[i]);}fclose(fpOut);fclose(fp);return; }/*end of function*/ /********************************************************************//* Function Main *//********************************************************************/ int main(int argc, char** argv){int k=0,i=0,j=0;int sum=0;char temp[80];FILE *fpRmOut=fopen("fcmRm.out","w");FILE *fpOut=fopen("ClassData.out","w");FILE *fpCls=fopen("clsCenters.out","w");FILE *fpMinRm=fopen("minRm.out","w");FILE *fpOrgClass=fopen("orgClass.out","w");FILE *fpRm=fopen("Rm.out","w");FILE *fpJmRm=fopen("JmRm.out","w");FILE *fp=fopen("fcm.out","w");FILE *fp1; FILE *fp2=fopen("antAnalysis.out","a");FILE *fp3=fopen("fcmAnalysis.out","a"); FILE *fp4=fopen("errors.out","w");FILE *fp5;FILE *fpJm=fopen("jm.out","w");FILE *fpTime=fopen("time.out","w");FILE *fpFCM=fopen("fcmFCM.out","w");FILE *fpOutFCM=fopen("ClassDataFCM.out","w");fprintf(fpFCM,"# %d\n",EXPRUN);fprintf(fpFCM,"@ %d\n",1);fclose(fpFCM);fclose(fpOutFCM);fclose(fp4);fclose(fpJm);sprintf(temp,"%sObj.out",filename);fp5=fopen(temp,"w");fclose(fp5);strcpy(temp,"");sprintf(temp,"%sTot.out",filename);fp5=fopen(temp,"w");fclose(fp5);strcpy(temp,"");sprintf(temp,"%sOp.out",filename);fp1=fopen(temp,"w");fprintf(fp,"\n$%d",EXPRUN);fprintf(fp1,"\n$%d",EXPRUN);fclose(fp);fclose(fp1);fclose(fpJmRm);fprintf(fpRmOut,"# %d\n",EXPRUN);fprintf(fpRmOut,"@ %d\n",antsPerFeature);fclose(fpRmOut);fprintf(fpTime,"Experiments %d\n",EXPRUN);fprintf(fpMinRm,"# %d\n",EXPRUN);fprintf(fpMinRm,"@ %d\n",antsPerFeature);fclose(fpMinRm);fclose(fpOut);fclose(fpCls);fclose(fpOrgClass);fclose(fpRm);fclose(fpTime);/*readInput();*/ if(argc==2)sscanf(argv[1],"%d",&debugLevel); printf("\n Debug level %d\n",debugLevel); for( i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; readInput(); readOrg(); //Compute the distance of all the points if(maxDist) { Dmax=computeDistance(); //Compute the maximum distance fp5=fopen("maxData.txt","w");fprintf(fp5,"%f",Dmax);fclose(fp5); } else {fp5=fopen("maxData.txt","r");fscanf(fp5,"%f",&Dmax);fclose(fp5); } printf("\n %f \n",Dmax); //Initialise the board for(k=0;k<EXPRUN;k++) { fpRmOut=fopen("fcmRm.out","a");fpOut=fopen("ClassData.out","a");fpCls=fopen("clsCenters.out","a");fpOrgClass=fopen("orgClass.out","a");fpMinRm=fopen("minRm.out","a");fpRm=fopen("Rm.out","a");fpTime=fopen("time.out","a");fpFCM=fopen("fcmFCM.out","a");fpOutFCM=fopen("ClassDataFCM.out","a");fprintf(fpFCM,"$ %d\n",k);fprintf(fpOutFCM,"Experiment %d\n",k);fprintf(fpRm,"Exp: %2d ",k);fclose(fpRm);fprintf(fpCls,"EXP No %2d \n",k);fclose(fpCls);fprintf(fpRmOut,"$ %d\n",k);fprintf(fpMinRm,"$ %d\n",k);fprintf(fpOut,"Experiment %d\n",k);fprintf(fpOrgClass,"Experiment %d\n",k);fprintf(fpTime,"Experiment %d\n",k);fclose(fpRmOut);fclose(fpOut);fclose(fpMinRm);fclose(fpOrgClass);fclose(fpTime); fclose(fpFCM);fclose(fpOutFCM); init(); sum=0; srand48(state1[k]); initialiseBoard(); initialise(1); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(1); printf("\n %d \n",heapCount); //Simulate the working of ants iterate(1); //drop the objects after all the iterations dropFinal(1); //to verify the correctness for(i=0;i<heapCount;i++) sum+=heaps[i].count; //write the cluster centers to the file writeClusterInformation(1); printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); //getchar(); //Run FCM // heapCount=2973;/* To be commented */ printf("\n\n k %d \n\n",k); Fcm(data,V,0); //compute new board size. lCount=heapCount; heapRow=(int)ceil(sqrt(4*heapCount)); newHeapCount=lCount; printf("\n LCount %d newHeapCount %d heap Row %d \n",lCount,newHeapCount,heapRow); //harden the objects harden(newHeaps); //iterate with the heaps as the objects. initialiseBoard(); initialise(0); for(i=0;i<lCount;i++) computeHeapParameters(&heaps[i],0); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(0); printf("\n %d \n",heapCount); //getchar(); //Simulate the working of ants iterate(0); dropFinal(0); writeClusterInformation(0); sum=0; for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); // getchar(); fpJm=fopen("jm.out","a"); fprintf(fpJm,"Experiment %2d: ",k); fclose(fpJm); Fcm(data,V,1); harden1(); RmStage(newHeapCount,V); } fp=fopen("fcm.out","a"); fp1=fopen(temp,"a"); fprintf(fp,"\n"); fprintf(fp1,"\n"); fclose(fp); fclose(fp1); fp=fopen("fcm.out","r"); fp1=fopen(temp,"r");printf("\n Before read org\n");printf("\nafter read org\n");readFCM(fp1,fp2);printf("\n After 1st read fcm\n");readFCM(fp,fp3);printf("\n After 2 fcm read \n");analysis(1);analysis(0);return(1); }//end of main
Parag Kanade/Combined Algorithm/combWoErr.c
#include "headerStatic.h" /********************************************************************/ /********************************************************************/ /* Function to read the input data set */ /* The file name is assumed to be itest.data */ /* Status: Tested */ /* Output: Data from the file into the "data" (Global) data structure */ /* Output: Count (Global), the count of the number of objects */ /********************************************************************/ void readInput() { FILE *fp; char fname[80]; int i=0,j=0; char ch; sprintf(fname,"%s.data",filename); /* Check if the input file is opened */ if((fp=fopen(fname,"r"))==NULL) { printf("\n Unable to open input file \n"); exit(0); } /*initialise the minimum maximum and the scale */ for(i=0;i<features;i++) { minInput[i]=1000; maxInput[i]=0; minForHeaps[i]=1000; maxForHeaps[i]=0; scale[i]=0; scaleForHeaps[i]=0; } /* Discard leading comments */ ch = 'c'; while (ch != '#') fscanf (fp, "%c", &ch); i=0; /* Parse the file and populate the data structure */ while(!feof(fp)) { for(j=0;j<features;j++) { fscanf(fp,"%f ",&data[i][j]); } fscanf(fp,"\n"); for(j=0;j<features;j++) { if(data[i][j]<minInput[j]) minInput[j]=data[i][j]; if(data[i][j]>maxInput[j]) maxInput[j]=data[i][j]; } i++; } count=i; /* Normailze the feature values in between 0 and 1 */ for(j=0;j<features;j++) { if(minInput[j]!=maxInput[j]) scale[j]=1.0/(maxInput[j]-minInput[j]); else scale[j]=1.0; } for(i=0;i<count;i++) { for(j=0;j<features;j++) data[i][j]=(data[i][j]-minInput[j])*scale[j]; } fclose(fp); return; }//end of function /********************************************************************/ /*Function to compute the eucldiean distance for all input data set */ /* Output : an array conatining the distance of each object with the other */ /********************************************************************/ float computeDistance() { float distance,dist=0; int i=0,j=0,k=0; distance=0; for(j=0;j<count;j++) for(i=0;i<count;i++) { for(k=0;k<features;k++) dist+=sqrt((data[j][k]-data[i][k])*(data[j][k]-data[i][k])); if(distance<dist)distance=dist; dist=0; } return(distance); } /********************************************************************/ /* Function to compute the distance between two objects */ /* Output : Euclidean d istance between the two input objects */ /********************************************************************/ float computeDistanceBetween2(irisData a,irisData b) { float temp=0; int i=0; for(i=0;i<features;i++) temp+=(a[i]-b[i])*(a[i]-b[i]); temp=sqrt(temp); return(temp); } /********************************************************************/ /* Function to compute the value of an object */ /********************************************************************/ float value(irisData a) { int i=0; float temp=0; for(i=0;i<features;i++) temp+=a[i]*a[i]; return(sqrt(temp)); } /********************************************************************/ /* Function to find the object in the data structure */ /* Output : The position of the object in the data */ /* Input : The object */ /********************************************************************/ int findInData(irisData object,int iFlag) { int i=0,lastCount=0,j,position=-1,flag[features],flg;if(iFlag==1)lastCount=MAXDATA;else{}for(i=0;i<lastCount;i++){ for(j=0;j<features;j++) if(fabs(object[j]-data[i][j])<0.00001) flag[j]=1; else { flag[j]=0; break;} flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /* Function to find whether there is an object on the board at a,b */ /* Output : a flag indicating whether an object is found or not */ /* Input : The row and column indicating the board position */ /********************************************************************/ int found(int a , int b) { if(board[a][b]==9) return 1; else return 0; } /********************************************************************/ /* Function to initialize the initial board */ /* Output : None */ /* Global Structures modified : heaps */ /* Input : Flag indicating the iteration 1: First 0: Second */ /********************************************************************/ void initialise(int flag) { int a,b,i=0,k=0; int loopCount,rowCount,colCount; /* Initialize the row, column and number of heaps */ if(flag==1) { loopCount=count; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=lCount; rowCount=heapRow; colCount=heapRow; } /* Initialize the heaps */ for(i=0;i<loopCount;i++) { heaps[i].count=0; heaps[i].x=0; heaps[i].y=0; heaps[i].disPosition=0; heaps[i].Dmax=0; heaps[i].Dmean=0; } for(i=0;i<loopCount;i++) { /*find a board position which is empty*/ do { a=lrand48()%rowCount; b=lrand48()%colCount; } while(found(a,b)); /*Allocate the object to that place and assign a heap to it*/ heaps[i].x=a; heaps[i].y=b; heaps[i].count=1; heaps[i].Dmax=0; heaps[i].Dmean=0; if(flag==1) { heaps[i].objects[0]=i; for(k=0;k<features;k++)heaps[i].Ocenter[k]=data[i][k]; } else { for(k=0;k<features;k++) heaps[i].Ocenter[k]=newHeaps[i].Ocenter[k]; } heaps[i].disPosition=0; board[a][b]=9; if((debugLevel>0)&&(flag==1))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],data[heaps[i].objects[0]][0]); if((debugLevel>0)&&(flag==0))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],newHeaps[i].Ocenter[0]); } /*initialise the initial heap count*/ heapCount=loopCount; currentRow=rowCount; } /********************************************************************/ /* Function to find whether an heap is present at the location a b */ /* Output : Flag indicating the presencs of the heap */ /* Input : Roe and column indicating the board position */ /********************************************************************/ int findObject(int a,int b) { int i; int position=-1; for(i=0;i<heapCount;i++) { if((heaps[i].x==a)&&(heaps[i].y==b)) { position=i; break; } } return(position); } /********************************************************************/ /* Function initialize the ants */ /* Output : None */ /* Input : Flag indicating the iteration */ /* Global Variables Modified : ant, heapCount, heaps, board */ /********************************************************************/ void initialiseAnts(int flag) { int i=0,a=0,b=0,position,j=0,loopCount=0,rowCount,colCount,k=0; if(flag==1) { loopCount=MAXANTS; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=MAXANTSFORHEAPS; rowCount=heapRow; colCount=heapRow; } for(i=0;i<loopCount;i++) { /*generate random positions for the ants*/ a=lrand48()%rowCount; b=lrand48()%colCount; ants[i].x=a; ants[i].y=b; /*Find if an object is present at that position or not*/ if(board[a][b]==9) { ants[i].carrying=1; /*find the heap at that location*/ position=findObject(a,b); if(position==-1) { printf("\n Error in logic: Ant init \n"); //getchar(); break; } else { /*Assign the heap data to the ant data and decrement the heap count*/ if(flag==1){ for(k=0;k<features;k++)ants[i].data[k]=data[heaps[position].objects[0]][k]; }else{for(k=0;k<features;k++)ants[i].data[k]=heaps[position].Ocenter[k];} for(j=position;j<heapCount-1;j++) heaps[j]=heaps[j+1]; heapCount--; } /*Clear the board position */ board[a][b]=-9; } else ants[i].carrying=-1; ants[i].speed=0; ants[i].dir=lrand48()%8; printf("\n Ant %2d X: %2d Y: %2d Carying : %2d ",i,ants[i].x,ants[i].y,ants[i].carrying); } currentAntCount=loopCount; } /********************************************************************/ /* Function to move the ant */ /* Output: None */ /* Input: Ant to be moved and the flag indicating the iteration */ /********************************************************************/ void moveNext(ant* a,int flag) { int rowCount,colCount; rowCount=currentRow;colCount=currentRow; /*Depending upon the direction move the ant*/ switch (a->dir) { case 0: a->y++; if(a->y>=colCount)a->y=0; break; case 1: a->x--; a->y++;; if(a->x<0)a->x=rowCount-1; if(a->y>=colCount)a->y=0; break; case 2: a->x--; if(a->x<0)a->x=rowCount-1; break; case 3: a->x--; a->y--; if(a->x<0)a->x=rowCount-1; if(a->y<0)a->y=colCount-1; break; case 4: a->y--; if(a->y<0)a->y=colCount-1; break; case 5: a->x++; a->y--; if(a->x>=rowCount)a->x=0; if(a->y<0)a->y=colCount-1; break; case 6: a->x++; if(a->x>=rowCount) a->x=0; break; case 7: a->x++; a->y++; if(a->x>=rowCount)a->x=0; if(a->y>=colCount)a->y=0; break; } }//end of function /********************************************************************/ /* Function to compute the parameters of the heap */ /* Output: None */ /* Input: The heap whose parameters are to be computed iteration flag*/ /********************************************************************/ void computeHeapParameters(heap* heapData,int flag) { int i=0,j=0,k=0,position=0; float distance=0; float Dmean=0.0; float *dis; float featureSum[features]; float max=0; float sum=0; /* init*/ for(k=0;k<features;k++) featureSum[k]=0; /*Compute the distance of each object and find the maximum distance*/ max=0; if(flag==1){ for(j=0;j<heapData->count;j++) for(i=0;i<heapData->count;i++) { for(k=0;k<features;k++) sum+= (data[heapData->objects[j]][k]-data[heapData->objects[i]][k])*(data[heapData->objects[j]][k]-data[heapData->objects[i]][k]); distance=sqrt(sum); if(max<distance) max=distance; sum=0; } /* Assign the maximum distance to the heap */ heapData->Dmax=max;/*Compute the centre object*/for(i=0;i<heapData->count;i++)for(k=0;k<features;k++) featureSum[k]+=data[heapData->objects[i]][k];for(k=0;k<features;k++)heapData->Ocenter[k]=featureSum[k]*1.0/heapData->count; /* Find the mean distance */if((dis=(float *) calloc(heapData->count,sizeof(float)))==NULL){printf("\nUnable to allocate memory in the compute heap parameters procedure\n");exit(0);} for(i=0;i<heapData->count;i++) { Dmean+=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); dis[i]=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); } heapData->Dmean=Dmean*1.0/heapData->count; /*Compute the most dissimilar object*/ max=dis[0]; for(i=1;i<heapData->count;i++) if(max<dis[i]) { max=dis[i]; position=i; } /*Assign the most dissimilar object to the heap variable*/ for(k=0;k<features;k++) heapData->Odissim[k]=data[heapData->objects[position]][k]; heapData->disPosition=position;free(dis); } else{/* Heap Parameters for the second stage */for(k=0;k<features;k++){ heapData->Odissim[k]=heapData->Ocenter[k];}heapData->disPosition=0;heapData->Dmean=0;heapData->Dmax=0;} }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a single object*/ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject1(ant *a,int position,int flag) { int i,k=0; /*Clear the board*/ board[heaps[position].x][heaps[position].y]=-9; /* Assign the data to the ant*/if(flag==1){ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[0]][k];}else {for(k=0;k<features;k++) a->data[k]=heaps[position].Ocenter[k];} a->carrying=1; /*Copy all the heaps remaining heaps in the structure*/ for(i=position;i<heapCount-1;i++) heaps[i]=heaps[i+1]; /*Decrement the heap count*/ heapCount--; }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a two objects */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject2(ant *a , int position,int flag) { float Pdestroy1=-1; int i=0,k=0; /*Compute the probability to destroy the heap*/ Pdestroy1=lrand48()%13*1.0/12.0; /*If the probability is more than Pdestroy then destroy the heap */ if(Pdestroy1<Pdestroy) { /*pick the object randomly*/ i=lrand48()%2; /* Assign the data to the ant */ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[i]][k]; a->carrying=1; /*Correct the heap parameters*/ heaps[position].count=1; heaps[position].objects[0]=heaps[position].objects[1-i]; computeHeapParameters(&heaps[position],flag); } }//end of function /********************************************************************/ /*Function to pick a object from a heap consisting of more than two object */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /********************************************************************/ void pickObjectn(ant *a,int position,int flag) { int i=0,k=0; /*If the criteria is satsfied then pick the object*/ if((computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)*1.0/heaps[position].Dmean)>Tremove) { a->carrying=1; for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[heaps[position].disPosition]][k]; for(i=heaps[position].disPosition;i<heaps[position].count-1;i++) heaps[position].objects[i]=heaps[position].objects[i+1]; heaps[position].count--; computeHeapParameters(&heaps[position],1); } }//end of function /********************************************************************/ /* Function to pick a object */ /********************************************************************/ void pick(ant *a,int flag) { int position=-1,i=0; float Pload1=-1.0; for(i=0;i<heapCount;i++) { /*Check if a heap is present in the eight neighbouring cells*/ if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if Heap is found*/ if(position!=-1) { /* heap or object found.*/ /*Depending upon the number present in the heap call the corresponding routine*/ switch(heaps[i].count) { case 1: Pload1 = lrand48()%151*1.0/150.0; if(Pload1<Pload) { pickObject1(a,position,flag); } break; case 2: pickObject2(a,position,flag); break; default: pickObjectn(a,position,flag); break; } } } /********************************************************************/ /* Function to drop a object to form a new heap */ /* Output: None */ /* Input: Ant, iteration flag */ /* Global Structure modified : heap, heapCount */ /********************************************************************/ void dropObject(ant* a,int flag) { /*Create a new heap*/ int k=0; heaps[heapCount].count=1; heaps[heapCount].x=a->x; heaps[heapCount].y=a->y; heaps[heapCount].Dmax=0; heaps[heapCount].Dmean=0; heaps[heapCount].disPosition=0; for(k=0;k<features;k++) { heaps[heapCount].Odissim[k]=a->data[k]; heaps[heapCount].Ocenter[k]=a->data[k]; } if(flag==1) {heaps[heapCount].objects[0]=findInData(a->data,flag); /*computeHeapParameters(&heaps[heapCount],flag);*/ } computeHeapParameters(&heaps[heapCount],flag); heapCount++; a->carrying=-1; board[a->x][a->y]=9; }//end of function /********************************************************************/ /* Function to find the heap position during the second iteration */ /* Output: position of the heap */ /* Input: object center of the heap that the ant is carrying */ /* Global Structure modified : none */ /********************************************************************/ int findInNewheaps(irisData object) { int position=-1,i,j=0,flag[features],flg; for(i=0;i<newHeapCount;i++) { for(j=0;j<features;j++) { if(fabs(object[j]-newHeaps[i].Ocenter[j])<0.00001) flag[j]=1; else {flag[j]=0;break;} } flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /*Function to drop a object to a heap consisting of a one or more object */ /* Output: none */ /* Input: Ant, position of the heap , iteration flag */ /* Global Structure modified: heaps,newHeaps */ /********************************************************************/ void dropObject1(ant* a, int position,int flag) { int heapPosition=-1,heapPosition1=-1,i,j,k=0; irisData newData,temp; if(flag==1) { heaps[position].objects[heaps[position].count]=findInData(a->data,flag); heaps[position].count++; computeHeapParameters(&heaps[position],flag); } else { for(k=0;k<features;k++)temp[k]=heaps[position].Ocenter[k]; heapPosition=findInNewheaps(a->data); heapPosition1=findInNewheaps(heaps[position].Ocenter); if(heapPosition==-1||heapPosition1==-1) { printf("\n error in logic:new heaps\n"); //getchar(); return; } for(k=0;k<features;k++) {newData[k]=(newHeaps[heapPosition].Ocenter[k]*newHeaps[heapPosition].count+newHeaps[heapPosition1].Ocenter[k]*newHeaps[heapPosition1].count)*1.0/(newHeaps[heapPosition].count+newHeaps[heapPosition1].count);newHeaps[heapPosition].Ocenter[k]=newData[k];heaps[position].Ocenter[k]=newData[k]; } computeHeapParameters(&heaps[position],flag); for(i=newHeaps[heapPosition].count,j=0;j<newHeaps[heapPosition1].count;i++,j++) { newHeaps[heapPosition].objects[i]=newHeaps[heapPosition1].objects[j]; } newHeaps[heapPosition].count+=newHeaps[heapPosition1].count; for(i=heapPosition1;i<newHeapCount-1;i++) newHeaps[i]=newHeaps[i+1]; newHeapCount--; } a->carrying=-1; }//end of function /********************************************************************/ /* Function to drop a object */ /* Output: None */ /* Input: Ant, iteration flag */ /********************************************************************/ void drop(ant* a,int flag) { int i, position=-1; float Pdrop1=0.0; /*Find whether we have a heap in the neighbourhood of the cell*/ for(i=0;i<heapCount;i++) { if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if a heap is found*/ if(position!=-1) { /*heap or object found.*/ /*Depending on the number of objects present take action*/ switch(heaps[position].count) { /*If criteria is satisfied then drop the object*/ case 1: if(flag==1) { if((computeDistanceBetween2(a->data,data[heaps[position].objects[0]])*1.0/Dmax)<Tcreate) dropObject1(a,position,flag); } else { if((computeDistanceBetween2(a->data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) dropObject1(a,position,flag); } break; default: if(computeDistanceBetween2(a->data,heaps[position].Ocenter)<computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)) dropObject1(a,position,flag); break; } } else { /*Compute the probability to drop the object*/ Pdrop1 = lrand48()%151*1.0/150; if(Pdrop1<Pdrop) dropObject(a,flag); } }//end of function /********************************************************************/ /* Function to move the ant */ /* Output: none */ /* Input: Ant, iteration flag */ /********************************************************************/ void move(ant* a,int flag) { float pDir; /*Check the speed */ if (a->speed!=0) { /*move in the same direction*/ a->speed--; moveNext(a,flag); } else { /*generate the new direction*/ pDir=lrand48()%17*1.0/16.0; if(pDir<.85) { a->dir=lrand48()%8; } else if(pDir>.95) { a->speed=2; } moveNext(a,flag); } } /********************************************************************/ /* Function to simulate the movement of the ants */ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified: minHeapCount, minHeapPosition */ /********************************************************************/ void iterate(int flag) { int i=0,j=0,k=0,loopCount=0; if (flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS; while (i<MAXITERATIONS) { i++; for(j=0;j<loopCount;j++) { move(&ants[j],flag); if(ants[j].carrying==1) { drop(&ants[j],flag); } else { pick(&ants[j],flag); } } if(debugLevel>0){ for(k=0;k<heapCount;k++) for(j=0;j<heapCount;j++) if((k!=j)&&(heaps[k].x==heaps[j].x)&&(heaps[k].y==heaps[j].y)) { printf("\nerror two heaps with same co ordinates %d %d ",k,j); //getchar(); } k=0; for(j=0;j<heapCount;j++) k+=heaps[j].count; } if(heapCount<minHeapCount) { minHeapCount=heapCount; minPosition=i; } if(debugLevel>0) printf("\n i:%d Heap count %d sum %d",i,heapCount,k); else printf("\n i:%d Heap count %d",i,heapCount); heapSum+=heapCount; } }//end of function /********************************************************************/ /*Function to drop the objects carried by the ants after all the iterations*/ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified:none */ /********************************************************************/ void dropFinal(int flag) { int i=0,j=0,position=-1,loopCount=0; loopCount=currentAntCount; for(i=0;i<loopCount;i++) { if(ants[i].carrying==1) { if(flag==1) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position,flag); } } else { /*Find if a heap is present */ do { position=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position,flag); position=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position!=-1); } } } }//end of function /********************************************************************/ /* Function for the implementation of QuickSort */ /* Output: none */ /* Input: data structure, low and high indices */ /* Global structure modified:none */ /********************************************************************/ void quickSort( heap A[], int low,int high ) { int mid=0; if(low<high) { mid=partition(A,low,high); quickSort(A,low,mid); quickSort(A,mid+1,high); } } /********************************************************************/ /* Partition routine used by quick sort */ /* Output: partition location */ /* Input: data , low, high */ /* Global structure modified:none */ /********************************************************************/ int partition(heap a[], int low,int high) { heap temp; int x=0,i=0,j=0; i=low; j=high; x=a[low].count; while (1) { while (a[j].count<x) j=j-1; while (a[i].count>x) i=i+1; if(i<j) { temp=a[i]; a[i]=a[j]; a[j--]=temp; } else return(j); } } /********************************************************************/ /* Function used to write the cluster information */ /* Output: none */ /* Input:iteration flag */ /* Global structure modified:none */ /********************************************************************/ void writeClusterInformation(int flag) { FILE *fp=fopen("center.clt","w"); FILE *fp1; FILE *fp2; FILE *fp3; char temp[80]; int i=0,j=0,k=0; int lastCount=0; int rowCount,colCount,antCount; strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp3=fopen(temp,"a"); if(dataDump) {strcpy(temp,"");sprintf(temp,"%sTot.out",filename);fp1=fopen(temp,"a");strcpy(temp,"");sprintf(temp,"%sObj.out",filename);fp2=fopen(temp,"a");if(fp1==NULL||fp2==NULL)printf("\n Error in opening file in the writer Cluster Information routine\n"); } rowCount=currentRow; colCount=currentRow; antCount=currentAntCount; if(fp==NULL) { printf("\n Unable to open cluster center output file \n"); /*return;*/ exit(0); } /*sort the array according to the count value and write the value of the top three elements*/ if((flag==1)&&(!EntireHeaps)) quickSort(heaps,0,heapCount); if(EntireHeaps) {if(flag==1) lastCount=heapCount;else lastCount=newHeapCount; } else lastCount=c; for(i=0;i<lastCount;i++) { if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else { for(k=0;k<features;k++) { fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",newHeaps[i].Ocenter[k]); fprintf(fp,"\n"); } else { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); fprintf(fp,"\n"); } } if(dataDump) { fprintf(fp1,"\n Information from the Ant Based Algorithm \n"); fprintf(fp1,"\n Important Parameters : Board %d X %d Ants : %d Iterations %d Total Heaps %d ",rowCount,colCount,antCount,MAXITERATIONS,lastCount); } if(flag==0) { if(dataDump) { fprintf(fp1," TCreateForHeaps %f \n",TcreateForHeaps); fprintf(fp2,"\nTotal Heaps : %d\n",heapCount); fprintf(fp2,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); } fprintf(fp3,"\n@ %d\n",lastCount); } else if(dataDump) fprintf(fp1,"\n");if(dataDump) { fprintf(fp1,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); for(i=0;i<lastCount;i++) if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp2,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); } fprintf(fp1," %5d\n",newHeaps[i].count); fprintf(fp2," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp1," %5d\n",heaps[i].count); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]); fprintf(fp1," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]); fprintf(fp1," %5d\n",heaps[i].count); }} if(flag==0) { if(dataDump) fprintf(fp1,"\n Objects in the heaps \n");for(i=0;i<newHeapCount;i++) { if(dataDump) fprintf(fp1,"\n\n Heap %d\n \n",i+1);fprintf(fp3,"# %d %d\n",i ,newHeaps[i].count); for(j=0;j<newHeaps[i].count;j++){ for(k=0;k<features;k++){ fprintf(fp3,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]); if(dataDump) fprintf(fp1,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]);} if(dataDump) fprintf(fp1,"\n"); fprintf(fp3,"\n"); } } } fclose(fp); fclose(fp3); if(dataDump) { fclose(fp1);fclose(fp2); }}//end of flie /********************************************************************/ /* Function to initialise the new heaps */ /* Output: none */ /* Input:new Heap structure */ /* Global structure modified:none */ /********************************************************************/ void initialiseNewHeaps(heap newHeaps[]) { int i=0,j=0; for(i=0;i<lCount;i++) { newHeaps[i].count=0; for(j=0;j<features;j++) newHeaps[i].Ocenter[j]=V[i][j]; newHeaps[i].x=heaps[i].x; newHeaps[i].y=heaps[i].y; } }//end of function /********************************************************************/ /* Function to initialise the new heaps */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ int findPosition(int i) { int j,position=0; for(j=1;j<lCount;j++) { if(U[j][i]>U[position][i]) position=j; } /*printf("\n Position %d ",position);*/ return(position); }//end of function find position /********************************************************************/ /* Function to add object */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ void addObject(int object,heap * heapPosition) { heapPosition->objects[heapPosition->count]=object; heapPosition->count++; }//end of function add object /********************************************************************/ /* Function to harden the outputs obtained from fcm */ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/ void harden(heap newHeaps[]) { int i,heapPosition=-1,sum=0,j=0; /*initialise the new heaps*/ initialiseNewHeaps(newHeaps); for(i=0;i<count;i++) { heapPosition=findPosition(i); addObject(i,&newHeaps[heapPosition]); } /* To check for degenerate partitions*/ for(i=0;i<lCount;i++) { if(newHeaps[i].count==0){for(j=i;j<lCount-1;j++){newHeaps[j]=newHeaps[j+1];}lCount--;i--;} } newHeapCount=lCount; for(i=0;i<lCount;i++) computeHeapParameters(&newHeaps[i],1); if(debugLevel>0) { for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\n sum = %d",sum);} }//end of function/********************************************************************/ /* Function to initialize the initial parameters for the ant algorithm*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void init() { int i=0,j=0; for(i=0;i<MAXROWS;i++) for(j=0;j<MAXCOLS;j++) board[i][j]=-9; heapCount=0; newHeapCount=0; heapRow=0; minPosition=-1; minHeapCount=100000; for(i=0;i<MAXANTS;i++) { ants[i].carrying=-1; ants[i].x=-1; ants[i].y=-1; ants[i].speed=-1; ants[i].dir=-1; } } /********************************************************************/ /* Function to initialize the initial board */ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void initialiseBoard() { int i,j; for(i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; }/********************************************************************/ /* Function to harden the outputs obtained from fcm(2nd stage)*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: Cluster center , cluster center count*/ /********************************************************************/void harden1() { int i=0,heapPosition=-1; for(i=0;i<heapCount;i++) cenCount[i]=0; for(i=0;i<n;i++) { heapPosition=findPosition1(i); addObject1(i,heapPosition); } writeInfo(); }//end of function/********************************************************************/ /* Function to find to which class the object belongs */ /* Output: Class number */ /* Input: object position */ /* Global Structure Modified: None */ /********************************************************************/int findPosition1(int i) { int j,position=0; for(j=1;j<heapCount;j++) { if(U[j][i]>U[position][i]) position=j; } return(position); }//end of function find position/********************************************************************/ /* Function to Write the output of the hardened objects to file*/ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/void writeInfo(){int i=0,j=0,k=0;FILE *fp=fopen("fcm.out","a");if(fp==NULL){printf("\n Unable to open fcm output file \n");return;}fprintf(fp,"\n@ %d\n",heapCount);for(i=0;i<heapCount;i++){fprintf(fp,"# %d %d\n",i,cenCount[i]);for(j=0;j<cenCount[i];j++){for(k=0;k<s;k++)fprintf(fp,"%8.2f ",clsCen[i][j][k]/scale[k]+minInput[k]);fprintf(fp,"\n");}}fclose(fp);return;}/********************************************************************/ /* Function to add a object to a cluster (2nd stage) */ /* Output: none */ /* Input: object poistion , cluster position */ /* Global Structure Modified: Cluster object and cluster count*/ /*******************************************************************/void addObject1(int object,int heapPosition) { int k=0; for(k=0;k<features;k++) clsCen[heapPosition][cenCount[heapPosition]][k]=X[object][k]; cenCount[heapPosition]++; return; }//end of function add object/********************************************************************/ /* Function to read the original classification of objects */ /* Output: none */ /* Input: none */ /* Global Structure Modified: None */ /*******************************************************************/void readOrg(){int i=0,k=0;char temp[80];FILE *fp;strcpy(temp,"");sprintf(temp,"%sFull.data",filename);fp=fopen(temp,"r");if(fp==NULL){printf("\n Unable to open full data input file ");exit(0);}for(i=0;i<n;i++){fscanf(fp,"%f ",&orgData[i][0]);for(k=1;k<s+1;k++)fscanf(fp,"%f ",&orgData[i][k]);}return;}// end of function/********************************************************************/ /* Function to classify the objects in different clusters */ /* Output: none */ /* Input: the cluster objects, the original classification, */ /* number of objects in the cluster,file to write the data */ /* Global Structure Modified: None *//********************************************************************/int analysisData(float data[][s],float orgData[n][s+1],int count,FILE * fp){int i=0,j=0,k=0,type=1,max=0;heapInfo info;for(i=0;i<c;i++){info.classObj[i]=0;}info.total=0;info.total=count;for(i=0;i<count;i++)for(j=0;j<n;j++){type=1;for(k=0;k<s;k++)if(fabs(data[i][k]-orgData[j][k+1])>errThresh){type=-1;break;}if(type!=-1){info.classObj[(int)orgData[j][0]-1]++;break;}}max=0;for(k=0;k<c;k++){if(info.classObj[k]>info.classObj[max])max=k;fprintf(fp,"\nClass %d Objects % d ",k+1,info.classObj[k]);}j=0;for(k=0;k<c;k++){if(k!=max)j+=info.classObj[k];}fprintf(fp,"\n Total errors : %d \n",j);return(j);}//end of analyse/********************************************************************/ /* Function to read the cluster information */ /* Output: none */ /* Input: input file pointer , output file pointer */ /* Global Structure Modified: None *//********************************************************************/void readFCM(FILE* fp,FILE *fp1){int i=0,j=0,k=0,l=0;int totalRuns=0,heapCount=0,junk=0,sum=0;char ch;FILE *fp2=fopen("errors.out","a");ch = 'c'; while (ch != '$') fscanf (fp, "%c", &ch);fscanf(fp,"%d\n",&totalRuns);printf("\n total runs %d ",totalRuns);for(l=0;l<totalRuns;l++){fscanf(fp,"%c",&ch);fscanf(fp,"%d\n",&heapCount);fprintf(fp1,"\n \nExperiment %d \n ",l+1);sum=0;for(i=0;i<heapCount;i++){fscanf(fp,"%c",&ch);fscanf(fp," %d %d\n",&junk,&clsCenCount[i]);for(j=0;j<clsCenCount[i];j++)for(k=0;k<s;k++)fscanf(fp,"%f",&fcmData[i][j][k]);fscanf(fp,"\n");fprintf(fp1,"\n\n Heap %d Total Objects %d \n",i+1,clsCenCount[i]);sum+=analysisData(fcmData[i],orgData,clsCenCount[i],fp1);}fprintf(fp2," %3d %3d %3d \n",l,sum,heapCount);}fprintf(fp2,"\n --------------------------\n");fclose(fp2);return;}//end of function void initRm(int heapCount) { antCount=heapCount*antsPerFeature*features;classes=heapCount;newAnts=(antdata*) calloc(antCount,sizeof(antdata));if(ants==NULL){printf("\n Cannot allocate memory to ants in Rm stage");printf("\n Exiting ... ");exit(-1);}} /***************************************************************************//* Function to initialise the ants *//* Status: under developement *//* Output: the ant structure is modified with initial random values *//* Input : Ant structure (this is modified) *//***************************************************************************/void initializeAntsRm(antdata* ants,center clsCen){int i,j,k;/* Initialize all the ants with initial values and the rest and direction*/for(i=0;i<antCount;i++){ants[i].currPos=drand48();for(j=0;j<memory;j++){ants[i].Rm[j]=inf;for(k=0;k<antsPerFeature;k++)Rm[k][j]=inf;}ants[i].rest=1;ants[i].direction=drand48()<0.5?1:-1;}for(j=0;j<features;j++)for(i=0;i<classes;i++){ants[j*classes+i].currPos=clsCen[i][j];}}/*end of function*//***************************************************************************//* Function that runs one epoch *//* Status: under developement *//* Output: the ant structure is modified with according to the epoch *//* Input : Ant structure (this is modified) *//***************************************************************************/void epoch(antdata* ants){int i,j;float Trest=0,Tcontinue=0,Tinc=0;float dDiff=0.0;float temp=0;dDiff=DmaxRm-Dmin;for(j=0;j<iterations;j++){for(i=0;i<antCount;i++){if(ants[i].rest!=0){Trest=drand48();if(Trest<Prest){ants[i].rest=0;continue;}Tcontinue=drand48();if(Tcontinue>Pcontinue)ants[i].direction=-1*ants[i].direction;Tinc=drand48();temp=ants[i].currPos+ants[i].direction*(Dmin+Tinc*dDiff);if(temp>1||temp<0)ants[i].direction=-1*ants[i].direction;ants[i].currPos+=ants[i].direction*(Dmin+Tinc*dDiff);}}}for(i=0;i<antCount;i++)ants[i].rest=1;}/*end of function*//***************************************************************************//* Function that computes Rm *//* Status: under developement *//* Output: the ant structure is modified, the worst Rm is removed *//* Input : Ant structure (this is modified) *//***************************************************************************/void computeRm(antdata* ants,float data[MAXDATA][features],float newRm[antsPerFeature]){int i,j,k=0,l=0;float clsCenters[antsPerFeature][MAXDATA][features];double Rm=0.0,temp=0.0,Dik=0;for(k=0;k<antsPerFeature;k++)for(j=0;j<features;j++)for(i=0;i<classes;i++){clsCenters[k][i][j]=ants[k*classes*features+j*classes+i].currPos;}for(k=0;k<antsPerFeature;k++){Rm=0;for(i=0;i<count;i++){Dik=0;for(j=0;j<classes;j++){temp=0;for(l=0;l<features;l++)temp+=(data[i][l]-clsCenters[k][j][l])*(data[i][l]-clsCenters[k][j][l]);/*temp=sqrt(temp);*//*temp=NORM(data[i],clsCenters[k][j]);temp=temp*temp;*/Dik+=pow(temp,1.0/(1-m));}Rm+=pow(Dik,(1-m));}newRm[k]=Rm;}return;}/*end of function*//********************************************************************//* Function to update the memory of the ants *//* Output: none *//* Input: ant structure and the new Rm, old memory *//* Global Structure Modified: none *//********************************************************************/void updateMemory(antdata* ants,float newRm[antsPerFeature],float Rm[antsPerFeature][memory]){int i,minPosition[antsPerFeature],maxPosition[antsPerFeature],flag[antsPerFeature],k,j,b[memory],infCount=0;float temp=0,tempRm[memory],tChoose=0,pContinueCurr=0;for(i=0;i<antsPerFeature;i++){minPosition[i]=0;maxPosition[i]=0;flag[i]=1;}for(k=0;k<antsPerFeature;k++){b[0]=0;for(i=1;i<memory;i++){if(Rm[k][i]<Rm[k][minPosition[k]])minPosition[k]=i;if(Rm[k][i]>Rm[k][maxPosition[k]])maxPosition[k]=i;if(Rm[k][i]==newRm[k]){flag[k]=0;break;}temp=(newRm[k]-Rm[k][i])*1.0/Rm[k][i];if(temp<0) temp=-1*temp;if(temp<minChange){flag[k]=0;break;}b[i]=i;}if(flag[k]==1){if(newRm[k]<Rm[k][maxPosition[k]]){for(j=0;j<features;j++)for(i=0;i<classes;i++){ants[k*classes*features+j*classes+i].Rm[maxPosition[k]]=ants[k*classes*features+j*classes+i].currPos;}Rm[k][maxPosition[k]]=newRm[k];}else{/* find min Rm and restore its position*/infCount=0;for(i=0;i<memory;i++){tempRm[i]=Rm[k][i];if(Rm[k][i]==inf) infCount++;}for(i=0;i<memory;i++)for(j=0;j<memory-1-i;j++){if(tempRm[j]>tempRm[j+1]){temp=tempRm[j];tempRm[j]=tempRm[j+1];tempRm[j+1]=temp;temp=b[j];b[j]=b[j+1];b[j+1]=temp;}}tChoose=drand48();if(tChoose<0.6){minPosition[k]=b[0];}else if (tChoose<0.8){minPosition[k]=b[1];}else if(tChoose<0.9){minPosition[k]=b[2];}else if(tChoose<0.975){minPosition[k]=b[3];}else {minPosition[k]=b[4];}pContinueCurr=drand48();if(pContinueCurr<tContinueCurr){/*for(j=0;j<features;j++)for(i=0;i<classes;i++){ants[k*classes*features+j*classes+i].Rm[maxPosition[k]]=ants[k*classes*features+j*classes+i].currPos;}Rm[k][maxPosition[k]]=newRm[k];*/}else if(Rm[k][minPosition[k]]!=inf)for(j=0;j<features;j++)for(i=0;i<classes;i++){ants[k*classes*features+j*classes+i].currPos=ants[k*classes*features+j*classes+i].Rm[minPosition[k]];}}}}}/* end of function *//********************************************************************//* Function to cluster according to the cluster centroids *//* Output: none *//* Input: ant structure and the data points *//* Global Structure Modified: none *//********************************************************************/void finalCluster(antdata* ants,float data[MAXDATA][features],float Rm[antsPerFeature][memory]){int i,j,position[MAXDATA],minPosition=0,k=0,l=0,minRm=0;float clsCenters[antsPerFeature][MAXDATA][features];float distance[MAXDATA];int cenCount[MAXDATA],classCount[MAXDATA][c];float temp=0;int clsObjects[MAXDATA][MAXDATA],label[MAXDATA];int minPosition1[antsPerFeature],maxPosition1[antsPerFeature];FILE *fp,*fpOut,*fpCls,*fpMinRm,*fpOrgClass,*fpRm;fp=fopen("fcmRm.out","a");fpOut=fopen("ClassData.out","a");fpCls=fopen("clsCenters.out","a");fpMinRm=fopen("minRm.out","a");fpOrgClass=fopen("orgClass.out","a");fpRm=fopen("Rm.out","a");if(fp==NULL){printf("\n Unable to open fcm output file \n");return;}for(k=0;k<antsPerFeature;k++){for(j=0;j<features;j++)for(i=0;i<classes;i++)clsCenters[k][i][j]=ants[k*classes*features+j*classes+i].currPos;minPosition1[k]=0;maxPosition1[k]=0;}for(k=0;k<antsPerFeature;k++){for(i=1;i<memory;i++){if(Rm[l][i]<Rm[l][minPosition1[l]])minPosition1[l]=i;if(Rm[l][i]>Rm[l][maxPosition1[l]])maxPosition1[l]=i;}}minRm=0;for(k=1;k<antsPerFeature;k++){if(Rm[k][minPosition1[k]]<Rm[minRm][minPosition1[minRm]])minRm=k;}fprintf(fpRm,"Rm %8.4f\n",Rm[minRm][minPosition1[minRm]]);fclose(fpRm);Fcm(data,clsCenters[minRm],2);hardenRm();for(l=0;l<antsPerFeature;l++){fprintf(fpCls,"Cluster number %2d\n",l);for(j=0;j<classes;j++){distance[j]=inf;cenCount[j]=0;for(k=0;k<c;k++)classCount[j][k]=0;}fprintf(fp,"* %d\n",l);if(l==minRm)fprintf(fpMinRm,"* %d\n",l);for(i=0;i<count;i++){minPosition=0;for(k=0;k<classes;k++){temp=0.0;for(j=0;j<features;j++)temp+= (clsCenters[l][k][j]-data[i][j])*(clsCenters[l][k][j]-data[i][j]);temp=sqrt(temp);distance[k]=temp;if(distance[k]<distance[minPosition])minPosition=k;}position[i]=minPosition;clsObjects[minPosition][cenCount[minPosition]]=i;cenCount[minPosition]++;}for(j=0;j<classes;j++){for(i=0;i<cenCount[j];i++)classCount[j][(int)orgData[clsObjects[j][i]][0]-1]++;}/* minPosition varaible re used , now minPosition denotes the maximum class of the cluster*/fprintf(fpOrgClass,"\nCluster number: %2d \n",l);for(j=0;j<classes;j++){minPosition=0;fprintf(fpOrgClass,"\n Cluster %2d \n",j+1);fprintf(fpOrgClass,"%2d %2d\n",1,classCount[j][0]);for(i=1;i<c;i++){if(classCount[j][i]>classCount[j][minPosition]) minPosition=i;label[j]=minPosition;fprintf(fpOrgClass,"%2d %2d\n",i+1,classCount[j][i]);}}for(i=0;i<count;i++){for(j=0;j<classes;j++)for(k=0;k<cenCount[j];k++)if(clsObjects[j][k]==i){fprintf(fp,"%d ",label[j]+1);break;}}fprintf(fp,"\n");fprintf(fpOut,"\nCluster number: %2d \n",l);for(i=0;i<classes;i++){fprintf(fpOut,"%2d %4d\n",label[i]+1,cenCount[i]);for(j=0;j<features;j++)fprintf(fpCls,"%8.7f ",clsCenters[l][i][j]/scale[j]+minInput[j]);fprintf(fpCls,"\n");}}/* Write the data to the file */fclose(fp);fclose(fpOut);fclose(fpCls);fclose(fpMinRm);fclose(fpOrgClass);}/* end of function *//********************************************************************//* Function to amnalyze the results *//* Output: none *//* Input: *//* Global Structure Modified: none *//********************************************************************/void analysis(int flag){int i,j,k,temp;char junk;int totalRuns=0,errors[antsPerFeature],epoch=0,position=0,antsperfeature=0,clsNumber=0,min=0,currMinRm;FILE *fp,*fpError,*fpMin,*fpMinRm,*fpMinIp;if(flag==1){fp=fopen("fcmRm.out","r");fpMinIp=fopen("minRm.out","r");fpMinRm=fopen("minRmError.out","w");fpError=fopen("error.out","w");fpMin=fopen("minError.out","w");}else{fp=fopen("fcmFCM.out","r");fpError=fopen("errorFCM.out","w");}if(fp==NULL||fpError==NULL){printf("\n unable to open files in the analysis module \n");return;}fscanf(fp,"%c %d\n",&junk,&totalRuns);fscanf(fp,"%c %d\n",&junk,&antsperfeature);if(flag==1){fscanf(fpMinIp,"%c %d\n",&junk,&temp);fscanf(fpMinIp,"%c %d\n",&junk,&temp);}for(i=0;i<totalRuns;i++){for(j=0;j<antsperfeature;j++){errors[j]=0;}fscanf(fp,"%c %d\n",&junk,&epoch);if(flag==1){fscanf(fpMinIp,"%c %d\n",&junk,&temp);fscanf(fpMinIp,"%c %d\n",&junk,&currMinRm);}fprintf(fpError,"Experiment %3d ",i);for(k=0;k<antsperfeature;k++){fscanf(fp,"%c %d\n",&junk,&clsNumber);for(j=0;j<count;j++){fscanf(fp,"%d ",&position);if(orgData[j][0]!=position)errors[k]++;}fscanf(fp,"\n");if(flag==1){fprintf(fpError,"\nCluster %3d Errors %5d",k,errors[k]);if(k==currMinRm){fprintf(fpMinRm,"Cluster %2d Errors %5d\n",k,errors[k]);}}else fprintf(fpError," Errors %5d\n",errors[k]);}if(flag==1){min=0;for(j=1;j<antsPerFeature;j++){if(errors[j]<errors[min])min=j;}fprintf(fpMin,"Exp %2d Min Error %5d\n",i,errors[min]);}}fclose(fp);fclose(fpError);if(flag==1){fclose(fpMin);fclose(fpMinRm);fclose(fpMinIp);}}/* end of function */ void RmStage(int heapCount,center clsCen) { FILE *fpTime=fopen("time.out","a");int flag[antsPerFeature],flg;struct rusage start_usage, end_usage,epoch_start_usage, epoch_end_usage;double *perf_times;float newRm[antsPerFeature],oldRm[antsPerFeature],temp;int i=0,j=0,k=0;initRm(heapCount);initializeAntsRm(newAnts,clsCen);for(i=0;i<antsPerFeature;i++){oldRm[i]=inf;newRm[i]=inf;}flg=1;i=0;getrusage(RUSAGE_SELF, &start_usage);while(i<maxEpocs){getrusage(RUSAGE_SELF, &epoch_start_usage);epoch(newAnts);getrusage(RUSAGE_SELF, &epoch_end_usage);perf_times=timing_of(epoch_start_usage,epoch_end_usage); fprintf(fpTime,"Epoch %3d Timing: %f user, %f system, %f total.\n",i, perf_times[0], perf_times[1], perf_times[0] +perf_times[1]);for(j=0;j<antsPerFeature;j++){oldRm[j]=newRm[j];flag[j]=1;}computeRm(newAnts,data,newRm);updateMemory(newAnts,newRm,Rm);flg=0;for(j=0;j<antsPerFeature;j++){if(newRm[j]!=inf){if(oldRm[j]!=inf){temp=0;temp=newRm[j]-oldRm[j]<0? (oldRm[j]-newRm[j]):(newRm[j]-oldRm[j]);/*printf("\n new %f old %f temp %f ",newRm[j],oldRm[j],temp);*/if(temp/oldRm[j]>minChange){flg=1;break;}}else flg=1;}}i++;printf("\n Epoch %d ",i);}/* Do the final clustering*/finalCluster(newAnts,data,Rm);getrusage(RUSAGE_SELF, &end_usage);perf_times=timing_of(start_usage,end_usage); fprintf(fpTime,"Exp %3d Timing: %f user, %f system, %f total.\n",k, perf_times[0], perf_times[1], perf_times[0] +perf_times[1]);/* Compute the error */} /****************************************************************/ void Fcm (objects X1,center V,int flag) { int i,j,l; FILE *ofile,*fpJm; FILE *iniClsCen=fopen("center.clt","a+"); char temp[80]; float jmFinal=0,rmFinal=0; Random_seed=state1[run];/*randseed*/ srand48(Random_seed); for(i=0;i<MAXDATA;i++) for(j=0;j<features;j++)X[i][j]=X1[i][j]; if(iniClsCen==NULL) { printf("\n Unable to open the initial cluster center file\n"); printf("\n choosing random cluster centers....\n"); flag=1; } for (run=0;run<TOTRUNS;run++) { if(flag!=2) { if (EntireHeaps) lCount=heapCount; else lCount=c; for(i=0;i<lCount;i++) for(j=0;j<s;j++) V[i][j]=0; for(i=0;i<lCount;i++) { for(l=0;l<s;l++) { if(flag==1) { rand_index = lrand48() % n; V[i][l] = X[rand_index][l]; } else { fscanf(iniClsCen,"%f ",&V[i][l]); } }//end for }}else lCount=heapCount;eps=0.001; stop = FALSE; /* This loop finds the final cluster center and the corresponding U values */ z = 0; while (stop == FALSE) { z++; UMAT(U,V,X); /** Update the U matrix **/stop = FINISHED(U1,eps); CLUSTER(U,X,V); /** Get new cluster center **/printf("\nIteration: %d \n",z); } /* end while */ printf("Number of iterations: %d\n\n", z);strcpy(temp,""); sprintf(temp,"%sFCM.out",filename);if(flag==1){jmFinal=Compute_Jm(V,X);rmFinal=Compute_Rm(V,X);fpJm=fopen("jm.out","a");fprintf(fpJm," classes %2d Jm: %10.6f Rm: %10.6f\n",lCount,jmFinal,rmFinal);fclose(fpJm);} if(flag==2) Output(temp,V,X); /* output the results */ }/*end for*/ ofile=fopen(temp,"a"); for (i=0; i <= mins; i++) fprintf(ofile, "Min %d of %10.3f occurred %d times\n", i, mintab[i], mincount[i]); fprintf(ofile, "Average iterations %f\n", (float)aveit/(float)TOTRUNS); fclose(ofile); }/* end Main */ /* The NORM function computes the norm of two vectors, x and v, of dimension s. This gives an indication of the distance between them */ float NORM( feature x, feature v) //feature x, v; { /* Parameters : x -- a local copy of an input vector v -- a local copy of a cluster center */ int i,j; /* loop variable */ double sum; /* the square root of sum is the norm; sum is the sum of the differences squared */ float mat1[features]; float mat2[features]; if (maha) { for (i=0; i<features; i++) mat1[i]=x[i]-v[i]; for(i=0;i<features;i++) { sum =0; for(j=0;j<features;j++) sum += mat1[j] * inv_cov[j][i]; mat2[i] = sum; } sum =0; for(j=0;j<features;j++) sum += mat1[j]*mat2[j]; } else { sum = 0; for(j=0;j<features;j++) sum += (x[j] - v[j])* (x[j] - v[j]); } return (float)(sqrt(sum)); } /* end NORM */ /* The UMAT procedure calculates the updated U matrix according to Bezdek's formula. Its side-effect is the update of the global array U1 */ void UMAT( matrix U,center V, objects X) /*matrix U; center V; objects X;*/ { /* Parameters: U, V, and X: same as in main program */ int i, j, k,l ;/* loop variables *///, class /* class whose cluster center //is closest to pattern k */; float d1,d2,d; float sum; int exact; for (k=0;k<MAXDATA;k++) { /*printf("\n k %d ",k);*/ exact=false; for (i=0;i<lCount;i++) { sum=0; for (j=0;j<lCount;j++) { d1=NORM(X[k],V[i]); d2=NORM(X[k],V[j]); if(d2!=0) { d= d1/d2; d= d * d;/* pow(d1/d2,2.0/(m-1.0)); */ sum+=d; } else { exact = true; for(l=0;l<lCount;l++) if (l==j) U1[l][k]=1.0; else U1[l][k]=0.0; break; } } if (exact!=true) U1[i][k]=1.0/sum; } } } /* end UMAT */ /* The function FINISHED determines if a termination occurs. If not it updates U with U1, so its side-effect is the potential modification of U */ BOOLEAN FINISHED( matrix U1,float eps) //matrix U1; float eps; { /* Parameters: U1, eps-- same as in main */ float sum; /* sum of squared differences between corresponding elements of U and U1 */ int i,k; /* loop control variabes */ BOOLEAN finished; /* set to true if all corresponding elements are within epsilon */ finished = TRUE; sum = 0; for (i=0; i<lCount; i++) for (k=0; k<MAXDATA; k++) sum += (U[i][k] - U1[i][k])*(U[i][k]-U1[i][k]); if (sqrt(sum) > eps) { finished = FALSE; for (i=0; i<lCount; i++) for (k=0; k<MAXDATA; k++) U[i][k] = U1[i][k]; } /* end if */ return finished; } /* end FINISHED */ /* The CLUSTER procedure determines cluster centers in V for the c classes being searched for. The global array V is updated */ void CLUSTER( matrix U, objects X,center V) //matrix U; objects X; { /* Parameters: U, X -- as in main */ int i, j, k; /* loop control variables */ feature num; /* numerator in the cluster center computation formula presented by Bezdek */ float denum; /* denumenator in the obove formula */ for (i=0; i<lCount; i++) { denum = 0; for (j=0; j<features; j++) { num[j] = 0; for (k=0; k<MAXDATA; k++) num[j] += U[i][k] * U[i][k] * X[k][j]; /* pow(U[i][k],m) * X[k][j]; */ } /* end for */ for (k=0; k<MAXDATA; k++) denum += U[i][k] * U[i][k]; /* pow(U[i][k],m); */ for (j=0; j<features; j++) V[i][j] = num[j] / denum; } /* end for */ } /* end CLUSTER */ float Compute_Jm(center V, objects X) //center V; //objects X; { int i, k,found; double Jm_value; float u,dik; Jm_value = 0; for (k=0; k<MAXDATA; k++) { found = FALSE; for (i=0; i<lCount; i++) { dik=NORM(X[k],V[i]); dik=dik*dik; if (dik==0.0) { if (found == FALSE) { u=1.0; found = TRUE; printf("found the case with dik=0\n"); } else { printf("\n cant proceed with this initialization"); exit(1); } } else { if (found != TRUE) u=U1[i][k]; /* get_Uvalue(V,X,dik,k); */ else u=0.0; } Jm_value += u * u * dik;/* pow(u, m) * dik; */ } } return (Jm_value); } /* end Compute_Jm */ /* The Output procedure outputs the U matrix which gives the fuzzy measure of each feature belonging to a cluster center. It also outputs the cluster center for each class */ void Output(char fname[],center V,objects X) //char fname[80]; /* Parameters: U, V -- same as in main */ { int i, j, found; /* loop control variables */ float J2c,R2c; FILE *fpJm=fopen("JmRm.out","a"),*fp; if ((fp=fopen(fname,"a"))==NULL) printf("\n CAN'T OPEN %s\n",fname); else { fprintf(fp,"\n \n"); for (i=0; i<lCount; i++) { fprintf(fp,"\n"); for (j=0; j<features; j++) fprintf(fp,"%4.3f ",V[i][j]); } /* end for */ } /* end if */ J2c= Compute_Jm(V,X); R2c=Compute_Rm(V,X); fprintf(fpJm,"Classes: %3d Jm: %10.6f Rm: %10.6f \n",lCount,J2c,R2c); found =0; for (i=0;i<= mins; i++) { if ((found == 0) && ((J2c - mintab[i]) < .001) && ((J2c - mintab[i]) > -.001)){ mincount[i]++; found = 1; } } if (found == 0) { mins++; mintab[mins]=J2c; mincount[mins]=1; } fprintf(fp,"\nJ%2d = %f", m,J2c); fprintf(fp, "Number of iterations: %d\n\n", z); aveit=aveit + z; fclose(fp); fclose(fpJm); } /***************************************************************/ void find_covar( ) { int i,j,k; float mean[features],sum; for (i=0;i<features;i++) mean[i]=0; for (i=0;i<features;i++) for (j=0;j<m;j++) mean[i]+=X[j][i]; for (i=0;i<features;i++) mean[i]/=m; for (i=0;i<features;i++) for (j=0;j<features;j++) { sum=0; for (k=0;k<m;k++) sum+=(X[k][i]-mean[i])*(X[k][j]-mean[j]); Y[i][j]=sum/m; } }float Compute_Rm(center V, objects X){int i=0,j=0,l=0;double Dik=0,temp=0,Rm=0;Rm=0;for(i=0;i<MAXDATA;i++){Dik=0;for(j=0;j<lCount;j++){temp=0;for(l=0;l<features;l++)temp+=(X[i][l]-V[j][l])*(X[i][l]-V[j][l]);Dik+=pow(temp,1.0/(1-m));}Rm+=pow(Dik,(1-m));}return(Rm);}/* End of function *//********************************************************************/ /* Function to harden the outputs obtained from fcm(2nd stage)*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: Cluster center , cluster center count*/ /********************************************************************/void hardenRm() { FILE *fp=fopen("fcmFCM.out","a"); FILE *fpOut=fopen("ClassDataFCM.out","a"); int i=0,minPosition=-1,position[MAXDATA],j=0,k=0; int cenCount[MAXDATA],classCount[MAXDATA][c],label[c], clsObjects[MAXDATA][MAXDATA]; for(j=0;j<classes;j++) {cenCount[j]=0;for(k=0;k<classes;k++)classCount[j][k]=0; } for(i=0;i<MAXDATA;i++) { minPosition=findPosition(i); position[i]=minPosition;clsObjects[minPosition][cenCount[minPosition]]=i;cenCount[minPosition]++; } for(j=0;j<classes;j++) {for(i=0;i<cenCount[j];i++)classCount[j][(int)orgData[clsObjects[j][i]][0]-1]++; } /* minPosition varaible re used , now minPosition denotes the maximum class of the cluster*/for(j=0;j<classes;j++){minPosition=0;for(i=1;i<c;i++){if(classCount[j][i]>classCount[j][minPosition]) minPosition=i;label[j]=minPosition;}}fprintf(fp,"* %d\n",0);for(i=0;i<count;i++){for(j=0;j<classes;j++)for(k=0;k<cenCount[j];k++)if(clsObjects[j][k]==i){fprintf(fp,"%d ",label[j]+1);break;}}fprintf(fp,"\n");for(i=0;i<classes;i++){fprintf(fpOut,"%2d %4d\n",label[i]+1,cenCount[i]);}fclose(fpOut);fclose(fp);return; }/*end of function*/ /********************************************************************//* Function Main *//********************************************************************/ int main(int argc, char** argv){int k=0,i=0,j=0;int sum=0;char temp[80];FILE *fpRmOut=fopen("fcmRm.out","w");FILE *fpOut=fopen("ClassData.out","w");FILE *fpCls=fopen("clsCenters.out","w");FILE *fpMinRm=fopen("minRm.out","w");FILE *fpOrgClass=fopen("orgClass.out","w");FILE *fpRm=fopen("Rm.out","w");FILE *fpJmRm=fopen("JmRm.out","w");FILE *fp=fopen("fcm.out","w");FILE *fp1; FILE *fp2=fopen("antAnalysis.out","a");FILE *fp3=fopen("fcmAnalysis.out","a"); FILE *fp4=fopen("errors.out","w");FILE *fp5;FILE *fpJm=fopen("jm.out","w");FILE *fpTime=fopen("time.out","w");FILE *fpFCM=fopen("fcmFCM.out","w");FILE *fpOutFCM=fopen("ClassDataFCM.out","w");fprintf(fpFCM,"# %d\n",EXPRUN);fprintf(fpFCM,"@ %d\n",1);fclose(fpFCM);fclose(fpOutFCM);fclose(fp4);fclose(fpJm);sprintf(temp,"%sObj.out",filename);fp5=fopen(temp,"w");fclose(fp5);strcpy(temp,"");sprintf(temp,"%sTot.out",filename);fp5=fopen(temp,"w");fclose(fp5);strcpy(temp,"");sprintf(temp,"%sOp.out",filename);fp1=fopen(temp,"w");fprintf(fp,"\n$%d",EXPRUN);fprintf(fp1,"\n$%d",EXPRUN);fclose(fp);fclose(fp1);fclose(fpJmRm);fprintf(fpRmOut,"# %d\n",EXPRUN);fprintf(fpRmOut,"@ %d\n",antsPerFeature);fclose(fpRmOut);fprintf(fpTime,"Experiments %d\n",EXPRUN);fprintf(fpMinRm,"# %d\n",EXPRUN);fprintf(fpMinRm,"@ %d\n",antsPerFeature);fclose(fpMinRm);fclose(fpOut);fclose(fpCls);fclose(fpOrgClass);fclose(fpRm);fclose(fpTime);/*readInput();*/ if(argc==2)sscanf(argv[1],"%d",&debugLevel); printf("\n Debug level %d\n",debugLevel); for( i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; readInput(); /*readOrg();*/ //Compute the distance of all the points if(maxDist) { Dmax=computeDistance(); //Compute the maximum distance fp5=fopen("maxData.txt","w");fprintf(fp5,"%f",Dmax);fclose(fp5); } else {fp5=fopen("maxData.txt","r");fscanf(fp5,"%f",&Dmax);fclose(fp5); } printf("\n %f \n",Dmax); //Initialise the board for(k=0;k<EXPRUN;k++) { fpRmOut=fopen("fcmRm.out","a");fpOut=fopen("ClassData.out","a");fpCls=fopen("clsCenters.out","a");fpOrgClass=fopen("orgClass.out","a");fpMinRm=fopen("minRm.out","a");fpRm=fopen("Rm.out","a");fpTime=fopen("time.out","a");fpFCM=fopen("fcmFCM.out","a");fpOutFCM=fopen("ClassDataFCM.out","a");fprintf(fpFCM,"$ %d\n",k);fprintf(fpOutFCM,"Experiment %d\n",k);fprintf(fpRm,"Exp: %2d ",k);fclose(fpRm);fprintf(fpCls,"EXP No %2d \n",k);fclose(fpCls);fprintf(fpRmOut,"$ %d\n",k);fprintf(fpMinRm,"$ %d\n",k);fprintf(fpOut,"Experiment %d\n",k);fprintf(fpOrgClass,"Experiment %d\n",k);fprintf(fpTime,"Experiment %d\n",k);fclose(fpRmOut);fclose(fpOut);fclose(fpMinRm);fclose(fpOrgClass);fclose(fpTime); fclose(fpFCM);fclose(fpOutFCM); init(); sum=0; srand48(state1[k]); initialiseBoard(); initialise(1); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(1); printf("\n %d \n",heapCount); //Simulate the working of ants iterate(1); //drop the objects after all the iterations dropFinal(1); //to verify the correctness for(i=0;i<heapCount;i++) sum+=heaps[i].count; //write the cluster centers to the file writeClusterInformation(1); printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); //getchar(); //Run FCM // heapCount=2973;/* To be commented */ printf("\n\n k %d \n\n",k); Fcm(data,V,0); //compute new board size. lCount=heapCount; heapRow=(int)ceil(sqrt(4*heapCount)); newHeapCount=lCount; printf("\n LCount %d newHeapCount %d heap Row %d \n",lCount,newHeapCount,heapRow); //harden the objects harden(newHeaps); //iterate with the heaps as the objects. initialiseBoard(); initialise(0); for(i=0;i<lCount;i++) computeHeapParameters(&heaps[i],0); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(0); printf("\n %d \n",heapCount); //getchar(); //Simulate the working of ants iterate(0); dropFinal(0); writeClusterInformation(0); sum=0; for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); // getchar(); fpJm=fopen("jm.out","a"); fprintf(fpJm,"Experiment %2d: ",k); fclose(fpJm); Fcm(data,V,1); harden1(); RmStage(newHeapCount,V); } fp=fopen("fcm.out","a"); fp1=fopen(temp,"a"); fprintf(fp,"\n"); fprintf(fp1,"\n"); fclose(fp); fclose(fp1); fp=fopen("fcm.out","r"); fp1=fopen(temp,"r"); printf("\n Before read org\n");printf("\nafter read org\n");/*readFCM(fp1,fp2);*/printf("\n After 1st read fcm\n");/*readFCM(fp,fp3);*/printf("\n After 2 fcm read \n");/*analysis(1);analysis(0);*/return(1); }//end of main
Parag Kanade/Combined Algorithm/header.h
/********************************************************************//* Ant Class parameters *//* SPEED # amplitude of moves [1,10] *//* P direction Probability to move in the same direction [.5,1] *//* Max carry : Maximum object carrying time [20,200] *//* P load Probability to pick up a single object [0.4,0.8] *//* P destroy probability to destroy a heap of two objects [0,0.6] *//* T remove min. dissimilarity necessary for removing an object *//* from a heap [.1,.2] *//* T create max dissimilarity permitted for creating a heap[.05,.2]*//********************************************************************/ #include <stdio.h>#include <math.h>#include <string.h>#include <stdlib.h>#include <ctype.h>#include <time.h>#include <sys/time.h>#include "timing_of.c"#define MAXANTS 17#define MAXDATA 50#define MAXANTSFORHEAPS 15#define MAXITERATIONS 1000#define MAXROWS 14#define MAXCOLS 14#define features 4#define filename "british"#define c 5 /* number of clusters */#define EXPRUN 2#define Tremove 3.0#define Tcreate 1.5#define Pdrop 0.2#define Pdestroy 0.3#define Pload 0.3#define normalize 0#define EntireHeaps 1#define TcreateForHeaps 0.10#define errThresh 0.1#define dataDump 1#define maxDist 1#define Prest 0.01#define Pcontinue 0.75#define tContinueCurr 0.20#define Dmin 0.001#define DmaxRm 0.01#define iterations 50#define memory 5#define antsPerFeature 30#define inf 10e100#define m 2#define TRUE 1#define maxEpocs 1000#define minChange 0.00075#define maha 0#define FALSE 0#define true 1#define false 0#define TOTRUNS 1 /* number of V's to write out *//* some type definitions to make C code a little more readable */#define n MAXDATA /* number of input vectors */#define s features /* number of features */#define square 0extern int count;int debugLevel=0;/* To debug the code and verify the correctness of algorithms*/int currHeapCount=0;typedef int BOOLEAN;typedef short TYPE_IN_DATA; /* Type of input binary data */typedef float feature[s]; /* Type of each input; made up of input features */typedef float irisData[s];typedef feature objects[MAXDATA]; /* Type of array holding all inputs */typedef feature center[MAXDATA]; /* Type of array holding cluster centers */typedef float matrix[MAXDATA][MAXDATA];/* Type of the matrix containing membership grades */typedef struct Heap{float Dmax;irisData Ocenter;float Dmean;irisData Odissim;int x;int y;int count;int disPosition;int objects[MAXDATA];int objCount;}heap;typedef struct Ant{int x;int y;int carrying;int speed;int dir;irisData data;}ant;typedef struct a{float Rm[memory];int rest;int direction;float currPos;}antdata;typedef struct HeapInfo{int total;int classObj[c];} heapInfo;antdata *newAnts; /* Ants */int classes;float Rm[antsPerFeature][memory];float orgData[n][s+1];float fcmData[260][n][s];int clsCenCount[260];int currentRow=0;int currentAntCount=0;int updateAfter=50;int heapSum=0;int minAnts=3;int rowMin=5;int antCount=0; /*******************************************************************/ /*** Global Variables ***/ irisData data[MAXDATA]; //To hold the data read from the file int count=0; //Count of the total number of data elements int heapCount=0; // Total number of heaps int heapRow=0; // Rows for the second iteration with heaps int newHeapCount=0; // Count of the heaps for the second iteration heap heaps[MAXDATA]; // Data structure to hold the heap information heap newHeaps[MAXDATA]; // Data Structure to hold the new heap information // For the second iteration int board[MAXROWS][MAXCOLS]; // Board on which the objects are located ant ants[MAXANTS]; // Data structure to hold the ants float Dmax=0; // Distance of the most dissimilar object pair int minHeapCount=100000; // Counter to hold the minimum heap count, used only for academic purpose // no use in the algorithm int minPosition; // the minimum heap iteration , only for academic purpose // no use in the algorithm float clsCen[MAXDATA][MAXDATA][s];//to hold the objects after hardening int cenCount[MAXDATA];//to hold the number of objects after hardening /********************************************************************/ /*** Varaibles to normalize the features between 0 and 1 */ float minInput[features], maxInput[features],scale[features],minForHeaps[features],maxForHeaps[features],scaleForHeaps[features]; /********************************************************************/ /** Variables for the FCM algorithm */ int temp[200]; /* for square matrix tests */ float eps; matrix U, U1; BOOLEAN stop; center V; objects X; char fname[80]; int run; float inv_cov[s+1][s+1]; /* inverse of covariance matrix Y */ float Y[s][s]; long rand_index, Random_seed; long state1[52] = { 9347, 3835, 5194, 8310, 346, 535, 5297, 6711, 77, 3834, 668, 4175, 6868, 5890, 9304, 8462, 5269, 920, 65392, 41600, 70119, 91032, 76220, 26245, 4746, 73608, 32823, 63264, 75641, 99104, 36534, 24704, 98255, 72266, 75336, 65152, 7269, 63163, 88471, 27271, 43641, 76649, 47773, 23777, 27491, 35926, 16651, 48652, 89766, 90921, 6056 }; int z; int mins=0; int aveit =0; float mintab[200]; int mincount[200]; long start,end,total; int lCount;//added by parag/*heapInfo info[MAXDATA];*//********************************************************************//***Function decelarations*//********************************************************************//***For ant based algorithm*/void readInput();float computeDistance();float computeDistanceBetween2(irisData a,irisData b);float findMax(float *distance);float value(irisData a);int found(int a , int b);void initialise(int flag);int findObject(int a,int b);void initialiseAnts(int flag);void moveNext(ant* a,int flag);void computeHeapParameters(heap* data,int flag);void pickObject1(ant *a,int position,int flag);void pickObject2(ant *a , int position,int flag);void pickObjectn(ant *a,int position,int flag);void pick(ant *a,int flag);void dropObject(ant* a,int flag);int findInNewheaps(irisData object);void dropObject1(ant* a, int position,int flag);void drop(ant* a,int flag);void move(ant* a,int flag);void iterate(int flag);void dropFinal(int flag);int partition(heap a[], int low,int high);void quickSort( heap A[], int low,int high ) ;void writeClusterInformation(int flag);void initialiseNewHeaps(heap newHeaps[]);int findPosition(int i);void harden(heap newHeaps[]);void harden1();int findPosition1(int );void writeInfo();void addObject1(int ,int);void readFCM(FILE *,FILE *);void readOrg();int findInData(irisData input,int iflag);void adjustBoard(int flag);void writeIncremental(int iteration,int flag);void initializeAntsRm(antdata* ants,center clsCen);void epoch(antdata *ants);void computeRm(antdata *ants,float data[MAXDATA][features],float newRm[antsPerFeature]);void updateMemory(antdata *ants,float newRm[antsPerFeature], float Rm[antsPerFeature][memory]);void analysis();void GET_INPUTS1(char []);void UMAT( matrix,center,objects);BOOLEAN FINISHED(matrix, float);void CLUSTER( matrix, objects,center);void Output(char[],center V,objects X);void Fcm(objects X,center V,int flag);float Compute_Jm(center V, objects X);float Compute_Rm(center V, objects X);float NORM( feature x, feature v);double *timing_of(); /* Calculate time in seconds */void RmStage(int heapCount,center clsCen);void hardenRm();/********************************************************************//***For FCM algorithm*//*void CLUSTER( matrix, objects);*//*void Output(char[]);*//*void Fcm(irisData data[],int stage);*//********************************************************************/
Parag Kanade/Combined Algorithm/timing_of.c
/* timing_of.c Calculates timing given struct rusage. $Id: timing_of.c,v 1.3 2002/07/12 20:48:49 eschrich Exp $ Steven Eschrich Copyright (C) 2002 University of South Florida This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*/�#include <stdlib.h>#include <time.h>#include <sys/times.h>#include <sys/resource.h>/* Get time, in seconds */double *timing_of(struct rusage start, struct rusage stop){ long totaluMicroseconds, totalsMicroseconds; static double totalTime[2]; totaluMicroseconds = stop.ru_utime.tv_usec - start.ru_utime.tv_usec; totalsMicroseconds = stop.ru_stime.tv_usec - start.ru_stime.tv_usec; /* If we need to borrow, do so */ if ( totaluMicroseconds < 0 ) { stop.ru_utime.tv_sec--; totaluMicroseconds=1000000L + stop.ru_utime.tv_usec - start.ru_utime.tv_usec; } if ( totalsMicroseconds < 0 ) { stop.ru_stime.tv_sec--; totalsMicroseconds=1000000L + stop.ru_stime.tv_usec - start.ru_stime.tv_usec; } totalTime[0] = (stop.ru_utime.tv_sec - start.ru_utime.tv_sec) + 0.000001 * totaluMicroseconds; totalTime[1] = (stop.ru_stime.tv_sec - start.ru_stime.tv_sec) + 0.000001 * totalsMicroseconds; return totalTime;}
Parag Kanade/Combined Algorithm/iris.c
#include "header.h" /********************************************************************/ /********************************************************************/ /* Function to read the input data set */ /* The file name is assumed to be itest.data */ /* Status: Tested */ /* Output: Data from the file into the "data" (Global) data structure */ /* Output: Count (Global), the count of the number of objects */ /********************************************************************/ void readInput() { FILE *fp; char fname[80]; int i=0,j=0; char ch; sprintf(fname,"%s.data",filename); /* Check if the input file is opened */ if((fp=fopen(fname,"r"))==NULL) { printf("\n Unable to open input file \n"); exit(0); } /*initialise the minimum maximum and the scale */ for(i=0;i<features;i++) { minInput[i]=1000; maxInput[i]=0; minForHeaps[i]=1000; maxForHeaps[i]=0; scale[i]=0; scaleForHeaps[i]=0; } /* Discard leading comments */ ch = 'c'; while (ch != '#') fscanf (fp, "%c", &ch); i=0; /* Parse the file and populate the data structure */ while(!feof(fp)) { for(j=0;j<features;j++) { fscanf(fp,"%f ",&data[i][j]); } fscanf(fp,"\n"); for(j=0;j<features;j++) { if(data[i][j]<minInput[j]) minInput[j]=data[i][j]; if(data[i][j]>maxInput[j]) maxInput[j]=data[i][j]; } i++; } count=i; /* Normailze the feature values in between 0 and 1 */ for(j=0;j<features;j++) { if(minInput[j]!=maxInput[j]) scale[j]=1.0/(maxInput[j]-minInput[j]); else scale[j]=1.0; } for(i=0;i<count;i++) { for(j=0;j<features;j++) data[i][j]=(data[i][j]-minInput[j])*scale[j]; } fclose(fp); return; }//end of function /********************************************************************/ /*Function to compute the eucldiean distance for all input data set */ /* Output : an array conatining the distance of each object with the other */ /********************************************************************/ float computeDistance() { float distance,dist=0; int i=0,j=0,k=0; distance=0; for(j=0;j<count;j++) for(i=0;i<count;i++) { for(k=0;k<features;k++) dist+=sqrt((data[j][k]-data[i][k])*(data[j][k]-data[i][k])); if(distance<dist)distance=dist; dist=0; } return(distance); } /********************************************************************/ /* Function to compute the distance between two objects */ /* Output : Euclidean d istance between the two input objects */ /********************************************************************/ float computeDistanceBetween2(irisData a,irisData b) { float temp=0; int i=0; for(i=0;i<features;i++) temp+=(a[i]-b[i])*(a[i]-b[i]); temp=sqrt(temp); return(temp); } /********************************************************************/ /* Function to compute the value of an object */ /********************************************************************/ float value(irisData a) { int i=0; float temp=0; for(i=0;i<features;i++) temp+=a[i]*a[i]; return(sqrt(temp)); } /********************************************************************/ /* Function to find the object in the data structure */ /* Output : The position of the object in the data */ /* Input : The object */ /********************************************************************/ int findInData(irisData object,int iFlag) { int i=0,lastCount=0,j,position=-1,flag[features],flg;if(iFlag==1)lastCount=MAXDATA;else{}for(i=0;i<lastCount;i++){ for(j=0;j<features;j++) if(fabs(object[j]-data[i][j])<0.00001) flag[j]=1; else { flag[j]=0; break;} flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /* Function to find whether there is an object on the board at a,b */ /* Output : a flag indicating whether an object is found or not */ /* Input : The row and column indicating the board position */ /********************************************************************/ int found(int a , int b) { if(board[a][b]==9) return 1; else return 0; } /********************************************************************/ /* Function to initialize the initial board */ /* Output : None */ /* Global Structures modified : heaps */ /* Input : Flag indicating the iteration 1: First 0: Second */ /********************************************************************/ void initialise(int flag) { int a,b,i=0,k=0; int loopCount,rowCount,colCount; /* Initialize the row, column and number of heaps */ if(flag==1) { loopCount=count; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=lCount; rowCount=heapRow; colCount=heapRow; } /* Initialize the heaps */ for(i=0;i<loopCount;i++) { heaps[i].count=0; heaps[i].x=0; heaps[i].y=0; heaps[i].disPosition=0; heaps[i].Dmax=0; heaps[i].Dmean=0; } for(i=0;i<loopCount;i++) { /*find a board position which is empty*/ do { a=lrand48()%rowCount; b=lrand48()%colCount; } while(found(a,b)); /*Allocate the object to that place and assign a heap to it*/ heaps[i].x=a; heaps[i].y=b; heaps[i].count=1; heaps[i].Dmax=0; heaps[i].Dmean=0; if(flag==1) { heaps[i].objects[0]=i; for(k=0;k<features;k++)heaps[i].Ocenter[k]=data[i][k]; } else { for(k=0;k<features;k++) heaps[i].Ocenter[k]=newHeaps[i].Ocenter[k]; } heaps[i].disPosition=0; board[a][b]=9; if((debugLevel>0)&&(flag==1))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],data[heaps[i].objects[0]][0]); if((debugLevel>0)&&(flag==0))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],newHeaps[i].Ocenter[0]); } /*initialise the initial heap count*/ heapCount=loopCount; currentRow=rowCount; } /********************************************************************/ /* Function to find whether an heap is present at the location a b */ /* Output : Flag indicating the presencs of the heap */ /* Input : Roe and column indicating the board position */ /********************************************************************/ int findObject(int a,int b) { int i; int position=-1; for(i=0;i<heapCount;i++) { if((heaps[i].x==a)&&(heaps[i].y==b)) { position=i; break; } } return(position); } /********************************************************************/ /* Function initialize the ants */ /* Output : None */ /* Input : Flag indicating the iteration */ /* Global Variables Modified : ant, heapCount, heaps, board */ /********************************************************************/ void initialiseAnts(int flag) { int i=0,a=0,b=0,position,j=0,loopCount=0,rowCount,colCount,k=0; if(flag==1) { loopCount=MAXANTS; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=MAXANTSFORHEAPS; rowCount=heapRow; colCount=heapRow; } for(i=0;i<loopCount;i++) { /*generate random positions for the ants*/ a=lrand48()%rowCount; b=lrand48()%colCount; ants[i].x=a; ants[i].y=b; /*Find if an object is present at that position or not*/ if(board[a][b]==9) { ants[i].carrying=1; /*find the heap at that location*/ position=findObject(a,b); if(position==-1) { printf("\n Error in logic: Ant init \n"); //getchar(); break; } else { /*Assign the heap data to the ant data and decrement the heap count*/ if(flag==1){ for(k=0;k<features;k++)ants[i].data[k]=data[heaps[position].objects[0]][k]; }else{for(k=0;k<features;k++)ants[i].data[k]=heaps[position].Ocenter[k];} for(j=position;j<heapCount-1;j++) heaps[j]=heaps[j+1]; heapCount--; } /*Clear the board position */ board[a][b]=-9; } else ants[i].carrying=-1; ants[i].speed=0; ants[i].dir=lrand48()%8; printf("\n Ant %2d X: %2d Y: %2d Carying : %2d ",i,ants[i].x,ants[i].y,ants[i].carrying); } currentAntCount=loopCount; } /********************************************************************/ /* Function to move the ant */ /* Output: None */ /* Input: Ant to be moved and the flag indicating the iteration */ /********************************************************************/ void moveNext(ant* a,int flag) { int rowCount,colCount; rowCount=currentRow;colCount=currentRow; /*Depending upon the direction move the ant*/ switch (a->dir) { case 0: a->y++; if(a->y>=colCount)a->y=0; break; case 1: a->x--; a->y++;; if(a->x<0)a->x=rowCount-1; if(a->y>=colCount)a->y=0; break; case 2: a->x--; if(a->x<0)a->x=rowCount-1; break; case 3: a->x--; a->y--; if(a->x<0)a->x=rowCount-1; if(a->y<0)a->y=colCount-1; break; case 4: a->y--; if(a->y<0)a->y=colCount-1; break; case 5: a->x++; a->y--; if(a->x>=rowCount)a->x=0; if(a->y<0)a->y=colCount-1; break; case 6: a->x++; if(a->x>=rowCount) a->x=0; break; case 7: a->x++; a->y++; if(a->x>=rowCount)a->x=0; if(a->y>=colCount)a->y=0; break; } }//end of function /********************************************************************/ /* Function to compute the parameters of the heap */ /* Output: None */ /* Input: The heap whose parameters are to be computed iteration flag*/ /********************************************************************/ void computeHeapParameters(heap* heapData,int flag) { int i=0,j=0,k=0,position=0; float distance=0; float Dmean=0.0; float *dis; float featureSum[features]; float max=0; float sum=0; /* init*/ for(k=0;k<features;k++) featureSum[k]=0; /*Compute the distance of each object and find the maximum distance*/ max=0; if(flag==1){ for(j=0;j<heapData->count;j++) for(i=0;i<heapData->count;i++) { for(k=0;k<features;k++) sum+= (data[heapData->objects[j]][k]-data[heapData->objects[i]][k])*(data[heapData->objects[j]][k]-data[heapData->objects[i]][k]); distance=sqrt(sum); if(max<distance) max=distance; sum=0; } /* Assign the maximum distance to the heap */ heapData->Dmax=max;/*Compute the centre object*/for(i=0;i<heapData->count;i++)for(k=0;k<features;k++) featureSum[k]+=data[heapData->objects[i]][k];for(k=0;k<features;k++)heapData->Ocenter[k]=featureSum[k]*1.0/heapData->count; /* Find the mean distance */if((dis=(float *) calloc(heapData->count,sizeof(float)))==NULL){printf("\nUnable to allocate memory in the compute heap parameters procedure\n");exit(0);} for(i=0;i<heapData->count;i++) { Dmean+=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); dis[i]=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); } heapData->Dmean=Dmean*1.0/heapData->count; /*Compute the most dissimilar object*/ max=dis[0]; for(i=1;i<heapData->count;i++) if(max<dis[i]) { max=dis[i]; position=i; } /*Assign the most dissimilar object to the heap variable*/ for(k=0;k<features;k++) heapData->Odissim[k]=data[heapData->objects[position]][k]; heapData->disPosition=position;free(dis); } else{/* Heap Parameters for the second stage */for(k=0;k<features;k++){ heapData->Odissim[k]=heapData->Ocenter[k];}heapData->disPosition=0;heapData->Dmean=0;heapData->Dmax=0;} }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a single object*/ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject1(ant *a,int position,int flag) { int i,k=0; /*Clear the board*/ board[heaps[position].x][heaps[position].y]=-9; /* Assign the data to the ant*/if(flag==1){ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[0]][k];}else {for(k=0;k<features;k++) a->data[k]=heaps[position].Ocenter[k];} a->carrying=1; /*Copy all the heaps remaining heaps in the structure*/ for(i=position;i<heapCount-1;i++) heaps[i]=heaps[i+1]; /*Decrement the heap count*/ heapCount--; }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a two objects */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject2(ant *a , int position,int flag) { float Pdestroy1=-1; int i=0,k=0; /*Compute the probability to destroy the heap*/ Pdestroy1=lrand48()%13*1.0/12.0; /*If the probability is more than Pdestroy then destroy the heap */ if(Pdestroy1<Pdestroy) { /*pick the object randomly*/ i=lrand48()%2; /* Assign the data to the ant */ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[i]][k]; a->carrying=1; /*Correct the heap parameters*/ heaps[position].count=1; heaps[position].objects[0]=heaps[position].objects[1-i]; computeHeapParameters(&heaps[position],flag); } }//end of function /********************************************************************/ /*Function to pick a object from a heap consisting of more than two object */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /********************************************************************/ void pickObjectn(ant *a,int position,int flag) { int i=0,k=0; /*If the criteria is satsfied then pick the object*/ if((computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)*1.0/heaps[position].Dmean)>Tremove) { a->carrying=1; for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[heaps[position].disPosition]][k]; for(i=heaps[position].disPosition;i<heaps[position].count-1;i++) heaps[position].objects[i]=heaps[position].objects[i+1]; heaps[position].count--; computeHeapParameters(&heaps[position],1); } }//end of function /********************************************************************/ /* Function to pick a object */ /********************************************************************/ void pick(ant *a,int flag) { int position=-1,i=0; float Pload1=-1.0; for(i=0;i<heapCount;i++) { /*Check if a heap is present in the eight neighbouring cells*/ if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if Heap is found*/ if(position!=-1) { /* heap or object found.*/ /*Depending upon the number present in the heap call the corresponding routine*/ switch(heaps[i].count) { case 1: Pload1 = lrand48()%151*1.0/150.0; if(Pload1<Pload) { pickObject1(a,position,flag); } break; case 2: pickObject2(a,position,flag); break; default: pickObjectn(a,position,flag); break; } } } /********************************************************************/ /* Function to drop a object to form a new heap */ /* Output: None */ /* Input: Ant, iteration flag */ /* Global Structure modified : heap, heapCount */ /********************************************************************/ void dropObject(ant* a,int flag) { /*Create a new heap*/ int k=0; heaps[heapCount].count=1; heaps[heapCount].x=a->x; heaps[heapCount].y=a->y; heaps[heapCount].Dmax=0; heaps[heapCount].Dmean=0; heaps[heapCount].disPosition=0; for(k=0;k<features;k++) { heaps[heapCount].Odissim[k]=a->data[k]; heaps[heapCount].Ocenter[k]=a->data[k]; } if(flag==1) {heaps[heapCount].objects[0]=findInData(a->data,flag); /*computeHeapParameters(&heaps[heapCount],flag);*/ } computeHeapParameters(&heaps[heapCount],flag); heapCount++; a->carrying=-1; board[a->x][a->y]=9; }//end of function /********************************************************************/ /* Function to find the heap position during the second iteration */ /* Output: position of the heap */ /* Input: object center of the heap that the ant is carrying */ /* Global Structure modified : none */ /********************************************************************/ int findInNewheaps(irisData object) { int position=-1,i,j=0,flag[features],flg; for(i=0;i<newHeapCount;i++) { for(j=0;j<features;j++) { if(fabs(object[j]-newHeaps[i].Ocenter[j])<0.00001) flag[j]=1; else {flag[j]=0;break;} } flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /*Function to drop a object to a heap consisting of a one or more object */ /* Output: none */ /* Input: Ant, position of the heap , iteration flag */ /* Global Structure modified: heaps,newHeaps */ /********************************************************************/ void dropObject1(ant* a, int position,int flag) { int heapPosition=-1,heapPosition1=-1,i,j,k=0; irisData newData,temp; if(flag==1) { heaps[position].objects[heaps[position].count]=findInData(a->data,flag); heaps[position].count++; computeHeapParameters(&heaps[position],flag); } else { for(k=0;k<features;k++)temp[k]=heaps[position].Ocenter[k]; heapPosition=findInNewheaps(a->data); heapPosition1=findInNewheaps(heaps[position].Ocenter); if(heapPosition==-1||heapPosition1==-1) { printf("\n error in logic:new heaps\n"); //getchar(); return; } for(k=0;k<features;k++) {newData[k]=(newHeaps[heapPosition].Ocenter[k]*newHeaps[heapPosition].count+newHeaps[heapPosition1].Ocenter[k]*newHeaps[heapPosition1].count)*1.0/(newHeaps[heapPosition].count+newHeaps[heapPosition1].count);newHeaps[heapPosition].Ocenter[k]=newData[k];heaps[position].Ocenter[k]=newData[k]; } computeHeapParameters(&heaps[position],flag); for(i=newHeaps[heapPosition].count,j=0;j<newHeaps[heapPosition1].count;i++,j++) { newHeaps[heapPosition].objects[i]=newHeaps[heapPosition1].objects[j]; } newHeaps[heapPosition].count+=newHeaps[heapPosition1].count; for(i=heapPosition1;i<newHeapCount-1;i++) newHeaps[i]=newHeaps[i+1]; newHeapCount--; } a->carrying=-1; }//end of function /********************************************************************/ /* Function to drop a object */ /* Output: None */ /* Input: Ant, iteration flag */ /********************************************************************/ void drop(ant* a,int flag) { int i, position=-1; float Pdrop1=0.0; /*Find whether we have a heap in the neighbourhood of the cell*/ for(i=0;i<heapCount;i++) { if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if a heap is found*/ if(position!=-1) { /*heap or object found.*/ /*Depending on the number of objects present take action*/ switch(heaps[position].count) { /*If criteria is satisfied then drop the object*/ case 1: if(flag==1) { if((computeDistanceBetween2(a->data,data[heaps[position].objects[0]])*1.0/Dmax)<Tcreate) dropObject1(a,position,flag); } else { if((computeDistanceBetween2(a->data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) dropObject1(a,position,flag); } break; default: if(computeDistanceBetween2(a->data,heaps[position].Ocenter)<computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)) dropObject1(a,position,flag); break; } } else { /*Compute the probability to drop the object*/ Pdrop1 = lrand48()%151*1.0/150; if(Pdrop1<Pdrop) dropObject(a,flag); } }//end of function /********************************************************************/ /* Function to move the ant */ /* Output: none */ /* Input: Ant, iteration flag */ /********************************************************************/ void move(ant* a,int flag) { float pDir; /*Check the speed */ if (a->speed!=0) { /*move in the same direction*/ a->speed--; moveNext(a,flag); } else { /*generate the new direction*/ pDir=lrand48()%17*1.0/16.0; if(pDir<.85) { a->dir=lrand48()%8; } else if(pDir>.95) { a->speed=2; } moveNext(a,flag); } } /********************************************************************/ /* Function to simulate the movement of the ants */ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified: minHeapCount, minHeapPosition */ /********************************************************************/ void iterate(int flag) { int i=0,j=0,k=0,loopCount=0; if (flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS; while (i<MAXITERATIONS) { i++; for(j=0;j<loopCount;j++) { move(&ants[j],flag); if(ants[j].carrying==1) { drop(&ants[j],flag); } else { pick(&ants[j],flag); } } if(debugLevel>0){ for(k=0;k<heapCount;k++) for(j=0;j<heapCount;j++) if((k!=j)&&(heaps[k].x==heaps[j].x)&&(heaps[k].y==heaps[j].y)) { printf("\nerror two heaps with same co ordinates %d %d ",k,j); //getchar(); } k=0; for(j=0;j<heapCount;j++) k+=heaps[j].count; } if(heapCount<minHeapCount) { minHeapCount=heapCount; minPosition=i; } if(debugLevel>0) printf("\n i:%d Heap count %d sum %d",i,heapCount,k); else printf("\n i:%d Heap count %d",i,heapCount); heapSum+=heapCount; } }//end of function /********************************************************************/ /*Function to drop the objects carried by the ants after all the iterations*/ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified:none */ /********************************************************************/ void dropFinal(int flag) { int i=0,j=0,position=-1,loopCount=0; loopCount=currentAntCount; for(i=0;i<loopCount;i++) { if(ants[i].carrying==1) { if(flag==1) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position,flag); } } else { /*Find if a heap is present */ do { position=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position,flag); position=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position!=-1); } } } }//end of function /********************************************************************/ /* Function for the implementation of QuickSort */ /* Output: none */ /* Input: data structure, low and high indices */ /* Global structure modified:none */ /********************************************************************/ void quickSort( heap A[], int low,int high ) { int mid=0; if(low<high) { mid=partition(A,low,high); quickSort(A,low,mid); quickSort(A,mid+1,high); } } /********************************************************************/ /* Partition routine used by quick sort */ /* Output: partition location */ /* Input: data , low, high */ /* Global structure modified:none */ /********************************************************************/ int partition(heap a[], int low,int high) { heap temp; int x=0,i=0,j=0; i=low; j=high; x=a[low].count; while (1) { while (a[j].count<x) j=j-1; while (a[i].count>x) i=i+1; if(i<j) { temp=a[i]; a[i]=a[j]; a[j--]=temp; } else return(j); } } /********************************************************************/ /* Function used to write the cluster information */ /* Output: none */ /* Input:iteration flag */ /* Global structure modified:none */ /********************************************************************/ void writeClusterInformation(int flag) { FILE *fp=fopen("center.clt","w"); FILE *fp1; FILE *fp2; FILE *fp3; char temp[80]; int i=0,j=0,k=0; int lastCount=0; int rowCount,colCount,antCount; strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp3=fopen(temp,"a"); if(dataDump) {strcpy(temp,"");sprintf(temp,"%sTot.out",filename);fp1=fopen(temp,"a");strcpy(temp,"");sprintf(temp,"%sObj.out",filename);fp2=fopen(temp,"a");if(fp1==NULL||fp2==NULL)printf("\n Error in opening file in the writer Cluster Information routine\n"); } rowCount=currentRow; colCount=currentRow; antCount=currentAntCount; if(fp==NULL) { printf("\n Unable to open cluster center output file \n"); /*return;*/ exit(0); } /*sort the array according to the count value and write the value of the top three elements*/ if((flag==1)&&(!EntireHeaps)) quickSort(heaps,0,heapCount); if(EntireHeaps) {if(flag==1) lastCount=heapCount;else lastCount=newHeapCount; } else lastCount=c; for(i=0;i<lastCount;i++) { if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else { for(k=0;k<features;k++) { fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",newHeaps[i].Ocenter[k]); fprintf(fp,"\n"); } else { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); fprintf(fp,"\n"); } } if(dataDump) { fprintf(fp1,"\n Information from the Ant Based Algorithm \n"); fprintf(fp1,"\n Important Parameters : Board %d X %d Ants : %d Iterations %d Total Heaps %d ",rowCount,colCount,antCount,MAXITERATIONS,lastCount); } if(flag==0) { if(dataDump) { fprintf(fp1," TCreateForHeaps %f \n",TcreateForHeaps); fprintf(fp2,"\nTotal Heaps : %d\n",heapCount); fprintf(fp2,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); } fprintf(fp3,"\n@ %d\n",lastCount); } else if(dataDump) fprintf(fp1,"\n");if(dataDump) { fprintf(fp1,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); for(i=0;i<lastCount;i++) if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp2,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); } fprintf(fp1," %5d\n",newHeaps[i].count); fprintf(fp2," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp1," %5d\n",heaps[i].count); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]); fprintf(fp1," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]); fprintf(fp1," %5d\n",heaps[i].count); }} if(flag==0) { if(dataDump) fprintf(fp1,"\n Objects in the heaps \n");for(i=0;i<newHeapCount;i++) { if(dataDump) fprintf(fp1,"\n\n Heap %d\n \n",i+1);fprintf(fp3,"# %d %d\n",i ,newHeaps[i].count); for(j=0;j<newHeaps[i].count;j++){ for(k=0;k<features;k++){ fprintf(fp3,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]); if(dataDump) fprintf(fp1,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]);} if(dataDump) fprintf(fp1,"\n"); fprintf(fp3,"\n"); } } } fclose(fp); fclose(fp3); if(dataDump) { fclose(fp1);fclose(fp2); }}//end of flie /********************************************************************/ /* Function to initialise the new heaps */ /* Output: none */ /* Input:new Heap structure */ /* Global structure modified:none */ /********************************************************************/ void initialiseNewHeaps(heap newHeaps[]) { int i=0,j=0; for(i=0;i<lCount;i++) { newHeaps[i].count=0; for(j=0;j<features;j++) newHeaps[i].Ocenter[j]=V[i][j]; newHeaps[i].x=heaps[i].x; newHeaps[i].y=heaps[i].y; } }//end of function /********************************************************************/ /* Function to initialise the new heaps */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ int findPosition(int i) { int j,position=0; for(j=1;j<lCount;j++) { if(U[j][i]>U[position][i]) position=j; } /*printf("\n Position %d ",position);*/ return(position); }//end of function find position /********************************************************************/ /* Function to add object */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ void addObject(int object,heap * heapPosition) { heapPosition->objects[heapPosition->count]=object; heapPosition->count++; }//end of function add object /********************************************************************/ /* Function to harden the outputs obtained from fcm */ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/ void harden(heap newHeaps[]) { int i,heapPosition=-1,sum=0,j=0; /*initialise the new heaps*/ initialiseNewHeaps(newHeaps); for(i=0;i<count;i++) { heapPosition=findPosition(i); addObject(i,&newHeaps[heapPosition]); } /* To check for degenerate partitions*/ for(i=0;i<lCount;i++) { if(newHeaps[i].count==0){for(j=i;j<lCount-1;j++){newHeaps[j]=newHeaps[j+1];}lCount--;i--;} } newHeapCount=lCount; for(i=0;i<lCount;i++) computeHeapParameters(&newHeaps[i],1); if(debugLevel>0) { for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\n sum = %d",sum);} }//end of function/********************************************************************/ /* Function to initialize the initial parameters for the ant algorithm*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void init() { int i=0,j=0; for(i=0;i<MAXROWS;i++) for(j=0;j<MAXCOLS;j++) board[i][j]=-9; heapCount=0; newHeapCount=0; heapRow=0; minPosition=-1; minHeapCount=100000; for(i=0;i<MAXANTS;i++) { ants[i].carrying=-1; ants[i].x=-1; ants[i].y=-1; ants[i].speed=-1; ants[i].dir=-1; } } /********************************************************************/ /* Function to initialize the initial board */ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void initialiseBoard() { int i,j; for(i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; }/********************************************************************/ /* Function to harden the outputs obtained from fcm(2nd stage)*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: Cluster center , cluster center count*/ /********************************************************************/void harden1() { int i=0,heapPosition=-1; for(i=0;i<heapCount;i++) cenCount[i]=0; for(i=0;i<n;i++) { heapPosition=findPosition1(i); addObject1(i,heapPosition); } writeInfo(); }//end of function/********************************************************************/ /* Function to find to which class the object belongs */ /* Output: Class number */ /* Input: object position */ /* Global Structure Modified: None */ /********************************************************************/int findPosition1(int i) { int j,position=0; for(j=1;j<heapCount;j++) { if(U[j][i]>U[position][i]) position=j; } return(position); }//end of function find position/********************************************************************/ /* Function to Write the output of the hardened objects to file*/ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/void writeInfo(){int i=0,j=0,k=0;FILE *fp=fopen("fcm.out","a");if(fp==NULL){printf("\n Unable to open fcm output file \n");return;}fprintf(fp,"\n@ %d\n",heapCount);for(i=0;i<heapCount;i++){fprintf(fp,"# %d %d\n",i,cenCount[i]);for(j=0;j<cenCount[i];j++){for(k=0;k<s;k++)fprintf(fp,"%8.2f ",clsCen[i][j][k]/scale[k]+minInput[k]);fprintf(fp,"\n");}}fclose(fp);return;}/********************************************************************/ /* Function to add a object to a cluster (2nd stage) */ /* Output: none */ /* Input: object poistion , cluster position */ /* Global Structure Modified: Cluster object and cluster count*/ /*******************************************************************/void addObject1(int object,int heapPosition) { int k=0; for(k=0;k<features;k++) clsCen[heapPosition][cenCount[heapPosition]][k]=X[object][k]; cenCount[heapPosition]++; return; }//end of function add object/********************************************************************/ /* Function to read the original classification of objects */ /* Output: none */ /* Input: none */ /* Global Structure Modified: None */ /*******************************************************************/void readOrg(){int i=0,k=0;char temp[80];FILE *fp;strcpy(temp,"");sprintf(temp,"%sFull.data",filename);fp=fopen(temp,"r");if(fp==NULL){printf("\n Unable to open full data input file ");exit(0);}for(i=0;i<n;i++){fscanf(fp,"%f ",&orgData[i][0]);for(k=1;k<s+1;k++)fscanf(fp,"%f ",&orgData[i][k]);}return;}// end of function/********************************************************************/ /* Function to classify the objects in different clusters */ /* Output: none */ /* Input: the cluster objects, the original classification, */ /* number of objects in the cluster,file to write the data */ /* Global Structure Modified: None *//********************************************************************/int analysisData(float data[][s],float orgData[n][s+1],int count,FILE * fp){int i=0,j=0,k=0,type=1,max=0;heapInfo info;for(i=0;i<c;i++){info.classObj[i]=0;}info.total=0;info.total=count;for(i=0;i<count;i++)for(j=0;j<n;j++){type=1;for(k=0;k<s;k++)if(fabs(data[i][k]-orgData[j][k+1])>errThresh){type=-1;break;}if(type!=-1){info.classObj[(int)orgData[j][0]-1]++;break;}}max=0;for(k=0;k<c;k++){if(info.classObj[k]>info.classObj[max])max=k;fprintf(fp,"\nClass %d Objects % d ",k+1,info.classObj[k]);}j=0;for(k=0;k<c;k++){if(k!=max)j+=info.classObj[k];}fprintf(fp,"\n Total errors : %d \n",j);return(j);}//end of analyse/********************************************************************/ /* Function to read the cluster information */ /* Output: none */ /* Input: input file pointer , output file pointer */ /* Global Structure Modified: None *//********************************************************************/void readFCM(FILE* fp,FILE *fp1){int i=0,j=0,k=0,l=0;int totalRuns=0,heapCount=0,junk=0,sum=0;char ch;FILE *fp2=fopen("errors.out","a");ch = 'c'; while (ch != '$') fscanf (fp, "%c", &ch);fscanf(fp,"%d\n",&totalRuns);printf("\n total runs %d ",totalRuns);for(l=0;l<totalRuns;l++){fscanf(fp,"%c",&ch);fscanf(fp,"%d\n",&heapCount);fprintf(fp1,"\n \nExperiment %d \n ",l+1);sum=0;for(i=0;i<heapCount;i++){fscanf(fp,"%c",&ch);fscanf(fp," %d %d\n",&junk,&clsCenCount[i]);for(j=0;j<clsCenCount[i];j++)for(k=0;k<s;k++)fscanf(fp,"%f",&fcmData[i][j][k]);fscanf(fp,"\n");fprintf(fp1,"\n\n Heap %d Total Objects %d \n",i+1,clsCenCount[i]);sum+=analysisData(fcmData[i],orgData,clsCenCount[i],fp1);}fprintf(fp2," %3d %3d %3d \n",l,sum,heapCount);}fprintf(fp2,"\n --------------------------\n");fclose(fp2);return;}//end of functionvoid initRm(int heapCount) { antCount=heapCount*antsPerFeature*features;classes=heapCount;newAnts=(antdata*) calloc(antCount,sizeof(antdata));if(ants==NULL){printf("\n Cannot allocate memory to ants in Rm stage");printf("\n Exiting ... ");exit(-1);}} /***************************************************************************//* Function to initialise the ants *//* Status: under developement *//* Output: the ant structure is modified with initial random values *//* Input : Ant structure (this is modified) *//***************************************************************************/void initializeAntsRm(antdata* ants,center clsCen){int i,j,k;/* Initialize all the ants with initial values and the rest and direction*/for(i=0;i<antCount;i++){ants[i].currPos=drand48();for(j=0;j<memory;j++){ants[i].Rm[j]=inf;for(k=0;k<antsPerFeature;k++)Rm[k][j]=inf;}ants[i].rest=1;ants[i].direction=drand48()<0.5?1:-1;}for(j=0;j<features;j++)for(i=0;i<classes;i++){ants[j*classes+i].currPos=clsCen[i][j];}}/*end of function*//***************************************************************************//* Function that runs one epoch *//* Status: under developement *//* Output: the ant structure is modified with according to the epoch *//* Input : Ant structure (this is modified) *//***************************************************************************/void epoch(antdata* ants){int i,j;float Trest=0,Tcontinue=0,Tinc=0;float dDiff=0.0;float temp=0;dDiff=DmaxRm-Dmin;for(j=0;j<iterations;j++){for(i=0;i<antCount;i++){if(ants[i].rest!=0){Trest=drand48();if(Trest<Prest){ants[i].rest=0;continue;}Tcontinue=drand48();if(Tcontinue>Pcontinue)ants[i].direction=-1*ants[i].direction;Tinc=drand48();temp=ants[i].currPos+ants[i].direction*(Dmin+Tinc*dDiff);if(temp>1||temp<0)ants[i].direction=-1*ants[i].direction;ants[i].currPos+=ants[i].direction*(Dmin+Tinc*dDiff);}}}for(i=0;i<antCount;i++)ants[i].rest=1;}/*end of function*//***************************************************************************//* Function that computes Rm *//* Status: under developement *//* Output: the ant structure is modified, the worst Rm is removed *//* Input : Ant structure (this is modified) *//***************************************************************************/void computeRm(antdata* ants,float data[MAXDATA][features],float newRm[antsPerFeature]){int i,j,k=0,l=0;float clsCenters[antsPerFeature][MAXDATA][features];double Rm=0.0,temp=0.0,Dik=0;for(k=0;k<antsPerFeature;k++)for(j=0;j<features;j++)for(i=0;i<classes;i++){clsCenters[k][i][j]=ants[k*classes*features+j*classes+i].currPos;}for(k=0;k<antsPerFeature;k++){Rm=0;for(i=0;i<count;i++){Dik=0;for(j=0;j<classes;j++){temp=0;for(l=0;l<features;l++)temp+=(data[i][l]-clsCenters[k][j][l])*(data[i][l]-clsCenters[k][j][l]);/*temp=sqrt(temp);*//*temp=NORM(data[i],clsCenters[k][j]);temp=temp*temp;*/Dik+=pow(temp,1.0/(1-m));}Rm+=pow(Dik,(1-m));}newRm[k]=Rm;}return;}/*end of function*//********************************************************************//* Function to update the memory of the ants *//* Output: none *//* Input: ant structure and the new Rm, old memory *//* Global Structure Modified: none *//********************************************************************/void updateMemory(antdata* ants,float newRm[antsPerFeature],float Rm[antsPerFeature][memory]){int i,minPosition[antsPerFeature],maxPosition[antsPerFeature],flag[antsPerFeature],k,j,b[memory],infCount=0;float temp=0,tempRm[memory],tChoose=0,pContinueCurr=0;for(i=0;i<antsPerFeature;i++){minPosition[i]=0;maxPosition[i]=0;flag[i]=1;}for(k=0;k<antsPerFeature;k++){b[0]=0;for(i=1;i<memory;i++){if(Rm[k][i]<Rm[k][minPosition[k]])minPosition[k]=i;if(Rm[k][i]>Rm[k][maxPosition[k]])maxPosition[k]=i;if(Rm[k][i]==newRm[k]){flag[k]=0;break;}temp=(newRm[k]-Rm[k][i])*1.0/Rm[k][i];if(temp<0) temp=-1*temp;if(temp<minChange){flag[k]=0;break;}b[i]=i;}if(flag[k]==1){if(newRm[k]<Rm[k][maxPosition[k]]){for(j=0;j<features;j++)for(i=0;i<classes;i++){ants[k*classes*features+j*classes+i].Rm[maxPosition[k]]=ants[k*classes*features+j*classes+i].currPos;}Rm[k][maxPosition[k]]=newRm[k];}else{/* find min Rm and restore its position*/infCount=0;for(i=0;i<memory;i++){tempRm[i]=Rm[k][i];if(Rm[k][i]==inf) infCount++;}for(i=0;i<memory;i++)for(j=0;j<memory-1-i;j++){if(tempRm[j]>tempRm[j+1]){temp=tempRm[j];tempRm[j]=tempRm[j+1];tempRm[j+1]=temp;temp=b[j];b[j]=b[j+1];b[j+1]=temp;}}tChoose=drand48();if(tChoose<0.6){minPosition[k]=b[0];}else if (tChoose<0.8){minPosition[k]=b[1];}else if(tChoose<0.9){minPosition[k]=b[2];}else if(tChoose<0.975){minPosition[k]=b[3];}else {minPosition[k]=b[4];}pContinueCurr=drand48();if(pContinueCurr<tContinueCurr){/*for(j=0;j<features;j++)for(i=0;i<classes;i++){ants[k*classes*features+j*classes+i].Rm[maxPosition[k]]=ants[k*classes*features+j*classes+i].currPos;}Rm[k][maxPosition[k]]=newRm[k];*/}else if(Rm[k][minPosition[k]]!=inf)for(j=0;j<features;j++)for(i=0;i<classes;i++){ants[k*classes*features+j*classes+i].currPos=ants[k*classes*features+j*classes+i].Rm[minPosition[k]];}}}}}/* end of function *//********************************************************************//* Function to cluster according to the cluster centroids *//* Output: none *//* Input: ant structure and the data points *//* Global Structure Modified: none *//********************************************************************/void finalCluster(antdata* ants,float data[MAXDATA][features],float Rm[antsPerFeature][memory]){int i,j,position[MAXDATA],minPosition=0,k=0,l=0,minRm=0;float clsCenters[antsPerFeature][MAXDATA][features];float distance[MAXDATA];int cenCount[MAXDATA],classCount[MAXDATA][c];float temp=0;int clsObjects[MAXDATA][MAXDATA],label[MAXDATA];int minPosition1[antsPerFeature],maxPosition1[antsPerFeature];FILE *fp,*fpOut,*fpCls,*fpMinRm,*fpOrgClass,*fpRm;fp=fopen("fcmRm.out","a");fpOut=fopen("ClassData.out","a");fpCls=fopen("clsCenters.out","a");fpMinRm=fopen("minRm.out","a");fpOrgClass=fopen("orgClass.out","a");fpRm=fopen("Rm.out","a");if(fp==NULL){printf("\n Unable to open fcm output file \n");return;}for(k=0;k<antsPerFeature;k++){for(j=0;j<features;j++)for(i=0;i<classes;i++)clsCenters[k][i][j]=ants[k*classes*features+j*classes+i].currPos;minPosition1[k]=0;maxPosition1[k]=0;}for(k=0;k<antsPerFeature;k++){for(i=1;i<memory;i++){if(Rm[l][i]<Rm[l][minPosition1[l]])minPosition1[l]=i;if(Rm[l][i]>Rm[l][maxPosition1[l]])maxPosition1[l]=i;}}minRm=0;for(k=1;k<antsPerFeature;k++){if(Rm[k][minPosition1[k]]<Rm[minRm][minPosition1[minRm]])minRm=k;}fprintf(fpRm,"Rm %8.4f\n",Rm[minRm][minPosition1[minRm]]);fclose(fpRm);Fcm(data,clsCenters[minRm],2);hardenRm();for(l=0;l<antsPerFeature;l++){fprintf(fpCls,"Cluster number %2d\n",l);for(j=0;j<classes;j++){distance[j]=inf;cenCount[j]=0;for(k=0;k<c;k++)classCount[j][k]=0;}fprintf(fp,"* %d\n",l);if(l==minRm)fprintf(fpMinRm,"* %d\n",l);for(i=0;i<count;i++){minPosition=0;for(k=0;k<classes;k++){temp=0.0;for(j=0;j<features;j++)temp+= (clsCenters[l][k][j]-data[i][j])*(clsCenters[l][k][j]-data[i][j]);temp=sqrt(temp);distance[k]=temp;if(distance[k]<distance[minPosition])minPosition=k;}position[i]=minPosition;clsObjects[minPosition][cenCount[minPosition]]=i;cenCount[minPosition]++;}for(j=0;j<classes;j++){for(i=0;i<cenCount[j];i++)classCount[j][(int)orgData[clsObjects[j][i]][0]-1]++;}/* minPosition varaible re used , now minPosition denotes the maximum class of the cluster*/fprintf(fpOrgClass,"\nCluster number: %2d \n",l);for(j=0;j<classes;j++){minPosition=0;fprintf(fpOrgClass,"\n Cluster %2d \n",j+1);fprintf(fpOrgClass,"%2d %2d\n",1,classCount[j][0]);for(i=1;i<c;i++){if(classCount[j][i]>classCount[j][minPosition]) minPosition=i;label[j]=minPosition;fprintf(fpOrgClass,"%2d %2d\n",i+1,classCount[j][i]);}}for(i=0;i<count;i++){for(j=0;j<classes;j++)for(k=0;k<cenCount[j];k++)if(clsObjects[j][k]==i){fprintf(fp,"%d ",label[j]+1);break;}}fprintf(fp,"\n");fprintf(fpOut,"\nCluster number: %2d \n",l);for(i=0;i<classes;i++){fprintf(fpOut,"%2d %4d\n",label[i]+1,cenCount[i]);for(j=0;j<features;j++)fprintf(fpCls,"%8.7f ",clsCenters[l][i][j]/scale[j]+minInput[j]);fprintf(fpCls,"\n");}}/* Write the data to the file */fclose(fp);fclose(fpOut);fclose(fpCls);fclose(fpMinRm);fclose(fpOrgClass);}/* end of function *//********************************************************************//* Function to amnalyze the results *//* Output: none *//* Input: *//* Global Structure Modified: none *//********************************************************************/void analysis(int flag){int i,j,k,temp;char junk;int totalRuns=0,errors[antsPerFeature],epoch=0,position=0,antsperfeature=0,clsNumber=0,min=0,currMinRm;FILE *fp,*fpError,*fpMin,*fpMinRm,*fpMinIp;if(flag==1){fp=fopen("fcmRm.out","r");fpMinIp=fopen("minRm.out","r");fpMinRm=fopen("minRmError.out","w");fpError=fopen("error.out","w");fpMin=fopen("minError.out","w");}else{fp=fopen("fcmFCM.out","r");fpError=fopen("errorFCM.out","w");}if(fp==NULL||fpError==NULL){printf("\n unable to open files in the analysis module \n");return;}fscanf(fp,"%c %d\n",&junk,&totalRuns);fscanf(fp,"%c %d\n",&junk,&antsperfeature);if(flag==1){fscanf(fpMinIp,"%c %d\n",&junk,&temp);fscanf(fpMinIp,"%c %d\n",&junk,&temp);}for(i=0;i<totalRuns;i++){for(j=0;j<antsperfeature;j++){errors[j]=0;}fscanf(fp,"%c %d\n",&junk,&epoch);if(flag==1){fscanf(fpMinIp,"%c %d\n",&junk,&temp);fscanf(fpMinIp,"%c %d\n",&junk,&currMinRm);}fprintf(fpError,"Experiment %3d ",i);for(k=0;k<antsperfeature;k++){fscanf(fp,"%c %d\n",&junk,&clsNumber);for(j=0;j<count;j++){fscanf(fp,"%d ",&position);if(orgData[j][0]!=position)errors[k]++;}fscanf(fp,"\n");if(flag==1){fprintf(fpError,"\nCluster %3d Errors %5d",k,errors[k]);if(k==currMinRm){fprintf(fpMinRm,"Cluster %2d Errors %5d\n",k,errors[k]);}}else fprintf(fpError," Errors %5d\n",errors[k]);}if(flag==1){min=0;for(j=1;j<antsPerFeature;j++){if(errors[j]<errors[min])min=j;}fprintf(fpMin,"Exp %2d Min Error %5d\n",i,errors[min]);}}fclose(fp);fclose(fpError);if(flag==1){fclose(fpMin);fclose(fpMinRm);fclose(fpMinIp);}}/* end of function */ void RmStage(int heapCount,center clsCen) { FILE *fpTime=fopen("time.out","a");int flag[antsPerFeature],flg;struct rusage start_usage, end_usage,epoch_start_usage, epoch_end_usage;double *perf_times;float newRm[antsPerFeature],oldRm[antsPerFeature],temp;int i=0,j=0,k=0;initRm(heapCount);initializeAntsRm(newAnts,clsCen);for(i=0;i<antsPerFeature;i++){oldRm[i]=inf;newRm[i]=inf;}flg=1;i=0;getrusage(RUSAGE_SELF, &start_usage);while(i<maxEpocs){getrusage(RUSAGE_SELF, &epoch_start_usage);epoch(newAnts);getrusage(RUSAGE_SELF, &epoch_end_usage);perf_times=timing_of(epoch_start_usage,epoch_end_usage); fprintf(fpTime,"Epoch %3d Timing: %f user, %f system, %f total.\n",i, perf_times[0], perf_times[1], perf_times[0] +perf_times[1]);for(j=0;j<antsPerFeature;j++){oldRm[j]=newRm[j];flag[j]=1;}computeRm(newAnts,data,newRm);updateMemory(newAnts,newRm,Rm);flg=0;for(j=0;j<antsPerFeature;j++){if(newRm[j]!=inf){if(oldRm[j]!=inf){temp=0;temp=newRm[j]-oldRm[j]<0? (oldRm[j]-newRm[j]):(newRm[j]-oldRm[j]);/*printf("\n new %f old %f temp %f ",newRm[j],oldRm[j],temp);*/if(temp/oldRm[j]>minChange){flg=1;break;}}else flg=1;}}i++;printf("\n Epoch %d ",i);}/* Do the final clustering*/finalCluster(newAnts,data,Rm);getrusage(RUSAGE_SELF, &end_usage);perf_times=timing_of(start_usage,end_usage); fprintf(fpTime,"Exp %3d Timing: %f user, %f system, %f total.\n",k, perf_times[0], perf_times[1], perf_times[0] +perf_times[1]);/* Compute the error */} /****************************************************************/ void Fcm (objects X1,center V,int flag) { int i,j,l; FILE *ofile,*fpJm; FILE *iniClsCen=fopen("center.clt","a+"); char temp[80]; float jmFinal=0,rmFinal=0; Random_seed=state1[run];/*randseed*/ srand48(Random_seed); for(i=0;i<MAXDATA;i++) for(j=0;j<features;j++)X[i][j]=X1[i][j]; if(iniClsCen==NULL) { printf("\n Unable to open the initial cluster center file\n"); printf("\n choosing random cluster centers....\n"); flag=1; } for (run=0;run<TOTRUNS;run++) { if(flag!=2) { if (EntireHeaps) lCount=heapCount; else lCount=c; for(i=0;i<lCount;i++) for(j=0;j<s;j++) V[i][j]=0; for(i=0;i<lCount;i++) { for(l=0;l<s;l++) { if(flag==1) { rand_index = lrand48() % n; V[i][l] = X[rand_index][l]; } else { fscanf(iniClsCen,"%f ",&V[i][l]); } }//end for }}else lCount=heapCount;eps=0.001; stop = FALSE; /* This loop finds the final cluster center and the corresponding U values */ z = 0; while (stop == FALSE) { z++; UMAT(U,V,X); /** Update the U matrix **/stop = FINISHED(U1,eps); CLUSTER(U,X,V); /** Get new cluster center **/printf("\nIteration: %d \n",z); } /* end while */ printf("Number of iterations: %d\n\n", z);strcpy(temp,""); sprintf(temp,"%sFCM.out",filename);if(flag==1){jmFinal=Compute_Jm(V,X);rmFinal=Compute_Rm(V,X);fpJm=fopen("jm.out","a");fprintf(fpJm," classes %2d Jm: %10.6f Rm: %10.6f\n",lCount,jmFinal,rmFinal);fclose(fpJm);} if(flag==2) Output(temp,V,X); /* output the results */ }/*end for*/ ofile=fopen(temp,"a"); for (i=0; i <= mins; i++) fprintf(ofile, "Min %d of %10.3f occurred %d times\n", i, mintab[i], mincount[i]); fprintf(ofile, "Average iterations %f\n", (float)aveit/(float)TOTRUNS); fclose(ofile); }/* end Main */ /* The NORM function computes the norm of two vectors, x and v, of dimension s. This gives an indication of the distance between them */ float NORM( feature x, feature v) //feature x, v; { /* Parameters : x -- a local copy of an input vector v -- a local copy of a cluster center */ int i,j; /* loop variable */ double sum; /* the square root of sum is the norm; sum is the sum of the differences squared */ float mat1[features]; float mat2[features]; if (maha) { for (i=0; i<features; i++) mat1[i]=x[i]-v[i]; for(i=0;i<features;i++) { sum =0; for(j=0;j<features;j++) sum += mat1[j] * inv_cov[j][i]; mat2[i] = sum; } sum =0; for(j=0;j<features;j++) sum += mat1[j]*mat2[j]; } else { sum = 0; for(j=0;j<features;j++) sum += (x[j] - v[j])* (x[j] - v[j]); } return (float)(sqrt(sum)); } /* end NORM */ /* The UMAT procedure calculates the updated U matrix according to Bezdek's formula. Its side-effect is the update of the global array U1 */ void UMAT( matrix U,center V, objects X) /*matrix U; center V; objects X;*/ { /* Parameters: U, V, and X: same as in main program */ int i, j, k,l ;/* loop variables *///, class /* class whose cluster center //is closest to pattern k */; float d1,d2,d; float sum; int exact; for (k=0;k<MAXDATA;k++) { /*printf("\n k %d ",k);*/ exact=false; for (i=0;i<lCount;i++) { sum=0; for (j=0;j<lCount;j++) { d1=NORM(X[k],V[i]); d2=NORM(X[k],V[j]); if(d2!=0) { d= d1/d2; d= d * d;/* pow(d1/d2,2.0/(m-1.0)); */ sum+=d; } else { exact = true; for(l=0;l<lCount;l++) if (l==j) U1[l][k]=1.0; else U1[l][k]=0.0; break; } } if (exact!=true) U1[i][k]=1.0/sum; } } } /* end UMAT */ /* The function FINISHED determines if a termination occurs. If not it updates U with U1, so its side-effect is the potential modification of U */ BOOLEAN FINISHED( matrix U1,float eps) //matrix U1; float eps; { /* Parameters: U1, eps-- same as in main */ float sum; /* sum of squared differences between corresponding elements of U and U1 */ int i,k; /* loop control variabes */ BOOLEAN finished; /* set to true if all corresponding elements are within epsilon */ finished = TRUE; sum = 0; for (i=0; i<lCount; i++) for (k=0; k<MAXDATA; k++) sum += (U[i][k] - U1[i][k])*(U[i][k]-U1[i][k]); if (sqrt(sum) > eps) { finished = FALSE; for (i=0; i<lCount; i++) for (k=0; k<MAXDATA; k++) U[i][k] = U1[i][k]; } /* end if */ return finished; } /* end FINISHED */ /* The CLUSTER procedure determines cluster centers in V for the c classes being searched for. The global array V is updated */ void CLUSTER( matrix U, objects X,center V) //matrix U; objects X; { /* Parameters: U, X -- as in main */ int i, j, k; /* loop control variables */ feature num; /* numerator in the cluster center computation formula presented by Bezdek */ float denum; /* denumenator in the obove formula */ for (i=0; i<lCount; i++) { denum = 0; for (j=0; j<features; j++) { num[j] = 0; for (k=0; k<MAXDATA; k++) num[j] += U[i][k] * U[i][k] * X[k][j]; /* pow(U[i][k],m) * X[k][j]; */ } /* end for */ for (k=0; k<MAXDATA; k++) denum += U[i][k] * U[i][k]; /* pow(U[i][k],m); */ for (j=0; j<features; j++) V[i][j] = num[j] / denum; } /* end for */ } /* end CLUSTER */ float Compute_Jm(center V, objects X) //center V; //objects X; { int i, k,found; double Jm_value; float u,dik; Jm_value = 0; for (k=0; k<MAXDATA; k++) { found = FALSE; for (i=0; i<lCount; i++) { dik=NORM(X[k],V[i]); dik=dik*dik; if (dik==0.0) { if (found == FALSE) { u=1.0; found = TRUE; printf("found the case with dik=0\n"); } else { printf("\n cant proceed with this initialization"); exit(1); } } else { if (found != TRUE) u=U1[i][k]; /* get_Uvalue(V,X,dik,k); */ else u=0.0; } Jm_value += u * u * dik;/* pow(u, m) * dik; */ } } return (Jm_value); } /* end Compute_Jm */ /* The Output procedure outputs the U matrix which gives the fuzzy measure of each feature belonging to a cluster center. It also outputs the cluster center for each class */ void Output(char fname[],center V,objects X) //char fname[80]; /* Parameters: U, V -- same as in main */ { int i, j, found; /* loop control variables */ float J2c,R2c; FILE *fpJm=fopen("JmRm.out","a"),*fp; if ((fp=fopen(fname,"a"))==NULL) printf("\n CAN'T OPEN %s\n",fname); else { fprintf(fp,"\n \n"); for (i=0; i<lCount; i++) { fprintf(fp,"\n"); for (j=0; j<features; j++) fprintf(fp,"%4.3f ",V[i][j]); } /* end for */ } /* end if */ J2c= Compute_Jm(V,X); R2c=Compute_Rm(V,X); fprintf(fpJm,"Classes: %3d Jm: %10.6f Rm: %10.6f \n",lCount,J2c,R2c); found =0; for (i=0;i<= mins; i++) { if ((found == 0) && ((J2c - mintab[i]) < .001) && ((J2c - mintab[i]) > -.001)){ mincount[i]++; found = 1; } } if (found == 0) { mins++; mintab[mins]=J2c; mincount[mins]=1; } fprintf(fp,"\nJ%2d = %f", m,J2c); fprintf(fp, "Number of iterations: %d\n\n", z); aveit=aveit + z; fclose(fp); fclose(fpJm); } /***************************************************************/ void find_covar( ) { int i,j,k; float mean[features],sum; for (i=0;i<features;i++) mean[i]=0; for (i=0;i<features;i++) for (j=0;j<m;j++) mean[i]+=X[j][i]; for (i=0;i<features;i++) mean[i]/=m; for (i=0;i<features;i++) for (j=0;j<features;j++) { sum=0; for (k=0;k<m;k++) sum+=(X[k][i]-mean[i])*(X[k][j]-mean[j]); Y[i][j]=sum/m; } }float Compute_Rm(center V, objects X){int i=0,j=0,l=0;double Dik=0,temp=0,Rm=0;Rm=0;for(i=0;i<MAXDATA;i++){Dik=0;for(j=0;j<lCount;j++){temp=0;for(l=0;l<features;l++)temp+=(X[i][l]-V[j][l])*(X[i][l]-V[j][l]);/*temp=sqrt(temp);*//*temp=NORM(X[i],V[j]);temp=temp*temp;*/Dik+=pow(temp,1.0/(1-m));}Rm+=pow(Dik,(1-m));}return(Rm);}/* End of function *//********************************************************************/ /* Function to harden the outputs obtained from fcm(2nd stage)*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: Cluster center , cluster center count*/ /********************************************************************/void hardenRm() { FILE *fp=fopen("fcmFCM.out","a"); FILE *fpOut=fopen("ClassDataFCM.out","a"); int i=0,minPosition=-1,position[MAXDATA],j=0,k=0; int cenCount[MAXDATA],classCount[MAXDATA][c],label[c], clsObjects[MAXDATA][MAXDATA]; for(j=0;j<classes;j++) {cenCount[j]=0;for(k=0;k<classes;k++)classCount[j][k]=0; } for(i=0;i<MAXDATA;i++) { minPosition=findPosition(i); position[i]=minPosition;clsObjects[minPosition][cenCount[minPosition]]=i;cenCount[minPosition]++; } for(j=0;j<classes;j++) {for(i=0;i<cenCount[j];i++)classCount[j][(int)orgData[clsObjects[j][i]][0]-1]++; } /* minPosition varaible re used , now minPosition denotes the maximum class of the cluster*/for(j=0;j<classes;j++){minPosition=0;for(i=1;i<c;i++){if(classCount[j][i]>classCount[j][minPosition]) minPosition=i;label[j]=minPosition;}}fprintf(fp,"* %d\n",0);for(i=0;i<count;i++){for(j=0;j<classes;j++)for(k=0;k<cenCount[j];k++)if(clsObjects[j][k]==i){fprintf(fp,"%d ",label[j]+1);break;}}fprintf(fp,"\n");for(i=0;i<classes;i++){fprintf(fpOut,"%2d %4d\n",label[i]+1,cenCount[i]);}fclose(fpOut);fclose(fp);return; }/*end of function*/ /********************************************************************//* Function Main *//********************************************************************/ int main(int argc, char** argv){int k=0,i=0,j=0;int sum=0;char temp[80];FILE *fpRmOut=fopen("fcmRm.out","w");FILE *fpOut=fopen("ClassData.out","w");FILE *fpCls=fopen("clsCenters.out","w");FILE *fpMinRm=fopen("minRm.out","w");FILE *fpOrgClass=fopen("orgClass.out","w");FILE *fpRm=fopen("Rm.out","w");FILE *fpJmRm=fopen("JmRm.out","w");FILE *fp=fopen("fcm.out","w");FILE *fp1; FILE *fp2=fopen("antAnalysis.out","a");FILE *fp3=fopen("fcmAnalysis.out","a"); FILE *fp4=fopen("errors.out","w");FILE *fp5;FILE *fpJm=fopen("jm.out","w");FILE *fpTime=fopen("time.out","w");FILE *fpFCM=fopen("fcmFCM.out","w");FILE *fpOutFCM=fopen("ClassDataFCM.out","w");fprintf(fpFCM,"# %d\n",EXPRUN);fprintf(fpFCM,"@ %d\n",1);fclose(fpFCM);fclose(fpOutFCM);fclose(fp4);fclose(fpJm);sprintf(temp,"%sObj.out",filename);fp5=fopen(temp,"w");fclose(fp5);strcpy(temp,"");sprintf(temp,"%sTot.out",filename);fp5=fopen(temp,"w");fclose(fp5);strcpy(temp,"");sprintf(temp,"%sOp.out",filename);fp1=fopen(temp,"w");fprintf(fp,"\n$%d",EXPRUN);fprintf(fp1,"\n$%d",EXPRUN);fclose(fp);fclose(fp1);fclose(fpJmRm);fprintf(fpRmOut,"# %d\n",EXPRUN);fprintf(fpRmOut,"@ %d\n",antsPerFeature);fclose(fpRmOut);fprintf(fpTime,"Experiments %d\n",EXPRUN);fprintf(fpMinRm,"# %d\n",EXPRUN);fprintf(fpMinRm,"@ %d\n",antsPerFeature);fclose(fpMinRm);fclose(fpOut);fclose(fpCls);fclose(fpOrgClass);fclose(fpRm);fclose(fpTime);/*readInput();*/ if(argc==2)sscanf(argv[1],"%d",&debugLevel); printf("\n Debug level %d\n",debugLevel); for( i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; readInput(); readOrg(); //Compute the distance of all the points if(maxDist) { Dmax=computeDistance(); //Compute the maximum distance fp5=fopen("maxData.txt","w");fprintf(fp5,"%f",Dmax);fclose(fp5); } else {fp5=fopen("maxData.txt","r");fscanf(fp5,"%f",&Dmax);fclose(fp5); } printf("\n %f \n",Dmax); //Initialise the board for(k=0;k<EXPRUN;k++) { fpRmOut=fopen("fcmRm.out","a");fpOut=fopen("ClassData.out","a");fpCls=fopen("clsCenters.out","a");fpOrgClass=fopen("orgClass.out","a");fpMinRm=fopen("minRm.out","a");fpRm=fopen("Rm.out","a");fpTime=fopen("time.out","a");fpFCM=fopen("fcmFCM.out","a");fpOutFCM=fopen("ClassDataFCM.out","a");fprintf(fpFCM,"$ %d\n",k);fprintf(fpOutFCM,"Experiment %d\n",k);fprintf(fpRm,"Exp: %2d ",k);fclose(fpRm);fprintf(fpCls,"EXP No %2d \n",k);fclose(fpCls);fprintf(fpRmOut,"$ %d\n",k);fprintf(fpMinRm,"$ %d\n",k);fprintf(fpOut,"Experiment %d\n",k);fprintf(fpOrgClass,"Experiment %d\n",k);fprintf(fpTime,"Experiment %d\n",k);fclose(fpRmOut);fclose(fpOut);fclose(fpMinRm);fclose(fpOrgClass);fclose(fpTime); fclose(fpFCM);fclose(fpOutFCM); init(); sum=0; srand48(state1[k]); initialiseBoard(); initialise(1); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(1); printf("\n %d \n",heapCount); //Simulate the working of ants iterate(1); //drop the objects after all the iterations dropFinal(1); //to verify the correctness for(i=0;i<heapCount;i++) sum+=heaps[i].count; //write the cluster centers to the file writeClusterInformation(1); printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); //getchar(); //Run FCM // heapCount=2973;/* To be commented */ printf("\n\n k %d \n\n",k); Fcm(data,V,0); //compute new board size. lCount=heapCount; heapRow=(int)ceil(sqrt(4*heapCount)); newHeapCount=lCount; printf("\n LCount %d newHeapCount %d heap Row %d \n",lCount,newHeapCount,heapRow); //harden the objects harden(newHeaps); //iterate with the heaps as the objects. initialiseBoard(); initialise(0); for(i=0;i<lCount;i++) computeHeapParameters(&heaps[i],0); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(0); printf("\n %d \n",heapCount); //getchar(); //Simulate the working of ants iterate(0); dropFinal(0); writeClusterInformation(0); sum=0; for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); // getchar(); fpJm=fopen("jm.out","a"); fprintf(fpJm,"Experiment %2d: ",k); fclose(fpJm); Fcm(data,V,1); harden1(); RmStage(newHeapCount,V); } fp=fopen("fcm.out","a"); fp1=fopen(temp,"a"); fprintf(fp,"\n"); fprintf(fp1,"\n"); fclose(fp); fclose(fp1); fp=fopen("fcm.out","r"); fp1=fopen(temp,"r");printf("\n Before read org\n");printf("\nafter read org\n");readFCM(fp1,fp2);printf("\n After 1st read fcm\n");readFCM(fp,fp3);printf("\n After 2 fcm read \n");analysis(1);analysis(0);return(1); }//end of main
Parag Kanade/Combined Algorithm/british.c
#include "headerStatic.h" /********************************************************************/ /********************************************************************/ /* Function to read the input data set */ /* The file name is assumed to be itest.data */ /* Status: Tested */ /* Output: Data from the file into the "data" (Global) data structure */ /* Output: Count (Global), the count of the number of objects */ /********************************************************************/ void readInput() { FILE *fp; char fname[80]; int i=0,j=0; char ch; sprintf(fname,"%s.data",filename); /* Check if the input file is opened */ if((fp=fopen(fname,"r"))==NULL) { printf("\n Unable to open input file \n"); exit(0); } /*initialise the minimum maximum and the scale */ for(i=0;i<features;i++) { minInput[i]=1000; maxInput[i]=0; minForHeaps[i]=1000; maxForHeaps[i]=0; scale[i]=0; scaleForHeaps[i]=0; } /* Discard leading comments */ ch = 'c'; while (ch != '#') fscanf (fp, "%c", &ch); i=0; /* Parse the file and populate the data structure */ while(!feof(fp)) { for(j=0;j<features;j++) { fscanf(fp,"%f ",&data[i][j]); } fscanf(fp,"\n"); for(j=0;j<features;j++) { if(data[i][j]<minInput[j]) minInput[j]=data[i][j]; if(data[i][j]>maxInput[j]) maxInput[j]=data[i][j]; } i++; } count=i; /* Normailze the feature values in between 0 and 1 */ for(j=0;j<features;j++) { if(minInput[j]!=maxInput[j]) scale[j]=1.0/(maxInput[j]-minInput[j]); else scale[j]=1.0; } for(i=0;i<count;i++) { for(j=0;j<features;j++) data[i][j]=(data[i][j]-minInput[j])*scale[j]; } fclose(fp); return; }//end of function /********************************************************************/ /*Function to compute the eucldiean distance for all input data set */ /* Output : an array conatining the distance of each object with the other */ /********************************************************************/ float computeDistance() { float distance,dist=0; int i=0,j=0,k=0; distance=0; for(j=0;j<count;j++) for(i=0;i<count;i++) { for(k=0;k<features;k++) dist+=sqrt((data[j][k]-data[i][k])*(data[j][k]-data[i][k])); if(distance<dist)distance=dist; dist=0; } return(distance); } /********************************************************************/ /* Function to compute the distance between two objects */ /* Output : Euclidean d istance between the two input objects */ /********************************************************************/ float computeDistanceBetween2(irisData a,irisData b) { float temp=0; int i=0; for(i=0;i<features;i++) temp+=(a[i]-b[i])*(a[i]-b[i]); temp=sqrt(temp); return(temp); } /********************************************************************/ /* Function to compute the value of an object */ /********************************************************************/ float value(irisData a) { int i=0; float temp=0; for(i=0;i<features;i++) temp+=a[i]*a[i]; return(sqrt(temp)); } /********************************************************************/ /* Function to find the object in the data structure */ /* Output : The position of the object in the data */ /* Input : The object */ /********************************************************************/ int findInData(irisData object,int iFlag) { int i=0,lastCount=0,j,position=-1,flag[features],flg;if(iFlag==1)lastCount=MAXDATA;else{}for(i=0;i<lastCount;i++){ for(j=0;j<features;j++) if(fabs(object[j]-data[i][j])<0.00001) flag[j]=1; else { flag[j]=0; break;} flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /* Function to find whether there is an object on the board at a,b */ /* Output : a flag indicating whether an object is found or not */ /* Input : The row and column indicating the board position */ /********************************************************************/ int found(int a , int b) { if(board[a][b]==9) return 1; else return 0; } /********************************************************************/ /* Function to initialize the initial board */ /* Output : None */ /* Global Structures modified : heaps */ /* Input : Flag indicating the iteration 1: First 0: Second */ /********************************************************************/ void initialise(int flag) { int a,b,i=0,k=0; int loopCount,rowCount,colCount; /* Initialize the row, column and number of heaps */ if(flag==1) { loopCount=count; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=lCount; rowCount=heapRow; colCount=heapRow; } /* Initialize the heaps */ for(i=0;i<loopCount;i++) { heaps[i].count=0; heaps[i].x=0; heaps[i].y=0; heaps[i].disPosition=0; heaps[i].Dmax=0; heaps[i].Dmean=0; } for(i=0;i<loopCount;i++) { /*find a board position which is empty*/ do { a=lrand48()%rowCount; b=lrand48()%colCount; } while(found(a,b)); /*Allocate the object to that place and assign a heap to it*/ heaps[i].x=a; heaps[i].y=b; heaps[i].count=1; heaps[i].Dmax=0; heaps[i].Dmean=0; if(flag==1) { heaps[i].objects[0]=i; for(k=0;k<features;k++)heaps[i].Ocenter[k]=data[i][k]; } else { for(k=0;k<features;k++) heaps[i].Ocenter[k]=newHeaps[i].Ocenter[k]; } heaps[i].disPosition=0; board[a][b]=9; if((debugLevel>0)&&(flag==1))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],data[heaps[i].objects[0]][0]); if((debugLevel>0)&&(flag==0))printf("heap %3d x %3d y %3d centre Ist feature %6.3f Ist Feature %5.3f\n",i,heaps[i].x,heaps[i].y,heaps[i].Ocenter[0],newHeaps[i].Ocenter[0]); } /*initialise the initial heap count*/ heapCount=loopCount; currentRow=rowCount; } /********************************************************************/ /* Function to find whether an heap is present at the location a b */ /* Output : Flag indicating the presencs of the heap */ /* Input : Roe and column indicating the board position */ /********************************************************************/ int findObject(int a,int b) { int i; int position=-1; for(i=0;i<heapCount;i++) { if((heaps[i].x==a)&&(heaps[i].y==b)) { position=i; break; } } return(position); } /********************************************************************/ /* Function initialize the ants */ /* Output : None */ /* Input : Flag indicating the iteration */ /* Global Variables Modified : ant, heapCount, heaps, board */ /********************************************************************/ void initialiseAnts(int flag) { int i=0,a=0,b=0,position,j=0,loopCount=0,rowCount,colCount,k=0; if(flag==1) { loopCount=MAXANTS; rowCount=MAXROWS; colCount=MAXCOLS; } else { loopCount=MAXANTSFORHEAPS; rowCount=heapRow; colCount=heapRow; } for(i=0;i<loopCount;i++) { /*generate random positions for the ants*/ a=lrand48()%rowCount; b=lrand48()%colCount; ants[i].x=a; ants[i].y=b; /*Find if an object is present at that position or not*/ if(board[a][b]==9) { ants[i].carrying=1; /*find the heap at that location*/ position=findObject(a,b); if(position==-1) { printf("\n Error in logic: Ant init \n"); //getchar(); break; } else { /*Assign the heap data to the ant data and decrement the heap count*/ if(flag==1){ for(k=0;k<features;k++)ants[i].data[k]=data[heaps[position].objects[0]][k]; }else{for(k=0;k<features;k++)ants[i].data[k]=heaps[position].Ocenter[k];} for(j=position;j<heapCount-1;j++) heaps[j]=heaps[j+1]; heapCount--; } /*Clear the board position */ board[a][b]=-9; } else ants[i].carrying=-1; ants[i].speed=0; ants[i].dir=lrand48()%8; printf("\n Ant %2d X: %2d Y: %2d Carying : %2d ",i,ants[i].x,ants[i].y,ants[i].carrying); } currentAntCount=loopCount; } /********************************************************************/ /* Function to move the ant */ /* Output: None */ /* Input: Ant to be moved and the flag indicating the iteration */ /********************************************************************/ void moveNext(ant* a,int flag) { int rowCount,colCount; rowCount=currentRow;colCount=currentRow; /*Depending upon the direction move the ant*/ switch (a->dir) { case 0: a->y++; if(a->y>=colCount)a->y=0; break; case 1: a->x--; a->y++;; if(a->x<0)a->x=rowCount-1; if(a->y>=colCount)a->y=0; break; case 2: a->x--; if(a->x<0)a->x=rowCount-1; break; case 3: a->x--; a->y--; if(a->x<0)a->x=rowCount-1; if(a->y<0)a->y=colCount-1; break; case 4: a->y--; if(a->y<0)a->y=colCount-1; break; case 5: a->x++; a->y--; if(a->x>=rowCount)a->x=0; if(a->y<0)a->y=colCount-1; break; case 6: a->x++; if(a->x>=rowCount) a->x=0; break; case 7: a->x++; a->y++; if(a->x>=rowCount)a->x=0; if(a->y>=colCount)a->y=0; break; } }//end of function /********************************************************************/ /* Function to compute the parameters of the heap */ /* Output: None */ /* Input: The heap whose parameters are to be computed iteration flag*/ /********************************************************************/ void computeHeapParameters(heap* heapData,int flag) { int i=0,j=0,k=0,position=0; float distance=0; float Dmean=0.0; float *dis; float featureSum[features]; float max=0; float sum=0; /* init*/ for(k=0;k<features;k++) featureSum[k]=0; /*Compute the distance of each object and find the maximum distance*/ max=0; if(flag==1){ for(j=0;j<heapData->count;j++) for(i=0;i<heapData->count;i++) { for(k=0;k<features;k++) sum+= (data[heapData->objects[j]][k]-data[heapData->objects[i]][k])*(data[heapData->objects[j]][k]-data[heapData->objects[i]][k]); distance=sqrt(sum); if(max<distance) max=distance; sum=0; } /* Assign the maximum distance to the heap */ heapData->Dmax=max;/*Compute the centre object*/for(i=0;i<heapData->count;i++)for(k=0;k<features;k++) featureSum[k]+=data[heapData->objects[i]][k];for(k=0;k<features;k++)heapData->Ocenter[k]=featureSum[k]*1.0/heapData->count; /* Find the mean distance */if((dis=(float *) calloc(heapData->count,sizeof(float)))==NULL){printf("\nUnable to allocate memory in the compute heap parameters procedure\n");exit(0);} for(i=0;i<heapData->count;i++) { Dmean+=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); dis[i]=computeDistanceBetween2(heapData->Ocenter,data[heapData->objects[i]]); } heapData->Dmean=Dmean*1.0/heapData->count; /*Compute the most dissimilar object*/ max=dis[0]; for(i=1;i<heapData->count;i++) if(max<dis[i]) { max=dis[i]; position=i; } /*Assign the most dissimilar object to the heap variable*/ for(k=0;k<features;k++) heapData->Odissim[k]=data[heapData->objects[position]][k]; heapData->disPosition=position;free(dis); } else{/* Heap Parameters for the second stage */for(k=0;k<features;k++){ heapData->Odissim[k]=heapData->Ocenter[k];}heapData->disPosition=0;heapData->Dmean=0;heapData->Dmax=0;} }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a single object*/ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject1(ant *a,int position,int flag) { int i,k=0; /*Clear the board*/ board[heaps[position].x][heaps[position].y]=-9; /* Assign the data to the ant*/if(flag==1){ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[0]][k];}else {for(k=0;k<features;k++) a->data[k]=heaps[position].Ocenter[k];} a->carrying=1; /*Copy all the heaps remaining heaps in the structure*/ for(i=position;i<heapCount-1;i++) heaps[i]=heaps[i+1]; /*Decrement the heap count*/ heapCount--; }//end of function /*********************************************************************/ /*Function to pick a object from a heap consisting of a two objects */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /*********************************************************************/ void pickObject2(ant *a , int position,int flag) { float Pdestroy1=-1; int i=0,k=0; /*Compute the probability to destroy the heap*/ Pdestroy1=lrand48()%13*1.0/12.0; /*If the probability is more than Pdestroy then destroy the heap */ if(Pdestroy1<Pdestroy) { /*pick the object randomly*/ i=lrand48()%2; /* Assign the data to the ant */ for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[i]][k]; a->carrying=1; /*Correct the heap parameters*/ heaps[position].count=1; heaps[position].objects[0]=heaps[position].objects[1-i]; computeHeapParameters(&heaps[position],flag); } }//end of function /********************************************************************/ /*Function to pick a object from a heap consisting of more than two object */ /* Output: None */ /* Input: Ant and the position of the heap */ /* Global Structure Modified: heaps, heapCount, board */ /********************************************************************/ void pickObjectn(ant *a,int position,int flag) { int i=0,k=0; /*If the criteria is satsfied then pick the object*/ if((computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)*1.0/heaps[position].Dmean)>Tremove) { a->carrying=1; for(k=0;k<features;k++) a->data[k]=data[heaps[position].objects[heaps[position].disPosition]][k]; for(i=heaps[position].disPosition;i<heaps[position].count-1;i++) heaps[position].objects[i]=heaps[position].objects[i+1]; heaps[position].count--; computeHeapParameters(&heaps[position],1); } }//end of function /********************************************************************/ /* Function to pick a object */ /********************************************************************/ void pick(ant *a,int flag) { int position=-1,i=0; float Pload1=-1.0; for(i=0;i<heapCount;i++) { /*Check if a heap is present in the eight neighbouring cells*/ if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if Heap is found*/ if(position!=-1) { /* heap or object found.*/ /*Depending upon the number present in the heap call the corresponding routine*/ switch(heaps[i].count) { case 1: Pload1 = lrand48()%151*1.0/150.0; if(Pload1<Pload) { pickObject1(a,position,flag); } break; case 2: pickObject2(a,position,flag); break; default: pickObjectn(a,position,flag); break; } } } /********************************************************************/ /* Function to drop a object to form a new heap */ /* Output: None */ /* Input: Ant, iteration flag */ /* Global Structure modified : heap, heapCount */ /********************************************************************/ void dropObject(ant* a,int flag) { /*Create a new heap*/ int k=0; heaps[heapCount].count=1; heaps[heapCount].x=a->x; heaps[heapCount].y=a->y; heaps[heapCount].Dmax=0; heaps[heapCount].Dmean=0; heaps[heapCount].disPosition=0; for(k=0;k<features;k++) { heaps[heapCount].Odissim[k]=a->data[k]; heaps[heapCount].Ocenter[k]=a->data[k]; } if(flag==1) {heaps[heapCount].objects[0]=findInData(a->data,flag); /*computeHeapParameters(&heaps[heapCount],flag);*/ } computeHeapParameters(&heaps[heapCount],flag); heapCount++; a->carrying=-1; board[a->x][a->y]=9; }//end of function /********************************************************************/ /* Function to find the heap position during the second iteration */ /* Output: position of the heap */ /* Input: object center of the heap that the ant is carrying */ /* Global Structure modified : none */ /********************************************************************/ int findInNewheaps(irisData object) { int position=-1,i,j=0,flag[features],flg; for(i=0;i<newHeapCount;i++) { for(j=0;j<features;j++) { if(fabs(object[j]-newHeaps[i].Ocenter[j])<0.00001) flag[j]=1; else {flag[j]=0;break;} } flg=1; for(j=0;j<features;j++) if(flag[j]==0) { position=-1; flg=0; break; } if(flg==1) { position=i; break; } } return (position); } /********************************************************************/ /*Function to drop a object to a heap consisting of a one or more object */ /* Output: none */ /* Input: Ant, position of the heap , iteration flag */ /* Global Structure modified: heaps,newHeaps */ /********************************************************************/ void dropObject1(ant* a, int position,int flag) { int heapPosition=-1,heapPosition1=-1,i,j,k=0; irisData newData,temp; if(flag==1) { heaps[position].objects[heaps[position].count]=findInData(a->data,flag); heaps[position].count++; computeHeapParameters(&heaps[position],flag); } else { for(k=0;k<features;k++)temp[k]=heaps[position].Ocenter[k]; heapPosition=findInNewheaps(a->data); heapPosition1=findInNewheaps(heaps[position].Ocenter); if(heapPosition==-1||heapPosition1==-1) { printf("\n error in logic:new heaps\n"); //getchar(); return; } for(k=0;k<features;k++) {newData[k]=(newHeaps[heapPosition].Ocenter[k]*newHeaps[heapPosition].count+newHeaps[heapPosition1].Ocenter[k]*newHeaps[heapPosition1].count)*1.0/(newHeaps[heapPosition].count+newHeaps[heapPosition1].count);newHeaps[heapPosition].Ocenter[k]=newData[k];heaps[position].Ocenter[k]=newData[k]; } computeHeapParameters(&heaps[position],flag); for(i=newHeaps[heapPosition].count,j=0;j<newHeaps[heapPosition1].count;i++,j++) { newHeaps[heapPosition].objects[i]=newHeaps[heapPosition1].objects[j]; } newHeaps[heapPosition].count+=newHeaps[heapPosition1].count; for(i=heapPosition1;i<newHeapCount-1;i++) newHeaps[i]=newHeaps[i+1]; newHeapCount--; } a->carrying=-1; }//end of function /********************************************************************/ /* Function to drop a object */ /* Output: None */ /* Input: Ant, iteration flag */ /********************************************************************/ void drop(ant* a,int flag) { int i, position=-1; float Pdrop1=0.0; /*Find whether we have a heap in the neighbourhood of the cell*/ for(i=0;i<heapCount;i++) { if(abs(heaps[i].x-a->x)<=1&&abs(heaps[i].y-a->y)<=1) { position=i; break; } } /*Check if a heap is found*/ if(position!=-1) { /*heap or object found.*/ /*Depending on the number of objects present take action*/ switch(heaps[position].count) { /*If criteria is satisfied then drop the object*/ case 1: if(flag==1) { if((computeDistanceBetween2(a->data,data[heaps[position].objects[0]])*1.0/Dmax)<Tcreate) dropObject1(a,position,flag); } else { if((computeDistanceBetween2(a->data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) dropObject1(a,position,flag); } break; default: if(computeDistanceBetween2(a->data,heaps[position].Ocenter)<computeDistanceBetween2(heaps[position].Odissim,heaps[position].Ocenter)) dropObject1(a,position,flag); break; } } else { /*Compute the probability to drop the object*/ Pdrop1 = lrand48()%151*1.0/150; if(Pdrop1<Pdrop) dropObject(a,flag); } }//end of function /********************************************************************/ /* Function to move the ant */ /* Output: none */ /* Input: Ant, iteration flag */ /********************************************************************/ void move(ant* a,int flag) { float pDir; /*Check the speed */ if (a->speed!=0) { /*move in the same direction*/ a->speed--; moveNext(a,flag); } else { /*generate the new direction*/ pDir=lrand48()%17*1.0/16.0; if(pDir<.85) { a->dir=lrand48()%8; } else if(pDir>.95) { a->speed=2; } moveNext(a,flag); } } /********************************************************************/ /* Function to simulate the movement of the ants */ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified: minHeapCount, minHeapPosition */ /********************************************************************/ void iterate(int flag) { int i=0,j=0,k=0,loopCount=0; if (flag==1) loopCount=MAXANTS; else loopCount=MAXANTSFORHEAPS; while (i<MAXITERATIONS) { i++; for(j=0;j<loopCount;j++) { move(&ants[j],flag); if(ants[j].carrying==1) { drop(&ants[j],flag); } else { pick(&ants[j],flag); } } if(debugLevel>0){ for(k=0;k<heapCount;k++) for(j=0;j<heapCount;j++) if((k!=j)&&(heaps[k].x==heaps[j].x)&&(heaps[k].y==heaps[j].y)) { printf("\nerror two heaps with same co ordinates %d %d ",k,j); //getchar(); } k=0; for(j=0;j<heapCount;j++) k+=heaps[j].count; } if(heapCount<minHeapCount) { minHeapCount=heapCount; minPosition=i; } if(debugLevel>0) printf("\n i:%d Heap count %d sum %d",i,heapCount,k); else printf("\n i:%d Heap count %d",i,heapCount); heapSum+=heapCount; } }//end of function /********************************************************************/ /*Function to drop the objects carried by the ants after all the iterations*/ /* Output: none */ /* Input: Iteration flag */ /* Global structure modified:none */ /********************************************************************/ void dropFinal(int flag) { int i=0,j=0,position=-1,loopCount=0; loopCount=currentAntCount; for(i=0;i<loopCount;i++) { if(ants[i].carrying==1) { if(flag==1) { for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /*drop the object to form a new heap*/ dropObject1(&ants[i],position,flag); } } else { /*Find if a heap is present */ do { position=-1; for(j=0;j<heapCount;j++) { if((heaps[j].x==ants[i].x)&&(heaps[j].y==ants[i].y)) { position=i; break; } } if(position!=-1) { /* if a heap is present then drop the heap if the criteria is satisfied */ if((computeDistanceBetween2(ants[i].data,heaps[position].Ocenter)*1.0/Dmax)<TcreateForHeaps) { dropObject1(&ants[i],position,flag); position=-1; } else { /* Find a new location to drop the heap carried by the ant */ move(&ants[i],flag); } } else { dropObject(&ants[i],flag); } }while (position!=-1); } } } }//end of function /********************************************************************/ /* Function for the implementation of QuickSort */ /* Output: none */ /* Input: data structure, low and high indices */ /* Global structure modified:none */ /********************************************************************/ void quickSort( heap A[], int low,int high ) { int mid=0; if(low<high) { mid=partition(A,low,high); quickSort(A,low,mid); quickSort(A,mid+1,high); } } /********************************************************************/ /* Partition routine used by quick sort */ /* Output: partition location */ /* Input: data , low, high */ /* Global structure modified:none */ /********************************************************************/ int partition(heap a[], int low,int high) { heap temp; int x=0,i=0,j=0; i=low; j=high; x=a[low].count; while (1) { while (a[j].count<x) j=j-1; while (a[i].count>x) i=i+1; if(i<j) { temp=a[i]; a[i]=a[j]; a[j--]=temp; } else return(j); } } /********************************************************************/ /* Function used to write the cluster information */ /* Output: none */ /* Input:iteration flag */ /* Global structure modified:none */ /********************************************************************/ void writeClusterInformation(int flag) { FILE *fp=fopen("center.clt","w"); FILE *fp1; FILE *fp2; FILE *fp3; char temp[80]; int i=0,j=0,k=0; int lastCount=0; int rowCount,colCount,antCount; strcpy(temp,""); sprintf(temp,"%sOp.out",filename); fp3=fopen(temp,"a"); if(dataDump) {strcpy(temp,"");sprintf(temp,"%sTot.out",filename);fp1=fopen(temp,"a");strcpy(temp,"");sprintf(temp,"%sObj.out",filename);fp2=fopen(temp,"a");if(fp1==NULL||fp2==NULL)printf("\n Error in opening file in the writer Cluster Information routine\n"); } rowCount=currentRow; colCount=currentRow; antCount=currentAntCount; if(fp==NULL) { printf("\n Unable to open cluster center output file \n"); /*return;*/ exit(0); } /*sort the array according to the count value and write the value of the top three elements*/ if((flag==1)&&(!EntireHeaps)) quickSort(heaps,0,heapCount); if(EntireHeaps) {if(flag==1) lastCount=heapCount;else lastCount=newHeapCount; } else lastCount=c; for(i=0;i<lastCount;i++) { if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { fprintf(fp,"%5.2f \t ",newHeaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else { for(k=0;k<features;k++) { fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); } fprintf(fp,"\n"); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",newHeaps[i].Ocenter[k]); fprintf(fp,"\n"); } else { for(k=0;k<features;k++) fprintf(fp,"%5.2f \t",heaps[i].Ocenter[k]); fprintf(fp,"\n"); } } if(dataDump) { fprintf(fp1,"\n Information from the Ant Based Algorithm \n"); fprintf(fp1,"\n Important Parameters : Board %d X %d Ants : %d Iterations %d Total Heaps %d ",rowCount,colCount,antCount,MAXITERATIONS,lastCount); } if(flag==0) { if(dataDump) { fprintf(fp1," TCreateForHeaps %f \n",TcreateForHeaps); fprintf(fp2,"\nTotal Heaps : %d\n",heapCount); fprintf(fp2,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); } fprintf(fp3,"\n@ %d\n",lastCount); } else if(dataDump) fprintf(fp1,"\n");if(dataDump) { fprintf(fp1,"\n Cluster centers \t\t\t\t\t\t\t\t\t\tObjects in Heap \n"); for(i=0;i<lastCount;i++) if(normalize==0) if(flag==0) { for(k=0;k<features;k++) { fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp2,"%8.2f ",newHeaps[i].Ocenter[k]/scale[k]+minInput[k]); } fprintf(fp1," %5d\n",newHeaps[i].count); fprintf(fp2," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]/scale[k]+minInput[k]); fprintf(fp1," %5d\n",heaps[i].count); } else if(flag==0) { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",newHeaps[i].Ocenter[k]); fprintf(fp1," %5d\n",newHeaps[i].count); } else { for(k=0;k<features;k++) fprintf(fp1,"%8.2f ",heaps[i].Ocenter[k]); fprintf(fp1," %5d\n",heaps[i].count); }} if(flag==0) { if(dataDump) fprintf(fp1,"\n Objects in the heaps \n");for(i=0;i<newHeapCount;i++) { if(dataDump) fprintf(fp1,"\n\n Heap %d\n \n",i+1);fprintf(fp3,"# %d %d\n",i ,newHeaps[i].count); for(j=0;j<newHeaps[i].count;j++){ for(k=0;k<features;k++){ fprintf(fp3,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]); if(dataDump) fprintf(fp1,"%8.2f",data[newHeaps[i].objects[j]][k]/scale[k]+minInput[k]);} if(dataDump) fprintf(fp1,"\n"); fprintf(fp3,"\n"); } } } fclose(fp); fclose(fp3); if(dataDump) { fclose(fp1);fclose(fp2); }}//end of flie /********************************************************************/ /* Function to initialise the new heaps */ /* Output: none */ /* Input:new Heap structure */ /* Global structure modified:none */ /********************************************************************/ void initialiseNewHeaps(heap newHeaps[]) { int i=0,j=0; for(i=0;i<lCount;i++) { newHeaps[i].count=0; for(j=0;j<features;j++) newHeaps[i].Ocenter[j]=V[i][j]; newHeaps[i].x=heaps[i].x; newHeaps[i].y=heaps[i].y; } }//end of function /********************************************************************/ /* Function to initialise the new heaps */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ int findPosition(int i) { int j,position=0; for(j=1;j<lCount;j++) { if(U[j][i]>U[position][i]) position=j; } /*printf("\n Position %d ",position);*/ return(position); }//end of function find position /********************************************************************/ /* Function to add object */ /* Output: position of maximum membership */ /* Input:object index */ /* Global structure modified:none */ /********************************************************************/ void addObject(int object,heap * heapPosition) { heapPosition->objects[heapPosition->count]=object; heapPosition->count++; }//end of function add object /********************************************************************/ /* Function to harden the outputs obtained from fcm */ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/ void harden(heap newHeaps[]) { int i,heapPosition=-1,sum=0,j=0; /*initialise the new heaps*/ initialiseNewHeaps(newHeaps); for(i=0;i<count;i++) { heapPosition=findPosition(i); addObject(i,&newHeaps[heapPosition]); } /* To check for degenerate partitions*/ for(i=0;i<lCount;i++) { if(newHeaps[i].count==0){for(j=i;j<lCount-1;j++){newHeaps[j]=newHeaps[j+1];}lCount--;i--;} } newHeapCount=lCount; for(i=0;i<lCount;i++) computeHeapParameters(&newHeaps[i],1); if(debugLevel>0) { for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\n sum = %d",sum);} }//end of function/********************************************************************/ /* Function to initialize the initial parameters for the ant algorithm*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void init() { int i=0,j=0; for(i=0;i<MAXROWS;i++) for(j=0;j<MAXCOLS;j++) board[i][j]=-9; heapCount=0; newHeapCount=0; heapRow=0; minPosition=-1; minHeapCount=100000; for(i=0;i<MAXANTS;i++) { ants[i].carrying=-1; ants[i].x=-1; ants[i].y=-1; ants[i].speed=-1; ants[i].dir=-1; } } /********************************************************************/ /* Function to initialize the initial board */ /* Output: none */ /* Input: None */ /* Global Structure Modified: None */ /********************************************************************/ void initialiseBoard() { int i,j; for(i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; }/********************************************************************/ /* Function to harden the outputs obtained from fcm(2nd stage)*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: Cluster center , cluster center count*/ /********************************************************************/void harden1() { int i=0,heapPosition=-1; for(i=0;i<heapCount;i++) cenCount[i]=0; for(i=0;i<n;i++) { heapPosition=findPosition1(i); addObject1(i,heapPosition); } writeInfo(); }//end of function/********************************************************************/ /* Function to find to which class the object belongs */ /* Output: Class number */ /* Input: object position */ /* Global Structure Modified: None */ /********************************************************************/int findPosition1(int i) { int j,position=0; for(j=1;j<heapCount;j++) { if(U[j][i]>U[position][i]) position=j; } return(position); }//end of function find position/********************************************************************/ /* Function to Write the output of the hardened objects to file*/ /* Output: none */ /* Input: New heap structure */ /* Global Structure Modified: None */ /********************************************************************/void writeInfo(){int i=0,j=0,k=0;FILE *fp=fopen("fcm.out","a");if(fp==NULL){printf("\n Unable to open fcm output file \n");return;}fprintf(fp,"\n@ %d\n",heapCount);for(i=0;i<heapCount;i++){fprintf(fp,"# %d %d\n",i,cenCount[i]);for(j=0;j<cenCount[i];j++){for(k=0;k<s;k++)fprintf(fp,"%8.2f ",clsCen[i][j][k]/scale[k]+minInput[k]);fprintf(fp,"\n");}}fclose(fp);return;}/********************************************************************/ /* Function to add a object to a cluster (2nd stage) */ /* Output: none */ /* Input: object poistion , cluster position */ /* Global Structure Modified: Cluster object and cluster count*/ /*******************************************************************/void addObject1(int object,int heapPosition) { int k=0; for(k=0;k<features;k++) clsCen[heapPosition][cenCount[heapPosition]][k]=X[object][k]; cenCount[heapPosition]++; return; }//end of function add object/********************************************************************/ /* Function to read the original classification of objects */ /* Output: none */ /* Input: none */ /* Global Structure Modified: None */ /*******************************************************************/void readOrg(){int i=0,k=0;char temp[80];FILE *fp;strcpy(temp,"");sprintf(temp,"%sFull.data",filename);fp=fopen(temp,"r");if(fp==NULL){printf("\n Unable to open full data input file ");exit(0);}for(i=0;i<n;i++){fscanf(fp,"%f ",&orgData[i][0]);for(k=1;k<s+1;k++)fscanf(fp,"%f ",&orgData[i][k]);}return;}// end of function/********************************************************************/ /* Function to classify the objects in different clusters */ /* Output: none */ /* Input: the cluster objects, the original classification, */ /* number of objects in the cluster,file to write the data */ /* Global Structure Modified: None *//********************************************************************/int analysisData(float data[][s],float orgData[n][s+1],int count,FILE * fp){int i=0,j=0,k=0,type=1,max=0;heapInfo info;for(i=0;i<c;i++){info.classObj[i]=0;}info.total=0;info.total=count;for(i=0;i<count;i++)for(j=0;j<n;j++){type=1;for(k=0;k<s;k++)if(fabs(data[i][k]-orgData[j][k+1])>errThresh){type=-1;break;}if(type!=-1){info.classObj[(int)orgData[j][0]-1]++;break;}}max=0;for(k=0;k<c;k++){if(info.classObj[k]>info.classObj[max])max=k;fprintf(fp,"\nClass %d Objects % d ",k+1,info.classObj[k]);}j=0;for(k=0;k<c;k++){if(k!=max)j+=info.classObj[k];}fprintf(fp,"\n Total errors : %d \n",j);return(j);}//end of analyse/********************************************************************/ /* Function to read the cluster information */ /* Output: none */ /* Input: input file pointer , output file pointer */ /* Global Structure Modified: None *//********************************************************************/void readFCM(FILE* fp,FILE *fp1){int i=0,j=0,k=0,l=0;int totalRuns=0,heapCount=0,junk=0,sum=0;char ch;FILE *fp2=fopen("errors.out","a");ch = 'c'; while (ch != '$') fscanf (fp, "%c", &ch);fscanf(fp,"%d\n",&totalRuns);printf("\n total runs %d ",totalRuns);for(l=0;l<totalRuns;l++){fscanf(fp,"%c",&ch);fscanf(fp,"%d\n",&heapCount);fprintf(fp1,"\n \nExperiment %d \n ",l+1);sum=0;for(i=0;i<heapCount;i++){fscanf(fp,"%c",&ch);fscanf(fp," %d %d\n",&junk,&clsCenCount[i]);for(j=0;j<clsCenCount[i];j++)for(k=0;k<s;k++)fscanf(fp,"%f",&fcmData[i][j][k]);fscanf(fp,"\n");fprintf(fp1,"\n\n Heap %d Total Objects %d \n",i+1,clsCenCount[i]);sum+=analysisData(fcmData[i],orgData,clsCenCount[i],fp1);}fprintf(fp2," %3d %3d %3d \n",l,sum,heapCount);}fprintf(fp2,"\n --------------------------\n");fclose(fp2);return;}//end of function void initRm(int heapCount) { antCount=heapCount*antsPerFeature*features;classes=heapCount;newAnts=(antdata*) calloc(antCount,sizeof(antdata));if(ants==NULL){printf("\n Cannot allocate memory to ants in Rm stage");printf("\n Exiting ... ");exit(-1);}} /***************************************************************************//* Function to initialise the ants *//* Status: under developement *//* Output: the ant structure is modified with initial random values *//* Input : Ant structure (this is modified) *//***************************************************************************/void initializeAntsRm(antdata* ants,center clsCen){int i,j,k;/* Initialize all the ants with initial values and the rest and direction*/for(i=0;i<antCount;i++){ants[i].currPos=drand48();for(j=0;j<memory;j++){ants[i].Rm[j]=inf;for(k=0;k<antsPerFeature;k++)Rm[k][j]=inf;}ants[i].rest=1;ants[i].direction=drand48()<0.5?1:-1;}for(j=0;j<features;j++)for(i=0;i<classes;i++){ants[j*classes+i].currPos=clsCen[i][j];}}/*end of function*//***************************************************************************//* Function that runs one epoch *//* Status: under developement *//* Output: the ant structure is modified with according to the epoch *//* Input : Ant structure (this is modified) *//***************************************************************************/void epoch(antdata* ants){int i,j;float Trest=0,Tcontinue=0,Tinc=0;float dDiff=0.0;float temp=0;dDiff=DmaxRm-Dmin;for(j=0;j<iterations;j++){for(i=0;i<antCount;i++){if(ants[i].rest!=0){Trest=drand48();if(Trest<Prest){ants[i].rest=0;continue;}Tcontinue=drand48();if(Tcontinue>Pcontinue)ants[i].direction=-1*ants[i].direction;Tinc=drand48();temp=ants[i].currPos+ants[i].direction*(Dmin+Tinc*dDiff);if(temp>1||temp<0)ants[i].direction=-1*ants[i].direction;ants[i].currPos+=ants[i].direction*(Dmin+Tinc*dDiff);}}}for(i=0;i<antCount;i++)ants[i].rest=1;}/*end of function*//***************************************************************************//* Function that computes Rm *//* Status: under developement *//* Output: the ant structure is modified, the worst Rm is removed *//* Input : Ant structure (this is modified) *//***************************************************************************/void computeRm(antdata* ants,float data[MAXDATA][features],float newRm[antsPerFeature]){int i,j,k=0,l=0;float clsCenters[antsPerFeature][MAXDATA][features];double Rm=0.0,temp=0.0,Dik=0;for(k=0;k<antsPerFeature;k++)for(j=0;j<features;j++)for(i=0;i<classes;i++){clsCenters[k][i][j]=ants[k*classes*features+j*classes+i].currPos;}for(k=0;k<antsPerFeature;k++){Rm=0;for(i=0;i<count;i++){Dik=0;for(j=0;j<classes;j++){temp=0;for(l=0;l<features;l++)temp+=(data[i][l]-clsCenters[k][j][l])*(data[i][l]-clsCenters[k][j][l]);/*temp=sqrt(temp);*//*temp=NORM(data[i],clsCenters[k][j]);temp=temp*temp;*/Dik+=pow(temp,1.0/(1-m));}Rm+=pow(Dik,(1-m));}newRm[k]=Rm;}return;}/*end of function*//********************************************************************//* Function to update the memory of the ants *//* Output: none *//* Input: ant structure and the new Rm, old memory *//* Global Structure Modified: none *//********************************************************************/void updateMemory(antdata* ants,float newRm[antsPerFeature],float Rm[antsPerFeature][memory]){int i,minPosition[antsPerFeature],maxPosition[antsPerFeature],flag[antsPerFeature],k,j,b[memory],infCount=0;float temp=0,tempRm[memory],tChoose=0,pContinueCurr=0;for(i=0;i<antsPerFeature;i++){minPosition[i]=0;maxPosition[i]=0;flag[i]=1;}for(k=0;k<antsPerFeature;k++){b[0]=0;for(i=1;i<memory;i++){if(Rm[k][i]<Rm[k][minPosition[k]])minPosition[k]=i;if(Rm[k][i]>Rm[k][maxPosition[k]])maxPosition[k]=i;if(Rm[k][i]==newRm[k]){flag[k]=0;break;}temp=(newRm[k]-Rm[k][i])*1.0/Rm[k][i];if(temp<0) temp=-1*temp;if(temp<minChange){flag[k]=0;break;}b[i]=i;}if(flag[k]==1){if(newRm[k]<Rm[k][maxPosition[k]]){for(j=0;j<features;j++)for(i=0;i<classes;i++){ants[k*classes*features+j*classes+i].Rm[maxPosition[k]]=ants[k*classes*features+j*classes+i].currPos;}Rm[k][maxPosition[k]]=newRm[k];}else{/* find min Rm and restore its position*/infCount=0;for(i=0;i<memory;i++){tempRm[i]=Rm[k][i];if(Rm[k][i]==inf) infCount++;}for(i=0;i<memory;i++)for(j=0;j<memory-1-i;j++){if(tempRm[j]>tempRm[j+1]){temp=tempRm[j];tempRm[j]=tempRm[j+1];tempRm[j+1]=temp;temp=b[j];b[j]=b[j+1];b[j+1]=temp;}}tChoose=drand48();if(tChoose<0.6){minPosition[k]=b[0];}else if (tChoose<0.8){minPosition[k]=b[1];}else if(tChoose<0.9){minPosition[k]=b[2];}else if(tChoose<0.975){minPosition[k]=b[3];}else {minPosition[k]=b[4];}pContinueCurr=drand48();if(pContinueCurr<tContinueCurr){/*for(j=0;j<features;j++)for(i=0;i<classes;i++){ants[k*classes*features+j*classes+i].Rm[maxPosition[k]]=ants[k*classes*features+j*classes+i].currPos;}Rm[k][maxPosition[k]]=newRm[k];*/}else if(Rm[k][minPosition[k]]!=inf)for(j=0;j<features;j++)for(i=0;i<classes;i++){ants[k*classes*features+j*classes+i].currPos=ants[k*classes*features+j*classes+i].Rm[minPosition[k]];}}}}}/* end of function *//********************************************************************//* Function to cluster according to the cluster centroids *//* Output: none *//* Input: ant structure and the data points *//* Global Structure Modified: none *//********************************************************************/void finalCluster(antdata* ants,float data[MAXDATA][features],float Rm[antsPerFeature][memory]){int i,j,position[MAXDATA],minPosition=0,k=0,l=0,minRm=0;float clsCenters[antsPerFeature][MAXDATA][features];float distance[MAXDATA];int cenCount[MAXDATA],classCount[MAXDATA][c];float temp=0;int clsObjects[MAXDATA][MAXDATA],label[MAXDATA];int minPosition1[antsPerFeature],maxPosition1[antsPerFeature];FILE *fp,*fpOut,*fpCls,*fpMinRm,*fpOrgClass,*fpRm;fp=fopen("fcmRm.out","a");fpOut=fopen("ClassData.out","a");fpCls=fopen("clsCenters.out","a");fpMinRm=fopen("minRm.out","a");fpOrgClass=fopen("orgClass.out","a");fpRm=fopen("Rm.out","a");if(fp==NULL){printf("\n Unable to open fcm output file \n");return;}for(k=0;k<antsPerFeature;k++){for(j=0;j<features;j++)for(i=0;i<classes;i++)clsCenters[k][i][j]=ants[k*classes*features+j*classes+i].currPos;minPosition1[k]=0;maxPosition1[k]=0;}for(k=0;k<antsPerFeature;k++){for(i=1;i<memory;i++){if(Rm[l][i]<Rm[l][minPosition1[l]])minPosition1[l]=i;if(Rm[l][i]>Rm[l][maxPosition1[l]])maxPosition1[l]=i;}}minRm=0;for(k=1;k<antsPerFeature;k++){if(Rm[k][minPosition1[k]]<Rm[minRm][minPosition1[minRm]])minRm=k;}fprintf(fpRm,"Rm %8.4f\n",Rm[minRm][minPosition1[minRm]]);fclose(fpRm);Fcm(data,clsCenters[minRm],2);hardenRm();for(l=0;l<antsPerFeature;l++){fprintf(fpCls,"Cluster number %2d\n",l);for(j=0;j<classes;j++){distance[j]=inf;cenCount[j]=0;for(k=0;k<c;k++)classCount[j][k]=0;}fprintf(fp,"* %d\n",l);if(l==minRm)fprintf(fpMinRm,"* %d\n",l);for(i=0;i<count;i++){minPosition=0;for(k=0;k<classes;k++){temp=0.0;for(j=0;j<features;j++)temp+= (clsCenters[l][k][j]-data[i][j])*(clsCenters[l][k][j]-data[i][j]);temp=sqrt(temp);distance[k]=temp;if(distance[k]<distance[minPosition])minPosition=k;}position[i]=minPosition;clsObjects[minPosition][cenCount[minPosition]]=i;cenCount[minPosition]++;}for(j=0;j<classes;j++){for(i=0;i<cenCount[j];i++)classCount[j][(int)orgData[clsObjects[j][i]][0]-1]++;}/* minPosition varaible re used , now minPosition denotes the maximum class of the cluster*/fprintf(fpOrgClass,"\nCluster number: %2d \n",l);for(j=0;j<classes;j++){minPosition=0;fprintf(fpOrgClass,"\n Cluster %2d \n",j+1);fprintf(fpOrgClass,"%2d %2d\n",1,classCount[j][0]);for(i=1;i<c;i++){if(classCount[j][i]>classCount[j][minPosition]) minPosition=i;label[j]=minPosition;fprintf(fpOrgClass,"%2d %2d\n",i+1,classCount[j][i]);}}for(i=0;i<count;i++){for(j=0;j<classes;j++)for(k=0;k<cenCount[j];k++)if(clsObjects[j][k]==i){fprintf(fp,"%d ",label[j]+1);break;}}fprintf(fp,"\n");fprintf(fpOut,"\nCluster number: %2d \n",l);for(i=0;i<classes;i++){fprintf(fpOut,"%2d %4d\n",label[i]+1,cenCount[i]);for(j=0;j<features;j++)fprintf(fpCls,"%8.7f ",clsCenters[l][i][j]/scale[j]+minInput[j]);fprintf(fpCls,"\n");}}/* Write the data to the file */fclose(fp);fclose(fpOut);fclose(fpCls);fclose(fpMinRm);fclose(fpOrgClass);}/* end of function *//********************************************************************//* Function to amnalyze the results *//* Output: none *//* Input: *//* Global Structure Modified: none *//********************************************************************/void analysis(int flag){int i,j,k,temp;char junk;int totalRuns=0,errors[antsPerFeature],epoch=0,position=0,antsperfeature=0,clsNumber=0,min=0,currMinRm;FILE *fp,*fpError,*fpMin,*fpMinRm,*fpMinIp;if(flag==1){fp=fopen("fcmRm.out","r");fpMinIp=fopen("minRm.out","r");fpMinRm=fopen("minRmError.out","w");fpError=fopen("error.out","w");fpMin=fopen("minError.out","w");}else{fp=fopen("fcmFCM.out","r");fpError=fopen("errorFCM.out","w");}if(fp==NULL||fpError==NULL){printf("\n unable to open files in the analysis module \n");return;}fscanf(fp,"%c %d\n",&junk,&totalRuns);fscanf(fp,"%c %d\n",&junk,&antsperfeature);if(flag==1){fscanf(fpMinIp,"%c %d\n",&junk,&temp);fscanf(fpMinIp,"%c %d\n",&junk,&temp);}for(i=0;i<totalRuns;i++){for(j=0;j<antsperfeature;j++){errors[j]=0;}fscanf(fp,"%c %d\n",&junk,&epoch);if(flag==1){fscanf(fpMinIp,"%c %d\n",&junk,&temp);fscanf(fpMinIp,"%c %d\n",&junk,&currMinRm);}fprintf(fpError,"Experiment %3d ",i);for(k=0;k<antsperfeature;k++){fscanf(fp,"%c %d\n",&junk,&clsNumber);for(j=0;j<count;j++){fscanf(fp,"%d ",&position);if(orgData[j][0]!=position)errors[k]++;}fscanf(fp,"\n");if(flag==1){fprintf(fpError,"\nCluster %3d Errors %5d",k,errors[k]);if(k==currMinRm){fprintf(fpMinRm,"Cluster %2d Errors %5d\n",k,errors[k]);}}else fprintf(fpError," Errors %5d\n",errors[k]);}if(flag==1){min=0;for(j=1;j<antsPerFeature;j++){if(errors[j]<errors[min])min=j;}fprintf(fpMin,"Exp %2d Min Error %5d\n",i,errors[min]);}}fclose(fp);fclose(fpError);if(flag==1){fclose(fpMin);fclose(fpMinRm);fclose(fpMinIp);}}/* end of function */ void RmStage(int heapCount,center clsCen) { FILE *fpTime=fopen("time.out","a");int flag[antsPerFeature],flg;struct rusage start_usage, end_usage,epoch_start_usage, epoch_end_usage;double *perf_times;float newRm[antsPerFeature],oldRm[antsPerFeature],temp;int i=0,j=0,k=0;initRm(heapCount);initializeAntsRm(newAnts,clsCen);for(i=0;i<antsPerFeature;i++){oldRm[i]=inf;newRm[i]=inf;}flg=1;i=0;getrusage(RUSAGE_SELF, &start_usage);while(i<maxEpocs){getrusage(RUSAGE_SELF, &epoch_start_usage);epoch(newAnts);getrusage(RUSAGE_SELF, &epoch_end_usage);perf_times=timing_of(epoch_start_usage,epoch_end_usage); fprintf(fpTime,"Epoch %3d Timing: %f user, %f system, %f total.\n",i, perf_times[0], perf_times[1], perf_times[0] +perf_times[1]);for(j=0;j<antsPerFeature;j++){oldRm[j]=newRm[j];flag[j]=1;}computeRm(newAnts,data,newRm);updateMemory(newAnts,newRm,Rm);flg=0;for(j=0;j<antsPerFeature;j++){if(newRm[j]!=inf){if(oldRm[j]!=inf){temp=0;temp=newRm[j]-oldRm[j]<0? (oldRm[j]-newRm[j]):(newRm[j]-oldRm[j]);/*printf("\n new %f old %f temp %f ",newRm[j],oldRm[j],temp);*/if(temp/oldRm[j]>minChange){flg=1;break;}}else flg=1;}}i++;printf("\n Epoch %d ",i);}/* Do the final clustering*/finalCluster(newAnts,data,Rm);getrusage(RUSAGE_SELF, &end_usage);perf_times=timing_of(start_usage,end_usage); fprintf(fpTime,"Exp %3d Timing: %f user, %f system, %f total.\n",k, perf_times[0], perf_times[1], perf_times[0] +perf_times[1]);/* Compute the error */} /****************************************************************/ void Fcm (objects X1,center V,int flag) { int i,j,l; FILE *ofile,*fpJm; FILE *iniClsCen=fopen("center.clt","a+"); char temp[80]; float jmFinal=0,rmFinal=0; Random_seed=state1[run];/*randseed*/ srand48(Random_seed); for(i=0;i<MAXDATA;i++) for(j=0;j<features;j++)X[i][j]=X1[i][j]; if(iniClsCen==NULL) { printf("\n Unable to open the initial cluster center file\n"); printf("\n choosing random cluster centers....\n"); flag=1; } for (run=0;run<TOTRUNS;run++) { if(flag!=2) { if (EntireHeaps) lCount=heapCount; else lCount=c; for(i=0;i<lCount;i++) for(j=0;j<s;j++) V[i][j]=0; for(i=0;i<lCount;i++) { for(l=0;l<s;l++) { if(flag==1) { rand_index = lrand48() % n; V[i][l] = X[rand_index][l]; } else { fscanf(iniClsCen,"%f ",&V[i][l]); } }//end for }}else lCount=heapCount;eps=0.001; stop = FALSE; /* This loop finds the final cluster center and the corresponding U values */ z = 0; while (stop == FALSE) { z++; UMAT(U,V,X); /** Update the U matrix **/stop = FINISHED(U1,eps); CLUSTER(U,X,V); /** Get new cluster center **/printf("\nIteration: %d \n",z); } /* end while */ printf("Number of iterations: %d\n\n", z);strcpy(temp,""); sprintf(temp,"%sFCM.out",filename);if(flag==1){jmFinal=Compute_Jm(V,X);rmFinal=Compute_Rm(V,X);fpJm=fopen("jm.out","a");fprintf(fpJm," classes %2d Jm: %10.6f Rm: %10.6f\n",lCount,jmFinal,rmFinal);fclose(fpJm);} if(flag==2) Output(temp,V,X); /* output the results */ }/*end for*/ ofile=fopen(temp,"a"); for (i=0; i <= mins; i++) fprintf(ofile, "Min %d of %10.3f occurred %d times\n", i, mintab[i], mincount[i]); fprintf(ofile, "Average iterations %f\n", (float)aveit/(float)TOTRUNS); fclose(ofile); }/* end Main */ /* The NORM function computes the norm of two vectors, x and v, of dimension s. This gives an indication of the distance between them */ float NORM( feature x, feature v) //feature x, v; { /* Parameters : x -- a local copy of an input vector v -- a local copy of a cluster center */ int i,j; /* loop variable */ double sum; /* the square root of sum is the norm; sum is the sum of the differences squared */ float mat1[features]; float mat2[features]; if (maha) { for (i=0; i<features; i++) mat1[i]=x[i]-v[i]; for(i=0;i<features;i++) { sum =0; for(j=0;j<features;j++) sum += mat1[j] * inv_cov[j][i]; mat2[i] = sum; } sum =0; for(j=0;j<features;j++) sum += mat1[j]*mat2[j]; } else { sum = 0; for(j=0;j<features;j++) sum += (x[j] - v[j])* (x[j] - v[j]); } return (float)(sqrt(sum)); } /* end NORM */ /* The UMAT procedure calculates the updated U matrix according to Bezdek's formula. Its side-effect is the update of the global array U1 */ void UMAT( matrix U,center V, objects X) /*matrix U; center V; objects X;*/ { /* Parameters: U, V, and X: same as in main program */ int i, j, k,l ;/* loop variables *///, class /* class whose cluster center //is closest to pattern k */; float d1,d2,d; float sum; int exact; for (k=0;k<MAXDATA;k++) { /*printf("\n k %d ",k);*/ exact=false; for (i=0;i<lCount;i++) { sum=0; for (j=0;j<lCount;j++) { d1=NORM(X[k],V[i]); d2=NORM(X[k],V[j]); if(d2!=0) { d= d1/d2; d= d * d;/* pow(d1/d2,2.0/(m-1.0)); */ sum+=d; } else { exact = true; for(l=0;l<lCount;l++) if (l==j) U1[l][k]=1.0; else U1[l][k]=0.0; break; } } if (exact!=true) U1[i][k]=1.0/sum; } } } /* end UMAT */ /* The function FINISHED determines if a termination occurs. If not it updates U with U1, so its side-effect is the potential modification of U */ BOOLEAN FINISHED( matrix U1,float eps) //matrix U1; float eps; { /* Parameters: U1, eps-- same as in main */ float sum; /* sum of squared differences between corresponding elements of U and U1 */ int i,k; /* loop control variabes */ BOOLEAN finished; /* set to true if all corresponding elements are within epsilon */ finished = TRUE; sum = 0; for (i=0; i<lCount; i++) for (k=0; k<MAXDATA; k++) sum += (U[i][k] - U1[i][k])*(U[i][k]-U1[i][k]); if (sqrt(sum) > eps) { finished = FALSE; for (i=0; i<lCount; i++) for (k=0; k<MAXDATA; k++) U[i][k] = U1[i][k]; } /* end if */ return finished; } /* end FINISHED */ /* The CLUSTER procedure determines cluster centers in V for the c classes being searched for. The global array V is updated */ void CLUSTER( matrix U, objects X,center V) //matrix U; objects X; { /* Parameters: U, X -- as in main */ int i, j, k; /* loop control variables */ feature num; /* numerator in the cluster center computation formula presented by Bezdek */ float denum; /* denumenator in the obove formula */ for (i=0; i<lCount; i++) { denum = 0; for (j=0; j<features; j++) { num[j] = 0; for (k=0; k<MAXDATA; k++) num[j] += U[i][k] * U[i][k] * X[k][j]; /* pow(U[i][k],m) * X[k][j]; */ } /* end for */ for (k=0; k<MAXDATA; k++) denum += U[i][k] * U[i][k]; /* pow(U[i][k],m); */ for (j=0; j<features; j++) V[i][j] = num[j] / denum; } /* end for */ } /* end CLUSTER */ float Compute_Jm(center V, objects X) //center V; //objects X; { int i, k,found; double Jm_value; float u,dik; Jm_value = 0; for (k=0; k<MAXDATA; k++) { found = FALSE; for (i=0; i<lCount; i++) { dik=NORM(X[k],V[i]); dik=dik*dik; if (dik==0.0) { if (found == FALSE) { u=1.0; found = TRUE; printf("found the case with dik=0\n"); } else { printf("\n cant proceed with this initialization"); exit(1); } } else { if (found != TRUE) u=U1[i][k]; /* get_Uvalue(V,X,dik,k); */ else u=0.0; } Jm_value += u * u * dik;/* pow(u, m) * dik; */ } } return (Jm_value); } /* end Compute_Jm */ /* The Output procedure outputs the U matrix which gives the fuzzy measure of each feature belonging to a cluster center. It also outputs the cluster center for each class */ void Output(char fname[],center V,objects X) //char fname[80]; /* Parameters: U, V -- same as in main */ { int i, j, found; /* loop control variables */ float J2c,R2c; FILE *fpJm=fopen("JmRm.out","a"),*fp; if ((fp=fopen(fname,"a"))==NULL) printf("\n CAN'T OPEN %s\n",fname); else { fprintf(fp,"\n \n"); for (i=0; i<lCount; i++) { fprintf(fp,"\n"); for (j=0; j<features; j++) fprintf(fp,"%4.3f ",V[i][j]); } /* end for */ } /* end if */ J2c= Compute_Jm(V,X); R2c=Compute_Rm(V,X); fprintf(fpJm,"Classes: %3d Jm: %10.6f Rm: %10.6f \n",lCount,J2c,R2c); found =0; for (i=0;i<= mins; i++) { if ((found == 0) && ((J2c - mintab[i]) < .001) && ((J2c - mintab[i]) > -.001)){ mincount[i]++; found = 1; } } if (found == 0) { mins++; mintab[mins]=J2c; mincount[mins]=1; } fprintf(fp,"\nJ%2d = %f", m,J2c); fprintf(fp, "Number of iterations: %d\n\n", z); aveit=aveit + z; fclose(fp); fclose(fpJm); } /***************************************************************/ void find_covar( ) { int i,j,k; float mean[features],sum; for (i=0;i<features;i++) mean[i]=0; for (i=0;i<features;i++) for (j=0;j<m;j++) mean[i]+=X[j][i]; for (i=0;i<features;i++) mean[i]/=m; for (i=0;i<features;i++) for (j=0;j<features;j++) { sum=0; for (k=0;k<m;k++) sum+=(X[k][i]-mean[i])*(X[k][j]-mean[j]); Y[i][j]=sum/m; } }float Compute_Rm(center V, objects X){int i=0,j=0,l=0;double Dik=0,temp=0,Rm=0;Rm=0;for(i=0;i<MAXDATA;i++){Dik=0;for(j=0;j<lCount;j++){temp=0;for(l=0;l<features;l++)temp+=(X[i][l]-V[j][l])*(X[i][l]-V[j][l]);Dik+=pow(temp,1.0/(1-m));}Rm+=pow(Dik,(1-m));}return(Rm);}/* End of function *//********************************************************************/ /* Function to harden the outputs obtained from fcm(2nd stage)*/ /* Output: none */ /* Input: None */ /* Global Structure Modified: Cluster center , cluster center count*/ /********************************************************************/void hardenRm() { FILE *fp=fopen("fcmFCM.out","a"); FILE *fpOut=fopen("ClassDataFCM.out","a"); int i=0,minPosition=-1,position[MAXDATA],j=0,k=0; int cenCount[MAXDATA],classCount[MAXDATA][c],label[c], clsObjects[MAXDATA][MAXDATA]; for(j=0;j<classes;j++) {cenCount[j]=0;for(k=0;k<classes;k++)classCount[j][k]=0; } for(i=0;i<MAXDATA;i++) { minPosition=findPosition(i); position[i]=minPosition;clsObjects[minPosition][cenCount[minPosition]]=i;cenCount[minPosition]++; } for(j=0;j<classes;j++) {for(i=0;i<cenCount[j];i++)classCount[j][(int)orgData[clsObjects[j][i]][0]-1]++; } /* minPosition varaible re used , now minPosition denotes the maximum class of the cluster*/for(j=0;j<classes;j++){minPosition=0;for(i=1;i<c;i++){if(classCount[j][i]>classCount[j][minPosition]) minPosition=i;label[j]=minPosition;}}fprintf(fp,"* %d\n",0);for(i=0;i<count;i++){for(j=0;j<classes;j++)for(k=0;k<cenCount[j];k++)if(clsObjects[j][k]==i){fprintf(fp,"%d ",label[j]+1);break;}}fprintf(fp,"\n");for(i=0;i<classes;i++){fprintf(fpOut,"%2d %4d\n",label[i]+1,cenCount[i]);}fclose(fpOut);fclose(fp);return; }/*end of function*/ /********************************************************************//* Function Main *//********************************************************************/ int main(int argc, char** argv){int k=0,i=0,j=0;int sum=0;char temp[80];FILE *fpRmOut=fopen("fcmRm.out","w");FILE *fpOut=fopen("ClassData.out","w");FILE *fpCls=fopen("clsCenters.out","w");FILE *fpMinRm=fopen("minRm.out","w");FILE *fpOrgClass=fopen("orgClass.out","w");FILE *fpRm=fopen("Rm.out","w");FILE *fpJmRm=fopen("JmRm.out","w");FILE *fp=fopen("fcm.out","w");FILE *fp1; FILE *fp2=fopen("antAnalysis.out","a");FILE *fp3=fopen("fcmAnalysis.out","a"); FILE *fp4=fopen("errors.out","w");FILE *fp5;FILE *fpJm=fopen("jm.out","w");FILE *fpTime=fopen("time.out","w");FILE *fpFCM=fopen("fcmFCM.out","w");FILE *fpOutFCM=fopen("ClassDataFCM.out","w");fprintf(fpFCM,"# %d\n",EXPRUN);fprintf(fpFCM,"@ %d\n",1);fclose(fpFCM);fclose(fpOutFCM);fclose(fp4);fclose(fpJm);sprintf(temp,"%sObj.out",filename);fp5=fopen(temp,"w");fclose(fp5);strcpy(temp,"");sprintf(temp,"%sTot.out",filename);fp5=fopen(temp,"w");fclose(fp5);strcpy(temp,"");sprintf(temp,"%sOp.out",filename);fp1=fopen(temp,"w");fprintf(fp,"\n$%d",EXPRUN);fprintf(fp1,"\n$%d",EXPRUN);fclose(fp);fclose(fp1);fclose(fpJmRm);fprintf(fpRmOut,"# %d\n",EXPRUN);fprintf(fpRmOut,"@ %d\n",antsPerFeature);fclose(fpRmOut);fprintf(fpTime,"Experiments %d\n",EXPRUN);fprintf(fpMinRm,"# %d\n",EXPRUN);fprintf(fpMinRm,"@ %d\n",antsPerFeature);fclose(fpMinRm);fclose(fpOut);fclose(fpCls);fclose(fpOrgClass);fclose(fpRm);fclose(fpTime);/*readInput();*/ if(argc==2)sscanf(argv[1],"%d",&debugLevel); printf("\n Debug level %d\n",debugLevel); for( i=0;i<MAXROWS;i++) for( j=0;j<MAXCOLS;j++) board[i][j]=-9; readInput(); /*readOrg();*/ //Compute the distance of all the points if(maxDist) { Dmax=computeDistance(); //Compute the maximum distance fp5=fopen("maxData.txt","w");fprintf(fp5,"%f",Dmax);fclose(fp5); } else {fp5=fopen("maxData.txt","r");fscanf(fp5,"%f",&Dmax);fclose(fp5); } printf("\n %f \n",Dmax); //Initialise the board for(k=0;k<EXPRUN;k++) { fpRmOut=fopen("fcmRm.out","a");fpOut=fopen("ClassData.out","a");fpCls=fopen("clsCenters.out","a");fpOrgClass=fopen("orgClass.out","a");fpMinRm=fopen("minRm.out","a");fpRm=fopen("Rm.out","a");fpTime=fopen("time.out","a");fpFCM=fopen("fcmFCM.out","a");fpOutFCM=fopen("ClassDataFCM.out","a");fprintf(fpFCM,"$ %d\n",k);fprintf(fpOutFCM,"Experiment %d\n",k);fprintf(fpRm,"Exp: %2d ",k);fclose(fpRm);fprintf(fpCls,"EXP No %2d \n",k);fclose(fpCls);fprintf(fpRmOut,"$ %d\n",k);fprintf(fpMinRm,"$ %d\n",k);fprintf(fpOut,"Experiment %d\n",k);fprintf(fpOrgClass,"Experiment %d\n",k);fprintf(fpTime,"Experiment %d\n",k);fclose(fpRmOut);fclose(fpOut);fclose(fpMinRm);fclose(fpOrgClass);fclose(fpTime); fclose(fpFCM);fclose(fpOutFCM); init(); sum=0; srand48(state1[k]); initialiseBoard(); initialise(1); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(1); printf("\n %d \n",heapCount); //Simulate the working of ants iterate(1); //drop the objects after all the iterations dropFinal(1); //to verify the correctness for(i=0;i<heapCount;i++) sum+=heaps[i].count; //write the cluster centers to the file writeClusterInformation(1); printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); //getchar(); //Run FCM // heapCount=2973;/* To be commented */ printf("\n\n k %d \n\n",k); Fcm(data,V,0); //compute new board size. lCount=heapCount; heapRow=(int)ceil(sqrt(4*heapCount)); newHeapCount=lCount; printf("\n LCount %d newHeapCount %d heap Row %d \n",lCount,newHeapCount,heapRow); //harden the objects harden(newHeaps); //iterate with the heaps as the objects. initialiseBoard(); initialise(0); for(i=0;i<lCount;i++) computeHeapParameters(&heaps[i],0); printf("\n %d \n",heapCount); //Initialise the ants initialiseAnts(0); printf("\n %d \n",heapCount); //getchar(); //Simulate the working of ants iterate(0); dropFinal(0); writeClusterInformation(0); sum=0; for(i=0;i<newHeapCount;i++) sum+=newHeaps[i].count; printf("\nHeap Count %d sum %d \n",heapCount,sum); printf("\n Min heap count %d iteration %d \n",minHeapCount,minPosition); // getchar(); fpJm=fopen("jm.out","a"); fprintf(fpJm,"Experiment %2d: ",k); fclose(fpJm); Fcm(data,V,1); harden1(); RmStage(newHeapCount,V); } fp=fopen("fcm.out","a"); fp1=fopen(temp,"a"); fprintf(fp,"\n"); fprintf(fp1,"\n"); fclose(fp); fclose(fp1); fp=fopen("fcm.out","r"); fp1=fopen(temp,"r"); printf("\n Before read org\n");printf("\nafter read org\n");/*readFCM(fp1,fp2);*/printf("\n After 1st read fcm\n");/*readFCM(fp,fp3);*/printf("\n After 2 fcm read \n");/*analysis(1);analysis(0);*/return(1); }//end of main