Changeset 12876 for branches/HeuristicLab.Problems.GrammaticalOptimization-gkr/HeuristicLab.Algorithms.GrammaticalOptimization
- Timestamp:
- 08/17/15 19:13:19 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.GrammaticalOptimization-gkr/HeuristicLab.Algorithms.GrammaticalOptimization/Solvers/SequentialSearch.cs
r12290 r12876 201 201 var children = n.children; 202 202 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); 208 206 // write phrases 209 207 foreach (var ch in children) { 210 SetColorForValue(policy.Get Value(ch.phrase) / maxValue);208 SetColorForValue(policy.GetTries(ch.phrase) / maxTries); 211 209 Console.Write(" {0,-4}", ch.phrase.Substring(Math.Max(0, ch.phrase.Length - 3), Math.Min(3, ch.phrase.Length))); 212 210 } … … 215 213 // write values 216 214 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 "); 219 220 } 220 221 Console.WriteLine(); … … 222 223 // write tries 223 224 foreach (var ch in children) { 224 SetColorForValue(policy.Get Value(ch.phrase) / maxValue);225 SetColorForValue(policy.GetTries(ch.phrase) / maxTries); 225 226 Console.Write(" {0,4}", policy.GetTries(ch.phrase)); 226 227 }
Note: See TracChangeset
for help on using the changeset viewer.