Optimal Long-Term Investment Model with Memory