Free cookie consent management tool by TermsFeed Policy Generator

source: branches/LearningClassifierSystems/HeuristicLab.Encodings.CombinedIntegerVectorEncoding/3.3/Crossovers/SinglePointCrossover.cs @ 9089

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

#1980:

  • added ConditionActionClassificationProblem
  • added ConditionActionEncoding
  • added Manipulators, Crossovers and an LCSAdaptedGeneticAlgorithm
  • changed LearningClassifierSystemMainLoop
File size: 2.2 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 System;
23using HeuristicLab.Common;
24using HeuristicLab.Core;
25using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
26
27namespace HeuristicLab.Encodings.CombinedIntegerVectorEncoding {
28  [Item("SinglePointCrossover", "Single point crossover for integer vectors. It is implemented as described in Michalewicz, Z. 1999. Genetic Algorithms + Data Structures = Evolution Programs. Third, Revised and Extended Edition, Spring-Verlag Berlin Heidelberg.")]
29  [StorableClass]
30  public class SinglePointCrossover : CombinedIntegerVectorCrossover {
31    [StorableConstructor]
32    protected SinglePointCrossover(bool deserializing) : base(deserializing) { }
33    protected SinglePointCrossover(SinglePointCrossover original, Cloner cloner) : base(original, cloner) { }
34    public SinglePointCrossover() : base() { }
35
36    public override IDeepCloneable Clone(Cloner cloner) {
37      return new SinglePointCrossover(this, cloner);
38    }
39
40    protected override CombinedIntegerVector Cross(IRandom random, ItemArray<CombinedIntegerVector> parents) {
41      if (parents.Length != 2) throw new ArgumentException("ERROR in SinglePointCrossover: The number of parents is not equal to 2");
42      return new CombinedIntegerVector(HeuristicLab.Encodings.IntegerVectorEncoding.SinglePointCrossover.Apply(random, parents[0], parents[1]), parents[0].ActionLength, parents[0].Bounds);
43    }
44  }
45}
Note: See TracBrowser for help on using the repository browser.