Optimal oracle inequalities for model selection