A clustering approach to portfolio replication