protected void generate(String folder, List<String> files, int totalOfFiles, int level) throws Exception { logger.info( "Generating Quality Indicators for " + folder + ". Finding a True Pareto-front file in the path"); File parent = new File(folder); for (int i = 0; i < level; i++) { parent = parent.getParentFile(); } String approxTrueParetoFrontPath = parent.getAbsolutePath() + File.separator + "PFAPPROX"; if (!new File(approxTrueParetoFrontPath).exists()) { throw new Exception("You must to define a true Pareto-front before"); } SolutionSet paretoFront = SolutionSetUtils.getFromFile(approxTrueParetoFrontPath); if (paretoFront.size() == 0) { throw new IllegalArgumentException("The Approximate Pareto-front cannot be empty"); } int numberOfObjectives = paretoFront.get(0).getNumberOfObjectives(); Problem p = new FakeProblem(numberOfObjectives); QualityIndicator qi = new QualityIndicator(p, approxTrueParetoFrontPath); for (String file : files) { generateQualityIndicators(qi, folder, file, paretoFront, totalOfFiles); } }
protected void generateQualityIndicators( QualityIndicator qi, String folder, String file, SolutionSet paretoFront, int totalOfFiles) throws IOException { updateNote(getCurrentProgress() + " from " + totalOfFiles); logger.info("Generating QI for file " + file); SolutionSet population = SolutionSetUtils.getFromFile(file); Properties values = new Properties(); List<Indicator> indicators = IndicatorUtils.getIndicatorList(); for (Indicator ind : indicators) { values.put(ind.getKey(), ind.execute(qi, paretoFront, file, population)); } values = convertAllValuesToString(values); String filename = FilenameUtils.getBaseName(file); String outputFile = folder + File.separator + "QI_" + filename; PropertiesUtils.save(new File(outputFile), values); updateProgress(); }