optimized kmeans and agllo