Dynamic Debt Optimization and Mean-Variance Investment Portfolio