Control sequences so as to optimize energy use by controlled machine