21import java.awt.BasicStroke;
 
   22import java.awt.BorderLayout;
 
   24import java.awt.Dimension;
 
   25import java.awt.FlowLayout;
 
   27import java.awt.GridLayout;
 
   28import java.awt.event.ActionEvent;
 
   29import java.awt.event.ActionListener;
 
   30import java.util.ArrayList;
 
   31import java.util.HashMap;
 
   33import java.util.concurrent.atomic.AtomicInteger;
 
   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;
 
   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;
 
   65import denoptim.ga.EAUtils;
 
   66import denoptim.programs.denovo.GAParameters;
 
   84    public static AtomicInteger 
gaFormUID = 
new AtomicInteger(1);
 
  121    String 
keyPar5 = 
"GA-SortByIncreasingFitness";
 
  360    String 
NL = System.getProperty(
"line.separator");
 
  366        this.setLayout(
new BorderLayout()); 
 
  368        block = 
new JPanel();
 
  369        JScrollPane scrollablePane = 
new JScrollPane(
block);
 
  370        block.setLayout(
new BoxLayout(
block, SwingConstants.VERTICAL));
 
  375                SwingConstants.VERTICAL));
 
  380                SwingConstants.VERTICAL));
 
  385                SwingConstants.VERTICAL));
 
  390                SwingConstants.VERTICAL));
 
  397                SwingConstants.VERTICAL));
 
  402                SwingConstants.VERTICAL));
 
  407                SwingConstants.VERTICAL));
 
  414                SwingConstants.VERTICAL));
 
  419                SwingConstants.VERTICAL));
 
  424                SwingConstants.VERTICAL));
 
  432                SwingConstants.VERTICAL));
 
  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");
 
  438        rdbSrcOrNew.addActionListener(
new ActionListener(){
 
  439            public void actionPerformed(ActionEvent e){
 
  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);
 
  465        btnGASource.addActionListener(
new ActionListener() {
 
  466        public void actionPerformed(ActionEvent e) {
 
  472        txtGASource.setToolTipText(
"<html>Specify the file containing the " 
  473                + 
"parameters to be loaded in this form.</html>");
 
  475            public void actionPerformed(ActionEvent e) {
 
  482                    if (e1.getMessage().equals(
"") || e1.getMessage() == 
null)
 
  484                        e1.printStackTrace();
 
  486                                "<html>Exception occurred while importing parameters.<br>Please, report this to the DENOPTIM team.</html>",
 
  488                                JOptionPane.ERROR_MESSAGE,
 
  489                                UIManager.getIcon(
"OptionPane.errorIcon"));
 
  496                                JOptionPane.ERROR_MESSAGE,
 
  497                                UIManager.getIcon(
"OptionPane.errorIcon"));
 
  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);
 
  515        lblPar6.setToolTipText(toolTipPar6);
 
  517        txtPar6.setToolTipText(toolTipPar6);
 
  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);
 
  529        lblPar7.setToolTipText(toolTipPar7);
 
  531        txtPar7.setToolTipText(toolTipPar7);
 
  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);
 
  543        lblPar8.setToolTipText(toolTipPar8);
 
  545        txtPar8.setToolTipText(toolTipPar8);
 
  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);
 
  557        lblPar9.setToolTipText(toolTipPar9);
 
  559        txtPar9.setToolTipText(toolTipPar9);
 
  575            public void actionPerformed(ActionEvent e){
 
  584        rbtMolSzGrowth = 
new JRadioButton(
"molecular size (heavy atoms count)");
 
  586            public void actionPerformed(ActionEvent e){
 
  602        String toolTipPar12 = 
"<html>Specifies the value of the factor used in" 
  603                + 
" growth probability schemes <code>" 
  604                + ProbabilityFuncitonShape.EXP_DIFF + 
"</code> and " 
  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>λ</code><html>", SwingConstants.LEFT);
 
  611        lblPar12.setToolTipText(toolTipPar12);
 
  612        spnPar12 = 
new JSpinner(
new SpinnerNumberModel(1.0, 0.0, 
null, 0.1));
 
  613        spnPar12.setToolTipText(toolTipPar12);
 
  620        String toolTipPar13 = 
"<html>Specifies the value of parameter " 
  621                + 
"σ<sub>1</sub> used for growth probability scheme" 
  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>σ</code><sub>1</sub>:</html>", 
 
  629                SwingConstants.LEFT);
 
  631        lblPar13.setToolTipText(toolTipPar13);
 
  632        spnPar13 = 
new JSpinner(
new SpinnerNumberModel(1.0, 
null, 
null, 0.1));
 
  633        spnPar13.setToolTipText(toolTipPar13);
 
  640        String toolTipPar14 = 
"<html>Specifies the value of parameter " 
  641                + 
"σ<sub>2</sub> used in growth probability scheme " 
  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>σ</code><sub>2</sub>:<html>", 
 
  649                SwingConstants.LEFT);
 
  651        lblPar14.setToolTipText(toolTipPar14);
 
  652        spnPar14 = 
