Cluster analysis for portfolio optimization