Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.CEDMA.Server/3.3/ProblemSpecification.cs @ 2502

Last change on this file since 2502 was 2422, checked in by gkronber, 15 years ago

Fixed bugs in CEDMA cockpit:

  • Runs were started for target variables that are turned off
  • Runs were started for deterministic algorithms with the same setting (when using time series settings)

#676 Cockpit for the CEDMA Server to control algorithm settings

File size: 5.9 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 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.Collections.Generic;
24using System.Linq;
25using System.Text;
26using HeuristicLab.Core;
27using System.Xml;
28using HeuristicLab.Operators;
29using HeuristicLab.Modeling.Database;
30
31namespace HeuristicLab.CEDMA.Server {
32  /// <summary>
33  /// ProblemSpecification describes the data mining task.
34  /// </summary>
35  public class ProblemSpecification {
36
37    private HeuristicLab.DataAnalysis.Dataset dataset;
38    public HeuristicLab.DataAnalysis.Dataset Dataset {
39      get { return dataset; }
40      set {
41        if (value != dataset) {
42          dataset = value;
43        }
44      }
45    }
46
47    public string TargetVariable { get; set; }
48
49    private int trainingSamplesStart;
50    public int TrainingSamplesStart {
51      get { return trainingSamplesStart; }
52      set { trainingSamplesStart = value; }
53    }
54
55    private int trainingSamplesEnd;
56    public int TrainingSamplesEnd {
57      get { return trainingSamplesEnd; }
58      set { trainingSamplesEnd = value; }
59    }
60
61    private int validationSamplesStart;
62    public int ValidationSamplesStart {
63      get { return validationSamplesStart; }
64      set { validationSamplesStart = value; }
65    }
66
67    private int validationSamplesEnd;
68    public int ValidationSamplesEnd {
69      get { return validationSamplesEnd; }
70      set { validationSamplesEnd = value; }
71    }
72
73    private int testSamplesStart;
74    public int TestSamplesStart {
75      get { return testSamplesStart; }
76      set { testSamplesStart = value; }
77    }
78
79    private int testSamplesEnd;
80    public int TestSamplesEnd {
81      get { return testSamplesEnd; }
82      set { testSamplesEnd = value; }
83    }
84
85    public int MaxTimeOffset { get; set; }
86    public int MinTimeOffset { get; set; }
87
88    public bool AutoRegressive { get; set; }
89
90    private LearningTask learningTask;
91    public LearningTask LearningTask {
92      get { return learningTask; }
93      set { learningTask = value; }
94    }
95
96    private List<string> inputVariables;
97    public IEnumerable<string> InputVariables {
98      get { return inputVariables; }
99    }
100
101    public ProblemSpecification() {
102      Dataset = new HeuristicLab.DataAnalysis.Dataset();
103      inputVariables = new List<string>();
104    }
105
106    // copy ctr
107    public ProblemSpecification(ProblemSpecification original) {
108      LearningTask = original.LearningTask;
109      TargetVariable = original.TargetVariable;
110      MinTimeOffset = original.MinTimeOffset;
111      MaxTimeOffset = original.MaxTimeOffset;
112      AutoRegressive = original.AutoRegressive;
113      TrainingSamplesStart = original.TrainingSamplesStart;
114      TrainingSamplesEnd = original.TrainingSamplesEnd;
115      ValidationSamplesStart = original.ValidationSamplesStart;
116      ValidationSamplesEnd = original.ValidationSamplesEnd;
117      TestSamplesStart = original.TestSamplesStart;
118      TestSamplesEnd = original.TestSamplesEnd;
119      inputVariables = new List<string>(original.InputVariables);
120      Dataset = original.Dataset;
121    }
122
123    internal void AddInputVariable(string name) {
124      if (!inputVariables.Contains(name)) inputVariables.Add(name);
125    }
126
127    internal void RemoveInputVariable(string name) {
128      inputVariables.Remove(name);
129    }
130
131    public override bool Equals(object obj) {
132      ProblemSpecification other = (obj as ProblemSpecification);
133      if (other == null) return false;
134      return
135        other.LearningTask == LearningTask &&
136        other.MinTimeOffset == MinTimeOffset &&
137        other.MaxTimeOffset == MaxTimeOffset &&
138        other.AutoRegressive == AutoRegressive &&
139        other.TargetVariable == TargetVariable &&
140        other.trainingSamplesStart == trainingSamplesStart &&
141        other.trainingSamplesEnd == trainingSamplesEnd &&
142        other.validationSamplesStart == validationSamplesStart &&
143        other.validationSamplesEnd == validationSamplesEnd &&
144        other.testSamplesStart == testSamplesStart &&
145        other.testSamplesEnd == testSamplesEnd &&
146        other.InputVariables.Count() == InputVariables.Count() &&
147        other.InputVariables.All(x => InputVariables.Contains(x)) &&
148        // it would be safer to check if the dataset values are the same but
149        // it should be sufficient to check if the dimensions are equal for now (gkronber 09/21/2009)
150        other.Dataset.Rows == Dataset.Rows &&
151        other.Dataset.Columns == Dataset.Columns;
152    }
153
154    public override int GetHashCode() {
155      return
156        LearningTask.GetHashCode() |
157        TargetVariable.GetHashCode() |
158        MinTimeOffset.GetHashCode() |
159        MaxTimeOffset.GetHashCode() |
160        AutoRegressive.GetHashCode() |
161        TrainingSamplesStart.GetHashCode() |
162        TrainingSamplesEnd.GetHashCode() |
163        ValidationSamplesStart.GetHashCode() |
164        ValidationSamplesEnd.GetHashCode() |
165        TestSamplesStart.GetHashCode() |
166        TestSamplesEnd.GetHashCode() |
167        InputVariables.Count().GetHashCode() |
168        Dataset.Rows.GetHashCode() |
169        Dataset.Columns.GetHashCode();
170    }
171  }
172}
Note: See TracBrowser for help on using the repository browser.