Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers.Views/3.3/SuccessorConfigurator.cs @ 9198

Last change on this file since 9198 was 9150, checked in by ascheibe, 11 years ago

#1886 fixed successor configuration and added successful mutation chart

File size: 3.2 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Linq;
24using System.Windows.Forms;
25using HeuristicLab.Common;
26using HeuristicLab.Core;
27using HeuristicLab.Core.Views;
28using HeuristicLab.Operators;
29using HeuristicLab.Optimization;
30
31namespace HeuristicLab.Analysis.AlgorithmBehavior.Views {
32  public partial class SuccessorConfigurator : Form {
33
34    public HeuristicOptimizationEngineAlgorithm Content { get; set; }
35    private HeuristicLab.Analysis.AlgorithmBehavior.Analyzers.CombinedOperator currentSuccessor = null;
36    private Type operatorType = null;
37
38    public SuccessorConfigurator() {
39      InitializeComponent();
40    }
41
42    private void chooseSuccessorButton_Click(object sender, System.EventArgs e) {
43      using (TypeSelectorDialog dialog = new TypeSelectorDialog()) {
44        dialog.Caption = "Select Successor";
45        dialog.TypeSelector.Caption = "Available Successor Operators";
46        dialog.TypeSelector.Configure(typeof(HeuristicLab.Analysis.AlgorithmBehavior.Analyzers.CombinedOperator), false, true);
47
48        if (dialog.ShowDialog() == DialogResult.OK) {
49          currentSuccessor = (HeuristicLab.Analysis.AlgorithmBehavior.Analyzers.CombinedOperator)dialog.TypeSelector.CreateInstanceOfSelectedType();
50          successorTextBox.Text = currentSuccessor.ToString();
51        }
52      }
53    }
54
55    private void okButton_Click(object sender, System.EventArgs e) {
56      ParametrizeOperators();
57      Close();
58    }
59
60    private void cancelButton_Click(object sender, System.EventArgs e) {
61      Close();
62    }
63
64    private void chooseOperatorTypeButton_Click(object sender, System.EventArgs e) {
65      using (TypeSelectorDialog dialog = new TypeSelectorDialog()) {
66        dialog.Caption = "Select Operator Type";
67        dialog.TypeSelector.Caption = "Available Operator Types";
68        dialog.TypeSelector.Configure(typeof(IOperator), true, true);
69
70        if (dialog.ShowDialog() == DialogResult.OK) {
71          operatorType = dialog.TypeSelector.SelectedType;
72          operatorNameTextBox.Text = operatorType.ToString();
73        }
74      }
75    }
76
77    private void ParametrizeOperators() {
78      foreach (var op in Content.Problem.Operators.OfType<SingleSuccessorOperator>()) {
79        if (op.GetType().GetInterfaces().Any(x => x == operatorType)) {
80          op.Successor = (IOperator)currentSuccessor.Clone(new Cloner());
81        }
82      }
83    }
84  }
85}
Note: See TracBrowser for help on using the repository browser.