Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/17/15 19:13:19 (9 years ago)
Author:
gkronber
Message:

#2283: implemented first crude version of extreme hunter algorithm in branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.GrammaticalOptimization-gkr/HeuristicLab.Algorithms.GrammaticalOptimization/Solvers/SequentialSearch.cs

    r12290 r12876  
    201201        var children = n.children;
    202202        if (children == null || !children.Any()) break;
    203         var values = children.Select(ch => policy.GetValue(ch.phrase));
    204         var maxValue = values.Max();
    205         if (maxValue == 0) maxValue = 1.0;
    206         if (double.IsPositiveInfinity(maxValue)) maxValue = double.MaxValue;
    207 
     203        var triesEnumerable = children.Select(ch => policy.GetTries(ch.phrase));
     204        double maxTries = triesEnumerable.Where(v => !double.IsInfinity(v)).DefaultIfEmpty(1).Max();
     205        maxTries = Math.Max(maxTries, 1.0);
    208206        // write phrases
    209207        foreach (var ch in children) {
    210           SetColorForValue(policy.GetValue(ch.phrase) / maxValue);
     208          SetColorForValue(policy.GetTries(ch.phrase) / maxTries);
    211209          Console.Write(" {0,-4}", ch.phrase.Substring(Math.Max(0, ch.phrase.Length - 3), Math.Min(3, ch.phrase.Length)));
    212210        }
     
    215213        // write values
    216214        foreach (var ch in children) {
    217           SetColorForValue(policy.GetValue(ch.phrase) / maxValue);
    218           Console.Write(" {0:F2}", policy.GetValue(ch.phrase) * 10.0);
     215          SetColorForValue(policy.GetTries(ch.phrase) / maxTries);
     216          if (!double.IsInfinity(policy.GetValue(ch.phrase)))
     217            Console.Write(" {0:F2}", policy.GetValue(ch.phrase) * 10.0);
     218          else
     219            Console.Write(" Inf ");
    219220        }
    220221        Console.WriteLine();
     
    222223        // write tries
    223224        foreach (var ch in children) {
    224           SetColorForValue(policy.GetValue(ch.phrase) / maxValue);
     225          SetColorForValue(policy.GetTries(ch.phrase) / maxTries);
    225226          Console.Write(" {0,4}", policy.GetTries(ch.phrase));
    226227        }
Note: See TracChangeset for help on using the changeset viewer.