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.Collections.Generic;
|
---|
23 | using System.Linq;
|
---|
24 | using System.Windows.Forms;
|
---|
25 | using HeuristicLab.Core;
|
---|
26 |
|
---|
27 | namespace HeuristicLab.Clients.OKB.RunCreation {
|
---|
28 | public partial class OKBRunConfigSelectionView : UserControl {
|
---|
29 |
|
---|
30 | private const string algorithmTypeParameterName = "Algorithm Type";
|
---|
31 | private const string problemTypeParameterName = "Problem Type";
|
---|
32 |
|
---|
33 | private List<Algorithm> algorithms;
|
---|
34 | public List<Algorithm> Algorithms {
|
---|
35 | get { return algorithms; }
|
---|
36 | set {
|
---|
37 | algorithms = value;
|
---|
38 | foreach (Algorithm a in Algorithms) {
|
---|
39 | cmbAlgorithm.Items.Add(a);
|
---|
40 | }
|
---|
41 | }
|
---|
42 | }
|
---|
43 |
|
---|
44 | private List<Problem> problems;
|
---|
45 | public List<Problem> Problems {
|
---|
46 | get { return problems; }
|
---|
47 | set {
|
---|
48 | problems = value;
|
---|
49 | foreach (Problem p in Problems) {
|
---|
50 | cmbProblem.Items.Add(p);
|
---|
51 | }
|
---|
52 | }
|
---|
53 | }
|
---|
54 |
|
---|
55 | private HeuristicLab.Optimization.IRun experimentRun;
|
---|
56 | public HeuristicLab.Optimization.IRun ExperimentRun {
|
---|
57 | get { return experimentRun; }
|
---|
58 | set {
|
---|
59 | experimentRun = value;
|
---|
60 | txtRunName.Text = ExperimentRun.Name;
|
---|
61 | }
|
---|
62 | }
|
---|
63 |
|
---|
64 | public OKBRunConfigSelectionView() {
|
---|
65 | InitializeComponent();
|
---|
66 | }
|
---|
67 |
|
---|
68 | public OKBRunConfigSelectionView(HeuristicLab.Optimization.IRun run, List<Algorithm> algorithms, List<Problem> problems) {
|
---|
69 | InitializeComponent();
|
---|
70 |
|
---|
71 | ExperimentRun = run;
|
---|
72 | Algorithms = algorithms;
|
---|
73 | Problems = problems;
|
---|
74 |
|
---|
75 | PopulateComboboxes();
|
---|
76 | }
|
---|
77 |
|
---|
78 | private void PopulateComboboxes() {
|
---|
79 | IItem algorithmType;
|
---|
80 | IItem problemType;
|
---|
81 |
|
---|
82 | if (cmbAlgorithm.Items.Count > 0) {
|
---|
83 | cmbAlgorithm.SelectedIndex = 0;
|
---|
84 | }
|
---|
85 | if (cmbProblem.Items.Count > 0) {
|
---|
86 | cmbProblem.SelectedIndex = 0;
|
---|
87 | }
|
---|
88 |
|
---|
89 | if (ExperimentRun.Parameters.TryGetValue(algorithmTypeParameterName, out algorithmType)) {
|
---|
90 | HeuristicLab.Data.StringValue algStr = algorithmType as HeuristicLab.Data.StringValue;
|
---|
91 | if (algStr != null) {
|
---|
92 | var result = Algorithms.FindAll(x => x.Name == algStr.Value);
|
---|
93 | if (result.Count > 0) {
|
---|
94 | cmbAlgorithm.SelectedItem = result.First();
|
---|
95 | }
|
---|
96 | }
|
---|
97 | }
|
---|
98 |
|
---|
99 | if (ExperimentRun.Parameters.TryGetValue(problemTypeParameterName, out problemType)) {
|
---|
100 | HeuristicLab.Data.StringValue prbStr = problemType as HeuristicLab.Data.StringValue;
|
---|
101 | if (prbStr != null) {
|
---|
102 | var result = Problems.FindAll(x => x.Name == prbStr.Value);
|
---|
103 | if (result.Count > 0) {
|
---|
104 | cmbProblem.SelectedItem = result.First();
|
---|
105 | }
|
---|
106 | }
|
---|
107 | }
|
---|
108 | }
|
---|
109 |
|
---|
110 | public Algorithm GetSelectedAlgorithm() {
|
---|
111 | return cmbAlgorithm.SelectedItem as Algorithm;
|
---|
112 | }
|
---|
113 |
|
---|
114 | public Problem GetSelectedProblem() {
|
---|
115 | return cmbProblem.SelectedItem as Problem;
|
---|
116 | }
|
---|
117 |
|
---|
118 | public bool UploadToOKB() {
|
---|
119 | return chkUpload.Checked;
|
---|
120 | }
|
---|
121 | }
|
---|
122 | }
|
---|