[9053] | 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 |
|
---|
| 22 | using System;
|
---|
| 23 | using System.Linq;
|
---|
| 24 | using System.Windows.Forms;
|
---|
| 25 | using HeuristicLab.Common;
|
---|
| 26 | using HeuristicLab.Core;
|
---|
| 27 | using HeuristicLab.Core.Views;
|
---|
| 28 | using HeuristicLab.Operators;
|
---|
| 29 | using HeuristicLab.Optimization;
|
---|
| 30 |
|
---|
| 31 | namespace HeuristicLab.Analysis.AlgorithmBehavior.Analyzers.Views {
|
---|
| 32 | public partial class SuccessorConfigurator : Form {
|
---|
| 33 |
|
---|
| 34 | public HeuristicOptimizationEngineAlgorithm Content { get; set; }
|
---|
| 35 | private 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(CombinedOperator), false, true);
|
---|
| 47 |
|
---|
| 48 | if (dialog.ShowDialog() == DialogResult.OK) {
|
---|
| 49 | currentSuccessor = (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 | }
|
---|