Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/24/12 15:04:37 (12 years ago)
Author:
jkarder
Message:

#1331:

  • applied some of the changes suggested by ascheibe in comment:32:ticket:1331
  • restructured path relinking and improvement operators and similarity calculators
  • fixed bug in TSPMultipleGuidesPathRelinker
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  
    3535  /// An operator that improves test functions solutions.
    3636  /// </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>
    3741  [Item("SingleObjectiveTestFunctionImprovementOperator", "An operator that improves test functions solutions.")]
    3842  [StorableClass]
    39   public sealed class SingleObjectiveTestFunctionImprovementOperator : SingleSuccessorOperator, IImprovementOperator {
     43  public sealed class SingleObjectiveTestFunctionImprovementOperator : SingleSuccessorOperator, ISingleObjectiveImprovementOperator {
    4044    #region Parameter properties
    4145    public IValueParameter<DoubleValue> AlphaParameter {
     
    6367      get { return (IValueLookupParameter<IntValue>)Parameters["ImprovementAttempts"]; }
    6468    }
    65     public IValueLookupParameter<IItem> TargetParameter {
    66       get { return (IValueLookupParameter<IItem>)Parameters["Target"]; }
     69    public IValueLookupParameter<IItem> SolutionParameter {
     70      get { return (IValueLookupParameter<IItem>)Parameters["Solution"]; }
    6771    }
    6872    #endregion
     
    109113      Parameters.Add(new ValueParameter<DoubleValue>("Gamma", new DoubleValue(0.5)));
    110114      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."));
    112116      #endregion
    113117    }
     
    118122
    119123    public override IOperation Apply() {
    120       RealVector bestSol = CurrentScope.Variables[TargetParameter.ActualName].Value as RealVector;
     124      RealVector bestSol = CurrentScope.Variables[SolutionParameter.ActualName].Value as RealVector;
    121125      if (bestSol == null)
    122126        throw new ArgumentException("Cannot improve solution because it has the wrong type.");
     
    196200      }
    197201
    198       CurrentScope.Variables[TargetParameter.ActualName].Value = simplex[0];
     202      CurrentScope.Variables[SolutionParameter.ActualName].Value = simplex[0];
    199203      CurrentScope.Variables.Add(new Variable("LocalEvaluatedSolutions", ImprovementAttempts));
    200204
  • branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.TestFunctions/3.3/PathRelinkers/SingleObjectiveTestFunctionPathRelinker.cs

    r8086 r8319  
    3535  /// An operator that relinks paths between test functions solutions.
    3636  /// </summary>
     37  /// <remarks>
     38  /// TODO: add reference and remarks
     39  /// </remarks>
    3740  [Item("SingleObjectiveTestFunctionPathRelinker", "An operator that relinks paths between test functions solutions.")]
    3841  [StorableClass]
    39   public sealed class SingleObjectiveTestFunctionPathRelinker : PathRelinker {
     42  public sealed class SingleObjectiveTestFunctionPathRelinker : SingleObjectivePathRelinker {
    4043    #region Parameter properties
    4144    public IValueParameter<IntValue> RelinkingIntensityParameter {
  • branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.TestFunctions/3.3/SimilarityCalculators/SingleObjectiveTestFunctionSimilarityCalculator.cs

    r8304 r8319  
    3232  /// An operator that performs similarity calculation between two test functions solutions.
    3333  /// </summary>
     34  /// <remarks>
     35  /// The operator calculates the similarity based on the euclidean distance of the two solutions in n-dimensional space.
     36  /// </remarks>
    3437  [Item("SingleObjectiveTestFunctionSimilarityCalculator", "An operator that performs similarity calculation between two test functions solutions.")]
    3538  [StorableClass]
    36   public sealed class SingleObjectiveTestFunctionSimilarityCalculator : SimilarityCalculator {
     39  public sealed class SingleObjectiveTestFunctionSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator {
    3740    #region Properties
    3841    [Storable]
     
    5760      if (bounds == null)
    5861        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.");
    5964      if (left == right) return 1.0;
    6065
     
    7277    }
    7378
    74     public override double CalculateIndividualSimilarity(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;
    7782
    7883      return CalculateSimilarity(sol1, sol2, Bounds);
  • branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.TestFunctions/3.3/SingleObjectiveTestFunctionProblem.cs

    r8086 r8319  
    363363        op.MaximizationParameter.Hidden = true;
    364364      }
    365       foreach (var op in Operators.OfType<IRealVectorMultiNeighborhoodShakingOperator>()) {
    366         op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
    367         op.RealVectorParameter.Hidden = true;
    368       }
    369       foreach (IImprovementOperator op in Operators.OfType<IImprovementOperator>()) {
    370         op.TargetParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
    371         op.TargetParameter.Hidden = true;
    372       }
    373       foreach (IPathRelinker 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>()) {
    374374        op.ParentsParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
    375375        op.ParentsParameter.Hidden = true;
    376376      }
    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;
    379379        op.Bounds = Bounds;
    380380      }
Note: See TracChangeset for help on using the changeset viewer.