Continual learning with direction-constrained optimization