public void crossover(){
for (int m=0; m<pais.size(); m=m+2){
ArrayList<Integer> mapeamento1 = new ArrayList<Integer>();
ArrayList<Integer> mapeamento2 = new ArrayList<Integer>();
Caminho filho1 = new Caminho();
Caminho filho2 = new Caminho();
for(int q=0; q<6; q++){
filho1.getCaminho().add(0);
filho2.getCaminho().add(0);
}
filho1.getCaminho().set(1, pais.get(m+1).getCaminho().get(2));
filho1.getCaminho().set(1, pais.get(m+1).getCaminho().get(3));
filho2.getCaminho().set(2, pais.get(m).getCaminho().get(2));
filho2.getCaminho().set(2, pais.get(m).getCaminho().get(3));
mapeamento1.add(pais.get(m).getCaminho().get(2));
mapeamento1.add(pais.get(m+1).getCaminho().get(2));
mapeamento2.add(pais.get(m).getCaminho().get(3));
mapeamento2.add(pais.get(m+1).getCaminho().get(3));
for (int n=0; n<6; n++){
if (n != 2 || n != 3){
if(!(mapeamento1.contains(pais.get(m).getCaminho().get(n)))){
filho1.getCaminho().set(n, pais.get(m).getCaminho().get(n));
filho2.getCaminho().set(n, pais.get(m+1).getCaminho().get(n));
}
else {
int index = mapeamento1.indexOf(pais.get(m).getCaminho().get(n));
if ((index % 2) == 0){
filho1.getCaminho().set(n, mapeamento1.get(index+1));
}
else{
filho1.getCaminho().set(n, mapeamento1.get(index-1));
}
}
}
}
for (int p=0; p<6; p++){
if (p != 2 || p != 3){
if(!(mapeamento2.contains(pais.get(m+1).getCaminho().get(p)))){
filho2.getCaminho().set(p, pais.get(m+1).getCaminho().get(p));
}
else {
int index = mapeamento2.indexOf(pais.get(m+1).getCaminho().get(p));
if ((index % 2) == 0){
filho2.getCaminho().set(p, mapeamento2.get(index+1));
}
else{
filho2.getCaminho().set(p, mapeamento2.get(index-1));
}
}
}
}