#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 HeuristicLab.Common;
using HeuristicLab.Core;
using HeuristicLab.Data;
using HeuristicLab.Operators;
using HeuristicLab.Optimization.Operators.LCS;
using HeuristicLab.Parameters;
using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
namespace HeuristicLab.Encodings.DecisionList {
[Item("DecisionListCreator", "Description missing")]
[StorableClass]
public abstract class DecisionListCreator : SingleSuccessorOperator, IDecisionListCreator {
#region Parameter Properties
public IValueLookupParameter ProblemDataParameter {
get { return (IValueLookupParameter)Parameters["ProblemData"]; }
}
public IValueLookupParameter InitialNumberOfRulesParameter {
get { return (IValueLookupParameter)Parameters["InitialNumberOfRules"]; }
}
public IValueLookupParameter OneProbabilityParameter {
get { return (IValueLookupParameter)Parameters["OneProbability"]; }
}
public IValueLookupParameter> DiscretizersParameter {
get { return (IValueLookupParameter>)Parameters["Discretizers"]; }
}
public ILookupParameter DecisionListParameter {
get { return (ILookupParameter)Parameters["DecisionList"]; }
}
public ILookupParameter RandomParameter {
get { return (ILookupParameter)Parameters["Random"]; }
}
public ILookupParameter GAssistNicheParameter {
get { return (ILookupParameter)Parameters["GAssistNiche"]; }
}
#endregion
[StorableConstructor]
protected DecisionListCreator(bool deserializing) : base(deserializing) { }
protected DecisionListCreator(DecisionListCreator original, Cloner cloner)
: base(original, cloner) {
}
public DecisionListCreator()
: base() {
Parameters.Add(new ValueLookupParameter("ProblemData", ""));
Parameters.Add(new ValueLookupParameter("InitialNumberOfRules", ""));
Parameters.Add(new ValueLookupParameter("OneProbability", ""));
Parameters.Add(new ValueLookupParameter>("Discretizers", ""));
Parameters.Add(new LookupParameter("DecisionList", ""));
Parameters.Add(new LookupParameter("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
Parameters.Add(new LookupParameter("GAssistNiche", ""));
}
public override IOperation Apply() {
if (GAssistNicheParameter.ActualValue != null && !(GAssistNicheParameter.ActualValue is IAction)) throw new ArgumentException("GAssistNiche has to be a IAction.");
DecisionListParameter.ActualValue = Create(RandomParameter.ActualValue,
ProblemDataParameter.ActualValue.SampleRuleParameter.Value,
InitialNumberOfRulesParameter.ActualValue.Value,
OneProbabilityParameter.ActualValue.Value,
DiscretizersParameter.ActualValue,
(IAction)GAssistNicheParameter.ActualValue);
return base.Apply();
}
protected abstract DecisionList Create(IRandom random, Rule sampleRule, int initialNumberOfRules, double oneProbability, ItemCollection discretizers, IAction niche);
}
}