Changeset 3187 for trunk/sources/HeuristicLab.Problems.TestFunctions
- Timestamp:
- 03/22/10 22:58:43 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.TestFunctions/3.3
- Files:
-
- 17 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
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.