Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3.2/sources/HeuristicLab.CEDMA.Server/3.3/ProblemSpecification.cs @ 8614

Last change on this file since 8614 was 2843, checked in by gkronber, 15 years ago

Removed max. and min. time offset constraints as algorithm parameters and from all engines. The time constraints were added to the relevant terminal symbols (variable & differential) instead. The time offset constraint can be changed by editing the symbols in the function library. #880 (Max and min time offsets for variable symbols are not set correctly by FunctionLibraryInjectors)

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 bool AutoRegressive { get; set; }
86
87    private LearningTask learningTask;
88    public LearningTask LearningTask {
89      get { return learningTask; }
90      set { learningTask = value; }
91    }
92
93    private List<string> inputVariables;
94    public IEnumerable<string> InputVariables {
95      get { return inputVariables; }
96    }
97
98    public ProblemSpecification() {
99      Dataset = new HeuristicLab.DataAnalysis.Dataset();
100      inputVariables = new List<string>();
101    }
102
103    // copy ctr
104    public ProblemSpecification(ProblemSpecification original) {
105      LearningTask = original.LearningTask;
106      TargetVariable = original.TargetVariable;
107      AutoRegressive = original.AutoRegressive;
108      TrainingSamplesStart = original.TrainingSamplesStart;
109      TrainingSamplesEnd = original.TrainingSamplesEnd;
110      ValidationSamplesStart = original.ValidationSamplesStart;
111      ValidationSamplesEnd = original.ValidationSamplesEnd;
112      TestSamplesStart = original.TestSamplesStart;
113      TestSamplesEnd = original.TestSamplesEnd;
114      inputVariables = new List<string>(original.InputVariables);
115      Dataset = original.Dataset;
116    }
117
118    internal void AddInputVariable(string name) {
119      if (!inputVariables.Contains(name)) inputVariables.Add(name);
120    }
121
122    internal void RemoveInputVariable(string name) {
123      inputVariables.Remove(name);
124    }
125
126    public override bool Equals(object obj) {
127      ProblemSpecification other = (obj as ProblemSpecification);
128      if (other == null) return false;
129      return
130        other.LearningTask == LearningTask &&
131        other.AutoRegressive == AutoRegressive &&
132        other.TargetVariable == TargetVariable &&
133        other.trainingSamplesStart == trainingSamplesStart &&
134        other.trainingSamplesEnd == trainingSamplesEnd &&
135        other.validationSamplesStart == validationSamplesStart &&
136        other.validationSamplesEnd == validationSamplesEnd &&
137        other.testSamplesStart == testSamplesStart &&
138        other.testSamplesEnd == testSamplesEnd &&
139        other.InputVariables.Count() == InputVariables.Count() &&
140        other.InputVariables.All(x => InputVariables.Contains(x)) &&
141        // it would be safer to check if the dataset values are the same but
142        // it should be sufficient to check if the dimensions are equal for now (gkronber 09/21/2009)
143        other.Dataset.Rows == Dataset.Rows &&
144        other.Dataset.Columns == Dataset.Columns;
145    }
146
147    public override int GetHashCode() {
148      return
149        LearningTask.GetHashCode() |
150        TargetVariable.GetHashCode() |
151        AutoRegressive.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.