| 1 | package de.uka.ipd.sdq.dsexplore.launch; |
| 2 | |
| 3 | import java.io.File; |
| 4 | import java.io.IOException; |
| 5 | import java.net.MalformedURLException; |
| 6 | import java.net.URL; |
| 7 | import java.util.ArrayList; |
| 8 | import java.util.HashMap; |
| 9 | import java.util.LinkedList; |
| 10 | import java.util.List; |
| 11 | import java.util.Map; |
| 12 | |
| 13 | import org.eclipse.core.runtime.CoreException; |
| 14 | import org.eclipse.core.runtime.FileLocator; |
| 15 | import org.eclipse.core.runtime.Status; |
| 16 | import org.eclipse.debug.core.ILaunchConfiguration; |
| 17 | import org.opt4j.core.DoubleValue; |
| 18 | import org.opt4j.core.Value; |
| 19 | |
| 20 | import de.uka.ipd.sdq.dsexplore.analysis.AnalysisProxy; |
| 21 | import de.uka.ipd.sdq.dsexplore.analysis.AnalysisQualityAttributes; |
| 22 | import de.uka.ipd.sdq.dsexplore.analysis.IAnalysis; |
| 23 | import de.uka.ipd.sdq.dsexplore.launch.DSEConstantsContainer.QualityAttribute; |
| 24 | import de.uka.ipd.sdq.dsexplore.launch.DSEWorkflowConfiguration.SearchMethod; |
| 25 | import de.uka.ipd.sdq.tcfmoop.config.ElapsedTimeConfig; |
| 26 | import de.uka.ipd.sdq.tcfmoop.config.GivenParetoFrontIsReachedConfig; |
| 27 | import de.uka.ipd.sdq.tcfmoop.config.InsignificantParetoFrontChangeConfig; |
| 28 | import de.uka.ipd.sdq.tcfmoop.config.InsignificantSetQualityImprovementConfig; |
| 29 | import de.uka.ipd.sdq.tcfmoop.config.MaxGenerationNumberConfig; |
| 30 | import de.uka.ipd.sdq.tcfmoop.config.MinimalQualityCriteriaValueConfig; |
| 31 | import de.uka.ipd.sdq.tcfmoop.config.NoNewParetoOptimalCandidatesFoundConfig; |
| 32 | import de.uka.ipd.sdq.tcfmoop.config.ParetoOptimalSetStabilityConfig; |
| 33 | import de.uka.ipd.sdq.tcfmoop.config.ElapsedTimeConfig.TimeType; |
| 34 | import de.uka.ipd.sdq.tcfmoop.config.InsignificantSetQualityImprovementConfig.UnresolvedValueDifference; |
| 35 | import de.uka.ipd.sdq.tcfmoop.config.ParetoOptimalSetStabilityConfig.EvaluationMode; |
| 36 | import de.uka.ipd.sdq.tcfmoop.config.exceptions.InvalidConfigException; |
| 37 | import de.uka.ipd.sdq.workflow.launchconfig.AbstractWorkflowBasedRunConfiguration; |
| 38 | import de.uka.ipd.sdq.workflow.launchconfig.AbstractWorkflowConfigurationBuilder; |
| 39 | import de.uka.ipd.sdq.workflow.pcm.ConstantsContainer; |
| 40 | |
| 41 | public class DSEWorkflowConfigurationBuilder extends |
| 42 | AbstractWorkflowConfigurationBuilder { |
| 43 | |
| 44 | /**XXX Quickfix to reset the loggers in the analysis Proxies */ |
| 45 | DSELaunch dseLaunch; |
| 46 | |
| 47 | public DSEWorkflowConfigurationBuilder(ILaunchConfiguration configuration, |
| 48 | String mode, DSELaunch dseLaunch) throws CoreException { |
| 49 | super(configuration, mode); |
| 50 | this.dseLaunch = dseLaunch; |
| 51 | // TODO Auto-generated constructor stub |
| 52 | } |
| 53 | |
| 54 | @Override |
| 55 | public void fillConfiguration( |
| 56 | AbstractWorkflowBasedRunConfiguration abstractConfiguration) |
| 57 | throws CoreException { |
| 58 | |
| 59 | DSEWorkflowConfiguration config = (DSEWorkflowConfiguration)abstractConfiguration; |
| 60 | |
| 61 | config.setOriginalConfig(this.configuration); |
| 62 | |
| 63 | config.setMaxIterations(getIntAttribute(DSEConstantsContainer.MAX_ITERATIONS)); |
| 64 | config.setIndividualsPerGeneration(getIntAttribute(DSEConstantsContainer.INDIVIDUALS_PER_GENERATION)); |
| 65 | config.setCrossoverRate(getDoubleAttribute(DSEConstantsContainer.CROSSOVER_RATE)); |
| 66 | |
| 67 | |
| 68 | config.setPredefinedInstancesFileName(getStringAttribute(DSEConstantsContainer.PREDEFINED_INSTANCES)); |
| 69 | config.setCacheInstancesFileName(getStringAttribute(DSEConstantsContainer.CACHE_INSTANCES)); |
| 70 | config.setPredefinedAllCandidatesFileName(getStringAttribute(DSEConstantsContainer.ALL_CANDIDATES)); |
| 71 | config.setArchiveCandidateFileName(getStringAttribute(DSEConstantsContainer.ARCHIVE_CANDIDATES)); |
| 72 | |
| 73 | |
| 74 | String searchMethod = getStringAttribute(DSEConstantsContainer.SEARCH_METHOD); |
| 75 | if (searchMethod.equals(DSEConstantsContainer.SEARCH_EVOLUTIONARY)){ |
| 76 | config.setSearchMethod(SearchMethod.EVOLUTIONARY); |
| 77 | } else if (searchMethod.equals(DSEConstantsContainer.SEARCH_RANDOM)) { |
| 78 | config.setSearchMethod(SearchMethod.RANDOM); |
| 79 | } else if (searchMethod.equals(DSEConstantsContainer.SEARCH_RULE)) { |
| 80 | config.setSearchMethod(SearchMethod.RULE); |
| 81 | } else if (searchMethod.equals(DSEConstantsContainer.SEARCH_RULE_OPT)){ |
| 82 | config.setSearchMethod(SearchMethod.RULE_OPT); |
| 83 | } |
| 84 | |
| 85 | |
| 86 | config.setNewProblem(!this.configuration.getAttribute(DSEConstantsContainer.OPTIMISATION_ONLY, false)); |
| 87 | config.setOptimise(!this.configuration.getAttribute(DSEConstantsContainer.DESIGN_DECISIONS_ONLY, false)); |
| 88 | |
| 89 | |
| 90 | /* |
| 91 | * Heuristics settings |
| 92 | */ |
| 93 | boolean isConsiderQMLBounds = getBooleanAttribute(DSEConstantsContainer.CONSIDER_QML_BOUNDS); |
| 94 | config.setConsiderQMLBoundsWhenApplyingHeuristics(isConsiderQMLBounds); |
| 95 | |
| 96 | double tacticsProbability = getDoubleAttribute(DSEConstantsContainer.TACTICS_PROBABILITY); |
| 97 | config.setTacticsProbability(tacticsProbability); |
| 98 | |
| 99 | boolean isUseReallocation = getBooleanAttribute(DSEConstantsContainer.USE_REALLOCATION); |
| 100 | config.setUseReallocation(isUseReallocation); |
| 101 | if (isUseReallocation){ |
| 102 | config.setReallocationThresholdUtilisationDifference(getDoubleAttribute(DSEConstantsContainer.REALLOCATION_UTILISATION_DIFFERENCE)); |
| 103 | config.setReallocationWeight(getDoubleAttribute(DSEConstantsContainer.REALLOCATION_WEIGHT)); |
| 104 | } |
| 105 | |
| 106 | boolean isUseProcRate = getBooleanAttribute(DSEConstantsContainer.USE_PROCESSING_RATE); |
| 107 | config.setUseProcessingRate(isUseProcRate); |
| 108 | if (isUseProcRate){ |
| 109 | config.setProcessingRateDecreaseFactor(getDoubleAttribute(DSEConstantsContainer.PROCESSING_RATE_DECREASE_FACTOR)); |
| 110 | config.setProcessingRateIncreaseFactor(getDoubleAttribute(DSEConstantsContainer.PROCESSING_RATE_INCREASE_FACTOR)); |
| 111 | config.setProcessingRateThresholdHighUtilisation(getDoubleAttribute(DSEConstantsContainer.PROCESSING_RATE_THRESHOLD_HIGH_UTILISATION)); |
| 112 | config.setProcessingRateThresholdLowUtilisation(getDoubleAttribute(DSEConstantsContainer.PROCESSING_RATE_THRESHOLD_LOW_UTILISATION)); |
| 113 | config.setProcessingRateWeight(getDoubleAttribute(DSEConstantsContainer.PROCESSING_RATE_WEIGHT)); |
| 114 | } |
| 115 | |
| 116 | boolean isUseServerConsolidation = getBooleanAttribute(DSEConstantsContainer.USE_SERVER_CONSOLIDATION); |
| 117 | config.setUseServerConsolidation(isUseServerConsolidation); |
| 118 | if (isUseServerConsolidation){ |
| 119 | config.setServerConsolidationThresholdLowUtilisation(getDoubleAttribute(DSEConstantsContainer.SERVER_CONSOLIDATION_THRESHOLD_LOW_UTILISATION)); |
| 120 | config.setServerConsolidationWeight(getDoubleAttribute(DSEConstantsContainer.SERVER_CONSOLIDATION_WEIGHT)); |
| 121 | } |
| 122 | |
| 123 | boolean isUseServerExpansion = getBooleanAttribute(DSEConstantsContainer.USE_SERVER_EXPANSION); |
| 124 | config.setUseServerExpansion(isUseServerExpansion); |
| 125 | if (isUseServerExpansion){ |
| 126 | config.setServerExpansionMaxNumberOfReplacements(getIntAttribute(DSEConstantsContainer.SERVER_EXPANSION_MAX_NUMBER_OF_REPLACEMENTS)); |
| 127 | config.setServerExpansionThresholdHighUtilisation(getDoubleAttribute(DSEConstantsContainer.SERVER_EXPANSION_THRESHOLD_HIGH_UTILISATION)); |
| 128 | config.setServerExpansionWeight(getDoubleAttribute(DSEConstantsContainer.SERVER_EXPANSION_WEIGHT)); |
| 129 | } |
| 130 | |
| 131 | boolean isUseLinkRealloc = getBooleanAttribute(DSEConstantsContainer.USE_LINK_REALLOCATION); |
| 132 | config.setUseLinkReallocationTactic(isUseLinkRealloc); |
| 133 | |
| 134 | boolean isUseAntipattern = getBooleanAttribute(DSEConstantsContainer.USE_ANTIPATTERNS); |
| 135 | config.setUseAntipatternKnowledge(isUseAntipattern); |
| 136 | |
| 137 | /* |
| 138 | * Starting Population |
| 139 | */ |
| 140 | boolean isUseStartingPop = getBooleanAttribute(DSEConstantsContainer.USE_STARTING_POPULATION_HEURISTIC); |
| 141 | config.setUseStartingPopulationHeuristic(isUseStartingPop); |
| 142 | if (isUseStartingPop){ |
| 143 | config.setMinNumberOfResourceContainers(getIntAttribute(DSEConstantsContainer.MIN_NUMBER_RESOURCE_CONTAINERS)); |
| 144 | config.setMaxNumberOfResourceContainers(getIntAttribute(DSEConstantsContainer.MAX_NUMBER_RESOURCE_CONTAINERS)); |
| 145 | config.setNumberOfCandidatesPerAllocationLevel(getIntAttribute(DSEConstantsContainer.NUMBER_OF_CANDIDATES_PER_ALLOCATION_LEVEL)); |
| 146 | } |
| 147 | |
| 148 | |
| 149 | |
| 150 | String ddfilename = this.configuration.getAttribute(DSEConstantsContainer.DESIGN_DECISION_FILE, ""); |
| 151 | if (ddfilename.length() == 0){ |
| 152 | ddfilename = getDefaultDesignDecisionFileName(); |
| 153 | } |
| 154 | config.setDesignDecisionFileName(ddfilename); |
| 155 | |
| 156 | //Write results "next to" allocation model file. |
| 157 | String folderPathOnly = getPathToAllocation(); |
| 158 | |
| 159 | String resultsPath = folderPathOnly+"PerOpteryx_results/"; |
| 160 | File f = new File(resultsPath); |
| 161 | if (f.exists()){ |
| 162 | if (!f.isDirectory()){ |
| 163 | throw new CoreException(new Status(Status.ERROR,"de.uka.ipd.sdq.dsexplore.launch.DSEWorkflowConfigurationBuilder","File "+resultsPath+" already exists and is not a directory, please rename that file.")); |
| 164 | } |
| 165 | } else { |
| 166 | f.mkdir(); |
| 167 | } |
| 168 | |
| 169 | config.setResultFolder(resultsPath); |
| 170 | |
| 171 | config.setConfigurationName(this.configuration.getName()); |
| 172 | |
| 173 | //Initialise Evaluators last |
| 174 | ArrayList<IAnalysis> evaluators = new ArrayList<IAnalysis>(); |
| 175 | for(QualityAttribute d : new AnalysisQualityAttributes().getAllQualityAttributes()) { |
| 176 | addEvaluatorsIfSelected(evaluators, d, config); |
| 177 | } |
| 178 | //addEvaluatorsIfSelected(evaluators, DSEConstantsContainer.SECURITY, config); |
| 179 | config.setEvaluators(evaluators); |
| 180 | |
| 181 | addTerminationCriteriaSettings(config); |
| 182 | |
| 183 | config.setStopOnInitialFailure(getBooleanAttribute(DSEConstantsContainer.STOP_ON_INITIAL_FAILURE)); |
| 184 | config.setResultsAsEMF(getBooleanAttribute(DSEConstantsContainer.STORE_RESULTS_AS_EMF)); |
| 185 | config.setResultsAsCSV(!getBooleanAttribute(DSEConstantsContainer.STORE_RESULTS_AS_EMF)); |
| 186 | |
| 187 | } |
| 188 | |
| 189 | private void addEvaluatorsIfSelected(ArrayList<IAnalysis> evaluators, |
| 190 | QualityAttribute d, DSEWorkflowConfiguration config) throws CoreException { |
| 191 | |
| 192 | String methodName = configuration.getAttribute(DSEConstantsContainer.getAnalysisMethod(d), ""); |
| 193 | if (!methodName.equals(DSEConstantsContainer.NONE)){ |
| 194 | AnalysisProxy analysis = new AnalysisProxy(config, d, this.dseLaunch, methodName); |
| 195 | evaluators.add(analysis); |
| 196 | } |
| 197 | |
| 198 | } |
| 199 | |
| 200 | |
| 201 | private String getPathToAllocation() throws CoreException { |
| 202 | String allocFileName = this.configuration.getAttribute(ConstantsContainer.ALLOCATION_FILE, ""); |
| 203 | String folderPathOnly = getPathTo(allocFileName); |
| 204 | if ("".equals(folderPathOnly)){ |
| 205 | throw new CoreException(new Status(Status.ERROR,"de.uka.ipd.sdq.dsexplore.launch.DSEWorkflowConfigurationBuilder","Cannot determine path to allocation model to decide where to put the result files. Please check you allocation model.")); |
| 206 | } |
| 207 | return folderPathOnly; |
| 208 | } |
| 209 | |
| 210 | /** |
| 211 | * Reads an attribute from the configurations and tries to parse it as an integer. |
| 212 | * @param configuration The {@link ILaunchConfiguration} |
| 213 | * @param key The key under which the attribute is stored |
| 214 | * @param defaultValue A default value if the attribute is not found |
| 215 | * @return An integer value for the attribute, 0 if parsing was unsuccessful |
| 216 | * @throws CoreException thrown by {@link ILaunchConfiguration#getAttribute(String, String)} |
| 217 | */ |
| 218 | private int getIntAttribute(String key) |
| 219 | throws CoreException { |
| 220 | String stringValue = configuration.getAttribute(key, "0"); |
| 221 | if (stringValue.equals("")){ |
| 222 | return 0; |
| 223 | } else { |
| 224 | int i = Integer.parseInt(stringValue); |
| 225 | return i; |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | |
| 230 | private String getDefaultDesignDecisionFileName() throws CoreException { |
| 231 | String problemName = this.configuration.getName(); |
| 232 | return getPathToAllocation()+problemName+".designdecision"; |
| 233 | } |
| 234 | |
| 235 | /**returns the path including the last slash */ |
| 236 | private String getPathTo(String fileURL){ |
| 237 | // if this is a platform URL, first resolve it to an absolute path |
| 238 | if (fileURL.startsWith("platform:")){ |
| 239 | try { |
| 240 | URL solvedURL = FileLocator.resolve(new URL(fileURL)); |
| 241 | fileURL = solvedURL.getPath(); |
| 242 | } catch (Exception e) { |
| 243 | e.printStackTrace(); |
| 244 | return ""; |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | // now this should be an absolute path, but it can have either slashes or backslashes |
| 249 | int indexBackslash = fileURL.lastIndexOf("\\"); |
| 250 | int indexSlash = fileURL.lastIndexOf("/"); |
| 251 | // the right directory separator is the one where the above results in the higher index (assuming that linux file systems do not allow backslashes in file names...) |
| 252 | int index = indexBackslash > indexSlash ? indexBackslash : indexSlash; |
| 253 | String folderPath = fileURL.substring(0, index+1); |
| 254 | return folderPath; |
| 255 | |
| 256 | } |
| 257 | |
| 258 | private void addTerminationCriteriaSettings(DSEWorkflowConfiguration config) throws CoreException { |
| 259 | config.setUseTerminationCriteria(this.getBooleanAttribute(DSEConstantsContainer.TC_GENERAL_USE_TERMINATION_CRITERIA)); |
| 260 | |
| 261 | if(config.getUseTerminationCriteria()){ |
| 262 | config.setRunInComparisionMode(this.getBooleanAttribute(DSEConstantsContainer.TC_GENERAL_COMPARISION_MODE)); |
| 263 | |
| 264 | config.setActivateComposedTerminationCriteria(this.getBooleanAttribute(DSEConstantsContainer.TC_COMPOSED_CRITERIA_ACTIVATE)); |
| 265 | if(config.getActivateComposedTerminationCriteria()){ |
| 266 | config.setComposedCriteriaExpression(this.getStringAttribute(DSEConstantsContainer.TC_COMPOSED_CRITERIA_EXPRESSION)); |
| 267 | } |
| 268 | |
| 269 | //Maximum Generation Number Criterion |
| 270 | if(getBooleanAttribute(DSEConstantsContainer.TC_MAX_NUM_OF_GEN_ACTIVATE)){ |
| 271 | try { |
| 272 | MaxGenerationNumberConfig mgnc = new MaxGenerationNumberConfig(); |
| 273 | mgnc.setMaximumNumberOfIterations(this.getIntegerAttribute(DSEConstantsContainer.TC_MAX_NUM_OF_GEN_LIMIT)); |
| 274 | config.getTCConfigurations().add(mgnc); |
| 275 | } catch (InvalidConfigException e) { |
| 276 | // TODO Auto-generated catch block |
| 277 | e.printStackTrace(); |
| 278 | } |
| 279 | |
| 280 | } |
| 281 | |
| 282 | //Elapsed Time Criterion |
| 283 | if (getBooleanAttribute(DSEConstantsContainer.TC_ELAPSED_TIME_ACTIVATE)) { |
| 284 | try { |
| 285 | ElapsedTimeConfig etc = new ElapsedTimeConfig(); |
| 286 | etc.setExecutionInterval(this.getIntegerAttribute(DSEConstantsContainer.TC_ELAPSED_TIME_TIME_LIMIT)*60*1000L); |
| 287 | if (getStringAttribute(DSEConstantsContainer.TC_ELAPSED_TIME_TYPE).equalsIgnoreCase("USER_TIME")) { |
| 288 | etc.setTimeType(TimeType.USER_TIME); |
| 289 | config.getTCConfigurations().add(etc); |
| 290 | } else if (getStringAttribute(DSEConstantsContainer.TC_ELAPSED_TIME_TYPE).equalsIgnoreCase("CPU_TIME")) { |
| 291 | etc.setTimeType(TimeType.CPU_TIME); |
| 292 | etc.setExecutionInterval(this.getIntegerAttribute(DSEConstantsContainer.TC_ELAPSED_TIME_TIME_LIMIT)*60*1000L); |
| 293 | config.getTCConfigurations().add(etc); |
| 294 | } |
| 295 | } catch (InvalidConfigException e) { |
| 296 | // TODO Auto-generated catch block |
| 297 | e.printStackTrace(); |
| 298 | } |
| 299 | |
| 300 | } |
| 301 | //No New Pareto Optimal Candidates Found Criterion |
| 302 | if(getBooleanAttribute(DSEConstantsContainer.TC_NO_NEW_CANDIDATES_ACTIVATE)){ |
| 303 | try { |
| 304 | NoNewParetoOptimalCandidatesFoundConfig nnpocf = new NoNewParetoOptimalCandidatesFoundConfig(); |
| 305 | nnpocf.setIterationsWithoutNewCandidates(this.getIntegerAttribute(DSEConstantsContainer.TC_NO_NEW_CANDIDATES_ITERATIONS_WITHOUT)); |
| 306 | config.getTCConfigurations().add(nnpocf); |
| 307 | } catch (InvalidConfigException e) { |
| 308 | // TODO Auto-generated catch block |
| 309 | e.printStackTrace(); |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | //Pareto Optimal Set Stability |
| 314 | if(getBooleanAttribute(DSEConstantsContainer.TC_SET_STABILITY_ACTIVATE)){ |
| 315 | try { |
| 316 | ParetoOptimalSetStabilityConfig poss = new ParetoOptimalSetStabilityConfig(); |
| 317 | poss.setMinimumIterationsToSurvive(this.getIntegerAttribute(DSEConstantsContainer.TC_SET_STABILITY_MINIMUM_ITERATION_TO_SURVIVE)); |
| 318 | if(getStringAttribute(DSEConstantsContainer.TC_SET_STABILITY_MODE).equalsIgnoreCase("EXACT_NUMBER")){ |
| 319 | poss.setEvaluationMode(EvaluationMode.EXACT_NUMBER); |
| 320 | poss.setMinimumSurvivors(this.getIntegerAttribute(DSEConstantsContainer.TC_SET_STABILITY_NUMBER_OF_SURVIVORS_EXACT)); |
| 321 | }else if(getStringAttribute(DSEConstantsContainer.TC_SET_STABILITY_MODE).equalsIgnoreCase("PERCENTAGE")){ |
| 322 | poss.setEvaluationMode(EvaluationMode.PERCENTAGE); |
| 323 | poss.setMinimumSurvivorsInPercentage(this.getIntegerAttribute(DSEConstantsContainer.TC_SET_STABILITY_NUMBER_OF_SURVIVORS_PERCENTAGE) / 100.0); |
| 324 | } |
| 325 | config.getTCConfigurations().add(poss); |
| 326 | } catch (InvalidConfigException e) { |
| 327 | // TODO Auto-generated catch block |
| 328 | e.printStackTrace(); |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | //Minimal Quality Criteria Value |
| 333 | if(getBooleanAttribute(DSEConstantsContainer.TC_MINIMAL_VALUES_ACTIVATE)){ |
| 334 | try { |
| 335 | MinimalQualityCriteriaValueConfig mqcvc = new MinimalQualityCriteriaValueConfig(); |
| 336 | mqcvc.setNumberOfCandidatesToConform(this.getIntegerAttribute(DSEConstantsContainer.TC_MINIMAL_VALUES_CANDIDATES_TO_CONFORM)); |
| 337 | |
| 338 | String[] configuredObjectivesLines = getStringAttribute(DSEConstantsContainer.TC_MINIMAL_VALUES_CONFIGURED_OBJECTIVES).split(";"); |
| 339 | List<String[]> decodedLines = new LinkedList<String[]>(); |
| 340 | for(String item : configuredObjectivesLines){ |
| 341 | decodedLines.add(item.split("\\|")); |
| 342 | } |
| 343 | |
| 344 | Map<String, Value<?>> unresolvedObjectives = new HashMap<String, Value<?>>(); |
| 345 | for (String[] singleLine : decodedLines) { |
| 346 | unresolvedObjectives.put(singleLine[0], new DoubleValue(Double.parseDouble(singleLine[1]))); |
| 347 | } |
| 348 | |
| 349 | mqcvc.setUnresolvedObjectiveMinimalValue(unresolvedObjectives); |
| 350 | config.getTCConfigurations().add(mqcvc); |
| 351 | } catch (InvalidConfigException e) { |
| 352 | // TODO Auto-generated catch block |
| 353 | e.printStackTrace(); |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | //A Given Pareto Front is Reached |
| 358 | if(getBooleanAttribute(DSEConstantsContainer.TC_PARETO_FRONT_IS_REACHED_ACTIVATE)){ |
| 359 | try { |
| 360 | GivenParetoFrontIsReachedConfig gpfir = new GivenParetoFrontIsReachedConfig(); |
| 361 | gpfir.setParetoFrontFile(getStringAttribute(DSEConstantsContainer.TC_PARETO_FRONT_IS_REACHED_PATH_TO_FRONT_FILE)); |
| 362 | gpfir.setPercentagesToCover(this.getIntegerAttribute(DSEConstantsContainer.TC_PARETO_FRONT_IS_REACHED_PERCENTAGES_TO_COVER)/100d); |
| 363 | config.getTCConfigurations().add(gpfir); |
| 364 | } catch (InvalidConfigException e) { |
| 365 | // TODO Auto-generated catch block |
| 366 | e.printStackTrace(); |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | //Insignificant Set Quality Improvement |
| 371 | if(getBooleanAttribute(DSEConstantsContainer.TC_INSIGNIFICANT_SET_IMPROVEMENT_ACTIVATE)){ |
| 372 | try { |
| 373 | InsignificantSetQualityImprovementConfig isqic = new InsignificantSetQualityImprovementConfig(); |
| 374 | isqic.setComparisionGenerations(configuration.getAttribute(DSEConstantsContainer.TC_INSIGNIFICANT_SET_IMPROVEMENT_GENERATION_X, 1)); |
| 375 | |
| 376 | String[] configuredObjectivesLines = getStringAttribute(DSEConstantsContainer.TC_INSIGNIFICANT_SET_IMPROVEMENT_CONFIGURED_OBJECTIVES).split(";"); |
| 377 | List<String[]> decodedLines = new LinkedList<String[]>(); |
| 378 | for(String item : configuredObjectivesLines){ |
| 379 | decodedLines.add(item.split("\\|")); |
| 380 | } |
| 381 | |
| 382 | List<UnresolvedValueDifference> unresolvedValueDifferences = new LinkedList<UnresolvedValueDifference>(); |
| 383 | |
| 384 | for(String[] singleLine : decodedLines){ |
| 385 | unresolvedValueDifferences.add(isqic.new UnresolvedValueDifference(singleLine[0], Double.parseDouble(singleLine[1])/100d, Double.parseDouble(singleLine[2])/100d)); |
| 386 | } |
| 387 | |
| 388 | isqic.setUnresolvedValueDifferences(unresolvedValueDifferences); |
| 389 | config.getTCConfigurations().add(isqic); |
| 390 | } catch (InvalidConfigException e) { |
| 391 | // TODO Auto-generated catch block |
| 392 | e.printStackTrace(); |
| 393 | } catch (NumberFormatException e) { |
| 394 | // TODO Auto-generated catch block |
| 395 | e.printStackTrace(); |
| 396 | } catch (Exception e) { |
| 397 | // TODO Auto-generated catch block |
| 398 | e.printStackTrace(); |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | //Insignificant Pareto Front Change |
| 403 | if(getBooleanAttribute(DSEConstantsContainer.TC_INSIGNIFICANT_FRONT_CHANGE_ACTIVATE)){ |
| 404 | try { |
| 405 | InsignificantParetoFrontChangeConfig ipfc = new InsignificantParetoFrontChangeConfig(); |
| 406 | ipfc.setPastIterationNumber(this.getIntegerAttribute(DSEConstantsContainer.TC_INSIGNIFICANT_FRONT_CHANGE_GENERATION_X)); |
| 407 | ipfc.setMinimumAllowedDifference(this.getIntegerAttribute(DSEConstantsContainer.TC_INSIGNIFICANT_FRONT_CHANGE_IMPROVEMENT)/100d); |
| 408 | config.getTCConfigurations().add(ipfc); |
| 409 | } catch (InvalidConfigException e) { |
| 410 | // TODO Auto-generated catch block |
| 411 | e.printStackTrace(); |
| 412 | } |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | } |
| 417 | |
| 418 | } |