package adda.ej2;

import java.util.Locale;

import adda.ej2.common.BinaryCestaAG;
import adda.util.Titles;
import us.lsi.ag.agchromosomes.AlgoritmoAG;
import us.lsi.ag.agstopping.StoppingConditionFactory;

public class TestCestaAG {
	@SuppressWarnings({ "rawtypes" })
	private static void test(String fichero) {
		Locale.setDefault(Locale.of("en", "US"));
		
		AlgoritmoAG.ELITISM_RATE  = 0.10;
		AlgoritmoAG.CROSSOVER_RATE = 0.9;
		AlgoritmoAG.MUTATION_RATE = 0.75;
		AlgoritmoAG.POPULATION_SIZE = 1000;
		
		StoppingConditionFactory.NUM_GENERATIONS = 1000;
		StoppingConditionFactory.stoppingConditionType = StoppingConditionFactory.StoppingConditionType.GenerationCount;
		
		BinaryCestaAG p = new BinaryCestaAG(fichero);
		AlgoritmoAG alg = AlgoritmoAG.of(p);
		alg.ejecuta();
		
		System.out.println("================================");
		System.out.println(alg.bestSolution());
		System.out.println("================================");
	}
	
	public static void main(String[] args) {
		System.out.println(Titles.F1);
		test("ficheros/ej2/Ejercicio2DatosEntrada1.txt");
		System.out.println(Titles.F2);
		test("ficheros/ej2/Ejercicio2DatosEntrada2.txt");
		System.out.println(Titles.F3);
		test("ficheros/ej2/Ejercicio2DatosEntrada3.txt");
	}
}
