1 | package de.uka.ipd.sdq.dsexplore.launch; |
2 | |
3 | import java.text.SimpleDateFormat; |
4 | import java.util.Calendar; |
5 | import java.util.Collections; |
6 | import java.util.LinkedList; |
7 | import java.util.List; |
8 | |
9 | import org.eclipse.core.runtime.CoreException; |
10 | import org.eclipse.debug.core.ILaunchConfiguration; |
11 | |
12 | import de.uka.ipd.sdq.dsexplore.analysis.IAnalysis; |
13 | import de.uka.ipd.sdq.tcfmoop.config.IConfiguration; |
14 | import de.uka.ipd.sdq.workflow.pcm.configurations.AbstractPCMWorkflowRunConfiguration; |
15 | |
16 | /** |
17 | * Configuration for a PerOpteryx run. |
18 | * |
19 | * Contains different types of information: |
20 | * <ul> |
21 | * <li>Inherits the PCM model information</li> |
22 | * <li>Contains information on the run, such as max iterations</li> |
23 | * <li>Contains the raw ILaunchConfiguration in order to derive SimuCom and |
24 | * PCMSolver configuration (TODO: refactor, make this a composite configuration |
25 | * and initialise the proper configurations earlier. Make the analysis extension |
26 | * provide access to the appropriate configuration builder.)</li> |
27 | * </ul> |
28 | * |
29 | * @author martens |
30 | * |
31 | */ |
32 | public class DSEWorkflowConfiguration extends |
33 | AbstractPCMWorkflowRunConfiguration { |
34 | |
35 | public enum SearchMethod{ |
36 | EVOLUTIONARY, |
37 | RANDOM, |
38 | RULE, |
39 | RULE_OPT |
40 | }; |
41 | |
42 | private ILaunchConfiguration rawConfiguration; |
43 | |
44 | private ILaunchConfiguration originalConfig; |
45 | |
46 | private List<IAnalysis> evaluators = Collections.emptyList(); |
47 | |
48 | private String decimalFormat = "0.#######"; |
49 | |
50 | /** |
51 | * A default to be overridden by the settings in the run dialog. |
52 | */ |
53 | private int maxIterations = Integer.MAX_VALUE; |
54 | private double mrtRequirements = 0; |
55 | private int individualsPerGeneration = 5; |
56 | private double crossoverRate = 0.5; |
57 | |
58 | private double maxCost = 0; |
59 | private double maxPOFOD = 0; |
60 | |
61 | private boolean newProblem; |
62 | private boolean optimise; |
63 | |
64 | private String designDecisionFileName; |
65 | private String resultFolder; |
66 | |
67 | private String configurationName; |
68 | |
69 | /** |
70 | * Settings for the termination criteria |
71 | */ |
72 | |
73 | private boolean useTerminationCriteria = false; |
74 | public void setUseTerminationCriteria(boolean useTerminationCriteria){ |
75 | this.useTerminationCriteria = useTerminationCriteria; |
76 | } |
77 | public boolean getUseTerminationCriteria(){ |
78 | return this.useTerminationCriteria; |
79 | } |
80 | |
81 | private boolean runInComparisionMode = false; |
82 | public void setRunInComparisionMode(boolean runInComparisionMode){ |
83 | this.runInComparisionMode = runInComparisionMode; |
84 | } |
85 | public boolean getRunInComparisionMode(){ |
86 | return this.runInComparisionMode; |
87 | } |
88 | |
89 | private boolean activateComposedTerminationCriteria = false; |
90 | public void setActivateComposedTerminationCriteria(boolean activateComposedTerminationCriteria){ |
91 | this.activateComposedTerminationCriteria = activateComposedTerminationCriteria; |
92 | } |
93 | public boolean getActivateComposedTerminationCriteria(){ |
94 | return this.activateComposedTerminationCriteria; |
95 | } |
96 | |
97 | private String composedCriteriaExpression = ""; |
98 | public void setComposedCriteriaExpression(String expression){ |
99 | this.composedCriteriaExpression = expression; |
100 | } |
101 | public String getComposedCriteriaExpression(){ |
102 | return this.composedCriteriaExpression; |
103 | } |
104 | |
105 | private List<IConfiguration> tcConfigurations = new LinkedList<IConfiguration>(); |
106 | public void setTCConfigurations(List<IConfiguration> tcConfigurations){ |
107 | this.tcConfigurations = tcConfigurations; |
108 | } |
109 | public List<IConfiguration> getTCConfigurations(){ |
110 | return this.tcConfigurations; |
111 | } |
112 | |
113 | |
114 | /** |
115 | * Setting for heuristics |
116 | */ |
117 | private boolean considerQMLBoundsWhenApplyingHeuristics; |
118 | private double tacticsProbability = DSEConstantsContainer.TACTICS_PROBABILITY_DEFAULT; |
119 | |
120 | private boolean useReallocation; |
121 | private double reallocationThresholdUtilisationDifference; |
122 | private double reallocationWeight; |
123 | |
124 | private boolean useProcessingRate; |
125 | private double processingRateThresholdLowUtilisation; |
126 | private double processingRateThresholdHighUtilisation; |
127 | private double processingRateDecreaseFactor; |
128 | private double processingRateIncreaseFactor; |
129 | private double processingRateWeight; |
130 | |
131 | private boolean useServerConsolidation; |
132 | private double serverConsolidationThresholdLowUtilisation; |
133 | private double serverConsolidationWeight; |
134 | |
135 | private boolean useServerExpansion; |
136 | private double serverExpansionThresholdHighUtilisation; |
137 | private int serverExpansionMaxNumberOfReplacements; |
138 | private double serverExpansionWeight; |
139 | |
140 | private int minNumberOfResourceContainers; |
141 | private int maxNumberOfResourceContainers; |
142 | private int numberOfCandidatesPerAllocationLevel; |
143 | |
144 | |
145 | |
146 | public final String startTimestamp; |
147 | |
148 | private SearchMethod searchMethod = SearchMethod.EVOLUTIONARY; |
149 | |
150 | |
151 | /* |
152 | * Starting population heuristic |
153 | */ |
154 | private boolean useStartingPopulationHeuristic; |
155 | |
156 | private boolean useLinkReallocationTactic; |
157 | |
158 | private boolean useAntipatternKnowledge; |
159 | |
160 | private boolean stopOnInitialFailure; |
161 | |
162 | private boolean resultsAsEMF; |
163 | |
164 | private boolean resultsAsCSV; |
165 | |
166 | private String predefinedInstancesFileName = ""; |
167 | private String cacheInstancesFileName = ""; |
168 | private String predefinedAllCandidatesFileName = ""; |
169 | private String archiveCandidateFileName = ""; |
170 | |
171 | |
172 | /** |
173 | * @return the useStartingPopulationHeuristic |
174 | */ |
175 | public boolean getUseStartingPopulationHeuristic() { |
176 | return useStartingPopulationHeuristic; |
177 | } |
178 | |
179 | /** |
180 | * @param useStartingPopulationHeuristic the useStartingPopulationHeuristic to set |
181 | */ |
182 | public void setUseStartingPopulationHeuristic(boolean useStartingPopulationHeuristic) { |
183 | this.useStartingPopulationHeuristic = useStartingPopulationHeuristic; |
184 | } |
185 | |
186 | /** |
187 | * @return the minNumberOfResourceContainers |
188 | */ |
189 | public int getMinNumberOfResourceContainers() { |
190 | return minNumberOfResourceContainers; |
191 | } |
192 | |
193 | /** |
194 | * @param minNumberOfResourceContainers the minNumberOfResourceContainers to set |
195 | */ |
196 | public void setMinNumberOfResourceContainers(int minNumberOfResourceContainers) { |
197 | this.minNumberOfResourceContainers = minNumberOfResourceContainers; |
198 | } |
199 | |
200 | /** |
201 | * @return the maxNumberOfResourceContainers |
202 | */ |
203 | public int getMaxNumberOfResourceContainers() { |
204 | return maxNumberOfResourceContainers; |
205 | } |
206 | |
207 | /** |
208 | * @param maxNumberOfResourceContainers the maxNumberOfResourceContainers to set |
209 | */ |
210 | public void setMaxNumberOfResourceContainers(int maxNumberOfResourceContainers) { |
211 | this.maxNumberOfResourceContainers = maxNumberOfResourceContainers; |
212 | } |
213 | |
214 | /** |
215 | * @return the numberOfCandidatesPerAllocationLevel |
216 | */ |
217 | public int getNumberOfCandidatesPerAllocationLevel() { |
218 | return numberOfCandidatesPerAllocationLevel; |
219 | } |
220 | |
221 | /** |
222 | * @param numberOfCandidatesPerAllocationLevel the numberOfCandidatesPerAllocationLevel to set |
223 | */ |
224 | public void setNumberOfCandidatesPerAllocationLevel(int numberOfCandidatesPerAllocationLevel) { |
225 | this.numberOfCandidatesPerAllocationLevel = numberOfCandidatesPerAllocationLevel; |
226 | } |
227 | |
228 | |
229 | public DSEWorkflowConfiguration() { |
230 | String DATE_FORMAT_NOW = "yyyy-MM-dd-HHmmss"; |
231 | Calendar cal = Calendar.getInstance(); |
232 | SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW); |
233 | this.startTimestamp = sdf.format(cal.getTime()); |
234 | } |
235 | |
236 | public String getDecimalFormat() { |
237 | return decimalFormat; |
238 | } |
239 | |
240 | public ILaunchConfiguration getOriginalConfig() { |
241 | return originalConfig; |
242 | } |
243 | |
244 | public void setOriginalConfig(ILaunchConfiguration originalConfig) { |
245 | this.originalConfig = originalConfig; |
246 | } |
247 | |
248 | public void setMaxIterations(int maxIterations) { |
249 | this.maxIterations = maxIterations; |
250 | } |
251 | |
252 | public void setMrtRequirements(double mrtRequirements) { |
253 | this.mrtRequirements = mrtRequirements; |
254 | } |
255 | |
256 | public void setIndividualsPerGeneration(int individualsPerGeneration) { |
257 | this.individualsPerGeneration = individualsPerGeneration; |
258 | } |
259 | |
260 | public void setMaxCost(double maxCost) { |
261 | this.maxCost = maxCost; |
262 | } |
263 | |
264 | public void setMaxPOFOD(double maxPOFOD) { |
265 | this.maxPOFOD = maxPOFOD; |
266 | } |
267 | |
268 | public void setNewProblem(boolean newProblem) { |
269 | this.newProblem = newProblem; |
270 | } |
271 | |
272 | public void setOptimise(boolean optimise) { |
273 | this.optimise = optimise; |
274 | } |
275 | |
276 | public void setDesignDecisionFileName(String designDecisionFileName) { |
277 | this.designDecisionFileName = designDecisionFileName; |
278 | } |
279 | |
280 | public void setConfigurationName(String configurationName) { |
281 | this.configurationName = configurationName; |
282 | } |
283 | |
284 | public int getMaxIterations() { |
285 | return maxIterations; |
286 | } |
287 | |
288 | public int getIndividualsPerGeneration() { |
289 | return individualsPerGeneration; |
290 | } |
291 | |
292 | public boolean isNewProblem() { |
293 | return newProblem; |
294 | } |
295 | |
296 | public boolean isOptimise() { |
297 | return optimise; |
298 | } |
299 | |
300 | public double getMrtRequirements() { |
301 | return mrtRequirements; |
302 | } |
303 | |
304 | |
305 | |
306 | public double getMaxCost() { |
307 | return maxCost; |
308 | } |
309 | |
310 | |
311 | |
312 | public double getMaxPOFOD() { |
313 | return maxPOFOD; |
314 | } |
315 | |
316 | @Override |
317 | public String getErrorMessage() { |
318 | return null; |
319 | } |
320 | |
321 | @Override |
322 | public void setDefaults() { |
323 | |
324 | } |
325 | |
326 | public ILaunchConfiguration getOriginalConfiguration(){ |
327 | return this.originalConfig; |
328 | } |
329 | |
330 | |
331 | |
332 | public boolean hasPredefinedInstances() throws CoreException { |
333 | return this.getPredefinedInstancesFileName() != "" |
334 | || this.getPredefinedAllCandidatesFileName() != "" |
335 | || this.getArchiveCandidateFileName() != "" ; |
336 | } |
337 | |
338 | public boolean isRandomSearch() { |
339 | return this.searchMethod == SearchMethod.RANDOM; |
340 | } |
341 | |
342 | public boolean isRuleBasedSearch() { |
343 | return |
344 | (this.searchMethod == SearchMethod.RULE |
345 | || this.searchMethod == SearchMethod.RULE_OPT); |
346 | } |
347 | |
348 | /** |
349 | * Returns whether the rule based search should explore the full search |
350 | * tree up to the depth given by the number of iterations. |
351 | * Otherwise, suboptimal candidates are pruned and not further |
352 | * explored per iteration. |
353 | * @return |
354 | */ |
355 | public boolean isFullRuleBasedSearch(){ |
356 | return this.searchMethod == SearchMethod.RULE; |
357 | } |
358 | |
359 | public String getPredefinedInstancesFileName() { |
360 | return this.predefinedInstancesFileName; |
361 | } |
362 | |
363 | public String getCacheInstancesFileName() { |
364 | return this.cacheInstancesFileName; |
365 | } |
366 | |
367 | public String getPredefinedAllCandidatesFileName() { |
368 | return this.predefinedAllCandidatesFileName; |
369 | } |
370 | |
371 | public String getArchiveCandidateFileName() { |
372 | return this.archiveCandidateFileName; |
373 | } |
374 | |
375 | public void setPredefinedInstancesFileName(String name) { |
376 | this.predefinedInstancesFileName = name; |
377 | } |
378 | |
379 | public void setCacheInstancesFileName(String name) { |
380 | this.cacheInstancesFileName = name; |
381 | } |
382 | |
383 | public void setPredefinedAllCandidatesFileName(String name) { |
384 | this.predefinedAllCandidatesFileName = name; |
385 | } |
386 | |
387 | public void setArchiveCandidateFileName(String name) { |
388 | this.archiveCandidateFileName = name; |
389 | } |
390 | |
391 | public boolean hasCacheInstances() throws CoreException { |
392 | return this.originalConfig.hasAttribute(DSEConstantsContainer.CACHE_INSTANCES) |
393 | && !this.originalConfig.getAttribute(DSEConstantsContainer.CACHE_INSTANCES, "").equals("") |
394 | ; |
395 | } |
396 | |
397 | public String getDesignDecisionFileName(){ |
398 | return this.designDecisionFileName; |
399 | } |
400 | |
401 | public void setRawConfig(ILaunchConfiguration configuration) { |
402 | this.rawConfiguration = configuration; |
403 | } |
404 | |
405 | public ILaunchConfiguration getRawConfiguration(){ |
406 | return rawConfiguration; |
407 | } |
408 | |
409 | public String getConfigurationName() { |
410 | return configurationName; |
411 | } |
412 | |
413 | /** |
414 | * @param resultFolder the resultFolder to set |
415 | */ |
416 | public void setResultFolder(String resultFolder) { |
417 | this.resultFolder = resultFolder; |
418 | } |
419 | |
420 | /** |
421 | * @return the resultFolder |
422 | */ |
423 | public String getResultFolder() { |
424 | return resultFolder; |
425 | } |
426 | |
427 | public double getCrossoverRate() { |
428 | return crossoverRate; |
429 | } |
430 | |
431 | public void setCrossoverRate(double crossoverRate) { |
432 | this.crossoverRate = crossoverRate; |
433 | } |
434 | |
435 | public boolean isConsiderQMLBoundsWhenApplyingHeuristics() { |
436 | return considerQMLBoundsWhenApplyingHeuristics; |
437 | } |
438 | |
439 | public void setConsiderQMLBoundsWhenApplyingHeuristics(boolean considerQMLBoundsWhenApplyingHeuristics) { |
440 | this.considerQMLBoundsWhenApplyingHeuristics = considerQMLBoundsWhenApplyingHeuristics; |
441 | } |
442 | |
443 | public void setTacticsProbability(double tacticsProbability) { |
444 | this.tacticsProbability = tacticsProbability; |
445 | } |
446 | |
447 | public double getTacticsProbability(){ |
448 | return this.tacticsProbability; |
449 | } |
450 | |
451 | public boolean getUseReallocation() { |
452 | return useReallocation; |
453 | } |
454 | |
455 | public void setUseReallocation(boolean useReallocation) { |
456 | this.useReallocation = useReallocation; |
457 | } |
458 | |
459 | public double getReallocationThresholdUtilisationDifference() { |
460 | return reallocationThresholdUtilisationDifference; |
461 | } |
462 | |
463 | public void setReallocationThresholdUtilisationDifference( |
464 | double reallocationThresholdUtilisationDifference) { |
465 | this.reallocationThresholdUtilisationDifference = reallocationThresholdUtilisationDifference; |
466 | } |
467 | |
468 | |
469 | public double getReallocationWeight() { |
470 | return reallocationWeight; |
471 | } |
472 | |
473 | public void setReallocationWeight(double reallocationWeight) { |
474 | this.reallocationWeight = reallocationWeight; |
475 | } |
476 | |
477 | public boolean getUseProcessingRate() { |
478 | return useProcessingRate; |
479 | } |
480 | |
481 | public void setUseProcessingRate(boolean useProcessingRate) { |
482 | this.useProcessingRate = useProcessingRate; |
483 | } |
484 | |
485 | public double getProcessingRateThresholdLowUtilisation() { |
486 | return processingRateThresholdLowUtilisation; |
487 | } |
488 | |
489 | public void setProcessingRateThresholdLowUtilisation( |
490 | double processingRateThresholdLowUtilisation) { |
491 | this.processingRateThresholdLowUtilisation = processingRateThresholdLowUtilisation; |
492 | } |
493 | |
494 | public double getProcessingRateThresholdHighUtilisation() { |
495 | return processingRateThresholdHighUtilisation; |
496 | } |
497 | |
498 | public void setProcessingRateThresholdHighUtilisation( |
499 | double processingRateThresholdHighUtilisation) { |
500 | this.processingRateThresholdHighUtilisation = processingRateThresholdHighUtilisation; |
501 | } |
502 | |
503 | public double getProcessingRateDecreaseFactor() { |
504 | return processingRateDecreaseFactor; |
505 | } |
506 | |
507 | public void setProcessingRateDecreaseFactor(double processingRateDecreaseFactor) { |
508 | this.processingRateDecreaseFactor = processingRateDecreaseFactor; |
509 | } |
510 | |
511 | public double getProcessingRateIncreaseFactor() { |
512 | return processingRateIncreaseFactor; |
513 | } |
514 | |
515 | public void setProcessingRateIncreaseFactor(double processingRateIncreaseFactor) { |
516 | this.processingRateIncreaseFactor = processingRateIncreaseFactor; |
517 | } |
518 | |
519 | public double getProcessingRateWeight() { |
520 | return processingRateWeight; |
521 | } |
522 | |
523 | public void setProcessingRateWeight(double processingRateWeight) { |
524 | this.processingRateWeight = processingRateWeight; |
525 | } |
526 | |
527 | public boolean getUseServerConsolidation() { |
528 | return useServerConsolidation; |
529 | } |
530 | |
531 | public void setUseServerConsolidation(boolean useServerConsolidation) { |
532 | this.useServerConsolidation = useServerConsolidation; |
533 | } |
534 | |
535 | public double getServerConsolidationThresholdLowUtilisation() { |
536 | return serverConsolidationThresholdLowUtilisation; |
537 | } |
538 | |
539 | public void setServerConsolidationThresholdLowUtilisation( |
540 | double serverConsolidationThresholdLowUtilisation) { |
541 | this.serverConsolidationThresholdLowUtilisation = serverConsolidationThresholdLowUtilisation; |
542 | } |
543 | |
544 | public double getServerConsolidationWeight() { |
545 | return serverConsolidationWeight; |
546 | } |
547 | |
548 | public void setServerConsolidationWeight(double serverConsolidationWeight) { |
549 | this.serverConsolidationWeight = serverConsolidationWeight; |
550 | } |
551 | |
552 | public boolean getUseServerExpansion() { |
553 | return useServerExpansion; |
554 | } |
555 | |
556 | public void setUseServerExpansion(boolean useServerExpansion) { |
557 | this.useServerExpansion = useServerExpansion; |
558 | } |
559 | |
560 | public double getServerExpansionThresholdHighUtilisation() { |
561 | return serverExpansionThresholdHighUtilisation; |
562 | } |
563 | |
564 | public void setServerExpansionThresholdHighUtilisation( |
565 | double serverExpansionThresholdHighUtilisation) { |
566 | this.serverExpansionThresholdHighUtilisation = serverExpansionThresholdHighUtilisation; |
567 | } |
568 | |
569 | public int getServerExpansionMaxNumberOfReplacements() { |
570 | return serverExpansionMaxNumberOfReplacements; |
571 | } |
572 | |
573 | public void setServerExpansionMaxNumberOfReplacements( |
574 | int serverExpansionMaxNumberOfReplacements) { |
575 | this.serverExpansionMaxNumberOfReplacements = serverExpansionMaxNumberOfReplacements; |
576 | } |
577 | |
578 | public double getServerExpansionWeight() { |
579 | return serverExpansionWeight; |
580 | } |
581 | |
582 | public void setServerExpansionWeight(double serverExpansionWeight) { |
583 | this.serverExpansionWeight = serverExpansionWeight; |
584 | } |
585 | |
586 | public void setSearchMethod(SearchMethod searchMethod) { |
587 | this.searchMethod = searchMethod; |
588 | |
589 | } |
590 | |
591 | public boolean isUseHeuristics() { |
592 | //return getUseProcessingRate() || getUseReallocation() || getUseServerConsolidation() || getUseServerExpansion() || getUseAntipatternKnowledge(); |
593 | return true; |
594 | } |
595 | |
596 | public void setEvaluators(List<IAnalysis> evaluators) { |
597 | this.evaluators = evaluators; |
598 | |
599 | } |
600 | |
601 | public List<IAnalysis> getEvaluators(){ |
602 | return this.evaluators; |
603 | } |
604 | |
605 | public boolean getUseLinkReallocationTactic() { |
606 | return this.useLinkReallocationTactic; |
607 | } |
608 | |
609 | public void setUseLinkReallocationTactic(boolean isUseLinkReallocationTactic){ |
610 | this.useLinkReallocationTactic = isUseLinkReallocationTactic; |
611 | } |
612 | |
613 | public boolean getUseAntipatternKnowledge() { |
614 | return this.useAntipatternKnowledge; |
615 | } |
616 | |
617 | public void setUseAntipatternKnowledge(boolean isUseAntipattern){ |
618 | this.useAntipatternKnowledge = isUseAntipattern; |
619 | } |
620 | public boolean isStopOnInitialFailure() { |
621 | return this.stopOnInitialFailure; |
622 | } |
623 | |
624 | public void setStopOnInitialFailure(boolean stop){ |
625 | this.stopOnInitialFailure = stop; |
626 | } |
627 | |
628 | public boolean isResultsAsEMF() { |
629 | return this.resultsAsEMF; |
630 | } |
631 | |
632 | public void setResultsAsEMF(boolean asEMF){ |
633 | this.resultsAsEMF = asEMF; |
634 | } |
635 | public boolean isResultsAsCSV() { |
636 | return this.resultsAsCSV; |
637 | } |
638 | |
639 | public void setResultsAsCSV(boolean resultsAsCVS){ |
640 | this.resultsAsCSV = resultsAsCVS; |
641 | } |
642 | |
643 | |
644 | } |