Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/20/17 20:41:33 (8 years ago)
Author:
abeham
Message:

#2457: working on identification of problem instances

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PerformanceComparison/HeuristicLab.Analysis.FitnessLandscape/3.3/CharacteristicCalculator/RandomWalkCalculator.cs

    r13920 r14690  
    5858      characteristics = cloner.Clone(original.characteristics);
    5959    }
    60     public RandomWalkCalculator() {
     60    public RandomWalkCalculator() : this(new RandomWalk()) { }
     61    public RandomWalkCalculator(RandomWalk walker) {
    6162      Name = ItemName;
    6263      Description = ItemDescription;
    63       walker = new RandomWalk();
     64      this.walker = walker;
    6465      characteristics = new CheckedItemList<StringValue>(
    6566        new[] { "AutoCorrelation1", "CorrelationLength", "InformationContent",
    66         "PartialInformationContent", "DensityBasinInformation", "InformationStability", 
     67        "PartialInformationContent", "DensityBasinInformation", "InformationStability",
    6768        "Diversity", "Regularity", "TotalEntropy", "PeakInformationContent",
    6869        "PeakDensityBasinInformation" }.Select(x => new StringValue(x)));
     
    9192        };
    9293        walker.ExecutionStateChanged += evHandle;
    93         walker.Start();
    94         waitHandle.WaitOne();
    95         walker.ExecutionStateChanged -= evHandle;
     94        try {
     95          walker.Start();
     96          waitHandle.WaitOne();
     97        } finally { walker.ExecutionStateChanged -= evHandle; }
    9698      }
    9799      foreach (var p in characteristics.CheckedItems) {
    98         yield return new Result("RandomWalk." + walker.MutatorParameter.Value.Name + "." + p.Value.Value, walker.Results[p.Value.Value].Value);
     100        var resultName = "RandomWalk." + walker.MutatorParameter.Value.Name + "." + p.Value.Value;
     101        IResult result;
     102        if (walker.Results.TryGetValue(p.Value.Value, out result)) {
     103          yield return new Result(resultName, result.Value);
     104        } else yield return new Result(resultName, new DoubleValue(0));
    99105      }
    100106      walker.Prepare(true);
Note: See TracChangeset for help on using the changeset viewer.