Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/20/11 14:54:02 (14 years ago)
Author:
cneumuel
Message:

#1215

  • made solution cache use less memory, by deleting unnecessary information
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Evaluators/ParameterConfigurationEvaluator.cs

    r5337 r5340  
    129129    private RunCollection ExecuteAlgorithm(ParameterConfigurationTree parameterConfiguration, IAlgorithm algorithm, IItemList<IProblem> problems) {
    130130      IAlgorithm algorithmClone = (IAlgorithm)algorithm.Clone();
     131      var parameterNames = new List<string>();
     132      var resultNames = new List<string> { "BestQuality", "Execution Time" };
     133      parameterConfiguration.CollectOptimizedParameterNames(parameterNames, "");
    131134
    132135      // set parameters
     
    154157          int problemIndex = problems.IndexOf(problem) + 1;
    155158          IRun run = algorithmClone.Runs.Last();
     159          CleanRun(run, resultNames, parameterNames);
    156160          run.Results.Add("Meta.FromCache", new BoolValue(false));
    157161          run.Results.Add("Meta.Generation", new IntValue(GenerationsParameter.ActualValue != null ? GenerationsParameter.ActualValue.Value : 0));
     
    165169    }
    166170
     171    /// <summary>
     172    /// Removes all information from the run which is not needed for lated analysis
     173    /// only keep the results which are important and the parameters which were optimized
     174    /// </summary>
     175    private void CleanRun(IRun run, IEnumerable<string> resultsToKeep, IEnumerable<string> parametersToKeep) {
     176      var resultsToRemove = new List<string>();
     177      var parametersToRemove = new List<string>();
     178      foreach (var result in run.Results) {
     179        if (!resultsToKeep.Contains(result.Key))
     180          resultsToRemove.Add(result.Key);
     181      }
     182      foreach (var parameter in run.Parameters) {
     183        if (!parametersToKeep.Contains(parameter.Key))
     184          parametersToRemove.Add(parameter.Key);
     185      }
     186
     187      foreach (var result in resultsToRemove)
     188        run.Results.Remove(result);
     189      foreach (var parameter in parametersToRemove)
     190        run.Parameters.Remove(parameter);
     191    }
     192
    167193    public static double NormalizeQualities(ParameterConfigurationTree parameterConfigurationTree, double[] referenceQualities) {
    168194      double[] qualitiesNormalized = new double[referenceQualities.Length];
Note: See TracChangeset for help on using the changeset viewer.