Cluster analysis is a technique that is used to discover patterns and associations within data. One of the major problems is that different clustering methods can form different solutions for the same dataset in cluster analysis. Therefore, this study aimed to provide optimal clustering of units by using a genetic algorithm. To this end, a new fitness function was defined by adding the silhouette function that shows the units are in the correct clusters, to the fitness function, which minimizes the ratio of intra-cluster distances to inter-cluster distances. This algorithm was supported by simulation studies and tried on real data. The results of the analysis showed that this algorithm could generate better clustering results than some other clustering algorithms. Hence, in this algorithm, the use of fitness function ensured convergence to the global optimum.