Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/21/10 01:13:49 (13 years ago)
Author:
cneumuel
Message:

#1215

  • added possibility to create all parameter combinations from a ParameterConfigurationTree and generate an experiment from them
File:
1 edited

Legend:

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

    r5112 r5144  
    88using HeuristicLab.Optimization;
    99using HeuristicLab.Data;
     10using System.Collections;
    1011
    1112namespace HeuristicLab.Problems.MetaOptimization {
    1213  // todo: storable, name, descr, ...
    1314  [StorableClass]
    14   public class ParameterConfigurationTree : ValueConfiguration {
     15  public class ParameterConfigurationTree : ValueConfiguration, IEnumerable {
    1516    //[Storable]
    1617    //public EngineAlgorithm Algorithm {
     
    180181      ((IAlgorithm)item).CollectParameterValues(this.Parameters);
    181182    }
     183
     184    public Experiment GenerateExperiment(IAlgorithm algorithm) {
     185      Experiment experiment = new Experiment();
     186      foreach (IValueConfiguration combination in this) {
     187        IAlgorithm clonedAlg = (IAlgorithm)algorithm.Clone();
     188        clonedAlg.Name = combination.ToParameterInfoString();
     189        combination.Parameterize(clonedAlg);
     190        experiment.Optimizers.Add(clonedAlg);
     191      }
     192      return experiment;
     193    }
     194
     195    public IEnumerator GetEnumerator() {
     196      IEnumerator enumerator = new ParameterCombinationsEnumerator(this);
     197      enumerator.Reset();
     198      return enumerator;
     199    }
     200
     201    public long GetCombinationCount() {
     202      long cnt = 0;
     203      foreach (var c in this) {
     204        cnt++;
     205      }
     206      return cnt;
     207    }
    182208  }
    183209}
Note: See TracChangeset for help on using the changeset viewer.