Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2605_StackingProblems/HeuristicLab.Encodings.MoveVectorEncoding/3.3/MoveVectorCreator.cs @ 17393

Last change on this file since 17393 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: 3.4 KB
Line 
1using HeuristicLab.Encodings.MoveVectorEncoding.Interfaces;
2using HeuristicLab.Operators;
3using HeuristicLab.Optimization;
4using HeuristicLab.Core;
5using HeuristicLab.Common;
6using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
7using HeuristicLab.Data;
8using HeuristicLab.Parameters;
9using HeuristicLab.Data.MoveVectorData;
10using System.Collections.Generic;
11using HeuristicLab.Data.MoveVectorData.Interfaces;
12using System;
13using HeuristicLab.PluginInfrastructure;
14using System.Linq;
15
16namespace HeuristicLab.Encodings.MoveVectorEncoding
17{
18    [Item("MoveVectorCreator", "A base class for operators creating Move Vectors.")]
19    [StorableClass]
20    public abstract class MoveVectorCreator : InstrumentedOperator, IMoveVectorCreator, IStochasticOperator
21    {
22        #region Parameter Properties
23        public ILookupParameter<IRandom> RandomParameter
24        {
25            get { return (LookupParameter<IRandom>)Parameters["Random"]; }
26        }
27        public ILookupParameter<MoveVector> MoveVectorParameter
28        {
29            get { return (ILookupParameter<MoveVector>)Parameters["MoveVector"]; }
30        }
31        public IValueLookupParameter<IntValue> LengthParameter
32        {
33            get { return (IValueLookupParameter<IntValue>)Parameters["Length"]; }
34        }
35        public IValueLookupParameter<IntMatrix> BoundsParameter
36        {
37            get { return (IValueLookupParameter<IntMatrix>)Parameters["Bounds"]; }
38        }
39        #endregion
40
41        #region Properties
42        [Storable]
43        private IList<Type> moveTypes;
44        public IList<Type> MoveTypes
45        {
46            get
47            {
48                if(moveTypes == null) moveTypes = ApplicationManager.Manager.GetTypes(typeof(IMove)).ToList();
49                return moveTypes;
50            }
51            set
52            {
53                moveTypes = value;
54            }
55        }
56        #endregion
57
58        #region Cloning
59        [StorableConstructor]
60        protected MoveVectorCreator(bool deserializing) : base(deserializing) { }
61        protected MoveVectorCreator(MoveVectorCreator original, Cloner cloner) : base(original, cloner) { }
62        [StorableHook(HookType.AfterDeserialization)]
63        private void AfterDeserialization()
64        {
65        }
66        #endregion
67
68        protected MoveVectorCreator(): base() {
69            Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
70            Parameters.Add(new LookupParameter<MoveVector>("MoveVector", "The move vector which should be manipulated."));
71            Parameters.Add(new ValueLookupParameter<IntValue>("Length", "The length of the vector."));
72            Parameters.Add(new ValueLookupParameter<IntMatrix>("Bounds", "The bounds matrix can contain one row for each dimension with three columns specifying minimum (inclusive), maximum (exclusive), and step size. If less rows are given the matrix is cycled."));
73        }
74
75        public override IOperation InstrumentedApply()
76        {
77            MoveVectorParameter.ActualValue = Create(RandomParameter.ActualValue, LengthParameter.ActualValue, BoundsParameter.ActualValue);
78            return base.InstrumentedApply();
79        }
80
81        public abstract MoveVector Create(IRandom random, IntValue length, IntMatrix bounds);
82    }
83}
Note: See TracBrowser for help on using the repository browser.