Changeset 3781
- Timestamp:
- 05/11/10 19:18:32 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 17 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab 3.3.sln
r3777 r3781 244 244 EndProject 245 245 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.DataAnalysis.Tests-3.3", "HeuristicLab.Problems.DataAnalysis\3.3\Tests\HeuristicLab.Problems.DataAnalysis.Tests-3.3.csproj", "{5A4679EF-A8F3-4647-B722-441A36B3BA6B}" 246 EndProject 247 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.TestFunctions-3.3.Tests", "HeuristicLab.Problems.TestFunctions\3.3\Tests\HeuristicLab.Problems.TestFunctions-3.3.Tests.csproj", "{71D904D9-233B-44B2-ABB2-1525691228C5}" 246 248 EndProject 247 249 Global … … 1356 1358 {5A4679EF-A8F3-4647-B722-441A36B3BA6B}.Services|x64.ActiveCfg = Release|Any CPU 1357 1359 {5A4679EF-A8F3-4647-B722-441A36B3BA6B}.Services|x86.ActiveCfg = Release|Any CPU 1360 {71D904D9-233B-44B2-ABB2-1525691228C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 1361 {71D904D9-233B-44B2-ABB2-1525691228C5}.Debug|Any CPU.Build.0 = Debug|Any CPU 1362 {71D904D9-233B-44B2-ABB2-1525691228C5}.Debug|x64.ActiveCfg = Debug|Any CPU 1363 {71D904D9-233B-44B2-ABB2-1525691228C5}.Debug|x86.ActiveCfg = Debug|Any CPU 1364 {71D904D9-233B-44B2-ABB2-1525691228C5}.Release|Any CPU.ActiveCfg = Release|Any CPU 1365 {71D904D9-233B-44B2-ABB2-1525691228C5}.Release|Any CPU.Build.0 = Release|Any CPU 1366 {71D904D9-233B-44B2-ABB2-1525691228C5}.Release|x64.ActiveCfg = Release|Any CPU 1367 {71D904D9-233B-44B2-ABB2-1525691228C5}.Release|x86.ActiveCfg = Release|Any CPU 1368 {71D904D9-233B-44B2-ABB2-1525691228C5}.Services|Any CPU.ActiveCfg = Release|Any CPU 1369 {71D904D9-233B-44B2-ABB2-1525691228C5}.Services|Any CPU.Build.0 = Release|Any CPU 1370 {71D904D9-233B-44B2-ABB2-1525691228C5}.Services|x64.ActiveCfg = Release|Any CPU 1371 {71D904D9-233B-44B2-ABB2-1525691228C5}.Services|x86.ActiveCfg = Release|Any CPU 1358 1372 EndGlobalSection 1359 1373 GlobalSection(SolutionProperties) = preSolution -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Analyzers/BestSingleObjectiveTestFunctionSolutionAnalyzer.cs
r3661 r3781 55 55 get { return (ILookupParameter<SingleObjectiveTestFunctionSolution>)Parameters["BestSolution"]; } 56 56 } 57 public ILookupParameter<RealVector> BestKnownSolutionParameter { 58 get { return (ILookupParameter<RealVector>)Parameters["BestKnownSolution"]; } 59 } 60 public ILookupParameter<DoubleValue> BestKnownQualityParameter { 61 get { return (ILookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; } 62 } 57 63 public IValueLookupParameter<ResultCollection> ResultsParameter { 58 64 get { return (IValueLookupParameter<ResultCollection>)Parameters["Results"]; } … … 67 73 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the SingleObjectiveTestFunction solutions which should be visualized.")); 68 74 Parameters.Add(new LookupParameter<SingleObjectiveTestFunctionSolution>("BestSolution", "The best SingleObjectiveTestFunction solution.")); 75 Parameters.Add(new LookupParameter<RealVector>("BestKnownSolution", "The best known solution.")); 76 Parameters.Add(new LookupParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution.")); 69 77 Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the SingleObjectiveTestFunction solution should be stored.")); 70 78 Parameters.Add(new ValueLookupParameter<ISingleObjectiveTestFunctionProblemEvaluator>("Evaluator", "The evaluator with which the solution is evaluated.")); … … 76 84 ResultCollection results = ResultsParameter.ActualValue; 77 85 ISingleObjectiveTestFunctionProblemEvaluator evaluator = EvaluatorParameter.ActualValue; 86 bool max = evaluator.Maximization; 78 87 79 88 int i = qualities.Select((x, index) => new { index, x.Value }).OrderBy(x => x.Value).First().index; … … 82 91 solution = new SingleObjectiveTestFunctionSolution(realVectors[i], qualities[i], evaluator); 83 92 solution.Population = realVectors; 93 double bestknownQuality = BestKnownQualityParameter.ActualValue.Value; 94 if (max && qualities[i].Value >= bestknownQuality 95 || !max && qualities[i].Value <= bestknownQuality) { 96 BestKnownSolutionParameter.ActualValue = (RealVector)realVectors[i].Clone(); 97 } 98 solution.BestKnownRealVector = BestKnownSolutionParameter.ActualValue; 84 99 BestSolutionParameter.ActualValue = solution; 85 86 100 results.Add(new Result("Best SingleObjectiveTestFunction Solution", solution)); 87 101 } else { 88 if (evaluator.Maximization && qualities[i].Value > solution.BestQuality.Value 89 || !evaluator.Maximization && qualities[i].Value < solution.BestQuality.Value) { 102 double bestknownQuality = BestKnownQualityParameter.ActualValue.Value; 103 if (max && qualities[i].Value >= bestknownQuality 104 || !max && qualities[i].Value <= bestknownQuality) { 105 BestKnownSolutionParameter.ActualValue = (RealVector)realVectors[i].Clone(); 106 } 107 if (max && qualities[i].Value > solution.BestQuality.Value 108 || !max && qualities[i].Value < solution.BestQuality.Value) { 90 109 solution.BestRealVector = realVectors[i]; 91 110 solution.BestQuality = qualities[i]; 92 111 } 93 112 solution.Population = realVectors; 94 95 113 //results["Best SingleObjectiveTestFunction Solution"].Value = solution; 96 114 } -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/AckleyEvaluator.cs
r3450 r3781 66 66 } 67 67 68 public override RealVector GetBestKnownSolution(int dimension) { 69 return new RealVector(dimension); 70 } 71 68 72 /// <summary> 69 73 /// Evaluates the Ackley function for a specific <paramref name="point"/>. -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/BealeEvaluator.cs
r3376 r3781 66 66 } 67 67 68 public override RealVector GetBestKnownSolution(int dimension) { 69 if (dimension != 2) throw new ArgumentException(Name + ": This function is only defined for 2 dimensions.", "dimension"); 70 return new RealVector(new double[] { 3, 0.5 }); 71 } 68 72 /// <summary> 69 73 /// Evaluates the test function for a specific <paramref name="point"/>. -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/BoothEvaluator.cs
r3376 r3781 65 65 } 66 66 67 public override RealVector GetBestKnownSolution(int dimension) { 68 if (dimension != 2) throw new ArgumentException(Name + ": This function is only defined for 2 dimensions.", "dimension"); 69 return new RealVector(new double[] { 1, 3 }); 70 } 67 71 /// <summary> 68 72 /// Evaluates the test function for a specific <paramref name="point"/>. -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/GriewankEvaluator.cs
r3376 r3781 67 67 } 68 68 69 public override RealVector GetBestKnownSolution(int dimension) { 70 return new RealVector(dimension); 71 } 69 72 /// <summary> 70 73 /// If dimension of the problem is less or equal than 100 the values of Math.Sqrt(i + 1) are precomputed. -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/LevyEvaluator.cs
r3376 r3781 65 65 } 66 66 67 public override RealVector GetBestKnownSolution(int dimension) { 68 if (dimension < 2) throw new ArgumentException(Name + ": This function is not defined for 1 dimension."); 69 RealVector result = new RealVector(dimension); 70 for (int i = 0; i < dimension; i++) result[i] = 1; 71 return result; 72 } 67 73 /// <summary> 68 74 /// Evaluates the test function for a specific <paramref name="point"/>. … … 80 86 81 87 s = Math.Sin(Math.PI * z[0]); 88 if (Math.Abs(s) < 1e-15) s = 0; // Math.Sin(Math.PI) == 0.00000000000000012246063538223773 82 89 s *= s; 83 90 -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/MatyasEvaluator.cs
r3376 r3781 65 65 } 66 66 67 public override RealVector GetBestKnownSolution(int dimension) { 68 if (dimension != 2) throw new ArgumentException(Name + ": This function is only defined for 2 dimensions.", "dimension"); 69 return new RealVector(dimension); 70 } 67 71 /// <summary> 68 72 /// Evaluates the test function for a specific <paramref name="point"/>. -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/RastriginEvaluator.cs
r3376 r3781 80 80 } 81 81 82 public override RealVector GetBestKnownSolution(int dimension) { 83 return new RealVector(dimension); 84 } 85 82 86 /// <summary> 83 87 /// Initializes a new instance of the RastriginEvaluator with one parameter (<c>A</c>). -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/RosenbrockEvaluator.cs
r3376 r3781 69 69 } 70 70 71 public override RealVector GetBestKnownSolution(int dimension) { 72 if (dimension < 2) throw new ArgumentException(Name + ": This function is not defined for 1 dimension."); 73 RealVector result = new RealVector(dimension); 74 for (int i = 0; i < dimension; i++) result[i] = 1; 75 return result; 76 } 77 71 78 /// <summary> 72 79 /// Evaluates the test function for a specific <paramref name="point"/>. -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/SchwefelEvaluator.cs
r3376 r3781 31 31 /// The Schwefel function (sine root) is implemented as described in Affenzeller, M. and Wagner, S. 2005. Offspring Selection: A New Self-Adaptive Selection Scheme for Genetic Algorithms. Ribeiro, B., Albrecht, R. F., Dobnikar, A., Pearson, D. W., and Steele, N. C. (eds.). Adaptive and Natural Computing Algorithms, pp. 218-221, Springer. 32 32 /// </summary> 33 [Item("SchwefelEvaluator", "Evaluates the Schwefel function (sine root) on a given point. The optimum of this function is0 at (420.968746453712,420.968746453712,...,420.968746453712). It is implemented as described in Affenzeller, M. and Wagner, S. 2005. Offspring Selection: A New Self-Adaptive Selection Scheme for Genetic Algorithms. Ribeiro, B., Albrecht, R. F., Dobnikar, A., Pearson, D. W., and Steele, N. C. (eds.). Adaptive and Natural Computing Algorithms, pp. 218-221, Springer.")]33 [Item("SchwefelEvaluator", "Evaluates the Schwefel function (sine root) on a given point. In the given bounds [-500;500] the optimum of this function is close to 0 at (420.968746453712,420.968746453712,...,420.968746453712). It is implemented as described in Affenzeller, M. and Wagner, S. 2005. Offspring Selection: A New Self-Adaptive Selection Scheme for Genetic Algorithms. Ribeiro, B., Albrecht, R. F., Dobnikar, A., Pearson, D. W., and Steele, N. C. (eds.). Adaptive and Natural Computing Algorithms, pp. 218-221, Springer.")] 34 34 [StorableClass] 35 35 public class SchwefelEvaluator : SingleObjectiveTestFunctionProblemEvaluator { … … 65 65 } 66 66 67 public override RealVector GetBestKnownSolution(int dimension) { 68 return null; 69 } 70 67 71 /// <summary> 68 72 /// Evaluates the test function for a specific <paramref name="point"/>. -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/SingleObjectiveTestFunctionProblemEvaluator.cs
r3665 r3781 87 87 return EvaluateFunction(new RealVector(new double[] { x, y })); 88 88 } 89 /// <summary> 90 /// Gets the best known solution for this function. 91 /// </summary> 92 public abstract RealVector GetBestKnownSolution(int dimension); 89 93 90 94 /// <summary> -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/SphereEvaluator.cs
r3376 r3781 66 66 get { return int.MaxValue; } 67 67 } 68 69 public override RealVector GetBestKnownSolution(int dimension) { 70 return new RealVector(dimension); 71 } 72 68 73 /// <summary> 69 74 /// The parameter C modifies the steepness of the objective function y = C * ||X||^Alpha. Default is C = 1. -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/SumSquaresEvaluator.cs
r3376 r3781 65 65 } 66 66 67 public override RealVector GetBestKnownSolution(int dimension) { 68 return new RealVector(dimension); 69 } 70 67 71 /// <summary> 68 72 /// Evaluates the test function for a specific <paramref name="point"/>. -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/ZakharovEvaluator.cs
r3376 r3781 65 65 } 66 66 67 public override RealVector GetBestKnownSolution(int dimension) { 68 return new RealVector(dimension); 69 } 70 67 71 /// <summary> 68 72 /// Evaluates the test function for a specific <paramref name="point"/>. -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Interfaces/ISingleObjectiveTestFunctionProblemEvaluator.cs
r3665 r3781 40 40 41 41 double Evaluate2D(double x, double y); 42 RealVector GetBestKnownSolution(int dimension); 42 43 } 43 44 } -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/SingleObjectiveTestFunctionProblem.cs
r3751 r3781 83 83 get { return BestKnownQualityParameter; } 84 84 } 85 public OptionalValueParameter<RealVector> BestKnownSolutionParameter { 86 get { return (OptionalValueParameter<RealVector>)Parameters["BestKnownSolution"]; } 87 } 85 88 #endregion 86 89 … … 141 144 Parameters.Add(new ValueParameter<ISingleObjectiveTestFunctionProblemEvaluator>("Evaluator", "The operator which should be used to evaluate test function solutions.", evaluator)); 142 145 Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this test function.", new DoubleValue(evaluator.BestKnownQuality))); 146 Parameters.Add(new OptionalValueParameter<RealVector>("BestKnownSolution", "The best known solution for this test function instance.")); 143 147 144 148 strategyVectorCreator = new StdDevStrategyVectorCreator(); … … 194 198 if (ProblemSize.Value < 1) ProblemSize.Value = 1; 195 199 ParameterizeSolutionCreator(); 200 ParameterizeEvaluator(); 196 201 strategyVectorManipulator.GeneralLearningRateParameter.Value = new DoubleValue(1.0 / Math.Sqrt(2 * ProblemSize.Value)); 197 202 strategyVectorManipulator.LearningRateParameter.Value = new DoubleValue(1.0 / Math.Sqrt(2 * Math.Sqrt(ProblemSize.Value))); 203 OnReset(); 198 204 } 199 205 private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) { … … 219 225 BestKnownQuality = new DoubleValue(Evaluator.BestKnownQuality); 220 226 Evaluator_QualityParameter_ActualNameChanged(null, EventArgs.Empty); 227 OnReset(); 221 228 } 222 229 private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) { … … 230 237 if (Bounds.Columns != 2 || Bounds.Rows < 1) 231 238 Bounds = new DoubleMatrix(1, 2); 232 ParameterizeOperators(); 239 ParameterizeOperators(); 240 UpdateStrategyVectorBounds(); 233 241 } 234 242 private void Bounds_ItemChanged(object sender, EventArgs<int, int> e) { … … 237 245 if (e.Value2 == 1 && Bounds[e.Value, 0] >= Bounds[e.Value, 1]) 238 246 Bounds[e.Value, 0] = Bounds[e.Value, 1] - 0.1; 239 ParameterizeOperators(); 247 ParameterizeOperators(); 248 UpdateStrategyVectorBounds(); 240 249 } 241 250 private void MoveGenerator_AdditiveMoveParameter_ActualNameChanged(object sender, EventArgs e) { … … 263 272 } 264 273 private void strategyVectorCreator_BoundsParameter_ValueChanged(object sender, EventArgs e) { 265 strategyVectorManipulator.BoundsParameter.Value = strategyVectorCreator.BoundsParameter.Value;274 strategyVectorManipulator.BoundsParameter.Value = (DoubleMatrix)strategyVectorCreator.BoundsParameter.Value.Clone(); 266 275 } 267 276 private void strategyVectorCreator_StrategyParameterParameter_ActualNameChanged(object sender, EventArgs e) { … … 344 353 private void ParameterizeEvaluator() { 345 354 Evaluator.PointParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName; 355 BestKnownSolutionParameter.Value = Evaluator.GetBestKnownSolution(ProblemSize.Value); 346 356 } 347 357 private void ParameterizeOperators() { … … 371 381 } 372 382 } 383 private void UpdateStrategyVectorBounds() { 384 DoubleMatrix strategyBounds = (DoubleMatrix)Bounds.Clone(); 385 for (int i = 0; i < strategyBounds.Rows; i++) 386 if (strategyBounds[i, 0] < 0) strategyBounds[i, 0] = 0; 387 strategyVectorCreator.BoundsParameter.Value = strategyBounds; 388 } 373 389 #endregion 374 390 }
Note: See TracChangeset
for help on using the changeset viewer.