In this chapter, the authors conduct portfolio backtesting in a realistic setting by including transaction costs and investment constraints such as no-short-selling rules. They start with standard mean-variance efficient portfolios and introduce constraints in a step-by-step manner. The authors introduce the quadprog package to perform numerical constrained optimization for quadratic objective functions and alabama for more general non-linear objective functions and constraints. Wang and Garlappi et al. provide theoretical analysis on optimal portfolio choice under model and estimation uncertainty. In the most extreme case, Pflug et al. shows that the naive portfolio which allocates equal wealth to all assets is the optimal choice for an investor averse to model uncertainty.