Model predictive optimization for imitation learning from demonstrations