new JSpinner(
new SpinnerNumberModel(3.5, 
null, 
null, 0.1));
 
  653        spnPar14.setToolTipText(toolTipPar14);
 
  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);
 
  665        lblPar11.setToolTipText(toolTipPar11);
 
  666        cmbPar11 = 
new JComboBox<ProbabilityFuncitonShape>(
 
  669        cmbPar11.setToolTipText(toolTipPar11);
 
  680        final JSpinner spnMaxLev = 
new JSpinner(
new SpinnerNumberModel(
 
  682        spnMaxLev.addChangeListener(
new ChangeListener()
 
  685            public void stateChanged(ChangeEvent event)
 
  687                int maxLev = ((Integer) spnMaxLev.getValue()).intValue();                
 
  698        grpLyoSubPrb.setAutoCreateGaps(
true);
 
  699        grpLyoSubPrb.setAutoCreateContainerGaps(
true);
 
  700        grpLyoSubPrb.setHorizontalGroup(grpLyoSubPrb.createSequentialGroup()
 
  703        grpLyoSubPrb.setVerticalGroup(grpLyoSubPrb.createParallelGroup(
 
  704                GroupLayout.Alignment.CENTER)
 
  712        spnPar12.addChangeListener(
new ChangeListener()
 
  714            public void stateChanged(ChangeEvent event)
 
  719        spnPar13.addChangeListener(
new ChangeListener()
 
  721            public void stateChanged(ChangeEvent event)
 
  726        spnPar14.addChangeListener(
new ChangeListener()
 
  728            public void stateChanged(ChangeEvent event)
 
  734        cmbPar11.addActionListener(
new ActionListener(){
 
  735            public void actionPerformed(ActionEvent e){
 
  737                        cmbPar11.getSelectedItem().toString()))
 
  776        String toolTipParMolSz2 = 
"<html>Specifies the value of the factor used in" 
  777                + 
" molecular growth probability schemes <code>" 
  778                + ProbabilityFuncitonShape.EXP_DIFF + 
"</code> and " 
  780                + ProbabilityFuncitonShape.TANH + 
"</code></html>";
 
  782        lblParMolSz2 = 
new JLabel(
"<html>Mol growth probability - parameter " 
  783                + 
"<code>λ</code><html>", SwingConstants.LEFT);
 
  786        spnParMolSz2 = 
new JSpinner(
new SpinnerNumberModel(1.0, 0.0, 
null, 0.1));
 
  794        String toolTipParMolSz3 = 
"<html>Specifies the value of parameter " 
  795                + 
"σ<sub>1</sub> used for molecular growth probability " 
  798                + ProbabilityFuncitonShape.SIGMA
 
  799                + 
"</code>.<br>It corresponds to the steepness of" 
  800                + 
" the function where <i>P(level) = 50%</i></html>";
 
  802        lblParMolSz3 = 
new JLabel(
"<html>Mol growth probability - parameter " 
  803                + 
"<code>σ</code><sub>1</sub>:</html>", SwingConstants.LEFT);
 
  806        spnParMolSz3 = 
new JSpinner(
new SpinnerNumberModel(0.2, 
null, 
null, 0.1));
 
  814        String toolTipParMolSz4 = 
"<html>Specifies the value of parameter " 
  815                + 
"σ<sub>2</sub> used in molecular growth probability " 
  818                + ProbabilityFuncitonShape.SIGMA 
 
  819                + 
"</code>.<br>It corresponds to the level " 
  820                + 
"where <i>P(level) = 50%</i></html>";
 
  822        lblParMolSz4 = 
new JLabel(
"<html>Mol growth probability - parameter " 
  823                + 
"<code>σ</code><sub>2</sub>:<html>", SwingConstants.LEFT);
 
  826        spnParMolSz4 = 
new JSpinner(
new SpinnerNumberModel(25.0, 
null, 
null, 1.0));
 
  834        String toolTipParMolSz1 = 
"Specifies the molecular growth probability scheme";
 
  836        lblParMolSz1 = 
new JLabel(
"Mol growth probability function:",
 
  837                SwingConstants.LEFT);
 
  854        final JSpinner spnMaxLevMolSz = 
new JSpinner(
new SpinnerNumberModel(
 
  856        spnMaxLevMolSz.addChangeListener(
new ChangeListener()
 
  859            public void stateChanged(ChangeEvent event)
 
  861                int maxLev = ((Integer) spnMaxLevMolSz.getValue()).intValue();
 
  872        grpLyoMolSzProb.setAutoCreateGaps(
true);
 
  873        grpLyoMolSzProb.setAutoCreateContainerGaps(
true);
 
  874        grpLyoMolSzProb.setHorizontalGroup(grpLyoMolSzProb.createSequentialGroup()
 
  877        grpLyoMolSzProb.setVerticalGroup(grpLyoMolSzProb.createParallelGroup(
 
  878                GroupLayout.Alignment.CENTER)
 
  888            public void stateChanged(ChangeEvent event)
 
  895            public void stateChanged(ChangeEvent event)
 
  902            public void stateChanged(ChangeEvent event)
 
  909            public void actionPerformed(ActionEvent e){
 
  960        String toolTipParCrowd2 = 
"<html>Specifies the value of the factor used in" 
  961                + 
" crowding probability schemes <code>" 
  962                + ProbabilityFuncitonShape.EXP_DIFF
 
  965                + ProbabilityFuncitonShape.TANH
 
  968        lblParCrowd2 = 
new JLabel(
"<html>Crowding probability - parameter " 
  969                + 
"<code>λ</code><html>", SwingConstants.LEFT);
 
  972        spnParCrowd2 = 
new JSpinner(
new SpinnerNumberModel(1.0, 0.0, 
null, 0.1));
 
  980        String toolTipParCrowd3 = 
"<html>Specifies the value of parameter " 
  981                + 
"σ<sub>1</sub> used for crowding probability scheme" 
  983                + ProbabilityFuncitonShape.SIGMA
 
  984                + 
"</code>.<br>It corresponds to the steepness of" 
  985                + 
" the function where <i>P(level) = 50%</i></html>";
 
  987        lblParCrowd3 = 
new JLabel(
"<html>Crowding probability - parameter " 
  988                + 
"<code>σ</code><sub>1</sub>:</html>", SwingConstants.LEFT);
 
  991        spnParCrowd3 = 
new JSpinner(
new SpinnerNumberModel(1.0, 
null, 
null, 0.1));
 
  999        String toolTipParCrowd4 = 
"<html>Specifies the value of parameter " 
 1000                + 
"σ<sub>2</sub> used in crowding probability scheme " 
 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>σ</code><sub>2</sub>:<html>", SwingConstants.LEFT);
 
 1010        spnParCrowd4 = 
new JSpinner(
new SpinnerNumberModel(3.5, 
null, 
null, 0.1));
 
 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);
 
 1024        cmbParCrowd1 = 
new JComboBox<ProbabilityFuncitonShape>(
 
 1038        final JSpinner spnMaxLevCrowd = 
new JSpinner(
new SpinnerNumberModel(
 
 1040        spnMaxLevCrowd.addChangeListener(
new ChangeListener()
 
 1043            public void stateChanged(ChangeEvent event)
 
 1045                int maxLev = ((Integer) spnMaxLevCrowd.getValue()).intValue();                
 
 1056        grpLyoCrowdProb.setAutoCreateGaps(
true);
 
 1057        grpLyoCrowdProb.setAutoCreateContainerGaps(
true);
 
 1058        grpLyoCrowdProb.setHorizontalGroup(grpLyoCrowdProb.createSequentialGroup()
 
 1061        grpLyoCrowdProb.setVerticalGroup(grpLyoCrowdProb.createParallelGroup(
 
 1062                GroupLayout.Alignment.CENTER)
 
 1072            public void stateChanged(ChangeEvent event)
 
 1079            public void stateChanged(ChangeEvent event)
 
 1086            public void stateChanged(ChangeEvent event)
 
 1093            public void actionPerformed(ActionEvent e){
 
 1094                String scheme = 
cmbParCrowd1.getSelectedItem().toString();
 
 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>" 
 1148        linePar15 = 
new JPanel(
new FlowLayout(FlowLayout.LEFT));
 
 1149        lblPar15 = 
new JLabel(
"Parent selection algorithm:", SwingConstants.LEFT);
 
 1151        lblPar15.setToolTipText(toolTipPar15);
 
 1152        cmbPar15 = 
new JComboBox<String>(
new String[] {
"RANDOM", 
"TS", 
"RW", 
"SUS"});
 
 1153        cmbPar15.setToolTipText(toolTipPar15);
 
 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);
 
 1165        lblPar16.setToolTipText(toolTipPar16);
 
 1167        txtPar16.setToolTipText(toolTipPar16);
 
 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);
 
 1180        lblPar17.setToolTipText(toolTipPar17);
 
 1182        txtPar17.setToolTipText(toolTipPar17);
 
 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);
 
 1195        lblParWC.setToolTipText(toolTipParWC);
 
 1197        txtParWC.setToolTipText(toolTipParWC);
 
 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);
 
 1209        lblPar18.setToolTipText(toolTipPar18);
 
 1211        txtPar18.setToolTipText(toolTipPar18);
 
 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);
 
 1223        lblPar19.setToolTipText(toolTipPar19);
 
 1224        cmbPar19 = 
new JComboBox<String>(
new String[] {
"ELITIST", 
"NONE"});
 
 1225        cmbPar19.setToolTipText(toolTipPar19);
 
 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);
 
 1236        lblPar24.setToolTipText(toolTipPar24);
 
 1238        txtPar24.setToolTipText(toolTipPar24);
 
 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);
 
 1250        lblPar25.setToolTipText(toolTipPar25);
 
 1251        cmbPar25 = 
new JComboBox<String>(
new String[] {
"Synchronous", 
"Asynchronous"});
 
 1252        cmbPar25.setToolTipText(toolTipPar25);
 
 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);
 
 1267        lblParMSM.setToolTipText(toolTipParMSM);
 
 1269        txtParMSM.setToolTipText(toolTipParMSM);
 
 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);
 
 1281        lblPar3.setToolTipText(toolTipPar3);
 
 1283        txtPar3.setToolTipText(toolTipPar3);
 
 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);
 
 1295        lblPar1.setToolTipText(toolTipPar1);
 
 1297        txtPar1.setToolTipText(toolTipPar1);
 
 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);
 
 1309        lblPar2.setToolTipText(toolTipPar2);
 
 1310        cmbPar2 = 
new JComboBox<String>(
new String[] {
"-3", 
"-2", 
"-1", 
"0", 
"1", 
"2", 
"3"});
 
 1311        cmbPar2.setToolTipText(toolTipPar2);
 
 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);
 
 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);
 
 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);
 
 1341        lblPar10.setToolTipText(toolTipPar10);
 
 1343        txtPar10.setToolTipText(toolTipPar10);
 
 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>";
 
 1357        lblMolToGraph = 
new JLabel(
"Initial population from screening:", SwingConstants.LEFT);
 
 1364        txtMolToGraph.getDocument().addDocumentListener(
new DocumentListener() {
 
 1365            public void changedUpdate(DocumentEvent e) {
 
 1377            public void removeUpdate(DocumentEvent e) {
 
 1389            public void insertUpdate(DocumentEvent e) {
 
 1405        public void actionPerformed(ActionEvent e) {
 
 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);
 
 1426        btnFrgMols.addActionListener(
new ActionListener() {
 
 1427        public void actionPerformed(ActionEvent e) {
 
 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);
 
 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);
 
 1455        lblPar20.setToolTipText(toolTipPar20);
 
 1457        txtPar20.setToolTipText(toolTipPar20);
 
 1462        btnPar20.addActionListener(
new ActionListener() {
 
 1463        public void actionPerformed(ActionEvent e) {
 
 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);
 
 1476        lblPar21.setToolTipText(toolTipPar21);
 
 1478        txtPar21.setToolTipText(toolTipPar21);
 
 1483        btnPar21.addActionListener(
new ActionListener() {
 
 1484        public void actionPerformed(ActionEvent e) {
 
 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);
 
 1497        lblPar22.setToolTipText(toolTipPar22);
 
 1499        txtPar22.setToolTipText(toolTipPar22);
 
 1504        btnPar22.addActionListener(
new ActionListener() {
 
 1505        public void actionPerformed(ActionEvent e) {
 
 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." 
 1523                + 
"block library.");
 
 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." 
 1538                + 
"of scaffold building blocks.");
 
 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>";
 
 1554        lblRingSysTmpl = 
new JLabel(
"Threshold for saving ring systems:", 
 
 1555                SwingConstants.LEFT);
 
 1558        spnRingSysTmpl = 
new JSpinner(
new SpinnerNumberModel(0.10,0.0,1.0,0.05));
 
 1574        JButton advOptShow = 
new JButton(
"Advanced Settings");
 
 1575        advOptShow.addActionListener(
new ActionListener(){
 
 1576            public void actionPerformed(ActionEvent e){
 
 1580                    advOptShow.setText(
"Show Advanced Settings");                   
 
 1585                    advOptShow.setText(
"Hide Advanced Settings");
 
 1586                    scrollablePane.validate();
 
 1587                    scrollablePane.repaint();
 
 1588                    scrollablePane.getVerticalScrollBar().setValue(
 
 1589                            scrollablePane.getVerticalScrollBar().getValue() + (
int) 
preferredHeight*2/3);
 
 1594        JPanel advOptsController = 
new JPanel();
 
 1595        advOptsController.add(advOptShow);
 
 1600        this.add(scrollablePane);
 
 1617        ArrayList<Double> y = 
new ArrayList<Double>();
 
 1621                    cmbPar11.getSelectedItem().toString());
 
 1622            double l = (Double) 
spnPar12.getValue();
 
 1623            double s1 = (Double) 
spnPar13.getValue();
 
 1624            double s2 = (Double) 
spnPar14.getValue();
 
 1626            for (
int level=0; level<100; level++)
 
 1629                        level, scheme, l, s1, s2);
 
 1635            e.printStackTrace();
 
 1636            JOptionPane.showMessageDialog(
this,
 
 1637                    "<html>Exception occurred while reading growth proability " 
 1639                    + 
"Please, report this to the DENOPTIM team.</html>",
 
 1641                    JOptionPane.ERROR_MESSAGE,
 
 1642                    UIManager.getIcon(
"OptionPane.errorIcon"));
 
 1645        double[][] data = 
new double[2][y.size()];
 
 1646        for (
int level=0; level<100; level++)
 
 1648            data[0][level] = level;
 
 1649            data[1][level] = y.get(level);
 
 1674            PlotOrientation.VERTICAL,  
 
 1684        plot.getRangeAxis().setRange(0.0, 1.0);
 
 1692        XYLineAndShapeRenderer renderer = 
new XYLineAndShapeRenderer();
 
 1693        renderer.setSeriesPaint(0, Color.decode(
"#490092"));
 
 1694        renderer.setSeriesStroke(0, 
new BasicStroke(2.0f));
 
 1695        plot.setRenderer(renderer);
 
 1698        Font font3 = 
new Font(
"Dialog", Font.PLAIN, 12); 
 
 1699        plot.getDomainAxis().setLabelFont(font3);
 
 1700        plot.getRangeAxis().setLabelFont(font3);
 
 1717        ArrayList<Double> y = 
new ArrayList<Double>();
 
 1726          for (
int numHeavyAtoms=0; numHeavyAtoms<100; numHeavyAtoms++)
 
 1729                        numHeavyAtoms, scheme, l, s1, s2);
 
 1735          e.printStackTrace();
 
 1736          JOptionPane.showMessageDialog(
this,
 
 1737                  "<html>Exception occurred while reading croding proability " 
 1739                  + 
"Please, report this to the DENOPTIM team.</html>",
 
 1741                  JOptionPane.ERROR_MESSAGE,
 
 1742                  UIManager.getIcon(
"OptionPane.errorIcon"));
 
 1745        double[][] data = 
new double[2][y.size()];
 
 1746        for (
int numHeavyAtoms=0; numHeavyAtoms<100; numHeavyAtoms++)
 
 1748          data[0][numHeavyAtoms] = numHeavyAtoms;
 
 1749          data[1][numHeavyAtoms] = y.get(numHeavyAtoms);
 
 1774          PlotOrientation.VERTICAL,
 
 1784        plot.getRangeAxis().setRange(0.0, 1.0);
 
 1792        XYLineAndShapeRenderer renderer = 
new XYLineAndShapeRenderer();
 
 1793        renderer.setSeriesPaint(0, Color.decode(
"#db6d00"));
 
 1794        renderer.setSeriesStroke(0, 
new BasicStroke(2.0f));
 
 1795        plot.setRenderer(renderer);
 
 1798        Font font3 = 
new Font(
"Dialog", Font.PLAIN, 12);
 
 1799        plot.getDomainAxis().setLabelFont(font3);
 
 1800        plot.getRangeAxis().setLabelFont(font3);
 
 1817        ArrayList<Double> y = 
new ArrayList<Double>();
 
 1826            for (
int crowdedness=0; crowdedness<100; crowdedness++)
 
 1829                        crowdedness, scheme, l, s1, s2);
 
 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>",
 
 1841                    JOptionPane.ERROR_MESSAGE,
 
 1842                    UIManager.getIcon(
"OptionPane.errorIcon"));
 
 1845        double[][] data = 
new double[2][y.size()];
 
 1846        for (
int crowdedness=0; crowdedness<100; crowdedness++)
 
 1848            data[0][crowdedness] = crowdedness;
 
 1849            data[1][crowdedness] = y.get(crowdedness);
 
 1874            PlotOrientation.VERTICAL,  
 
 1884        plot.getRangeAxis().setRange(0.0, 1.0);
 
 1892        XYLineAndShapeRenderer renderer = 
new XYLineAndShapeRenderer();
 
 1893        renderer.setSeriesPaint(0, Color.decode(
"#ff6db6"));
 
 1894        renderer.setSeriesStroke(0, 
new BasicStroke(2.0f));
 
 1895        plot.setRenderer(renderer);
 
 1898        Font font3 = 
new Font(
"Dialog", Font.PLAIN, 12); 
 
 1899        plot.getDomainAxis().setLabelFont(font3);
 
 1900        plot.getRangeAxis().setLabelFont(font3);
 
 1930                cmbPar11.getSelectedItem().toString()))
 
 2030    @SuppressWarnings(
"unchecked")
 
 2035        String valueFieldClass;
 
 2039            valueFieldClass = valueField.getClass().toString();
 
 2047        switch (valueFieldClass)
 
 2049            case "class javax.swing.JTextField":
 
 2050                ((JTextField) valueField).setText(value);
 
 2053            case "class javax.swing.JRadioButton":
 
 2054                ((JRadioButton) valueField).setSelected(
true);
 
 2057            case "class javax.swing.JComboBox":
 
 2061                    ((JComboBox<ProbabilityFuncitonShape>) valueField)
 
 2063                                value.toUpperCase()));
 
 2065                    ((JComboBox<String>) valueField).setSelectedItem(
 
 2066                            value.toUpperCase());
 
 2070            case "class javax.swing.table.DefaultTableModel":
 
 2074                ((DefaultTableModel) valueField).addRow(value.split(
" "));
 
 2077            case "class javax.swing.JSpinner":
 
 2081                ((JSpinner) valueField).setValue(Double.parseDouble(value));
 
 2085                throw new Exception(
"<html>Unexpected type for parameter: "   
 2086                        + key + 
" (" + valueFieldClass 
 
 2087                        + 
").<br>Please report this to" 
 2088                        + 
"the DEMOPTIM team.</html>");
 
 2098        sb.append(
"# Genetic Algorithm - parameters").append(
NL);
 
 2104                throw new Exception(
"<html>No source specified for GA " 
 2105                        + 
"parameters.<br>Please, specify the file name.</html>");
 
Helper methods for the genetic algorithm.
 
static double getGrowthProbabilityAtLevel(int level, int scheme, double lambda, double sigmaOne, double sigmaTwo)
Calculates the probability of adding a fragment to the given level.
 
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...
 
static double getCrowdingProbabilityForCrowdedness(int crowdedness, int scheme, double lambda, double sigmaOne, double sigmaTwo)
Calculated the crowding probability for a given level of crowdedness.
 
File opener for DENOPTIM GUI.
 
static File pickFileForTxtField(JTextField txtField, Component parent)
 
Parameters for genetic algorithm.
 
static int convertProbabilityScheme(String option)