Free cookie consent management tool by TermsFeed Policy Generator

source: branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/Covering/CombinedIntegerVectorCoveringCreator.cs @ 9110

Last change on this file since 9110 was 9110, checked in by sforsten, 11 years ago

#1980:

  • added GA subsumption
  • simplified deletion before covering
  • simplified XCSDeletionOperator
File size: 3.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 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 HeuristicLab.Common;
23using HeuristicLab.Core;
24using HeuristicLab.Data;
25using HeuristicLab.Encodings.ConditionActionEncoding;
26using HeuristicLab.Operators;
27using HeuristicLab.Parameters;
28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
29
30namespace HeuristicLab.Encodings.CombinedIntegerVectorEncoding {
31  [Item("CombinedIntegerVectorCoveringCreator", "Description missing")]
32  [StorableClass]
33  public class CombinedIntegerVectorCoveringCreator : SingleSuccessorOperator, ICoveringSolutionCreator {
34
35    #region Parameter Properties
36    public ILookupParameter<IClassifier> CoverClassifierParameter {
37      get { return (ILookupParameter<IClassifier>)Parameters["CoverClassifier"]; }
38    }
39    public ILookupParameter<IClassifier> ActionParameter {
40      get { return (ILookupParameter<IClassifier>)Parameters["Action"]; }
41    }
42    public IValueLookupParameter<IClassifier> CreatedClassifierParameter {
43      get { return (IValueLookupParameter<IClassifier>)Parameters["CreatedClassifier"]; }
44    }
45    public ILookupParameter<PercentValue> ChangeSymbolProbabilityParameter {
46      get { return (ILookupParameter<PercentValue>)Parameters["ChangeSymbolProbability"]; }
47    }
48    public ILookupParameter<IRandom> RandomParameter {
49      get { return (ILookupParameter<IRandom>)Parameters["Random"]; }
50    }
51
52    #endregion
53
54    [StorableConstructor]
55    protected CombinedIntegerVectorCoveringCreator(bool deserializing) : base(deserializing) { }
56    protected CombinedIntegerVectorCoveringCreator(CombinedIntegerVectorCoveringCreator original, Cloner cloner)
57      : base(original, cloner) {
58    }
59    public override IDeepCloneable Clone(Cloner cloner) {
60      return new CombinedIntegerVectorCoveringCreator(this, cloner);
61    }
62    public CombinedIntegerVectorCoveringCreator()
63      : base() {
64      Parameters.Add(new LookupParameter<IClassifier>("CoverClassifier"));
65      Parameters.Add(new LookupParameter<IClassifier>("Action"));
66      Parameters.Add(new ValueLookupParameter<IClassifier>("CreatedClassifier"));
67      Parameters.Add(new LookupParameter<PercentValue>("ChangeSymbolProbability"));
68      Parameters.Add(new LookupParameter<IRandom>("Random"));
69    }
70
71    public override IOperation Apply() {
72      CombinedIntegerVector newCondition = (CombinedIntegerVector)CoverClassifierParameter.ActualValue.Condition.Clone();
73
74      CombinedIntegerVector condition = (CombinedIntegerVector)CoverClassifierParameter.ActualValue.Condition;
75      CombinedIntegerVector action = (CombinedIntegerVector)ActionParameter.ActualValue.Action;
76
77      newCondition = UniformSomePositionManipulator.ManipulateCondition(RandomParameter.ActualValue, condition, newCondition, ChangeSymbolProbabilityParameter.ActualValue.Value);
78
79      CreatedClassifierParameter.ActualValue = new CombinedIntegerVector(newCondition, newCondition.Bounds, action, action.Bounds);
80      return base.Apply();
81    }
82  }
83}
Note: See TracBrowser for help on using the repository browser.