Optimal control in linear advertising models with memory