Generating music with an optimization algorithm using a Markov based objective function