1 | using HeuristicLab.Common;
|
---|
2 | using HeuristicLab.Core;
|
---|
3 | using HeuristicLab.Data;
|
---|
4 | using HeuristicLab.Data.MoveVectorData;
|
---|
5 | using HeuristicLab.Encodings.MoveVectorEncoding.Interfaces;
|
---|
6 | using HeuristicLab.Parameters;
|
---|
7 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
8 | using System;
|
---|
9 |
|
---|
10 | namespace 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 | }
|
---|