A distribution-free mixed-integer optimization approach to hierarchical modelling of clustered and longitudinal data