Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/29/18 18:16:05 (6 years ago)
Author:
abeham
Message:

#2457:

  • Changed calculation of correlation length (using limit introduced Hordijk 1996)
  • Changed RuggednessCalculator (no more a HL item)
  • Added additional, information-analysis-based features for directed walks
  • Added generic DirectedWalk algorithm (as described in thesis)
  • Made OneSizeInstanceProvider parametrizable
  • Adapted program for analyzing problem instance reidentification
Location:
branches/2457_ExpertSystem/ProblemInstanceIdentifier
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/2457_ExpertSystem/ProblemInstanceIdentifier/InstanceDescriptor.cs

    r15031 r16096  
    1 using System;
    2 using System.Collections.Generic;
     1using System.Collections.Generic;
    32using System.Linq;
    43using System.Text.RegularExpressions;
    5 using HeuristicLab.Analysis.FitnessLandscape;
    64using HeuristicLab.Common;
    7 using HeuristicLab.Encodings.PermutationEncoding;
    85using HeuristicLab.Problems.QuadraticAssignment;
    96
     
    1613    public string[] FeatureNames { get; set; }
    1714    public double[] FeatureValues { get; set; }
     15
     16    public double DescriptionEffort { get; set; }
    1817   
    1918    private InstanceDescriptor() { }
     
    3332      FeatureNames = (string[])other.FeatureNames.Clone();
    3433      FeatureValues = (double[]) other.FeatureValues.Clone();
     34      DescriptionEffort = other.DescriptionEffort;
    3535    }
    3636
     
    4141        Dimension = qap.Weights.Rows,
    4242        FeatureNames = new string[0],
    43         FeatureValues = new double[0]
    44       };
    45     }
    46 
    47     public static InstanceDescriptor FromPaths(QuadraticAssignmentProblem qap, List<List<Tuple<Permutation, double>>> trajectories) {
    48       var result = PermutationPathAnalysis.GetCharacteristics(trajectories);
    49 
    50       return new InstanceDescriptor() {
    51         Name = qap.Name,
    52         Cls = GetClass(qap.Name),
    53         Dimension = qap.Weights.Rows,
    54         FeatureNames = result.GetNames(),
    55         FeatureValues = result.GetValues()
     43        FeatureValues = new double[0],
     44        DescriptionEffort = 0
    5645      };
    5746    }
  • branches/2457_ExpertSystem/ProblemInstanceIdentifier/InstanceExplorer.cs

    r15031 r16096  
    11using System;
     2using System.Collections.Generic;
    23using System.Linq;
    3 using HeuristicLab.Algorithms.MemPR.Permutation;
    44using HeuristicLab.Analysis.FitnessLandscape;
    55using HeuristicLab.Data;
    66using HeuristicLab.Encodings.PermutationEncoding;
    77using HeuristicLab.Problems.QuadraticAssignment;
    8 using HeuristicLab.Random;
    98using HeuristicLab.SequentialEngine;
    109
     
    2120  public class PathRelinkingExplorer : InstanceExplorer {
    2221    public int Paths { get; set; }
    23     public bool LocalOptima { get; set; }
     22    public QAPDirectedWalk.WalkType Type { get; set; }
    2423
    2524    public override string Name { get { return "Path-Relinking Explorer"; } }
    2625    public override int Effort { get { return Paths; } }
    2726
     27    public ISet<string> Features { get; set; }
     28
    2829    public PathRelinkingExplorer() {
    2930     
     
    3132
    3233    public override InstanceDescriptor Explore(QuadraticAssignmentProblem problem, int? seed = null) {
    33       var walk = new QAPDirectedWalk {
     34      var calculator = new QAPDirectedWalk {
    3435        Problem = problem,
    3536        BestImprovement = true,
    3637        Paths = Paths,
    3738        Seed = seed,
    38         LocalOptima = LocalOptima
    39       };
    40       var features = walk.Calculate().ToDictionary(x => x.Name, x => x.Value);
    41 
    42       return new InstanceDescriptor(problem.Name, InstanceDescriptor.GetClass(problem.Name), problem.Weights.Rows,
    43         features.Keys.ToArray(), features.Values.Select(x => ((DoubleValue)x).Value).ToArray());
    44     }
    45   }
    46 
    47   public class PathRelinkingOldFeaturedExplorer : InstanceExplorer {
    48     public int Paths { get; set; }
    49     public bool LocalOptima { get; set; }
    50 
    51     public override string Name { get { return "Path-Relinking Explorer"; } }
    52     public override int Effort { get { return Paths; } }
    53 
    54     public PathRelinkingOldFeaturedExplorer() {
    55 
    56     }
    57 
    58     public override InstanceDescriptor Explore(QuadraticAssignmentProblem problem, int? seed = null) {
    59       var random = new MersenneTwister();
    60       var samples = QAPDirectedWalk.CalculateRelinkingPoints(random, problem, Paths, LocalOptima);
    61       var trajectories = QAPDirectedWalk.Run(random, problem, samples);
    62 
    63       double avgAc1 = 0, avgCorLen = 0, avgIc = 0, avgDbi = 0, avgPic = 0, avgIs = 0, avgDiv = 0,
    64         avgReg = 0, avgEnt = 0, avgPkIc = 0, avgPkDbi = 0;
    65       int count = 0;
    66       foreach (var t in trajectories) {
    67         var trail = t.Select(x => x.Item2).ToArray();
    68         if (trail.Length < 4) continue;
    69         count++;
    70         double[] acf;
    71         var len = RuggednessCalculator.CalculateCorrelationLength(trail, out acf);
    72         avgAc1 += acf[0];
    73         avgCorLen += len;
    74         var analysis = new InformationAnalysis(trail, 20, 2);
    75         avgIc += analysis.InformationContent[0];
    76         avgDbi += analysis.DensityBasinInformation[0];
    77         avgPic += analysis.PartialInformationContent[0];
    78         avgIs += analysis.InformationStability;
    79         avgDiv += analysis.Diversity;
    80         avgReg += analysis.Regularity;
    81         avgEnt += analysis.TotalEntropy[0];
    82         avgPkIc += analysis.PeakInformationContent.Value;
    83         avgPkDbi += analysis.PeakDensityBasinInformation.Value;
    84       }
    85       avgAc1 /= count;
    86       avgCorLen /= count;
    87       avgIc /= count;
    88       avgDbi /= count;
    89       avgPic /= count;
    90       avgIs /= count;
    91       avgDiv /= count;
    92       avgReg /= count;
    93       avgEnt /= count;
    94       avgPkIc /= count;
    95       avgPkDbi /= count;
    96 
    97       return new InstanceDescriptor(problem.Name, InstanceDescriptor.GetClass(problem.Name), problem.Weights.Rows,
    98         new[] { "Autocorrelation(1)", "CorrelationLength", "InformationContent", "DensityBasinInformation",
    99           "PartialInformationContent", "InformationStability", "Diversity", "Regularity", "TotalEntropy",
    100           "PeakInformationContent", "PeakDensityBasinInformation" },
    101         new[] { avgAc1, avgCorLen, avgIc, avgDbi,
    102           avgPic, avgIs, avgDiv, avgReg, avgEnt,
    103           avgPkIc, avgPkDbi });
    104     }
    105   }
    106 
     39        Type = Type
     40      };
     41      if (Features != null && Features.Count > 0) {
     42        foreach (var c in calculator.Characteristics.ToList()) {
     43          calculator.Characteristics.SetItemCheckedState(c, Features.Contains(c.Value));
     44        }
     45      }
     46      var result = calculator.Calculate().ToDictionary(x => x.Name, x => x.Value);
     47      var evaluations = ((IntValue)result["EvaluatedSolutions"]).Value;
     48      result.Remove("EvaluatedSolutions");
     49      if (Features != null && result.Count != Features.Count) throw new InvalidOperationException("Not all features in results");
     50
     51      return new InstanceDescriptor(problem.Name, InstanceDescriptor.GetClass(problem.Name), problem.Weights.Rows,
     52        result.Keys.ToArray(), result.Values.Select(x => ((DoubleValue)x).Value).ToArray()) { DescriptionEffort = evaluations };
     53    }
     54  }
    10755
    10856  public class RandomWalkExplorer : InstanceExplorer {
     
    11159    public override string Name { get { return "Random-Walk Explorer"; } }
    11260    public override int Effort { get { return Iterations; } }
     61
     62    public ISet<string> Features { get; set; }
    11363
    11464    public RandomWalkExplorer() {
     
    12777      walk.MutatorParameter.Value = walk.MutatorParameter.ValidValues.First(x => x is Swap2Manipulator);
    12878      var calculator = new RandomWalkCalculator(walk) { Problem = problem };
    129       var features = calculator.Calculate().ToDictionary(x => x.Name, x => x.Value);
    130      
    131       return new InstanceDescriptor(problem.Name, InstanceDescriptor.GetClass(problem.Name), problem.Weights.Rows,
    132         features.Keys.ToArray(), features.Values.Select(x => ((DoubleValue)x).Value).ToArray());
     79      foreach (var c in calculator.Characteristics.ToList()) {
     80        calculator.Characteristics.SetItemCheckedState(c, Features.Contains(c.Value));
     81      }
     82      var result = calculator.Calculate().ToDictionary(x => x.Name, x => x.Value);
     83      if (Features != null && result.Count != Features.Count) throw new InvalidOperationException("Not all features in results");
     84
     85      return new InstanceDescriptor(problem.Name, InstanceDescriptor.GetClass(problem.Name), problem.Weights.Rows,
     86        result.Keys.ToArray(), result.Values.Select(x => ((DoubleValue)x).Value).ToArray());
    13387    }
    13488  }
     
    13993
    14094    public override string Name { get { return "Adaptive-Walk Explorer"; } }
    141     public override int Effort { get { return Iterations * SampleSize; } }
     95    private int _effort;
     96    public override int Effort { get { return _effort; } }
     97
     98    public ISet<string> Features { get; set; }
    14299
    143100    public AdaptiveWalkExplorer() {
    144 
     101      _effort = 0;
    145102    }
    146103
     
    157114      walk.MutatorParameter.Value = walk.MutatorParameter.ValidValues.First(x => x is Swap2Manipulator);
    158115      var calculator = new AdaptiveWalkCalculator(walk) { Problem = problem };
    159       var features = calculator.Calculate().ToDictionary(x => x.Name, x => x.Value);
    160 
    161       return new InstanceDescriptor(problem.Name, InstanceDescriptor.GetClass(problem.Name), problem.Weights.Rows,
    162         features.Keys.ToArray(), features.Values.Select(x => ((DoubleValue)x).Value).ToArray());
     116      foreach (var c in calculator.Characteristics.ToList()) {
     117        calculator.Characteristics.SetItemCheckedState(c, Features.Contains(c.Value));
     118      }
     119      var result = calculator.Calculate().ToDictionary(x => x.Name, x => x.Value);
     120      if (Features != null && result.Count != Features.Count) throw new InvalidOperationException("Not all features in results");
     121
     122      return new InstanceDescriptor(problem.Name, InstanceDescriptor.GetClass(problem.Name), problem.Weights.Rows,
     123        result.Keys.ToArray(), result.Values.Select(x => ((DoubleValue)x).Value).ToArray());
    163124    }
    164125  }
     
    170131    public override string Name { get { return "Up/Down-Walk Explorer"; } }
    171132    public override int Effort { get { return Iterations * SampleSize; } }
     133
     134    public ISet<string> Features { get; set; }
    172135
    173136    public UpDownWalkExplorer() {
     
    187150      walk.MutatorParameter.Value = walk.MutatorParameter.ValidValues.First(x => x is Swap2Manipulator);
    188151      var calculator = new UpDownWalkCalculator(walk) {  Problem = problem };
    189       var features = calculator.Calculate().ToDictionary(x => x.Name, x => x.Value);
    190 
    191       return new InstanceDescriptor(problem.Name, InstanceDescriptor.GetClass(problem.Name), problem.Weights.Rows,
    192         features.Keys.ToArray(), features.Values.Select(x => ((DoubleValue)x).Value).ToArray());
    193     }
    194   }
    195 
     152      foreach (var c in calculator.Characteristics.ToList()) {
     153        calculator.Characteristics.SetItemCheckedState(c, Features.Contains(c.Value));
     154      }
     155      var result = calculator.Calculate().ToDictionary(x => x.Name, x => x.Value);
     156      if (Features != null && result.Count != Features.Count) throw new InvalidOperationException("Not all features in results");
     157
     158      return new InstanceDescriptor(problem.Name, InstanceDescriptor.GetClass(problem.Name), problem.Weights.Rows,
     159        result.Keys.ToArray(), result.Values.Select(x => ((DoubleValue)x).Value).ToArray());
     160    }
     161  }
     162  /*
    196163  public class MemPRExplorer : InstanceExplorer {
    197164    public int Seconds { get; set; }
     
    230197      return new InstanceDescriptor(problem.Name, InstanceDescriptor.GetClass(problem.Name), problem.Weights.Rows, resultNames, result);
    231198    }
    232   }
     199  }*/
    233200}
  • branches/2457_ExpertSystem/ProblemInstanceIdentifier/ProblemInstanceIdentifier.csproj

    r15694 r16096  
    9797  </ItemGroup>
    9898  <ItemGroup>
    99     <ProjectReference Include="..\HeuristicLab.Algorithms.MemPR\3.3\HeuristicLab.Algorithms.MemPR-3.3.csproj">
    100       <Project>{9d274421-6332-4fbc-aae4-467ace27c368}</Project>
    101       <Name>HeuristicLab.Algorithms.MemPR-3.3</Name>
    102     </ProjectReference>
    10399    <ProjectReference Include="..\HeuristicLab.Analysis.FitnessLandscape\3.3\HeuristicLab.Analysis.FitnessLandscape-3.3.csproj">
    104100      <Project>{5fbdcd4a-3c2a-4ec6-83ce-34b29f43621a}</Project>
  • branches/2457_ExpertSystem/ProblemInstanceIdentifier/Program.cs

    r15031 r16096  
    22using System.Collections.Generic;
    33using System.Globalization;
     4using System.IO;
    45using System.Linq;
    56using System.Threading.Tasks;
    6 using HeuristicLab.PluginInfrastructure;
    7 using HeuristicLab.Problems.Instances;
     7using HeuristicLab.Analysis.FitnessLandscape;
    88using HeuristicLab.Problems.Instances.QAPLIB;
    99using HeuristicLab.Problems.QuadraticAssignment;
     
    1313  class Program {
    1414    static void Main(string[] args) {
    15       //var instances = Get20DifferentClasses();
    16       var instances = GetSomeRandomInstances(50, 13);
    1715
    1816      /*var classes = instances.Select(InstanceDescriptor.FromProblemOnly).GroupBy(x => x.Cls);
     
    2119      }*/
    2220
    23       var prExplorer = new PathRelinkingExplorer() {
    24         LocalOptima = false,
    25         Paths = 200
    26       };
    27       var prOldExplorer = new PathRelinkingOldFeaturedExplorer() {
    28         LocalOptima = false,
    29         Paths = 200
    30       };
    31 
    32       var prLocalExplorer = new PathRelinkingExplorer() {
    33         LocalOptima = true,
    34         Paths = 200
    35       };
    36       var prOldLocalExplorer = new PathRelinkingOldFeaturedExplorer() {
    37         LocalOptima = true,
    38         Paths = 200
    39       };
    40 
    41       var memPrExplorer = new MemPRExplorer() {
    42         IncludeLocalSearch = false,
    43         Seconds = 10
    44       };
    45 
    46       //var training = GenerateData(instances, prOldExplorer, parallel: true);
     21      var dwFeatureSets = new Dictionary<string, HashSet<string>>() {
     22        { "SBF", new HashSet<string>() { "Sharpness", "Bumpiness", "Flatness" } },
     23        { "FRQ", new HashSet<string>() { "DownQ2", "NeutQ2", "UpQ2", "DownQ1", "NeutQ1", "UpQ1", "DownQ3", "NeutQ3", "UpQ3" } },
     24        { "SBF+FRQ", new HashSet<string>() { "Sharpness", "Bumpiness", "Flatness", "DownQ2", "NeutQ2", "UpQ2", "DownQ1", "NeutQ1", "UpQ1", "DownQ3", "NeutQ3", "UpQ3" } },
     25        { "RUG", new HashSet<string>() { "AutoCorrelation1", "CorrelationLength" } },
     26        { "IAL", new HashSet<string>() { "InformationContent", "DensityBasinInformation", "PartialInformationContent", "Regularity", "TotalEntropy", "PeakInformationContent", "PeakDensityBasinInformation" } },
     27        { "RUG+IAL", new HashSet<string>() { "AutoCorrelation1", "CorrelationLength", "InformationContent", "DensityBasinInformation", "PartialInformationContent", "Regularity", "TotalEntropy", "PeakInformationContent", "PeakDensityBasinInformation" } },
     28        { "SBF+IAL", new HashSet<string>() { "Sharpness", "Bumpiness", "Flatness", "InformationContent", "DensityBasinInformation", "PartialInformationContent", "Regularity", "TotalEntropy", "PeakInformationContent", "PeakDensityBasinInformation" } },
     29        { "FRQ+IAL", new HashSet<string>() { "DownQ2", "NeutQ2", "UpQ2", "DownQ1", "NeutQ1", "UpQ1", "DownQ3", "NeutQ3", "UpQ3", "InformationContent", "DensityBasinInformation", "PartialInformationContent", "Regularity", "TotalEntropy", "PeakInformationContent", "PeakDensityBasinInformation" } },
     30        { "SBF+FRQ+IAL", new HashSet<string>() { "Sharpness", "Bumpiness", "Flatness", "DownQ2", "NeutQ2", "UpQ2", "DownQ1", "NeutQ1", "UpQ1", "DownQ3", "NeutQ3", "UpQ3", "InformationContent", "DensityBasinInformation", "PartialInformationContent", "Regularity", "TotalEntropy", "PeakInformationContent", "PeakDensityBasinInformation" } },
     31        { "SBF+FRQ+RUG+IAL", new HashSet<string>() { "Sharpness", "Bumpiness", "Flatness", "DownQ2", "NeutQ2", "UpQ2", "DownQ1", "NeutQ1", "UpQ1", "DownQ3", "NeutQ3", "UpQ3", "AutoCorrelation1", "CorrelationLength", "InformationContent", "DensityBasinInformation", "PartialInformationContent", "Regularity", "TotalEntropy", "PeakInformationContent", "PeakDensityBasinInformation" } },
     32      };
     33
     34      var dwTypes = new Dictionary<string, QAPDirectedWalk.WalkType> {
     35        { "(rr)-dw", QAPDirectedWalk.WalkType.RandomRandom },
     36        { "(rl)-dw", QAPDirectedWalk.WalkType.RandomLocal },
     37        { "(ll)-dw", QAPDirectedWalk.WalkType.LocalLocal },
     38        { "(li)-dw", QAPDirectedWalk.WalkType.LocalInverse }
     39      };
     40
     41      var dwPaths = new List<int> { 1, 2, 5, 10, 20, 50, 100, 200, 500 };
     42
     43      var random = new Random();
     44      using (var writer = File.CreateText("results.csv")) {
     45        writer.AutoFlush = true;
     46        var header = string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}\t{11}",
     47          "Rep", "FSet", "Type", "TrainEff", "TestEff", "ExCnt", "ExRnk", "ClsCnt", "ClsRnk", "TotCnt", "TrainEff2", "TestEff2");
     48        writer.WriteLine(header);
     49        Console.WriteLine(header);
     50        foreach (var dim in new[] { 20, 30, 40, 50, 100 }) {
     51          foreach (var feat in dwFeatureSets) {
     52            foreach (var type in dwTypes) {
     53              for (var rep = 0; rep < 10; rep++) {
     54                var instances = GetSomeRandomInstances(dimension: dim, totalInstances: 20, seed: random.Next());
     55
     56                var explorers = from p in dwPaths
     57                                select new PathRelinkingExplorer() { Features = feat.Value, Paths = p, Type = type.Value };
     58                ExploreMatching(writer, instances, explorers.ToArray(), explorers.ToArray(), string.Format("{0}\t{1}\t{2}", rep, feat.Key, type.Key));
     59              }
     60            }
     61          }
     62        }
     63      }
     64
     65
     66      //var training = GenerateData(instances, rrDwExplorer, parallel: true);
    4767      //var standardizer = InstancesStandardizer.CreateAndApply(training);
    48       //var test = GenerateData(instances, prOldExplorer, parallel: true);
     68      //var test = GenerateData(instances, rrDwExplorer, parallel: true);
    4969      //standardizer.Apply(test);
    5070      //PrintMatchResult(Compare(training, test));
     
    6585      //new[] { 300, 1500, 3000, 6000, 15000, 30000, 60000 }.Select(x => new AdaptiveWalkExplorer() { Iterations = x / 10, SampleSize = 10 }).ToArray(),
    6686      //parallel: true);
    67       Console.WriteLine("=== Up/Down Walk ===");
    68       ExploreMatching(instances,
    69       new[] { 300, 1500, 3000, 6000, 15000, 30000, 60000 }.Select(x => new UpDownWalkExplorer() { Iterations = x / 10, SampleSize = 10 }).ToArray(),
    70       new[] { 300, 1500, 3000, 6000, 15000, 30000, 60000 }.Select(x => new UpDownWalkExplorer() { Iterations = x / 10, SampleSize = 10 }).ToArray(),
    71       parallel: true);
    72     }
    73 
    74     private static List<QuadraticAssignmentProblem> GetSomeRandomInstances(int totalInstances, int seed) {
     87      //Console.WriteLine("=== Up/Down Walk ===");
     88      //ExploreMatching(instances,
     89      //new[] { 300, 1500, 3000, 6000, 15000, 30000, 60000 }.Select(x => new UpDownWalkExplorer() { Iterations = x / 10, SampleSize = 10 }).ToArray(),
     90      //new[] { 300, 1500, 3000, 6000, 15000, 30000, 60000 }.Select(x => new UpDownWalkExplorer() { Iterations = x / 10, SampleSize = 10 }).ToArray(),
     91      //parallel: true);
     92    }
     93
     94    private static List<QuadraticAssignmentProblem> GetSomeRandomInstances(int dimension, int totalInstances, int seed) {
    7595      var sync = new object();
    76       var provider = new OneSizeInstanceProvider();
     96      var provider = new OneSizeInstanceProvider(dimension);
    7797      var instances = new List<QuadraticAssignmentProblem>();
    7898      var random = new FastRandom(seed);
     
    87107        }
    88108      });
    89       return instances;
    90     }
    91 
    92     private static HashSet<string> selectedInstances = new HashSet<string>() {
    93       "bur26a", "chr25a", "dre24", "els19", "esc32a", "had20", "kra32", "lipa30a", "lipa30b",
    94       "nug30", "rou20", "scr20", "sko42", "ste36a", "tai25a", "tai25b", "tho30", "wil50",
    95       "RAND-S-6x6-36-25-AFFY-00_rand_rand_bl", "RAND-S-6x6-36-25-AFFY-00_rand_rand_ci"
    96     };
    97     private static List<QuadraticAssignmentProblem> Get20DifferentClasses() {
    98       var sync = new object();
    99 
    100       var qapProviders = ApplicationManager.Manager.GetInstances<ProblemInstanceProvider<QAPData>>().ToList();
    101       var instances = new List<QuadraticAssignmentProblem>();
    102       foreach (var provider in qapProviders) {
    103         if (provider is TaillardQAPInstanceProvider) continue;
    104         Parallel.ForEach(provider.GetDataDescriptors(), desc => {
    105           if (!selectedInstances.Contains(desc.Name)) return;
    106           //if (desc.Name == "esc16f") return;
    107           var qapData = provider.LoadData(desc);
    108           //if (qapData.Dimension < 15 || qapData.Dimension > 150) return;
    109           var qap = new QuadraticAssignmentProblem();
    110           qap.Load(qapData);
    111           lock (sync) {
    112             instances.Add(qap);
    113           }
    114         });
    115       }
    116109      return instances;
    117110    }
     
    155148        TotalCount = totalCount,
    156149        ExactAverageRank = exactRank / (double)totalCount,
    157         ClsAverageRank = clsRank / (double)totalCount
    158       };
    159     }
    160 
    161     private static void PrintMatchResult(MatchResult result) {
    162       Console.WriteLine("{0}\t{1}\t{2}\t{3:F2}\t{4:F2}",
    163         result.ExactCount, result.ClsCount, result.TotalCount,
    164         result.ExactAverageRank, result.ClsAverageRank);
     150        ClsAverageRank = clsRank / (double)totalCount,
     151        TrainingDescriptionEffort = training.Average(x => x.DescriptionEffort),
     152        TestDescriptionEffort = test.Average(x => x.DescriptionEffort)
     153      };
    165154    }
    166155
     
    168157      using (var iter = instances.GetEnumerator()) {
    169158        if (!iter.MoveNext()) return;
    170         Console.WriteLine(string.Join(";", new[] {"Name", "Cls", "Dimension"}
     159        Console.WriteLine(string.Join(";", new[] {"Name", "Cls", "Dimension", "Effort"}
    171160          .Concat(iter.Current != null ? iter.Current.FeatureNames : new [] { "(null)" })));
    172161        do {
     
    178167    private static void PrintInstanceLine(InstanceDescriptor instance) {
    179168      Console.WriteLine(string.Join(";",
    180         new[] {instance.Name, instance.Cls, instance.Dimension.ToString(CultureInfo.CurrentCulture)}
     169        new[] {instance.Name, instance.Cls, instance.Dimension.ToString(CultureInfo.CurrentCulture), instance.DescriptionEffort.ToString(CultureInfo.CurrentCulture)}
    181170          .Concat(instance.FeatureValues.Select(x => x.ToString(CultureInfo.CurrentCulture)))));
    182171    }
    183172
    184     private static void ExploreMatching(List<QuadraticAssignmentProblem> instances, InstanceExplorer[] trainingExplorers, InstanceExplorer[] testExporers, bool parallel = false) {
     173    private static void ExploreMatching(StreamWriter writer, List<QuadraticAssignmentProblem> instances, InstanceExplorer[] trainingExplorers, InstanceExplorer[] testExporers, string info, bool parallel = false) {
    185174      var sync = new object();
    186175
     
    223212          var result = Compare(point.Training.Value.Item2, normalizedTest);
    224213          lock (sync) {
    225             Console.WriteLine("{0}\t{1}\t{2}\t{3:F2}\t{4}\t{5:F2}\t{6}",
    226               point.Training.Key.Effort, point.Test.Key.Effort, result.ExactCount,
    227               result.ExactAverageRank, result.ClsCount, result.ClsAverageRank, result.TotalCount);
     214            string output = string.Format("{0}\t{1}\t{2}\t{3:F2}\t{4}\t{5:F2}\t{6}\t{7}\t{8}\t{9}",
     215              info, point.Training.Key.Effort, point.Test.Key.Effort, result.ExactCount,
     216              result.ExactAverageRank, result.ClsCount, result.ClsAverageRank, result.TotalCount,
     217              result.TrainingDescriptionEffort, result.TestDescriptionEffort);
     218            writer.WriteLine(output);
     219            Console.WriteLine(output);
    228220          }
    229221        });
     
    233225          point.Training.Value.Item1.Apply(normalizedTest);
    234226          var result = Compare(point.Training.Value.Item2, normalizedTest);
    235           Console.WriteLine("{0}\t{1}\t{2}\t{3:F2}\t{4}\t{5:F2}\t{6}",
    236             point.Training.Key.Effort, point.Test.Key.Effort, result.ExactCount,
    237             result.ExactAverageRank, result.ClsCount, result.ClsAverageRank, result.TotalCount);
     227          string output = string.Format("{0}\t{1}\t{2}\t{3:F2}\t{4}\t{5:F2}\t{6}\t{7}\t{8}\t{9}",
     228            info, point.Training.Key.Effort, point.Test.Key.Effort, result.ExactCount,
     229            result.ExactAverageRank, result.ClsCount, result.ClsAverageRank, result.TotalCount,
     230            result.TrainingDescriptionEffort, result.TestDescriptionEffort);
     231          writer.WriteLine(output);
     232          Console.WriteLine(output);
    238233        }
    239234      }
     
    246241      public double ExactAverageRank { get; set; }
    247242      public double ClsAverageRank { get; set; }
     243
     244      public double TrainingDescriptionEffort { get; set; }
     245      public double TestDescriptionEffort { get; set; }
    248246    }
    249247  }
Note: See TracChangeset for help on using the changeset viewer.