Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 2380 was 2375, checked in by gkronber, 15 years ago

Refactored CEDMA dispatcher and CEDMA server view to allow different modeling scenarios for each variable. #754

File size: 5.5 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      TrainingSamplesStart = original.TrainingSamplesStart;
111      TrainingSamplesEnd = original.TrainingSamplesEnd;
112      ValidationSamplesStart = original.ValidationSamplesStart;
113      ValidationSamplesEnd = original.ValidationSamplesEnd;
114      TestSamplesStart = original.TestSamplesStart;
115      TestSamplesEnd = original.TestSamplesEnd;
116      inputVariables = new List<string>(original.InputVariables);
117      Dataset = original.Dataset;
118    }
119
120    internal void AddInputVariable(string name) {
121      if (!inputVariables.Contains(name)) inputVariables.Add(name);
122    }
123
124    internal void RemoveInputVariable(string name) {
125      inputVariables.Remove(name);
126    }
127
128    public override bool Equals(object obj) {
129      ProblemSpecification other = (obj as ProblemSpecification);
130      if (other == null) return false;
131      return
132        other.LearningTask == LearningTask &&
133        other.TargetVariable == TargetVariable &&
134        other.trainingSamplesStart == trainingSamplesStart &&
135        other.trainingSamplesEnd == trainingSamplesEnd &&
136        other.validationSamplesStart == validationSamplesStart &&
137        other.validationSamplesEnd == validationSamplesEnd &&
138        other.testSamplesStart == testSamplesStart &&
139        other.testSamplesEnd == testSamplesEnd &&
140        other.InputVariables.Count() == InputVariables.Count() &&
141        other.InputVariables.All(x => InputVariables.Contains(x)) &&
142        // it would be safer to check if the dataset values are the same but
143        // it should be sufficient to check if the dimensions are equal for now (gkronber 09/21/2009)
144        other.Dataset.Rows == Dataset.Rows &&
145        other.Dataset.Columns == Dataset.Columns;
146    }
147
148    public override int GetHashCode() {
149      return
150        LearningTask.GetHashCode() |
151        TargetVariable.GetHashCode() |
152        TrainingSamplesStart.GetHashCode() |
153        TrainingSamplesEnd.GetHashCode() |
154        ValidationSamplesStart.GetHashCode() |
155        ValidationSamplesEnd.GetHashCode() |
156        TestSamplesStart.GetHashCode() |
157        TestSamplesEnd.GetHashCode() |
158        InputVariables.Count().GetHashCode() |
159        Dataset.Rows.GetHashCode() |
160        Dataset.Columns.GetHashCode();
161    }
162  }
163}
Note: See TracBrowser for help on using the repository browser.