[5649] | 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 |
|
---|
| 22 | using System.Collections.Generic;
|
---|
| 23 | using System.IO;
|
---|
| 24 | using HeuristicLab.Common;
|
---|
| 25 | using HeuristicLab.Core;
|
---|
| 26 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 27 |
|
---|
| 28 | namespace HeuristicLab.Problems.DataAnalysis {
|
---|
| 29 | [StorableClass]
|
---|
| 30 | [Item("ClusteringProblemData", "Represents an item containing all data defining a clustering problem.")]
|
---|
| 31 | public sealed class ClusteringProblemData : DataAnalysisProblemData, IClusteringProblemData {
|
---|
| 32 |
|
---|
| 33 | #region default data
|
---|
| 34 | private static double[,] kozaF1 = new double[,] {
|
---|
| 35 | {2.017885919, -1.449165046},
|
---|
| 36 | {1.30060506, -1.344523885},
|
---|
| 37 | {1.147134798, -1.317989331},
|
---|
| 38 | {0.877182504, -1.266142284},
|
---|
| 39 | {0.852562452, -1.261020794},
|
---|
| 40 | {0.431095788, -1.158793317},
|
---|
| 41 | {0.112586002, -1.050908405},
|
---|
| 42 | {0.04594507, -1.021989402},
|
---|
| 43 | {0.042572879, -1.020438113},
|
---|
| 44 | {-0.074027291, -0.959859562},
|
---|
| 45 | {-0.109178553, -0.938094706},
|
---|
| 46 | {-0.259721109, -0.803635355},
|
---|
| 47 | {-0.272991057, -0.387519561},
|
---|
| 48 | {-0.161978191, -0.193611001},
|
---|
| 49 | {-0.102489983, -0.114215349},
|
---|
| 50 | {-0.01469968, -0.014918985},
|
---|
| 51 | {-0.008863365, -0.008942626},
|
---|
| 52 | {0.026751057, 0.026054094},
|
---|
| 53 | {0.166922436, 0.14309643},
|
---|
| 54 | {0.176953808, 0.1504144},
|
---|
| 55 | {0.190233418, 0.159916534},
|
---|
| 56 | {0.199800708, 0.166635331},
|
---|
| 57 | {0.261502822, 0.207600348},
|
---|
| 58 | {0.30182879, 0.232370249},
|
---|
| 59 | {0.83763905, 0.468046718}
|
---|
| 60 | };
|
---|
| 61 | private static Dataset defaultDataset;
|
---|
| 62 | private static IEnumerable<string> defaultAllowedInputVariables;
|
---|
| 63 |
|
---|
| 64 | static ClusteringProblemData() {
|
---|
| 65 | defaultDataset = new Dataset(new string[] { "y", "x" }, kozaF1);
|
---|
| 66 | defaultDataset.Name = "Fourth-order Polynomial Function Benchmark Dataset";
|
---|
| 67 | defaultDataset.Description = "f(x) = x^4 + x^3 + x^2 + x^1";
|
---|
| 68 | defaultAllowedInputVariables = new List<string>() { "x", "y" };
|
---|
| 69 | }
|
---|
| 70 | #endregion
|
---|
| 71 |
|
---|
| 72 | [StorableConstructor]
|
---|
| 73 | private ClusteringProblemData(bool deserializing) : base(deserializing) { }
|
---|
| 74 |
|
---|
| 75 | private ClusteringProblemData(ClusteringProblemData original, Cloner cloner)
|
---|
| 76 | : base(original, cloner) {
|
---|
| 77 | }
|
---|
| 78 | public override IDeepCloneable Clone(Cloner cloner) { return new ClusteringProblemData(this, cloner); }
|
---|
| 79 |
|
---|
| 80 | public ClusteringProblemData()
|
---|
| 81 | : this(defaultDataset, defaultAllowedInputVariables) {
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | public ClusteringProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables)
|
---|
| 85 | : base(dataset, allowedInputVariables) {
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 |
|
---|
| 89 | #region Import from file
|
---|
| 90 | public static ClusteringProblemData ImportFromFile(string fileName) {
|
---|
| 91 | TableFileParser csvFileParser = new TableFileParser();
|
---|
| 92 | csvFileParser.Parse(fileName);
|
---|
| 93 |
|
---|
| 94 | Dataset dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values);
|
---|
| 95 | dataset.Name = Path.GetFileName(fileName);
|
---|
| 96 |
|
---|
[6760] | 97 | ClusteringProblemData problemData = new ClusteringProblemData(dataset, dataset.DoubleVariables);
|
---|
[5649] | 98 | problemData.Name = "Data imported from " + Path.GetFileName(fileName);
|
---|
| 99 | return problemData;
|
---|
| 100 | }
|
---|
| 101 | #endregion
|
---|
| 102 | }
|
---|
| 103 | }
|
---|