  In this research paper we modify a classical SIR model to better adapt to the
dynamics of COVID-19, that is we propose the heterogeneous SQAIRD model where
COVID-19 spreads over a population of economic agents, namely: the elderly,
adults and young people. We then compute and simulate an optimal control
problem faced by a Government, where its objective is to minimize the costs
generated by the pandemics using as control a compulsory quarantine measure
(that is, a lockdown). We first analyze the problem from a theoretical
perspective, claiming that different lockdown policies (total lockdown, no
lockdown or partial lockdown) may justified by different cost (concave or
convex) structures of the economies. We then focus on a particular cost
structure (convex costs) and we simulate a targeted optimal policy vs. a
uniform optimal policy, by dividing the whole population in three demographic
groups (young, adults and old). We also simulate the dynamic of the pandemic
with no policy implemented. Simulations highlighted the fact that: a) a policy
of lockdown is always better than the \emph{laissez faire} policy, because it
limits the costs that the pandemic generates in an uncontrolled situation; b) a
targeted policy based on age of the individuals outperforms a uniform policy in
terms of costs that it generates, being a targeted policy less costly and
equally effective in the control of the pandemic.
