A potential-based clustering method with hierarchical optimization