Learning to optimize: A tutorial for continuous and mixed-integer optimization