#region License Information
/* HeuristicLab
* Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using HeuristicLab.Common;
using HeuristicLab.Core;
using HeuristicLab.Data;
using HeuristicLab.Parameters;
using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
using HeuristicLab.Problems.DataAnalysis;
namespace HeuristicLab.Optimization.Operators.LCS {
[StorableClass]
[Item("GAssistEnsembleProblemData", "")]
public class GAssistEnsembleProblemData : ParameterizedNamedItem, IGAssistEnsembleProblemData {
public IValueParameter ProblemDataParameter {
get { return (IValueParameter)Parameters["ProblemData"]; }
}
public bool IsTrainingSample(int index) {
return index >= 0 && index < Dataset.Rows &&
TrainingPartition.Start <= index && index < TrainingPartition.End;
}
public bool IsTestSample(int index) {
return index >= 0 && index < Dataset.Rows &&
TestPartition.Start <= index && index < TestPartition.End;
}
public IEnumerable TrainingIndices {
get {
return Enumerable.Range(TrainingPartition.Start, Math.Max(0, TrainingPartition.End - TrainingPartition.Start))
.Where(IsTrainingSample);
}
}
public IEnumerable TestIndices {
get {
return Enumerable.Range(TestPartition.Start, Math.Max(0, TestPartition.End - TestPartition.Start))
.Where(IsTestSample);
}
}
[Storable]
private IGAssistProblemData problemData;
[StorableConstructor]
protected GAssistEnsembleProblemData(bool deserializing) : base(deserializing) { }
protected GAssistEnsembleProblemData(GAssistEnsembleProblemData original, Cloner cloner)
: base(original, cloner) {
problemData = (IGAssistProblemData)original.problemData.Clone();
}
public GAssistEnsembleProblemData()
: base() {
Parameters.Add(new ValueParameter("ProblemData", ""));
}
public GAssistEnsembleProblemData(IGAssistProblemData problemData)
: base() {
this.problemData = problemData;
Parameters.Add(new ValueParameter("ProblemData", "", problemData));
}
public override IDeepCloneable Clone(Cloner cloner) {
return new GAssistEnsembleProblemData(this, cloner);
}
public IGAssistProblemData GetGAssistProblemData() {
return (IGAssistProblemData)problemData.Clone();
}
#region IGAssistProblemData Members
public ICheckedItemList ConditionVariables {
get { return problemData.ConditionVariables; }
}
public StringValue TargetVariable {
get { return problemData.TargetVariable; }
}
public IEnumerable AllowedConditionVariables {
get { return problemData.AllowedConditionVariables; }
}
public int Classes {
get { return problemData.Classes; }
}
public IGAssistInput FetchInput(int row) {
return problemData.FetchInput(row);
}
public IEnumerable FetchInput(IEnumerable rows) {
return problemData.FetchInput(rows);
}
public IEnumerable FetchAction(IEnumerable rows) {
return problemData.FetchAction(rows);
}
public IGAssistNiche FetchAction(int rows) {
return problemData.FetchAction(rows);
}
public IEnumerable GetPossibleNiches() {
return problemData.GetPossibleNiches();
}
#endregion
#region IDataAnalysisProblemData Members
public bool IsEmpty {
get { return problemData.IsEmpty; }
}
public Dataset Dataset {
get { return problemData.Dataset; }
}
public ICheckedItemList InputVariables {
get { return problemData.InputVariables; }
}
public IEnumerable AllowedInputVariables {
get { return problemData.AllowedInputVariables; }
}
public IntRange TrainingPartition {
get { return problemData.TrainingPartition; }
}
public IntRange TestPartition {
get { return problemData.TestPartition; }
}
public event System.EventHandler Changed;
#endregion
}
}