source: trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionEnsembleProblemData.cs @ 6666

Last change on this file since 6666 was 6666, checked in by mkommend, 11 years ago

#1592: Enabled creation of empty ensemble solutions and problem data changes.

File size: 4.1 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2011 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.Collections.Generic;
23using System.Linq;
24using HeuristicLab.Common;
25using HeuristicLab.Core;
26using HeuristicLab.Data;
27using HeuristicLab.Parameters;
28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
29
30namespace HeuristicLab.Problems.DataAnalysis {
31  [StorableClass]
32  [Item("RegressionEnsembleProblemData", "Represents an item containing all data defining a regression problem.")]
33  public sealed class RegressionEnsembleProblemData : RegressionProblemData {
34
35    public override IEnumerable<int> TrainingIndizes {
36      get {
37        return Enumerable.Range(TrainingPartition.Start, TrainingPartition.End - TrainingPartition.Start);
38      }
39    }
40
41    public override IEnumerable<int> TestIndizes {
42      get {
43        return Enumerable.Range(TestPartition.Start, TestPartition.End - TestPartition.Start);
44      }
45    }
46
47    private static RegressionEnsembleProblemData emptyProblemData;
48    public new static RegressionEnsembleProblemData EmptyProblemData {
49      get { return emptyProblemData; }
50    }
51    static RegressionEnsembleProblemData() {
52      var problemData = new RegressionEnsembleProblemData();
53      problemData.Parameters.Clear();
54      problemData.Name = "Empty Regression ProblemData";
55      problemData.Description = "This ProblemData acts as place holder before the correct problem data is loaded.";
56      problemData.isEmpty = true;
57
58      problemData.Parameters.Add(new FixedValueParameter<Dataset>(DatasetParameterName, "", new Dataset()));
59      problemData.Parameters.Add(new FixedValueParameter<ReadOnlyCheckedItemList<StringValue>>(InputVariablesParameterName, ""));
60      problemData.Parameters.Add(new FixedValueParameter<IntRange>(TrainingPartitionParameterName, "", (IntRange)new IntRange(0, 0).AsReadOnly()));
61      problemData.Parameters.Add(new FixedValueParameter<IntRange>(TestPartitionParameterName, "", (IntRange)new IntRange(0, 0).AsReadOnly()));
62      problemData.Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>()));
63      emptyProblemData = problemData;
64    }
65
66    [StorableConstructor]
67    private RegressionEnsembleProblemData(bool deserializing) : base(deserializing) { }
68    private RegressionEnsembleProblemData(RegressionEnsembleProblemData original, Cloner cloner) : base(original, cloner) { }
69    public override IDeepCloneable Clone(Cloner cloner) {
70      if (this == emptyProblemData) return emptyProblemData;
71      return new RegressionEnsembleProblemData(this, cloner);
72    }
73
74    public RegressionEnsembleProblemData() : base() { }
75    public RegressionEnsembleProblemData(IRegressionProblemData regressionProblemData)
76      : base(regressionProblemData.Dataset, regressionProblemData.AllowedInputVariables, regressionProblemData.TargetVariable) {
77      TrainingPartition.Start = regressionProblemData.TrainingPartition.Start;
78      TrainingPartition.End = regressionProblemData.TrainingPartition.End;
79      TestPartition.Start = regressionProblemData.TestPartition.Start;
80      TestPartition.End = regressionProblemData.TestPartition.End;
81    }
82    public RegressionEnsembleProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable)
83      : base(dataset, allowedInputVariables, targetVariable) {
84    }
85  }
86}
Note: See TracBrowser for help on using the repository browser.