1 | using HeuristicLab.BioBoost.ProblemDescription;
|
---|
2 | using HeuristicLab.Common;
|
---|
3 | using HeuristicLab.Core;
|
---|
4 | using HeuristicLab.Data;
|
---|
5 | using HeuristicLab.Encodings.IntegerVectorEncoding;
|
---|
6 | using HeuristicLab.Parameters;
|
---|
7 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
8 |
|
---|
9 | namespace HeuristicLab.BioBoost.Operators.Mutation {
|
---|
10 | [StorableClass]
|
---|
11 | public class NeighborBasedIntegerVectorMutator : BoundedIntegerVectorManipulator {
|
---|
12 |
|
---|
13 | public LookupParameter<BioBoostProblemData> ProblemDataParameter {
|
---|
14 | get { return (LookupParameter<BioBoostProblemData>) Parameters["ProblemData"]; }
|
---|
15 | }
|
---|
16 |
|
---|
17 | public BioBoostProblemData ProblemData {
|
---|
18 | get { return ProblemDataParameter.ActualValue; }
|
---|
19 | }
|
---|
20 |
|
---|
21 | #region Construction & Cloning
|
---|
22 | [StorableConstructor]
|
---|
23 | protected NeighborBasedIntegerVectorMutator(bool isDeserializing) : base(isDeserializing) {}
|
---|
24 | protected NeighborBasedIntegerVectorMutator(NeighborBasedIntegerVectorMutator orig, Cloner cloner) : base(orig, cloner) {}
|
---|
25 | public NeighborBasedIntegerVectorMutator() {
|
---|
26 | Parameters.Add(new LookupParameter<BioBoostProblemData>("ProblemData", "The problem instance description container."));
|
---|
27 | }
|
---|
28 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
29 | return new NeighborBasedIntegerVectorMutator(this, cloner);
|
---|
30 | }
|
---|
31 | #endregion
|
---|
32 |
|
---|
33 | protected override void ManipulateBounded(IRandom random, IntegerVector integerVector, IntMatrix bounds) {
|
---|
34 | var source = random.Next(integerVector.Length);
|
---|
35 | var target = integerVector[source];
|
---|
36 | integerVector[source] = ProblemData.Neighbors.GetRandomNeighbor(target, random, bounds[0, 1]);
|
---|
37 | }
|
---|
38 | }
|
---|
39 | }
|
---|