Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3336


Ignore:
Timestamp:
04/13/10 18:32:07 (14 years ago)
Author:
abeham
Message:

updated Evolution Stratgy #932
StrategyParameters moved completely out of the ES into the encoding and problem, because they are inherently problem specific
The ProblemDimension and a few other parameters of ES were removed
Fixed a few bugs also and added some documentation

Location:
trunk/sources
Files:
13 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.EvolutionStrategy/3.3/EvolutionStrategyMainLoop.cs

    r3193 r3336  
    2828using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2929using HeuristicLab.Selection;
    30 using HeuristicLab.Encodings.RealVectorEncoding;
    3130
    3231namespace HeuristicLab.Algorithms.EvolutionStrategy {
     
    5958      get { return (ValueLookupParameter<IntValue>)Parameters["Children"]; }
    6059    }
    61     public ValueLookupParameter<RealVector> StrategyVectorParameter {
    62       get { return (ValueLookupParameter<RealVector>)Parameters["StrategyVector"]; }
    63     }
    64     public ValueLookupParameter<DoubleMatrix> StrategyVectorBoundsParameter {
    65       get { return (ValueLookupParameter<DoubleMatrix>)Parameters["StrategyVectorBounds"]; }
    66     }
    67     public ValueLookupParameter<DoubleValue> GeneralLearningRateParameter {
    68       get { return (ValueLookupParameter<DoubleValue>)Parameters["GeneralLearningRate"]; }
    69     }
    70     public ValueLookupParameter<DoubleValue> LearningRateParameter {
    71       get { return (ValueLookupParameter<DoubleValue>)Parameters["LearningRate"]; }
    72     }
    7360    public ValueLookupParameter<BoolValue> PlusSelectionParameter {
    7461      get { return (ValueLookupParameter<BoolValue>)Parameters["PlusSelection"]; }
     
    9784    private ScopeParameter CurrentScopeParameter {
    9885      get { return (ScopeParameter)Parameters["CurrentScope"]; }
     86    }
     87    private ValueLookupParameter<IOperator> StrategyParameterManipulatorParameter {
     88      get { return (ValueLookupParameter<IOperator>)Parameters["StrategyParameterManipulator"]; }
     89    }
     90    private ValueLookupParameter<IOperator> StrategyParameterCrossoverParameter {
     91      get { return (ValueLookupParameter<IOperator>)Parameters["StrategyParameterCrossover"]; }
    9992    }
    10093
     
    121114      Parameters.Add(new ValueLookupParameter<IntValue>("Children", "λ (lambda) - the size of the offspring population."));
    122115      Parameters.Add(new ValueLookupParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed."));
    123       Parameters.Add(new ValueLookupParameter<RealVector>("StrategyVector", "The strategy vector."));
    124       Parameters.Add(new LookupParameter<DoubleMatrix>("StrategyVectorBounds", "2 column matrix with one row for each dimension specifying upper and lower bound for the strategy vector. If there are less rows than dimensions, the strategy vector will be read in a cycle."));
    125       Parameters.Add(new ValueLookupParameter<DoubleValue>("GeneralLearningRate", "τ0 (tau0) - the factor with which adjustments in the strategy vector is dampened over all dimensions. Recommendation is to use 1/Sqrt(2*ProblemDimension)."));
    126       Parameters.Add(new ValueLookupParameter<DoubleValue>("LearningRate", "τ (tau) - the factor with which adjustments in the strategy vector are dampened in a single dimension. Recommendation is to use 1/Sqrt(2*Sqrt(ProblemDimension))."));
    127116      Parameters.Add(new ValueLookupParameter<BoolValue>("PlusSelection", "True for plus selection (elitist population), false for comma selection (non-elitist population)."));
    128117      Parameters.Add(new ValueLookupParameter<IOperator>("Mutator", "The operator used to mutate solutions."));
     
    133122      Parameters.Add(new LookupParameter<IItem>("Visualization", "The item which represents the visualization of solutions."));
    134123      Parameters.Add(new ScopeParameter("CurrentScope", "The current scope which represents a population of solutions on which the EvolutionStrategy should be applied."));
     124      Parameters.Add(new ValueLookupParameter<IOperator>("StrategyParameterManipulator", "The operator to mutate the endogeneous strategy parameters."));
     125      Parameters.Add(new ValueLookupParameter<IOperator>("StrategyParameterCrossover", "The operator to cross the endogeneous strategy parameters."));
    135126      #endregion
    136127
     
    151142      UniformSubScopesProcessor uniformSubScopesProcessor1 = new UniformSubScopesProcessor();
    152143      Placeholder recombinator = new Placeholder();
    153       StrategyVectorManipulator strategyMutator1 = new StrategyVectorManipulator();
     144      Placeholder strategyRecombinator = new Placeholder();
     145      Placeholder strategyMutator1 = new Placeholder();
    154146      Placeholder mutator1 = new Placeholder();
    155147      Placeholder evaluator1 = new Placeholder();
    156148      SubScopesRemover subScopesRemover = new SubScopesRemover();
    157149      UniformSubScopesProcessor uniformSubScopesProcessor2 = new UniformSubScopesProcessor();
    158       StrategyVectorManipulator strategyMutator2 = new StrategyVectorManipulator();
     150      Placeholder strategyMutator2 = new Placeholder();
    159151      Placeholder mutator2 = new Placeholder();
    160152      Placeholder evaluator2 = new Placeholder();
     
    230222      useRecombinationBranch.ConditionParameter.ActualName = "UseRecombination";
    231223
     224      childrenCreator.ParentsPerChild = null;
    232225      childrenCreator.ParentsPerChildParameter.ActualName = ParentsPerChildParameter.Name;
    233226
     
    235228      recombinator.OperatorParameter.ActualName = RecombinatorParameter.Name;
    236229
    237       strategyMutator1.StrategyVectorParameter.ActualName = StrategyVectorParameter.Name;
    238       strategyMutator1.GeneralLearningRateParameter.ActualName = GeneralLearningRateParameter.Name;
    239       strategyMutator1.LearningRateParameter.ActualName = LearningRateParameter.Name;
    240       strategyMutator1.RandomParameter.ActualName = RandomParameter.Name;
     230      strategyRecombinator.Name = "Strategy Parameter Recombinator (placeholder)";
     231      strategyRecombinator.OperatorParameter.ActualName = StrategyParameterCrossoverParameter.Name;
     232
     233      strategyMutator1.Name = "Strategy Parameter Manipulator (placeholder)";
     234      strategyMutator1.OperatorParameter.ActualName = StrategyParameterManipulatorParameter.Name;
    241235
    242236      mutator1.Name = "Mutator (placeholder)";
     
    248242      subScopesRemover.RemoveAllSubScopes = true;
    249243
    250       strategyMutator2.StrategyVectorParameter.ActualName = StrategyVectorParameter.Name;
    251       strategyMutator2.GeneralLearningRateParameter.ActualName = GeneralLearningRateParameter.Name;
    252       strategyMutator2.LearningRateParameter.ActualName = LearningRateParameter.Name;
    253       strategyMutator2.RandomParameter.ActualName = RandomParameter.Name;
     244      strategyMutator2.Name = "Strategy Parameter Manipulator (placeholder)";
     245      strategyMutator2.OperatorParameter.ActualName = StrategyParameterManipulatorParameter.Name;
    254246
    255247      mutator2.Name = "Mutator (placeholder)";
     
    327319      uniformSubScopesProcessor1.Operator = recombinator;
    328320      uniformSubScopesProcessor1.Successor = null;
    329       recombinator.Successor = strategyMutator1;
     321      recombinator.Successor = strategyRecombinator;
     322      strategyRecombinator.Successor = strategyMutator1;
    330323      strategyMutator1.Successor = mutator1;
    331324      mutator1.Successor = evaluator1;
  • trunk/sources/HeuristicLab.Algorithms.EvolutionStrategy/3.3/HeuristicLab.Algorithms.EvolutionStrategy-3.3.csproj

    r3183 r3336  
    8484    <Compile Include="EvolutionStrategy.cs" />
    8585    <Compile Include="EvolutionStrategyMainLoop.cs" />
    86     <Compile Include="SelfAdaptiveCrossover.cs" />
    87     <Compile Include="StrategyVectorManipulator.cs" />
    8886    <Compile Include="WithoutRepeatingBatchedRandomSelector.cs" />
    8987  </ItemGroup>
     
    109107      <Project>{BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}</Project>
    110108      <Name>HeuristicLab.Data-3.3</Name>
    111     </ProjectReference>
    112     <ProjectReference Include="..\..\HeuristicLab.Encodings.RealVectorEncoding\3.3\HeuristicLab.Encodings.RealVectorEncoding-3.3.csproj">
    113       <Project>{BB6D334A-4BB6-4674-9883-31A6EBB32CAB}</Project>
    114       <Name>HeuristicLab.Encodings.RealVectorEncoding-3.3</Name>
    115109    </ProjectReference>
    116110    <ProjectReference Include="..\..\HeuristicLab.Operators\3.3\HeuristicLab.Operators-3.3.csproj">
  • trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Creators/UniformRandomRealVectorCreator.cs

    r3160 r3336  
    3434  [Item("UniformRandomRealVectorCreator", "An operator which creates a new random real vector with each element uniformly distributed in a specified range.")]
    3535  [StorableClass]
    36   public class UniformRandomRealVectorCreator : RealVectorCreator {
     36  public class UniformRandomRealVectorCreator : RealVectorCreator, IStrategyParameterCreator {
    3737    /// <summary>
    3838    /// Generates a new random real vector with the given <paramref name="length"/> and in the interval [min,max).
  • trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/HeuristicLab.Encodings.RealVectorEncoding-3.3.csproj

    r3207 r3336  
    103103    <Compile Include="Crossovers\UniformSomePositionsArithmeticCrossover.cs" />
    104104    <Compile Include="HeuristicLabEncodingsRealVectorEncodingPlugin.cs" />
     105    <Compile Include="Interfaces\IRealVectorStrategyParameterManipulator.cs" />
     106    <Compile Include="Interfaces\IRealVectorStrategyParameterCrossover.cs" />
     107    <Compile Include="Interfaces\IRealVectorStrategyParameterCreator.cs" />
     108    <Compile Include="Interfaces\IRealVectorStrategyParameterOperator.cs" />
    105109    <Compile Include="Interfaces\IAdditiveRealVectorMoveOperator.cs" />
    106110    <Compile Include="Interfaces\IRealVectorBoundsChecker.cs" />
     
    108112    <Compile Include="Interfaces\IRealVectorMoveOperator.cs" />
    109113    <Compile Include="Manipulators\NormalAllPositionsManipulator.cs" />
     114    <Compile Include="StrategyParameters\StrategyVectorCreator.cs" />
     115    <Compile Include="StrategyParameters\StrategyVectorCrossover.cs" />
     116    <Compile Include="StrategyParameters\StrategyVectorManipulator.cs" />
    110117    <Compile Include="Moves\AdditiveMoveTabuAttribute.cs" />
    111118    <Compile Include="Moves\AdditiveTabuMoveEvaluator.cs" />
  • trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Manipulators/NormalAllPositionsManipulator.cs

    r3207 r3336  
    2323using HeuristicLab.Core;
    2424using HeuristicLab.Data;
     25using HeuristicLab.Optimization;
    2526using HeuristicLab.Parameters;
    2627using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3839  [Item("NormalAllPositionsManipulator", "This manipulation operator adds a value sigma_i * N(0,1) to the current value in each position i. The values for sigma_i are taken from the strategy vector, if there are less elements in the strategy vector than positions, then the strategy vector is cycled. It is implemented as described in Beyer, H.-G. and Schwefel, H.-P. 2002. Evolution Strategies - A Comprehensive Introduction Natural Computing, 1, pp. 3-52.")]
    3940  [StorableClass]
    40   public class NormalAllPositionsManipulator : RealVectorManipulator {
     41  public class NormalAllPositionsManipulator : RealVectorManipulator, IRealVectorStrategyParameterOperator, ISelfAdaptiveManipulator {
    4142    /// <summary>
    4243    /// Parameter for the strategy vector.
    4344    /// </summary>
    44     public ValueLookupParameter<RealVector> StrategyVectorParameter {
    45       get { return (ValueLookupParameter<RealVector>)Parameters["StrategyVector"]; }
     45    public IValueLookupParameter<RealVector> StrategyParameterParameter {
     46      get { return (IValueLookupParameter<RealVector>)Parameters["StrategyParameter"]; }
     47    }
     48
     49    IParameter ISelfAdaptiveManipulator.StrategyParameterParameter {
     50      get { return StrategyParameterParameter; }
    4651    }
    4752    /// <summary>
     
    5156    public NormalAllPositionsManipulator()
    5257      : base() {
    53       Parameters.Add(new ValueLookupParameter<RealVector>("StrategyVector", "The vector containing the endogenous strategy parameters."));
     58      Parameters.Add(new ValueLookupParameter<RealVector>("StrategyParameter", "The vector containing the endogenous strategy parameters."));
    5459    }
    5560
     
    7782    /// <param name="realVector">The vector of real values that is manipulated.</param>
    7883    protected override void Manipulate(IRandom random, RealVector realVector) {
    79       if (StrategyVectorParameter.ActualValue == null) throw new InvalidOperationException("NormalAllPositionsManipulator: The strategy vector parameter could not be found and does not have an associated value.");
    80       Apply(random, realVector, StrategyVectorParameter.ActualValue);
     84      if (StrategyParameterParameter.ActualValue == null) throw new InvalidOperationException("NormalAllPositionsManipulator: The strategy parameter could not be found and does not have an associated value.");
     85      Apply(random, realVector, StrategyParameterParameter.ActualValue);
    8186    }
    8287  }
  • trunk/sources/HeuristicLab.Logging/3.2/HeuristicLab.Logging-3.2.csproj

    r3203 r3336  
    8585    <Compile Include="BestAverageWorstQualityCalculator.cs" />
    8686    <Compile Include="PointXYChartView.cs">
     87      <SubType>UserControl</SubType>
    8788    </Compile>
    8889    <Compile Include="PointXYChartView.Designer.cs">
     
    9394    <Compile Include="HeuristicLabLoggingPlugin.cs" />
    9495    <Compile Include="LinechartView.cs">
     96      <SubType>UserControl</SubType>
    9597    </Compile>
    9698    <Compile Include="LinechartView.Designer.cs">
     
    98100    </Compile>
    99101    <Compile Include="LogView.cs">
     102      <SubType>UserControl</SubType>
    100103    </Compile>
    101104    <Compile Include="LogView.Designer.cs">
  • trunk/sources/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj

    r3280 r3336  
    8787    <Compile Include="Algorithm.cs" />
    8888    <Compile Include="BatchRun.cs" />
     89    <Compile Include="Interfaces\ISelfAdaptiveManipulator.cs" />
     90    <Compile Include="Interfaces\IStrategyParameterCrossover.cs" />
     91    <Compile Include="Interfaces\IStrategyParameterManipulator.cs" />
     92    <Compile Include="Interfaces\IStrategyParameterCreator.cs" />
    8993    <Compile Include="Interfaces\IRun.cs" />
     94    <Compile Include="Interfaces\IStrategyParameterOperator.cs" />
    9095    <Compile Include="OptimizerList.cs" />
    9196    <Compile Include="Experiment.cs" />
  • trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/IMoveOperator.cs

    r3044 r3336  
    2323
    2424namespace HeuristicLab.Optimization {
     25  /// <summary>
     26  /// The basic interface that marks all move operators.
     27  /// </summary>
     28  /// <remarks>
     29  /// A group of move operators that belong together should derive an interface from this one
     30  /// and implement the interface in each operator.<br />
     31  /// In an algorithm one can thus find out all move operators that belong together, by grouping operators
     32  /// according to the most specific interface derived from this interface that they implement.<br /><br />
     33  /// A concrete example:<br />
     34  /// You have a solution representation <c>MyRep</c> and there you have a move <c>MyRepMove</c> that you want
     35  /// to make available to the friendly GUIs. So in <c>MyRep</c> you derive an interface <c>IMyRepMoveOperator</c>.<br />
     36  /// Now you need to implement at least three operators that handle these moves: A MoveGenerator, a MoveMaker, and a MoveEvaluator.
     37  /// Note: The MoveEvaluator should be implemented in the problem plugin if you choose to separate representation and problem.<br />
     38  /// In each of these operators you implement <c>IMyRepMoveOperator</c> as well as the appropriate operator specific interface.
     39  /// For a MoveGenerator that would be one of <c>IExhaustiveMoveGenerator</c>, <c>ISingleMoveGenerator</c>,
     40  /// or <c>IMultiMoveGenerator</c>, for a MoveMaker that would be <c>IMoveMaker</c>, and for a MoveEvaluator that would
     41  /// either be <c>ISingleObjectiveMoveEvaluator</c> or <c>IMultiObjectiveMoveEvaluator</c>.<br />
     42  /// If you have this you need to make sure that an instance of all your operators are loaded in the Operators collection of your IProblem
     43  /// and you can select them in the respective algorithms.<br /><br />
     44  /// For Tabu Search support you will need two additional operators: A TabuChecker (e.g. derived from <see cref="TabuChecker" />),
     45  /// and a TabuMaker.<br /><br />
     46  /// If you decide later that you want another move, e.g. <c>MyRepMove2</c>, you would do as before and group them under
     47  /// the interface <c>IMyRepMove2Operator</c>.<br /><br />
     48  /// If you want to make use of multiple different moves, all your operators would need to know about all the moves that you plan
     49  /// to use.<br /><br />
     50  /// Take a look at the Permutation and TSP plugin to see how this looks like in real code.
     51  /// </remarks>
    2552  public interface IMoveOperator : IOperator {
    2653  }
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/SingleObjectiveTestFunctionProblem.cs

    r3318 r3336  
    3939  [Creatable("Problems")]
    4040  public sealed class SingleObjectiveTestFunctionProblem : ParameterizedNamedItem, ISingleObjectiveProblem {
     41    [Storable]
     42    private StrategyVectorCreator strategyVectorCreator;
     43    [Storable]
     44    private StrategyVectorCrossover strategyVectorCrossover;
     45    [Storable]
     46    private StrategyVectorManipulator strategyVectorManipulator;
     47
    4148    public override Image ItemImage {
    4249      get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Type; }
     
    144151      Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this TSP instance.", new DoubleValue(evaluator.BestKnownQuality)));
    145152
     153      strategyVectorCreator = new StrategyVectorCreator();
     154      strategyVectorCreator.LengthParameter.ActualName = ProblemSizeParameter.Name;
     155      strategyVectorCrossover = new StrategyVectorCrossover();
     156      strategyVectorManipulator = new StrategyVectorManipulator();
     157
    146158      creator.RealVectorParameter.ActualName = "Point";
    147159      ParameterizeSolutionCreator();
     
    184196    }
    185197    private void ProblemSize_ValueChanged(object sender, EventArgs e) {
     198      if (ProblemSize.Value < 1) ProblemSize.Value = 1;
    186199      ParameterizeSolutionCreator();
     200      strategyVectorManipulator.GeneralLearningRateParameter.Value = new DoubleValue(1.0 / Math.Sqrt(2 * ProblemSize.Value));
     201      strategyVectorManipulator.LearningRateParameter.Value = new DoubleValue(1.0 / Math.Sqrt(2 * Math.Sqrt(ProblemSize.Value)));
    187202    }
    188203    private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) {
     
    249264        }
    250265      }
     266    }
     267    private void strategyVectorCreator_BoundsParameter_ValueChanged(object sender, EventArgs e) {
     268      strategyVectorManipulator.BoundsParameter.Value = strategyVectorCreator.BoundsParameter.Value;
     269    }
     270    private void strategyVectorCreator_StrategyParameterParameter_ActualNameChanged(object sender, EventArgs e) {
     271      string name = strategyVectorCreator.StrategyParameterParameter.ActualName;
     272      strategyVectorCrossover.ParentsParameter.ActualName = name;
     273      strategyVectorCrossover.StrategyParameterParameter.ActualName = name;
     274      strategyVectorManipulator.StrategyParameterParameter.ActualName = name;
    251275    }
    252276    #endregion
     
    266290      Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
    267291      VisualizerParameter.ValueChanged += new EventHandler(VisualizerParameter_ValueChanged);
     292      strategyVectorCreator.BoundsParameter.ValueChanged += new EventHandler(strategyVectorCreator_BoundsParameter_ValueChanged);
     293      strategyVectorCreator.StrategyParameterParameter.ActualNameChanged += new EventHandler(strategyVectorCreator_StrategyParameterParameter_ActualNameChanged);
    268294    }
    269295    private void InitializeOperators() {
    270296      operators = new List<IOperator>();
    271297      operators.AddRange(ApplicationManager.Manager.GetInstances<IRealVectorOperator>().Cast<IOperator>());
     298      operators.Add(strategyVectorCreator);
     299      operators.Add(strategyVectorCrossover);
     300      operators.Add(strategyVectorManipulator);
    272301      UpdateMoveEvaluators();
    273302      ParameterizeOperators();
Note: See TracChangeset for help on using the changeset viewer.