- Timestamp:
- 06/22/12 11:11:38 (13 years ago)
- Location:
- branches/ScatterSearch (trunk integration)
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ScatterSearch (trunk integration)
- Property svn:ignore
-
old new 20 20 bin 21 21 protoc.exe 22 _ReSharper.HeuristicLab 3.3 Tests
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.TestFunctions/3.3/Improvers/SingleObjectiveTestFunctionImprovementOperator.cs
r7954 r8086 27 27 using HeuristicLab.Encodings.RealVectorEncoding; 28 28 using HeuristicLab.Operators; 29 using HeuristicLab.Optimization .Operators;29 using HeuristicLab.Optimization; 30 30 using HeuristicLab.Parameters; 31 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 63 63 get { return (IValueLookupParameter<IntValue>)Parameters["ImprovementAttempts"]; } 64 64 } 65 public IValueLookupParameter<IRandom> RandomParameter {66 get { return (IValueLookupParameter<IRandom>)Parameters["Random"]; }67 }68 65 public IValueLookupParameter<IItem> TargetParameter { 69 66 get { return (IValueLookupParameter<IItem>)Parameters["Target"]; } … … 89 86 public ISingleObjectiveTestFunctionProblemEvaluator Evaluator { 90 87 get { return EvaluatorParameter.ActualValue; } 91 set { EvaluatorParameter.ActualValue = value; }92 88 } 93 89 private DoubleValue Gamma { … … 96 92 public IntValue ImprovementAttempts { 97 93 get { return ImprovementAttemptsParameter.ActualValue; } 98 set { ImprovementAttemptsParameter.ActualValue = value; }99 }100 public IRandom Random {101 get { return RandomParameter.ActualValue; }102 set { RandomParameter.ActualValue = value; }103 }104 private IItem Target {105 get { return TargetParameter.ActualValue; }106 94 } 107 95 #endregion … … 115 103 Parameters.Add(new ValueParameter<DoubleValue>("Alpha", new DoubleValue(1.0))); 116 104 Parameters.Add(new ValueParameter<DoubleValue>("Beta", new DoubleValue(2.0))); 117 Parameters.Add(new ValueLookupParameter<DoubleMatrix>("Bounds" ));118 Parameters.Add(new ScopeParameter("CurrentScope" ));105 Parameters.Add(new ValueLookupParameter<DoubleMatrix>("Bounds", "The lower and upper bounds in each dimension.")); 106 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope that contains the solution to be improved.")); 119 107 Parameters.Add(new ValueParameter<DoubleValue>("Delta", new DoubleValue(0.5))); 120 Parameters.Add(new ValueLookupParameter<ISingleObjectiveTestFunctionProblemEvaluator>("Evaluator" ));108 Parameters.Add(new ValueLookupParameter<ISingleObjectiveTestFunctionProblemEvaluator>("Evaluator", "The operator used to evaluate solutions.")); 121 109 Parameters.Add(new ValueParameter<DoubleValue>("Gamma", new DoubleValue(0.5))); 122 Parameters.Add(new ValueLookupParameter<IntValue>("ImprovementAttempts", new IntValue(100))); 123 Parameters.Add(new ValueLookupParameter<IItem>("Target")); 124 Parameters.Add(new ValueLookupParameter<IRandom>("Random")); 110 Parameters.Add(new ValueLookupParameter<IntValue>("ImprovementAttempts", "The number of improvement attempts the operator should perform.", new IntValue(100))); 111 Parameters.Add(new ValueLookupParameter<IItem>("Target", "This parameter is used for name translation only.")); 125 112 #endregion 126 113 } … … 132 119 public override IOperation Apply() { 133 120 RealVector bestSol = CurrentScope.Variables[TargetParameter.ActualName].Value as RealVector; 121 if (bestSol == null) 122 throw new ArgumentException("Cannot improve solution because it has the wrong type."); 123 134 124 MethodInfo evaluationMethod = Evaluator.GetType().GetMethod("Apply", 135 125 BindingFlags.Public | BindingFlags.Static, … … 207 197 208 198 CurrentScope.Variables[TargetParameter.ActualName].Value = simplex[0]; 199 CurrentScope.Variables.Add(new Variable("LocalEvaluatedSolutions", ImprovementAttempts)); 209 200 210 201 return base.Apply(); -
branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.TestFunctions/3.3/PathRelinkers/SingleObjectiveTestFunctionPathRelinker.cs
r7789 r8086 47 47 private IntValue RelinkingIntensity { 48 48 get { return RelinkingIntensityParameter.Value; } 49 set { RelinkingIntensityParameter.Value = value; }50 49 } 51 50 #endregion … … 57 56 : base() { 58 57 #region Create parameters 59 Parameters.Add(new ValueParameter<IntValue>("RelinkingIntensity", new IntValue(10)));58 Parameters.Add(new ValueParameter<IntValue>("RelinkingIntensity", "Determines how strong path relinking should be applied.", new IntValue(10))); 60 59 #endregion 61 60 } -
branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.TestFunctions/3.3/Plugin.cs.frame
r7259 r8086 36 36 [PluginDependency("HeuristicLab.Operators", "3.3")] 37 37 [PluginDependency("HeuristicLab.Optimization", "3.3")] 38 [PluginDependency("HeuristicLab.Optimization.Operators", "3.3")] 38 39 [PluginDependency("HeuristicLab.Parameters", "3.3")] 39 40 [PluginDependency("HeuristicLab.Persistence", "3.3")] -
branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.TestFunctions/3.3/SimilarityCalculators/SingleObjectiveTestFunctionSimilarityCalculator.cs
r7954 r8086 26 26 using HeuristicLab.Encodings.RealVectorEncoding; 27 27 using HeuristicLab.Optimization.Operators; 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;29 28 30 29 namespace HeuristicLab.Problems.TestFunctions { … … 33 32 /// </summary> 34 33 [Item("SingleObjectiveTestFunctionSimilarityCalculator", "An operator that performs similarity calculation between two test functions solutions.")] 35 [StorableClass]36 34 public sealed class SingleObjectiveTestFunctionSimilarityCalculator : SimilarityCalculator { 37 35 #region Properties … … 39 37 #endregion 40 38 41 [StorableConstructor]42 39 private SingleObjectiveTestFunctionSimilarityCalculator(bool deserializing) : base(deserializing) { } 43 40 private SingleObjectiveTestFunctionSimilarityCalculator(SingleObjectiveTestFunctionSimilarityCalculator original, Cloner cloner) : base(original, cloner) { } 44 41 public SingleObjectiveTestFunctionSimilarityCalculator() : base() { } 45 42 46 public override IDeepCloneable Clone(Cloner cloner) { 47 return new SingleObjectiveTestFunctionSimilarityCalculator(this, cloner); 43 public static double CalculateSimilarity(RealVector left, RealVector right, DoubleMatrix bounds) { 44 if (left == null || right == null) 45 throw new ArgumentException("Cannot calculate similarity because one of the provided solutions or both are null."); 46 if (bounds == null) 47 throw new ArgumentException("Cannot calculate similarity because no bounds were provided."); 48 49 double maxSum = 0.0; 50 for (int i = 0; i < left.Length; i++) 51 maxSum += Math.Pow(bounds[0, 0] - bounds[0, 1], 2); 52 double maxDistance = Math.Sqrt(maxSum) / left.Length; 53 54 double sum = 0.0; 55 for (int i = 0; i < left.Length; i++) 56 sum += Math.Pow(left[i] - right[i], 2); 57 double distance = Math.Sqrt(sum) / left.Length; 58 59 return 1.0 - distance / maxDistance; 48 60 } 49 61 50 62 protected override double CalculateSimilarity(IScope left, IScope right) { 51 RealVector sol1 = left.Variables[ "Point"].Value as RealVector;52 RealVector sol2 = right.Variables[ "Point"].Value as RealVector;63 RealVector sol1 = left.Variables[Target].Value as RealVector; 64 RealVector sol2 = right.Variables[Target].Value as RealVector; 53 65 54 double maxSum = 0.0; 55 for (int i = 0; i < sol1.Length; i++) 56 maxSum += Math.Pow(Bounds[0, 0] - Bounds[0, 1], 2); 57 double maxDistance = Math.Sqrt(maxSum) / sol1.Length; 58 59 double sum = 0.0; 60 for (int i = 0; i < sol1.Length; i++) 61 sum += Math.Pow(sol1[i] - sol2[i], 2); 62 double distance = Math.Sqrt(sum) / sol1.Length; 63 64 return 1.0 - distance / maxDistance; 66 return CalculateSimilarity(sol1, sol2, Bounds); 65 67 } 66 68 } -
branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.TestFunctions/3.3/SingleObjectiveTestFunctionProblem.cs
r7954 r8086 28 28 using HeuristicLab.Encodings.RealVectorEncoding; 29 29 using HeuristicLab.Optimization; 30 using HeuristicLab.Optimization.Operators;31 30 using HeuristicLab.Parameters; 32 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 377 376 } 378 377 foreach (SingleObjectiveTestFunctionSimilarityCalculator op in Operators.OfType<ISimilarityCalculator>()) { 379 op.TargetParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName; 380 op.TargetParameter.Hidden = true; 378 op.Target = SolutionCreator.RealVectorParameter.ActualName; 381 379 op.Bounds = Bounds; 382 380 }
Note: See TracChangeset
for help on using the changeset viewer.