source: branches/StackingProblems/HeuristicLab.Encodings.MoveVectorEncoding/3.3/BoundedMoveVectorManipulator.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.8 KB
Line 
1using HeuristicLab.Common;
2using HeuristicLab.Core;
3using HeuristicLab.Data;
4using HeuristicLab.Data.MoveVectorData;
5using HeuristicLab.Encodings.MoveVectorEncoding.Interfaces;
6using HeuristicLab.Parameters;
7using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
8using System;
9
10namespace HeuristicLab.Encodings.MoveVectorEncoding
11{
12    [Item("BoundedMoveVectorManipulator", "A base class for operators that manipulate bounded move vectors.")]
13    [StorableClass]
14    public abstract class BoundedMoveVectorManipulator : MoveVectorManipulator, IBoundedMoveVectorOperator
15    {
16        public IValueLookupParameter<IntMatrix> BoundsParameter
17        {
18            get { return (IValueLookupParameter<IntMatrix>)Parameters["Bounds"]; }
19        }
20
21        [StorableConstructor]
22        protected BoundedMoveVectorManipulator(bool deserializing) : base(deserializing) { }
23        protected BoundedMoveVectorManipulator(BoundedMoveVectorManipulator original, Cloner cloner) : base(original, cloner) { }
24        protected BoundedMoveVectorManipulator() : base()
25        {
26           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."));
27        }
28
29        protected sealed override void Manipulate(IRandom random, MoveVector moveVector)
30        {
31            if (BoundsParameter.ActualValue == null) throw new InvalidOperationException("BoundedIntegerVectorManipulator: Parameter " + BoundsParameter.ActualName + " could not be found.");
32            ManipulateBounded(random, moveVector, BoundsParameter.ActualValue);
33        }
34
35        protected abstract void ManipulateBounded(IRandom random, MoveVector moveVector, IntMatrix bounds);
36    }
37}
Note: See TracBrowser for help on using the repository browser.