04 January 2020 2 9K Report

I want to apply a genetic algorithm for this program, I need the same output using the genetic algorithm. Can someone help me?

public static void main(String[] args) {

List all_genes = new ArrayList();

all_genes.add(1);

all_genes.add(2);

all_genes.add(3);

//initial input of all tickets

List temp_gene = new ArrayList(all_genes);

System.out.println("initial input of tickets="+temp_gene); for (int i = 0; i < 3; i++) { //here we use shuffle the all tickets and make a different orders of tickets //random permutations of the genes

java.util.Collections.shuffle(all_genes);

System.out.println("tickets orders="+all_genes); } }

//output initial input of tickets=[1, 2, 3, 4, 5, 6, 7]

tickets orders=[1, 7, 4, 3, 2, 6, 5]

tickets orders=[6, 2, 3, 1, 5, 4, 7]

tickets orders=[2, 1, 3, 7, 4, 6, 5]

More Ali Arain's questions See All
Similar questions and discussions