1 | package de.uka.ipd.sdq.dsexplore.launch; |
2 | |
3 | import org.eclipse.core.runtime.CoreException; |
4 | import org.eclipse.debug.core.ILaunchConfiguration; |
5 | import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; |
6 | import org.eclipse.debug.ui.ILaunchConfigurationTab; |
7 | import org.eclipse.swt.SWT; |
8 | import org.eclipse.swt.events.ModifyEvent; |
9 | import org.eclipse.swt.events.ModifyListener; |
10 | import org.eclipse.swt.events.SelectionEvent; |
11 | import org.eclipse.swt.events.SelectionListener; |
12 | import org.eclipse.swt.graphics.Image; |
13 | import org.eclipse.swt.layout.GridData; |
14 | import org.eclipse.swt.layout.GridLayout; |
15 | import org.eclipse.swt.widgets.Button; |
16 | import org.eclipse.swt.widgets.Combo; |
17 | import org.eclipse.swt.widgets.Composite; |
18 | import org.eclipse.swt.widgets.Group; |
19 | import org.eclipse.swt.widgets.Label; |
20 | import org.eclipse.swt.widgets.Text; |
21 | |
22 | import de.uka.ipd.sdq.dsexplore.DSEPluginActivator; |
23 | import de.uka.ipd.sdq.workflow.launchconfig.RunConfigPlugin; |
24 | import de.uka.ipd.sdq.workflow.launchconfig.tabs.TabHelper; |
25 | import de.uka.ipd.sdq.workflow.pcm.ConstantsContainer; |
26 | import de.uka.ipd.sdq.workflow.pcm.runconfig.FileNamesInputTab; |
27 | |
28 | public class DSEOptionsTab extends FileNamesInputTab { |
29 | |
30 | private Text maximumIterations; |
31 | |
32 | private Text numberOfIndividualsPerGeneration; |
33 | |
34 | private Image icon; |
35 | |
36 | //private Text meanResponseTimeRequirement; |
37 | |
38 | private Combo useHeuristics; |
39 | |
40 | private Text crossoverRate; |
41 | |
42 | //private Text maxCost; |
43 | |
44 | private Text textGivenInstances; |
45 | |
46 | private Button designDecisionsOnly; |
47 | |
48 | private Button optimisationOnly; |
49 | |
50 | private Text textDesignDecisionFile; |
51 | |
52 | //private Text textQMLDefinitionFile; |
53 | |
54 | private Text textCacheInstances; |
55 | private Text textAllInstances; |
56 | private Text textArchiveInstances; |
57 | |
58 | private Button stopOnInitialFailure; |
59 | |
60 | private Button outputAsEMF; |
61 | |
62 | /** |
63 | * Option to start a number of DSE runs on the same settings, to get several samples for the |
64 | * runs and be able to draw statistically valid conclusions. |
65 | */ |
66 | private Text numberOfDSERuns; |
67 | |
68 | |
69 | //private QMLManager qmlManager; |
70 | //private QMLDefinitionsLoadListener qmlDefinitionsLoadListener; |
71 | |
72 | // public DSEOptionsTab(FileNamesInputTab modelsTab, QMLManager qmlManager){ |
73 | // this.modelsTab = modelsTab; |
74 | // this.qmlManager = qmlManager; |
75 | // } |
76 | |
77 | @Override |
78 | public void createControl(Composite parent) { |
79 | final ModifyListener modifyListener = new ModifyListener() { |
80 | |
81 | public void modifyText(ModifyEvent e) { |
82 | DSEOptionsTab.this.setDirty(true); |
83 | DSEOptionsTab.this.updateLaunchConfigurationDialog(); |
84 | } |
85 | }; |
86 | |
87 | final SelectionListener selectionListener = new SelectionListener() { |
88 | |
89 | public void widgetDefaultSelected(SelectionEvent e) { |
90 | DSEOptionsTab.this.setDirty(true); |
91 | DSEOptionsTab.this.updateLaunchConfigurationDialog(); |
92 | } |
93 | |
94 | public void widgetSelected(SelectionEvent e) { |
95 | DSEOptionsTab.this.setDirty(true); |
96 | DSEOptionsTab.this.updateLaunchConfigurationDialog(); |
97 | } |
98 | }; |
99 | |
100 | this.container = new Composite(parent, SWT.NONE); |
101 | setControl(container); |
102 | container.setLayout(new GridLayout()); |
103 | |
104 | |
105 | // /** |
106 | // * Add QML input section |
107 | // */ |
108 | // this.textQMLDefinitionFile = new Text(container, SWT.SINGLE | SWT.BORDER); |
109 | // String[] qmlExtension = new String[1]; |
110 | // qmlExtension[0] = DSEConstantsContainer.QML_DEFINITION_EXTENSION; |
111 | // this.createFileInputSection(container, modifyListener, "QML Criteria Definitions", qmlExtension, textQMLDefinitionFile); |
112 | // final Button buttonQML = new Button(container, SWT.NONE); |
113 | // buttonQML.setText("Load QML..."); |
114 | // qmlDefinitionsLoadListener = new QMLDefinitionsLoadListener(textQMLDefinitionFile, modelsTab.getUsageModelFile(), qmlManager, modifyListener); |
115 | // buttonQML.addSelectionListener(qmlDefinitionsLoadListener); |
116 | |
117 | final Group maximumIterationsGroup = new Group(container, SWT.NONE); |
118 | final GridLayout glmaximumIterationsGroup = new GridLayout(); |
119 | glmaximumIterationsGroup.numColumns = 2; |
120 | maximumIterationsGroup.setLayout(glmaximumIterationsGroup); |
121 | maximumIterationsGroup.setText("Evolutionary algorithm parameters"); |
122 | maximumIterationsGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, |
123 | true, false)); |
124 | |
125 | final Label maxIterationLabel = new Label(maximumIterationsGroup, SWT.NONE); |
126 | maxIterationLabel.setText("Maximum number of iterations:"); |
127 | |
128 | maximumIterations = new Text(maximumIterationsGroup, SWT.SINGLE | SWT.BORDER); |
129 | maximumIterations.setEnabled(true); |
130 | maximumIterations.addModifyListener(modifyListener); |
131 | |
132 | final Label numberOfIndividualsPerGenerationLabel = new Label(maximumIterationsGroup, SWT.NONE); |
133 | numberOfIndividualsPerGenerationLabel.setText("Number of individuals per generation:"); |
134 | |
135 | numberOfIndividualsPerGeneration = new Text(maximumIterationsGroup, SWT.SINGLE | SWT.BORDER); |
136 | numberOfIndividualsPerGeneration.setEnabled(true); |
137 | numberOfIndividualsPerGeneration.addModifyListener(modifyListener); |
138 | |
139 | final Label crossoverRateLabel = new Label(maximumIterationsGroup, SWT.NONE); |
140 | crossoverRateLabel.setText("Crossover rate:"); |
141 | |
142 | crossoverRate = new Text(maximumIterationsGroup, SWT.SINGLE | SWT.BORDER); |
143 | crossoverRate.setEnabled(true); |
144 | crossoverRate.addModifyListener(modifyListener); |
145 | |
146 | // final Label meanRespTimeLabel = new Label(maximumIterationsGroup, SWT.NONE); |
147 | // meanRespTimeLabel.setText("Maximal response time:"); |
148 | |
149 | /* meanResponseTimeRequirement = new Text(maximumIterationsGroup, SWT.SINGLE | SWT.BORDER); |
150 | meanResponseTimeRequirement.setEnabled(true); |
151 | meanResponseTimeRequirement.addModifyListener(modifyListener); |
152 | */ |
153 | // final Label maxCostLabel = new Label(maximumIterationsGroup, SWT.NONE); |
154 | // maxCostLabel.setText("Maximal cost:"); |
155 | |
156 | // maxCost = new Text(maximumIterationsGroup, SWT.SINGLE | SWT.BORDER); |
157 | // maxCost.setEnabled(true); |
158 | // maxCost.addModifyListener(modifyListener); |
159 | |
160 | |
161 | useHeuristics = new Combo(container, SWT.READ_ONLY); |
162 | useHeuristics.setEnabled(true); |
163 | useHeuristics.setItems (new String [] { |
164 | DSEConstantsContainer.SEARCH_EVOLUTIONARY, |
165 | DSEConstantsContainer.SEARCH_RANDOM, |
166 | DSEConstantsContainer.SEARCH_RULE, |
167 | DSEConstantsContainer.SEARCH_RULE_OPT, |
168 | }); |
169 | useHeuristics.setSize (400, 200); |
170 | useHeuristics.addModifyListener(modifyListener); |
171 | useHeuristics.addSelectionListener(selectionListener); |
172 | |
173 | /** |
174 | * Add given instances input section |
175 | */ |
176 | this.textGivenInstances = new Text(container, SWT.SINGLE | SWT.BORDER); |
177 | TabHelper.createFileInputSection(container, modifyListener, "Start population or predefined candidates (optional), either .csv or .designdecision containing Candidates", DSEConstantsContainer.CANDIDATE_EXTENSION, textGivenInstances, getShell(), DSEConstantsContainer.DEFAULT_GIVEN_CANDIDATES_FILE); |
178 | |
179 | this.textCacheInstances = new Text(container, SWT.SINGLE | SWT.BORDER); |
180 | TabHelper.createFileInputSection(container, modifyListener, "Candidates for evaluation cache (optional, .csv)", DSEConstantsContainer.CSV_EXTENSION, textCacheInstances, getShell(), DSEConstantsContainer.DEFAULT_CACHED_CANDIDATES_FILE); |
181 | |
182 | this.textAllInstances = new Text(container, SWT.SINGLE | SWT.BORDER); |
183 | TabHelper.createFileInputSection(container, modifyListener, "All previous candidates (optional, .csv), will be included in allcandidates*.csv, and cache (optional). Not considered by the evolutionary algorithm.", DSEConstantsContainer.CSV_EXTENSION, textAllInstances, getShell(), DSEConstantsContainer.DEFAULT_ALL_CANDIDATES_FILE); |
184 | |
185 | this.textArchiveInstances = new Text(container, SWT.SINGLE | SWT.BORDER); |
186 | TabHelper.createFileInputSection(container, modifyListener, "Archive candidates (optional, .csv), will be included in the internal archive and archiveIndividuals.csv and cache (optional, .csv). Must be specified if an evolutionary search should be properly continued.", DSEConstantsContainer.CSV_EXTENSION, textArchiveInstances, getShell(), DSEConstantsContainer.DEFAULT_ARCHIVE_INSTANCES_FILE); |
187 | |
188 | final Group designDecisionOptions = new Group(container, SWT.NONE); |
189 | final GridLayout gldesignDecisionOptions = new GridLayout(); |
190 | gldesignDecisionOptions.numColumns = 2; |
191 | designDecisionOptions.setLayout(gldesignDecisionOptions); |
192 | designDecisionOptions.setText("Design decision options"); |
193 | designDecisionOptions.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, |
194 | true, false)); |
195 | |
196 | |
197 | // simulateFailuresButton = new Button(reliabilityGroup, SWT.CHECK); |
198 | // final GridData gd_simulateFailuresButton = new GridData(SWT.FILL, SWT.CENTER, true, false); |
199 | // simulateFailuresButton.setLayoutData(gd_simulateFailuresButton); |
200 | // simulateFailuresButton.setText("Simulate failures"); |
201 | // simulateFailuresButton.addSelectionListener(selectionListener); |
202 | |
203 | designDecisionsOnly = new Button(designDecisionOptions, SWT.CHECK); |
204 | designDecisionsOnly.setEnabled(true); |
205 | designDecisionsOnly.setText("Only determine design decisions, do not optimise"); |
206 | designDecisionsOnly.addSelectionListener(selectionListener); |
207 | |
208 | optimisationOnly = new Button(designDecisionOptions, SWT.CHECK); |
209 | optimisationOnly.setEnabled(true); |
210 | optimisationOnly.setText("Only optimise, using pre-existing design decisions"); |
211 | optimisationOnly.addSelectionListener(selectionListener); |
212 | |
213 | /** |
214 | * Add optional design decision input section |
215 | */ |
216 | this.textDesignDecisionFile = new Text(container, SWT.SINGLE | SWT.BORDER); |
217 | TabHelper.createFileInputSection(container, modifyListener, "Design Decision File", DSEConstantsContainer.DESIGNDECISION_EXTENSION, textDesignDecisionFile, getShell(), DSEConstantsContainer.DEFAULT_DESIGN_DECISION_FILE); |
218 | |
219 | //this.createHelpSection(); |
220 | final Group failureOptions = new Group(container, SWT.NONE); |
221 | final GridLayout glfailureOptions = new GridLayout(); |
222 | glfailureOptions.numColumns = 2; |
223 | failureOptions.setLayout(glfailureOptions); |
224 | failureOptions.setText("Failure handling options"); |
225 | failureOptions.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, |
226 | true, false)); |
227 | |
228 | stopOnInitialFailure = new Button(failureOptions, SWT.CHECK); |
229 | stopOnInitialFailure.setEnabled(true); |
230 | stopOnInitialFailure.setSelection(true); |
231 | stopOnInitialFailure.setText("Stop on initial failure"); |
232 | stopOnInitialFailure.addSelectionListener(selectionListener); |
233 | |
234 | final Group outputOptions = new Group(container, SWT.NONE); |
235 | final GridLayout gloutputOptions = new GridLayout(); |
236 | gloutputOptions.numColumns = 2; |
237 | outputOptions.setLayout(gloutputOptions); |
238 | outputOptions.setText("Output options"); |
239 | outputOptions.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, |
240 | true, false)); |
241 | |
242 | outputAsEMF = new Button(outputOptions, SWT.CHECK); |
243 | outputAsEMF.setEnabled(true); |
244 | outputAsEMF.setSelection(false); |
245 | outputAsEMF.setText("Output as EMF models"); |
246 | outputAsEMF.addSelectionListener(selectionListener); |
247 | |
248 | final Group dseIterationsGroups = new Group(container, SWT.NONE); |
249 | final GridLayout dseIterationsGroup = new GridLayout(); |
250 | dseIterationsGroup.numColumns = 2; |
251 | dseIterationsGroups.setLayout(dseIterationsGroup); |
252 | dseIterationsGroups.setText("Evolutionary algorithm parameters"); |
253 | dseIterationsGroups.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, |
254 | true, false)); |
255 | |
256 | final Label dseIterationsLabel = new Label(dseIterationsGroups, SWT.NONE); |
257 | dseIterationsLabel.setText("Number of DSE runs (optional, default is 1):"); |
258 | |
259 | numberOfDSERuns = new Text(dseIterationsGroups, SWT.SINGLE | SWT.BORDER); |
260 | numberOfDSERuns.setEnabled(true); |
261 | numberOfDSERuns.addModifyListener(modifyListener); |
262 | |
263 | } |
264 | |
265 | // protected void loadQML() { |
266 | // qmlManager.processQMLFile(textQMLDefinitionFile.getText(), modelsTab.getUsageModelFile().getText()); |
267 | // } |
268 | |
269 | //klappt nicht so |
270 | /*private void createHelpSection() { |
271 | final Group helpGroup = new Group(container, SWT.NONE); |
272 | final GridLayout glHelpLayout = new GridLayout(); |
273 | glHelpLayout.numColumns = 2; |
274 | helpGroup.setLayout(glHelpLayout); |
275 | helpGroup.setText("Design decision options"); |
276 | helpGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, |
277 | true, false)); |
278 | this.helpButton = new Button(helpGroup, SWT.NONE); |
279 | this.helpButton.setText("Help"); |
280 | this.helpButton.addSelectionListener(new SelectionListener() { |
281 | |
282 | @Override |
283 | public void widgetSelected(SelectionEvent e) { |
284 | PlatformUI.getWorkbench().getHelpSystem().displayHelp("de.uka.ipd.sdq.dsexplore.launchDSE"); |
285 | |
286 | } |
287 | |
288 | @Override |
289 | public void widgetDefaultSelected(SelectionEvent e) { |
290 | PlatformUI.getWorkbench().getHelpSystem().displayHelp("de.uka.ipd.sdq.dsexplore.launchDSE"); |
291 | |
292 | } |
293 | }); |
294 | PlatformUI.getWorkbench().getHelpSystem().setHelp(helpButton, "de.uka.ipd.sdq.dsexplore.launchDSE"); |
295 | } |
296 | |
297 | @Override |
298 | public String getName() { |
299 | return "DSE Options"; |
300 | }*/ |
301 | |
302 | /* (non-Javadoc) |
303 | * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#getImage() |
304 | */ |
305 | @Override |
306 | public Image getImage() { |
307 | if (icon == null){ |
308 | icon = DSEPluginActivator.getImageDescriptor("icons/dse_launch.gif").createImage(); |
309 | } |
310 | return icon; |
311 | } |
312 | |
313 | @Override |
314 | public void initializeFrom(ILaunchConfiguration configuration) { |
315 | |
316 | // try { |
317 | // this.textQMLDefinitionFile.setText(configuration.getAttribute( |
318 | // DSEConstantsContainer.QML_DEFINITION_FILE, "")); |
319 | // } catch (CoreException e) { |
320 | // RunConfigPlugin.errorLogger(getName(),DSEConstantsContainer.QML_DEFINITION_FILE, e.getMessage()); |
321 | // } |
322 | |
323 | try { |
324 | maximumIterations.setText(configuration.getAttribute( |
325 | DSEConstantsContainer.MAX_ITERATIONS, "")); |
326 | } catch (CoreException e) { |
327 | RunConfigPlugin.errorLogger(getName(),"maximum iterations", e.getMessage()); |
328 | } |
329 | try { |
330 | numberOfIndividualsPerGeneration.setText(configuration.getAttribute( |
331 | DSEConstantsContainer.INDIVIDUALS_PER_GENERATION, "")); |
332 | } catch (CoreException e) { |
333 | RunConfigPlugin.errorLogger(getName(),"numberOfIndividualsPerGeneration", e.getMessage()); |
334 | } |
335 | try { |
336 | crossoverRate.setText(configuration.getAttribute( |
337 | DSEConstantsContainer.CROSSOVER_RATE, "0.5")); |
338 | } catch (CoreException e) { |
339 | RunConfigPlugin.errorLogger(getName(),"numberOfIndividualsPerGeneration", e.getMessage()); |
340 | } |
341 | |
342 | try{ |
343 | String solverStr = configuration.getAttribute(DSEConstantsContainer.SEARCH_METHOD, |
344 | DSEConstantsContainer.SEARCH_EVOLUTIONARY); |
345 | String[] items = useHeuristics.getItems(); |
346 | for (int i=0; i<items.length; i++){ |
347 | String str = items[i]; |
348 | if (str.equals(solverStr)){ |
349 | useHeuristics.select(i); |
350 | } |
351 | } |
352 | } catch(CoreException e){ |
353 | useHeuristics.select(0); |
354 | } |
355 | |
356 | try { |
357 | this.textGivenInstances.setText(configuration.getAttribute( |
358 | DSEConstantsContainer.PREDEFINED_INSTANCES, "")); |
359 | } catch (CoreException e) { |
360 | RunConfigPlugin.errorLogger(getName(),DSEConstantsContainer.PREDEFINED_INSTANCES, e.getMessage()); |
361 | } |
362 | |
363 | try { |
364 | this.textCacheInstances.setText(configuration.getAttribute( |
365 | DSEConstantsContainer.CACHE_INSTANCES, "")); |
366 | } catch (CoreException e) { |
367 | RunConfigPlugin.errorLogger(getName(),DSEConstantsContainer.CACHE_INSTANCES, e.getMessage()); |
368 | } |
369 | |
370 | try { |
371 | this.textAllInstances.setText(configuration.getAttribute( |
372 | DSEConstantsContainer.ALL_CANDIDATES, "")); |
373 | } catch (CoreException e) { |
374 | RunConfigPlugin.errorLogger(getName(),DSEConstantsContainer.ALL_CANDIDATES, e.getMessage()); |
375 | } |
376 | |
377 | try { |
378 | this.textArchiveInstances.setText(configuration.getAttribute( |
379 | DSEConstantsContainer.ARCHIVE_CANDIDATES, "")); |
380 | } catch (CoreException e) { |
381 | RunConfigPlugin.errorLogger(getName(),DSEConstantsContainer.ARCHIVE_CANDIDATES, e.getMessage()); |
382 | } |
383 | |
384 | try { |
385 | this.designDecisionsOnly.setSelection(configuration.getAttribute( |
386 | DSEConstantsContainer.DESIGN_DECISIONS_ONLY, false)); |
387 | } catch (CoreException e) { |
388 | this.designDecisionsOnly.setSelection(false); |
389 | } |
390 | try { |
391 | this.optimisationOnly.setSelection(configuration.getAttribute( |
392 | DSEConstantsContainer.OPTIMISATION_ONLY, false)); |
393 | } catch (CoreException e) { |
394 | this.optimisationOnly.setSelection(false); |
395 | } |
396 | try { |
397 | this.textDesignDecisionFile.setText(configuration.getAttribute( |
398 | DSEConstantsContainer.DESIGN_DECISION_FILE, "")); |
399 | if ("".equals(this.textDesignDecisionFile.getText())){ |
400 | String fullName = getFullDefaultDesignDecisionName(configuration); |
401 | this.textDesignDecisionFile.setText(fullName); |
402 | } |
403 | } catch (CoreException e) { |
404 | RunConfigPlugin.errorLogger(getName(),DSEConstantsContainer.DESIGN_DECISION_FILE, e.getMessage()); |
405 | } |
406 | try { |
407 | this.stopOnInitialFailure.setSelection(configuration.getAttribute( |
408 | DSEConstantsContainer.STOP_ON_INITIAL_FAILURE, false)); |
409 | } catch (CoreException e) { |
410 | this.stopOnInitialFailure.setSelection(true); |
411 | } |
412 | try { |
413 | this.outputAsEMF.setSelection(configuration.getAttribute( |
414 | DSEConstantsContainer.STORE_RESULTS_AS_EMF, false)); |
415 | } catch (CoreException e) { |
416 | this.outputAsEMF.setSelection(false); |
417 | } |
418 | try { |
419 | numberOfDSERuns.setText(configuration.getAttribute( |
420 | DSEConstantsContainer.DSE_ITERATIONS, "")); |
421 | } catch (CoreException e) { |
422 | RunConfigPlugin.errorLogger(getName(),"number of DSE iterations", e.getMessage()); |
423 | } |
424 | //loadQML(); |
425 | } |
426 | |
427 | |
428 | |
429 | @Override |
430 | public void performApply(ILaunchConfigurationWorkingCopy configuration) { |
431 | //loadQML(); |
432 | |
433 | configuration.setAttribute( |
434 | DSEConstantsContainer.MAX_ITERATIONS, |
435 | this.maximumIterations.getText()); |
436 | configuration.setAttribute( |
437 | DSEConstantsContainer.INDIVIDUALS_PER_GENERATION, |
438 | this.numberOfIndividualsPerGeneration.getText()); |
439 | configuration.setAttribute( |
440 | DSEConstantsContainer.CROSSOVER_RATE, |
441 | this.crossoverRate.getText()); |
442 | // configuration.setAttribute( |
443 | // DSEConstantsContainer.MRT_REQUIREMENTS, |
444 | // this.meanResponseTimeRequirement.getText()); |
445 | // configuration.setAttribute( |
446 | // DSEConstantsContainer.MAX_COST, |
447 | // this.maxCost.getText()); |
448 | configuration.setAttribute( |
449 | DSEConstantsContainer.SEARCH_METHOD, |
450 | this.useHeuristics.getText()); |
451 | configuration.setAttribute( |
452 | DSEConstantsContainer.PREDEFINED_INSTANCES, |
453 | this.textGivenInstances.getText()); |
454 | configuration.setAttribute( |
455 | DSEConstantsContainer.CACHE_INSTANCES, |
456 | this.textCacheInstances.getText()); |
457 | configuration.setAttribute( |
458 | DSEConstantsContainer.ALL_CANDIDATES, |
459 | this.textAllInstances.getText()); |
460 | configuration.setAttribute( |
461 | DSEConstantsContainer.ARCHIVE_CANDIDATES, |
462 | this.textArchiveInstances.getText()); |
463 | configuration.setAttribute( |
464 | DSEConstantsContainer.DESIGN_DECISIONS_ONLY, |
465 | this.designDecisionsOnly.getSelection()); |
466 | configuration.setAttribute( |
467 | DSEConstantsContainer.OPTIMISATION_ONLY, |
468 | this.optimisationOnly.getSelection()); |
469 | configuration.setAttribute( |
470 | DSEConstantsContainer.DESIGN_DECISION_FILE, |
471 | this.textDesignDecisionFile.getText()); |
472 | // configuration.setAttribute( |
473 | // DSEConstantsContainer.QML_DEFINITION_FILE, |
474 | // this.textQMLDefinitionFile.getText()); |
475 | configuration.setAttribute( |
476 | DSEConstantsContainer.STOP_ON_INITIAL_FAILURE, |
477 | this.stopOnInitialFailure.getSelection()); |
478 | configuration.setAttribute( |
479 | DSEConstantsContainer.STORE_RESULTS_AS_EMF, |
480 | this.outputAsEMF.getSelection()); |
481 | configuration.setAttribute( |
482 | DSEConstantsContainer.DSE_ITERATIONS, |
483 | this.numberOfDSERuns.getText()); |
484 | } |
485 | |
486 | @Override |
487 | public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { |
488 | configuration.setAttribute( |
489 | DSEConstantsContainer.INDIVIDUALS_PER_GENERATION, |
490 | "3"); |
491 | configuration.setAttribute(DSEConstantsContainer.DESIGN_DECISIONS_ONLY, false); |
492 | configuration.setAttribute(DSEConstantsContainer.OPTIMISATION_ONLY, false); |
493 | configuration.setAttribute(DSEConstantsContainer.SEARCH_METHOD, DSEConstantsContainer.SEARCH_EVOLUTIONARY); |
494 | } |
495 | |
496 | /* (non-Javadoc) |
497 | * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration) |
498 | */ |
499 | @Override |
500 | public boolean isValid(ILaunchConfiguration launchConfig) { |
501 | setErrorMessage(null); |
502 | |
503 | // if(!qmlManager.isQMLLoaded()){ |
504 | // String errorMessage = "Select Usage Model and load QML Definition!"; |
505 | // if(qmlManager.getDiagnosis() != null) { |
506 | // errorMessage += " "+qmlManager.getDiagnosis(); |
507 | // } |
508 | // setErrorMessage(errorMessage); |
509 | // return false; |
510 | // } else if(qmlManager.getActivatedCriteria().size() < 1) { |
511 | // setErrorMessage("QML definition contains no objectives. Nothing to optimize!"); |
512 | // return false; |
513 | // } |
514 | |
515 | // check this.maxIterations |
516 | if (this.maximumIterations.getText().length() != 0) { |
517 | try { |
518 | Integer.parseInt(this.maximumIterations.getText()); |
519 | } catch (NumberFormatException e) { |
520 | setErrorMessage("Maximum iterations must be an integer value or empty."); |
521 | return false; |
522 | } |
523 | } |
524 | |
525 | // check this.numberOfIndividualsPerGeneration |
526 | if (this.numberOfIndividualsPerGeneration.getText().length() != 0) { |
527 | try { |
528 | Integer.parseInt(this.numberOfIndividualsPerGeneration.getText()); |
529 | } catch (NumberFormatException e) { |
530 | setErrorMessage("Number of individuals per generation must be an integer value or empty."); |
531 | return false; |
532 | } |
533 | } |
534 | |
535 | try { |
536 | Double.parseDouble(this.crossoverRate.getText()); |
537 | } catch (NumberFormatException e) { |
538 | setErrorMessage("Crossover rate must be a number."); |
539 | return false; |
540 | } |
541 | |
542 | |
543 | // if (this.meanResponseTimeRequirement.getText().length() != 0) { |
544 | // try { |
545 | // Double.parseDouble(this.meanResponseTimeRequirement.getText()); |
546 | // } catch (NumberFormatException e) { |
547 | // setErrorMessage("Mean response time requirement must be a double value or empty."); |
548 | // return false; |
549 | // } |
550 | // } |
551 | // |
552 | // if (this.maxCost.getText().length() != 0) { |
553 | // try { |
554 | // Double.parseDouble(this.maxCost.getText()); |
555 | // } catch (NumberFormatException e) { |
556 | // setErrorMessage("Maximal cost must be a double value or empty."); |
557 | // return false; |
558 | // } |
559 | // } |
560 | |
561 | if (this.designDecisionsOnly.getSelection() && this.optimisationOnly.getSelection()){ |
562 | setErrorMessage("You cannot choose both \"design decisions only\" and \"optimisation only\", as nothing remains to be done."); |
563 | return false; |
564 | } |
565 | |
566 | if ( this.textDesignDecisionFile.getText().length() > 0){ |
567 | //If something is written in the textDesignDecisionFile text, it must be a valid path. |
568 | if (!TabHelper.validateFilenameExtension(textDesignDecisionFile.getText(), |
569 | DSEConstantsContainer.DESIGNDECISION_EXTENSION)) { |
570 | setErrorMessage("Design decision file path is invalid: The file must have the correct extension."); |
571 | return false; |
572 | } |
573 | //Additionally, if the optimisation only button is not set, we inform the user that the |
574 | //specified file will be overwritten. |
575 | if (!this.optimisationOnly.getSelection()){ |
576 | setMessage("Note that your defined design decision file will be overwritten or created if it does not exist yet."); |
577 | } |
578 | } else if(this.optimisationOnly.getSelection()){ |
579 | //We need a design decision file if optimisation only is selected |
580 | setErrorMessage("You need to provide a design decision file to read the problem from."); |
581 | return false; |
582 | } else { |
583 | //Notify user about the default design decision file name. |
584 | setMessage("If you do not specify a design decision file, the default name will be <name of this launch configuration>.designdecision."); |
585 | } |
586 | |
587 | if (this.numberOfDSERuns.getText().length() != 0) { |
588 | try { |
589 | Integer.parseInt(this.numberOfDSERuns.getText()); |
590 | } catch (NumberFormatException e) { |
591 | setErrorMessage("Number of DSE iterations must be an integer value or empty."); |
592 | return false; |
593 | } |
594 | } |
595 | |
596 | //If rule-based search is selected, one should choose one of the tactics |
597 | if (this.useHeuristics.getText().equals(DSEConstantsContainer.SEARCH_RULE) |
598 | || this.useHeuristics.getText().equals(DSEConstantsContainer.SEARCH_RULE_OPT)){ |
599 | boolean noTacticsSelected = true; |
600 | try { |
601 | noTacticsSelected = |
602 | !launchConfig.getAttribute(DSEConstantsContainer.USE_PROCESSING_RATE, false) |
603 | && !launchConfig.getAttribute(DSEConstantsContainer.USE_REALLOCATION, false) |
604 | && !launchConfig.getAttribute(DSEConstantsContainer.USE_SERVER_CONSOLIDATION, false) |
605 | && !launchConfig.getAttribute(DSEConstantsContainer.USE_SERVER_EXPANSION, false) |
606 | && !launchConfig.getAttribute(DSEConstantsContainer.USE_ANTIPATTERNS, false); |
607 | } catch (CoreException e) { |
608 | //noTactics will stay true and the message will be written. |
609 | } |
610 | if (noTacticsSelected){ |
611 | setMessage("Make sure to select some tactics when choosing the rule-based search, otherwise nothing will happen."); |
612 | return false; |
613 | } |
614 | } |
615 | |
616 | return true; |
617 | } |
618 | |
619 | /** |
620 | * Disposes the image for the DSE options tab. |
621 | * |
622 | * @see ILaunchConfigurationTab#dispose() |
623 | */ |
624 | @Override |
625 | public void dispose() { |
626 | if (icon != null){ |
627 | icon.dispose(); |
628 | } |
629 | } |
630 | |
631 | @Override |
632 | public void activated(ILaunchConfigurationWorkingCopy workingCopy) { |
633 | // Leave this method empty to prevent unnecessary invocation of |
634 | // initializeFrom() and multiple resulting invocations of |
635 | // performApply(). |
636 | } |
637 | |
638 | @Override |
639 | public void deactivated(ILaunchConfigurationWorkingCopy workingCopy) {} |
640 | |
641 | /**returns the path including the last /*/ |
642 | private String getPathTo(String fileURL){ |
643 | int index = fileURL.lastIndexOf("\\"); |
644 | String folderPath = fileURL.substring(0, index+1); |
645 | return folderPath; |
646 | } |
647 | |
648 | private String getDefaultDesignDecisionFileName(ILaunchConfiguration configuration) throws CoreException { |
649 | String problemName = configuration.getName(); |
650 | return problemName+".designdecision"; |
651 | } |
652 | |
653 | private String getFullDefaultDesignDecisionName( |
654 | ILaunchConfiguration configuration) throws CoreException { |
655 | String allocFile = configuration.getAttribute(ConstantsContainer.ALLOCATION_FILE,""); |
656 | String path = getPathTo(allocFile); |
657 | String name = getDefaultDesignDecisionFileName(configuration); |
658 | String fullName = path+name; |
659 | return fullName; |
660 | } |
661 | |
662 | /* (non-Javadoc) |
663 | * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName() |
664 | */ |
665 | @Override |
666 | public String getName() { |
667 | return "DSE Options"; |
668 | } |
669 | |
670 | } |