// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: // ::::::::::::: L O A D E L E M E N T S ::::::::::::::::::::::::::::::::: // :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: public static ArrayList<Genetic> loadGenetic(String txt, String KEY, String KEY_LIB) { ArrayList<Genetic> elements = new ArrayList<>(); Scanner file = new Scanner(txt); String line; while (file.hasNext()) { line = file.nextLine().trim(); if (line.startsWith(KEY)) { // remove key line = line.substring(KEY.length()).trim(); // bad definition if (line.indexOf("=") != 0) { continue; } // remove = line = line.substring(1).trim(); try { // try to build a genetic alement Genetic g = Genetic.createNew(KEY_LIB + line); elements.add(g); } catch (Exception e) { // not a genetic element } } } return elements; }
public EAsolverArray(EAsolver template) { // :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: this.solverName = template.solverName; // copy information from template this.template = template; this.numberOfRun = template.numberOfRun; this.randomSeed = template.randomSeed; this.random = new Random(randomSeed); this.problem = template.problem.getClone(); this.parents = template.parents.getCleanClone(); this.selection = (GeneticOperator) Genetic.getClone(template.selection); this.recombination = (GeneticOperator) Genetic.getClone(template.recombination); this.mutation = (GeneticOperator) Genetic.getClone(template.mutation); this.replacement = (GeneticOperator) Genetic.getClone(template.replacement); this.rescaling = (GeneticOperator) Genetic.getClone(template.rescaling); this.stop = (StopCriteria) Genetic.getClone(template.stop); // new type of report this.report = new ReportSolverArray(template); this.updateSolverAtributes(); // :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: arrayOfSolvers = createArrayOfSolvers(template); }
public static String getSimpleGenetic(String prefix, Genetic elem) { String str = elem.getClass().getCanonicalName().substring(prefix.length()); str += " " + elem.getParameters(); return str.trim(); }