- Timestamp:
- 03/22/10 22:58:43 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 26 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearch.cs
r3145 r3187 65 65 get { return (ValueParameter<IntValue>)Parameters["MaximumIterations"]; } 66 66 } 67 private ValueParameter<IntValue> SampleSizeParameter { 68 get { return (ValueParameter<IntValue>)Parameters["SampleSize"]; } 69 } 67 70 #endregion 68 71 … … 91 94 get { return MaximumIterationsParameter.Value; } 92 95 set { MaximumIterationsParameter.Value = value; } 96 } 97 public IntValue SampleSize { 98 get { return SampleSizeParameter.Value; } 99 set { SampleSizeParameter.Value = value; } 93 100 } 94 101 private RandomCreator RandomCreator { … … 113 120 Parameters.Add(new ConstrainedValueParameter<ISingleObjectiveMoveEvaluator>("MoveEvaluator", "The operator used to evaluate a move.")); 114 121 Parameters.Add(new ValueParameter<IntValue>("MaximumIterations", "The maximum number of generations which should be processed.", new IntValue(1000))); 122 Parameters.Add(new ValueParameter<IntValue>("SampleSize", "Number of moves that MultiMoveGenerators should create. This is ignored for Exhaustive- and SingleMoveGenerators.", new IntValue(100))); 115 123 116 124 RandomCreator randomCreator = new RandomCreator(); … … 158 166 ParameterizeMoveMakers(); 159 167 UpdateMoveGenerator(); 168 UpdateMoveParameters(); 160 169 Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); 161 170 base.OnProblemChanged(); … … 189 198 op.MoveQualityParameter.ActualNameChanged += new EventHandler(MoveEvaluator_MoveQualityParameter_ActualNameChanged); 190 199 } 191 IMoveGenerator oldMoveGenerator = MoveGenerator;192 200 UpdateMoveGenerator(); 193 if (oldMoveGenerator == MoveGenerator) // in this case MoveGeneratorParameter_ValueChanged did not fire 194 UpdateMoveParameters(); 201 UpdateMoveParameters(); 195 202 ParameterizeMainLoop(); 196 203 ParameterizeMoveEvaluators(); -
trunk/sources/HeuristicLab.Algorithms.SimulatedAnnealing/3.3/SimulatedAnnealing.cs
r3145 r3187 191 191 ParameterizeSolutionsCreator(); 192 192 ParameterizeMainLoop(); 193 UpdateMoveGenerator(); 194 UpdateMoveParameters(); 193 195 ParameterizeMoveEvaluators(); 194 196 ParameterizeMoveMakers(); 195 197 ParameterizeMoveGenerators(); 196 UpdateMoveGenerator();197 198 Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); 198 199 base.OnProblemChanged(); … … 226 227 op.MoveQualityParameter.ActualNameChanged += new EventHandler(MoveEvaluator_MoveQualityParameter_ActualNameChanged); 227 228 } 228 IMultiMoveGenerator oldMoveGenerator = MoveGenerator;229 229 UpdateMoveGenerator(); 230 if (oldMoveGenerator == MoveGenerator) // in this case MoveGeneratorParameter_ValueChanged did not fire 231 UpdateMoveParameters(); 230 UpdateMoveParameters(); 232 231 ParameterizeMainLoop(); 233 232 ParameterizeMoveEvaluators(); -
trunk/sources/HeuristicLab.Algorithms.TabuSearch/3.3/TabuSearch.cs
r3145 r3187 188 188 ParameterizeSolutionsCreator(); 189 189 ParameterizeMainLoop(); 190 UpdateMoveGenerator(); 191 UpdateMoveParameters(); 190 192 ParameterizeMoveGenerators(); 191 193 ParameterizeMoveEvaluator(); 192 194 ParameterizeMoveMaker(); 193 UpdateMoveGenerator();194 195 Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); 195 196 base.OnProblemChanged(); … … 227 228 op.MoveTabuParameter.ActualNameChanged += new EventHandler(TabuMoveEvaluator_MoveTabuParameter_ActualNameChanged); 228 229 } 229 IMoveGenerator oldMoveGenerator = MoveGenerator;230 230 UpdateMoveGenerator(); 231 if (oldMoveGenerator == MoveGenerator) // in this case MoveGeneratorParameter_ValueChanged did not fire 232 UpdateMoveParameters(); 231 UpdateMoveParameters(); 233 232 ParameterizeMainLoop(); 234 233 ParameterizeMoveGenerators(); -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/HeuristicLab.Encodings.RealVectorEncoding-3.3.csproj
r3182 r3187 103 103 <Compile Include="Crossovers\UniformSomePositionsArithmeticCrossover.cs" /> 104 104 <Compile Include="HeuristicLabEncodingsRealVectorEncodingPlugin.cs" /> 105 <Compile Include="Interfaces\IAdditiveRealVectorMoveOperator.cs" /> 105 106 <Compile Include="Interfaces\IRealVectorBoundsChecker.cs" /> 107 <Compile Include="Interfaces\IRealVectorMoveGenerator.cs" /> 108 <Compile Include="Interfaces\IRealVectorMoveOperator.cs" /> 109 <Compile Include="Moves\Polynomial\StochasticPolynomialMultiMoveGenerator.cs" /> 110 <Compile Include="Moves\AdditiveMoveMaker.cs" /> 111 <Compile Include="Moves\AdditiveMove.cs" /> 112 <Compile Include="Moves\AdditiveMoveGenerator.cs" /> 106 113 <Compile Include="RealVector.cs" /> 107 114 <Compile Include="Manipulators\BreederGeneticAlgorithmManipulator.cs" /> -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Manipulators/PolynomialAllPositionManipulator.cs
r3060 r3187 48 48 /// </summary> 49 49 /// <remarks> 50 /// The manipulated value is not restricted by the (possibly) specified lower and upper bounds. Use the <see cref="BoundsChecker"/> to correct the values after performing the mutation.50 /// If there are bounds specified the manipulated value is restricted by the given lower and upper bounds. 51 51 /// </remarks> 52 52 public ValueLookupParameter<DoubleValue> MaximumManipulationParameter { -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Manipulators/PolynomialOnePositionManipulator.cs
r3060 r3187 47 47 /// </summary> 48 48 /// <remarks> 49 /// The manipulated value is not restricted by the (possibly) specified lower and upper bounds. Use the <see cref="BoundsChecker"/> to correct the values after performing the mutation.49 /// If there are bounds specified the manipulated value is restricted by the given lower and upper bounds. 50 50 /// </remarks> 51 51 public ValueLookupParameter<DoubleValue> MaximumManipulationParameter { … … 73 73 if (contiguity.Value < 0) throw new ArgumentException("PolynomialOnePositionManipulator: Contiguity value is smaller than 0", "contiguity"); 74 74 int index = random.Next(vector.Length); 75 vector[index] += Apply(random, contiguity.Value) * maxManipulation.Value; 76 } 77 78 public static double Apply(IRandom random, double contiguity) { 75 79 double u = random.NextDouble(), delta = 0; 76 80 77 81 if (u < 0.5) { 78 delta = Math.Pow(2 * u, 1.0 / (contiguity .Value+ 1)) - 1.0;82 delta = Math.Pow(2 * u, 1.0 / (contiguity + 1)) - 1.0; 79 83 } else if (u > 0.5) { 80 delta = 1.0 - Math.Pow(2.0 - 2.0 * u, 1.0 / contiguity .Value+ 1);81 } else if (u == 0.5)delta = 0;84 delta = 1.0 - Math.Pow(2.0 - 2.0 * u, 1.0 / contiguity + 1); 85 } else delta = 0; 82 86 83 vector[index] += delta * maxManipulation.Value;87 return delta; 84 88 } 85 89 -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/SumSquaresEvaluator.cs
r3161 r3187 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-20 08Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 21 21 22 22 using System; 23 using System.Collections.Generic; 24 using System.Text; 23 using HeuristicLab.Core; 24 using HeuristicLab.Data; 25 using HeuristicLab.Encodings.RealVectorEncoding; 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 25 27 26 namespace HeuristicLab. TestFunctions {28 namespace HeuristicLab.Problems.TestFunctions { 27 29 /// <summary> 28 30 /// Sum Squares Function<br/> … … 30 32 /// Optimum: 0.0 at (0.0, 0.0, ..., 0.0) 31 33 /// </summary> 32 public class SumSquaresEvaluator : TestFunctionEvaluatorBase { 33 /// <inheritdoc select="summary"/> 34 public override string Description { 35 get { return 36 @"Sum Squares Function 37 38 Domain: [-10.0 , 10.0]^n 39 Optimum: 0.0 at (0.0, 0.0, ..., 0.0)"; 40 } 34 [Item("SumSquaresEvaluator", "Evaluates the sum squares function on a given point. The optimum of this function is 0 at the origin.")] 35 [StorableClass] 36 public class SumSquaresEvaluator : SingleObjectiveTestFunctionProblemEvaluator { 37 /// <summary> 38 /// Returns false as the Rosenbrock function is a minimization problem. 39 /// </summary> 40 public override bool Maximization { 41 get { return false; } 42 } 43 /// <summary> 44 /// Gets the optimum function value (0). 45 /// </summary> 46 public override double BestKnownQuality { 47 get { return 0; } 48 } 49 /// <summary> 50 /// Gets the lower and upper bound of the function. 51 /// </summary> 52 public override DoubleMatrix Bounds { 53 get { return new DoubleMatrix(new double[,] { { -10, 10 } }); } 54 } 55 /// <summary> 56 /// Gets the minimum problem size (1). 57 /// </summary> 58 public override int MinimumProblemSize { 59 get { return 1; } 60 } 61 /// <summary> 62 /// Gets the (theoretical) maximum problem size (2^31 - 1). 63 /// </summary> 64 public override int MaximumProblemSize { 65 get { return int.MaxValue; } 41 66 } 42 67 … … 46 71 /// <param name="point">N-dimensional point for which the test function should be evaluated.</param> 47 72 /// <returns>The result value of the Sum Squares function at the given point.</returns> 48 public static double Apply( double[]point) {73 public static double Apply(RealVector point) { 49 74 double result = 0; 50 75 for (int i = 0; i < point.Length; i++) { … … 60 85 /// <param name="point">N-dimensional point for which the test function should be evaluated.</param> 61 86 /// <returns>The result value of the Sum Squares function at the given point.</returns> 62 protected override double EvaluateFunction( double[]point) {87 protected override double EvaluateFunction(RealVector point) { 63 88 return Apply(point); 64 89 } -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/HeuristicLab.Problems.TestFunctions-3.3.csproj
r3170 r3187 95 95 <Compile Include="Evaluators\SingleObjectiveTestFunctionProblemEvaluator.cs" /> 96 96 <Compile Include="Evaluators\SphereEvaluator.cs" /> 97 <Compile Include="Evaluators\SumSquaresEvaluator.cs" /> 97 98 <Compile Include="Evaluators\ZakharovEvaluator.cs" /> 98 99 <Compile Include="HeuristicLabProblemsTestFunctionsPlugin.cs" /> 100 <Compile Include="Interfaces\ISingleObjectiveTestFunctionAdditiveMoveEvaluator.cs" /> 101 <Compile Include="Interfaces\ISingleObjectiveTestFunctionMoveEvaluator.cs" /> 99 102 <Compile Include="Interfaces\ISingleObjectiveTestFunctionProblemEvaluator.cs" /> 100 103 <Compile Include="Interfaces\ISingleObjectiveTestFunctionProblemSolutionsVisualizer.cs" /> 104 <Compile Include="MoveEvaluators\AckleyAdditiveMoveEvaluator.cs" /> 105 <Compile Include="MoveEvaluators\BealeAdditiveMoveEvaluator.cs" /> 106 <Compile Include="MoveEvaluators\BoothAdditiveMoveEvaluator.cs" /> 107 <Compile Include="MoveEvaluators\ZakharovAdditiveMoveEvaluator.cs" /> 108 <Compile Include="MoveEvaluators\SumSquaresAdditiveMoveEvaluator.cs" /> 109 <Compile Include="MoveEvaluators\SphereAdditiveMoveEvaluator.cs" /> 110 <Compile Include="MoveEvaluators\SchwefelAdditiveMoveEvaluator.cs" /> 111 <Compile Include="MoveEvaluators\MatyasAdditiveMoveEvaluator.cs" /> 112 <Compile Include="MoveEvaluators\RosenbrockAdditiveMoveEvaluator.cs" /> 113 <Compile Include="MoveEvaluators\RastriginAdditiveMoveEvaluator.cs" /> 114 <Compile Include="MoveEvaluators\LevyAdditiveMoveEvaluator.cs" /> 115 <Compile Include="MoveEvaluators\GriewangkAdditiveMoveEvaluator.cs" /> 116 <Compile Include="MoveEvaluators\AdditiveMoveEvaluator.cs" /> 117 <Compile Include="MoveEvaluators\RealVectorAdditiveMoveWrapper.cs" /> 101 118 <Compile Include="SingleObjectiveTestFunctionProblem.cs" /> 102 119 <None Include="HeuristicLab.snk" /> -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/SingleObjectiveTestFunctionProblem.cs
r3182 r3187 123 123 set { BestKnownQualityParameter.Value = value; } 124 124 } 125 private List<I RealVectorOperator> operators;125 private List<IOperator> operators; 126 126 public IEnumerable<IOperator> Operators { 127 get { return operators .Cast<IOperator>(); }127 get { return operators; } 128 128 } 129 129 #endregion … … 197 197 private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) { 198 198 ParameterizeEvaluator(); 199 UpdateMoveEvaluators(); 199 200 Maximization.Value = Evaluator.Maximization; 200 201 BoundsParameter.Value = Evaluator.Bounds; … … 226 227 Bounds[e.Value, 0] = Bounds[e.Value, 1] - 0.1; 227 228 } 228 private void BoundsParameter_NameChanged(object sender, EventArgs e) { 229 ParameterizeOperators(); 229 private void MoveGenerator_AdditiveMoveParameter_ActualNameChanged(object sender, EventArgs e) { 230 string name = ((ILookupParameter<AdditiveMove>)sender).ActualName; 231 foreach (IAdditiveRealVectorMoveOperator op in Operators.OfType<IAdditiveRealVectorMoveOperator>()) { 232 op.AdditiveMoveParameter.ActualName = name; 233 } 230 234 } 231 235 #endregion … … 237 241 ProblemSizeParameter.ValueChanged += new EventHandler(ProblemSizeParameter_ValueChanged); 238 242 ProblemSize.ValueChanged += new EventHandler(ProblemSize_ValueChanged); 239 BoundsParameter.NameChanged += new EventHandler(BoundsParameter_NameChanged);240 243 BoundsParameter.ValueChanged += new EventHandler(BoundsParameter_ValueChanged); 241 244 Bounds.ToStringChanged += new EventHandler(Bounds_ToStringChanged); … … 248 251 } 249 252 private void InitializeOperators() { 250 operators = new List<I RealVectorOperator>();253 operators = new List<IOperator>(); 251 254 if (ApplicationManager.Manager != null) { 252 operators.AddRange(ApplicationManager.Manager.GetInstances<IRealVectorOperator>()); 255 foreach (IRealVectorOperator op in ApplicationManager.Manager.GetInstances<IRealVectorOperator>()) 256 operators.Add(op); 257 UpdateMoveEvaluators(); 253 258 ParameterizeOperators(); 254 259 } 255 //InitializeMoveGenerators();256 } 257 /*private void InitializeMoveGenerators() {258 foreach (I TwoOptPermutationMoveOperator op in Operators.OfType<ITwoOptPermutationMoveOperator>()) {260 InitializeMoveGenerators(); 261 } 262 private void InitializeMoveGenerators() { 263 foreach (IAdditiveRealVectorMoveOperator op in Operators.OfType<IAdditiveRealVectorMoveOperator>()) { 259 264 if (op is IMoveGenerator) { 260 op. TwoOptMoveParameter.ActualNameChanged += new EventHandler(MoveGenerator_TwoOptMoveParameter_ActualNameChanged);265 op.AdditiveMoveParameter.ActualNameChanged += new EventHandler(MoveGenerator_AdditiveMoveParameter_ActualNameChanged); 261 266 } 262 267 } 263 foreach (IThreeOptPermutationMoveOperator op in Operators.OfType<IThreeOptPermutationMoveOperator>()) { 264 if (op is IMoveGenerator) { 265 op.ThreeOptMoveParameter.ActualNameChanged += new EventHandler(MoveGenerator_ThreeOptMoveParameter_ActualNameChanged); 266 } 267 } 268 }*/ 268 } 269 private void UpdateMoveEvaluators() { 270 if (ApplicationManager.Manager != null) { 271 foreach (ISingleObjectiveTestFunctionMoveEvaluator op in Operators.OfType<ISingleObjectiveTestFunctionMoveEvaluator>().ToList()) 272 operators.Remove(op); 273 foreach (ISingleObjectiveTestFunctionMoveEvaluator op in ApplicationManager.Manager.GetInstances<ISingleObjectiveTestFunctionMoveEvaluator>()) 274 if (op.EvaluatorType == Evaluator.GetType()) { 275 operators.Add(op); 276 } 277 ParameterizeOperators(); 278 OnOperatorsChanged(); 279 } 280 } 269 281 private void ParameterizeSolutionCreator() { 270 282 SolutionCreator.LengthParameter.Value = new IntValue(ProblemSize.Value); … … 289 301 op.BoundsParameter.ActualName = BoundsParameter.Name; 290 302 } 291 /*foreach (IPermutationMoveOperator op in Operators.OfType<IPermutationMoveOperator>()) { 292 op.PermutationParameter.ActualName = SolutionCreator.PermutationParameter.ActualName; 293 } 294 foreach (ITSPPathMoveEvaluator op in Operators.OfType<ITSPPathMoveEvaluator>()) { 295 op.CoordinatesParameter.ActualName = CoordinatesParameter.Name; 296 op.DistanceMatrixParameter.ActualName = DistanceMatrixParameter.Name; 297 op.UseDistanceMatrixParameter.ActualName = UseDistanceMatrixParameter.Name; 298 }*/ 303 foreach (IRealVectorMoveOperator op in Operators.OfType<IRealVectorMoveOperator>()) { 304 op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName; 305 } 306 foreach (IRealVectorMoveGenerator op in Operators.OfType<IRealVectorMoveGenerator>()) { 307 op.BoundsParameter.ActualName = BoundsParameter.Name; 308 } 309 foreach (ISingleObjectiveTestFunctionAdditiveMoveEvaluator op in Operators.OfType<ISingleObjectiveTestFunctionAdditiveMoveEvaluator>()) { 310 op.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName; 311 op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName; 312 } 299 313 } 300 314 #endregion
Note: See TracChangeset
for help on using the changeset viewer.