Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9728


Ignore:
Timestamp:
07/20/13 13:06:59 (11 years ago)
Author:
ascheibe
Message:

#1886 worked on solution caching

Location:
branches/HeuristicLab.Analysis.AlgorithmBehavior
Files:
3 added
6 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers.Views/3.3/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers.Views-3.3.csproj

    r9361 r9728  
    143143      <DependentUpon>ParameterInfluenceView.cs</DependentUpon>
    144144    </Compile>
     145    <Compile Include="PermutationSolutionDictionaryView.cs">
     146      <SubType>UserControl</SubType>
     147    </Compile>
     148    <Compile Include="PermutationSolutionDictionaryView.Designer.cs">
     149      <DependentUpon>PermutationSolutionDictionaryView.cs</DependentUpon>
     150    </Compile>
    145151    <Compile Include="Plugin.cs" />
    146152    <Compile Include="Properties\AssemblyInfo.cs" />
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers-3.3.csproj

    r9723 r9728  
    119119    <Compile Include="SolutionsCaching\SolutionDictionary.cs" />
    120120    <Compile Include="SelectionPressureAnalyzer.cs" />
     121    <Compile Include="SolutionsCaching\PermutationInformation.cs" />
    121122    <Compile Include="WorstQualityAnalyzer.cs" />
    122123    <Compile Include="InitializableOperator.cs" />
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/SolutionsCaching/PermutationSolutionDictionary.cs

    r9723 r9728  
    3131  [StorableClass]
    3232  public class PermutationSolutionDictionary<TKey, TValue> : SolutionDictionary<TKey, TValue>
    33     where TKey : PermutationWrapper {
     33    where TKey : PermutationWrapper
     34    where TValue : PermutationInformation {
    3435
    3536    public PermutationSolutionDictionary() {
     
    8384      return new PermutationSolutionDictionary<TKey, TValue>(this, cloner);
    8485    }
     86
     87    public int NumberOfPartialSolutions() {
     88      return solutionDictionary.Where(x => x.Key.ElementType == ElementType.Diff).Count();
     89    }
     90
     91    public int NumberOfCompleteSolutions() {
     92      return solutionDictionary.Where(x => x.Key.ElementType == ElementType.Complete).Count();
     93    }
    8594  }
    8695}
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/SolutionsCaching/SolutionCachingAnalyzer.cs

    r9723 r9728  
    2020#endregion
    2121
    22 
    2322using HeuristicLab.Common;
    2423using HeuristicLab.Core;
     
    3534  public class SolutionCachingAnalyzer : SingleSuccessorOperator, IAnalyzer {
    3635    private const string ResultsParameterName = "Results";
    37     //TODO: this should be a stateful item!
     36
    3837    #region IAnalyzer Members
    3938    public bool EnabledByDefault {
     
    5857      get { return ResultsParameter.ActualValue; }
    5958    }
    60 
    61     [Storable]
    62     private PermutationSolutionDictionary<PermutationWrapper, int> solDict;
    6359    #endregion
    6460
     
    6864    private SolutionCachingAnalyzer(SolutionCachingAnalyzer original, Cloner cloner)
    6965      : base(original, cloner) {
    70       this.solDict = (PermutationSolutionDictionary<PermutationWrapper, int>)original.solDict.Clone(cloner);
    7166    }
    7267
     
    7671      Parameters.Add(new LookupParameter<IntValue>("Generations", "Nr of generations."));
    7772      Parameters.Add(new ScopeTreeLookupParameter<Permutation>("Solution", "The solutions that should be stored.", "TSPTour", 1));
    78       solDict = new PermutationSolutionDictionary<PermutationWrapper, int>();
    7973    }
    8074
     
    8579    public override IOperation Apply() {
    8680      ItemArray<Permutation> solutions = SolutionParameter.ActualValue;
     81      PermutationSolutionDictionary<PermutationWrapper, PermutationInformation> solDict;
     82
     83      if (!Results.ContainsKey("SolutionCache")) {
     84        solDict = new PermutationSolutionDictionary<PermutationWrapper, PermutationInformation>();
     85        Results.Add(new Result("SolutionCache", solDict));
     86      } else {
     87        solDict = (PermutationSolutionDictionary<PermutationWrapper, PermutationInformation>)Results["SolutionCache"].Value;
     88      }
    8789
    8890      foreach (var sol in solutions) {
    89         solDict.Add(new PermutationWrapper(sol), GenerationsParameter.ActualValue.Value);
     91        PermutationInformation info = new PermutationInformation();
     92        info.Generation = GenerationsParameter.ActualValue.Value;
     93        info.ProducedBy = ProducedBy.Mutation;
     94       
     95        solDict.Add(new PermutationWrapper(sol), info);
    9096      }
    91 
    92       if (!ResultsParameter.ActualValue.ContainsKey("SolutionCache")) {
    93         ResultsParameter.ActualValue.Add(new Result("SolutionCache", solDict));
    94       }
    95 
    9697      return base.Apply();
    9798    }
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/SolutionsCaching/SolutionDictionary.cs

    r9723 r9728  
    6666      return solutionDictionary.ContainsKey(key);
    6767    }
     68
     69    public int Size() {
     70      return solutionDictionary.Count;
     71    }
    6872  }
    6973}
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.sln

    r9723 r9728  
    55  ProjectSection(SolutionItems) = preProject
    66    Build.cmd = Build.cmd
    7     Performance1.psess = Performance1.psess
    87    PreBuildEvent.cmd = PreBuildEvent.cmd
    98  EndProjectSection
Note: See TracChangeset for help on using the changeset viewer.