Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.CEDMA.Server/3.3/DispatcherView.cs @ 2290

Last change on this file since 2290 was 2290, checked in by gkronber, 15 years ago
  • introduced a variablename to index mapping for SVM models (to make sure we can use the model for prediction in the model analyzer)
  • added support to enable and disable algorithms in the dispatcher and removed DispatcherBase
  • fixed bugs when calculating variable impacts and reading the final model of GP algorithms

#722 (IModel should provide a Predict() method to get predicted values for an input vector)

File size: 3.8 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Drawing;
5using System.Data;
6using System.Linq;
7using System.Text;
8using System.Windows.Forms;
9using HeuristicLab.Core;
10
11namespace HeuristicLab.CEDMA.Server {
12  public partial class DispatcherView : ViewBase {
13    private SimpleDispatcher dispatcher;
14    public DispatcherView(SimpleDispatcher dispatcher)
15      : base() {
16      this.dispatcher = dispatcher;
17      InitializeComponent();
18      UpdateControls();
19      dispatcher.Changed += (sender, args) => UpdateControls();
20      this.inputVariableList.CheckOnClick = true;
21    }
22
23    protected override void UpdateControls() {
24      if (InvokeRequired) {
25        Invoke((Action)UpdateControls);
26      } else {
27        base.UpdateControls();
28        algorithmsListBox.Items.Clear();
29        targetVariableList.Items.Clear();
30        inputVariableList.Items.Clear();
31
32        foreach (string targetVar in dispatcher.TargetVariables) {
33          targetVariableList.Items.Add(targetVar, false);
34        }
35
36        foreach (string inputVar in dispatcher.InputVariables) {
37          inputVariableList.Items.Add(inputVar, false);
38        }
39
40        foreach (HeuristicLab.Modeling.IAlgorithm algo in dispatcher.Algorithms) {
41          algorithmsListBox.Items.Add(algo, false);
42        }
43        targetVariableList.ClearSelected();
44        inputVariableList.Enabled = false;
45      }
46    }
47
48    private void targetVariableList_ItemCheck(object sender, ItemCheckEventArgs e) {
49      if (e.NewValue == CheckState.Checked) {
50        dispatcher.EnableTargetVariable((string)targetVariableList.Items[e.Index]);
51      } else if (e.NewValue == CheckState.Unchecked) {
52        dispatcher.DisableTargetVariable((string)targetVariableList.Items[e.Index]);
53      }
54    }
55
56    private void inputVariableList_ItemCheck(object sender, ItemCheckEventArgs e) {
57      string selectedTarget = (string)targetVariableList.SelectedItem;
58      if (e.NewValue == CheckState.Checked) {
59        dispatcher.EnableInputVariable(selectedTarget, (string)inputVariableList.Items[e.Index]);
60      } else if (e.NewValue == CheckState.Unchecked) {
61        dispatcher.DisableInputVariable(selectedTarget, (string)inputVariableList.Items[e.Index]);
62      }
63    }
64
65    private void targetVariableList_SelectedValueChanged(object sender, EventArgs e) {
66      string selectedTarget = (string)targetVariableList.SelectedItem;
67      UpdateInputVariableList(selectedTarget);
68    }
69
70    private void UpdateInputVariableList(string target) {
71      inputVariableList.Items.Clear();
72      var activatedInputVariables = dispatcher.GetInputVariables(target);
73      foreach (string inputVar in dispatcher.InputVariables) {
74        inputVariableList.Items.Add(inputVar, activatedInputVariables.Contains(inputVar));
75      }
76      inputVariableList.Enabled = true;
77    }
78
79    private void setAllButton_Click(object sender, EventArgs e) {     
80      foreach (string targetVar in dispatcher.TargetVariables) {
81        for (int i = 0; i < inputVariableList.Items.Count; i++) {
82          if (inputVariableList.GetItemChecked(i)) {
83            dispatcher.EnableInputVariable(targetVar, (string)inputVariableList.Items[i]);
84          } else {
85            dispatcher.DisableInputVariable(targetVar, (string)inputVariableList.Items[i]);
86          }
87        }
88      }
89    }
90
91    private void algorithmsListBox_ItemCheck(object sender, ItemCheckEventArgs e) {
92      if(e.NewValue == CheckState.Checked) {
93        dispatcher.EnableAlgorithm((HeuristicLab.Modeling.IAlgorithm)algorithmsListBox.Items[e.Index]);
94      } else if(e.NewValue == CheckState.Unchecked) {
95        dispatcher.DisableAlgorithm((HeuristicLab.Modeling.IAlgorithm)algorithmsListBox.Items[e.Index]);
96      }
97    }
98  }
99}
Note: See TracBrowser for help on using the repository browser.