source: branches/StackingProblems/HeuristicLab.Encodings.MoveVectorEncoding/3.3/Creators/RandomMoveVectorCreator.cs @ 14278

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

Initial Commit for ticket #2605

Implemented:

  • Encoding
  • Moves
  • Views
  • Blocks World Problem
  • Blocks Relocation Problem
  • Stacking Problem
File size: 1.6 KB
Line 
1using HeuristicLab.Common;
2using HeuristicLab.Core;
3using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
4using HeuristicLab.PluginInfrastructure;
5using HeuristicLab.Data;
6using HeuristicLab.Data.MoveVectorData;
7using HeuristicLab.Data.MoveVectorData.Interfaces;
8using System.Linq;
9using System;
10using System.Collections.Generic;
11
12namespace HeuristicLab.Encodings.MoveVectorEncoding.Creators
13{
14    [NonDiscoverableType]
15    [StorableClass]
16    [Item("RandomMoveVectorCreator", "An operator that creates new MoveVectors using random methods")]
17    public class RandomMoveVectorCreator : MoveVectorCreator
18    {
19
20        #region Cloning
21        [StorableConstructor]
22        protected RandomMoveVectorCreator(bool deserializing) : base(deserializing) { }
23        protected RandomMoveVectorCreator(RandomMoveVectorCreator original, Cloner cloner) : base(original, cloner) { }
24        public override IDeepCloneable Clone(Cloner cloner)
25        {
26            var ret = new RandomMoveVectorCreator(this, cloner);
27            ret.MoveTypes = this.MoveTypes;
28            return ret;
29        }
30        #endregion
31
32        public RandomMoveVectorCreator() : base() { }
33
34        public static MoveVector Apply(IRandom random, IList<Type> moveTypes, int length, IntMatrix bounds)
35        {
36            var result = new MoveVector(length, moveTypes);
37            result.Randomize(random, bounds);
38            return result;
39        }
40
41        public override MoveVector Create(IRandom random, IntValue length, IntMatrix bounds)
42        {
43            return Apply(random, MoveTypes, length.Value, bounds);
44        }
45    }
46}
Note: See TracBrowser for help on using the repository browser.