Changeset 12921 for trunk/sources
- Timestamp:
- 08/27/15 15:37:46 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeProblem.cs
r12904 r12921 26 26 using HeuristicLab.Common; 27 27 using HeuristicLab.Core; 28 using HeuristicLab.Data; 28 29 using HeuristicLab.Optimization; 29 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 56 57 } 57 58 58 public virtual void Analyze(ISymbolicExpressionTree[] trees, double[] qualities, ResultCollection results, IRandom random) { 59 var bestQuality = Maximization ? qualities.Max() : qualities.Min(); 60 var bestIdx = Array.IndexOf(qualities, bestQuality); 61 var best = trees[bestIdx]; 59 public virtual void Analyze(ISymbolicExpressionTree[] trees, double[] qualities, ResultCollection results, 60 IRandom random) { 61 if (!results.ContainsKey("Best Solution Quality")) { 62 results.Add(new Result("Best Solution Quality", typeof(DoubleValue))); 63 } 62 64 if (!results.ContainsKey("Best Solution")) { 63 65 results.Add(new Result("Best Solution", typeof(ISymbolicExpressionTree))); 64 66 } 65 results["Best Solution"].Value = (IItem)best.Clone(); 67 68 var bestQuality = Maximization ? qualities.Max() : qualities.Min(); 69 70 if (results["Best Solution Quality"].Value == null || 71 IsBetter(bestQuality, ((DoubleValue)results["Best Solution Quality"].Value).Value)) { 72 var bestIdx = Array.IndexOf(qualities, bestQuality); 73 var bestClone = (IItem)trees[bestIdx].Clone(); 74 results["Best Solution"].Value = bestClone; 75 results["Best Solution Quality"].Value = new DoubleValue(bestQuality); 76 } 66 77 } 78 67 79 public sealed override void Analyze(Individual[] individuals, double[] qualities, ResultCollection results, IRandom random) { 68 80 Analyze(individuals.Select(ind => ind.SymbolicExpressionTree()).ToArray(), qualities, results, random);
Note: See TracChangeset
for help on using the changeset viewer.