Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.BioBoost/HeuristicLab.Problems.BioBoost/3.3/Operators/Mutation/NeighborBasedIntegerVectorMutator.cs @ 13069

Last change on this file since 13069 was 13069, checked in by gkronber, 8 years ago

#2499: imported source code for HeuristicLab.BioBoost from private repository with some changes

File size: 1.6 KB
Line 
1using HeuristicLab.BioBoost.ProblemDescription;
2using HeuristicLab.Common;
3using HeuristicLab.Core;
4using HeuristicLab.Data;
5using HeuristicLab.Encodings.IntegerVectorEncoding;
6using HeuristicLab.Parameters;
7using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
8
9namespace 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}
Note: See TracBrowser for help on using the repository browser.