Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Moves/StochasticPolynomialMultiMoveGenerator.cs @ 4068

Last change on this file since 4068 was 4068, checked in by swagner, 14 years ago

Sorted usings and removed unused usings in entire solution (#1094)

File size: 3.9 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using HeuristicLab.Core;
23using HeuristicLab.Data;
24using HeuristicLab.Optimization;
25using HeuristicLab.Parameters;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
27
28namespace HeuristicLab.Encodings.RealVectorEncoding {
29  [Item("StochasticPolynomialMultiMoveGenerator", "Generates polynomial moves from a given real vector.")]
30  [StorableClass]
31  public class StochasticPolynomialMultiMoveGenerator : AdditiveMoveGenerator, IMultiMoveGenerator {
32    /// <summary>
33    /// The maximum manipulation parameter specifies the range of the manipulation. The value specified here is the highest value the mutation will ever add to the current value.
34    /// </summary>
35    public ValueLookupParameter<DoubleValue> MaximumManipulationParameter {
36      get { return (ValueLookupParameter<DoubleValue>)Parameters["MaximumManipulation"]; }
37    }
38    /// <summary>
39    /// The contiguity parameter specifies the shape of the probability density function that controls the mutation. Setting it to 0 is similar to a uniform distribution over the entire manipulation range (specified by <see cref="MaximumManipulationParameter"/>.
40    /// A higher value will shape the density function such that values closer to 0 (little manipulation) are more likely than values closer to 1 or -1 (maximum manipulation).
41    /// </summary>
42    public IValueLookupParameter<DoubleValue> ContiguityParameter {
43      get { return (IValueLookupParameter<DoubleValue>)Parameters["Contiguity"]; }
44    }
45    public IValueLookupParameter<IntValue> SampleSizeParameter {
46      get { return (IValueLookupParameter<IntValue>)Parameters["SampleSize"]; }
47    }
48
49    public StochasticPolynomialMultiMoveGenerator()
50      : base() {
51      Parameters.Add(new ValueLookupParameter<DoubleValue>("Contiguity", "Specifies whether the manipulation should produce far stretching (small value) or close (large value) manipulations with higher probability. Valid values must be greater or equal to 0.", new DoubleValue(2)));
52      Parameters.Add(new ValueLookupParameter<IntValue>("SampleSize", "The number of moves that should be generated."));
53      Parameters.Add(new ValueLookupParameter<DoubleValue>("MaximumManipulation", "Specifies the maximum value that should be added or subtracted by the manipulation. If this value is set to 0 no mutation will be performed.", new DoubleValue(1)));
54    }
55
56    public static AdditiveMove[] Apply(IRandom random, RealVector realVector, double contiguity, int sampleSize, double maxManipulation) {
57      AdditiveMove[] moves = new AdditiveMove[sampleSize];
58      for (int i = 0; i < sampleSize; i++) {
59        int index = random.Next(realVector.Length);
60        moves[i] = new AdditiveMove(index, PolynomialOnePositionManipulator.Apply(random, contiguity) * maxManipulation);
61      }
62      return moves;
63    }
64
65    protected override AdditiveMove[] GenerateMoves(IRandom random, RealVector realVector) {
66      return Apply(random, realVector, ContiguityParameter.ActualValue.Value, SampleSizeParameter.ActualValue.Value, MaximumManipulationParameter.ActualValue.Value);
67    }
68  }
69}
Note: See TracBrowser for help on using the repository browser.