Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/31/11 11:52:11 (13 years ago)
Author:
abeham
Message:

#1628

  • Updated branch from trunk
  • Changed ReferenceEqualityComparer<T> to become a non-generic class (generic implementation probably was only made because of lacking support for co- and contravariance in C# 3.5)
  • Added finished experiment from sample algorithms to the tests
  • Wrote a unit test to instantiate every IDeepCloneable type, clone it and compare the objects in the object graph for equal references
  • Wrote a unit test to load the experiment, clone it and compare again the objects in the object graph
  • Preliminary fix for a potential bug in ThreadSafeLog
  • Preliminary fix for a potential bug in OperatorGraphVisualizationInfo
  • Preliminary fix for a potential bug in Calculator (and added license headers)
  • Preliminary fix for a potential bug in ScrambleMove
Location:
branches/GeneralizedQAP
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • branches/GeneralizedQAP

  • branches/GeneralizedQAP/HeuristicLab.Problems.DataAnalysis

  • branches/GeneralizedQAP/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationEnsembleModel.cs

    r6613 r6685  
    4646      this.models = original.Models.Select(m => cloner.Clone(m)).ToList();
    4747    }
     48
     49    public ClassificationEnsembleModel() : this(Enumerable.Empty<IClassificationModel>()) { }
    4850    public ClassificationEnsembleModel(IEnumerable<IClassificationModel> models)
    4951      : base() {
  • branches/GeneralizedQAP/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationEnsembleProblemData.cs

    r6520 r6685  
    2020#endregion
    2121
    22 using System;
    2322using System.Collections.Generic;
    24 using System.IO;
    25 using System.Linq;
    2623using HeuristicLab.Common;
    2724using HeuristicLab.Core;
     
    3532  public class ClassificationEnsembleProblemData : ClassificationProblemData {
    3633
    37     public override IEnumerable<int> TrainingIndizes {
    38       get {
    39         return Enumerable.Range(TrainingPartition.Start, TrainingPartition.End - TrainingPartition.Start);
    40       }
     34    public override bool IsTrainingSample(int index) {
     35      return index >= 0 && index < Dataset.Rows &&
     36             TrainingPartition.Start <= index && index < TrainingPartition.End;
    4137    }
    42     public override IEnumerable<int> TestIndizes {
    43       get {
    44         return Enumerable.Range(TestPartition.Start, TestPartition.End - TestPartition.Start);
    45       }
     38
     39    public override bool IsTestSample(int index) {
     40      return index >= 0 && index < Dataset.Rows &&
     41             TestPartition.Start <= index && index < TestPartition.End;
     42    }
     43
     44    private static readonly ClassificationEnsembleProblemData emptyProblemData;
     45    public static ClassificationEnsembleProblemData EmptyProblemData {
     46      get { return emptyProblemData; }
     47    }
     48
     49    static ClassificationEnsembleProblemData() {
     50      var problemData = new ClassificationEnsembleProblemData();
     51      problemData.Parameters.Clear();
     52      problemData.Name = "Empty Classification ProblemData";
     53      problemData.Description = "This ProblemData acts as place holder before the correct problem data is loaded.";
     54      problemData.isEmpty = true;
     55
     56      problemData.Parameters.Add(new FixedValueParameter<Dataset>(DatasetParameterName, "", new Dataset()));
     57      problemData.Parameters.Add(new FixedValueParameter<ReadOnlyCheckedItemList<StringValue>>(InputVariablesParameterName, ""));
     58      problemData.Parameters.Add(new FixedValueParameter<IntRange>(TrainingPartitionParameterName, "", (IntRange)new IntRange(0, 0).AsReadOnly()));
     59      problemData.Parameters.Add(new FixedValueParameter<IntRange>(TestPartitionParameterName, "", (IntRange)new IntRange(0, 0).AsReadOnly()));
     60      problemData.Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>()));
     61      problemData.Parameters.Add(new FixedValueParameter<StringMatrix>(ClassNamesParameterName, "", new StringMatrix(0, 0).AsReadOnly()));
     62      problemData.Parameters.Add(new FixedValueParameter<DoubleMatrix>(ClassificationPenaltiesParameterName, "", (DoubleMatrix)new DoubleMatrix(0, 0).AsReadOnly()));
     63      emptyProblemData = problemData;
    4664    }
    4765
    4866    [StorableConstructor]
    4967    protected ClassificationEnsembleProblemData(bool deserializing) : base(deserializing) { }
     68    protected ClassificationEnsembleProblemData(ClassificationEnsembleProblemData original, Cloner cloner) : base(original, cloner) { }
     69    public override IDeepCloneable Clone(Cloner cloner) {
     70      if (this == emptyProblemData) return emptyProblemData;
     71      return new ClassificationEnsembleProblemData(this, cloner);
     72    }
    5073
    51     protected ClassificationEnsembleProblemData(ClassificationEnsembleProblemData original, Cloner cloner)
    52       : base(original, cloner) {
    53     }
    54     public override IDeepCloneable Clone(Cloner cloner) { return new ClassificationEnsembleProblemData(this, cloner); }
    55 
     74    public ClassificationEnsembleProblemData() : base() { }
    5675    public ClassificationEnsembleProblemData(IClassificationProblemData classificationProblemData)
    5776      : base(classificationProblemData.Dataset, classificationProblemData.AllowedInputVariables, classificationProblemData.TargetVariable) {
     
    6180      this.TestPartition.End = classificationProblemData.TestPartition.End;
    6281    }
     82
     83    public ClassificationEnsembleProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable)
     84      : base(dataset, allowedInputVariables, targetVariable) {
     85    }
    6386  }
    6487}
  • branches/GeneralizedQAP/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationEnsembleSolution.cs

    r6613 r6685  
    3535  [StorableClass]
    3636  [Item("Classification Ensemble Solution", "A classification solution that contains an ensemble of multiple classification models")]
    37   // [Creatable("Data Analysis")]
     37  [Creatable("Data Analysis - Ensembles")]
    3838  public sealed class ClassificationEnsembleSolution : ClassificationSolution, IClassificationEnsembleSolution {
    3939    public new IClassificationEnsembleModel Model {
    4040      get { return (IClassificationEnsembleModel)base.Model; }
     41    }
     42    public new ClassificationEnsembleProblemData ProblemData {
     43      get { return (ClassificationEnsembleProblemData)base.ProblemData; }
     44      set { base.ProblemData = value; }
    4145    }
    4246
     
    8286
    8387      classificationSolutions = cloner.Clone(original.classificationSolutions);
     88      RegisterClassificationSolutionsEventHandler();
     89    }
     90
     91    public ClassificationEnsembleSolution()
     92      : base(new ClassificationEnsembleModel(), ClassificationEnsembleProblemData.EmptyProblemData) {
     93      trainingPartitions = new Dictionary<IClassificationModel, IntRange>();
     94      testPartitions = new Dictionary<IClassificationModel, IntRange>();
     95      classificationSolutions = new ItemCollection<IClassificationSolution>();
     96
    8497      RegisterClassificationSolutionsEventHandler();
    8598    }
     
    208221    #endregion
    209222
     223    protected override void OnProblemDataChanged() {
     224      IClassificationProblemData problemData = new ClassificationProblemData(ProblemData.Dataset,
     225                                                                     ProblemData.AllowedInputVariables,
     226                                                                     ProblemData.TargetVariable);
     227      problemData.TrainingPartition.Start = ProblemData.TrainingPartition.Start;
     228      problemData.TrainingPartition.End = ProblemData.TrainingPartition.End;
     229      problemData.TestPartition.Start = ProblemData.TestPartition.Start;
     230      problemData.TestPartition.End = ProblemData.TestPartition.End;
     231
     232      foreach (var solution in ClassificationSolutions) {
     233        if (solution is ClassificationEnsembleSolution)
     234          solution.ProblemData = ProblemData;
     235        else
     236          solution.ProblemData = problemData;
     237      }
     238      foreach (var trainingPartition in trainingPartitions.Values) {
     239        trainingPartition.Start = ProblemData.TrainingPartition.Start;
     240        trainingPartition.End = ProblemData.TrainingPartition.End;
     241      }
     242      foreach (var testPartition in testPartitions.Values) {
     243        testPartition.Start = ProblemData.TestPartition.Start;
     244        testPartition.End = ProblemData.TestPartition.End;
     245      }
     246
     247      base.OnProblemDataChanged();
     248    }
     249
    210250    public void AddClassificationSolutions(IEnumerable<IClassificationSolution> solutions) {
    211251      classificationSolutions.AddRange(solutions);
  • branches/GeneralizedQAP/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationProblemData.cs

    r6440 r6685  
    3434  [Item("ClassificationProblemData", "Represents an item containing all data defining a classification problem.")]
    3535  public class ClassificationProblemData : DataAnalysisProblemData, IClassificationProblemData {
    36     private const string TargetVariableParameterName = "TargetVariable";
    37     private const string ClassNamesParameterName = "ClassNames";
    38     private const string ClassificationPenaltiesParameterName = "ClassificationPenalties";
    39     private const int MaximumNumberOfClasses = 20;
    40     private const int InspectedRowsToDetermineTargets = 500;
     36    protected const string TargetVariableParameterName = "TargetVariable";
     37    protected const string ClassNamesParameterName = "ClassNames";
     38    protected const string ClassificationPenaltiesParameterName = "ClassificationPenalties";
     39    protected const int MaximumNumberOfClasses = 20;
     40    protected const int InspectedRowsToDetermineTargets = 500;
    4141
    4242    #region default data
     
    171171     {1176881,7,5,3,7,4,10,7,5,5,4        }
    172172};
    173     private static Dataset defaultDataset;
    174     private static IEnumerable<string> defaultAllowedInputVariables;
    175     private static string defaultTargetVariable;
     173    private static readonly Dataset defaultDataset;
     174    private static readonly IEnumerable<string> defaultAllowedInputVariables;
     175    private static readonly string defaultTargetVariable;
     176
     177    private static readonly ClassificationProblemData emptyProblemData;
     178    public static ClassificationProblemData EmptyProblemData {
     179      get { return EmptyProblemData; }
     180    }
     181
    176182    static ClassificationProblemData() {
    177183      defaultDataset = new Dataset(defaultVariableNames, defaultData);
     
    181187      defaultAllowedInputVariables = defaultVariableNames.Except(new List<string>() { "sample", "class" });
    182188      defaultTargetVariable = "class";
     189
     190      var problemData = new ClassificationProblemData();
     191      problemData.Parameters.Clear();
     192      problemData.Name = "Empty Classification ProblemData";
     193      problemData.Description = "This ProblemData acts as place holder before the correct problem data is loaded.";
     194      problemData.isEmpty = true;
     195
     196      problemData.Parameters.Add(new FixedValueParameter<Dataset>(DatasetParameterName, "", new Dataset()));
     197      problemData.Parameters.Add(new FixedValueParameter<ReadOnlyCheckedItemList<StringValue>>(InputVariablesParameterName, ""));
     198      problemData.Parameters.Add(new FixedValueParameter<IntRange>(TrainingPartitionParameterName, "", (IntRange)new IntRange(0, 0).AsReadOnly()));
     199      problemData.Parameters.Add(new FixedValueParameter<IntRange>(TestPartitionParameterName, "", (IntRange)new IntRange(0, 0).AsReadOnly()));
     200      problemData.Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>()));
     201      problemData.Parameters.Add(new FixedValueParameter<StringMatrix>(ClassNamesParameterName, "", new StringMatrix(0, 0).AsReadOnly()));
     202      problemData.Parameters.Add(new FixedValueParameter<DoubleMatrix>(ClassificationPenaltiesParameterName, "", (DoubleMatrix)new DoubleMatrix(0, 0).AsReadOnly()));
     203      emptyProblemData = problemData;
    183204    }
    184205    #endregion
     
    249270      RegisterParameterEvents();
    250271    }
    251     public override IDeepCloneable Clone(Cloner cloner) { return new ClassificationProblemData(this, cloner); }
     272    public override IDeepCloneable Clone(Cloner cloner) {
     273      if (this == emptyProblemData) return emptyProblemData;
     274      return new ClassificationProblemData(this, cloner);
     275    }
    252276
    253277    public ClassificationProblemData() : this(defaultDataset, defaultAllowedInputVariables, defaultTargetVariable) { }
     
    267291    private static IEnumerable<string> CheckVariablesForPossibleTargetVariables(Dataset dataset) {
    268292      int maxSamples = Math.Min(InspectedRowsToDetermineTargets, dataset.Rows);
    269       var validTargetVariables = from v in dataset.VariableNames
    270                                  let DistinctValues = dataset.GetVariableValues(v)
    271                                    .Take(maxSamples)
    272                                    .Distinct()
    273                                    .Count()
    274                                  where DistinctValues < MaximumNumberOfClasses
    275                                  select v;
     293      var validTargetVariables = (from v in dataset.VariableNames
     294                                  let distinctValues = dataset.GetEnumeratedVariableValues(v)
     295                                    .Take(maxSamples)
     296                                    .Distinct()
     297                                    .Count()
     298                                  where distinctValues < MaximumNumberOfClasses
     299                                  select v).ToArray();
    276300
    277301      if (!validTargetVariables.Any())
     
    283307
    284308    private void ResetTargetVariableDependentMembers() {
    285       DergisterParameterEvents();
     309      DeregisterParameterEvents();
    286310
    287311      classNames = null;
     
    357381      ClassificationPenaltiesParameter.Value.ItemChanged += new EventHandler<EventArgs<int, int>>(MatrixParameter_ItemChanged);
    358382    }
    359     private void DergisterParameterEvents() {
     383    private void DeregisterParameterEvents() {
    360384      TargetVariableParameter.ValueChanged -= new EventHandler(TargetVariableParameter_ValueChanged);
    361385      ClassNamesParameter.Value.Reset -= new EventHandler(Parameter_ValueChanged);
  • branches/GeneralizedQAP/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolutionBase.cs

    r6589 r6685  
    4040    public new IClassificationProblemData ProblemData {
    4141      get { return (IClassificationProblemData)base.ProblemData; }
    42       protected set { base.ProblemData = value; }
     42      set { base.ProblemData = value; }
    4343    }
    4444
  • branches/GeneralizedQAP/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs

    r6581 r6685  
    3333  [StorableClass]
    3434  public abstract class DataAnalysisProblemData : ParameterizedNamedItem, IDataAnalysisProblemData {
    35     private const string DatasetParameterName = "Dataset";
    36     private const string InputVariablesParameterName = "InputVariables";
    37     private const string TrainingPartitionParameterName = "TrainingPartition";
    38     private const string TestPartitionParameterName = "TestPartition";
     35    protected const string DatasetParameterName = "Dataset";
     36    protected const string InputVariablesParameterName = "InputVariables";
     37    protected const string TrainingPartitionParameterName = "TrainingPartition";
     38    protected const string TestPartitionParameterName = "TestPartition";
    3939
    4040    #region parameter properites
     
    5353    #endregion
    5454
    55     #region propeties
     55    #region properties
     56    protected bool isEmpty = false;
     57    public bool IsEmpty {
     58      get { return isEmpty; }
     59    }
    5660    public Dataset Dataset {
    5761      get { return DatasetParameter.Value; }
     
    7478      get {
    7579        return Enumerable.Range(TrainingPartition.Start, TrainingPartition.End - TrainingPartition.Start)
    76                          .Where(i => i >= 0 && i < Dataset.Rows && (i < TestPartition.Start || TestPartition.End <= i));
     80                         .Where(IsTrainingSample);
    7781      }
    7882    }
     
    8084      get {
    8185        return Enumerable.Range(TestPartition.Start, TestPartition.End - TestPartition.Start)
    82            .Where(i => i >= 0 && i < Dataset.Rows);
     86           .Where(IsTestSample);
    8387      }
     88    }
     89
     90    public virtual bool IsTrainingSample(int index) {
     91      return index >= 0 && index < Dataset.Rows &&
     92        TrainingPartition.Start <= index && index < TrainingPartition.End &&
     93        (index < TestPartition.Start || TestPartition.End <= index);
     94    }
     95
     96    public virtual bool IsTestSample(int index) {
     97      return index >= 0 && index < Dataset.Rows &&
     98             TestPartition.Start <= index && index < TestPartition.End;
    8499    }
    85100    #endregion
     
    87102    protected DataAnalysisProblemData(DataAnalysisProblemData original, Cloner cloner)
    88103      : base(original, cloner) {
     104      isEmpty = original.isEmpty;
    89105      RegisterEventHandlers();
    90106    }
  • branches/GeneralizedQAP/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisSolution.cs

    r6606 r6685  
    5656    public IDataAnalysisProblemData ProblemData {
    5757      get { return (IDataAnalysisProblemData)this[ProblemDataResultName].Value; }
    58       protected set {
     58      set {
    5959        if (this[ProblemDataResultName].Value != value) {
    6060          if (value != null) {
  • branches/GeneralizedQAP/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionEnsembleModel.cs

    r6612 r6685  
    5858      this.models = original.Models.Select(m => cloner.Clone(m)).ToList();
    5959    }
     60
     61    public RegressionEnsembleModel() : this(Enumerable.Empty<IRegressionModel>()) { }
    6062    public RegressionEnsembleModel(IEnumerable<IRegressionModel> models)
    6163      : base() {
  • branches/GeneralizedQAP/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionEnsembleProblemData.cs

    r6238 r6685  
    2020#endregion
    2121
    22 using System;
    2322using System.Collections.Generic;
    24 using System.IO;
    25 using System.Linq;
    2623using HeuristicLab.Common;
    2724using HeuristicLab.Core;
     
    3532  public sealed class RegressionEnsembleProblemData : RegressionProblemData {
    3633
    37     public override IEnumerable<int> TrainingIndizes {
    38       get {
    39         return Enumerable.Range(TrainingPartition.Start, TrainingPartition.End - TrainingPartition.Start);
    40       }
     34    public override bool IsTrainingSample(int index) {
     35      return index >= 0 && index < Dataset.Rows &&
     36             TrainingPartition.Start <= index && index < TrainingPartition.End;
    4137    }
    4238
    43     public override IEnumerable<int> TestIndizes {
    44       get {
    45         return Enumerable.Range(TestPartition.Start, TestPartition.End - TestPartition.Start);
    46       }
     39    public override bool IsTestSample(int index) {
     40      return index >= 0 && index < Dataset.Rows &&
     41             TestPartition.Start <= index && index < TestPartition.End;
     42    }
     43
     44    private static readonly RegressionEnsembleProblemData emptyProblemData;
     45    public new static RegressionEnsembleProblemData EmptyProblemData {
     46      get { return emptyProblemData; }
     47    }
     48    static RegressionEnsembleProblemData() {
     49      var problemData = new RegressionEnsembleProblemData();
     50      problemData.Parameters.Clear();
     51      problemData.Name = "Empty Regression ProblemData";
     52      problemData.Description = "This ProblemData acts as place holder before the correct problem data is loaded.";
     53      problemData.isEmpty = true;
     54
     55      problemData.Parameters.Add(new FixedValueParameter<Dataset>(DatasetParameterName, "", new Dataset()));
     56      problemData.Parameters.Add(new FixedValueParameter<ReadOnlyCheckedItemList<StringValue>>(InputVariablesParameterName, ""));
     57      problemData.Parameters.Add(new FixedValueParameter<IntRange>(TrainingPartitionParameterName, "", (IntRange)new IntRange(0, 0).AsReadOnly()));
     58      problemData.Parameters.Add(new FixedValueParameter<IntRange>(TestPartitionParameterName, "", (IntRange)new IntRange(0, 0).AsReadOnly()));
     59      problemData.Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>()));
     60      emptyProblemData = problemData;
    4761    }
    4862
    4963    [StorableConstructor]
    5064    private RegressionEnsembleProblemData(bool deserializing) : base(deserializing) { }
     65    private RegressionEnsembleProblemData(RegressionEnsembleProblemData original, Cloner cloner) : base(original, cloner) { }
     66    public override IDeepCloneable Clone(Cloner cloner) {
     67      if (this == emptyProblemData) return emptyProblemData;
     68      return new RegressionEnsembleProblemData(this, cloner);
     69    }
    5170
    52     private RegressionEnsembleProblemData(RegressionEnsembleProblemData original, Cloner cloner)
    53       : base(original, cloner) {
    54     }
    55     public override IDeepCloneable Clone(Cloner cloner) { return new RegressionEnsembleProblemData(this, cloner); }
    56 
     71    public RegressionEnsembleProblemData() : base() { }
    5772    public RegressionEnsembleProblemData(IRegressionProblemData regressionProblemData)
    5873      : base(regressionProblemData.Dataset, regressionProblemData.AllowedInputVariables, regressionProblemData.TargetVariable) {
     
    6277      TestPartition.End = regressionProblemData.TestPartition.End;
    6378    }
     79    public RegressionEnsembleProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable)
     80      : base(dataset, allowedInputVariables, targetVariable) {
     81    }
    6482  }
    6583}
  • branches/GeneralizedQAP/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionEnsembleSolution.cs

    r6613 r6685  
    3535  [StorableClass]
    3636  [Item("Regression Ensemble Solution", "A regression solution that contains an ensemble of multiple regression models")]
    37   // [Creatable("Data Analysis")]
     37  [Creatable("Data Analysis - Ensembles")]
    3838  public sealed class RegressionEnsembleSolution : RegressionSolution, IRegressionEnsembleSolution {
    3939    public new IRegressionEnsembleModel Model {
    4040      get { return (IRegressionEnsembleModel)base.Model; }
     41    }
     42
     43    public new RegressionEnsembleProblemData ProblemData {
     44      get { return (RegressionEnsembleProblemData)base.ProblemData; }
     45      set { base.ProblemData = value; }
    4146    }
    4247
     
    5964    private void AfterDeserialization() {
    6065      foreach (var model in Model.Models) {
    61         IRegressionProblemData problemData = (IRegressionProblemData)ProblemData.Clone();
     66        IRegressionProblemData problemData = (IRegressionProblemData) ProblemData.Clone();
    6267        problemData.TrainingPartition.Start = trainingPartitions[model].Start;
    6368        problemData.TrainingPartition.End = trainingPartitions[model].End;
     
    8287
    8388      regressionSolutions = cloner.Clone(original.regressionSolutions);
     89      RegisterRegressionSolutionsEventHandler();
     90    }
     91
     92    public RegressionEnsembleSolution()
     93      : base(new RegressionEnsembleModel(), RegressionEnsembleProblemData.EmptyProblemData) {
     94      trainingPartitions = new Dictionary<IRegressionModel, IntRange>();
     95      testPartitions = new Dictionary<IRegressionModel, IntRange>();
     96      regressionSolutions = new ItemCollection<IRegressionSolution>();
     97
    8498      RegisterRegressionSolutionsEventHandler();
    8599    }
     
    203217    #endregion
    204218
     219    protected override void OnProblemDataChanged() {
     220      IRegressionProblemData problemData = new RegressionProblemData(ProblemData.Dataset,
     221                                                                     ProblemData.AllowedInputVariables,
     222                                                                     ProblemData.TargetVariable);
     223      problemData.TrainingPartition.Start = ProblemData.TrainingPartition.Start;
     224      problemData.TrainingPartition.End = ProblemData.TrainingPartition.End;
     225      problemData.TestPartition.Start = ProblemData.TestPartition.Start;
     226      problemData.TestPartition.End = ProblemData.TestPartition.End;
     227
     228      foreach (var solution in RegressionSolutions) {
     229        if (solution is RegressionEnsembleSolution)
     230          solution.ProblemData = ProblemData;
     231        else
     232          solution.ProblemData = problemData;
     233      }
     234      foreach (var trainingPartition in trainingPartitions.Values) {
     235        trainingPartition.Start = ProblemData.TrainingPartition.Start;
     236        trainingPartition.End = ProblemData.TrainingPartition.End;
     237      }
     238      foreach (var testPartition in testPartitions.Values) {
     239        testPartition.Start = ProblemData.TestPartition.Start;
     240        testPartition.End = ProblemData.TestPartition.End;
     241      }
     242
     243      base.OnProblemDataChanged();
     244    }
     245
    205246    public void AddRegressionSolutions(IEnumerable<IRegressionSolution> solutions) {
    206       solutions.OfType<RegressionEnsembleSolution>().SelectMany(ensemble => ensemble.RegressionSolutions);
    207247      regressionSolutions.AddRange(solutions);
    208248    }
  • branches/GeneralizedQAP/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblemData.cs

    r6439 r6685  
    3434  [Item("RegressionProblemData", "Represents an item containing all data defining a regression problem.")]
    3535  public class RegressionProblemData : DataAnalysisProblemData, IRegressionProblemData {
    36     private const string TargetVariableParameterName = "TargetVariable";
     36    protected const string TargetVariableParameterName = "TargetVariable";
    3737
    3838    #region default data
     
    6464          {0.83763905,  0.468046718}
    6565    };
    66     private static Dataset defaultDataset;
    67     private static IEnumerable<string> defaultAllowedInputVariables;
    68     private static string defaultTargetVariable;
     66    private static readonly Dataset defaultDataset;
     67    private static readonly IEnumerable<string> defaultAllowedInputVariables;
     68    private static readonly string defaultTargetVariable;
     69
     70    private static readonly RegressionProblemData emptyProblemData;
     71    public static RegressionProblemData EmptyProblemData {
     72      get { return emptyProblemData; }
     73    }
    6974
    7075    static RegressionProblemData() {
     
    7479      defaultAllowedInputVariables = new List<string>() { "x" };
    7580      defaultTargetVariable = "y";
     81
     82      var problemData = new RegressionProblemData();
     83      problemData.Parameters.Clear();
     84      problemData.Name = "Empty Regression ProblemData";
     85      problemData.Description = "This ProblemData acts as place holder before the correct problem data is loaded.";
     86      problemData.isEmpty = true;
     87
     88      problemData.Parameters.Add(new FixedValueParameter<Dataset>(DatasetParameterName, "", new Dataset()));
     89      problemData.Parameters.Add(new FixedValueParameter<ReadOnlyCheckedItemList<StringValue>>(InputVariablesParameterName, ""));
     90      problemData.Parameters.Add(new FixedValueParameter<IntRange>(TrainingPartitionParameterName, "", (IntRange)new IntRange(0, 0).AsReadOnly()));
     91      problemData.Parameters.Add(new FixedValueParameter<IntRange>(TestPartitionParameterName, "", (IntRange)new IntRange(0, 0).AsReadOnly()));
     92      problemData.Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>()));
     93      emptyProblemData = problemData;
    7694    }
    7795    #endregion
     
    91109    }
    92110
    93 
    94111    protected RegressionProblemData(RegressionProblemData original, Cloner cloner)
    95112      : base(original, cloner) {
    96113      RegisterParameterEvents();
    97114    }
    98     public override IDeepCloneable Clone(Cloner cloner) { return new RegressionProblemData(this, cloner); }
     115    public override IDeepCloneable Clone(Cloner cloner) {
     116      if (this == emptyProblemData) return emptyProblemData;
     117      return new RegressionProblemData(this, cloner);
     118    }
    99119
    100120    public RegressionProblemData()
  • branches/GeneralizedQAP/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolutionBase.cs

    r6643 r6685  
    4848    public new IRegressionProblemData ProblemData {
    4949      get { return (IRegressionProblemData)base.ProblemData; }
    50       protected set { base.ProblemData = value; }
     50      set { base.ProblemData = value; }
    5151    }
    5252
     
    127127        OnlineCalculatorError errorState;
    128128        Add(new Result(TrainingMeanAbsoluteErrorResultName, "Mean of absolute errors of the model on the training partition", new DoubleValue()));
    129         double trainingMAE = OnlineMeanSquaredErrorCalculator.Calculate(EstimatedTrainingValues, ProblemData.Dataset.GetEnumeratedVariableValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes), out errorState);
     129        double trainingMAE = OnlineMeanAbsoluteErrorCalculator.Calculate(EstimatedTrainingValues, ProblemData.Dataset.GetEnumeratedVariableValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes), out errorState);
    130130        TrainingMeanAbsoluteError = errorState == OnlineCalculatorError.None ? trainingMAE : double.NaN;
    131131      }
  • branches/GeneralizedQAP/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Classification/IClassificationSolution.cs

    r5809 r6685  
    2020#endregion
    2121
    22 using System;
    2322using System.Collections.Generic;
    2423namespace HeuristicLab.Problems.DataAnalysis {
    2524  public interface IClassificationSolution : IDataAnalysisSolution {
    2625    new IClassificationModel Model { get; }
    27     new IClassificationProblemData ProblemData { get; }
     26    new IClassificationProblemData ProblemData { get; set; }
    2827
    2928    IEnumerable<double> EstimatedClassValues { get; }
  • branches/GeneralizedQAP/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Clustering/IClusteringSolution.cs

    r5809 r6685  
    2424  public interface IClusteringSolution : IDataAnalysisSolution {
    2525    new IClusteringModel Model { get; }
    26     new IClusteringProblemData ProblemData { get; }
     26    new IClusteringProblemData ProblemData { get; set; }
    2727
    2828    IEnumerable<int> ClusterValues { get; }
  • branches/GeneralizedQAP/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisProblemData.cs

    r5883 r6685  
    2727namespace HeuristicLab.Problems.DataAnalysis {
    2828  public interface IDataAnalysisProblemData : INamedItem {
     29    bool IsEmpty { get; }
     30
    2931    Dataset Dataset { get; }
    3032    ICheckedItemList<StringValue> InputVariables { get; }
     
    3739    IEnumerable<int> TestIndizes { get; }
    3840
     41    bool IsTrainingSample(int index);
     42    bool IsTestSample(int index);
     43
    3944    event EventHandler Changed;
    4045  }
  • branches/GeneralizedQAP/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisSolution.cs

    r5909 r6685  
    2121
    2222using System;
     23using HeuristicLab.Common;
    2324using HeuristicLab.Core;
    24 using HeuristicLab.Common;
    2525
    2626namespace HeuristicLab.Problems.DataAnalysis {
    2727  public interface IDataAnalysisSolution : INamedItem, IStorableContent {
    2828    IDataAnalysisModel Model { get; }
    29     IDataAnalysisProblemData ProblemData { get; }
     29    IDataAnalysisProblemData ProblemData { get; set; }
    3030
    3131    event EventHandler ModelChanged;
  • branches/GeneralizedQAP/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Regression/IRegressionEnsembleSolution.cs

    r6612 r6685  
    2525  public interface IRegressionEnsembleSolution : IRegressionSolution {
    2626    new IRegressionEnsembleModel Model { get; }
     27    new RegressionEnsembleProblemData ProblemData { get; set; }
    2728    IItemCollection<IRegressionSolution> RegressionSolutions { get; }
    2829    IEnumerable<IEnumerable<double>> GetEstimatedValueVectors(Dataset dataset, IEnumerable<int> rows);
  • branches/GeneralizedQAP/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Regression/IRegressionSolution.cs

    r6643 r6685  
    2424  public interface IRegressionSolution : IDataAnalysisSolution {
    2525    new IRegressionModel Model { get; }
    26     new IRegressionProblemData ProblemData { get; }
     26    new IRegressionProblemData ProblemData { get; set; }
    2727
    2828    IEnumerable<double> EstimatedValues { get; }
Note: See TracChangeset for help on using the changeset viewer.