Changeset 3336 for trunk/sources
- Timestamp:
- 04/13/10 18:32:07 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 13 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.EvolutionStrategy/3.3/EvolutionStrategyMainLoop.cs
r3193 r3336 28 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 29 using HeuristicLab.Selection; 30 using HeuristicLab.Encodings.RealVectorEncoding;31 30 32 31 namespace HeuristicLab.Algorithms.EvolutionStrategy { … … 59 58 get { return (ValueLookupParameter<IntValue>)Parameters["Children"]; } 60 59 } 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 }73 60 public ValueLookupParameter<BoolValue> PlusSelectionParameter { 74 61 get { return (ValueLookupParameter<BoolValue>)Parameters["PlusSelection"]; } … … 97 84 private ScopeParameter CurrentScopeParameter { 98 85 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"]; } 99 92 } 100 93 … … 121 114 Parameters.Add(new ValueLookupParameter<IntValue>("Children", "λ (lambda) - the size of the offspring population.")); 122 115 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))."));127 116 Parameters.Add(new ValueLookupParameter<BoolValue>("PlusSelection", "True for plus selection (elitist population), false for comma selection (non-elitist population).")); 128 117 Parameters.Add(new ValueLookupParameter<IOperator>("Mutator", "The operator used to mutate solutions.")); … … 133 122 Parameters.Add(new LookupParameter<IItem>("Visualization", "The item which represents the visualization of solutions.")); 134 123 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.")); 135 126 #endregion 136 127 … … 151 142 UniformSubScopesProcessor uniformSubScopesProcessor1 = new UniformSubScopesProcessor(); 152 143 Placeholder recombinator = new Placeholder(); 153 StrategyVectorManipulator strategyMutator1 = new StrategyVectorManipulator(); 144 Placeholder strategyRecombinator = new Placeholder(); 145 Placeholder strategyMutator1 = new Placeholder(); 154 146 Placeholder mutator1 = new Placeholder(); 155 147 Placeholder evaluator1 = new Placeholder(); 156 148 SubScopesRemover subScopesRemover = new SubScopesRemover(); 157 149 UniformSubScopesProcessor uniformSubScopesProcessor2 = new UniformSubScopesProcessor(); 158 StrategyVectorManipulator strategyMutator2 = new StrategyVectorManipulator();150 Placeholder strategyMutator2 = new Placeholder(); 159 151 Placeholder mutator2 = new Placeholder(); 160 152 Placeholder evaluator2 = new Placeholder(); … … 230 222 useRecombinationBranch.ConditionParameter.ActualName = "UseRecombination"; 231 223 224 childrenCreator.ParentsPerChild = null; 232 225 childrenCreator.ParentsPerChildParameter.ActualName = ParentsPerChildParameter.Name; 233 226 … … 235 228 recombinator.OperatorParameter.ActualName = RecombinatorParameter.Name; 236 229 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; 241 235 242 236 mutator1.Name = "Mutator (placeholder)"; … … 248 242 subScopesRemover.RemoveAllSubScopes = true; 249 243 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; 254 246 255 247 mutator2.Name = "Mutator (placeholder)"; … … 327 319 uniformSubScopesProcessor1.Operator = recombinator; 328 320 uniformSubScopesProcessor1.Successor = null; 329 recombinator.Successor = strategyMutator1; 321 recombinator.Successor = strategyRecombinator; 322 strategyRecombinator.Successor = strategyMutator1; 330 323 strategyMutator1.Successor = mutator1; 331 324 mutator1.Successor = evaluator1; -
trunk/sources/HeuristicLab.Algorithms.EvolutionStrategy/3.3/HeuristicLab.Algorithms.EvolutionStrategy-3.3.csproj
r3183 r3336 84 84 <Compile Include="EvolutionStrategy.cs" /> 85 85 <Compile Include="EvolutionStrategyMainLoop.cs" /> 86 <Compile Include="SelfAdaptiveCrossover.cs" />87 <Compile Include="StrategyVectorManipulator.cs" />88 86 <Compile Include="WithoutRepeatingBatchedRandomSelector.cs" /> 89 87 </ItemGroup> … … 109 107 <Project>{BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}</Project> 110 108 <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>115 109 </ProjectReference> 116 110 <ProjectReference Include="..\..\HeuristicLab.Operators\3.3\HeuristicLab.Operators-3.3.csproj"> -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Creators/UniformRandomRealVectorCreator.cs
r3160 r3336 34 34 [Item("UniformRandomRealVectorCreator", "An operator which creates a new random real vector with each element uniformly distributed in a specified range.")] 35 35 [StorableClass] 36 public class UniformRandomRealVectorCreator : RealVectorCreator {36 public class UniformRandomRealVectorCreator : RealVectorCreator, IStrategyParameterCreator { 37 37 /// <summary> 38 38 /// 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 103 103 <Compile Include="Crossovers\UniformSomePositionsArithmeticCrossover.cs" /> 104 104 <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" /> 105 109 <Compile Include="Interfaces\IAdditiveRealVectorMoveOperator.cs" /> 106 110 <Compile Include="Interfaces\IRealVectorBoundsChecker.cs" /> … … 108 112 <Compile Include="Interfaces\IRealVectorMoveOperator.cs" /> 109 113 <Compile Include="Manipulators\NormalAllPositionsManipulator.cs" /> 114 <Compile Include="StrategyParameters\StrategyVectorCreator.cs" /> 115 <Compile Include="StrategyParameters\StrategyVectorCrossover.cs" /> 116 <Compile Include="StrategyParameters\StrategyVectorManipulator.cs" /> 110 117 <Compile Include="Moves\AdditiveMoveTabuAttribute.cs" /> 111 118 <Compile Include="Moves\AdditiveTabuMoveEvaluator.cs" /> -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Manipulators/NormalAllPositionsManipulator.cs
r3207 r3336 23 23 using HeuristicLab.Core; 24 24 using HeuristicLab.Data; 25 using HeuristicLab.Optimization; 25 26 using HeuristicLab.Parameters; 26 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 38 39 [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.")] 39 40 [StorableClass] 40 public class NormalAllPositionsManipulator : RealVectorManipulator {41 public class NormalAllPositionsManipulator : RealVectorManipulator, IRealVectorStrategyParameterOperator, ISelfAdaptiveManipulator { 41 42 /// <summary> 42 43 /// Parameter for the strategy vector. 43 44 /// </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; } 46 51 } 47 52 /// <summary> … … 51 56 public NormalAllPositionsManipulator() 52 57 : base() { 53 Parameters.Add(new ValueLookupParameter<RealVector>("Strategy Vector", "The vector containing the endogenous strategy parameters."));58 Parameters.Add(new ValueLookupParameter<RealVector>("StrategyParameter", "The vector containing the endogenous strategy parameters.")); 54 59 } 55 60 … … 77 82 /// <param name="realVector">The vector of real values that is manipulated.</param> 78 83 protected override void Manipulate(IRandom random, RealVector realVector) { 79 if (Strategy VectorParameter.ActualValue == null) throw new InvalidOperationException("NormalAllPositionsManipulator: The strategy vectorparameter could not be found and does not have an associated value.");80 Apply(random, realVector, Strategy VectorParameter.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); 81 86 } 82 87 } -
trunk/sources/HeuristicLab.Logging/3.2/HeuristicLab.Logging-3.2.csproj
r3203 r3336 85 85 <Compile Include="BestAverageWorstQualityCalculator.cs" /> 86 86 <Compile Include="PointXYChartView.cs"> 87 <SubType>UserControl</SubType> 87 88 </Compile> 88 89 <Compile Include="PointXYChartView.Designer.cs"> … … 93 94 <Compile Include="HeuristicLabLoggingPlugin.cs" /> 94 95 <Compile Include="LinechartView.cs"> 96 <SubType>UserControl</SubType> 95 97 </Compile> 96 98 <Compile Include="LinechartView.Designer.cs"> … … 98 100 </Compile> 99 101 <Compile Include="LogView.cs"> 102 <SubType>UserControl</SubType> 100 103 </Compile> 101 104 <Compile Include="LogView.Designer.cs"> -
trunk/sources/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj
r3280 r3336 87 87 <Compile Include="Algorithm.cs" /> 88 88 <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" /> 89 93 <Compile Include="Interfaces\IRun.cs" /> 94 <Compile Include="Interfaces\IStrategyParameterOperator.cs" /> 90 95 <Compile Include="OptimizerList.cs" /> 91 96 <Compile Include="Experiment.cs" /> -
trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/IMoveOperator.cs
r3044 r3336 23 23 24 24 namespace 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> 25 52 public interface IMoveOperator : IOperator { 26 53 } -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/SingleObjectiveTestFunctionProblem.cs
r3318 r3336 39 39 [Creatable("Problems")] 40 40 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 41 48 public override Image ItemImage { 42 49 get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Type; } … … 144 151 Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this TSP instance.", new DoubleValue(evaluator.BestKnownQuality))); 145 152 153 strategyVectorCreator = new StrategyVectorCreator(); 154 strategyVectorCreator.LengthParameter.ActualName = ProblemSizeParameter.Name; 155 strategyVectorCrossover = new StrategyVectorCrossover(); 156 strategyVectorManipulator = new StrategyVectorManipulator(); 157 146 158 creator.RealVectorParameter.ActualName = "Point"; 147 159 ParameterizeSolutionCreator(); … … 184 196 } 185 197 private void ProblemSize_ValueChanged(object sender, EventArgs e) { 198 if (ProblemSize.Value < 1) ProblemSize.Value = 1; 186 199 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))); 187 202 } 188 203 private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) { … … 249 264 } 250 265 } 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; 251 275 } 252 276 #endregion … … 266 290 Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); 267 291 VisualizerParameter.ValueChanged += new EventHandler(VisualizerParameter_ValueChanged); 292 strategyVectorCreator.BoundsParameter.ValueChanged += new EventHandler(strategyVectorCreator_BoundsParameter_ValueChanged); 293 strategyVectorCreator.StrategyParameterParameter.ActualNameChanged += new EventHandler(strategyVectorCreator_StrategyParameterParameter_ActualNameChanged); 268 294 } 269 295 private void InitializeOperators() { 270 296 operators = new List<IOperator>(); 271 297 operators.AddRange(ApplicationManager.Manager.GetInstances<IRealVectorOperator>().Cast<IOperator>()); 298 operators.Add(strategyVectorCreator); 299 operators.Add(strategyVectorCrossover); 300 operators.Add(strategyVectorManipulator); 272 301 UpdateMoveEvaluators(); 273 302 ParameterizeOperators();
Note: See TracChangeset
for help on using the changeset viewer.