Changeset 8720


Ignore:
Timestamp:
10/02/12 18:59:15 (7 years ago)
Author:
jkarder
Message:

#1899: applied the changes suggested by ascheibe in comment:6:ticket:1899

Location:
trunk/sources
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Analysis/3.3/PopulationDiversityAnalysis/PopulationDiversityAnalyzer.cs

    r7259 r8720  
    3131
    3232namespace HeuristicLab.Analysis {
     33  // use HeuristicLab.Analysis.SingleObjectivePopulationDiversityAnalyzer instead
     34  // BackwardsCompatibility3.3
     35  #region Backwards compatible code, remove with 3.4
    3336  /// <summary>
    3437  /// An operator for analyzing the solution diversity in a population.
    3538  /// </summary>
     39  [Obsolete]
    3640  [Item("PopulationDiversityAnalyzer", "An operator for analyzing the solution diversity in a population.")]
    3741  [StorableClass]
     
    245249    protected abstract double[,] CalculateSimilarities(T[] solutions);
    246250  }
     251  #endregion
    247252}
  • trunk/sources/HeuristicLab.Problems.Knapsack/3.3/HeuristicLab.Problems.Knapsack-3.3.csproj

    r8600 r8720  
    129129  </ItemGroup>
    130130  <ItemGroup>
     131    <ProjectReference Include="..\..\HeuristicLab.Analysis\3.3\HeuristicLab.Analysis-3.3.csproj">
     132      <Project>{887425B4-4348-49ED-A457-B7D2C26DDBF9}</Project>
     133      <Name>HeuristicLab.Analysis-3.3</Name>
     134    </ProjectReference>
    131135    <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj">
    132136      <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project>
     
    216220  -->
    217221  <PropertyGroup>
    218    <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
     222    <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
    219223set ProjectDir=$(ProjectDir)
    220224set SolutionDir=$(SolutionDir)
     
    223227call PreBuildEvent.cmd
    224228</PreBuildEvent>
    225 <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
     229    <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
    226230export ProjectDir=$(ProjectDir)
    227231export SolutionDir=$(SolutionDir)
  • trunk/sources/HeuristicLab.Problems.Knapsack/3.3/KnapsackProblem.cs

    r8334 r8720  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HeuristicLab.Analysis;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     
    8081    private BestKnapsackSolutionAnalyzer BestKnapsackSolutionAnalyzer {
    8182      get { return Operators.OfType<BestKnapsackSolutionAnalyzer>().FirstOrDefault(); }
     83    }
     84    private SingleObjectivePopulationDiversityAnalyzer SingleObjectivePopulationDiversityAnalyzer {
     85      get { return Operators.OfType<SingleObjectivePopulationDiversityAnalyzer>().FirstOrDefault(); }
    8286    }
    8387    #endregion
     
    228232    }
    229233    private void ParameterizeAnalyzer() {
    230       BestKnapsackSolutionAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name;
    231       BestKnapsackSolutionAnalyzer.MaximizationParameter.Hidden = true;
    232       BestKnapsackSolutionAnalyzer.BestKnownQualityParameter.ActualName = BestKnownQualityParameter.Name;
    233       BestKnapsackSolutionAnalyzer.BestKnownQualityParameter.Hidden = true;
    234       BestKnapsackSolutionAnalyzer.BestKnownSolutionParameter.ActualName = BestKnownSolutionParameter.Name;
    235       BestKnapsackSolutionAnalyzer.BestKnownSolutionParameter.Hidden = true;
    236       BestKnapsackSolutionAnalyzer.BinaryVectorParameter.ActualName = SolutionCreator.BinaryVectorParameter.ActualName;
    237       BestKnapsackSolutionAnalyzer.BinaryVectorParameter.Hidden = true;
    238       BestKnapsackSolutionAnalyzer.KnapsackCapacityParameter.ActualName = KnapsackCapacityParameter.Name;
    239       BestKnapsackSolutionAnalyzer.KnapsackCapacityParameter.Hidden = true;
    240       BestKnapsackSolutionAnalyzer.WeightsParameter.ActualName = WeightsParameter.Name;
    241       BestKnapsackSolutionAnalyzer.WeightsParameter.Hidden = true;
    242       BestKnapsackSolutionAnalyzer.ValuesParameter.ActualName = ValuesParameter.Name;
    243       BestKnapsackSolutionAnalyzer.ValuesParameter.Hidden = true;
     234      if (BestKnapsackSolutionAnalyzer != null) {
     235        BestKnapsackSolutionAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name;
     236        BestKnapsackSolutionAnalyzer.MaximizationParameter.Hidden = true;
     237        BestKnapsackSolutionAnalyzer.BestKnownQualityParameter.ActualName = BestKnownQualityParameter.Name;
     238        BestKnapsackSolutionAnalyzer.BestKnownQualityParameter.Hidden = true;
     239        BestKnapsackSolutionAnalyzer.BestKnownSolutionParameter.ActualName = BestKnownSolutionParameter.Name;
     240        BestKnapsackSolutionAnalyzer.BestKnownSolutionParameter.Hidden = true;
     241        BestKnapsackSolutionAnalyzer.BinaryVectorParameter.ActualName = SolutionCreator.BinaryVectorParameter.ActualName;
     242        BestKnapsackSolutionAnalyzer.BinaryVectorParameter.Hidden = true;
     243        BestKnapsackSolutionAnalyzer.KnapsackCapacityParameter.ActualName = KnapsackCapacityParameter.Name;
     244        BestKnapsackSolutionAnalyzer.KnapsackCapacityParameter.Hidden = true;
     245        BestKnapsackSolutionAnalyzer.WeightsParameter.ActualName = WeightsParameter.Name;
     246        BestKnapsackSolutionAnalyzer.WeightsParameter.Hidden = true;
     247        BestKnapsackSolutionAnalyzer.ValuesParameter.ActualName = ValuesParameter.Name;
     248        BestKnapsackSolutionAnalyzer.ValuesParameter.Hidden = true;
     249      }
     250
     251      if (SingleObjectivePopulationDiversityAnalyzer != null) {
     252        SingleObjectivePopulationDiversityAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name;
     253        SingleObjectivePopulationDiversityAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
     254        SingleObjectivePopulationDiversityAnalyzer.ResultsParameter.ActualName = "Results";
     255        SingleObjectivePopulationDiversityAnalyzer.SimilarityCalculator = Operators.OfType<KnapsackSimilarityCalculator>().SingleOrDefault();
     256      }
    244257    }
    245258    private void InitializeOperators() {
     
    250263
    251264      Operators.Add(new BestKnapsackSolutionAnalyzer());
     265      Operators.Add(new SingleObjectivePopulationDiversityAnalyzer());
    252266      ParameterizeAnalyzer();
    253267      foreach (IBinaryVectorOperator op in ApplicationManager.Manager.GetInstances<IBinaryVectorOperator>()) {
  • trunk/sources/HeuristicLab.Problems.Knapsack/3.3/Plugin.cs.frame

    r8334 r8720  
    2828  [Plugin("HeuristicLab.Problems.Knapsack", "3.3.7.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Problems.Knapsack-3.3.dll", PluginFileType.Assembly)]
     30  [PluginDependency("HeuristicLab.Analysis", "3.3")]
    3031  [PluginDependency("HeuristicLab.Collections", "3.3")]
    3132  [PluginDependency("HeuristicLab.Common", "3.3")]
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/HeuristicLab.Problems.TestFunctions-3.3.csproj

    r8600 r8720  
    162162  </ItemGroup>
    163163  <ItemGroup>
     164    <ProjectReference Include="..\..\HeuristicLab.Analysis\3.3\HeuristicLab.Analysis-3.3.csproj">
     165      <Project>{887425B4-4348-49ED-A457-B7D2C26DDBF9}</Project>
     166      <Name>HeuristicLab.Analysis-3.3</Name>
     167    </ProjectReference>
    164168    <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj">
    165169      <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project>
     
    249253  -->
    250254  <PropertyGroup>
    251    <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
     255    <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
    252256set ProjectDir=$(ProjectDir)
    253257set SolutionDir=$(SolutionDir)
     
    256260call PreBuildEvent.cmd
    257261</PreBuildEvent>
    258 <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
     262    <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
    259263export ProjectDir=$(ProjectDir)
    260264export SolutionDir=$(SolutionDir)
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Plugin.cs.frame

    r8334 r8720  
    2828  [Plugin("HeuristicLab.Problems.TestFunctions", "3.3.7.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Problems.TestFunctions-3.3.dll", PluginFileType.Assembly)]
     30  [PluginDependency("HeuristicLab.Analysis", "3.3")]
    3031  [PluginDependency("HeuristicLab.Collections", "3.3")]
    3132  [PluginDependency("HeuristicLab.Common", "3.3")]
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/SingleObjectiveTestFunctionProblem.cs

    r8493 r8720  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HeuristicLab.Analysis;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     
    6970    private BestSingleObjectiveTestFunctionSolutionAnalyzer BestSingleObjectiveTestFunctionSolutionAnalyzer {
    7071      get { return Operators.OfType<BestSingleObjectiveTestFunctionSolutionAnalyzer>().FirstOrDefault(); }
     72    }
     73    private SingleObjectivePopulationDiversityAnalyzer SingleObjectivePopulationDiversityAnalyzer {
     74      get { return Operators.OfType<SingleObjectivePopulationDiversityAnalyzer>().FirstOrDefault(); }
    7175    }
    7276    #endregion
     
    249253    }
    250254    private void ParameterizeAnalyzers() {
    251       BestSingleObjectiveTestFunctionSolutionAnalyzer.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
    252       BestSingleObjectiveTestFunctionSolutionAnalyzer.ResultsParameter.ActualName = "Results";
    253       BestSingleObjectiveTestFunctionSolutionAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
    254       BestSingleObjectiveTestFunctionSolutionAnalyzer.BestKnownQualityParameter.ActualName = BestKnownQualityParameter.Name;
    255       BestSingleObjectiveTestFunctionSolutionAnalyzer.BestKnownSolutionParameter.ActualName = BestKnownSolutionParameter.Name;
    256       BestSingleObjectiveTestFunctionSolutionAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name;
    257       BestSingleObjectiveTestFunctionSolutionAnalyzer.EvaluatorParameter.ActualName = EvaluatorParameter.Name;
    258       BestSingleObjectiveTestFunctionSolutionAnalyzer.BoundsParameter.ActualName = BoundsParameter.Name;
     255      if (BestSingleObjectiveTestFunctionSolutionAnalyzer != null) {
     256        BestSingleObjectiveTestFunctionSolutionAnalyzer.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
     257        BestSingleObjectiveTestFunctionSolutionAnalyzer.ResultsParameter.ActualName = "Results";
     258        BestSingleObjectiveTestFunctionSolutionAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
     259        BestSingleObjectiveTestFunctionSolutionAnalyzer.BestKnownQualityParameter.ActualName = BestKnownQualityParameter.Name;
     260        BestSingleObjectiveTestFunctionSolutionAnalyzer.BestKnownSolutionParameter.ActualName = BestKnownSolutionParameter.Name;
     261        BestSingleObjectiveTestFunctionSolutionAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name;
     262        BestSingleObjectiveTestFunctionSolutionAnalyzer.EvaluatorParameter.ActualName = EvaluatorParameter.Name;
     263        BestSingleObjectiveTestFunctionSolutionAnalyzer.BoundsParameter.ActualName = BoundsParameter.Name;
     264      }
     265
     266      if (SingleObjectivePopulationDiversityAnalyzer != null) {
     267        SingleObjectivePopulationDiversityAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name;
     268        SingleObjectivePopulationDiversityAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
     269        SingleObjectivePopulationDiversityAnalyzer.ResultsParameter.ActualName = "Results";
     270        SingleObjectivePopulationDiversityAnalyzer.SimilarityCalculator = Operators.OfType<SingleObjectiveTestFunctionSimilarityCalculator>().SingleOrDefault();
     271      }
    259272    }
    260273    private void InitializeOperators() {
     
    264277
    265278      Operators.Add(new BestSingleObjectiveTestFunctionSolutionAnalyzer());
     279      Operators.Add(new SingleObjectivePopulationDiversityAnalyzer());
    266280      ParameterizeAnalyzers();
    267281      Operators.AddRange(ApplicationManager.Manager.GetInstances<IRealVectorOperator>().Cast<IOperator>());
     
    316330      try {
    317331        BestKnownSolutionParameter.Value = Evaluator.GetBestKnownSolution(ProblemSize.Value);
    318       } catch (ArgumentException e) {
     332      }
     333      catch (ArgumentException e) {
    319334        ErrorHandling.ShowErrorDialog(e);
    320335        ProblemSize.Value = Evaluator.MinimumProblemSize;
  • trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/Analyzers/TSPPopulationDiversityAnalyzer.cs

    r7259 r8720  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Analysis;
    2324using HeuristicLab.Common;
     
    2526using HeuristicLab.Encodings.PermutationEncoding;
    2627using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     28using HeuristicLab.PluginInfrastructure;
    2729
    2830namespace HeuristicLab.Problems.TravelingSalesman {
     31  // BackwardsCompatibility3.3
     32  #region Backwards compatible code, remove with 3.4
    2933  /// <summary>
    3034  /// An operator for analyzing the diversity of solutions of Traveling Salesman Problems given in path representation.
    3135  /// </summary>
     36  [Obsolete]
     37  [NonDiscoverableType]
    3238  [Item("TSPPopulationDiversityAnalyzer", "An operator for analyzing the diversity of solutions of Traveling Salesman Problems given in path representation.")]
    3339  [StorableClass]
     
    7985    }
    8086  }
     87  #endregion
    8188}
  • trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs

    r8478 r8720  
    8282      get { return Operators.OfType<TSPAlleleFrequencyAnalyzer>().FirstOrDefault(); }
    8383    }
    84     private TSPPopulationDiversityAnalyzer TSPPopulationDiversityAnalyzer {
    85       get { return Operators.OfType<TSPPopulationDiversityAnalyzer>().FirstOrDefault(); }
    86     }
    8784    private SingleObjectivePopulationDiversityAnalyzer SingleObjectivePopulationDiversityAnalyzer {
    8885      get { return Operators.OfType<SingleObjectivePopulationDiversityAnalyzer>().FirstOrDefault(); }
     
    321318        TSPAlleleFrequencyAnalyzer.BestKnownSolutionParameter.ActualName = BestKnownSolutionParameter.Name;
    322319        TSPAlleleFrequencyAnalyzer.ResultsParameter.ActualName = "Results";
    323       }
    324 
    325       if (TSPPopulationDiversityAnalyzer != null) {
    326         TSPPopulationDiversityAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name;
    327         TSPPopulationDiversityAnalyzer.SolutionParameter.ActualName = SolutionCreator.PermutationParameter.ActualName;
    328         TSPPopulationDiversityAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
    329         TSPPopulationDiversityAnalyzer.ResultsParameter.ActualName = "Results";
    330320      }
    331321
     
    448438        try {
    449439          EvaluateAndLoadTour(data.BestKnownTour);
    450         } catch (InvalidOperationException) {
     440        }
     441        catch (InvalidOperationException) {
    451442          if (data.BestKnownQuality.HasValue)
    452443            BestKnownQuality = new DoubleValue(data.BestKnownQuality.Value);
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/SimilarityCalculators/VRPSimilarityCalculator.cs

    r8346 r8720  
    9292
    9393    public override double CalculateSolutionSimilarity(IScope leftSolution, IScope rightSolution) {
    94       var sol1 = leftSolution.Variables[SolutionVariableName].Value as PotvinEncoding;
    95       var sol2 = rightSolution.Variables[SolutionVariableName].Value as PotvinEncoding;
     94      var sol1 = leftSolution.Variables[SolutionVariableName].Value as IVRPEncoding;
     95      var sol2 = rightSolution.Variables[SolutionVariableName].Value as IVRPEncoding;
    9696
    97       return CalculateSimilarity(sol1, sol2);
     97      var potvinSol1 = sol1 is PotvinEncoding ? sol1 as PotvinEncoding : PotvinEncoding.ConvertFrom(sol1, ProblemInstance);
     98      var potvinSol2 = sol2 is PotvinEncoding ? sol2 as PotvinEncoding : PotvinEncoding.ConvertFrom(sol2, ProblemInstance);
     99
     100      return CalculateSimilarity(potvinSol1, potvinSol2);
    98101    }
    99102  }
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs

    r8346 r8720  
    2424using System.Drawing;
    2525using System.Linq;
     26using HeuristicLab.Analysis;
    2627using HeuristicLab.Common;
    2728using HeuristicLab.Core;
     
    112113      set { SolutionCreatorParameter.Value = value; }
    113114    }
     115    private SingleObjectivePopulationDiversityAnalyzer SingleObjectivePopulationDiversityAnalyzer {
     116      get { return Operators.OfType<SingleObjectivePopulationDiversityAnalyzer>().FirstOrDefault(); }
     117    }
    114118    #endregion
    115119
     
    244248          ApplicationManager.Manager.GetInstances<IGeneralVRPOperator>().Cast<IOperator>()).OrderBy(op => op.Name));
    245249        Operators.Add(new VRPSimilarityCalculator());
     250        Operators.Add(new SingleObjectivePopulationDiversityAnalyzer());
    246251
    247252        IVRPCreator defaultCreator = null;
     
    277282          op.QualityVariableName = ProblemInstance.SolutionEvaluator.QualityParameter.ActualName;
    278283          op.ProblemInstance = ProblemInstance;
     284        }
     285        if (SingleObjectivePopulationDiversityAnalyzer != null) {
     286          SingleObjectivePopulationDiversityAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name;
     287          SingleObjectivePopulationDiversityAnalyzer.QualityParameter.ActualName = ProblemInstance.SolutionEvaluator.QualityParameter.ActualName;
     288          SingleObjectivePopulationDiversityAnalyzer.ResultsParameter.ActualName = "Results";
     289          SingleObjectivePopulationDiversityAnalyzer.SimilarityCalculator = Operators.OfType<VRPSimilarityCalculator>().SingleOrDefault();
    279290        }
    280291      }
Note: See TracChangeset for help on using the changeset viewer.