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
Location:
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ParameterConfigurations/ParameterConfiguration.cs

    r5337 r5340  
    476476      return list;
    477477    }
     478
     479    public void CollectOptimizedParameterNames(List<string> parameterNames, string prefix) {
     480      foreach (var vc in ValueConfigurations) {
     481        if (vc.Optimize) {
     482          vc.CollectOptimizedParameterNames(parameterNames, prefix);
     483        }
     484      }
     485    }
    478486  }
    479487}
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ValueConfigurations/ValueConfiguration.cs

    r5303 r5340  
    280280      return list;
    281281    }
     282
     283    public void CollectOptimizedParameterNames(List<string> parameterNames, string prefix) {
     284      foreach (var pc in ParameterConfigurations) {
     285        if (pc.Optimize) {
     286          parameterNames.Add(prefix + pc.ParameterName);
     287          pc.CollectOptimizedParameterNames(parameterNames, prefix + pc.ParameterName + ".");
     288        }
     289      }
     290    }
    282291  }
    283292}
  • 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];
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Interfaces/IOptimizable.cs

    r5303 r5340  
    1919    void Cross(IRandom random, IOptimizable other, CrossDelegate cross, IIntValueCrossover intValueCrossover, IDoubleValueCrossover doubleValueCrossover);
    2020    string ParameterInfoString { get; }
     21    void CollectOptimizedParameterNames(List<string> parameterNames, string prefix);
    2122
    2223    /// <summary>
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/MetaOptimizationProblem.cs

    r5337 r5340  
    224224      IAlgorithm instance = (IAlgorithm)Activator.CreateInstance(AlgorithmType.Value);
    225225      this.ProblemType.ValidTypes = ApplicationManager.Manager.GetTypes(instance.ProblemType, true).ToList();
    226       this.ProblemType.Value = this.ProblemType.ValidTypes.First();
    227       ParameterConfigurationTreeParameter.ActualValue = new ParameterConfigurationTree(CreateAlgorithm(AlgorithmType.Value, ProblemType.Value));
     226      this.ProblemType.Value = this.ProblemType.ValidTypes.Where(t => t != typeof(MetaOptimizationProblem)).FirstOrDefault();
     227      if (ProblemType.Value != null) {
     228        ParameterConfigurationTreeParameter.ActualValue = new ParameterConfigurationTree(CreateAlgorithm(AlgorithmType.Value, ProblemType.Value));
     229      } else {
     230        ParameterConfigurationTreeParameter.ActualValue = null;
     231      }
    228232    }
    229233
Note: See TracChangeset for help on using the changeset viewer.