$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 keyPar5a = "GA-NaNFitnessKillsExperiment";
126 JPanel linePar5a;
127 JRadioButton rdbPar5a;
128
129 String keyPar6 = "GA-PopulationSize";
130 JPanel linePar6;
131 JLabel lblPar6;
132 JTextField txtPar6;
133
134 String keyPar7 = "GA-NumChildren";
135 JPanel linePar7;
136 JLabel lblPar7;
137 JTextField txtPar7;
138
139 String keyPar8 = "GA-NumGenerations";
140 JPanel linePar8;
141 JLabel lblPar8;
142 JTextField txtPar8;
143
144 String keyPar9 = "GA-NumConvGen";
145 JPanel linePar9;
146 JLabel lblPar9;
147 JTextField txtPar9;
148
149 String keyPar10 = "GA-MaxTriesPerPopulation";
150 JPanel linePar10;
151 JLabel lblPar10;
152 JTextField txtPar10;
153
156 JTextField txtMolToGraph;
158 String keyMolToGraph = "GA-InitMolsToFragmentFile";
159
162 JTextField txtFrgMols;
163 JButton btnFrgMols;
164 String keyFrgMols = "FRG-CuttingRulesFile";
165
166 JPanel lineAddH;
167 JLabel lblAddH;
168 JRadioButton rdbAddH;
169 String keyAddH = "FRG-AddExplicitHydrogen";
170
173 ButtonGroup bgGrowthMode;
174 JRadioButton rbtLevelGrowth;
175 JRadioButton rbtMolSzGrowth;
176
177 DefaultXYDataset molSizeProbData;
182 Double minMolSizeProbPlot = 1.0;
183 Double maxMolSizeProbPlot = 50.0;
184
185 String keyParMolSz1 = "GA-MolGrowthProbScheme";
188 JComboBox<ProbabilityFuncitonShape> cmbParMolSz1;
189
190 String keyParMolSz2 = "GA-MolGrowthMultiplier";
193 JSpinner spnParMolSz2;
194
195 String keyParMolSz3 = "GA-MolGrowthSigmaSteepness";
198 JSpinner spnParMolSz3;
199
200 String keyParMolSz4 = "GA-MolGrowthSigmaMiddle";
203 JSpinner spnParMolSz4;
204
209
210 DefaultXYDataset levelProbData;
215 Double minLevelProbPlot = 0.0;
216 Double maxLevelProbPlot = 5.0;
217
218 String keyPar11 = "GA-LevelGrowthProbScheme";
219 JPanel linePar11;
220 JLabel lblPar11;
221 JComboBox<ProbabilityFuncitonShape> cmbPar11;
222
223 String keyPar12 = "GA-LevelGrowthMultiplier";
224 JPanel linePar12;
225 JLabel lblPar12;
226 JSpinner spnPar12;
227
228 String keyPar13 = "GA-LevelGrowthSigmaSteepness";
229 JPanel linePar13;
230 JLabel lblPar13;
231 JSpinner spnPar13;
232
233 String keyPar14 = "GA-LevelGrowthSigmaMiddle";
234 JPanel linePar14;
235 JLabel lblPar14;
236 JSpinner spnPar14;
237
242
243 DefaultXYDataset crowdProbData;
250
254
255 String keyParCrowd1 = "GA-CrowdProbScheme";
258 JComboBox<ProbabilityFuncitonShape> cmbParCrowd1;
259
260 String keyParCrowd2 = "GA-CrowdMultiplier";
263 JSpinner spnParCrowd2;
264
265 String keyParCrowd3 = "GA-CrowdSigmaSteepness";
268 JSpinner spnParCrowd3;
269
270 String keyParCrowd4 = "GA-CrowdSigmaMiddle";
273 JSpinner spnParCrowd4;
274
275 String keyPar15 = "GA-XOverSelectionMode";
276 JPanel linePar15;
277 JLabel lblPar15;
278 JComboBox<String> cmbPar15;
279
280 String keyPar16 = "GA-CrossoverWeight";
281 JPanel linePar16;
282 JLabel lblPar16;
283 JTextField txtPar16;
284
285 String keyPar17 = "GA-MutationWeight";
286 JPanel linePar17;
287 JLabel lblPar17;
288 JTextField txtPar17;
289
290 String keyParMSM = "GA-MultiSiteMutationWeights";
292 JLabel lblParMSM;
293 JTextField txtParMSM;
294
295 String keyParWC = "GA-ConstructionWeight";
296 JPanel lineParWC;
297 JLabel lblParWC;
298 JTextField txtParWC;
299
300 String keyPar18 = "GA-SymmetryProbability";
301 JPanel linePar18;
302 JLabel lblPar18;
303 JTextField txtPar18;
304
305 String keyPar19 = "GA-ReplacementStrategy";
306 JPanel linePar19;
307 JLabel lblPar19;
308 JComboBox<String> cmbPar19;
309
310 String keyPar20 = "GA-InitPoplnFile";
311 JPanel linePar20;
312 JLabel lblPar20;
313 JTextField txtPar20;
314 JButton btnPar20;
315
316 String keyPar21 = "GA-UIDFileIn";
317 JPanel linePar21;
318 JLabel lblPar21;
319 JTextField txtPar21;
320 JButton btnPar21;
321
322 String keyPar22 = "GA-UIDFileOut";
323 JPanel linePar22;
324 JLabel lblPar22;
325 JTextField txtPar22;
326 JButton btnPar22;
327
328 String keyPar24 = "GA-NumParallelTasks";
329 JPanel linePar24;
330 JLabel lblPar24;
331 JTextField txtPar24;
332
333 String keyPar25 = "GA-Parallelization";
334 JPanel linePar25;
335 JLabel lblPar25;
336 JComboBox<String> cmbPar25;
337
338 String keyRingTmplsFrags = "GA-KeepNewRingSystemVertexes";
340 JRadioButton rdbRingTmplsFrags;
341
342 String keyRingTmplsScaff = "GA-KeepNewRingSystemScaffolds";
344 JRadioButton rdbRingTmplsScaff;
345
346 String keyRingSysTmplTrhld = "GA-KeepNewRingSystemFitnessTrsh";
350
355 SIGMA, UNRESTRICTED};
356
357 //HEREGOFIELDS this is only to facilitate automated insertion of code
358
359
360 String NL = System.getProperty("line.separator");
361
362 public GAParametersForm(Dimension d)
363 {
364 mapKeyFieldToValueField = new HashMap<String,Object>();
365
366 this.setLayout(new BorderLayout()); //Needed to allow dynamic resizing!
367
368 block = new JPanel();
369 JScrollPane scrollablePane = new JScrollPane(block);
370 block.setLayout(new BoxLayout(block, SwingConstants.VERTICAL));
371
372 localBlock1 = new JPanel();
373 localBlock1.setVisible(false);
374 localBlock1.setLayout(new BoxLayout(localBlock1,
375 SwingConstants.VERTICAL));
376
377 localBlock2 = new JPanel();
378 localBlock2.setVisible(true);
379 localBlock2.setLayout(new BoxLayout(localBlock2,
380 SwingConstants.VERTICAL));
381
382 localBlockMolSz3 = new JPanel();
383 localBlockMolSz3.setVisible(false);
384 localBlockMolSz3.setLayout(new BoxLayout(localBlockMolSz3,
385 SwingConstants.VERTICAL));
386
387 localBlockMolSz4 = new JPanel();
388 localBlockMolSz4.setVisible(true);
389 localBlockMolSz4.setLayout(new BoxLayout(localBlockMolSz4,
390 SwingConstants.VERTICAL));
391
392 localBlockMolSzGraph = new JPanel();
393 localBlockMolSzGraph.setVisible(true);
394 localBlockMolSzAll = new JPanel();
395 localBlockMolSzAll.setVisible(false);
396 localBlockMolSzAll.setLayout(new BoxLayout(localBlockMolSzAll,
397 SwingConstants.VERTICAL));
398
399 localBlockLvlProb3 = new JPanel();
400 localBlockLvlProb3.setVisible(true);
401 localBlockLvlProb3.setLayout(new BoxLayout(localBlockLvlProb3,
402 SwingConstants.VERTICAL));
403
404 localBlockLvlProb4 = new JPanel();
405 localBlockLvlProb4.setVisible(false);
406 localBlockLvlProb4.setLayout(new BoxLayout(localBlockLvlProb4,
407 SwingConstants.VERTICAL));
408
409 localBlockLvlProbGraph = new JPanel();
410 localBlockLvlProbGraph.setVisible(true);
411 localBlockLvlProbAll = new JPanel();
412 localBlockLvlProbAll.setVisible(true);
413 localBlockLvlProbAll.setLayout(new BoxLayout(localBlockLvlProbAll,
414 SwingConstants.VERTICAL));
415
416 localBlockCrowd3 = new JPanel();
417 localBlockCrowd3.setVisible(false);
418 localBlockCrowd3.setLayout(new BoxLayout(localBlockCrowd3,
419 SwingConstants.VERTICAL));
420
421 localBlockCrowd4 = new JPanel();
422 localBlockCrowd4.setVisible(false);
423 localBlockCrowd4.setLayout(new BoxLayout(localBlockCrowd4,
424 SwingConstants.VERTICAL));
425
426 localBlockCrowdGraph = new JPanel();
427 localBlockCrowdGraph.setVisible(false);
428
429 advOptsBlock = new JPanel();
430 advOptsBlock.setVisible(false);
431 advOptsBlock.setLayout(new BoxLayout(advOptsBlock,
432 SwingConstants.VERTICAL));
433
434 String toolTipSrcOrNew = "Tick here to use settings from file.";
435 lineSrcOrNew = new JPanel(new FlowLayout(FlowLayout.LEFT));
436 rdbSrcOrNew = new JRadioButton("Use parameters from existing file");
437 rdbSrcOrNew.setToolTipText(toolTipSrcOrNew);
438 rdbSrcOrNew.addActionListener(new ActionListener(){
439 public void actionPerformed(ActionEvent e){
440 if (rdbSrcOrNew.isSelected())
441 {
442 localBlock1.setVisible(true);
443 localBlock2.setVisible(false);
444 }
445 else
446 {
447 localBlock1.setVisible(false);
448 localBlock2.setVisible(true);
449 }
450 }
451 });
453 block.add(lineSrcOrNew);
454 block.add(localBlock1);
455 block.add(localBlock2);
456
457 String toolTipGASource = "<html>Pathname of a DENOPTIM's parameter file with GA settings.</html>";
458 lineGASource = new JPanel(new FlowLayout(FlowLayout.LEFT));
459 lblGASource = new JLabel("Use parameters from file:", SwingConstants.LEFT);
460 lblGASource.setToolTipText(toolTipGASource);
461 txtGASource = new JTextField();
462 txtGASource.setToolTipText(toolTipGASource);
463 txtGASource.setPreferredSize(fileFieldSize);
464 btnGASource = new JButton("Browse");
465 btnGASource.addActionListener(new ActionListener() {
466 public void actionPerformed(ActionEvent e) {
469 }
470 });
471 btnLoadGASource = new JButton("Load...");
472 txtGASource.setToolTipText("<html>Specify the file containing the "
473 + "parameters to be loaded in this form.</html>");
474 btnLoadGASource.addActionListener(new ActionListener() {
475 public void actionPerformed(ActionEvent e) {
476 try
477 {
479 }
480 catch (Exception e1)
481 {
482 if (e1.getMessage().equals("") || e1.getMessage() == null)
483 {
484 e1.printStackTrace();
485 JOptionPane.showMessageDialog(btnLoadGASource,
486 "<html>Exception occurred while importing parameters.<br>Please, report this to the DENOPTIM team.</html>",
487 "Error",
488 JOptionPane.ERROR_MESSAGE,
489 UIManager.getIcon("OptionPane.errorIcon"));
490 }
491 else
492 {
493 JOptionPane.showMessageDialog(btnLoadGASource,
494 e1.getMessage(),
495 "Error",
496 JOptionPane.ERROR_MESSAGE,
497 UIManager.getIcon("OptionPane.errorIcon"));
498 }
499 return;
500 }
501 }
502 });
508
509 //HEREGOESIMPLEMENTATION this is only to facilitate automated insertion of code
510
511 String toolTipPar6 = "Specifies the number of individuals in the population.";
512 linePar6 = new JPanel(new FlowLayout(FlowLayout.LEFT));
513 lblPar6 = new JLabel("Size of population:", SwingConstants.LEFT);
514 lblPar6.setPreferredSize(fileLabelSize);
515 lblPar6.setToolTipText(toolTipPar6);
516 txtPar6 = new JTextField();
517 txtPar6.setToolTipText(toolTipPar6);
518 txtPar6.setPreferredSize(strFieldSize);
519 txtPar6.getDocument().addDocumentListener(fieldListener);
520 mapKeyFieldToValueField.put(keyPar6.toUpperCase(),txtPar6);
521 linePar6.add(lblPar6);
522 linePar6.add(txtPar6);
524
525 String toolTipPar7 = "Specifies the number of children to be generated for each generation.";
526 linePar7 = new JPanel(new FlowLayout(FlowLayout.LEFT));
527 lblPar7 = new JLabel("No. offsprings per generation:", SwingConstants.LEFT);
528 lblPar7.setPreferredSize(fileLabelSize);
529 lblPar7.setToolTipText(toolTipPar7);
530 txtPar7 = new JTextField();
531 txtPar7.setToolTipText(toolTipPar7);
532 txtPar7.setPreferredSize(strFieldSize);
533 txtPar7.getDocument().addDocumentListener(fieldListener);
534 mapKeyFieldToValueField.put(keyPar7.toUpperCase(),txtPar7);
535 linePar7.add(lblPar7);
536 linePar7.add(txtPar7);
538
539 String toolTipPar8 = "Specifies the maximum number of generation.";
540 linePar8 = new JPanel(new FlowLayout(FlowLayout.LEFT));
541 lblPar8 = new JLabel("Max. number of generations:", SwingConstants.LEFT);
542 lblPar8.setPreferredSize(fileLabelSize);
543 lblPar8.setToolTipText(toolTipPar8);
544 txtPar8 = new JTextField();
545 txtPar8.setToolTipText(toolTipPar8);
546 txtPar8.setPreferredSize(strFieldSize);
547 txtPar8.getDocument().addDocumentListener(fieldListener);
548 mapKeyFieldToValueField.put(keyPar8.toUpperCase(),txtPar8);
549 linePar8.add(lblPar8);
550 linePar8.add(txtPar8);
552
553 String toolTipPar9 = "Specifies the convergence criterion as number of subsequent identical generations.";
554 linePar9 = new JPanel(new FlowLayout(FlowLayout.LEFT));
555 lblPar9 = new JLabel("Max. stagnating generations:", SwingConstants.LEFT);
556 lblPar9.setPreferredSize(fileLabelSize);
557 lblPar9.setToolTipText(toolTipPar9);
558 txtPar9 = new JTextField();
559 txtPar9.setToolTipText(toolTipPar9);
560 txtPar9.setPreferredSize(strFieldSize);
561 txtPar9.getDocument().addDocumentListener(fieldListener);
562 mapKeyFieldToValueField.put(keyPar9.toUpperCase(),txtPar9);
563 linePar9.add(lblPar9);
564 linePar9.add(txtPar9);
566
567 localBlock2.add(new JSeparator());
568
569 lineGrowthPropMode = new JPanel(new FlowLayout(FlowLayout.LEFT));
570 lblGrowthPropMode = new JLabel("Graph growth controlled by: ");
571 bgGrowthMode = new ButtonGroup();
572 rbtLevelGrowth = new JRadioButton("graph deepness (level)");
573 rbtLevelGrowth.setSelected(true);
574 rbtLevelGrowth.addActionListener(new ActionListener(){
575 public void actionPerformed(ActionEvent e){
576 if (rbtLevelGrowth.isSelected())
577 {
578 localBlockLvlProbAll.setVisible(true);
579 localBlockMolSzAll.setVisible(false);
580 }
581 }
582 });
583 rbtLevelGrowth.addChangeListener(rdbFieldChange);
584 rbtMolSzGrowth = new JRadioButton("molecular size (heavy atoms count)");
585 rbtMolSzGrowth.addActionListener(new ActionListener(){
586 public void actionPerformed(ActionEvent e){
587 if (rbtMolSzGrowth.isSelected())
588 {
589 localBlockLvlProbAll.setVisible(false);
590 localBlockMolSzAll.setVisible(true);
591 }
592 }
593 });
594 rbtMolSzGrowth.addChangeListener(rdbFieldChange);
601
602 String toolTipPar12 = "<html>Specifies the value of the factor used in"
603 + " growth probability schemes <code>"
604 + ProbabilityFuncitonShape.EXP_DIFF + "</code> and "
605 + "<code>"
606 + ProbabilityFuncitonShape.TANH + "</code></html>";
607 linePar12 = new JPanel(new FlowLayout(FlowLayout.LEFT));
608 lblPar12 = new JLabel("<html>Graph growth by level - parameter "
609 + "<code>&lambda;</code><html>", SwingConstants.LEFT);
610 lblPar12.setPreferredSize(fileLabelSize);
611 lblPar12.setToolTipText(toolTipPar12);
612 spnPar12 = new JSpinner(new SpinnerNumberModel(1.0, 0.0, null, 0.1));
613 spnPar12.setToolTipText(toolTipPar12);
614 spnPar12.setPreferredSize(strFieldSize);
615 mapKeyFieldToValueField.put(keyPar12.toUpperCase(),spnPar12);
616 linePar12.add(lblPar12);
617 linePar12.add(spnPar12);
619
620 String toolTipPar13 = "<html>Specifies the value of parameter "
621 + "&sigma;<sub>1</sub> used for growth probability scheme"
622 + " <code>"
623 + ProbabilityFuncitonShape.SIGMA
624 + "</code>.<br>It corresponds to the steepness of"
625 + " the function where <i>P(level) = 50%</i></html>";
626 linePar13 = new JPanel(new FlowLayout(FlowLayout.LEFT));
627 lblPar13 = new JLabel("<html>Graph growth by level - parameter "
628 + "<code>&sigma;</code><sub>1</sub>:</html>",
629 SwingConstants.LEFT);
630 lblPar13.setPreferredSize(fileLabelSize);
631 lblPar13.setToolTipText(toolTipPar13);
632 spnPar13 = new JSpinner(new SpinnerNumberModel(1.0, null, null, 0.1));
633 spnPar13.setToolTipText(toolTipPar13);
634 spnPar13.setPreferredSize(strFieldSize);
635 mapKeyFieldToValueField.put(keyPar13.toUpperCase(),spnPar13);
636 linePar13.add(lblPar13);
637 linePar13.add(spnPar13);
639
640 String toolTipPar14 = "<html>Specifies the value of parameter "
641 + "&sigma;<sub>2</sub> used in growth probability scheme "
642 + "<code>"
643 + ProbabilityFuncitonShape.SIGMA
644 + "</code>.<br>It corresponds to the level "
645 + "where <i>P(level) = 50%</i></html>";
646 linePar14 = new JPanel(new FlowLayout(FlowLayout.LEFT));
647 lblPar14 = new JLabel("<html>Graph growth by level - parameter "
648 + "<code>&sigma;</code><sub>2</sub>:<html>",
649 SwingConstants.LEFT);
650 lblPar14.setPreferredSize(fileLabelSize);
651 lblPar14.setToolTipText(toolTipPar14);
652 spnPar14 = new JSpinner(new SpinnerNumberModel(3.5, null, null, 0.1));
653 spnPar14.setToolTipText(toolTipPar14);
654 spnPar14.setPreferredSize(strFieldSize);
655 mapKeyFieldToValueField.put(keyPar14.toUpperCase(),spnPar14);
656 linePar14.add(lblPar14);
657 linePar14.add(spnPar14);
659
660 String toolTipPar11 = "Specifies the growth probability scheme";
661 linePar11 = new JPanel(new FlowLayout(FlowLayout.LEFT));
662 lblPar11 = new JLabel("Graph extension probability function:",
663 SwingConstants.LEFT);
664 lblPar11.setPreferredSize(fileLabelSize);
665 lblPar11.setToolTipText(toolTipPar11);
666 cmbPar11 = new JComboBox<ProbabilityFuncitonShape>(
667 ProbabilityFuncitonShape.values());
669 cmbPar11.setToolTipText(toolTipPar11);
670 cmbPar11.addActionListener(cmbFieldChange);
671 mapKeyFieldToValueField.put(keyPar11.toUpperCase(),cmbPar11);
672
673 // NB: we need to create the graph before setting the action listeners
674 // that will eventually edit the data plotted.
676
677 graphLvlProbJFChartCtrlPanel = new JPanel(new BorderLayout());
678 graphLvlProbJFChartCtrlPanel.setMaximumSize(new Dimension(100,100));
679 graphLvlProbSpinnerPane = new JPanel(new GridLayout(0,2));
680 final JSpinner spnMaxLev = new JSpinner(new SpinnerNumberModel(
681 maxLevelProbPlot.intValue(), 1, null, 1));
682 spnMaxLev.addChangeListener(new ChangeListener()
683 {
684 @Override
685 public void stateChanged(ChangeEvent event)
686 {
687 int maxLev = ((Integer) spnMaxLev.getValue()).intValue();
688 ((XYPlot) graphLvlProbJFChart.getPlot())
689 .getDomainAxis().setRange(minLevelProbPlot, maxLev);
690 }
691 });
692 graphLvlProbSpinnerPane.add(new JLabel("X-axis max: "));
693 graphLvlProbSpinnerPane.add(spnMaxLev);
695
696 GroupLayout grpLyoSubPrb = new GroupLayout(localBlockLvlProbGraph);
697 localBlockLvlProbGraph.setLayout(grpLyoSubPrb);
698 grpLyoSubPrb.setAutoCreateGaps(true);
699 grpLyoSubPrb.setAutoCreateContainerGaps(true);
700 grpLyoSubPrb.setHorizontalGroup(grpLyoSubPrb.createSequentialGroup()
701 .addComponent(graphLvlProbJFChartChartPanel)
702 .addComponent(graphLvlProbJFChartCtrlPanel));
703 grpLyoSubPrb.setVerticalGroup(grpLyoSubPrb.createParallelGroup(
704 GroupLayout.Alignment.CENTER)
705 .addComponent(graphLvlProbJFChartChartPanel)
706 .addComponent(graphLvlProbJFChartCtrlPanel));
707
708 // NB: The listeners must be defined here because we first have to
709 // built all the pieces (plot + parameters) and then define how
710 // things change upon change of the parameters/controllers.
711
712 spnPar12.addChangeListener(new ChangeListener()
713 {
714 public void stateChanged(ChangeEvent event)
715 {
717 }
718 });
719 spnPar13.addChangeListener(new ChangeListener()
720 {
721 public void stateChanged(ChangeEvent event)
722 {
724 }
725 });
726 spnPar14.addChangeListener(new ChangeListener()
727 {
728 public void stateChanged(ChangeEvent event)
729 {
731 }
732 });
733
734 cmbPar11.addActionListener(new ActionListener(){
735 public void actionPerformed(ActionEvent e){
736 switch (ProbabilityFuncitonShape.valueOf(
737 cmbPar11.getSelectedItem().toString()))
738 {
739 case EXP_DIFF:
741 localBlockLvlProb3.setVisible(true);
742 localBlockLvlProb4.setVisible(false);
743 localBlockLvlProbGraph.setVisible(true);
744 break;
745
746 case TANH:
748 localBlockLvlProb3.setVisible(true);
749 localBlockLvlProb4.setVisible(false);
750 localBlockLvlProbGraph.setVisible(true);
751 break;
752
753 case SIGMA:
755 localBlockLvlProb3.setVisible(false);
756 localBlockLvlProb4.setVisible(true);
757 localBlockLvlProbGraph.setVisible(true);
758 break;
759
760 default:
761 localBlockLvlProb3.setVisible(false);
762 localBlockLvlProb4.setVisible(false);
763 localBlockLvlProbGraph.setVisible(false);
764 break;
765 }
766 }
767 });
768 linePar11.add(lblPar11);
769 linePar11.add(cmbPar11);
775
776 String toolTipParMolSz2 = "<html>Specifies the value of the factor used in"
777 + " molecular growth probability schemes <code>"
778 + ProbabilityFuncitonShape.EXP_DIFF + "</code> and "
779 + "<code>"
780 + ProbabilityFuncitonShape.TANH + "</code></html>";
781 lineParMolSz2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
782 lblParMolSz2 = new JLabel("<html>Mol growth probability - parameter "
783 + "<code>&lambda;</code><html>", SwingConstants.LEFT);
784 lblParMolSz2.setPreferredSize(fileLabelSize);
785 lblParMolSz2.setToolTipText(toolTipParMolSz2);
786 spnParMolSz2 = new JSpinner(new SpinnerNumberModel(1.0, 0.0, null, 0.1));
787 spnParMolSz2.setToolTipText(toolTipParMolSz2);
788 spnParMolSz2.setPreferredSize(strFieldSize);
793
794 String toolTipParMolSz3 = "<html>Specifies the value of parameter "
795 + "&sigma;<sub>1</sub> used for molecular growth probability "
796 + "scheme"
797 + " <code>"
798 + ProbabilityFuncitonShape.SIGMA
799 + "</code>.<br>It corresponds to the steepness of"
800 + " the function where <i>P(level) = 50%</i></html>";
801 lineParMolSz3 = new JPanel(new FlowLayout(FlowLayout.LEFT));
802 lblParMolSz3 = new JLabel("<html>Mol growth probability - parameter "
803 + "<code>&sigma;</code><sub>1</sub>:</html>", SwingConstants.LEFT);
804 lblParMolSz3.setPreferredSize(fileLabelSize);
805 lblParMolSz3.setToolTipText(toolTipParMolSz3);
806 spnParMolSz3 = new JSpinner(new SpinnerNumberModel(0.2, null, null, 0.1));
807 spnParMolSz3.setToolTipText(toolTipParMolSz3);
808 spnParMolSz3.setPreferredSize(strFieldSize);
813
814 String toolTipParMolSz4 = "<html>Specifies the value of parameter "
815 + "&sigma;<sub>2</sub> used in molecular growth probability "
816 + "scheme "
817 + "<code>"
818 + ProbabilityFuncitonShape.SIGMA
819 + "</code>.<br>It corresponds to the level "
820 + "where <i>P(level) = 50%</i></html>";
821 lineParMolSz4 = new JPanel(new FlowLayout(FlowLayout.LEFT));
822 lblParMolSz4 = new JLabel("<html>Mol growth probability - parameter "
823 + "<code>&sigma;</code><sub>2</sub>:<html>", SwingConstants.LEFT);
824 lblParMolSz4.setPreferredSize(fileLabelSize);
825 lblParMolSz4.setToolTipText(toolTipParMolSz4);
826 spnParMolSz4 = new JSpinner(new SpinnerNumberModel(25.0, null, null, 1.0));
827 spnParMolSz4.setToolTipText(toolTipParMolSz4);
828 spnParMolSz4.setPreferredSize(strFieldSize);
833
834 String toolTipParMolSz1 = "Specifies the molecular growth probability scheme";
835 lineParMolSz1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
836 lblParMolSz1 = new JLabel("Mol growth probability function:",
837 SwingConstants.LEFT);
838 lblParMolSz1.setPreferredSize(fileLabelSize);
839 lblParMolSz1.setToolTipText(toolTipParMolSz1);
840 cmbParMolSz1 = new JComboBox<ProbabilityFuncitonShape>(
841 ProbabilityFuncitonShape.values());
843 cmbParMolSz1.setToolTipText(toolTipParMolSz1);
844 cmbParMolSz1.addActionListener(cmbFieldChange);
846
847 // NB: we need to create the graph before setting the action listeners
848 // that will eventually edit the data plotted.
850
851 graphMolSzProbJFChartCtrlPanel = new JPanel(new BorderLayout());
852 graphMolSzProbJFChartCtrlPanel.setMaximumSize(new Dimension(100,100));
853 graphMolSzProbSpinnerPane = new JPanel(new GridLayout(0,2));
854 final JSpinner spnMaxLevMolSz = new JSpinner(new SpinnerNumberModel(
855 maxMolSizeProbPlot.intValue(), 1, null, 1));
856 spnMaxLevMolSz.addChangeListener(new ChangeListener()
857 {
858 @Override
859 public void stateChanged(ChangeEvent event)
860 {
861 int maxLev = ((Integer) spnMaxLevMolSz.getValue()).intValue();
862 ((XYPlot) graphMolSzProbJFChart.getPlot())
863 .getDomainAxis().setRange(minMolSizeProbPlot, maxLev);
864 }
865 });
866 graphMolSzProbSpinnerPane.add(new JLabel("X-axis max: "));
867 graphMolSzProbSpinnerPane.add(spnMaxLevMolSz);
869
870 GroupLayout grpLyoMolSzProb = new GroupLayout(localBlockMolSzGraph);
871 localBlockMolSzGraph.setLayout(grpLyoMolSzProb);
872 grpLyoMolSzProb.setAutoCreateGaps(true);
873 grpLyoMolSzProb.setAutoCreateContainerGaps(true);
874 grpLyoMolSzProb.setHorizontalGroup(grpLyoMolSzProb.createSequentialGroup()
876 .addComponent(graphMolSzProbJFChartCtrlPanel));
877 grpLyoMolSzProb.setVerticalGroup(grpLyoMolSzProb.createParallelGroup(
878 GroupLayout.Alignment.CENTER)
880 .addComponent(graphMolSzProbJFChartCtrlPanel));
881
882 // NB: The listeners must be defined here because we first have to
883 // built all the pieces (plot + parameters) and then define how
884 // things change upon change of the parameters/controllers.
885
886 spnParMolSz2.addChangeListener(new ChangeListener()
887 {
888 public void stateChanged(ChangeEvent event)
889 {
891 }
892 });
893 spnParMolSz3.addChangeListener(new ChangeListener()
894 {
895 public void stateChanged(ChangeEvent event)
896 {
898 }
899 });
900 spnParMolSz4.addChangeListener(new ChangeListener()
901 {
902 public void stateChanged(ChangeEvent event)
903 {
905 }
906 });
907
908 cmbParMolSz1.addActionListener(new ActionListener(){
909 public void actionPerformed(ActionEvent e){
910 switch (ProbabilityFuncitonShape.valueOf(
911 cmbParMolSz1.getSelectedItem().toString()))
912 {
913 case EXP_DIFF:
915 localBlockMolSz3.setVisible(true);
916 localBlockMolSz4.setVisible(false);
917 localBlockMolSzGraph.setVisible(true);
918 break;
919
920 case TANH:
922 localBlockMolSz3.setVisible(true);
923 localBlockMolSz4.setVisible(false);
924 localBlockMolSzGraph.setVisible(true);
925 break;
926
927 case SIGMA:
929 localBlockMolSz3.setVisible(false);
930 localBlockMolSz4.setVisible(true);
931 localBlockMolSzGraph.setVisible(true);
932 break;
933
934 case UNRESTRICTED:
936 localBlockMolSz3.setVisible(false);
937 localBlockMolSz4.setVisible(false);
938 localBlockMolSzGraph.setVisible(true);
939 break;
940
941 default:
942 localBlockMolSz3.setVisible(false);
943 localBlockMolSz4.setVisible(false);
944 localBlockMolSzGraph.setVisible(false);
945 break;
946 }
947 }
948 });
955
957
958 localBlock2.add(new JSeparator());
959
960 String toolTipParCrowd2 = "<html>Specifies the value of the factor used in"
961 + " crowding probability schemes <code>"
962 + ProbabilityFuncitonShape.EXP_DIFF
963 + "</code> and "
964 + "<code>"
965 + ProbabilityFuncitonShape.TANH
966 + "</code></html>";
967 lineParCrowd2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
968 lblParCrowd2 = new JLabel("<html>Crowding probability - parameter "
969 + "<code>&lambda;</code><html>", SwingConstants.LEFT);
970 lblParCrowd2.setPreferredSize(fileLabelSize);
971 lblParCrowd2.setToolTipText(toolTipParCrowd2);
972 spnParCrowd2 = new JSpinner(new SpinnerNumberModel(1.0, 0.0, null, 0.1));
973 spnParCrowd2.setToolTipText(toolTipParCrowd2);
974 spnParCrowd2.setPreferredSize(strFieldSize);
979
980 String toolTipParCrowd3 = "<html>Specifies the value of parameter "
981 + "&sigma;<sub>1</sub> used for crowding probability scheme"
982 + " <code>"
983 + ProbabilityFuncitonShape.SIGMA
984 + "</code>.<br>It corresponds to the steepness of"
985 + " the function where <i>P(level) = 50%</i></html>";
986 lineParCrowd3 = new JPanel(new FlowLayout(FlowLayout.LEFT));
987 lblParCrowd3 = new JLabel("<html>Crowding probability - parameter "
988 + "<code>&sigma;</code><sub>1</sub>:</html>", SwingConstants.LEFT);
989 lblParCrowd3.setPreferredSize(fileLabelSize);
990 lblParCrowd3.setToolTipText(toolTipParCrowd3);
991 spnParCrowd3 = new JSpinner(new SpinnerNumberModel(1.0, null, null, 0.1));
992 spnParCrowd3.setToolTipText(toolTipParCrowd3);
993 spnParCrowd3.setPreferredSize(strFieldSize);
998
999 String toolTipParCrowd4 = "<html>Specifies the value of parameter "
1000 + "&sigma;<sub>2</sub> used in crowding probability scheme "
1001 + "<code>"
1002 + ProbabilityFuncitonShape.SIGMA
1003 + "</code>.<br>It corresponds to the level "
1004 + "where <i>P(level) = 50%</i></html>";
1005 lineParCrowd4 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1006 lblParCrowd4 = new JLabel("<html>Crowding probability - parameter "
1007 + "<code>&sigma;</code><sub>2</sub>:<html>", SwingConstants.LEFT);
1008 lblParCrowd4.setPreferredSize(fileLabelSize);
1009 lblParCrowd4.setToolTipText(toolTipParCrowd4);
1010 spnParCrowd4 = new JSpinner(new SpinnerNumberModel(3.5, null, null, 0.1));
1011 spnParCrowd4.setToolTipText(toolTipParCrowd4);
1012 spnParCrowd4.setPreferredSize(strFieldSize);
1017
1018 String toolTipParCrowd1 = "Specifies the crowding probability scheme";
1019 lineParCrowd1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1020 lblParCrowd1 = new JLabel("Crowding probability function:",
1021 SwingConstants.LEFT);
1022 lblParCrowd1.setPreferredSize(fileLabelSize);
1023 lblParCrowd1.setToolTipText(toolTipParCrowd1);
1024 cmbParCrowd1 = new JComboBox<ProbabilityFuncitonShape>(
1025 ProbabilityFuncitonShape.values());
1027 cmbParCrowd1.setToolTipText(toolTipParCrowd1);
1028 cmbParCrowd1.addActionListener(cmbFieldChange);
1030
1031 // NB: we need to create the graph before setting the action listeners
1032 // that will eventually edit the data plotted.
1034
1035 graphCrowdProbJFChartCtrlPanel = new JPanel(new BorderLayout());
1036 graphCrowdProbJFChartCtrlPanel.setMaximumSize(new Dimension(100,100));
1037 graphCrowdProbSpinnerPane = new JPanel(new GridLayout(0,2));
1038 final JSpinner spnMaxLevCrowd = new JSpinner(new SpinnerNumberModel(
1039 maxLevelCrowdProbPlot.intValue(), 1, null, 1));
1040 spnMaxLevCrowd.addChangeListener(new ChangeListener()
1041 {
1042 @Override
1043 public void stateChanged(ChangeEvent event)
1044 {
1045 int maxLev = ((Integer) spnMaxLevCrowd.getValue()).intValue();
1046 ((XYPlot) graphCrowdProbJFChart.getPlot())
1047 .getDomainAxis().setRange(minLevelCrowdProbPlot, maxLev);
1048 }
1049 });
1050 graphCrowdProbSpinnerPane.add(new JLabel("X-axis max: "));
1051 graphCrowdProbSpinnerPane.add(spnMaxLevCrowd);
1053
1054 GroupLayout grpLyoCrowdProb = new GroupLayout(localBlockCrowdGraph);
1055 localBlockCrowdGraph.setLayout(grpLyoCrowdProb);
1056 grpLyoCrowdProb.setAutoCreateGaps(true);
1057 grpLyoCrowdProb.setAutoCreateContainerGaps(true);
1058 grpLyoCrowdProb.setHorizontalGroup(grpLyoCrowdProb.createSequentialGroup()
1059 .addComponent(graphCrowdProbJFChartChartPanel)
1060 .addComponent(graphCrowdProbJFChartCtrlPanel));
1061 grpLyoCrowdProb.setVerticalGroup(grpLyoCrowdProb.createParallelGroup(
1062 GroupLayout.Alignment.CENTER)
1063 .addComponent(graphCrowdProbJFChartChartPanel)
1064 .addComponent(graphCrowdProbJFChartCtrlPanel));
1065
1066 // NB: The listeners must be defined here because we first have to
1067 // built all the pieces (plot + parameters) and then define how
1068 // things change upon change of the parameters/controllers.
1069
1070 spnParCrowd2.addChangeListener(new ChangeListener()
1071 {
1072 public void stateChanged(ChangeEvent event)
1073 {
1075 }
1076 });
1077 spnParCrowd3.addChangeListener(new ChangeListener()
1078 {
1079 public void stateChanged(ChangeEvent event)
1080 {
1082 }
1083 });
1084 spnParCrowd4.addChangeListener(new ChangeListener()
1085 {
1086 public void stateChanged(ChangeEvent event)
1087 {
1089 }
1090 });
1091
1092 cmbParCrowd1.addActionListener(new ActionListener(){
1093 public void actionPerformed(ActionEvent e){
1094 String scheme = cmbParCrowd1.getSelectedItem().toString();
1095 switch (ProbabilityFuncitonShape.valueOf(scheme))
1096 {
1097 case EXP_DIFF:
1099 localBlockCrowd3.setVisible(true);
1100 localBlockCrowd4.setVisible(false);
1101 localBlockCrowdGraph.setVisible(true);
1102 break;
1103
1104 case TANH:
1106 localBlockCrowd3.setVisible(true);
1107 localBlockCrowd4.setVisible(false);
1108 localBlockCrowdGraph.setVisible(true);
1109 break;
1110
1111 case SIGMA:
1113 localBlockCrowd3.setVisible(false);
1114 localBlockCrowd4.setVisible(true);
1115 localBlockCrowdGraph.setVisible(true);
1116 break;
1117
1118 case UNRESTRICTED:
1120 localBlockCrowd3.setVisible(false);
1121 localBlockCrowd4.setVisible(false);
1122 localBlockCrowdGraph.setVisible(true);
1123 break;
1124
1125 default:
1126 localBlockCrowd3.setVisible(false);
1127 localBlockCrowd4.setVisible(false);
1128 localBlockCrowdGraph.setVisible(false);
1129 break;
1130 }
1131 }
1132 });
1139
1140 localBlock2.add(new JSeparator());
1141
1142 String toolTipPar15 = "<html>Specifies the strategy for selecting crossover partners.<ul>"
1143 + "<li><code>RANDOM</code>: unbiased selection.</li>"
1144 + "<li><code>TS</code>: Tournament.</li>"
1145 + "<li><code>RW</code>: Roulette Wheel.</li>"
1146 + "<li><code>SUS</code>: Stochastic Universal Sampling.</li>"
1147 + "</ul></html>";
1148 linePar15 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1149 lblPar15 = new JLabel("Parent selection algorithm:", SwingConstants.LEFT);
1150 lblPar15.setPreferredSize(fileLabelSize);
1151 lblPar15.setToolTipText(toolTipPar15);
1152 cmbPar15 = new JComboBox<String>(new String[] {"RANDOM", "TS", "RW", "SUS"});
1153 cmbPar15.setToolTipText(toolTipPar15);
1154 cmbPar15.addActionListener(cmbFieldChange);
1155 mapKeyFieldToValueField.put(keyPar15.toUpperCase(),cmbPar15);
1156 linePar15.add(lblPar15);
1157 linePar15.add(cmbPar15);
1159
1160 String toolTipPar16 = "<html>Specifies the relative weight of "
1161 + "crossover operations.</html>";
1162 linePar16 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1163 lblPar16 = new JLabel("Crossover weight:", SwingConstants.LEFT);
1164 lblPar16.setPreferredSize(fileLabelSize);
1165 lblPar16.setToolTipText(toolTipPar16);
1166 txtPar16 = new JTextField();
1167 txtPar16.setToolTipText(toolTipPar16);
1168 txtPar16.setPreferredSize(strFieldSize);
1169 txtPar16.getDocument().addDocumentListener(fieldListener);
1170 mapKeyFieldToValueField.put(keyPar16.toUpperCase(),txtPar16);
1171 linePar16.add(lblPar16);
1172 linePar16.add(txtPar16);
1174
1175 String toolTipPar17 = "<html>Specifies the relative weight of "
1176 + "mutation operations.</html>";
1177 linePar17 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1178 lblPar17 = new JLabel("Mutation weight:", SwingConstants.LEFT);
1179 lblPar17.setPreferredSize(fileLabelSize);
1180 lblPar17.setToolTipText(toolTipPar17);
1181 txtPar17 = new JTextField();
1182 txtPar17.setToolTipText(toolTipPar17);
1183 txtPar17.setPreferredSize(strFieldSize);
1184 txtPar17.getDocument().addDocumentListener(fieldListener);
1185 mapKeyFieldToValueField.put(keyPar17.toUpperCase(),txtPar17);
1186 linePar17.add(lblPar17);
1187 linePar17.add(txtPar17);
1189
1190 String toolTipParWC = "<html>Specifies the relative weight of "
1191 + "construction from scratch.</html>";
1192 lineParWC = new JPanel(new FlowLayout(FlowLayout.LEFT));
1193 lblParWC = new JLabel("Construction weight:", SwingConstants.LEFT);
1194 lblParWC.setPreferredSize(fileLabelSize);
1195 lblParWC.setToolTipText(toolTipParWC);
1196 txtParWC = new JTextField();
1197 txtParWC.setToolTipText(toolTipParWC);
1198 txtParWC.setPreferredSize(strFieldSize);
1199 txtParWC.getDocument().addDocumentListener(fieldListener);
1200 mapKeyFieldToValueField.put(keyParWC.toUpperCase(),txtParWC);
1201 lineParWC.add(lblParWC);
1202 lineParWC.add(txtParWC);
1204
1205 String toolTipPar18 = "Specifies the probability (0.0-1.0) of symmetric operations.";
1206 linePar18 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1207 lblPar18 = new JLabel("Symmetric operation probability:", SwingConstants.LEFT);
1208 lblPar18.setPreferredSize(fileLabelSize);
1209 lblPar18.setToolTipText(toolTipPar18);
1210 txtPar18 = new JTextField();
1211 txtPar18.setToolTipText(toolTipPar18);
1212 txtPar18.setPreferredSize(strFieldSize);
1213 txtPar18.getDocument().addDocumentListener(fieldListener);
1214 mapKeyFieldToValueField.put(keyPar18.toUpperCase(),txtPar18);
1215 linePar18.add(lblPar18);
1216 linePar18.add(txtPar18);
1218
1219 String toolTipPar19 = "Specifies the population members replacement strategy.";
1220 linePar19 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1221 lblPar19 = new JLabel("Population update mode:", SwingConstants.LEFT);
1222 lblPar19.setPreferredSize(fileLabelSize);
1223 lblPar19.setToolTipText(toolTipPar19);
1224 cmbPar19 = new JComboBox<String>(new String[] {"ELITIST", "NONE"});
1225 cmbPar19.setToolTipText(toolTipPar19);
1226 cmbPar19.addActionListener(cmbFieldChange);
1227 mapKeyFieldToValueField.put(keyPar19.toUpperCase(),cmbPar19);
1228 linePar19.add(lblPar19);
1229 linePar19.add(cmbPar19);
1231
1232 String toolTipPar24 = "Specifies the maximum number of parallel candidate evaluation tasks.";
1233 linePar24 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1234 lblPar24 = new JLabel("Number of parallel evaluation tasks:", SwingConstants.LEFT);
1235 lblPar24.setPreferredSize(fileLabelSize);
1236 lblPar24.setToolTipText(toolTipPar24);
1237 txtPar24 = new JTextField();
1238 txtPar24.setToolTipText(toolTipPar24);
1239 txtPar24.setPreferredSize(strFieldSize);
1240 txtPar24.getDocument().addDocumentListener(fieldListener);
1241 mapKeyFieldToValueField.put(keyPar24.toUpperCase(),txtPar24);
1242 linePar24.add(lblPar24);
1243 linePar24.add(txtPar24);
1245
1246 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>";
1247 linePar25 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1248 lblPar25 = new JLabel("Task parallelization scheme:", SwingConstants.LEFT);
1249 lblPar25.setPreferredSize(fileLabelSize);
1250 lblPar25.setToolTipText(toolTipPar25);
1251 cmbPar25 = new JComboBox<String>(new String[] {"Synchronous", "Asynchronous"});
1252 cmbPar25.setToolTipText(toolTipPar25);
1253 cmbPar25.addActionListener(cmbFieldChange);
1254 mapKeyFieldToValueField.put(keyPar25.toUpperCase(),cmbPar25);
1255 linePar25.add(lblPar25);
1256 linePar25.add(cmbPar25);
1258
1259 // From here it's all about advanced options
1260
1261 String toolTipParMSM = "<html>Specifies the relative weight of "
1262 + "multi-site mutation operations "
1263 + "(comma- or space-separated list).</html>";
1264 lineParMSM = new JPanel(new FlowLayout(FlowLayout.LEFT));
1265 lblParMSM = new JLabel("Multi-site mutation weight:", SwingConstants.LEFT);
1266 lblParMSM.setPreferredSize(fileLabelSize);
1267 lblParMSM.setToolTipText(toolTipParMSM);
1268 txtParMSM = new JTextField();
1269 txtParMSM.setToolTipText(toolTipParMSM);
1270 txtParMSM.setPreferredSize(strFieldSize);
1271 txtParMSM.getDocument().addDocumentListener(fieldListener);
1272 mapKeyFieldToValueField.put(keyParMSM.toUpperCase(),txtParMSM);
1273 lineParMSM.add(lblParMSM);
1274 lineParMSM.add(txtParMSM);
1276
1277 String toolTipPar3 = "Specifies the seed number used by the random number generator";
1278 linePar3 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1279 lblPar3 = new JLabel("Random Seed:", SwingConstants.LEFT);
1280 lblPar3.setPreferredSize(fileLabelSize);
1281 lblPar3.setToolTipText(toolTipPar3);
1282 txtPar3 = new JTextField();
1283 txtPar3.setToolTipText(toolTipPar3);
1284 txtPar3.setPreferredSize(new Dimension(150,preferredHeight));
1285 txtPar3.getDocument().addDocumentListener(fieldListener);
1286 mapKeyFieldToValueField.put(keyPar3.toUpperCase(),txtPar3);
1287 linePar3.add(lblPar3);
1288 linePar3.add(txtPar3);
1290
1291 String toolTipPar1 = "Specifies the number of figures used to report the fitness";
1292 linePar1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1293 lblPar1 = new JLabel("Precision of fitness value:", SwingConstants.LEFT);
1294 lblPar1.setPreferredSize(fileLabelSize);
1295 lblPar1.setToolTipText(toolTipPar1);
1296 txtPar1 = new JTextField();
1297 txtPar1.setToolTipText(toolTipPar1);
1298 txtPar1.setPreferredSize(strFieldSize);
1299 txtPar1.getDocument().addDocumentListener(fieldListener);
1300 mapKeyFieldToValueField.put(keyPar1.toUpperCase(),txtPar1);
1301 linePar1.add(lblPar1);
1302 linePar1.add(txtPar1);
1304
1305 String toolTipPar2 = "Specifies the amount of log produced.";
1306 linePar2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1307 lblPar2 = new JLabel("Verbosity of GA modules:", SwingConstants.LEFT);
1308 lblPar2.setPreferredSize(fileLabelSize);
1309 lblPar2.setToolTipText(toolTipPar2);
1310 cmbPar2 = new JComboBox<String>(new String[] {"-3", "-2", "-1", "0", "1", "2", "3"});
1311 cmbPar2.setToolTipText(toolTipPar2);
1312 cmbPar2.setSelectedItem("0");
1313 cmbPar2.addActionListener(cmbFieldChange);
1314 mapKeyFieldToValueField.put(keyPar2.toUpperCase(),cmbPar2);
1315 linePar2.add(lblPar2);
1316 linePar2.add(cmbPar2);
1318
1319 String toolTipPar5 = "Specifies whether the candidates should be reported in descending or ascending order of fitness.";
1320 linePar5 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1321 rdbPar5 = new JRadioButton("Sort by descending fitness");
1322 rdbPar5.setToolTipText(toolTipPar5);
1323 rdbPar5.addChangeListener(rdbFieldChange);
1324 mapKeyFieldToValueField.put(keyPar5.toUpperCase(),rdbPar5);
1325 linePar5.add(rdbPar5);
1327
1328 String toolTipPar5a = "Specifies whether a NaN fitness value should stop the design experiment.";
1329 linePar5a = new JPanel(new FlowLayout(FlowLayout.LEFT));
1330 rdbPar5a = new JRadioButton("Kill experiment on NaN fitness");
1331 rdbPar5a.setToolTipText(toolTipPar5a);
1332 rdbPar5a.addChangeListener(rdbFieldChange);
1333 mapKeyFieldToValueField.put(keyPar5a.toUpperCase(),rdbPar5a);
1334 linePar5a.add(rdbPar5a);
1336
1337 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>";
1338 linePar10 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1339 lblPar10 = new JLabel("Max tries to get new graph:", SwingConstants.LEFT);
1340 lblPar10.setPreferredSize(fileLabelSize);
1341 lblPar10.setToolTipText(toolTipPar10);
1342 txtPar10 = new JTextField();
1343 txtPar10.setToolTipText(toolTipPar10);
1344 txtPar10.setPreferredSize(strFieldSize);
1345 txtPar10.getDocument().addDocumentListener(fieldListener);
1346 mapKeyFieldToValueField.put(keyPar10.toUpperCase(),txtPar10);
1347 linePar10.add(lblPar10);
1348 linePar10.add(txtPar10);
1350
1351
1352 advOptsBlock.add(new JSeparator());
1353
1354
1355 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>";
1356 lineMolToGraph = new JPanel(new FlowLayout(FlowLayout.LEFT));
1357 lblMolToGraph = new JLabel("Initial population from screening:", SwingConstants.LEFT);
1358 lblMolToGraph.setPreferredSize(fileLabelSize);
1359 lblMolToGraph.setToolTipText(toolMolToGraph);
1360 txtMolToGraph = new JTextField();
1361 txtMolToGraph.setToolTipText(toolMolToGraph);
1362 txtMolToGraph.setPreferredSize(fileFieldSize);
1363 txtMolToGraph.getDocument().addDocumentListener(fieldListener);
1364 txtMolToGraph.getDocument().addDocumentListener(new DocumentListener() {
1365 public void changedUpdate(DocumentEvent e) {
1366 if (txtMolToGraph.getText().isBlank())
1367 {
1368 txtFrgMols.setEnabled(false);
1369 btnFrgMols.setEnabled(false);
1370 rdbAddH.setEnabled(false);
1371 } else {
1372 txtFrgMols.setEnabled(true);
1373 btnFrgMols.setEnabled(true);
1374 rdbAddH.setEnabled(true);
1375 }
1376 }
1377 public void removeUpdate(DocumentEvent e) {
1378 if (txtMolToGraph.getText().isBlank())
1379 {
1380 txtFrgMols.setEnabled(false);
1381 btnFrgMols.setEnabled(false);
1382 rdbAddH.setEnabled(false);
1383 } else {
1384 txtFrgMols.setEnabled(true);
1385 btnFrgMols.setEnabled(true);
1386 rdbAddH.setEnabled(true);
1387 }
1388 }
1389 public void insertUpdate(DocumentEvent e) {
1390 if (txtMolToGraph.getText().isBlank())
1391 {
1392 txtFrgMols.setEnabled(false);
1393 btnFrgMols.setEnabled(false);
1394 rdbAddH.setEnabled(false);
1395 } else {
1396 txtFrgMols.setEnabled(true);
1397 btnFrgMols.setEnabled(true);
1398 rdbAddH.setEnabled(true);
1399 }
1400 }
1401 });
1403 btnMolToGraph = new JButton("Browse");
1404 btnMolToGraph.addActionListener(new ActionListener() {
1405 public void actionPerformed(ActionEvent e) {
1407 }
1408 });
1413
1414 String toolFrgMols = "<html>Specifies the pathname of a file containing the cutting rules to apply when converting molecules into graphs</html>";
1415 lineFrgMols = new JPanel(new FlowLayout(FlowLayout.LEFT));
1416 lblFrgMols = new JLabel("Mol-to-graph bond-cutting rules:", SwingConstants.LEFT);
1417 lblFrgMols.setPreferredSize(fileLabelSize);
1418 lblFrgMols.setToolTipText(toolFrgMols);
1419 txtFrgMols = new JTextField();
1420 txtFrgMols.setToolTipText(toolFrgMols);
1421 txtFrgMols.setPreferredSize(fileFieldSize);
1422 txtFrgMols.getDocument().addDocumentListener(fieldListener);
1423 txtFrgMols.setEnabled(false);
1424 mapKeyFieldToValueField.put(keyFrgMols.toUpperCase(), txtFrgMols);
1425 btnFrgMols = new JButton("Browse");
1426 btnFrgMols.addActionListener(new ActionListener() {
1427 public void actionPerformed(ActionEvent e) {
1429 }
1430 });
1431 btnFrgMols.setEnabled(false);
1436
1437 String toolAddH = "Specifies whether the to add explicit H atoms upon importing molecules to be fragmented.";
1438 lineAddH = new JPanel(new FlowLayout(FlowLayout.LEFT));
1439 rdbAddH = new JRadioButton("Add explicit H atoms");
1440 rdbAddH.setToolTipText(toolAddH);
1441 rdbAddH.addChangeListener(rdbFieldChange);
1442 rdbAddH.setEnabled(false);
1443 mapKeyFieldToValueField.put(keyAddH.toUpperCase(),rdbAddH);
1444 lineAddH.add(rdbAddH);
1446
1447
1448 advOptsBlock.add(new JSeparator());
1449
1450
1451 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>";
1452 linePar20 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1453 lblPar20 = new JLabel("Initial population file (SDF):", SwingConstants.LEFT);
1454 lblPar20.setPreferredSize(fileLabelSize);
1455 lblPar20.setToolTipText(toolTipPar20);
1456 txtPar20 = new JTextField();
1457 txtPar20.setToolTipText(toolTipPar20);
1458 txtPar20.setPreferredSize(fileFieldSize);
1459 txtPar20.getDocument().addDocumentListener(fieldListener);
1460 mapKeyFieldToValueField.put(keyPar20.toUpperCase(),txtPar20);
1461 btnPar20 = new JButton("Browse");
1462 btnPar20.addActionListener(new ActionListener() {
1463 public void actionPerformed(ActionEvent e) {
1465 }
1466 });
1467 linePar20.add(lblPar20);
1468 linePar20.add(txtPar20);
1469 linePar20.add(btnPar20);
1471
1472 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>";
1473 linePar21 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1474 lblPar21 = new JLabel("File with known UIDs:", SwingConstants.LEFT);
1475 lblPar21.setPreferredSize(fileLabelSize);
1476 lblPar21.setToolTipText(toolTipPar21);
1477 txtPar21 = new JTextField();
1478 txtPar21.setToolTipText(toolTipPar21);
1479 txtPar21.setPreferredSize(fileFieldSize);
1480 txtPar21.getDocument().addDocumentListener(fieldListener);
1481 mapKeyFieldToValueField.put(keyPar21.toUpperCase(),txtPar21);
1482 btnPar21 = new JButton("Browse");
1483 btnPar21.addActionListener(new ActionListener() {
1484 public void actionPerformed(ActionEvent e) {
1486 }
1487 });
1488 linePar21.add(lblPar21);
1489 linePar21.add(txtPar21);
1490 linePar21.add(btnPar21);
1492
1493 String toolTipPar22 = "Specifies the pathname of the file that will collect unique individual identification (UID) strings encountered during an evolutionary experiment.";
1494 linePar22 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1495 lblPar22 = new JLabel("File for new UIDs:", SwingConstants.LEFT);
1496 lblPar22.setPreferredSize(fileLabelSize);
1497 lblPar22.setToolTipText(toolTipPar22);
1498 txtPar22 = new JTextField();
1499 txtPar22.setToolTipText(toolTipPar22);
1500 txtPar22.setPreferredSize(fileFieldSize);
1501 txtPar22.getDocument().addDocumentListener(fieldListener);
1502 mapKeyFieldToValueField.put(keyPar22.toUpperCase(),txtPar22);
1503 btnPar22 = new JButton("Browse");
1504 btnPar22.addActionListener(new ActionListener() {
1505 public void actionPerformed(ActionEvent e) {
1507 }
1508 });
1509 linePar22.add(lblPar22);
1510 linePar22.add(txtPar22);
1511 linePar22.add(btnPar22);
1513
1514 advOptsBlock.add(new JSeparator());
1515
1516 String toolTipRingTmplsFrags = "<html>Specifies whether ring systems "
1517 + "should be extracted <br>"
1518 + "from generated graphs and stored as new general-"
1519 + "purpose building blocks."
1520 + "</html>";
1521 lineRingTmplsFrags = new JPanel(new FlowLayout(FlowLayout.LEFT));
1522 rdbRingTmplsFrags = new JRadioButton("Add new ring systems to building "
1523 + "block library.");
1524 rdbRingTmplsFrags.setToolTipText(toolTipRingTmplsFrags);
1525 rdbRingTmplsFrags.addChangeListener(rdbFieldChange);
1530
1531 String toolTipRingTmplsScaff = "<html>Specifies whether ring systems "
1532 + "should be extracted <br>"
1533 + "from generated graphs and stored as new "
1534 + "scaffold building blocks."
1535 + "</html>";
1536 lineRingTmplsScaff = new JPanel(new FlowLayout(FlowLayout.LEFT));
1537 rdbRingTmplsScaff = new JRadioButton("Add new ring systems to library "
1538 + "of scaffold building blocks.");
1539 rdbRingTmplsScaff.setToolTipText(toolTipRingTmplsScaff);
1540 rdbRingTmplsScaff.addChangeListener(rdbFieldChange);
1545
1546 String toolTipRingSysTmpl = "<html>A %/100 defining how good "
1547 + "(high fitness w.r.t. population range)<br> "
1548 + "candidates need to be for generating "
1549 + "new ring system templates.<br>"
1550 + "For example, 0.10 "
1551 + "allows only the best 10% of the candidates <br>to generate "
1552 + "a new building block from theyr graph.</html>";
1553 lineRingSysTmpl = new JPanel(new FlowLayout(FlowLayout.LEFT));
1554 lblRingSysTmpl = new JLabel("Threshold for saving ring systems:",
1555 SwingConstants.LEFT);
1556 lblRingSysTmpl.setPreferredSize(fileLabelSize);
1557 lblRingSysTmpl.setToolTipText(toolTipRingSysTmpl);
1558 spnRingSysTmpl = new JSpinner(new SpinnerNumberModel(0.10,0.0,1.0,0.05));
1559 spnRingSysTmpl.setToolTipText(toolTipRingSysTmpl);
1560 spnRingSysTmpl.setPreferredSize(strFieldSize);
1568
1569 advOptsBlock.add(super.getPanelForUnformattedInput());
1570
1571
1572 //HEREGOESADVIMPLEMENTATION this is only to facilitate automated insertion of code
1573
1574 JButton advOptShow = new JButton("Advanced Settings");
1575 advOptShow.addActionListener(new ActionListener(){
1576 public void actionPerformed(ActionEvent e){
1577 if (advOptsBlock.isVisible())
1578 {
1579 advOptsBlock.setVisible(false);
1580 advOptShow.setText("Show Advanced Settings");
1581 }
1582 else
1583 {
1584 advOptsBlock.setVisible(true);
1585 advOptShow.setText("Hide Advanced Settings");
1586 scrollablePane.validate();
1587 scrollablePane.repaint();
1588 scrollablePane.getVerticalScrollBar().setValue(
1589 scrollablePane.getVerticalScrollBar().getValue() + (int) preferredHeight*2/3);
1590 }
1591 }
1592 });
1593
1594 JPanel advOptsController = new JPanel();
1595 advOptsController.add(advOptShow);
1596 localBlock2.add(new JSeparator());
1597 localBlock2.add(advOptsController);
1599
1600 this.add(scrollablePane);
1601 }
1602
1603//-----------------------------------------------------------------------------
1604
1606 {
1608 ((XYPlot) graphLvlProbJFChart.getPlot()).setDataset(levelProbData);
1609 }
1610
1611//-----------------------------------------------------------------------------
1612
1613 private void createLvlProbDataset()
1614 {
1615 levelProbData = new DefaultXYDataset();
1616
1617 ArrayList<Double> y = new ArrayList<Double>();
1618 try
1619 {
1621 cmbPar11.getSelectedItem().toString());
1622 double l = (Double) spnPar12.getValue();
1623 double s1 = (Double) spnPar13.getValue();
1624 double s2 = (Double) spnPar14.getValue();
1625
1626 for (int level=0; level<100; level++)
1627 {
1629 level, scheme, l, s1, s2);
1630 y.add(prob);
1631 }
1632 }
1633 catch (Exception e)
1634 {
1635 e.printStackTrace();
1636 JOptionPane.showMessageDialog(this,
1637 "<html>Exception occurred while reading growth proability "
1638 + "scheme.<br>"
1639 + "Please, report this to the DENOPTIM team.</html>",
1640 "Error",
1641 JOptionPane.ERROR_MESSAGE,
1642 UIManager.getIcon("OptionPane.errorIcon"));
1643 }
1644
1645 double[][] data = new double[2][y.size()];
1646 for (int level=0; level<100; level++)
1647 {
1648 data[0][level] = level;
1649 data[1][level] = y.get(level);
1650 }
1651
1652 levelProbData.addSeries("Growth Probability", data);
1653 }
1654
1655//-----------------------------------------------------------------------------
1656
1657 private void createLvlProbGraph()
1658 {
1662 graphLvlProbJFChartChartPanel.setMaximumSize(new Dimension(400,200));
1663 }
1664
1665//-----------------------------------------------------------------------------
1666
1667 private void createLvlProbChart()
1668 {
1669 graphLvlProbJFChart = ChartFactory.createXYLineChart(
1670 null, // plot title
1671 "Level", // x axis label
1672 "Probability", // y axis label
1673 levelProbData, // data
1674 PlotOrientation.VERTICAL,
1675 false, // include legend
1676 false, // tooltips
1677 false // urls
1678 );
1679
1680 XYPlot plot = (XYPlot) graphLvlProbJFChart.getPlot();
1681
1682 // axis ranges
1683 plot.getDomainAxis().setRange(minLevelProbPlot, maxLevelProbPlot);
1684 plot.getRangeAxis().setRange(0.0, 1.0);
1685
1686 // axis ticks interval
1687 //NB: this if commented out because it blocks automated selection of tick units
1688 // and therefore it allows ticks overlap when range is large
1689 //((NumberAxis) plot.getDomainAxis()).setTickUnit(new NumberTickUnit(1.0));
1690
1691 // series line thickness
1692 XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
1693 renderer.setSeriesPaint(0, Color.decode("#490092"));
1694 renderer.setSeriesStroke(0, new BasicStroke(2.0f));
1695 plot.setRenderer(renderer);
1696
1697 // font of axis label
1698 Font font3 = new Font("Dialog", Font.PLAIN, 12);
1699 plot.getDomainAxis().setLabelFont(font3);
1700 plot.getRangeAxis().setLabelFont(font3);
1701 }
1702
1703 //-----------------------------------------------------------------------------
1704
1706 {
1708 ((XYPlot) graphMolSzProbJFChart.getPlot()).setDataset(molSizeProbData);
1709 }
1710
1711//-----------------------------------------------------------------------------
1712
1714 {
1715 molSizeProbData = new DefaultXYDataset();
1716
1717 ArrayList<Double> y = new ArrayList<Double>();
1718 try
1719 {
1721 cmbParMolSz1.getSelectedItem().toString());
1722 double l = (Double) spnParMolSz2.getValue();
1723 double s1 = (Double) spnParMolSz3.getValue();
1724 double s2 = (Double) spnParMolSz4.getValue();
1725
1726 for (int numHeavyAtoms=0; numHeavyAtoms<100; numHeavyAtoms++)
1727 {
1728 double prob = EAUtils.getProbability(
1729 numHeavyAtoms, scheme, l, s1, s2);
1730 y.add(prob);
1731 }
1732 }
1733 catch (Exception e)
1734 {
1735 e.printStackTrace();
1736 JOptionPane.showMessageDialog(this,
1737 "<html>Exception occurred while reading croding proability "
1738 + "scheme.<br>"
1739 + "Please, report this to the DENOPTIM team.</html>",
1740 "Error",
1741 JOptionPane.ERROR_MESSAGE,
1742 UIManager.getIcon("OptionPane.errorIcon"));
1743 }
1744
1745 double[][] data = new double[2][y.size()];
1746 for (int numHeavyAtoms=0; numHeavyAtoms<100; numHeavyAtoms++)
1747 {
1748 data[0][numHeavyAtoms] = numHeavyAtoms;
1749 data[1][numHeavyAtoms] = y.get(numHeavyAtoms);
1750 }
1751
1752 molSizeProbData.addSeries("Mol Growth Probability", data);
1753 }
1754
1755//-----------------------------------------------------------------------------
1756
1758 {
1762 graphMolSzProbJFChartChartPanel.setMaximumSize(new Dimension(400,200));
1763 }
1764
1765//-----------------------------------------------------------------------------
1766
1768 {
1769 graphMolSzProbJFChart = ChartFactory.createXYLineChart(
1770 null, // plot title
1771 "# Heavy Atoms", // x axis label
1772 "Probability", // y axis label
1773 molSizeProbData, // data
1774 PlotOrientation.VERTICAL,
1775 false, // include legend
1776 false, // tooltips
1777 false // urls
1778 );
1779
1780 XYPlot plot = (XYPlot) graphMolSzProbJFChart.getPlot();
1781
1782 // axis ranges
1783 plot.getDomainAxis().setRange(minMolSizeProbPlot, maxMolSizeProbPlot);
1784 plot.getRangeAxis().setRange(0.0, 1.0);
1785
1786 // axis ticks interval
1787 //NB: this if commented out because it blocks automated selection of tick units
1788 // and therefore it allows ticks overlap when range is large
1789 //((NumberAxis) plot.getDomainAxis()).setTickUnit(new NumberTickUnit(1.0));
1790
1791 // series line thickness
1792 XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
1793 renderer.setSeriesPaint(0, Color.decode("#db6d00"));
1794 renderer.setSeriesStroke(0, new BasicStroke(2.0f));
1795 plot.setRenderer(renderer);
1796
1797 // font of axis label
1798 Font font3 = new Font("Dialog", Font.PLAIN, 12);
1799 plot.getDomainAxis().setLabelFont(font3);
1800 plot.getRangeAxis().setLabelFont(font3);
1801 }
1802
1803//-----------------------------------------------------------------------------
1804
1806 {
1808 ((XYPlot) graphCrowdProbJFChart.getPlot()).setDataset(crowdProbData);
1809 }
1810
1811//-----------------------------------------------------------------------------
1812
1814 {
1815 crowdProbData = new DefaultXYDataset();
1816
1817 ArrayList<Double> y = new ArrayList<Double>();
1818 try
1819 {
1821 cmbParCrowd1.getSelectedItem().toString());
1822 double l = (Double) spnParCrowd2.getValue();
1823 double s1 = (Double) spnParCrowd3.getValue();
1824 double s2 = (Double) spnParCrowd4.getValue();
1825
1826 for (int crowdedness=0; crowdedness<100; crowdedness++)
1827 {
1829 crowdedness, scheme, l, s1, s2);
1830 y.add(prob);
1831 }
1832 }
1833 catch (Exception e)
1834 {
1835 e.printStackTrace();
1836 JOptionPane.showMessageDialog(this,
1837 "<html>Exception occurred while reading mol growth "
1838 + "proability scheme.<br>"
1839 + "Please, report this to the DENOPTIM team.</html>",
1840 "Error",
1841 JOptionPane.ERROR_MESSAGE,
1842 UIManager.getIcon("OptionPane.errorIcon"));
1843 }
1844
1845 double[][] data = new double[2][y.size()];
1846 for (int crowdedness=0; crowdedness<100; crowdedness++)
1847 {
1848 data[0][crowdedness] = crowdedness;
1849 data[1][crowdedness] = y.get(crowdedness);
1850 }
1851
1852 crowdProbData.addSeries("Crowding Probability", data);
1853 }
1854
1855//-----------------------------------------------------------------------------
1856
1857 private void createCrowdProbGraph()
1858 {
1862 graphCrowdProbJFChartChartPanel.setMaximumSize(new Dimension(400,200));
1863 }
1864
1865//-----------------------------------------------------------------------------
1866
1868 {
1869 graphCrowdProbJFChart = ChartFactory.createXYLineChart(
1870 null, // plot title
1871 "Crowdedness", // x axis label
1872 "Probability", // y axis label
1873 crowdProbData, // data
1874 PlotOrientation.VERTICAL,
1875 false, // include legend
1876 false, // tooltips
1877 false // urls
1878 );
1879
1880 XYPlot plot = (XYPlot) graphCrowdProbJFChart.getPlot();
1881
1882 // axis ranges
1883 plot.getDomainAxis().setRange(minLevelCrowdProbPlot, maxLevelCrowdProbPlot);
1884 plot.getRangeAxis().setRange(0.0, 1.0);
1885
1886 // axis ticks interval
1887 //NB: this if commented out because it blocks automated selection of tick units
1888 // and therefore it allows ticks overlap when range is large
1889 //((NumberAxis) plot.getDomainAxis()).setTickUnit(new NumberTickUnit(1.0));
1890
1891 // series line thickness
1892 XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
1893 renderer.setSeriesPaint(0, Color.decode("#ff6db6"));
1894 renderer.setSeriesStroke(0, new BasicStroke(2.0f));
1895 plot.setRenderer(renderer);
1896
1897 // font of axis label
1898 Font font3 = new Font("Dialog", Font.PLAIN, 12);
1899 plot.getDomainAxis().setLabelFont(font3);
1900 plot.getRangeAxis().setLabelFont(font3);
1901 }
1902
1903//-----------------------------------------------------------------------------
1904
1914 @Override
1915 public void importParametersFromDenoptimParamsFile(String fileName) throws Exception
1916 {
1918 checkedFlags.clear();
1919 checkedFlags.put(keyPar11, false);
1920
1922
1923 // We have also some fragmentation parameters in this form
1925
1926 rdbSrcOrNew.setSelected(false);
1927 localBlock1.setVisible(false);
1928 localBlock2.setVisible(true);
1929 switch (ProbabilityFuncitonShape.valueOf(
1930 cmbPar11.getSelectedItem().toString()))
1931 {
1932 case EXP_DIFF:
1933 localBlockLvlProb3.setVisible(true);
1934 localBlockLvlProb4.setVisible(false);
1935 break;
1936
1937 case TANH:
1938 localBlockLvlProb3.setVisible(true);
1939 localBlockLvlProb4.setVisible(false);
1940 break;
1941
1942 case SIGMA:
1943 localBlockLvlProb3.setVisible(false);
1944 localBlockLvlProb4.setVisible(true);
1945 break;
1946
1947 default:
1948 localBlockLvlProb3.setVisible(false);
1949 localBlockLvlProb4.setVisible(false);
1950 break;
1951 }
1952 switch (ProbabilityFuncitonShape.valueOf(
1953 cmbParMolSz1.getSelectedItem().toString()))
1954 {
1955 case EXP_DIFF:
1956 localBlockMolSz3.setVisible(true);
1957 localBlockMolSz4.setVisible(false);
1958 break;
1959
1960 case TANH:
1961 localBlockMolSz3.setVisible(true);
1962 localBlockMolSz4.setVisible(false);
1963 break;
1964
1965 case SIGMA:
1966 localBlockMolSz3.setVisible(false);
1967 localBlockMolSz4.setVisible(true);
1968 break;
1969
1970 default:
1971 localBlockMolSz3.setVisible(false);
1972 localBlockMolSz4.setVisible(false);
1973 break;
1974 }
1975 if (checkedFlags.get(keyPar11))
1976 {
1977 rbtLevelGrowth.setSelected(true);
1978 localBlockLvlProbAll.setVisible(true);
1979 localBlockMolSzAll.setVisible(false);
1980 } else {
1981 rbtMolSzGrowth.setSelected(true);
1982 localBlockLvlProbAll.setVisible(false);
1983 localBlockMolSzAll.setVisible(true);
1984 }
1985
1986 switch (ProbabilityFuncitonShape.valueOf(
1987 cmbParCrowd1.getSelectedItem().toString()))
1988 {
1989 case EXP_DIFF:
1991 localBlockCrowd3.setVisible(true);
1992 localBlockCrowd4.setVisible(false);
1993 localBlockCrowdGraph.setVisible(true);
1994 break;
1995
1996 case TANH:
1998 localBlockCrowd3.setVisible(true);
1999 localBlockCrowd4.setVisible(false);
2000 localBlockCrowdGraph.setVisible(true);
2001 break;
2002
2003 case SIGMA:
2005 localBlockCrowd3.setVisible(false);
2006 localBlockCrowd4.setVisible(true);
2007 localBlockCrowdGraph.setVisible(true);
2008 break;
2009
2010 case UNRESTRICTED:
2012 localBlockCrowd3.setVisible(false);
2013 localBlockCrowd4.setVisible(false);
2014 localBlockCrowdGraph.setVisible(true);
2015 break;
2016
2017 default:
2018 localBlockCrowd3.setVisible(false);
2019 localBlockCrowd4.setVisible(false);
2020 localBlockCrowdGraph.setVisible(false);
2021 break;
2022 }
2023
2024 advOptsBlock.setVisible(true);
2025 showUnknownKeyWarning(this, "Genetic Algorithm");
2026 }
2027
2028//-----------------------------------------------------------------------------
2029
2030 @SuppressWarnings("unchecked")
2031 @Override
2032 public void importSingleParameter(String key, String value) throws Exception
2033 {
2034 Object valueField;
2035 String valueFieldClass;
2036 if (mapKeyFieldToValueField.containsKey(key.toUpperCase()))
2037 {
2038 valueField = mapKeyFieldToValueField.get(key.toUpperCase());
2039 valueFieldClass = valueField.getClass().toString();
2040 }
2041 else
2042 {
2043 addToUnformattedTxt(key, value);
2044 return;
2045 }
2046
2047 switch (valueFieldClass)
2048 {
2049 case "class javax.swing.JTextField":
2050 ((JTextField) valueField).setText(value);
2051 break;
2052
2053 case "class javax.swing.JRadioButton":
2054 ((JRadioButton) valueField).setSelected(true);
2055 break;
2056
2057 case "class javax.swing.JComboBox":
2058 if (valueField==cmbParMolSz1 || valueField==cmbParCrowd1 ||
2059 valueField==cmbPar11)
2060 {
2061 ((JComboBox<ProbabilityFuncitonShape>) valueField)
2062 .setSelectedItem(ProbabilityFuncitonShape.valueOf(
2063 value.toUpperCase()));
2064 } else {
2065 ((JComboBox<String>) valueField).setSelectedItem(
2066 value.toUpperCase());
2067 }
2068 break;
2069
2070 case "class javax.swing.table.DefaultTableModel":
2071
2072 //WARNING: there might be cases where we do not take all the records
2073
2074 ((DefaultTableModel) valueField).addRow(value.split(" "));
2075 break;
2076
2077 case "class javax.swing.JSpinner":
2078
2079 //WARNING: assuming all JSpinners work on doubles
2080
2081 ((JSpinner) valueField).setValue(Double.parseDouble(value));
2082 break;
2083
2084 default:
2085 throw new Exception("<html>Unexpected type for parameter: "
2086 + key + " (" + valueFieldClass
2087 + ").<br>Please report this to"
2088 + "the DEMOPTIM team.</html>");
2089 }
2090
2091 }
2092
2093//-----------------------------------------------------------------------------
2094
2095 @Override
2096 public void putParametersToString(StringBuilder sb) throws Exception
2097 {
2098 sb.append("# Genetic Algorithm - parameters").append(NL);
2099
2100 if (rdbSrcOrNew.isSelected())
2101 {
2102 if (txtGASource.getText().equals("") || txtGASource.getText() == null)
2103 {
2104 throw new Exception("<html>No source specified for GA "
2105 + "parameters.<br>Please, specify the file name.</html>");
2106 }
2108 }
2109
2112 sb.append(keyPar2).append("=").append(cmbPar2.getSelectedItem())
2113 .append(NL);
2121 if (rbtLevelGrowth.isSelected())
2122 {
2123 sb.append(keyPar11).append("=").append(cmbPar11.getSelectedItem())
2124 .append(NL);
2125 if (cmbPar11.getSelectedItem()!=ProbabilityFuncitonShape.UNRESTRICTED)
2126 {
2127 if (cmbPar11.getSelectedItem()==ProbabilityFuncitonShape.EXP_DIFF
2128 || cmbPar11.getSelectedItem()==ProbabilityFuncitonShape.TANH)
2129 {
2131 } else if (cmbPar11.getSelectedItem()==ProbabilityFuncitonShape.SIGMA)
2132 {
2135 }
2136 }
2137 } else if (rbtMolSzGrowth.isSelected())
2138 {
2139 sb.append(keyParMolSz1).append("=")
2140 .append(cmbParMolSz1.getSelectedItem()).append(NL);
2141 if (cmbParMolSz1.getSelectedItem()!=ProbabilityFuncitonShape.UNRESTRICTED)
2142 {
2143 if (cmbParMolSz1.getSelectedItem()==ProbabilityFuncitonShape.EXP_DIFF
2144 || cmbParMolSz1.getSelectedItem()==ProbabilityFuncitonShape.TANH)
2145 {
2147 } else if (cmbParMolSz1.getSelectedItem()==ProbabilityFuncitonShape.SIGMA)
2148 {
2151 }
2152 }
2153 }
2154 sb.append(keyParCrowd1).append("=")
2155 .append(cmbParCrowd1.getSelectedItem()).append(NL);
2156 if (cmbParCrowd1.getSelectedItem()!=ProbabilityFuncitonShape.UNRESTRICTED)
2157 {
2158 if (cmbParCrowd1.getSelectedItem()==ProbabilityFuncitonShape.EXP_DIFF
2159 || cmbParCrowd1.getSelectedItem()==ProbabilityFuncitonShape.TANH)
2160 {
2162 } else if (cmbParCrowd1.getSelectedItem()==ProbabilityFuncitonShape.SIGMA)
2163 {
2166 }
2167 }
2168 sb.append(keyPar15).append("=").append(cmbPar15.getSelectedItem())
2169 .append(NL);
2175 sb.append(keyPar19).append("=").append(cmbPar19.getSelectedItem())
2176 .append(NL);
2177
2181
2186 sb.append(keyPar25).append("=").append(cmbPar25.getSelectedItem())
2187 .append(NL);
2190 if (rdbRingTmplsScaff.isSelected() || rdbRingTmplsScaff.isSelected())
2191 {
2193 }
2194
2195 sb.append(getTextForUnformattedSettings()).append(NL);
2196
2197 //HEREGOESPRINT this is only to facilitate automated insertion of code
2198 }
2199}
Helper methods for the genetic algorithm.
Definition: EAUtils.java:107
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:2134
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:2199
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:2382
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.