$darkmode
DENOPTIM
GAParametersForm.java
Go to the documentation of this file.
1/*
2 * DENOPTIM
3 * Copyright (C) 2020 Marco Foscato <marco.foscato@uib.no>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as published
7 * by the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19package denoptim.gui;
20
21import java.awt.BasicStroke;
22import java.awt.BorderLayout;
23import java.awt.Color;
24import java.awt.Dimension;
25import java.awt.FlowLayout;
26import java.awt.Font;
27import java.awt.GridLayout;
28import java.awt.event.ActionEvent;
29import java.awt.event.ActionListener;
30import java.util.ArrayList;
31import java.util.HashMap;
32import java.util.Map;
33import java.util.concurrent.atomic.AtomicInteger;
34
35import javax.swing.BoxLayout;
36import javax.swing.ButtonGroup;
37import javax.swing.GroupLayout;
38import javax.swing.JButton;
39import javax.swing.JComboBox;
40import javax.swing.JLabel;
41import javax.swing.JOptionPane;
42import javax.swing.JPanel;
43import javax.swing.JRadioButton;
44import javax.swing.JScrollPane;
45import javax.swing.JSeparator;
46import javax.swing.JSpinner;
47import javax.swing.JTextField;
48import javax.swing.SpinnerNumberModel;
49import javax.swing.SwingConstants;
50import javax.swing.UIManager;
51import javax.swing.event.ChangeEvent;
52import javax.swing.event.ChangeListener;
53import javax.swing.event.DocumentEvent;
54import javax.swing.event.DocumentListener;
55import javax.swing.table.DefaultTableModel;
56
57import org.jfree.chart.ChartFactory;
58import org.jfree.chart.ChartPanel;
59import org.jfree.chart.JFreeChart;
60import org.jfree.chart.plot.PlotOrientation;
61import org.jfree.chart.plot.XYPlot;
62import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
63import org.jfree.data.xy.DefaultXYDataset;
64
65import denoptim.ga.EAUtils;
66import denoptim.programs.denovo.GAParameters;
67
68
73public class GAParametersForm extends ParametersForm
74{
75
79 private static final long serialVersionUID = 5067352357196631445L;
80
84 public static AtomicInteger gaFormUID = new AtomicInteger(1);
85
90 private Map<String,Object> mapKeyFieldToValueField;
91
92 JPanel block;
96
98 JRadioButton rdbSrcOrNew;
99
102 JTextField txtGASource;
103 JButton btnGASource;
105
106 String keyPar3 = "GA-RandomSeed";
107 JPanel linePar3;
108 JLabel lblPar3;
109 JTextField txtPar3;
110
111 String keyPar1 = "GA-PrecisionLevel";
112 JPanel linePar1;
113 JLabel lblPar1;
114 JTextField txtPar1;
115
116 String keyPar2 = "GA-Verbosity";
117 JPanel linePar2;
118 JLabel lblPar2;
119 JComboBox<String> cmbPar2;
120
121 String keyPar5 = "GA-SortByIncreasingFitness";
122 JPanel linePar5;
123 JRadioButton rdbPar5;
124
125 String keyPar6 = "GA-PopulationSize";
126 JPanel linePar6;
127 JLabel lblPar6;
128 JTextField txtPar6;
129
130 String keyPar7 = "GA-NumChildren";
131 JPanel linePar7;
132 JLabel lblPar7;
133 JTextField txtPar7;
134
135 String keyPar8 = "GA-NumGenerations";
136 JPanel linePar8;
137 JLabel lblPar8;
138 JTextField txtPar8;
139
140 String keyPar9 = "GA-NumConvGen";
141 JPanel linePar9;
142 JLabel lblPar9;
143 JTextField txtPar9;
144
145 String keyPar10 = "GA-MaxTriesPerPopulation";
146 JPanel linePar10;
147 JLabel lblPar10;
148 JTextField txtPar10;
149
152 JTextField txtMolToGraph;
154 String keyMolToGraph = "GA-InitMolsToFragmentFile";
155
158 JTextField txtFrgMols;
159 JButton btnFrgMols;
160 String keyFrgMols = "FRG-CuttingRulesFile";
161
162 JPanel lineAddH;
163 JLabel lblAddH;
164 JRadioButton rdbAddH;
165 String keyAddH = "FRG-AddExplicitHydrogen";
166
169 ButtonGroup bgGrowthMode;
170 JRadioButton rbtLevelGrowth;
171 JRadioButton rbtMolSzGrowth;
172
173 DefaultXYDataset molSizeProbData;
178 Double minMolSizeProbPlot = 1.0;
179 Double maxMolSizeProbPlot = 50.0;
180
181 String keyParMolSz1 = "GA-MolGrowthProbScheme";
184 JComboBox<ProbabilityFuncitonShape> cmbParMolSz1;
185
186 String keyParMolSz2 = "GA-MolGrowthMultiplier";
189 JSpinner spnParMolSz2;
190
191 String keyParMolSz3 = "GA-MolGrowthSigmaSteepness";
194 JSpinner spnParMolSz3;
195
196 String keyParMolSz4 = "GA-MolGrowthSigmaMiddle";
199 JSpinner spnParMolSz4;
200
205
206 DefaultXYDataset levelProbData;
211 Double minLevelProbPlot = 0.0;
212 Double maxLevelProbPlot = 5.0;
213
214 String keyPar11 = "GA-LevelGrowthProbScheme";
215 JPanel linePar11;
216 JLabel lblPar11;
217 JComboBox<ProbabilityFuncitonShape> cmbPar11;
218
219 String keyPar12 = "GA-LevelGrowthMultiplier";
220 JPanel linePar12;
221 JLabel lblPar12;
222 JSpinner spnPar12;
223
224 String keyPar13 = "GA-LevelGrowthSigmaSteepness";
225 JPanel linePar13;
226 JLabel lblPar13;
227 JSpinner spnPar13;
228
229 String keyPar14 = "GA-LevelGrowthSigmaMiddle";
230 JPanel linePar14;
231 JLabel lblPar14;
232 JSpinner spnPar14;
233
238
239 DefaultXYDataset crowdProbData;
246
250
251 String keyParCrowd1 = "GA-CrowdProbScheme";
254 JComboBox<ProbabilityFuncitonShape> cmbParCrowd1;
255
256 String keyParCrowd2 = "GA-CrowdMultiplier";
259 JSpinner spnParCrowd2;
260
261 String keyParCrowd3 = "GA-CrowdSigmaSteepness";
264 JSpinner spnParCrowd3;
265
266 String keyParCrowd4 = "GA-CrowdSigmaMiddle";
269 JSpinner spnParCrowd4;
270
271 String keyPar15 = "GA-XOverSelectionMode";
272 JPanel linePar15;
273 JLabel lblPar15;
274 JComboBox<String> cmbPar15;
275
276 String keyPar16 = "GA-CrossoverWeight";
277 JPanel linePar16;
278 JLabel lblPar16;
279 JTextField txtPar16;
280
281 String keyPar17 = "GA-MutationWeight";
282 JPanel linePar17;
283 JLabel lblPar17;
284 JTextField txtPar17;
285
286 String keyParMSM = "GA-MultiSiteMutationWeights";
288 JLabel lblParMSM;
289 JTextField txtParMSM;
290
291 String keyParWC = "GA-ConstructionWeight";
292 JPanel lineParWC;
293 JLabel lblParWC;
294 JTextField txtParWC;
295
296 String keyPar18 = "GA-SymmetryProbability";
297 JPanel linePar18;
298 JLabel lblPar18;
299 JTextField txtPar18;
300
301 String keyPar19 = "GA-ReplacementStrategy";
302 JPanel linePar19;
303 JLabel lblPar19;
304 JComboBox<String> cmbPar19;
305
306 String keyPar20 = "GA-InitPoplnFile";
307 JPanel linePar20;
308 JLabel lblPar20;
309 JTextField txtPar20;
310 JButton btnPar20;
311
312 String keyPar21 = "GA-UIDFileIn";
313 JPanel linePar21;
314 JLabel lblPar21;
315 JTextField txtPar21;
316 JButton btnPar21;
317
318 String keyPar22 = "GA-UIDFileOut";
319 JPanel linePar22;
320 JLabel lblPar22;
321 JTextField txtPar22;
322 JButton btnPar22;
323
324 String keyPar24 = "GA-NumParallelTasks";
325 JPanel linePar24;
326 JLabel lblPar24;
327 JTextField txtPar24;
328
329 String keyPar25 = "GA-Parallelization";
330 JPanel linePar25;
331 JLabel lblPar25;
332 JComboBox<String> cmbPar25;
333
334 String keyRingTmplsFrags = "GA-KeepNewRingSystemVertexes";
336 JRadioButton rdbRingTmplsFrags;
337
338 String keyRingTmplsScaff = "GA-KeepNewRingSystemScaffolds";
340 JRadioButton rdbRingTmplsScaff;
341
342 String keyRingSysTmplTrhld = "GA-KeepNewRingSystemFitnessTrsh";
346
351 SIGMA, UNRESTRICTED};
352
353 //HEREGOFIELDS this is only to facilitate automated insertion of code
354
355
356 String NL = System.getProperty("line.separator");
357
358 public GAParametersForm(Dimension d)
359 {
360 mapKeyFieldToValueField = new HashMap<String,Object>();
361
362 this.setLayout(new BorderLayout()); //Needed to allow dynamic resizing!
363
364 block = new JPanel();
365 JScrollPane scrollablePane = new JScrollPane(block);
366 block.setLayout(new BoxLayout(block, SwingConstants.VERTICAL));
367
368 localBlock1 = new JPanel();
369 localBlock1.setVisible(false);
370 localBlock1.setLayout(new BoxLayout(localBlock1,
371 SwingConstants.VERTICAL));
372
373 localBlock2 = new JPanel();
374 localBlock2.setVisible(true);
375 localBlock2.setLayout(new BoxLayout(localBlock2,
376 SwingConstants.VERTICAL));
377
378 localBlockMolSz3 = new JPanel();
379 localBlockMolSz3.setVisible(false);
380 localBlockMolSz3.setLayout(new BoxLayout(localBlockMolSz3,
381 SwingConstants.VERTICAL));
382
383 localBlockMolSz4 = new JPanel();
384 localBlockMolSz4.setVisible(true);
385 localBlockMolSz4.setLayout(new BoxLayout(localBlockMolSz4,
386 SwingConstants.VERTICAL));
387
388 localBlockMolSzGraph = new JPanel();
389 localBlockMolSzGraph.setVisible(true);
390 localBlockMolSzAll = new JPanel();
391 localBlockMolSzAll.setVisible(false);
392 localBlockMolSzAll.setLayout(new BoxLayout(localBlockMolSzAll,
393 SwingConstants.VERTICAL));
394
395 localBlockLvlProb3 = new JPanel();
396 localBlockLvlProb3.setVisible(true);
397 localBlockLvlProb3.setLayout(new BoxLayout(localBlockLvlProb3,
398 SwingConstants.VERTICAL));
399
400 localBlockLvlProb4 = new JPanel();
401 localBlockLvlProb4.setVisible(false);
402 localBlockLvlProb4.setLayout(new BoxLayout(localBlockLvlProb4,
403 SwingConstants.VERTICAL));
404
405 localBlockLvlProbGraph = new JPanel();
406 localBlockLvlProbGraph.setVisible(true);
407 localBlockLvlProbAll = new JPanel();
408 localBlockLvlProbAll.setVisible(true);
409 localBlockLvlProbAll.setLayout(new BoxLayout(localBlockLvlProbAll,
410 SwingConstants.VERTICAL));
411
412 localBlockCrowd3 = new JPanel();
413 localBlockCrowd3.setVisible(false);
414 localBlockCrowd3.setLayout(new BoxLayout(localBlockCrowd3,
415 SwingConstants.VERTICAL));
416
417 localBlockCrowd4 = new JPanel();
418 localBlockCrowd4.setVisible(false);
419 localBlockCrowd4.setLayout(new BoxLayout(localBlockCrowd4,
420 SwingConstants.VERTICAL));
421
422 localBlockCrowdGraph = new JPanel();
423 localBlockCrowdGraph.setVisible(false);
424
425 advOptsBlock = new JPanel();
426 advOptsBlock.setVisible(false);
427 advOptsBlock.setLayout(new BoxLayout(advOptsBlock,
428 SwingConstants.VERTICAL));
429
430 String toolTipSrcOrNew = "Tick here to use settings from file.";
431 lineSrcOrNew = new JPanel(new FlowLayout(FlowLayout.LEFT));
432 rdbSrcOrNew = new JRadioButton("Use parameters from existing file");
433 rdbSrcOrNew.setToolTipText(toolTipSrcOrNew);
434 rdbSrcOrNew.addActionListener(new ActionListener(){
435 public void actionPerformed(ActionEvent e){
436 if (rdbSrcOrNew.isSelected())
437 {
438 localBlock1.setVisible(true);
439 localBlock2.setVisible(false);
440 }
441 else
442 {
443 localBlock1.setVisible(false);
444 localBlock2.setVisible(true);
445 }
446 }
447 });
449 block.add(lineSrcOrNew);
450 block.add(localBlock1);
451 block.add(localBlock2);
452
453 String toolTipGASource = "<html>Pathname of a DENOPTIM's parameter file with GA settings.</html>";
454 lineGASource = new JPanel(new FlowLayout(FlowLayout.LEFT));
455 lblGASource = new JLabel("Use parameters from file:", SwingConstants.LEFT);
456 lblGASource.setToolTipText(toolTipGASource);
457 txtGASource = new JTextField();
458 txtGASource.setToolTipText(toolTipGASource);
459 txtGASource.setPreferredSize(fileFieldSize);
460 btnGASource = new JButton("Browse");
461 btnGASource.addActionListener(new ActionListener() {
462 public void actionPerformed(ActionEvent e) {
465 }
466 });
467 btnLoadGASource = new JButton("Load...");
468 txtGASource.setToolTipText("<html>Specify the file containing the "
469 + "parameters to be loaded in this form.</html>");
470 btnLoadGASource.addActionListener(new ActionListener() {
471 public void actionPerformed(ActionEvent e) {
472 try
473 {
475 }
476 catch (Exception e1)
477 {
478 if (e1.getMessage().equals("") || e1.getMessage() == null)
479 {
480 e1.printStackTrace();
481 JOptionPane.showMessageDialog(btnLoadGASource,
482 "<html>Exception occurred while importing parameters.<br>Please, report this to the DENOPTIM team.</html>",
483 "Error",
484 JOptionPane.ERROR_MESSAGE,
485 UIManager.getIcon("OptionPane.errorIcon"));
486 }
487 else
488 {
489 JOptionPane.showMessageDialog(btnLoadGASource,
490 e1.getMessage(),
491 "Error",
492 JOptionPane.ERROR_MESSAGE,
493 UIManager.getIcon("OptionPane.errorIcon"));
494 }
495 return;
496 }
497 }
498 });
504
505 //HEREGOESIMPLEMENTATION this is only to facilitate automated insertion of code
506
507 String toolTipPar6 = "Specifies the number of individuals in the population.";
508 linePar6 = new JPanel(new FlowLayout(FlowLayout.LEFT));
509 lblPar6 = new JLabel("Size of population:", SwingConstants.LEFT);
510 lblPar6.setPreferredSize(fileLabelSize);
511 lblPar6.setToolTipText(toolTipPar6);
512 txtPar6 = new JTextField();
513 txtPar6.setToolTipText(toolTipPar6);
514 txtPar6.setPreferredSize(strFieldSize);
515 txtPar6.getDocument().addDocumentListener(fieldListener);
516 mapKeyFieldToValueField.put(keyPar6.toUpperCase(),txtPar6);
517 linePar6.add(lblPar6);
518 linePar6.add(txtPar6);
520
521 String toolTipPar7 = "Specifies the number of children to be generated for each generation.";
522 linePar7 = new JPanel(new FlowLayout(FlowLayout.LEFT));
523 lblPar7 = new JLabel("No. offsprings per generation:", SwingConstants.LEFT);
524 lblPar7.setPreferredSize(fileLabelSize);
525 lblPar7.setToolTipText(toolTipPar7);
526 txtPar7 = new JTextField();
527 txtPar7.setToolTipText(toolTipPar7);
528 txtPar7.setPreferredSize(strFieldSize);
529 txtPar7.getDocument().addDocumentListener(fieldListener);
530 mapKeyFieldToValueField.put(keyPar7.toUpperCase(),txtPar7);
531 linePar7.add(lblPar7);
532 linePar7.add(txtPar7);
534
535 String toolTipPar8 = "Specifies the maximum number of generation.";
536 linePar8 = new JPanel(new FlowLayout(FlowLayout.LEFT));
537 lblPar8 = new JLabel("Max. number of generations:", SwingConstants.LEFT);
538 lblPar8.setPreferredSize(fileLabelSize);
539 lblPar8.setToolTipText(toolTipPar8);
540 txtPar8 = new JTextField();
541 txtPar8.setToolTipText(toolTipPar8);
542 txtPar8.setPreferredSize(strFieldSize);
543 txtPar8.getDocument().addDocumentListener(fieldListener);
544 mapKeyFieldToValueField.put(keyPar8.toUpperCase(),txtPar8);
545 linePar8.add(lblPar8);
546 linePar8.add(txtPar8);
548
549 String toolTipPar9 = "Specifies the convergence criterion as number of subsequent identical generations.";
550 linePar9 = new JPanel(new FlowLayout(FlowLayout.LEFT));
551 lblPar9 = new JLabel("Max. stagnating generations:", SwingConstants.LEFT);
552 lblPar9.setPreferredSize(fileLabelSize);
553 lblPar9.setToolTipText(toolTipPar9);
554 txtPar9 = new JTextField();
555 txtPar9.setToolTipText(toolTipPar9);
556 txtPar9.setPreferredSize(strFieldSize);
557 txtPar9.getDocument().addDocumentListener(fieldListener);
558 mapKeyFieldToValueField.put(keyPar9.toUpperCase(),txtPar9);
559 linePar9.add(lblPar9);
560 linePar9.add(txtPar9);
562
563 localBlock2.add(new JSeparator());
564
565 lineGrowthPropMode = new JPanel(new FlowLayout(FlowLayout.LEFT));
566 lblGrowthPropMode = new JLabel("Graph growth controlled by: ");
567 bgGrowthMode = new ButtonGroup();
568 rbtLevelGrowth = new JRadioButton("graph deepness (level)");
569 rbtLevelGrowth.setSelected(true);
570 rbtLevelGrowth.addActionListener(new ActionListener(){
571 public void actionPerformed(ActionEvent e){
572 if (rbtLevelGrowth.isSelected())
573 {
574 localBlockLvlProbAll.setVisible(true);
575 localBlockMolSzAll.setVisible(false);
576 }
577 }
578 });
579 rbtLevelGrowth.addChangeListener(rdbFieldChange);
580 rbtMolSzGrowth = new JRadioButton("molecular size (heavy atoms count)");
581 rbtMolSzGrowth.addActionListener(new ActionListener(){
582 public void actionPerformed(ActionEvent e){
583 if (rbtMolSzGrowth.isSelected())
584 {
585 localBlockLvlProbAll.setVisible(false);
586 localBlockMolSzAll.setVisible(true);
587 }
588 }
589 });
590 rbtMolSzGrowth.addChangeListener(rdbFieldChange);
597
598 String toolTipPar12 = "<html>Specifies the value of the factor used in"
599 + " growth probability schemes <code>"
600 + ProbabilityFuncitonShape.EXP_DIFF + "</code> and "
601 + "<code>"
602 + ProbabilityFuncitonShape.TANH + "</code></html>";
603 linePar12 = new JPanel(new FlowLayout(FlowLayout.LEFT));
604 lblPar12 = new JLabel("<html>Graph growth by level - parameter "
605 + "<code>&lambda;</code><html>", SwingConstants.LEFT);
606 lblPar12.setPreferredSize(fileLabelSize);
607 lblPar12.setToolTipText(toolTipPar12);
608 spnPar12 = new JSpinner(new SpinnerNumberModel(1.0, 0.0, null, 0.1));
609 spnPar12.setToolTipText(toolTipPar12);
610 spnPar12.setPreferredSize(strFieldSize);
611 mapKeyFieldToValueField.put(keyPar12.toUpperCase(),spnPar12);
612 linePar12.add(lblPar12);
613 linePar12.add(spnPar12);
615
616 String toolTipPar13 = "<html>Specifies the value of parameter "
617 + "&sigma;<sub>1</sub> used for growth probability scheme"
618 + " <code>"
619 + ProbabilityFuncitonShape.SIGMA
620 + "</code>.<br>It corresponds to the steepness of"
621 + " the function where <i>P(level) = 50%</i></html>";
622 linePar13 = new JPanel(new FlowLayout(FlowLayout.LEFT));
623 lblPar13 = new JLabel("<html>Graph growth by level - parameter "
624 + "<code>&sigma;</code><sub>1</sub>:</html>",
625 SwingConstants.LEFT);
626 lblPar13.setPreferredSize(fileLabelSize);
627 lblPar13.setToolTipText(toolTipPar13);
628 spnPar13 = new JSpinner(new SpinnerNumberModel(1.0, null, null, 0.1));
629 spnPar13.setToolTipText(toolTipPar13);
630 spnPar13.setPreferredSize(strFieldSize);
631 mapKeyFieldToValueField.put(keyPar13.toUpperCase(),spnPar13);
632 linePar13.add(lblPar13);
633 linePar13.add(spnPar13);
635
636 String toolTipPar14 = "<html>Specifies the value of parameter "
637 + "&sigma;<sub>2</sub> used in growth probability scheme "
638 + "<code>"
639 + ProbabilityFuncitonShape.SIGMA
640 + "</code>.<br>It corresponds to the level "
641 + "where <i>P(level) = 50%</i></html>";
642 linePar14 = new JPanel(new FlowLayout(FlowLayout.LEFT));
643 lblPar14 = new JLabel("<html>Graph growth by level - parameter "
644 + "<code>&sigma;</code><sub>2</sub>:<html>",
645 SwingConstants.LEFT);
646 lblPar14.setPreferredSize(fileLabelSize);
647 lblPar14.setToolTipText(toolTipPar14);
648 spnPar14 = new JSpinner(new SpinnerNumberModel(3.5, null, null, 0.1));
649 spnPar14.setToolTipText(toolTipPar14);
650 spnPar14.setPreferredSize(strFieldSize);
651 mapKeyFieldToValueField.put(keyPar14.toUpperCase(),spnPar14);
652 linePar14.add(lblPar14);
653 linePar14.add(spnPar14);
655
656 String toolTipPar11 = "Specifies the growth probability scheme";
657 linePar11 = new JPanel(new FlowLayout(FlowLayout.LEFT));
658 lblPar11 = new JLabel("Graph extension probability function:",
659 SwingConstants.LEFT);
660 lblPar11.setPreferredSize(fileLabelSize);
661 lblPar11.setToolTipText(toolTipPar11);
662 cmbPar11 = new JComboBox<ProbabilityFuncitonShape>(
663 ProbabilityFuncitonShape.values());
665 cmbPar11.setToolTipText(toolTipPar11);
666 cmbPar11.addActionListener(cmbFieldChange);
667 mapKeyFieldToValueField.put(keyPar11.toUpperCase(),cmbPar11);
668
669 // NB: we need to create the graph before setting the action listeners
670 // that will eventually edit the data plotted.
672
673 graphLvlProbJFChartCtrlPanel = new JPanel(new BorderLayout());
674 graphLvlProbJFChartCtrlPanel.setMaximumSize(new Dimension(100,100));
675 graphLvlProbSpinnerPane = new JPanel(new GridLayout(0,2));
676 final JSpinner spnMaxLev = new JSpinner(new SpinnerNumberModel(
677 maxLevelProbPlot.intValue(), 1, null, 1));
678 spnMaxLev.addChangeListener(new ChangeListener()
679 {
680 @Override
681 public void stateChanged(ChangeEvent event)
682 {
683 int maxLev = ((Integer) spnMaxLev.getValue()).intValue();
684 ((XYPlot) graphLvlProbJFChart.getPlot())
685 .getDomainAxis().setRange(minLevelProbPlot, maxLev);
686 }
687 });
688 graphLvlProbSpinnerPane.add(new JLabel("X-axis max: "));
689 graphLvlProbSpinnerPane.add(spnMaxLev);
691
692 GroupLayout grpLyoSubPrb = new GroupLayout(localBlockLvlProbGraph);
693 localBlockLvlProbGraph.setLayout(grpLyoSubPrb);
694 grpLyoSubPrb.setAutoCreateGaps(true);
695 grpLyoSubPrb.setAutoCreateContainerGaps(true);
696 grpLyoSubPrb.setHorizontalGroup(grpLyoSubPrb.createSequentialGroup()
697 .addComponent(graphLvlProbJFChartChartPanel)
698 .addComponent(graphLvlProbJFChartCtrlPanel));
699 grpLyoSubPrb.setVerticalGroup(grpLyoSubPrb.createParallelGroup(
700 GroupLayout.Alignment.CENTER)
701 .addComponent(graphLvlProbJFChartChartPanel)
702 .addComponent(graphLvlProbJFChartCtrlPanel));
703
704 // NB: The listeners must be defined here because we first have to
705 // built all the pieces (plot + parameters) and then define how
706 // things change upon change of the parameters/controllers.
707
708 spnPar12.addChangeListener(new ChangeListener()
709 {
710 public void stateChanged(ChangeEvent event)
711 {
713 }
714 });
715 spnPar13.addChangeListener(new ChangeListener()
716 {
717 public void stateChanged(ChangeEvent event)
718 {
720 }
721 });
722 spnPar14.addChangeListener(new ChangeListener()
723 {
724 public void stateChanged(ChangeEvent event)
725 {
727 }
728 });
729
730 cmbPar11.addActionListener(new ActionListener(){
731 public void actionPerformed(ActionEvent e){
732 switch (ProbabilityFuncitonShape.valueOf(
733 cmbPar11.getSelectedItem().toString()))
734 {
735 case EXP_DIFF:
737 localBlockLvlProb3.setVisible(true);
738 localBlockLvlProb4.setVisible(false);
739 localBlockLvlProbGraph.setVisible(true);
740 break;
741
742 case TANH:
744 localBlockLvlProb3.setVisible(true);
745 localBlockLvlProb4.setVisible(false);
746 localBlockLvlProbGraph.setVisible(true);
747 break;
748
749 case SIGMA:
751 localBlockLvlProb3.setVisible(false);
752 localBlockLvlProb4.setVisible(true);
753 localBlockLvlProbGraph.setVisible(true);
754 break;
755
756 default:
757 localBlockLvlProb3.setVisible(false);
758 localBlockLvlProb4.setVisible(false);
759 localBlockLvlProbGraph.setVisible(false);
760 break;
761 }
762 }
763 });
764 linePar11.add(lblPar11);
765 linePar11.add(cmbPar11);
771
772 String toolTipParMolSz2 = "<html>Specifies the value of the factor used in"
773 + " molecular growth probability schemes <code>"
774 + ProbabilityFuncitonShape.EXP_DIFF + "</code> and "
775 + "<code>"
776 + ProbabilityFuncitonShape.TANH + "</code></html>";
777 lineParMolSz2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
778 lblParMolSz2 = new JLabel("<html>Mol growth probability - parameter "
779 + "<code>&lambda;</code><html>", SwingConstants.LEFT);
780 lblParMolSz2.setPreferredSize(fileLabelSize);
781 lblParMolSz2.setToolTipText(toolTipParMolSz2);
782 spnParMolSz2 = new JSpinner(new SpinnerNumberModel(1.0, 0.0, null, 0.1));
783 spnParMolSz2.setToolTipText(toolTipParMolSz2);
784 spnParMolSz2.setPreferredSize(strFieldSize);
789
790 String toolTipParMolSz3 = "<html>Specifies the value of parameter "
791 + "&sigma;<sub>1</sub> used for molecular growth probability "
792 + "scheme"
793 + " <code>"
794 + ProbabilityFuncitonShape.SIGMA
795 + "</code>.<br>It corresponds to the steepness of"
796 + " the function where <i>P(level) = 50%</i></html>";
797 lineParMolSz3 = new JPanel(new FlowLayout(FlowLayout.LEFT));
798 lblParMolSz3 = new JLabel("<html>Mol growth probability - parameter "
799 + "<code>&sigma;</code><sub>1</sub>:</html>", SwingConstants.LEFT);
800 lblParMolSz3.setPreferredSize(fileLabelSize);
801 lblParMolSz3.setToolTipText(toolTipParMolSz3);
802 spnParMolSz3 = new JSpinner(new SpinnerNumberModel(0.2, null, null, 0.1));
803 spnParMolSz3.setToolTipText(toolTipParMolSz3);
804 spnParMolSz3.setPreferredSize(strFieldSize);
809
810 String toolTipParMolSz4 = "<html>Specifies the value of parameter "
811 + "&sigma;<sub>2</sub> used in molecular growth probability "
812 + "scheme "
813 + "<code>"
814 + ProbabilityFuncitonShape.SIGMA
815 + "</code>.<br>It corresponds to the level "
816 + "where <i>P(level) = 50%</i></html>";
817 lineParMolSz4 = new JPanel(new FlowLayout(FlowLayout.LEFT));
818 lblParMolSz4 = new JLabel("<html>Mol growth probability - parameter "
819 + "<code>&sigma;</code><sub>2</sub>:<html>", SwingConstants.LEFT);
820 lblParMolSz4.setPreferredSize(fileLabelSize);
821 lblParMolSz4.setToolTipText(toolTipParMolSz4);
822 spnParMolSz4 = new JSpinner(new SpinnerNumberModel(25.0, null, null, 1.0));
823 spnParMolSz4.setToolTipText(toolTipParMolSz4);
824 spnParMolSz4.setPreferredSize(strFieldSize);
829
830 String toolTipParMolSz1 = "Specifies the molecular growth probability scheme";
831 lineParMolSz1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
832 lblParMolSz1 = new JLabel("Mol growth probability function:",
833 SwingConstants.LEFT);
834 lblParMolSz1.setPreferredSize(fileLabelSize);
835 lblParMolSz1.setToolTipText(toolTipParMolSz1);
836 cmbParMolSz1 = new JComboBox<ProbabilityFuncitonShape>(
837 ProbabilityFuncitonShape.values());
839 cmbParMolSz1.setToolTipText(toolTipParMolSz1);
840 cmbParMolSz1.addActionListener(cmbFieldChange);
842
843 // NB: we need to create the graph before setting the action listeners
844 // that will eventually edit the data plotted.
846
847 graphMolSzProbJFChartCtrlPanel = new JPanel(new BorderLayout());
848 graphMolSzProbJFChartCtrlPanel.setMaximumSize(new Dimension(100,100));
849 graphMolSzProbSpinnerPane = new JPanel(new GridLayout(0,2));
850 final JSpinner spnMaxLevMolSz = new JSpinner(new SpinnerNumberModel(
851 maxMolSizeProbPlot.intValue(), 1, null, 1));
852 spnMaxLevMolSz.addChangeListener(new ChangeListener()
853 {
854 @Override
855 public void stateChanged(ChangeEvent event)
856 {
857 int maxLev = ((Integer) spnMaxLevMolSz.getValue()).intValue();
858 ((XYPlot) graphMolSzProbJFChart.getPlot())
859 .getDomainAxis().setRange(minMolSizeProbPlot, maxLev);
860 }
861 });
862 graphMolSzProbSpinnerPane.add(new JLabel("X-axis max: "));
863 graphMolSzProbSpinnerPane.add(spnMaxLevMolSz);
865
866 GroupLayout grpLyoMolSzProb = new GroupLayout(localBlockMolSzGraph);
867 localBlockMolSzGraph.setLayout(grpLyoMolSzProb);
868 grpLyoMolSzProb.setAutoCreateGaps(true);
869 grpLyoMolSzProb.setAutoCreateContainerGaps(true);
870 grpLyoMolSzProb.setHorizontalGroup(grpLyoMolSzProb.createSequentialGroup()
872 .addComponent(graphMolSzProbJFChartCtrlPanel));
873 grpLyoMolSzProb.setVerticalGroup(grpLyoMolSzProb.createParallelGroup(
874 GroupLayout.Alignment.CENTER)
876 .addComponent(graphMolSzProbJFChartCtrlPanel));
877
878 // NB: The listeners must be defined here because we first have to
879 // built all the pieces (plot + parameters) and then define how
880 // things change upon change of the parameters/controllers.
881
882 spnParMolSz2.addChangeListener(new ChangeListener()
883 {
884 public void stateChanged(ChangeEvent event)
885 {
887 }
888 });
889 spnParMolSz3.addChangeListener(new ChangeListener()
890 {
891 public void stateChanged(ChangeEvent event)
892 {
894 }
895 });
896 spnParMolSz4.addChangeListener(new ChangeListener()
897 {
898 public void stateChanged(ChangeEvent event)
899 {
901 }
902 });
903
904 cmbParMolSz1.addActionListener(new ActionListener(){
905 public void actionPerformed(ActionEvent e){
906 switch (ProbabilityFuncitonShape.valueOf(
907 cmbParMolSz1.getSelectedItem().toString()))
908 {
909 case EXP_DIFF:
911 localBlockMolSz3.setVisible(true);
912 localBlockMolSz4.setVisible(false);
913 localBlockMolSzGraph.setVisible(true);
914 break;
915
916 case TANH:
918 localBlockMolSz3.setVisible(true);
919 localBlockMolSz4.setVisible(false);
920 localBlockMolSzGraph.setVisible(true);
921 break;
922
923 case SIGMA:
925 localBlockMolSz3.setVisible(false);
926 localBlockMolSz4.setVisible(true);
927 localBlockMolSzGraph.setVisible(true);
928 break;
929
930 case UNRESTRICTED:
932 localBlockMolSz3.setVisible(false);
933 localBlockMolSz4.setVisible(false);
934 localBlockMolSzGraph.setVisible(true);
935 break;
936
937 default:
938 localBlockMolSz3.setVisible(false);
939 localBlockMolSz4.setVisible(false);
940 localBlockMolSzGraph.setVisible(false);
941 break;
942 }
943 }
944 });
951
953
954 localBlock2.add(new JSeparator());
955
956 String toolTipParCrowd2 = "<html>Specifies the value of the factor used in"
957 + " crowding probability schemes <code>"
958 + ProbabilityFuncitonShape.EXP_DIFF
959 + "</code> and "
960 + "<code>"
961 + ProbabilityFuncitonShape.TANH
962 + "</code></html>";
963 lineParCrowd2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
964 lblParCrowd2 = new JLabel("<html>Crowding probability - parameter "
965 + "<code>&lambda;</code><html>", SwingConstants.LEFT);
966 lblParCrowd2.setPreferredSize(fileLabelSize);
967 lblParCrowd2.setToolTipText(toolTipParCrowd2);
968 spnParCrowd2 = new JSpinner(new SpinnerNumberModel(1.0, 0.0, null, 0.1));
969 spnParCrowd2.setToolTipText(toolTipParCrowd2);
970 spnParCrowd2.setPreferredSize(strFieldSize);
975
976 String toolTipParCrowd3 = "<html>Specifies the value of parameter "
977 + "&sigma;<sub>1</sub> used for crowding probability scheme"
978 + " <code>"
979 + ProbabilityFuncitonShape.SIGMA
980 + "</code>.<br>It corresponds to the steepness of"
981 + " the function where <i>P(level) = 50%</i></html>";
982 lineParCrowd3 = new JPanel(new FlowLayout(FlowLayout.LEFT));
983 lblParCrowd3 = new JLabel("<html>Crowding probability - parameter "
984 + "<code>&sigma;</code><sub>1</sub>:</html>", SwingConstants.LEFT);
985 lblParCrowd3.setPreferredSize(fileLabelSize);
986 lblParCrowd3.setToolTipText(toolTipParCrowd3);
987 spnParCrowd3 = new JSpinner(new SpinnerNumberModel(1.0, null, null, 0.1));
988 spnParCrowd3.setToolTipText(toolTipParCrowd3);
989 spnParCrowd3.setPreferredSize(strFieldSize);
994
995 String toolTipParCrowd4 = "<html>Specifies the value of parameter "
996 + "&sigma;<sub>2</sub> used in crowding probability scheme "
997 + "<code>"
998 + ProbabilityFuncitonShape.SIGMA
999 + "</code>.<br>It corresponds to the level "
1000 + "where <i>P(level) = 50%</i></html>";
1001 lineParCrowd4 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1002 lblParCrowd4 = new JLabel("<html>Crowding probability - parameter "
1003 + "<code>&sigma;</code><sub>2</sub>:<html>", SwingConstants.LEFT);
1004 lblParCrowd4.setPreferredSize(fileLabelSize);
1005 lblParCrowd4.setToolTipText(toolTipParCrowd4);
1006 spnParCrowd4 = new JSpinner(new SpinnerNumberModel(3.5, null, null, 0.1));
1007 spnParCrowd4.setToolTipText(toolTipParCrowd4);
1008 spnParCrowd4.setPreferredSize(strFieldSize);
1013
1014 String toolTipParCrowd1 = "Specifies the crowding probability scheme";
1015 lineParCrowd1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1016 lblParCrowd1 = new JLabel("Crowding probability function:",
1017 SwingConstants.LEFT);
1018 lblParCrowd1.setPreferredSize(fileLabelSize);
1019 lblParCrowd1.setToolTipText(toolTipParCrowd1);
1020 cmbParCrowd1 = new JComboBox<ProbabilityFuncitonShape>(
1021 ProbabilityFuncitonShape.values());
1023 cmbParCrowd1.setToolTipText(toolTipParCrowd1);
1024 cmbParCrowd1.addActionListener(cmbFieldChange);
1026
1027 // NB: we need to create the graph before setting the action listeners
1028 // that will eventually edit the data plotted.
1030
1031 graphCrowdProbJFChartCtrlPanel = new JPanel(new BorderLayout());
1032 graphCrowdProbJFChartCtrlPanel.setMaximumSize(new Dimension(100,100));
1033 graphCrowdProbSpinnerPane = new JPanel(new GridLayout(0,2));
1034 final JSpinner spnMaxLevCrowd = new JSpinner(new SpinnerNumberModel(
1035 maxLevelCrowdProbPlot.intValue(), 1, null, 1));
1036 spnMaxLevCrowd.addChangeListener(new ChangeListener()
1037 {
1038 @Override
1039 public void stateChanged(ChangeEvent event)
1040 {
1041 int maxLev = ((Integer) spnMaxLevCrowd.getValue()).intValue();
1042 ((XYPlot) graphCrowdProbJFChart.getPlot())
1043 .getDomainAxis().setRange(minLevelCrowdProbPlot, maxLev);
1044 }
1045 });
1046 graphCrowdProbSpinnerPane.add(new JLabel("X-axis max: "));
1047 graphCrowdProbSpinnerPane.add(spnMaxLevCrowd);
1049
1050 GroupLayout grpLyoCrowdProb = new GroupLayout(localBlockCrowdGraph);
1051 localBlockCrowdGraph.setLayout(grpLyoCrowdProb);
1052 grpLyoCrowdProb.setAutoCreateGaps(true);
1053 grpLyoCrowdProb.setAutoCreateContainerGaps(true);
1054 grpLyoCrowdProb.setHorizontalGroup(grpLyoCrowdProb.createSequentialGroup()
1055 .addComponent(graphCrowdProbJFChartChartPanel)
1056 .addComponent(graphCrowdProbJFChartCtrlPanel));
1057 grpLyoCrowdProb.setVerticalGroup(grpLyoCrowdProb.createParallelGroup(
1058 GroupLayout.Alignment.CENTER)
1059 .addComponent(graphCrowdProbJFChartChartPanel)
1060 .addComponent(graphCrowdProbJFChartCtrlPanel));
1061
1062 // NB: The listeners must be defined here because we first have to
1063 // built all the pieces (plot + parameters) and then define how
1064 // things change upon change of the parameters/controllers.
1065
1066 spnParCrowd2.addChangeListener(new ChangeListener()
1067 {
1068 public void stateChanged(ChangeEvent event)
1069 {
1071 }
1072 });
1073 spnParCrowd3.addChangeListener(new ChangeListener()
1074 {
1075 public void stateChanged(ChangeEvent event)
1076 {
1078 }
1079 });
1080 spnParCrowd4.addChangeListener(new ChangeListener()
1081 {
1082 public void stateChanged(ChangeEvent event)
1083 {
1085 }
1086 });
1087
1088 cmbParCrowd1.addActionListener(new ActionListener(){
1089 public void actionPerformed(ActionEvent e){
1090 String scheme = cmbParCrowd1.getSelectedItem().toString();
1091 switch (ProbabilityFuncitonShape.valueOf(scheme))
1092 {
1093 case EXP_DIFF:
1095 localBlockCrowd3.setVisible(true);
1096 localBlockCrowd4.setVisible(false);
1097 localBlockCrowdGraph.setVisible(true);
1098 break;
1099
1100 case TANH:
1102 localBlockCrowd3.setVisible(true);
1103 localBlockCrowd4.setVisible(false);
1104 localBlockCrowdGraph.setVisible(true);
1105 break;
1106
1107 case SIGMA:
1109 localBlockCrowd3.setVisible(false);
1110 localBlockCrowd4.setVisible(true);
1111 localBlockCrowdGraph.setVisible(true);
1112 break;
1113
1114 case UNRESTRICTED:
1116 localBlockCrowd3.setVisible(false);
1117 localBlockCrowd4.setVisible(false);
1118 localBlockCrowdGraph.setVisible(true);
1119 break;
1120
1121 default:
1122 localBlockCrowd3.setVisible(false);
1123 localBlockCrowd4.setVisible(false);
1124 localBlockCrowdGraph.setVisible(false);
1125 break;
1126 }
1127 }
1128 });
1135
1136 localBlock2.add(new JSeparator());
1137
1138 String toolTipPar15 = "<html>Specifies the strategy for selecting crossover partners.<ul>"
1139 + "<li><code>RANDOM</code>: unbiased selection.</li>"
1140 + "<li><code>TS</code>: Tournament.</li>"
1141 + "<li><code>RW</code>: Roulette Wheel.</li>"
1142 + "<li><code>SUS</code>: Stochastic Universal Sampling.</li>"
1143 + "</ul></html>";
1144 linePar15 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1145 lblPar15 = new JLabel("Parent selection algorithm:", SwingConstants.LEFT);
1146 lblPar15.setPreferredSize(fileLabelSize);
1147 lblPar15.setToolTipText(toolTipPar15);
1148 cmbPar15 = new JComboBox<String>(new String[] {"RANDOM", "TS", "RW", "SUS"});
1149 cmbPar15.setToolTipText(toolTipPar15);
1150 cmbPar15.addActionListener(cmbFieldChange);
1151 mapKeyFieldToValueField.put(keyPar15.toUpperCase(),cmbPar15);
1152 linePar15.add(lblPar15);
1153 linePar15.add(cmbPar15);
1155
1156 String toolTipPar16 = "<html>Specifies the relative weight of "
1157 + "crossover operations.</html>";
1158 linePar16 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1159 lblPar16 = new JLabel("Crossover weight:", SwingConstants.LEFT);
1160 lblPar16.setPreferredSize(fileLabelSize);
1161 lblPar16.setToolTipText(toolTipPar16);
1162 txtPar16 = new JTextField();
1163 txtPar16.setToolTipText(toolTipPar16);
1164 txtPar16.setPreferredSize(strFieldSize);
1165 txtPar16.getDocument().addDocumentListener(fieldListener);
1166 mapKeyFieldToValueField.put(keyPar16.toUpperCase(),txtPar16);
1167 linePar16.add(lblPar16);
1168 linePar16.add(txtPar16);
1170
1171 String toolTipPar17 = "<html>Specifies the relative weight of "
1172 + "mutation operations.</html>";
1173 linePar17 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1174 lblPar17 = new JLabel("Mutation weight:", SwingConstants.LEFT);
1175 lblPar17.setPreferredSize(fileLabelSize);
1176 lblPar17.setToolTipText(toolTipPar17);
1177 txtPar17 = new JTextField();
1178 txtPar17.setToolTipText(toolTipPar17);
1179 txtPar17.setPreferredSize(strFieldSize);
1180 txtPar17.getDocument().addDocumentListener(fieldListener);
1181 mapKeyFieldToValueField.put(keyPar17.toUpperCase(),txtPar17);
1182 linePar17.add(lblPar17);
1183 linePar17.add(txtPar17);
1185
1186 String toolTipParWC = "<html>Specifies the relative weight of "
1187 + "construction from scratch.</html>";
1188 lineParWC = new JPanel(new FlowLayout(FlowLayout.LEFT));
1189 lblParWC = new JLabel("Construction weight:", SwingConstants.LEFT);
1190 lblParWC.setPreferredSize(fileLabelSize);
1191 lblParWC.setToolTipText(toolTipParWC);
1192 txtParWC = new JTextField();
1193 txtParWC.setToolTipText(toolTipParWC);
1194 txtParWC.setPreferredSize(strFieldSize);
1195 txtParWC.getDocument().addDocumentListener(fieldListener);
1196 mapKeyFieldToValueField.put(keyParWC.toUpperCase(),txtParWC);
1197 lineParWC.add(lblParWC);
1198 lineParWC.add(txtParWC);
1200
1201 String toolTipPar18 = "Specifies the probability (0.0-1.0) of symmetric operations.";
1202 linePar18 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1203 lblPar18 = new JLabel("Symmetric operation probability:", SwingConstants.LEFT);
1204 lblPar18.setPreferredSize(fileLabelSize);
1205 lblPar18.setToolTipText(toolTipPar18);
1206 txtPar18 = new JTextField();
1207 txtPar18.setToolTipText(toolTipPar18);
1208 txtPar18.setPreferredSize(strFieldSize);
1209 txtPar18.getDocument().addDocumentListener(fieldListener);
1210 mapKeyFieldToValueField.put(keyPar18.toUpperCase(),txtPar18);
1211 linePar18.add(lblPar18);
1212 linePar18.add(txtPar18);
1214
1215 String toolTipPar19 = "Specifies the population members replacement strategy.";
1216 linePar19 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1217 lblPar19 = new JLabel("Population update mode:", SwingConstants.LEFT);
1218 lblPar19.setPreferredSize(fileLabelSize);
1219 lblPar19.setToolTipText(toolTipPar19);
1220 cmbPar19 = new JComboBox<String>(new String[] {"ELITIST", "NONE"});
1221 cmbPar19.setToolTipText(toolTipPar19);
1222 cmbPar19.addActionListener(cmbFieldChange);
1223 mapKeyFieldToValueField.put(keyPar19.toUpperCase(),cmbPar19);
1224 linePar19.add(lblPar19);
1225 linePar19.add(cmbPar19);
1227
1228 String toolTipPar24 = "Specifies the maximum number of parallel candidate evaluation tasks.";
1229 linePar24 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1230 lblPar24 = new JLabel("Number of parallel evaluation tasks:", SwingConstants.LEFT);
1231 lblPar24.setPreferredSize(fileLabelSize);
1232 lblPar24.setToolTipText(toolTipPar24);
1233 txtPar24 = new JTextField();
1234 txtPar24.setToolTipText(toolTipPar24);
1235 txtPar24.setPreferredSize(strFieldSize);
1236 txtPar24.getDocument().addDocumentListener(fieldListener);
1237 mapKeyFieldToValueField.put(keyPar24.toUpperCase(),txtPar24);
1238 linePar24.add(lblPar24);
1239 linePar24.add(txtPar24);
1241
1242 String toolTipPar25 = "<html>Specifies the parallelization scheme:<br><ul><li><code>synchronous</code>, i.e., parallel tasks are submitted in batches, thus no new task is submitted until the last of the previous tasks is completed.</li><li><code>asynchronous</code>, i.e., a new parallel tasks is submitted as soon as any of the previous task is completed.</li></ul></html>";
1243 linePar25 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1244 lblPar25 = new JLabel("Task parallelization scheme:", SwingConstants.LEFT);
1245 lblPar25.setPreferredSize(fileLabelSize);
1246 lblPar25.setToolTipText(toolTipPar25);
1247 cmbPar25 = new JComboBox<String>(new String[] {"Synchronous", "Asynchronous"});
1248 cmbPar25.setToolTipText(toolTipPar25);
1249 cmbPar25.addActionListener(cmbFieldChange);
1250 mapKeyFieldToValueField.put(keyPar25.toUpperCase(),cmbPar25);
1251 linePar25.add(lblPar25);
1252 linePar25.add(cmbPar25);
1254
1255 // From here it's all about advanced options
1256
1257 String toolTipParMSM = "<html>Specifies the relative weight of "
1258 + "multi-site mutation operations "
1259 + "(comma- or space-separated list).</html>";
1260 lineParMSM = new JPanel(new FlowLayout(FlowLayout.LEFT));
1261 lblParMSM = new JLabel("Multi-site mutation weight:", SwingConstants.LEFT);
1262 lblParMSM.setPreferredSize(fileLabelSize);
1263 lblParMSM.setToolTipText(toolTipParMSM);
1264 txtParMSM = new JTextField();
1265 txtParMSM.setToolTipText(toolTipParMSM);
1266 txtParMSM.setPreferredSize(strFieldSize);
1267 txtParMSM.getDocument().addDocumentListener(fieldListener);
1268 mapKeyFieldToValueField.put(keyParMSM.toUpperCase(),txtParMSM);
1269 lineParMSM.add(lblParMSM);
1270 lineParMSM.add(txtParMSM);
1272
1273 String toolTipPar3 = "Specifies the seed number used by the random number generator";
1274 linePar3 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1275 lblPar3 = new JLabel("Random Seed:", SwingConstants.LEFT);
1276 lblPar3.setPreferredSize(fileLabelSize);
1277 lblPar3.setToolTipText(toolTipPar3);
1278 txtPar3 = new JTextField();
1279 txtPar3.setToolTipText(toolTipPar3);
1280 txtPar3.setPreferredSize(new Dimension(150,preferredHeight));
1281 txtPar3.getDocument().addDocumentListener(fieldListener);
1282 mapKeyFieldToValueField.put(keyPar3.toUpperCase(),txtPar3);
1283 linePar3.add(lblPar3);
1284 linePar3.add(txtPar3);
1286
1287 String toolTipPar1 = "Specifies the number of figures used to report the fitness";
1288 linePar1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1289 lblPar1 = new JLabel("Precision of fitness value:", SwingConstants.LEFT);
1290 lblPar1.setPreferredSize(fileLabelSize);
1291 lblPar1.setToolTipText(toolTipPar1);
1292 txtPar1 = new JTextField();
1293 txtPar1.setToolTipText(toolTipPar1);
1294 txtPar1.setPreferredSize(strFieldSize);
1295 txtPar1.getDocument().addDocumentListener(fieldListener);
1296 mapKeyFieldToValueField.put(keyPar1.toUpperCase(),txtPar1);
1297 linePar1.add(lblPar1);
1298 linePar1.add(txtPar1);
1300
1301 String toolTipPar2 = "Specifies the amount of log produced.";
1302 linePar2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1303 lblPar2 = new JLabel("Verbosity of GA modules:", SwingConstants.LEFT);
1304 lblPar2.setPreferredSize(fileLabelSize);
1305 lblPar2.setToolTipText(toolTipPar2);
1306 cmbPar2 = new JComboBox<String>(new String[] {"-3", "-2", "-1", "0", "1", "2", "3"});
1307 cmbPar2.setToolTipText(toolTipPar2);
1308 cmbPar2.setSelectedItem("0");
1309 cmbPar2.addActionListener(cmbFieldChange);
1310 mapKeyFieldToValueField.put(keyPar2.toUpperCase(),cmbPar2);
1311 linePar2.add(lblPar2);
1312 linePar2.add(cmbPar2);
1314
1315 String toolTipPar5 = "Specifies whether the candidates should be reported in descending or ascending order of fitness.";
1316 linePar5 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1317 rdbPar5 = new JRadioButton("Sort by descending fitness");
1318 rdbPar5.setToolTipText(toolTipPar5);
1319 rdbPar5.addChangeListener(rdbFieldChange);
1320 mapKeyFieldToValueField.put(keyPar5.toUpperCase(),rdbPar5);
1321 linePar5.add(rdbPar5);
1323
1324 String toolTipPar10 = "<html>Controls the maximum number of attempts to build a new graph.<br> The maximum number of attempts to build a new graph is given by the size of the population, times this factor.</html>";
1325 linePar10 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1326 lblPar10 = new JLabel("Max tries to get new graph:", SwingConstants.LEFT);
1327 lblPar10.setPreferredSize(fileLabelSize);
1328 lblPar10.setToolTipText(toolTipPar10);
1329 txtPar10 = new JTextField();
1330 txtPar10.setToolTipText(toolTipPar10);
1331 txtPar10.setPreferredSize(strFieldSize);
1332 txtPar10.getDocument().addDocumentListener(fieldListener);
1333 mapKeyFieldToValueField.put(keyPar10.toUpperCase(),txtPar10);
1334 linePar10.add(lblPar10);
1335 linePar10.add(txtPar10);
1337
1338
1339 advOptsBlock.add(new JSeparator());
1340
1341
1342 String toolMolToGraph = "<html>Specifies the pathname of a file containing molecules that should be screened to generate the initial population.<br> The file can be an SDF file or a text file where each line contains a SMILES.</html>";
1343 lineMolToGraph = new JPanel(new FlowLayout(FlowLayout.LEFT));
1344 lblMolToGraph = new JLabel("Initial population from screening:", SwingConstants.LEFT);
1345 lblMolToGraph.setPreferredSize(fileLabelSize);
1346 lblMolToGraph.setToolTipText(toolMolToGraph);
1347 txtMolToGraph = new JTextField();
1348 txtMolToGraph.setToolTipText(toolMolToGraph);
1349 txtMolToGraph.setPreferredSize(fileFieldSize);
1350 txtMolToGraph.getDocument().addDocumentListener(fieldListener);
1351 txtMolToGraph.getDocument().addDocumentListener(new DocumentListener() {
1352 public void changedUpdate(DocumentEvent e) {
1353 if (txtMolToGraph.getText().isBlank())
1354 {
1355 txtFrgMols.setEnabled(false);
1356 btnFrgMols.setEnabled(false);
1357 rdbAddH.setEnabled(false);
1358 } else {
1359 txtFrgMols.setEnabled(true);
1360 btnFrgMols.setEnabled(true);
1361 rdbAddH.setEnabled(true);
1362 }
1363 }
1364 public void removeUpdate(DocumentEvent e) {
1365 if (txtMolToGraph.getText().isBlank())
1366 {
1367 txtFrgMols.setEnabled(false);
1368 btnFrgMols.setEnabled(false);
1369 rdbAddH.setEnabled(false);
1370 } else {
1371 txtFrgMols.setEnabled(true);
1372 btnFrgMols.setEnabled(true);
1373 rdbAddH.setEnabled(true);
1374 }
1375 }
1376 public void insertUpdate(DocumentEvent e) {
1377 if (txtMolToGraph.getText().isBlank())
1378 {
1379 txtFrgMols.setEnabled(false);
1380 btnFrgMols.setEnabled(false);
1381 rdbAddH.setEnabled(false);
1382 } else {
1383 txtFrgMols.setEnabled(true);
1384 btnFrgMols.setEnabled(true);
1385 rdbAddH.setEnabled(true);
1386 }
1387 }
1388 });
1390 btnMolToGraph = new JButton("Browse");
1391 btnMolToGraph.addActionListener(new ActionListener() {
1392 public void actionPerformed(ActionEvent e) {
1394 }
1395 });
1400
1401 String toolFrgMols = "<html>Specifies the pathname of a file containing the cutting rules to apply when converting molecules into graphs</html>";
1402 lineFrgMols = new JPanel(new FlowLayout(FlowLayout.LEFT));
1403 lblFrgMols = new JLabel("Mol-to-graph bond-cutting rules:", SwingConstants.LEFT);
1404 lblFrgMols.setPreferredSize(fileLabelSize);
1405 lblFrgMols.setToolTipText(toolFrgMols);
1406 txtFrgMols = new JTextField();
1407 txtFrgMols.setToolTipText(toolFrgMols);
1408 txtFrgMols.setPreferredSize(fileFieldSize);
1409 txtFrgMols.getDocument().addDocumentListener(fieldListener);
1410 txtFrgMols.setEnabled(false);
1411 mapKeyFieldToValueField.put(keyFrgMols.toUpperCase(), txtFrgMols);
1412 btnFrgMols = new JButton("Browse");
1413 btnFrgMols.addActionListener(new ActionListener() {
1414 public void actionPerformed(ActionEvent e) {
1416 }
1417 });
1418 btnFrgMols.setEnabled(false);
1423
1424 String toolAddH = "Specifies whether the to add explicit H atoms upon importing molecules to be fragmented.";
1425 lineAddH = new JPanel(new FlowLayout(FlowLayout.LEFT));
1426 rdbAddH = new JRadioButton("Add explicit H atoms");
1427 rdbAddH.setToolTipText(toolAddH);
1428 rdbAddH.addChangeListener(rdbFieldChange);
1429 rdbAddH.setEnabled(false);
1430 mapKeyFieldToValueField.put(keyAddH.toUpperCase(),rdbAddH);
1431 lineAddH.add(rdbAddH);
1433
1434
1435 advOptsBlock.add(new JSeparator());
1436
1437
1438 String toolTipPar20 = "<html>Specifies the pathname of a file containing previously evaluated individuals to be added to the initial population.<br> The file can be an SDF file or a text file where each line containing the pathname to a single-molecule SDF file.</html>";
1439 linePar20 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1440 lblPar20 = new JLabel("Initial population file (SDF):", SwingConstants.LEFT);
1441 lblPar20.setPreferredSize(fileLabelSize);
1442 lblPar20.setToolTipText(toolTipPar20);
1443 txtPar20 = new JTextField();
1444 txtPar20.setToolTipText(toolTipPar20);
1445 txtPar20.setPreferredSize(fileFieldSize);
1446 txtPar20.getDocument().addDocumentListener(fieldListener);
1447 mapKeyFieldToValueField.put(keyPar20.toUpperCase(),txtPar20);
1448 btnPar20 = new JButton("Browse");
1449 btnPar20.addActionListener(new ActionListener() {
1450 public void actionPerformed(ActionEvent e) {
1452 }
1453 });
1454 linePar20.add(lblPar20);
1455 linePar20.add(txtPar20);
1456 linePar20.add(btnPar20);
1458
1459 String toolTipPar21 = "<html>Specifies the pathname of a text file collecting unique individual identification (UID) of previously known individuals.<br>The file must have one UID per line.</html>";
1460 linePar21 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1461 lblPar21 = new JLabel("File with known UIDs:", SwingConstants.LEFT);
1462 lblPar21.setPreferredSize(fileLabelSize);
1463 lblPar21.setToolTipText(toolTipPar21);
1464 txtPar21 = new JTextField();
1465 txtPar21.setToolTipText(toolTipPar21);
1466 txtPar21.setPreferredSize(fileFieldSize);
1467 txtPar21.getDocument().addDocumentListener(fieldListener);
1468 mapKeyFieldToValueField.put(keyPar21.toUpperCase(),txtPar21);
1469 btnPar21 = new JButton("Browse");
1470 btnPar21.addActionListener(new ActionListener() {
1471 public void actionPerformed(ActionEvent e) {
1473 }
1474 });
1475 linePar21.add(lblPar21);
1476 linePar21.add(txtPar21);
1477 linePar21.add(btnPar21);
1479
1480 String toolTipPar22 = "Specifies the pathname of the file that will collect unique individual identification (UID) strings encountered during an evolutionary experiment.";
1481 linePar22 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1482 lblPar22 = new JLabel("File for new UIDs:", SwingConstants.LEFT);
1483 lblPar22.setPreferredSize(fileLabelSize);
1484 lblPar22.setToolTipText(toolTipPar22);
1485 txtPar22 = new JTextField();
1486 txtPar22.setToolTipText(toolTipPar22);
1487 txtPar22.setPreferredSize(fileFieldSize);
1488 txtPar22.getDocument().addDocumentListener(fieldListener);
1489 mapKeyFieldToValueField.put(keyPar22.toUpperCase(),txtPar22);
1490 btnPar22 = new JButton("Browse");
1491 btnPar22.addActionListener(new ActionListener() {
1492 public void actionPerformed(ActionEvent e) {
1494 }
1495 });
1496 linePar22.add(lblPar22);
1497 linePar22.add(txtPar22);
1498 linePar22.add(btnPar22);
1500
1501 advOptsBlock.add(new JSeparator());
1502
1503 String toolTipRingTmplsFrags = "<html>Specifies whether ring systems "
1504 + "should be extracted <br>"
1505 + "from generated graphs and stored as new general-"
1506 + "purpose building blocks."
1507 + "</html>";
1508 lineRingTmplsFrags = new JPanel(new FlowLayout(FlowLayout.LEFT));
1509 rdbRingTmplsFrags = new JRadioButton("Add new ring systems to building "
1510 + "block library.");
1511 rdbRingTmplsFrags.setToolTipText(toolTipRingTmplsFrags);
1512 rdbRingTmplsFrags.addChangeListener(rdbFieldChange);
1517
1518 String toolTipRingTmplsScaff = "<html>Specifies whether ring systems "
1519 + "should be extracted <br>"
1520 + "from generated graphs and stored as new "
1521 + "scaffold building blocks."
1522 + "</html>";
1523 lineRingTmplsScaff = new JPanel(new FlowLayout(FlowLayout.LEFT));
1524 rdbRingTmplsScaff = new JRadioButton("Add new ring systems to library "
1525 + "of scaffold building blocks.");
1526 rdbRingTmplsScaff.setToolTipText(toolTipRingTmplsScaff);
1527 rdbRingTmplsScaff.addChangeListener(rdbFieldChange);
1532
1533 String toolTipRingSysTmpl = "<html>A %/100 defining how good "
1534 + "(high fitness w.r.t. population range)<br> "
1535 + "candidates need to be for generating "
1536 + "new ring system templates.<br>"
1537 + "For example, 0.10 "
1538 + "allows only the best 10% of the candidates <br>to generate "
1539 + "a new building block from theyr graph.</html>";
1540 lineRingSysTmpl = new JPanel(new FlowLayout(FlowLayout.LEFT));
1541 lblRingSysTmpl = new JLabel("Threshold for saving ring systems:",
1542 SwingConstants.LEFT);
1543 lblRingSysTmpl.setPreferredSize(fileLabelSize);
1544 lblRingSysTmpl.setToolTipText(toolTipRingSysTmpl);
1545 spnRingSysTmpl = new JSpinner(new SpinnerNumberModel(0.10,0.0,1.0,0.05));
1546 spnRingSysTmpl.setToolTipText(toolTipRingSysTmpl);
1547 spnRingSysTmpl.setPreferredSize(strFieldSize);
1555
1556 advOptsBlock.add(super.getPanelForUnformattedInput());
1557
1558
1559 //HEREGOESADVIMPLEMENTATION this is only to facilitate automated insertion of code
1560
1561 JButton advOptShow = new JButton("Advanced Settings");
1562 advOptShow.addActionListener(new ActionListener(){
1563 public void actionPerformed(ActionEvent e){
1564 if (advOptsBlock.isVisible())
1565 {
1566 advOptsBlock.setVisible(false);
1567 advOptShow.setText("Show Advanced Settings");
1568 }
1569 else
1570 {
1571 advOptsBlock.setVisible(true);
1572 advOptShow.setText("Hide Advanced Settings");
1573 scrollablePane.validate();
1574 scrollablePane.repaint();
1575 scrollablePane.getVerticalScrollBar().setValue(
1576 scrollablePane.getVerticalScrollBar().getValue() + (int) preferredHeight*2/3);
1577 }
1578 }
1579 });
1580
1581 JPanel advOptsController = new JPanel();
1582 advOptsController.add(advOptShow);
1583 localBlock2.add(new JSeparator());
1584 localBlock2.add(advOptsController);
1586
1587 this.add(scrollablePane);
1588 }
1589
1590//-----------------------------------------------------------------------------
1591
1593 {
1595 ((XYPlot) graphLvlProbJFChart.getPlot()).setDataset(levelProbData);
1596 }
1597
1598//-----------------------------------------------------------------------------
1599
1600 private void createLvlProbDataset()
1601 {
1602 levelProbData = new DefaultXYDataset();
1603
1604 ArrayList<Double> y = new ArrayList<Double>();
1605 try
1606 {
1608 cmbPar11.getSelectedItem().toString());
1609 double l = (Double) spnPar12.getValue();
1610 double s1 = (Double) spnPar13.getValue();
1611 double s2 = (Double) spnPar14.getValue();
1612
1613 for (int level=0; level<100; level++)
1614 {
1616 level, scheme, l, s1, s2);
1617 y.add(prob);
1618 }
1619 }
1620 catch (Exception e)
1621 {
1622 e.printStackTrace();
1623 JOptionPane.showMessageDialog(this,
1624 "<html>Exception occurred while reading growth proability "
1625 + "scheme.<br>"
1626 + "Please, report this to the DENOPTIM team.</html>",
1627 "Error",
1628 JOptionPane.ERROR_MESSAGE,
1629 UIManager.getIcon("OptionPane.errorIcon"));
1630 }
1631
1632 double[][] data = new double[2][y.size()];
1633 for (int level=0; level<100; level++)
1634 {
1635 data[0][level] = level;
1636 data[1][level] = y.get(level);
1637 }
1638
1639 levelProbData.addSeries("Growth Probability", data);
1640 }
1641
1642//-----------------------------------------------------------------------------
1643
1644 private void createLvlProbGraph()
1645 {
1649 graphLvlProbJFChartChartPanel.setMaximumSize(new Dimension(400,200));
1650 }
1651
1652//-----------------------------------------------------------------------------
1653
1654 private void createLvlProbChart()
1655 {
1656 graphLvlProbJFChart = ChartFactory.createXYLineChart(
1657 null, // plot title
1658 "Level", // x axis label
1659 "Probability", // y axis label
1660 levelProbData, // data
1661 PlotOrientation.VERTICAL,
1662 false, // include legend
1663 false, // tooltips
1664 false // urls
1665 );
1666
1667 XYPlot plot = (XYPlot) graphLvlProbJFChart.getPlot();
1668
1669 // axis ranges
1670 plot.getDomainAxis().setRange(minLevelProbPlot, maxLevelProbPlot);
1671 plot.getRangeAxis().setRange(0.0, 1.0);
1672
1673 // axis ticks interval
1674 //NB: this if commented out because it blocks automated selection of tick units
1675 // and therefore it allows ticks overlap when range is large
1676 //((NumberAxis) plot.getDomainAxis()).setTickUnit(new NumberTickUnit(1.0));
1677
1678 // series line thickness
1679 XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
1680 renderer.setSeriesPaint(0, Color.decode("#490092"));
1681 renderer.setSeriesStroke(0, new BasicStroke(2.0f));
1682 plot.setRenderer(renderer);
1683
1684 // font of axis label
1685 Font font3 = new Font("Dialog", Font.PLAIN, 12);
1686 plot.getDomainAxis().setLabelFont(font3);
1687 plot.getRangeAxis().setLabelFont(font3);
1688 }
1689
1690 //-----------------------------------------------------------------------------
1691
1693 {
1695 ((XYPlot) graphMolSzProbJFChart.getPlot()).setDataset(molSizeProbData);
1696 }
1697
1698//-----------------------------------------------------------------------------
1699
1701 {
1702 molSizeProbData = new DefaultXYDataset();
1703
1704 ArrayList<Double> y = new ArrayList<Double>();
1705 try
1706 {
1708 cmbParMolSz1.getSelectedItem().toString());
1709 double l = (Double) spnParMolSz2.getValue();
1710 double s1 = (Double) spnParMolSz3.getValue();
1711 double s2 = (Double) spnParMolSz4.getValue();
1712
1713 for (int numHeavyAtoms=0; numHeavyAtoms<100; numHeavyAtoms++)
1714 {
1715 double prob = EAUtils.getProbability(
1716 numHeavyAtoms, scheme, l, s1, s2);
1717 y.add(prob);
1718 }
1719 }
1720 catch (Exception e)
1721 {
1722 e.printStackTrace();
1723 JOptionPane.showMessageDialog(this,
1724 "<html>Exception occurred while reading croding proability "
1725 + "scheme.<br>"
1726 + "Please, report this to the DENOPTIM team.</html>",
1727 "Error",
1728 JOptionPane.ERROR_MESSAGE,
1729 UIManager.getIcon("OptionPane.errorIcon"));
1730 }
1731
1732 double[][] data = new double[2][y.size()];
1733 for (int numHeavyAtoms=0; numHeavyAtoms<100; numHeavyAtoms++)
1734 {
1735 data[0][numHeavyAtoms] = numHeavyAtoms;
1736 data[1][numHeavyAtoms] = y.get(numHeavyAtoms);
1737 }
1738
1739 molSizeProbData.addSeries("Mol Growth Probability", data);
1740 }
1741
1742//-----------------------------------------------------------------------------
1743
1745 {
1749 graphMolSzProbJFChartChartPanel.setMaximumSize(new Dimension(400,200));
1750 }
1751
1752//-----------------------------------------------------------------------------
1753
1755 {
1756 graphMolSzProbJFChart = ChartFactory.createXYLineChart(
1757 null, // plot title
1758 "# Heavy Atoms", // x axis label
1759 "Probability", // y axis label
1760 molSizeProbData, // data
1761 PlotOrientation.VERTICAL,
1762 false, // include legend
1763 false, // tooltips
1764 false // urls
1765 );
1766
1767 XYPlot plot = (XYPlot) graphMolSzProbJFChart.getPlot();
1768
1769 // axis ranges
1770 plot.getDomainAxis().setRange(minMolSizeProbPlot, maxMolSizeProbPlot);
1771 plot.getRangeAxis().setRange(0.0, 1.0);
1772
1773 // axis ticks interval
1774 //NB: this if commented out because it blocks automated selection of tick units
1775 // and therefore it allows ticks overlap when range is large
1776 //((NumberAxis) plot.getDomainAxis()).setTickUnit(new NumberTickUnit(1.0));
1777
1778 // series line thickness
1779 XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
1780 renderer.setSeriesPaint(0, Color.decode("#db6d00"));
1781 renderer.setSeriesStroke(0, new BasicStroke(2.0f));
1782 plot.setRenderer(renderer);
1783
1784 // font of axis label
1785 Font font3 = new Font("Dialog", Font.PLAIN, 12);
1786 plot.getDomainAxis().setLabelFont(font3);
1787 plot.getRangeAxis().setLabelFont(font3);
1788 }
1789
1790//-----------------------------------------------------------------------------
1791
1793 {
1795 ((XYPlot) graphCrowdProbJFChart.getPlot()).setDataset(crowdProbData);
1796 }
1797
1798//-----------------------------------------------------------------------------
1799
1801 {
1802 crowdProbData = new DefaultXYDataset();
1803
1804 ArrayList<Double> y = new ArrayList<Double>();
1805 try
1806 {
1808 cmbParCrowd1.getSelectedItem().toString());
1809 double l = (Double) spnParCrowd2.getValue();
1810 double s1 = (Double) spnParCrowd3.getValue();
1811 double s2 = (Double) spnParCrowd4.getValue();
1812
1813 for (int crowdedness=0; crowdedness<100; crowdedness++)
1814 {
1816 crowdedness, scheme, l, s1, s2);
1817 y.add(prob);
1818 }
1819 }
1820 catch (Exception e)
1821 {
1822 e.printStackTrace();
1823 JOptionPane.showMessageDialog(this,
1824 "<html>Exception occurred while reading mol growth "
1825 + "proability scheme.<br>"
1826 + "Please, report this to the DENOPTIM team.</html>",
1827 "Error",
1828 JOptionPane.ERROR_MESSAGE,
1829 UIManager.getIcon("OptionPane.errorIcon"));
1830 }
1831
1832 double[][] data = new double[2][y.size()];
1833 for (int crowdedness=0; crowdedness<100; crowdedness++)
1834 {
1835 data[0][crowdedness] = crowdedness;
1836 data[1][crowdedness] = y.get(crowdedness);
1837 }
1838
1839 crowdProbData.addSeries("Crowding Probability", data);
1840 }
1841
1842//-----------------------------------------------------------------------------
1843
1844 private void createCrowdProbGraph()
1845 {
1849 graphCrowdProbJFChartChartPanel.setMaximumSize(new Dimension(400,200));
1850 }
1851
1852//-----------------------------------------------------------------------------
1853
1855 {
1856 graphCrowdProbJFChart = ChartFactory.createXYLineChart(
1857 null, // plot title
1858 "Crowdedness", // x axis label
1859 "Probability", // y axis label
1860 crowdProbData, // data
1861 PlotOrientation.VERTICAL,
1862 false, // include legend
1863 false, // tooltips
1864 false // urls
1865 );
1866
1867 XYPlot plot = (XYPlot) graphCrowdProbJFChart.getPlot();
1868
1869 // axis ranges
1870 plot.getDomainAxis().setRange(minLevelCrowdProbPlot, maxLevelCrowdProbPlot);
1871 plot.getRangeAxis().setRange(0.0, 1.0);
1872
1873 // axis ticks interval
1874 //NB: this if commented out because it blocks automated selection of tick units
1875 // and therefore it allows ticks overlap when range is large
1876 //((NumberAxis) plot.getDomainAxis()).setTickUnit(new NumberTickUnit(1.0));
1877
1878 // series line thickness
1879 XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
1880 renderer.setSeriesPaint(0, Color.decode("#ff6db6"));
1881 renderer.setSeriesStroke(0, new BasicStroke(2.0f));
1882 plot.setRenderer(renderer);
1883
1884 // font of axis label
1885 Font font3 = new Font("Dialog", Font.PLAIN, 12);
1886 plot.getDomainAxis().setLabelFont(font3);
1887 plot.getRangeAxis().setLabelFont(font3);
1888 }
1889
1890//-----------------------------------------------------------------------------
1891
1901 @Override
1902 public void importParametersFromDenoptimParamsFile(String fileName) throws Exception
1903 {
1905 checkedFlags.clear();
1906 checkedFlags.put(keyPar11, false);
1907
1909
1910 // We have also some fragmentation parameters in this form
1912
1913 rdbSrcOrNew.setSelected(false);
1914 localBlock1.setVisible(false);
1915 localBlock2.setVisible(true);
1916 switch (ProbabilityFuncitonShape.valueOf(
1917 cmbPar11.getSelectedItem().toString()))
1918 {
1919 case EXP_DIFF:
1920 localBlockLvlProb3.setVisible(true);
1921 localBlockLvlProb4.setVisible(false);
1922 break;
1923
1924 case TANH:
1925 localBlockLvlProb3.setVisible(true);
1926 localBlockLvlProb4.setVisible(false);
1927 break;
1928
1929 case SIGMA:
1930 localBlockLvlProb3.setVisible(false);
1931 localBlockLvlProb4.setVisible(true);
1932 break;
1933
1934 default:
1935 localBlockLvlProb3.setVisible(false);
1936 localBlockLvlProb4.setVisible(false);
1937 break;
1938 }
1939 switch (ProbabilityFuncitonShape.valueOf(
1940 cmbParMolSz1.getSelectedItem().toString()))
1941 {
1942 case EXP_DIFF:
1943 localBlockMolSz3.setVisible(true);
1944 localBlockMolSz4.setVisible(false);
1945 break;
1946
1947 case TANH:
1948 localBlockMolSz3.setVisible(true);
1949 localBlockMolSz4.setVisible(false);
1950 break;
1951
1952 case SIGMA:
1953 localBlockMolSz3.setVisible(false);
1954 localBlockMolSz4.setVisible(true);
1955 break;
1956
1957 default:
1958 localBlockMolSz3.setVisible(false);
1959 localBlockMolSz4.setVisible(false);
1960 break;
1961 }
1962 if (checkedFlags.get(keyPar11))
1963 {
1964 rbtLevelGrowth.setSelected(true);
1965 localBlockLvlProbAll.setVisible(true);
1966 localBlockMolSzAll.setVisible(false);
1967 } else {
1968 rbtMolSzGrowth.setSelected(true);
1969 localBlockLvlProbAll.setVisible(false);
1970 localBlockMolSzAll.setVisible(true);
1971 }
1972
1973 switch (ProbabilityFuncitonShape.valueOf(
1974 cmbParCrowd1.getSelectedItem().toString()))
1975 {
1976 case EXP_DIFF:
1978 localBlockCrowd3.setVisible(true);
1979 localBlockCrowd4.setVisible(false);
1980 localBlockCrowdGraph.setVisible(true);
1981 break;
1982
1983 case TANH:
1985 localBlockCrowd3.setVisible(true);
1986 localBlockCrowd4.setVisible(false);
1987 localBlockCrowdGraph.setVisible(true);
1988 break;
1989
1990 case SIGMA:
1992 localBlockCrowd3.setVisible(false);
1993 localBlockCrowd4.setVisible(true);
1994 localBlockCrowdGraph.setVisible(true);
1995 break;
1996
1997 case UNRESTRICTED:
1999 localBlockCrowd3.setVisible(false);
2000 localBlockCrowd4.setVisible(false);
2001 localBlockCrowdGraph.setVisible(true);
2002 break;
2003
2004 default:
2005 localBlockCrowd3.setVisible(false);
2006 localBlockCrowd4.setVisible(false);
2007 localBlockCrowdGraph.setVisible(false);
2008 break;
2009 }
2010
2011 advOptsBlock.setVisible(true);
2012 showUnknownKeyWarning(this, "Genetic Algorithm");
2013 }
2014
2015//-----------------------------------------------------------------------------
2016
2017 @SuppressWarnings("unchecked")
2018 @Override
2019 public void importSingleParameter(String key, String value) throws Exception
2020 {
2021 Object valueField;
2022 String valueFieldClass;
2023 if (mapKeyFieldToValueField.containsKey(key.toUpperCase()))
2024 {
2025 valueField = mapKeyFieldToValueField.get(key.toUpperCase());
2026 valueFieldClass = valueField.getClass().toString();
2027 }
2028 else
2029 {
2030 addToUnformattedTxt(key, value);
2031 return;
2032 }
2033
2034 switch (valueFieldClass)
2035 {
2036 case "class javax.swing.JTextField":
2037 ((JTextField) valueField).setText(value);
2038 break;
2039
2040 case "class javax.swing.JRadioButton":
2041 ((JRadioButton) valueField).setSelected(true);
2042 break;
2043
2044 case "class javax.swing.JComboBox":
2045 if (valueField==cmbParMolSz1 || valueField==cmbParCrowd1 ||
2046 valueField==cmbPar11)
2047 {
2048 ((JComboBox<ProbabilityFuncitonShape>) valueField)
2049 .setSelectedItem(ProbabilityFuncitonShape.valueOf(
2050 value.toUpperCase()));
2051 } else {
2052 ((JComboBox<String>) valueField).setSelectedItem(
2053 value.toUpperCase());
2054 }
2055 break;
2056
2057 case "class javax.swing.table.DefaultTableModel":
2058
2059 //WARNING: there might be cases where we do not take all the records
2060
2061 ((DefaultTableModel) valueField).addRow(value.split(" "));
2062 break;
2063
2064 case "class javax.swing.JSpinner":
2065
2066 //WARNING: assuming all JSpinners work on doubles
2067
2068 ((JSpinner) valueField).setValue(Double.parseDouble(value));
2069 break;
2070
2071 default:
2072 throw new Exception("<html>Unexpected type for parameter: "
2073 + key + " (" + valueFieldClass
2074 + ").<br>Please report this to"
2075 + "the DEMOPTIM team.</html>");
2076 }
2077
2078 }
2079
2080//-----------------------------------------------------------------------------
2081
2082 @Override
2083 public void putParametersToString(StringBuilder sb) throws Exception
2084 {
2085 sb.append("# Genetic Algorithm - parameters").append(NL);
2086
2087 if (rdbSrcOrNew.isSelected())
2088 {
2089 if (txtGASource.getText().equals("") || txtGASource.getText() == null)
2090 {
2091 throw new Exception("<html>No source specified for GA "
2092 + "parameters.<br>Please, specify the file name.</html>");
2093 }
2095 }
2096
2099 sb.append(keyPar2).append("=").append(cmbPar2.getSelectedItem())
2100 .append(NL);
2107 if (rbtLevelGrowth.isSelected())
2108 {
2109 sb.append(keyPar11).append("=").append(cmbPar11.getSelectedItem())
2110 .append(NL);
2111 if (cmbPar11.getSelectedItem()!=ProbabilityFuncitonShape.UNRESTRICTED)
2112 {
2113 if (cmbPar11.getSelectedItem()==ProbabilityFuncitonShape.EXP_DIFF
2114 || cmbPar11.getSelectedItem()==ProbabilityFuncitonShape.TANH)
2115 {
2117 } else if (cmbPar11.getSelectedItem()==ProbabilityFuncitonShape.SIGMA)
2118 {
2121 }
2122 }
2123 } else if (rbtMolSzGrowth.isSelected())
2124 {
2125 sb.append(keyParMolSz1).append("=")
2126 .append(cmbParMolSz1.getSelectedItem()).append(NL);
2127 if (cmbParMolSz1.getSelectedItem()!=ProbabilityFuncitonShape.UNRESTRICTED)
2128 {
2129 if (cmbParMolSz1.getSelectedItem()==ProbabilityFuncitonShape.EXP_DIFF
2130 || cmbParMolSz1.getSelectedItem()==ProbabilityFuncitonShape.TANH)
2131 {
2133 } else if (cmbParMolSz1.getSelectedItem()==ProbabilityFuncitonShape.SIGMA)
2134 {
2137 }
2138 }
2139 }
2140 sb.append(keyParCrowd1).append("=")
2141 .append(cmbParCrowd1.getSelectedItem()).append(NL);
2142 if (cmbParCrowd1.getSelectedItem()!=ProbabilityFuncitonShape.UNRESTRICTED)
2143 {
2144 if (cmbParCrowd1.getSelectedItem()==ProbabilityFuncitonShape.EXP_DIFF
2145 || cmbParCrowd1.getSelectedItem()==ProbabilityFuncitonShape.TANH)
2146 {
2148 } else if (cmbParCrowd1.getSelectedItem()==ProbabilityFuncitonShape.SIGMA)
2149 {
2152 }
2153 }
2154 sb.append(keyPar15).append("=").append(cmbPar15.getSelectedItem())
2155 .append(NL);
2161 sb.append(keyPar19).append("=").append(cmbPar19.getSelectedItem())
2162 .append(NL);
2163
2167
2172 sb.append(keyPar25).append("=").append(cmbPar25.getSelectedItem())
2173 .append(NL);
2176 if (rdbRingTmplsScaff.isSelected() || rdbRingTmplsScaff.isSelected())
2177 {
2179 }
2180
2181 sb.append(getTextForUnformattedSettings()).append(NL);
2182
2183 //HEREGOESPRINT this is only to facilitate automated insertion of code
2184 }
2185}
Helper methods for the genetic algorithm.
Definition: EAUtils.java:93
static double getGrowthProbabilityAtLevel(int level, int scheme, double lambda, double sigmaOne, double sigmaTwo)
Calculates the probability of adding a fragment to the given level.
Definition: EAUtils.java:2009
static double getProbability(double value, int scheme, double lambda, double sigmaOne, double sigmaTwo)
Calculated a probability given parameters defining the shape of the probability function and a single...
Definition: EAUtils.java:2074
static double getCrowdingProbabilityForCrowdedness(int crowdedness, int scheme, double lambda, double sigmaOne, double sigmaTwo)
Calculated the crowding probability for a given level of crowdedness.
Definition: EAUtils.java:2257
Form collecting input parameters for a genetic algorithm experiment.
JComboBox< ProbabilityFuncitonShape > cmbParCrowd1
JComboBox< ProbabilityFuncitonShape > cmbParMolSz1
JComboBox< ProbabilityFuncitonShape > cmbPar11
void importSingleParameter(String key, String value)
Map< String, Object > mapKeyFieldToValueField
Map connecting the parameter keyword and the field containing the parameter value.
static AtomicInteger gaFormUID
Unique identified for instances of this form.
static final long serialVersionUID
Version.
void putParametersToString(StringBuilder sb)
void importParametersFromDenoptimParamsFile(String fileName)
Imports parameters from a properly formatted parameters file.
File opener for DENOPTIM GUI.
static File pickFileForTxtField(JTextField txtField, Component parent)
General structure of a form for collecting input parameters of various nature.
CmbFieldChange cmbFieldChange
Listener for changes in combo box-bound parameters.
final Dimension strFieldSize
Default sizes for short pathname fields (i.e., string or number)
FieldListener fieldListener
Listener for changes in parameters of this form.
String getStringForKVLine(String key, JSpinner spinner)
Produced the KEY:VALUE string for a general spinner.
final Dimension fileLabelSize
Default sizes for file pathname labels.
final int preferredHeight
Default text field height.
Map< String, Boolean > checkedFlags
Map of keyword to search for when reading a parameters file.
String getStringIfSelected(String key, JRadioButton btn)
Produced the KEY:VALUE string for a on/off button.
void addToUnformattedTxt(String key, String value)
void showUnknownKeyWarning(Component parent, String paramType)
Shown a warning dialog that informs the user about having found text that is not present in the Param...
final Dimension fileFieldSize
Default sizes for file pathname fields.
String getStringIfNotEmpty(String key, JTextField field, String prefix, String suffix)
Produced the KEY:VALUE string for a general text field.
RdbFieldChange rdbFieldChange
Listener for changes in radio button-bound parameters.
Parameters for genetic algorithm.
static int convertProbabilityScheme(String option)
The identifiers of probability function shapes that are available.