Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2605_StackingProblems/HeuristicLab.Encodings.MoveVectorEncoding/3.3/MoveVectorCrossover.cs

Last change on this file was 14278, checked in by mzehetho, 8 years ago

Initial Commit for ticket #2605

Implemented:

  • Encoding
  • Moves
  • Views
  • Blocks World Problem
  • Blocks Relocation Problem
  • Stacking Problem
File size: 2.3 KB
Line 
1using HeuristicLab.Common;
2using HeuristicLab.Core;
3using HeuristicLab.Data.MoveVectorData;
4using HeuristicLab.Encodings.MoveVectorEncoding.Interfaces;
5using HeuristicLab.Optimization;
6using HeuristicLab.Parameters;
7using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
8
9namespace HeuristicLab.Encodings.MoveVectorEncoding
10{
11    [Item("MoveVectorCrossover", "A base class for operators that perform a crossover of int-valued vectors.")]
12    [StorableClass]
13    public abstract class MoveVectorCrossover : MoveVectorOperator, IMoveVectorCrossover, IStochasticOperator
14    {
15        public override bool CanChangeName
16        {
17            get { return false; }
18        }
19        public ILookupParameter<IRandom> RandomParameter
20        {
21            get { return (LookupParameter<IRandom>)Parameters["Random"]; }
22        }
23        public ILookupParameter<ItemArray<MoveVector>> ParentsParameter
24        {
25            get { return (ScopeTreeLookupParameter<MoveVector>)Parameters["Parents"]; }
26        }
27        public ILookupParameter<MoveVector> ChildParameter
28        {
29            get { return (ILookupParameter<MoveVector>)Parameters["Child"]; }
30        }
31
32        [StorableConstructor]
33        protected MoveVectorCrossover(bool deserializing) : base(deserializing) { }
34        protected MoveVectorCrossover(MoveVectorCrossover original, Cloner cloner) : base(original, cloner) { }
35        protected MoveVectorCrossover() : base()
36        {
37            Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic crossover operators."));
38            Parameters.Add(new ScopeTreeLookupParameter<MoveVector>("Parents", "The parent vectors which should be crossed."));
39            ParentsParameter.ActualName = "IntegerVector";
40            Parameters.Add(new LookupParameter<MoveVector>("Child", "The child vector resulting from the crossover."));
41            ChildParameter.ActualName = "IntegerVector";
42        }
43
44        public sealed override IOperation InstrumentedApply()
45        {
46            ChildParameter.ActualValue = Cross(RandomParameter.ActualValue, ParentsParameter.ActualValue);
47            return base.InstrumentedApply();
48        }
49
50        protected abstract MoveVector Cross(IRandom random, ItemArray<MoveVector> parents);
51    }
52}
Note: See TracBrowser for help on using the repository browser.