I will disappoint you - it is something I simply remember from university years which is very long time ago. Pick any book on microeconomics and look for Paasche/Laspeyres indices and impact on budget constraint for an agent. :)
In general price indices (CPI/PPI) are based on "optimal" baskets...