[2375] | 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 |
|
---|
| 22 | using System;
|
---|
| 23 | using System.Collections.Generic;
|
---|
| 24 | using System.Linq;
|
---|
| 25 | using System.Text;
|
---|
| 26 | using HeuristicLab.Core;
|
---|
| 27 | using System.Xml;
|
---|
| 28 | using HeuristicLab.Operators;
|
---|
| 29 | using HeuristicLab.Modeling.Database;
|
---|
| 30 |
|
---|
| 31 | namespace 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 &&
|
---|
[2392] | 133 | other.MinTimeOffset == MinTimeOffset &&
|
---|
| 134 | other.MaxTimeOffset == MaxTimeOffset &&
|
---|
| 135 | other.AutoRegressive == AutoRegressive &&
|
---|
[2375] | 136 | other.TargetVariable == TargetVariable &&
|
---|
| 137 | other.trainingSamplesStart == trainingSamplesStart &&
|
---|
| 138 | other.trainingSamplesEnd == trainingSamplesEnd &&
|
---|
| 139 | other.validationSamplesStart == validationSamplesStart &&
|
---|
| 140 | other.validationSamplesEnd == validationSamplesEnd &&
|
---|
| 141 | other.testSamplesStart == testSamplesStart &&
|
---|
| 142 | other.testSamplesEnd == testSamplesEnd &&
|
---|
| 143 | other.InputVariables.Count() == InputVariables.Count() &&
|
---|
| 144 | other.InputVariables.All(x => InputVariables.Contains(x)) &&
|
---|
| 145 | // it would be safer to check if the dataset values are the same but
|
---|
| 146 | // it should be sufficient to check if the dimensions are equal for now (gkronber 09/21/2009)
|
---|
| 147 | other.Dataset.Rows == Dataset.Rows &&
|
---|
| 148 | other.Dataset.Columns == Dataset.Columns;
|
---|
| 149 | }
|
---|
| 150 |
|
---|
| 151 | public override int GetHashCode() {
|
---|
| 152 | return
|
---|
| 153 | LearningTask.GetHashCode() |
|
---|
| 154 | TargetVariable.GetHashCode() |
|
---|
| 155 | TrainingSamplesStart.GetHashCode() |
|
---|
| 156 | TrainingSamplesEnd.GetHashCode() |
|
---|
| 157 | ValidationSamplesStart.GetHashCode() |
|
---|
| 158 | ValidationSamplesEnd.GetHashCode() |
|
---|
| 159 | TestSamplesStart.GetHashCode() |
|
---|
| 160 | TestSamplesEnd.GetHashCode() |
|
---|
| 161 | InputVariables.Count().GetHashCode() |
|
---|
| 162 | Dataset.Rows.GetHashCode() |
|
---|
| 163 | Dataset.Columns.GetHashCode();
|
---|
| 164 | }
|
---|
| 165 | }
|
---|
| 166 | }
|
---|