Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/21/12 18:02:33 (12 years ago)
Author:
gkronber
Message:

#1847: merged trunk changes r7800:HEAD into gp move operators branch

Location:
branches/GP-MoveOperators
Files:
13 edited
19 copied

Legend:

Unmodified
Added
Removed
  • branches/GP-MoveOperators

  • branches/GP-MoveOperators/HeuristicLab.Encodings.IntegerVectorEncoding

    • Property svn:mergeinfo set to (toggle deleted branches)
      /trunk/sources/HeuristicLab.Encodings.IntegerVectorEncodingmergedeligible
      /branches/Benchmarking/sources/HeuristicLab.Encodings.IntegerVectorEncoding6917-7005
      /branches/CloningRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding4656-4721
      /branches/DataAnalysis Refactoring/HeuristicLab.Encodings.IntegerVectorEncoding5471-5808
      /branches/DataAnalysis SolutionEnsembles/HeuristicLab.Encodings.IntegerVectorEncoding5815-6180
      /branches/DataAnalysis/HeuristicLab.Encodings.IntegerVectorEncoding4458-4459,​4462,​4464
      /branches/GP.Grammar.Editor/HeuristicLab.Encodings.IntegerVectorEncoding6284-6795
      /branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Encodings.IntegerVectorEncoding5060
      /branches/IntegerVectorEncoding/HeuristicLab.Encodings.IntegerVectorEncoding7681-8018
      /branches/NET40/sources/HeuristicLab.Encodings.IntegerVectorEncoding5138-5162
      /branches/ParallelEngine/HeuristicLab.Encodings.IntegerVectorEncoding5175-5192
      /branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Encodings.IntegerVectorEncoding7568-7810
      /branches/QAPAlgorithms/HeuristicLab.Encodings.IntegerVectorEncoding6350-6627
      /branches/Restructure trunk solution/HeuristicLab.Encodings.IntegerVectorEncoding6828
      /branches/SuccessProgressAnalysis/HeuristicLab.Encodings.IntegerVectorEncoding5370-5682
      /branches/Trunk/HeuristicLab.Encodings.IntegerVectorEncoding6829-6865
      /branches/VNS/HeuristicLab.Encodings.IntegerVectorEncoding5594-5752
      /branches/histogram/HeuristicLab.Encodings.IntegerVectorEncoding5959-6341
  • branches/GP-MoveOperators/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/Creators/UniformRandomIntegerVectorCreator.cs

    r7259 r8085  
    4949    /// <param name="max">The maximum value of the sampling range for each vector element (exclusive).</param>
    5050    /// <returns>The newly created integer vector.</returns>
    51     public static IntegerVector Apply(IRandom random, int length, int min, int max) {
    52       int[] result = new int[length];
    53       for (int i = 0; i < length; i++)
    54         result[i] = random.Next(min, max);
    55       return new IntegerVector(result);
     51    public static IntegerVector Apply(IRandom random, int length, IntMatrix bounds) {
     52      var result = new IntegerVector(length);
     53      result.Randomize(random, bounds);
     54      return result;
    5655    }
    5756
     
    6160    /// <param name="random">The pseudo random number generator to use.</param>
    6261    /// <param name="length">The length of the int vector.</param>
    63     /// <param name="minimum">The minimum value of the sampling range for each vector element (inclusive).</param>
    64     /// <param name="maximum">The maximum value of the sampling range for each vector element (exclusive).</param>
     62    /// <param name="bounds">Contains in each row for each dimension minimum (inclusive), maximum (inclusive), and step size.</param>
    6563    /// <returns>The newly created int vector.</returns>
    66     protected override IntegerVector Create(IRandom random, IntValue length, IntValue minimum, IntValue maximum) {
    67       return Apply(random, length.Value, minimum.Value, maximum.Value);
     64    protected override IntegerVector Create(IRandom random, IntValue length, IntMatrix bounds) {
     65      return Apply(random, length.Value, bounds);
    6866    }
    6967  }
  • branches/GP-MoveOperators/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/Crossovers/DiscreteCrossover.cs

    r7259 r8085  
    4545
    4646    /// <summary>
    47     /// Performs a discrete crossover operation of the two given parents.
     47    /// Performs a discrete crossover operation of any number of given parents.
    4848    /// </summary>
    49     /// <exception cref="ArgumentException">Thrown when the vectors of the parents are of different length.</exception>
     49    /// <exception cref="ArgumentException">Thrown when the vectors of the parents are of different length or when there are less than 2 parents.</exception>
    5050    /// <param name="random">A random number generator.</param>
    51     /// <param name="parent1">The first parent for the crossover operation.</param>
    52     /// <param name="parent2">The second parent for the crossover operation.</param>
     51    /// <param name="parents">The list of parents for the crossover operation.</param>
    5352    /// <returns>The newly created integer vector, resulting from the crossover operation.</returns>
    54     public static IntegerVector Apply(IRandom random, IntegerVector parent1, IntegerVector parent2) {
    55       if (parent1.Length != parent2.Length)
    56         throw new ArgumentException("DiscreteCrossover: The parents are of different length.");
     53    public static IntegerVector Apply(IRandom random, ItemArray<IntegerVector> parents) {
     54      if (parents.Length < 2) throw new ArgumentException("DiscreteCrossover: There are less than two parents to cross.");
     55      int length = parents[0].Length;
    5756
    58       int length = parent1.Length;
    59       int[] result = new int[length];
     57      for (int i = 0; i < parents.Length; i++) {
     58        if (parents[i].Length != length)
     59          throw new ArgumentException("DiscreteCrossover: The parents' vectors are of different length.", "parents");
     60      }
    6061
     62      var result = new IntegerVector(length);
    6163      for (int i = 0; i < length; i++) {
    62         if (random.NextDouble() < 0.5)
    63           result[i] = parent1[i];
    64         else
    65           result[i] = parent2[i];
     64        result[i] = parents[random.Next(parents.Length)][i];
    6665      }
    67       return new IntegerVector(result);
     66
     67      return result;
    6868    }
    6969
    7070    /// <summary>
    71     /// Performs a discrete crossover operation for two given parent integer vectors.
     71    /// Performs a discrete crossover operation for any number of given parent integer vectors.
    7272    /// </summary>
    73     /// <exception cref="ArgumentException">Thrown if there are not exactly two parents.</exception>
    7473    /// <param name="random">A random number generator.</param>
    75     /// <param name="parents">An array containing the two integer vectors that should be crossed.</param>
     74    /// <param name="parents">An array containing integer vectors that should be crossed.</param>
    7675    /// <returns>The newly created integer vector, resulting from the crossover operation.</returns>
    7776    protected override IntegerVector Cross(IRandom random, ItemArray<IntegerVector> parents) {
    78       if (parents.Length != 2) throw new ArgumentException("ERROR in DiscreteCrossover: The number of parents is not equal to 2");
    79       return Apply(random, parents[0], parents[1]);
     77      return Apply(random, parents);
    8078    }
    8179  }
  • branches/GP-MoveOperators/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/Crossovers/MultiIntegerVectorCrossover.cs

    r7259 r8085  
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Core;
     27using HeuristicLab.Data;
    2728using HeuristicLab.Operators;
    2829using HeuristicLab.Optimization;
     
    3435  [Item("MultiIntegerVectorCrossover", "Randomly selects and applies one of its crossovers every time it is called.")]
    3536  [StorableClass]
    36   public class MultiIntegerVectorCrossover : StochasticMultiBranch<IIntegerVectorCrossover>, IIntegerVectorCrossover, IStochasticOperator {
     37  public class MultiIntegerVectorCrossover : StochasticMultiBranch<IIntegerVectorCrossover>, IIntegerVectorCrossover, IStochasticOperator, IBoundedIntegerVectorOperator {
    3738    public override bool CanChangeName {
    3839      get { return false; }
     
    4041    protected override bool CreateChildOperation {
    4142      get { return true; }
     43    }
     44
     45    public IValueLookupParameter<IntMatrix> BoundsParameter {
     46      get { return (IValueLookupParameter<IntMatrix>)Parameters["Bounds"]; }
    4247    }
    4348
     
    5560    public MultiIntegerVectorCrossover()
    5661      : base() {
     62      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."));
    5763      Parameters.Add(new ScopeTreeLookupParameter<IntegerVector>("Parents", "The parent integer vector which should be crossed."));
    5864      ParentsParameter.ActualName = "IntegerVector";
     
    8894        crossover.RandomParameter.ActualName = RandomParameter.Name;
    8995      }
     96      foreach (IBoundedIntegerVectorOperator crossover in Operators.OfType<IBoundedIntegerVectorOperator>()) {
     97        crossover.BoundsParameter.ActualName = BoundsParameter.Name;
     98      }
    9099    }
    91100
  • branches/GP-MoveOperators/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/Crossovers/SinglePointCrossover.cs

    r7259 r8085  
    5454    public static IntegerVector Apply(IRandom random, IntegerVector parent1, IntegerVector parent2) {
    5555      if (parent1.Length != parent2.Length)
    56         throw new ArgumentException("DiscreteCrossover: The parents are of different length.");
     56        throw new ArgumentException("SinglePointCrossover: The parents are of different length.");
    5757
    5858      int length = parent1.Length;
  • branches/GP-MoveOperators/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/HeuristicLab.Encodings.IntegerVectorEncoding-3.3.csproj

    r6866 r8085  
    106106  </ItemGroup>
    107107  <ItemGroup>
     108    <Compile Include="BoundedIntegerVectorCrossover.cs" />
     109    <Compile Include="BoundedIntegerVectorManipulator.cs" />
    108110    <Compile Include="Creators\UniformRandomIntegerVectorCreator.cs" />
     111    <Compile Include="Crossovers\RoundedAverageCrossover.cs" />
    109112    <Compile Include="Crossovers\DiscreteCrossover.cs">
    110113      <SubType>Code</SubType>
    111114    </Compile>
    112115    <Compile Include="Crossovers\MultiIntegerVectorCrossover.cs" />
     116    <Compile Include="Crossovers\RoundedBlendAlphaBetaCrossover.cs" />
     117    <Compile Include="Crossovers\RoundedBlendAlphaCrossover.cs" />
     118    <Compile Include="Crossovers\RoundedHeuristicCrossover.cs" />
     119    <Compile Include="Crossovers\RoundedLocalCrossover.cs" />
    113120    <Compile Include="Crossovers\SinglePointCrossover.cs">
    114121      <SubType>Code</SubType>
    115122    </Compile>
     123    <Compile Include="Crossovers\RoundedUniformArithmeticCrossover.cs" />
     124    <Compile Include="Interfaces\IBoundedIntegerVectorOperator.cs" />
    116125    <Compile Include="Interfaces\IIntegerVectorCreator.cs" />
    117126    <Compile Include="Interfaces\IIntegerVectorCrossover.cs" />
     
    121130    <Compile Include="IntegerVectorCrossover.cs" />
    122131    <Compile Include="IntegerVectorManipulator.cs" />
     132    <Compile Include="Interfaces\IIntegerVectorStdDevStrategyParameterCreator.cs" />
     133    <Compile Include="Interfaces\IIntegerVectorStdDevStrategyParameterCrossover.cs" />
     134    <Compile Include="Interfaces\IIntegerVectorStdDevStrategyParameterManipulator.cs" />
     135    <Compile Include="Interfaces\IIntegerVectorStdDevStrategyParameterOperator.cs" />
     136    <Compile Include="Manipulators\UniformSomePositionsManipulator.cs" />
     137    <Compile Include="Manipulators\RoundedNormalAllPositionsManipulator.cs" />
     138    <Compile Include="Manipulators\SelfAdaptiveRoundedNormalAllPositionsManipulator.cs" />
     139    <Compile Include="Manipulators\StdDevStrategyVectorCreator.cs" />
     140    <Compile Include="Manipulators\StdDevStrategyVectorCrossover.cs" />
     141    <Compile Include="Manipulators\StdDevStrategyVectorManipulator.cs" />
    123142    <Compile Include="Manipulators\UniformOnePositionManipulator.cs">
    124143      <SubType>Code</SubType>
     
    129148    <Compile Include="IntegerVectorCreator.cs" />
    130149    <Compile Include="ShakingOperators\IntegerVectorShakingOperator.cs" />
    131   </ItemGroup>
    132   <ItemGroup>
    133     <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj">
    134       <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project>
    135       <Name>HeuristicLab.Collections-3.3</Name>
    136       <Private>False</Private>
    137     </ProjectReference>
    138     <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj">
    139       <Project>{A9AD58B9-3EF9-4CC1-97E5-8D909039FF5C}</Project>
    140       <Name>HeuristicLab.Common-3.3</Name>
    141       <Private>False</Private>
    142     </ProjectReference>
    143     <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj">
    144       <Project>{C36BD924-A541-4A00-AFA8-41701378DDC5}</Project>
    145       <Name>HeuristicLab.Core-3.3</Name>
    146       <Private>False</Private>
    147     </ProjectReference>
    148     <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj">
    149       <Project>{BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}</Project>
    150       <Name>HeuristicLab.Data-3.3</Name>
    151       <Private>False</Private>
    152     </ProjectReference>
    153     <ProjectReference Include="..\..\HeuristicLab.Operators\3.3\HeuristicLab.Operators-3.3.csproj">
    154       <Project>{23DA7FF4-D5B8-41B6-AA96-F0561D24F3EE}</Project>
    155       <Name>HeuristicLab.Operators-3.3</Name>
    156       <Private>False</Private>
    157     </ProjectReference>
    158     <ProjectReference Include="..\..\HeuristicLab.Optimization.Operators\3.3\HeuristicLab.Optimization.Operators-3.3.csproj">
    159       <Project>{25087811-F74C-4128-BC86-8324271DA13E}</Project>
    160       <Name>HeuristicLab.Optimization.Operators-3.3</Name>
    161       <Private>False</Private>
    162     </ProjectReference>
    163     <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj">
    164       <Project>{14AB8D24-25BC-400C-A846-4627AA945192}</Project>
    165       <Name>HeuristicLab.Optimization-3.3</Name>
    166       <Private>False</Private>
    167     </ProjectReference>
    168     <ProjectReference Include="..\..\HeuristicLab.Parameters\3.3\HeuristicLab.Parameters-3.3.csproj">
    169       <Project>{56F9106A-079F-4C61-92F6-86A84C2D84B7}</Project>
    170       <Name>HeuristicLab.Parameters-3.3</Name>
    171       <Private>False</Private>
    172     </ProjectReference>
    173     <ProjectReference Include="..\..\HeuristicLab.Persistence\3.3\HeuristicLab.Persistence-3.3.csproj">
    174       <Project>{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}</Project>
    175       <Name>HeuristicLab.Persistence-3.3</Name>
    176       <Private>False</Private>
    177     </ProjectReference>
    178     <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj">
    179       <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>
    180       <Name>HeuristicLab.PluginInfrastructure-3.3</Name>
    181       <Private>False</Private>
    182     </ProjectReference>
    183150  </ItemGroup>
    184151  <ItemGroup>
     
    198165      <Install>true</Install>
    199166    </BootstrapperPackage>
     167  </ItemGroup>
     168  <ItemGroup>
     169    <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj">
     170      <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project>
     171      <Name>HeuristicLab.Collections-3.3</Name>
     172      <Private>False</Private>
     173    </ProjectReference>
     174    <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj">
     175      <Project>{A9AD58B9-3EF9-4CC1-97E5-8D909039FF5C}</Project>
     176      <Name>HeuristicLab.Common-3.3</Name>
     177      <Private>False</Private>
     178    </ProjectReference>
     179    <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj">
     180      <Project>{C36BD924-A541-4A00-AFA8-41701378DDC5}</Project>
     181      <Name>HeuristicLab.Core-3.3</Name>
     182      <Private>False</Private>
     183    </ProjectReference>
     184    <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj">
     185      <Project>{BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}</Project>
     186      <Name>HeuristicLab.Data-3.3</Name>
     187      <Private>False</Private>
     188    </ProjectReference>
     189    <ProjectReference Include="..\..\HeuristicLab.Operators\3.3\HeuristicLab.Operators-3.3.csproj">
     190      <Project>{23DA7FF4-D5B8-41B6-AA96-F0561D24F3EE}</Project>
     191      <Name>HeuristicLab.Operators-3.3</Name>
     192      <Private>False</Private>
     193    </ProjectReference>
     194    <ProjectReference Include="..\..\HeuristicLab.Optimization.Operators\3.3\HeuristicLab.Optimization.Operators-3.3.csproj">
     195      <Project>{25087811-F74C-4128-BC86-8324271DA13E}</Project>
     196      <Name>HeuristicLab.Optimization.Operators-3.3</Name>
     197      <Private>False</Private>
     198    </ProjectReference>
     199    <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj">
     200      <Project>{14AB8D24-25BC-400C-A846-4627AA945192}</Project>
     201      <Name>HeuristicLab.Optimization-3.3</Name>
     202      <Private>False</Private>
     203    </ProjectReference>
     204    <ProjectReference Include="..\..\HeuristicLab.Parameters\3.3\HeuristicLab.Parameters-3.3.csproj">
     205      <Project>{56F9106A-079F-4C61-92F6-86A84C2D84B7}</Project>
     206      <Name>HeuristicLab.Parameters-3.3</Name>
     207      <Private>False</Private>
     208    </ProjectReference>
     209    <ProjectReference Include="..\..\HeuristicLab.Persistence\3.3\HeuristicLab.Persistence-3.3.csproj">
     210      <Project>{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}</Project>
     211      <Name>HeuristicLab.Persistence-3.3</Name>
     212      <Private>False</Private>
     213    </ProjectReference>
     214    <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj">
     215      <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>
     216      <Name>HeuristicLab.PluginInfrastructure-3.3</Name>
     217      <Private>False</Private>
     218    </ProjectReference>
     219    <ProjectReference Include="..\..\HeuristicLab.Random\3.3\HeuristicLab.Random-3.3.csproj">
     220      <Project>{F4539FB6-4708-40C9-BE64-0A1390AEA197}</Project>
     221      <Name>HeuristicLab.Random-3.3</Name>
     222      <Private>False</Private>
     223    </ProjectReference>
    200224  </ItemGroup>
    201225  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • branches/GP-MoveOperators/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVector.cs

    r7259 r8085  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    4950    }
    5051
    51     public virtual void Randomize(IRandom random, int startIndex, int length, int min, int max) {
     52    public virtual void Randomize(IRandom random, int startIndex, int length, int min, int max, int step = 1) {
    5253      if (length > 0) {
    53         for (int i = 0; i < length; i++)
    54           array[startIndex + i] = random.Next(min, max);
     54        int numbers = (int)Math.Floor((max - min) / (double)step);
     55        for (int i = startIndex; i < startIndex + length; i++) {
     56          array[i] = random.Next(numbers) * step + min;
     57        }
    5558        OnReset();
    5659      }
    5760    }
    58     public void Randomize(IRandom random, int min, int max) {
    59       Randomize(random, 0, Length, min, max);
     61    public virtual void Randomize(IRandom random, int startIndex, int length, IntMatrix bounds) {
     62      if (length > 0) {
     63        for (int i = startIndex; i < startIndex + length; i++) {
     64          int min = bounds[i % bounds.Rows, 0], max = bounds[i % bounds.Rows, 1], step = 1;
     65          if (bounds.Columns > 2) step = bounds[i % bounds.Rows, 2];
     66          int numbers = (int)Math.Floor((max - min) / (double)step);
     67          array[i] = random.Next(numbers) * step + min;
     68        }
     69        OnReset();
     70      }
     71    }
     72    public void Randomize(IRandom random, int min, int max, int step = 1) {
     73      Randomize(random, 0, Length, min, max, step);
     74    }
     75    public void Randomize(IRandom random, IntMatrix bounds) {
     76      Randomize(random, 0, Length, bounds);
    6077    }
    6178  }
  • branches/GP-MoveOperators/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVectorCreator.cs

    r7259 r8085  
    4747      get { return (IValueLookupParameter<IntValue>)Parameters["Length"]; }
    4848    }
    49     public IValueLookupParameter<IntValue> MinimumParameter {
    50       get { return (IValueLookupParameter<IntValue>)Parameters["Minimum"]; }
    51     }
    52     public IValueLookupParameter<IntValue> MaximumParameter {
    53       get { return (IValueLookupParameter<IntValue>)Parameters["Maximum"]; }
     49    public IValueLookupParameter<IntMatrix> BoundsParameter {
     50      get { return (IValueLookupParameter<IntMatrix>)Parameters["Bounds"]; }
    5451    }
    5552
     
    6259      Parameters.Add(new LookupParameter<IntegerVector>("IntegerVector", "The vector which should be manipulated."));
    6360      Parameters.Add(new ValueLookupParameter<IntValue>("Length", "The length of the vector."));
    64       Parameters.Add(new ValueLookupParameter<IntValue>("Minimum", "The inclusive lower bound for each element in the vector."));
    65       Parameters.Add(new ValueLookupParameter<IntValue>("Maximum", "The exclusive upper bound for each element in the vector."));
     61      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."));
    6662    }
    6763
     64    // BackwardsCompatibility3.3
     65    #region Backwards compatible code, remove with 3.4
     66    [StorableHook(HookType.AfterDeserialization)]
     67    private void AfterDeserialization() {
     68      if (!Parameters.ContainsKey("Bounds")) {
     69        var min = ((IValueLookupParameter<IntValue>)Parameters["Minimum"]).Value as IntValue;
     70        var max = ((IValueLookupParameter<IntValue>)Parameters["Maximum"]).Value as IntValue;
     71        Parameters.Remove("Minimum");
     72        Parameters.Remove("Maximum");
     73        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."));
     74        if (min != null && max != null) {
     75          BoundsParameter.Value = new IntMatrix(new int[,] { { min.Value, max.Value, 1 } });
     76        }
     77      }
     78    }
     79    #endregion
     80
    6881    public sealed override IOperation Apply() {
    69       IntegerVectorParameter.ActualValue = Create(RandomParameter.ActualValue, LengthParameter.ActualValue, MinimumParameter.ActualValue, MaximumParameter.ActualValue);
     82      IntegerVectorParameter.ActualValue = Create(RandomParameter.ActualValue, LengthParameter.ActualValue, BoundsParameter.ActualValue);
    7083      return base.Apply();
    7184    }
    7285
    73     protected abstract IntegerVector Create(IRandom random, IntValue length, IntValue minimum, IntValue maximum);
     86    protected abstract IntegerVector Create(IRandom random, IntValue length, IntMatrix bounds);
    7487  }
    7588}
  • branches/GP-MoveOperators/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/Interfaces/IIntegerVectorCreator.cs

    r7259 r8085  
    2828  /// An interface which represents an operator for creating vectors of int-valued data.
    2929  /// </summary>
    30   public interface IIntegerVectorCreator : IIntegerVectorOperator, ISolutionCreator {
     30  public interface IIntegerVectorCreator : ISolutionCreator, IBoundedIntegerVectorOperator {
    3131    IValueLookupParameter<IntValue> LengthParameter { get; }
    32     IValueLookupParameter<IntValue> MinimumParameter { get; }
    33     IValueLookupParameter<IntValue> MaximumParameter { get; }
    3432    ILookupParameter<IntegerVector> IntegerVectorParameter { get; }
    3533  }
  • branches/GP-MoveOperators/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/Manipulators/UniformOnePositionManipulator.cs

    r7259 r8085  
    3636  [Item("UniformOnePositionManipulator", " Uniformly distributed change of a single position of an integer vector. It is implemented as described in Michalewicz, Z. 1999. Genetic Algorithms + Data Structures = Evolution Programs. Third, Revised and Extended Edition, Spring-Verlag Berlin Heidelberg.")]
    3737  [StorableClass]
    38   public class UniformOnePositionManipulator : IntegerVectorManipulator {
    39     /// <summary>
    40     /// The lower bound of the values in the int vector.
    41     /// </summary>
    42     public ValueLookupParameter<IntValue> MinimumParameter {
    43       get { return (ValueLookupParameter<IntValue>)Parameters["Minimum"]; }
    44     }
    45     /// <summary>
    46     /// The upper bound of the values in the int vector.
    47     /// </summary>
    48     public ValueLookupParameter<IntValue> MaximumParameter {
    49       get { return (ValueLookupParameter<IntValue>)Parameters["Maximum"]; }
    50     }
     38  public class UniformOnePositionManipulator : BoundedIntegerVectorManipulator {
    5139
    5240    [StorableConstructor]
     
    5745    /// (<c>Minimum</c> and <c>Maximum</c>).
    5846    /// </summary>
    59     public UniformOnePositionManipulator()
    60       : base() {
    61       Parameters.Add(new ValueLookupParameter<IntValue>("Minimum", "Minimum of the sampling range for the vector element (included)"));
    62       Parameters.Add(new ValueLookupParameter<IntValue>("Maximum", "Maximum of the sampling range for the vector element (excluded)"));
    63     }
     47    public UniformOnePositionManipulator() : base() { }
    6448
    6549    public override IDeepCloneable Clone(Cloner cloner) {
    6650      return new UniformOnePositionManipulator(this, cloner);
    6751    }
     52
     53    // BackwardsCompatibility3.3
     54    #region Backwards compatible code, remove with 3.4
     55    [StorableHook(HookType.AfterDeserialization)]
     56    private void AfterDeserialization() {
     57      if (!Parameters.ContainsKey("Bounds")) {
     58        var min = ((IValueLookupParameter<IntValue>)Parameters["Minimum"]).Value as IntValue;
     59        var max = ((IValueLookupParameter<IntValue>)Parameters["Maximum"]).Value as IntValue;
     60        Parameters.Remove("Minimum");
     61        Parameters.Remove("Maximum");
     62        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."));
     63        if (min != null && max != null) {
     64          BoundsParameter.Value = new IntMatrix(new int[,] { { min.Value, max.Value, 1 } });
     65        }
     66      }
     67    }
     68    #endregion
    6869
    6970    /// <summary>
     
    7677    /// <param name="max">The maximum value of the sampling range for
    7778    /// the vector element to change (exclusive).</param>
    78     public static void Apply(IRandom random, IntegerVector vector, IntValue min, IntValue max) {
    79       int index = random.Next(vector.Length);
    80       vector[index] = random.Next(min.Value, max.Value);
     79    /// <param name="bounds">The bounds and step size for each dimension (will be cycled in case there are less rows than elements in the parent vectors).</param>
     80    public static void Apply(IRandom random, IntegerVector vector, IntMatrix bounds) {
     81      Manipulate(random, vector, bounds, random.Next(vector.Length));
     82    }
     83
     84    public static void Manipulate(IRandom random, IntegerVector vector, IntMatrix bounds, int index) {
     85      if (bounds == null || bounds.Rows == 0 || bounds.Columns < 2) throw new ArgumentException("UniformOnePositionManipulator: Invalid bounds specified", "bounds");
     86      int min = bounds[index % bounds.Rows, 0], max = bounds[index % bounds.Rows, 1], step = 1;
     87      if (bounds.Columns > 2) step = bounds[index % bounds.Rows, 2];
     88      vector[index] = RoundFeasible(min, max, step, random.Next(min, max + 1));
    8189    }
    8290
     
    8795    /// <param name="random">A random number generator.</param>
    8896    /// <param name="vector">The integer vector to manipulate.</param>
    89     protected override void Manipulate(IRandom random, IntegerVector vector) {
    90       if (MinimumParameter.ActualValue == null) throw new InvalidOperationException("UniformOnePositionManipulator: Parameter " + MinimumParameter.ActualName + " could not be found.");
    91       if (MaximumParameter.ActualValue == null) throw new InvalidOperationException("UniformOnePositionManipulator: Parameter " + MaximumParameter.ActualName + " could not be found.");
    92       Apply(random, vector, MinimumParameter.ActualValue, MaximumParameter.ActualValue);
     97    /// <param name="bounds">The bounds and step size for each dimension (will be cycled in case there are less rows than elements in the parent vectors).</param>
     98    protected override void ManipulateBounded(IRandom random, IntegerVector vector, IntMatrix bounds) {
     99      if (BoundsParameter.ActualValue == null) throw new InvalidOperationException("UniformOnePositionManipulator: Parameter " + BoundsParameter.ActualName + " could not be found.");
     100      Apply(random, vector, bounds);
    93101    }
    94102  }
  • branches/GP-MoveOperators/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/Plugin.cs.frame

    r7259 r8085  
    3737  [PluginDependency("HeuristicLab.Parameters", "3.3")]
    3838  [PluginDependency("HeuristicLab.Persistence", "3.3")]
     39  [PluginDependency("HeuristicLab.Random", "3.3")]
    3940  public class HeuristicLabEncodingsIntegerVectorEncodingPlugin : PluginBase {
    4041  }
  • branches/GP-MoveOperators/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/ShakingOperators/IntegerVectorShakingOperator.cs

    r7259 r8085  
    5858      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator that will be used for stochastic shaking operators."));
    5959      foreach (IIntegerVectorManipulator shaker in ApplicationManager.Manager.GetInstances<IIntegerVectorManipulator>().OrderBy(x => x.Name))
    60         Operators.Add(shaker);
     60        if (!(shaker is ISelfAdaptiveManipulator)) Operators.Add(shaker);
    6161    }
    6262
Note: See TracChangeset for help on using the changeset viewer.