Given an index, let's say S&P500, I am trying to find a list of maximum n underlyings, which altogether track the index quite well. I am thinking of running a portfolio optimization algorithm, where I long the Index (weight = 1) and short the n underlyings, with the aim of minimizing portfolio variance. The output would be the weights of the underlyings.
However, given there are 500 underlyings, there would be too many different combinations of underlyings, whose len(underlyings) <= n, and as a result the program would run very slowly. Is there a faster way / another way of selecting a basket of stocks that track the index well?