Wireless sensor network (WSNs) consistsof a variety of sensor nodes to sense the environmentalparameters and communicate to the sink knot. The control factor is that controlling the power of the sensor nodes and charging or replacing the battery is an expensive and complicated process, which affects the sensor node lifetime as well as network lifetime. Clustering is one of the schemes that save energy by reducing the amount of intra-cluster communication cost. In this paper, an optimal clustering (OC) algorithm proposed to maximizes the network lifetime at data transmission without compromising energy expenditure. In OC algorithm, first we propose the turbid ant swarm(TAS) algorithm to form the clusters, which reduces much amount of energy consumption. Then, an improved myopic (IM) algorithm proposed to determines the cluster head (CH) of cluster, which minimizes re-clustering frequency and intra-communication charge. The proposed OC-TAS-IM algorithm is concentrate to get better the energy efficiency and extend the network life span. Moreover, the planned algorithm is practical to the low-energy adaptive clustering hierarchy (LEACH) to perform the entire routing. The completion and imitation experiment with Network Simulator (NS2) are obtainable in order to authenticate our planned OC-TAS-IM algorithm. Imitation outcome illustrate that OC-TAS-IM algorithm is stable in terms of energy consumption and network lifetime because of optimal clustering.