Inverse optimal control with polynomial optimization