Added partition cost function