Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/07/18 20:55:57 (6 years ago)
Author:
abeham
Message:

#1614: updates from last night ...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1614_GeneralizedQAP/HeuristicLab.OptimizationExpertSystem.Common/3.3/Recommenders/KNearestNeighborModel.cs

    r13878 r15736  
    2020#endregion
    2121
     22using System;
     23using System.Collections.Generic;
     24using System.Linq;
    2225using HeuristicLab.Collections;
    2326using HeuristicLab.Common;
    2427using HeuristicLab.Optimization;
    25 using System;
    26 using System.Collections.Generic;
    27 using System.Linq;
    2828
    2929namespace HeuristicLab.OptimizationExpertSystem.Common {
     
    5555        else feature[f] = (feature[f] - means[f]) / sdevs[f];
    5656      }
     57      var dist = features.Select((f, i) => Math.Sqrt(f.Select((g, j) => Math.Sqrt((g - feature[j]) * (g - feature[j]))).Sum())).ToList();
    5758      var nearestK = features.Select((f, i) => new { ProblemInstanceIndex = i, Feature = f })
    58                              .OrderBy(x => x.Feature.Select((f, i) => (f - feature[i]) * (f - feature[i])).Sum());
     59                             .OrderBy(x => dist[x.ProblemInstanceIndex]);
    5960     
    6061      var performances = new Dictionary<IAlgorithm, Performance>();
Note: See TracChangeset for help on using the changeset viewer.