- Timestamp:
- 07/24/12 15:04:37 (12 years ago)
- Location:
- branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.TestFunctions/3.3
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.TestFunctions/3.3/Improvers/SingleObjectiveTestFunctionImprovementOperator.cs
r8086 r8319 35 35 /// An operator that improves test functions solutions. 36 36 /// </summary> 37 /// <remarks> 38 /// It is implemented as described in Gao, F. and Han, L. (2010). Implementing the Nelder-Mead simplex algorithm with adaptive parameters. Computational Optimization and Applications, Vol. 51. Springer.<br /> 39 /// The operator is an implementation of the Nelder-Mead method and conducts relection, expansion, contraction and reduction on the test functions solution. 40 /// </remarks> 37 41 [Item("SingleObjectiveTestFunctionImprovementOperator", "An operator that improves test functions solutions.")] 38 42 [StorableClass] 39 public sealed class SingleObjectiveTestFunctionImprovementOperator : SingleSuccessorOperator, I ImprovementOperator {43 public sealed class SingleObjectiveTestFunctionImprovementOperator : SingleSuccessorOperator, ISingleObjectiveImprovementOperator { 40 44 #region Parameter properties 41 45 public IValueParameter<DoubleValue> AlphaParameter { … … 63 67 get { return (IValueLookupParameter<IntValue>)Parameters["ImprovementAttempts"]; } 64 68 } 65 public IValueLookupParameter<IItem> TargetParameter {66 get { return (IValueLookupParameter<IItem>)Parameters[" Target"]; }69 public IValueLookupParameter<IItem> SolutionParameter { 70 get { return (IValueLookupParameter<IItem>)Parameters["Solution"]; } 67 71 } 68 72 #endregion … … 109 113 Parameters.Add(new ValueParameter<DoubleValue>("Gamma", new DoubleValue(0.5))); 110 114 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."));115 Parameters.Add(new ValueLookupParameter<IItem>("Solution", "The solution to be improved. This parameter is used for name translation only.")); 112 116 #endregion 113 117 } … … 118 122 119 123 public override IOperation Apply() { 120 RealVector bestSol = CurrentScope.Variables[ TargetParameter.ActualName].Value as RealVector;124 RealVector bestSol = CurrentScope.Variables[SolutionParameter.ActualName].Value as RealVector; 121 125 if (bestSol == null) 122 126 throw new ArgumentException("Cannot improve solution because it has the wrong type."); … … 196 200 } 197 201 198 CurrentScope.Variables[ TargetParameter.ActualName].Value = simplex[0];202 CurrentScope.Variables[SolutionParameter.ActualName].Value = simplex[0]; 199 203 CurrentScope.Variables.Add(new Variable("LocalEvaluatedSolutions", ImprovementAttempts)); 200 204 -
branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.TestFunctions/3.3/PathRelinkers/SingleObjectiveTestFunctionPathRelinker.cs
r8086 r8319 35 35 /// An operator that relinks paths between test functions solutions. 36 36 /// </summary> 37 /// <remarks> 38 /// TODO: add reference and remarks 39 /// </remarks> 37 40 [Item("SingleObjectiveTestFunctionPathRelinker", "An operator that relinks paths between test functions solutions.")] 38 41 [StorableClass] 39 public sealed class SingleObjectiveTestFunctionPathRelinker : PathRelinker {42 public sealed class SingleObjectiveTestFunctionPathRelinker : SingleObjectivePathRelinker { 40 43 #region Parameter properties 41 44 public IValueParameter<IntValue> RelinkingIntensityParameter { -
branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.TestFunctions/3.3/SimilarityCalculators/SingleObjectiveTestFunctionSimilarityCalculator.cs
r8304 r8319 32 32 /// An operator that performs similarity calculation between two test functions solutions. 33 33 /// </summary> 34 /// <remarks> 35 /// The operator calculates the similarity based on the euclidean distance of the two solutions in n-dimensional space. 36 /// </remarks> 34 37 [Item("SingleObjectiveTestFunctionSimilarityCalculator", "An operator that performs similarity calculation between two test functions solutions.")] 35 38 [StorableClass] 36 public sealed class SingleObjectiveTestFunctionSimilarityCalculator : Si milarityCalculator {39 public sealed class SingleObjectiveTestFunctionSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator { 37 40 #region Properties 38 41 [Storable] … … 57 60 if (bounds == null) 58 61 throw new ArgumentException("Cannot calculate similarity because no bounds were provided."); 62 if (left.Length != right.Length) 63 throw new ArgumentException("Cannot calculate similarity because the provided solutions have different lengths."); 59 64 if (left == right) return 1.0; 60 65 … … 72 77 } 73 78 74 public override double Calculate IndividualSimilarity(IScope left, IScope right) {75 var sol1 = left .Variables[Target].Value as RealVector;76 var sol2 = right .Variables[Target].Value as RealVector;79 public override double CalculateSolutionSimilarity(IScope leftSolution, IScope rightSolution) { 80 var sol1 = leftSolution.Variables[SolutionVariableName].Value as RealVector; 81 var sol2 = rightSolution.Variables[SolutionVariableName].Value as RealVector; 77 82 78 83 return CalculateSimilarity(sol1, sol2, Bounds); -
branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.TestFunctions/3.3/SingleObjectiveTestFunctionProblem.cs
r8086 r8319 363 363 op.MaximizationParameter.Hidden = true; 364 364 } 365 foreach ( var op in Operators.OfType<IRealVectorMultiNeighborhoodShakingOperator>()) {366 op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName; 367 op.RealVectorParameter.Hidden = true; 368 } 369 foreach (I ImprovementOperator op in Operators.OfType<IImprovementOperator>()) {370 op. TargetParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;371 op. TargetParameter.Hidden = true;372 } 373 foreach (I PathRelinker op in Operators.OfType<IPathRelinker>()) {365 foreach (IRealVectorMultiNeighborhoodShakingOperator op in Operators.OfType<IRealVectorMultiNeighborhoodShakingOperator>()) { 366 op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName; 367 op.RealVectorParameter.Hidden = true; 368 } 369 foreach (ISingleObjectiveImprovementOperator op in Operators.OfType<ISingleObjectiveImprovementOperator>()) { 370 op.SolutionParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName; 371 op.SolutionParameter.Hidden = true; 372 } 373 foreach (ISingleObjectivePathRelinker op in Operators.OfType<ISingleObjectivePathRelinker>()) { 374 374 op.ParentsParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName; 375 375 op.ParentsParameter.Hidden = true; 376 376 } 377 foreach (SingleObjectiveTestFunctionSimilarityCalculator op in Operators.OfType< ISimilarityCalculator>()) {378 op. Target= SolutionCreator.RealVectorParameter.ActualName;377 foreach (SingleObjectiveTestFunctionSimilarityCalculator op in Operators.OfType<SingleObjectiveTestFunctionSimilarityCalculator>()) { 378 op.SolutionVariableName = SolutionCreator.RealVectorParameter.ActualName; 379 379 op.Bounds = Bounds; 380 380 }
Note: See TracChangeset
for help on using the changeset viewer.