Changeset 18026


Ignore:
Timestamp:
07/20/21 17:39:48 (4 months ago)
Author:
dpiringe
Message:

#3026

  • fixed a bug in Runner: the zip-method created wrong pairs (because the lists are unordered)
  • fixed a bug in SymbolicRegressionSolutionFormatterBase: the method now checks the target type as well
Location:
branches/3026_IntegrationIntoSymSpace
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.App/Runner.cs

    r17834 r18026  
    55using System.Threading;
    66using System.Threading.Tasks;
     7using HeuristicLab.Core;
    78using HeuristicLab.Optimization;
    89using Newtonsoft.Json.Linq;
     
    5354
    5455        // zip and filter the results with the ResultJsonItems
    55         var filteredResults = configuredResultItems.Zip(
    56           run.Results.Where(x => configuredResultItems.Any(y => y.Name == x.Key)),
    57           (x, y) => new { Item = x, Value = y.Value });
     56        var filteredResults = new List<Tuple<IResultJsonItem, IItem>>();
     57        foreach(var resultItem in configuredResultItems) {
     58          foreach(var result in run.Results) {
     59            if(resultItem.Name == result.Key) {
     60              filteredResults.Add(Tuple.Create(resultItem, result.Value));
     61            }
     62          }
     63        }
    5864
    5965        // add results to the JObject
    6066        foreach(var result in filteredResults) {
    61           var formatter = GetResultFormatter(result.Item.ResultFormatterType);
    62           obj.Add(result.Item.Name, formatter.Format(result.Value));
     67          var formatter = GetResultFormatter(result.Item1.ResultFormatterType);
     68          obj.Add(result.Item1.Name, formatter.Format(result.Item2));
    6369        }
    6470      }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonTemplateInstantiator.cs

    r17834 r18026  
    108108      foreach (JObject obj in Config) {
    109109        // build item from config object
    110         string path = obj.Property("Path").Value.ToString();
     110        string path = obj.Property("Path").Value.ToString(); // TODO: catch exception if path is not available
    111111        // override default value
    112112        if (Objects.TryGetValue(path, out IJsonItem param)) {
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/ResultFormatters/SymbolicRegressionSolutionFormatterBase.cs

    r17843 r18026  
    1010    public override bool CanFormatType(Type t) {
    1111      var interfaces = t.GetInterfaces();
    12       return t.GetInterfaces().Any(x => x == typeof(ISymbolicRegressionSolution));
     12      var symRegSolutionType = typeof(ISymbolicRegressionSolution);
     13      return t == symRegSolutionType || interfaces.Any(x => x == symRegSolutionType);
    1314    }
    1415
    1516    protected abstract ISymbolicExpressionTreeStringFormatter SymbolicExpressionTreeStringFormatter { get; }
    1617
    17     public override string Format(object o) => SymbolicExpressionTreeStringFormatter.Format((ISymbolicExpressionTree)((ISymbolicRegressionSolution)o).Model.SymbolicExpressionTree);
     18    public override string Format(object o) => SymbolicExpressionTreeStringFormatter.Format(((ISymbolicRegressionSolution)o).Model.SymbolicExpressionTree);
    1819  }
    1920}
Note: See TracChangeset for help on using the changeset viewer.