Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/10/15 09:57:29 (10 years ago)
Author:
pfleck
Message:

#2269 merged trunk

Location:
branches/ALPS
Files:
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/ALPS

  • branches/ALPS/HeuristicLab.Encodings.RealVectorEncoding

    • Property svn:mergeinfo set to (toggle deleted branches)
      /branches/HLScript/HeuristicLab.Encodings.RealVectorEncodingmergedeligible
      /stable/HeuristicLab.Encodings.RealVectorEncodingmergedeligible
      /trunk/sources/HeuristicLab.Encodings.RealVectorEncodingmergedeligible
      /branches/1721-RandomForestPersistence/HeuristicLab.Encodings.RealVectorEncoding10321-10322
      /branches/Algorithms.GradientDescent/HeuristicLab.Encodings.RealVectorEncoding5516-5520
      /branches/Benchmarking/sources/HeuristicLab.Encodings.RealVectorEncoding6917-7005
      /branches/CloningRefactoring/HeuristicLab.Encodings.RealVectorEncoding4656-4721
      /branches/CodeEditor/HeuristicLab.Encodings.RealVectorEncoding11700-11806
      /branches/DataAnalysis Refactoring/HeuristicLab.Encodings.RealVectorEncoding5471-5808
      /branches/DataAnalysis SolutionEnsembles/HeuristicLab.Encodings.RealVectorEncoding5815-6180
      /branches/DataAnalysis/HeuristicLab.Encodings.RealVectorEncoding4458-4459,​4462,​4464
      /branches/DataPreprocessing/HeuristicLab.Encodings.RealVectorEncoding10085-11101
      /branches/GP.Grammar.Editor/HeuristicLab.Encodings.RealVectorEncoding6284-6795
      /branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Encodings.RealVectorEncoding5060
      /branches/HeuristicLab.Problems.DataAnalysis.Trading/HeuristicLab.Encodings.RealVectorEncoding6123-9799
      /branches/LogResidualEvaluator/HeuristicLab.Encodings.RealVectorEncoding10202-10483
      /branches/NET40/sources/HeuristicLab.Encodings.RealVectorEncoding5138-5162
      /branches/ParallelEngine/HeuristicLab.Encodings.RealVectorEncoding5175-5192
      /branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Encodings.RealVectorEncoding7568-7810
      /branches/ProgrammableProblem/HeuristicLab.Encodings.RealVectorEncoding11777-11959
      /branches/QAPAlgorithms/HeuristicLab.Encodings.RealVectorEncoding6350-6627
      /branches/Restructure trunk solution/HeuristicLab.Encodings.RealVectorEncoding6828
      /branches/RuntimeOptimizer/HeuristicLab.Encodings.RealVectorEncoding8943-9078
      /branches/ScatterSearch (trunk integration)/HeuristicLab.Encodings.RealVectorEncoding7787-8333
      /branches/SlaveShutdown/HeuristicLab.Encodings.RealVectorEncoding8944-8956
      /branches/SpectralKernelForGaussianProcesses/HeuristicLab.Encodings.RealVectorEncoding10204-10479
      /branches/SuccessProgressAnalysis/HeuristicLab.Encodings.RealVectorEncoding5370-5682
      /branches/Trunk/HeuristicLab.Encodings.RealVectorEncoding6829-6865
      /branches/UnloadJobs/HeuristicLab.Encodings.RealVectorEncoding9168-9215
      /branches/VNS/HeuristicLab.Encodings.RealVectorEncoding5594-5752
      /branches/histogram/HeuristicLab.Encodings.RealVectorEncoding5959-6341
  • branches/ALPS/HeuristicLab.Encodings.RealVectorEncoding/3.3/Creators/NormalDistributedRealVectorCreator.cs

    r11171 r11975  
    8888    /// </remarks>
    8989    /// <param name="random">The random number generator.</param>
    90     /// <param name="mean">The mean vector around which the resulting vector is sampled.</param>
    91     /// <param name="sigma">The vector of standard deviations, must have at least one row.</param>
     90    /// <param name="means">The mean vector around which the resulting vector is sampled.</param>
     91    /// <param name="sigmas">The vector of standard deviations, must have at least one row.</param>
    9292    /// <param name="bounds">The lower and upper bound (1st and 2nd column) of the positions in the vector. If there are less rows than dimensions, the rows are cycled.</param>
    9393    /// <param name="maximumTries">The maximum number of tries to sample a value inside the bounds for each dimension. If a valid value cannot be obtained, the mean will be used.</param>
    9494    /// <returns>The newly created real vector.</returns>
    95     public static RealVector Apply(IRandom random, RealVector mean, DoubleArray sigma, DoubleMatrix bounds, int maximumTries = 1000) {
     95    public static RealVector Apply(IntValue lengthValue, IRandom random, RealVector means, DoubleArray sigmas, DoubleMatrix bounds, int maximumTries = 1000) {
     96      if (lengthValue == null || lengthValue.Value == 0) throw new ArgumentException("Length is not defined or zero");
    9697      if (random == null) throw new ArgumentNullException("Random is not defined", "random");
    97       if (mean == null || mean.Length == 0) throw new ArgumentNullException("Mean is not defined", "mean");
    98       if (sigma == null || sigma.Length == 0) throw new ArgumentNullException("Sigma is not defined.", "sigma");
     98      if (means == null || means.Length == 0) throw new ArgumentNullException("Mean is not defined", "mean");
     99      if (sigmas == null || sigmas.Length == 0) throw new ArgumentNullException("Sigma is not defined.", "sigma");
    99100      if (bounds == null || bounds.Rows == 0) bounds = new DoubleMatrix(new[,] { { double.MinValue, double.MaxValue } });
     101      var length = lengthValue.Value;
    100102      var nd = new NormalDistributedRandom(random, 0, 1);
    101       var result = (RealVector)mean.Clone();
     103      var result = new RealVector(length);
    102104      for (int i = 0; i < result.Length; i++) {
    103105        var min = bounds[i % bounds.Rows, 0];
    104106        var max = bounds[i % bounds.Rows, 1];
    105         if (min.IsAlmost(max) || mean[i] < min) result[i] = min;
    106         else if (mean[i] > max) result[i] = max;
     107        var mean = means[i % means.Length];
     108        var sigma = sigmas[i % sigmas.Length];
     109        if (min.IsAlmost(max) || mean < min) result[i] = min;
     110        else if (mean > max) result[i] = max;
    107111        else {
    108112          int count = 0;
    109113          bool inRange;
    110114          do {
    111             result[i] = mean[i] + sigma[i % sigma.Length] * nd.NextDouble();
    112             inRange = result[i] >= bounds[i % bounds.Rows, 0] && result[i] < bounds[i % bounds.Rows, 1];
     115            result[i] = mean + sigma * nd.NextDouble();
     116            inRange = result[i] >= min && result[i] < max;
    113117            count++;
    114118          } while (count < maximumTries && !inRange);
    115119          if (count == maximumTries && !inRange)
    116             result[i] = mean[i];
     120            result[i] = mean;
    117121        }
    118122      }
     
    128132    /// <returns>The newly created real vector.</returns>
    129133    protected override RealVector Create(IRandom random, IntValue length, DoubleMatrix bounds) {
    130       return Apply(random, MeanParameter.ActualValue, SigmaParameter.ActualValue, bounds, MaximumTriesParameter.Value.Value);
     134      return Apply(length, random, MeanParameter.ActualValue, SigmaParameter.ActualValue, bounds, MaximumTriesParameter.Value.Value);
    131135    }
    132136  }
  • branches/ALPS/HeuristicLab.Encodings.RealVectorEncoding/3.3/Crossovers/BlendAlphaBetaCrossover.cs

    r11171 r11975  
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Data;
     26using HeuristicLab.Optimization;
    2627using HeuristicLab.Parameters;
    2728using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    4041  [Item("BlendAlphaBetaCrossover", "The blend alpha beta crossover (BLX-a-b) for real vectors is similar to the blend alpha crossover (BLX-a), but distinguishes between the better and worse of the parents. The interval from which to choose the new offspring can be extended beyond the better parent by specifying a higher alpha value, and beyond the worse parent by specifying a higher beta value. The new offspring is sampled uniformly in the extended range. It is implemented as described in Takahashi, M. and Kita, H. 2001. A crossover operator using independent component analysis for real-coded genetic algorithms Proceedings of the 2001 Congress on Evolutionary Computation, pp. 643-649.")]
    4142  [StorableClass]
    42   public class BlendAlphaBetaCrossover : RealVectorCrossover {
     43  public class BlendAlphaBetaCrossover : RealVectorCrossover, ISingleObjectiveOperator {
    4344    /// <summary>
    4445    /// Whether the problem is a maximization or minimization problem.
  • branches/ALPS/HeuristicLab.Encodings.RealVectorEncoding/3.3/Crossovers/HeuristicCrossover.cs

    r11171 r11975  
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Data;
     26using HeuristicLab.Optimization;
    2627using HeuristicLab.Parameters;
    2728using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3738  [Item("HeuristicCrossover", "The heuristic crossover produces offspring that extend the better parent in direction from the worse to the better parent. It is implemented as described in Wright, A.H. (1994), Genetic algorithms for real parameter optimization, Foundations of Genetic Algorithms, G.J.E. Rawlins (Ed.), Morgan Kaufmann, San Mateo, CA, 205-218.")]
    3839  [StorableClass]
    39   public class HeuristicCrossover : RealVectorCrossover {
     40  public class HeuristicCrossover : RealVectorCrossover, ISingleObjectiveOperator {
    4041    /// <summary>
    4142    /// Whether the problem is a maximization or minimization problem.
  • branches/ALPS/HeuristicLab.Encodings.RealVectorEncoding/3.3/HeuristicLab.Encodings.RealVectorEncoding-3.3.csproj

    r11677 r11975  
    136136    <Compile Include="RealVectorCrossover.cs" />
    137137    <Compile Include="Properties\AssemblyInfo.cs" />
     138    <Compile Include="RealVectorEncoding.cs" />
    138139    <Compile Include="RealVectorManipulator.cs" />
    139140  </ItemGroup>
  • branches/ALPS/HeuristicLab.Encodings.RealVectorEncoding/3.3/Interfaces/IRealVectorMultiNeighborhoodShakingOperator.cs

    r11171 r11975  
    2121
    2222using HeuristicLab.Core;
     23using HeuristicLab.Data;
    2324
    2425namespace HeuristicLab.Encodings.RealVectorEncoding {
    2526  public interface IRealVectorMultiNeighborhoodShakingOperator : IRealVectorOperator {
    2627    ILookupParameter<RealVector> RealVectorParameter { get; }
     28    IValueLookupParameter<DoubleMatrix> BoundsParameter { get; }
    2729  }
    2830}
  • branches/ALPS/HeuristicLab.Encodings.RealVectorEncoding/3.3/Moves/AdditiveMoveMaker.cs

    r11171 r11975  
    3131  [Item("AdditiveMoveMaker", "Peforms an additive move on a given real vector and updates the quality.")]
    3232  [StorableClass]
    33   public class AdditiveMoveMaker : SingleSuccessorOperator, IAdditiveRealVectorMoveOperator, IMoveMaker {
     33  public class AdditiveMoveMaker : SingleSuccessorOperator, IAdditiveRealVectorMoveOperator, IMoveMaker, ISingleObjectiveOperator {
    3434    public override bool CanChangeName {
    3535      get { return false; }
  • branches/ALPS/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorSwarmUpdater.cs

    r11171 r11975  
    3535  [Item("RealVectorSwarmUpdater", "Updates personal best point and quality as well as global best point and quality.")]
    3636  [StorableClass]
    37   public sealed class RealVectorSwarmUpdater : SingleSuccessorOperator, IRealVectorSwarmUpdater {
     37  public sealed class RealVectorSwarmUpdater : SingleSuccessorOperator, IRealVectorSwarmUpdater, ISingleObjectiveOperator {
    3838
    3939    [Storable]
     
    235235
    236236    void VelocityBoundsStartValueParameter_Value_ValueChanged(object sender, EventArgs e) {
    237       UpdateVelocityBoundsParamater(); 
     237      UpdateVelocityBoundsParamater();
    238238    }
    239239
     
    257257        VelocityBoundsStartValueParameter.Value.ValueChanged += new EventHandler(VelocityBoundsStartValueParameter_Value_ValueChanged);
    258258      }
    259       UpdateVelocityBoundsParamater(); 
     259      UpdateVelocityBoundsParamater();
    260260    }
    261261
  • branches/ALPS/HeuristicLab.Encodings.RealVectorEncoding/3.3/ShakingOperators/RealVectorShakingOperator.cs

    r11171 r11975  
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Core;
     27using HeuristicLab.Data;
    2728using HeuristicLab.Optimization;
    2829using HeuristicLab.Optimization.Operators;
     
    4748    }
    4849
     50    public IValueLookupParameter<DoubleMatrix> BoundsParameter {
     51      get { return (IValueLookupParameter<DoubleMatrix>)Parameters["Bounds"]; }
     52    }
     53
     54
    4955    [StorableConstructor]
    5056    protected RealVectorShakingOperator(bool deserializing) : base(deserializing) { }
     
    5763      Parameters.Add(new LookupParameter<RealVector>("RealVector", "The real vector to shake."));
    5864      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator that will be used for stochastic shaking operators."));
     65      Parameters.Add(new ValueLookupParameter<DoubleMatrix>("Bounds", "A 2 column matrix specifying the lower and upper bound for each dimension. If there are less rows than dimension the bounds vector is cycled."));
    5966      foreach (IRealVectorManipulator shaker in ApplicationManager.Manager.GetInstances<IRealVectorManipulator>().OrderBy(x => x.Name))
    6067        if (!(shaker is MultiRealVectorManipulator)
    6168          && !(shaker is ISelfAdaptiveManipulator)) Operators.Add(shaker);
     69    }
     70
     71    [StorableHook(HookType.AfterDeserialization)]
     72    private void AfterDeserialization() {
     73      #region Backwards compatible code, remove with 3.4
     74      if (!Parameters.ContainsKey("Bounds"))
     75        Parameters.Add(new ValueLookupParameter<DoubleMatrix>("Bounds", "A 2 column matrix specifying the lower and upper bound for each dimension. If there are less rows than dimension the bounds vector is cycled."));
     76      #endregion
    6277    }
    6378
Note: See TracChangeset for help on using the changeset viewer.