Recent advances in wireless electronic and communications provide us the ability to build small, economical sensors with low power consumption and many diverse applications. Limited energy capacity of sensors is a huge challenge that will affect these networks. Clustering has been used as a well-known method to handle this challenge. To find appropriate location of clusters' heads, imperialist competitive algorithm as an emerging topic in computational intelligence has been used. Clusters' heads are connected in a three-level model so that cluster heads with low energy capacity and far from station are considered as level three indirectly communicating with base station. This eventually increases lifetime of wireless sensor networks.