1. A method of manufacturing at least a first product and a second product with at least a first machine and a second machine at minimum cost in an environment in which a cost of energy used by the first machine and the second machine varies as a function of time, the method comprising: generating multiple chromosomes, each chromosome including: a job sequence matrix describing an order of performing tasks to manufacture the first product and the second product using the first machine and the second machine; and an idle time matrix describing idle times before performing the tasks in the order described by the job sequence matrix; determining fitness scores of each of the chromosomes with the job sequence matrices and the idle time matrices, the fitness scores being based on energy costs at the times that the first and second machines perform the tasks; randomly generating, with probabilities based on the fitness scores, new chromosomes; determining fitness scores of the new chromosomes; selecting one of the new chromosomes with an optimal fitness score; and manufacturing at least the first product and the second product with at least the first machine and the second machine according to a schedule based on the selected new chromosome, the schedule determining when the first and second machines perform which tasks and when the first and second machines are idle.