Free cookie consent management tool by TermsFeed Policy Generator

Changeset 14776


Ignore:
Timestamp:
03/22/17 16:52:36 (8 years ago)
Author:
abeham
Message:

#2457: working on MemPR integration

Location:
branches/PerformanceComparison
Files:
5 added
5 deleted
21 edited
5 copied
1 moved

Legend:

Unmodified
Added
Removed
  • branches/PerformanceComparison/HeuristicLab.Algorithms.MemPR/3.3/Binary/SolutionModel/Univariate/BiasedModelTrainer.cs

    r14563 r14776  
    2626using HeuristicLab.Data;
    2727using HeuristicLab.Encodings.BinaryVectorEncoding;
     28using HeuristicLab.Encodings.BinaryVectorEncoding.SolutionModel;
    2829using HeuristicLab.Optimization;
    2930using HeuristicLab.Parameters;
     
    3132
    3233namespace HeuristicLab.Algorithms.MemPR.Binary.SolutionModel.Univariate {
     34  public enum ModelBiasOptions { Rank, Fitness }
     35
    3336  [Item("Biased Univariate Model Trainer (binary)", "", ExcludeGenericTypeInfo = true)]
    3437  [StorableClass]
     
    6063
    6164    public void TrainModel(TContext context) {
    62       context.Model = Trainer.TrainBiased(ModelBias, context.Random, context.Maximization, context.Population.Select(x => x.Solution), context.Population.Select(x => x.Fitness));
     65      var biasType = modelBiasParameter.Value.Value;
     66      switch (biasType) {
     67        case ModelBiasOptions.Fitness:
     68          context.Model = UnivariateModelTrainer.TrainWithFitnessBias(context.Random, context.Maximization,
     69            context.Population.Select(x => x.Solution),
     70            context.Population.Select(x => x.Fitness));
     71          break;
     72        case ModelBiasOptions.Rank:
     73          context.Model = UnivariateModelTrainer.TrainWithRankBias(context.Random, context.Maximization,
     74            context.Population.Select(x => x.Solution),
     75            context.Population.Select(x => x.Fitness));
     76          break;
     77      }
    6378    }
    6479  }
  • branches/PerformanceComparison/HeuristicLab.Algorithms.MemPR/3.3/Binary/SolutionModel/Univariate/UnbiasedModelTrainer.cs

    r14563 r14776  
    2525using HeuristicLab.Core;
    2626using HeuristicLab.Encodings.BinaryVectorEncoding;
     27using HeuristicLab.Encodings.BinaryVectorEncoding.SolutionModel;
    2728using HeuristicLab.Optimization;
    2829using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    4950
    5051    public void TrainModel(TContext context) {
    51       context.Model = Trainer.TrainUnbiased(context.Random, context.Population.Select(x => x.Solution));
     52      context.Model = UnivariateModelTrainer.TrainUnbiased(context.Random, context.Population.Select(x => x.Solution));
    5253    }
    5354  }
  • branches/PerformanceComparison/HeuristicLab.Algorithms.MemPR/3.3/HeuristicLab.Algorithms.MemPR-3.3.csproj

    r14691 r14776  
    102102      <Private>False</Private>
    103103    </Reference>
    104     <Reference Include="HeuristicLab.Encodings.BinaryVectorEncoding-3.3">
    105       <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Encodings.BinaryVectorEncoding-3.3.dll</HintPath>
    106       <Private>False</Private>
    107     </Reference>
    108     <Reference Include="HeuristicLab.Encodings.LinearLinkageEncoding-3.4">
    109       <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Encodings.LinearLinkageEncoding-3.4.dll</HintPath>
    110       <Private>False</Private>
    111     </Reference>
    112104    <Reference Include="HeuristicLab.Operators-3.3">
    113105      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Operators-3.3.dll</HintPath>
     
    165157    <Compile Include="Binary\LocalSearch\ExhaustiveBitflip.cs" />
    166158    <Compile Include="Binary\LocalSearch\StaticAPI\ExhaustiveBitflip.cs" />
    167     <Compile Include="Binary\SolutionModel\Univariate\StaticAPI\Trainer.cs" />
    168     <Compile Include="Binary\SolutionModel\Univariate\UnivariateSolutionModel.cs" />
    169159    <Compile Include="Binary\SolutionModel\Univariate\BiasedModelTrainer.cs" />
    170160    <Compile Include="Binary\SolutionModel\Univariate\UnbiasedModelTrainer.cs" />
     
    179169    <Compile Include="LinearLinkage\SolutionModel\Univariate\UnivariateSolutionModel.cs" />
    180170    <Compile Include="MemPRAlgorithm.cs" />
     171    <Compile Include="Permutation\InversionPathRelinker.cs" />
     172    <Compile Include="Permutation\LocalSearch\ExhaustiveInversionImprover.cs" />
    181173    <Compile Include="Permutation\PermutationMemPR.cs" />
    182174    <Compile Include="Permutation\PermutationMemPRContext.cs" />
     
    212204      <Private>False</Private>
    213205    </ProjectReference>
     206    <ProjectReference Include="..\..\HeuristicLab.Encodings.BinaryVectorEncoding\3.3\HeuristicLab.Encodings.BinaryVectorEncoding-3.3.csproj">
     207      <Project>{66d249c3-a01d-42a8-82a2-919bc8ec3d83}</Project>
     208      <Name>HeuristicLab.Encodings.BinaryVectorEncoding-3.3</Name>
     209      <Private>False</Private>
     210    </ProjectReference>
     211    <ProjectReference Include="..\..\HeuristicLab.Encodings.LinearLinkageEncoding\3.4\HeuristicLab.Encodings.LinearLinkageEncoding-3.4.csproj">
     212      <Project>{be698769-975a-429e-828c-72bb2b6182c8}</Project>
     213      <Name>HeuristicLab.Encodings.LinearLinkageEncoding-3.4</Name>
     214      <Private>False</Private>
     215    </ProjectReference>
    214216    <ProjectReference Include="..\..\HeuristicLab.Encodings.PermutationEncoding\3.3\HeuristicLab.Encodings.PermutationEncoding-3.3.csproj">
    215217      <Project>{dbecb8b0-b166-4133-baf1-ed67c3fd7fca}</Project>
  • branches/PerformanceComparison/HeuristicLab.Algorithms.MemPR/3.3/Interfaces/Interfaces.cs

    r14690 r14776  
    3737   * ********************************************* *
    3838   *************************************************/
    39 
    40   public interface ISolutionModel<TSolution> : IItem {
    41     TSolution Sample();
    42   }
    4339
    4440  public interface ISolutionSubspace<TSolution> : IItem { }
     
    8985      where TProblem : class, ISingleObjectiveHeuristicOptimizationProblem {
    9086    IEnumerable<ISingleObjectiveSolutionScope<TSolution>> Population { get; }
     87    int PopulationCount { get; }
    9188  }
    9289
  • branches/PerformanceComparison/HeuristicLab.Algorithms.MemPR/3.3/LinearLinkage/SolutionModel/Univariate/StaticAPI/Trainer.cs

    r14544 r14776  
    2121
    2222using System.Collections.Generic;
    23 using HeuristicLab.Algorithms.MemPR.Interfaces;
    2423using HeuristicLab.Core;
    2524using HeuristicLab.Encodings.LinearLinkageEncoding;
     25using HeuristicLab.Optimization;
    2626
    2727namespace HeuristicLab.Algorithms.MemPR.Grouping.SolutionModel.Univariate {
  • branches/PerformanceComparison/HeuristicLab.Algorithms.MemPR/3.3/LinearLinkage/SolutionModel/Univariate/UnivariateSolutionModel.cs

    r14544 r14776  
    2222using System;
    2323using System.Collections.Generic;
    24 using HeuristicLab.Algorithms.MemPR.Interfaces;
    2524using HeuristicLab.Common;
    2625using HeuristicLab.Core;
    2726using HeuristicLab.Data;
    2827using HeuristicLab.Encodings.LinearLinkageEncoding;
     28using HeuristicLab.Optimization;
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3030
  • branches/PerformanceComparison/HeuristicLab.Algorithms.MemPR/3.3/Permutation/SolutionModel/Univariate/StaticAPI/Trainer.cs

    r14496 r14776  
    2222using System;
    2323using System.Collections.Generic;
    24 using HeuristicLab.Algorithms.MemPR.Interfaces;
    2524using HeuristicLab.Core;
    2625using HeuristicLab.Encodings.PermutationEncoding;
     26using HeuristicLab.Optimization;
    2727
    2828namespace HeuristicLab.Algorithms.MemPR.Permutation.SolutionModel.Univariate {
  • branches/PerformanceComparison/HeuristicLab.Analysis

  • branches/PerformanceComparison/HeuristicLab.Analysis.FitnessLandscape/3.3/CharacteristicCalculator/AdaptiveWalkCalculator.cs

    r13920 r14776  
    5858      characteristics = cloner.Clone(original.characteristics);
    5959    }
    60     public AdaptiveWalkCalculator() {
     60    public AdaptiveWalkCalculator() : this(new AdaptiveWalk()) { }
     61    public AdaptiveWalkCalculator(AdaptiveWalk walker) {
    6162      Name = ItemName;
    6263      Description = ItemDescription;
    63       walker = new AdaptiveWalk();
     64      this.walker = walker;
    6465      characteristics = new CheckedItemList<StringValue>(
    6566        new[] { "AutoCorrelation1", "CorrelationLength", "InformationContent",
    66         "PartialInformationContent", "DensityBasinInformation", "InformationStability", 
     67        "PartialInformationContent", "DensityBasinInformation", "InformationStability",
    6768        "Diversity", "Regularity", "TotalEntropy", "PeakInformationContent",
    6869        "PeakDensityBasinInformation" }.Select(x => new StringValue(x)));
  • branches/PerformanceComparison/HeuristicLab.Analysis/3.3/HeuristicLab.Analysis-3.3.csproj

    r13794 r14776  
    187187    <Compile Include="BestNScopesSolutionAnalyzer.cs" />
    188188    <Compile Include="BestScopeSolutionAnalyzer.cs" />
     189    <Compile Include="DataVisualization\GanttData.cs" />
    189190    <Compile Include="Clustering\CkMeans1D.cs">
    190191      <SubType>Code</SubType>
  • branches/PerformanceComparison/HeuristicLab.Analysis/3.3/QualityAnalysis/ExpectedRuntimeHelper.cs

    r13803 r14776  
    3030      if (successful.Count > 0) {
    3131        var succAvg = successful.Average();
    32         var succDev = successful.StandardDeviation();
     32        var succDev = successful.StandardDeviation() + 1e-7;
    3333        successful.RemoveAll(x => x < succAvg - 2 * succDev);
    3434        unsuccessful.RemoveAll(x => x < succAvg - 2 * succDev);
  • branches/PerformanceComparison/HeuristicLab.Encodings.BinaryVectorEncoding/3.3

    • Property svn:ignore
      •  

        old new  
        55*.vs10x
        66Plugin.cs
         7*.DotSettings
  • branches/PerformanceComparison/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/HeuristicLab.Encodings.BinaryVectorEncoding-3.3.csproj

    r14660 r14776  
    9999  </PropertyGroup>
    100100  <ItemGroup>
     101    <Reference Include="HeuristicLab.Collections-3.3">
     102      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Collections-3.3.dll</HintPath>
     103      <Private>False</Private>
     104    </Reference>
     105    <Reference Include="HeuristicLab.Common-3.3">
     106      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath>
     107      <Private>False</Private>
     108    </Reference>
     109    <Reference Include="HeuristicLab.Core-3.3">
     110      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath>
     111      <Private>False</Private>
     112    </Reference>
     113    <Reference Include="HeuristicLab.Data-3.3">
     114      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Data-3.3.dll</HintPath>
     115      <Private>False</Private>
     116    </Reference>
     117    <Reference Include="HeuristicLab.Operators-3.3">
     118      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Operators-3.3.dll</HintPath>
     119      <Private>False</Private>
     120    </Reference>
     121    <Reference Include="HeuristicLab.Optimization.Operators-3.3">
     122      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Optimization.Operators-3.3.dll</HintPath>
     123      <Private>False</Private>
     124    </Reference>
     125    <Reference Include="HeuristicLab.Parameters-3.3">
     126      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Parameters-3.3.dll</HintPath>
     127      <Private>False</Private>
     128    </Reference>
     129    <Reference Include="HeuristicLab.Persistence-3.3">
     130      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Persistence-3.3.dll</HintPath>
     131      <Private>False</Private>
     132    </Reference>
     133    <Reference Include="HeuristicLab.PluginInfrastructure-3.3">
     134      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
     135      <Private>False</Private>
     136    </Reference>
    101137    <Reference Include="System" />
    102138    <Reference Include="System.Core">
     
    153189    <Compile Include="Properties\AssemblyInfo.cs" />
    154190    <Compile Include="ShakingOperators\BinaryVectorShakingOperator.cs" />
    155   </ItemGroup>
    156   <ItemGroup>
    157     <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj">
    158       <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project>
    159       <Name>HeuristicLab.Collections-3.3</Name>
    160       <Private>False</Private>
    161     </ProjectReference>
    162     <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj">
    163       <Project>{A9AD58B9-3EF9-4CC1-97E5-8D909039FF5C}</Project>
    164       <Name>HeuristicLab.Common-3.3</Name>
    165       <Private>False</Private>
    166     </ProjectReference>
    167     <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj">
    168       <Project>{C36BD924-A541-4A00-AFA8-41701378DDC5}</Project>
    169       <Name>HeuristicLab.Core-3.3</Name>
    170       <Private>False</Private>
    171     </ProjectReference>
    172     <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj">
    173       <Project>{BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}</Project>
    174       <Name>HeuristicLab.Data-3.3</Name>
    175       <Private>False</Private>
    176     </ProjectReference>
    177     <ProjectReference Include="..\..\HeuristicLab.Operators\3.3\HeuristicLab.Operators-3.3.csproj">
    178       <Project>{23DA7FF4-D5B8-41B6-AA96-F0561D24F3EE}</Project>
    179       <Name>HeuristicLab.Operators-3.3</Name>
    180       <Private>False</Private>
    181     </ProjectReference>
    182     <ProjectReference Include="..\..\HeuristicLab.Optimization.Operators\3.3\HeuristicLab.Optimization.Operators-3.3.csproj">
    183       <Project>{25087811-F74C-4128-BC86-8324271DA13E}</Project>
    184       <Name>HeuristicLab.Optimization.Operators-3.3</Name>
    185       <Private>False</Private>
    186     </ProjectReference>
     191    <Compile Include="SolutionModel\Univariate\UnivariateModelTrainer.cs" />
     192    <Compile Include="SolutionModel\Univariate\UnivariateModel.cs" />
     193    <Compile Include="SolutionModel\SolutionSamplingOperator.cs" />
     194    <Compile Include="SolutionModel\Univariate\UnivariateModelTrainingOperator.cs" />
     195  </ItemGroup>
     196  <ItemGroup>
    187197    <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj">
    188198      <Project>{14AB8D24-25BC-400C-A846-4627AA945192}</Project>
    189199      <Name>HeuristicLab.Optimization-3.3</Name>
    190       <Private>False</Private>
    191     </ProjectReference>
    192     <ProjectReference Include="..\..\HeuristicLab.Parameters\3.3\HeuristicLab.Parameters-3.3.csproj">
    193       <Project>{56F9106A-079F-4C61-92F6-86A84C2D84B7}</Project>
    194       <Name>HeuristicLab.Parameters-3.3</Name>
    195       <Private>False</Private>
    196     </ProjectReference>
    197     <ProjectReference Include="..\..\HeuristicLab.Persistence\3.3\HeuristicLab.Persistence-3.3.csproj">
    198       <Project>{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}</Project>
    199       <Name>HeuristicLab.Persistence-3.3</Name>
    200       <Private>False</Private>
    201     </ProjectReference>
    202     <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj">
    203       <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>
    204       <Name>HeuristicLab.PluginInfrastructure-3.3</Name>
    205200      <Private>False</Private>
    206201    </ProjectReference>
  • branches/PerformanceComparison/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/SolutionModel/Univariate/UnivariateModel.cs

    r14685 r14776  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    2422using System.Linq;
    25 using HeuristicLab.Algorithms.MemPR.Interfaces;
    2623using HeuristicLab.Common;
    2724using HeuristicLab.Core;
    2825using HeuristicLab.Data;
    29 using HeuristicLab.Encodings.BinaryVectorEncoding;
     26using HeuristicLab.Optimization;
    3027using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    31 using HeuristicLab.Random;
    3228
    33 namespace HeuristicLab.Algorithms.MemPR.Binary.SolutionModel.Univariate {
     29namespace HeuristicLab.Encodings.BinaryVectorEncoding.SolutionModel {
    3430  [Item("Univariate solution model (binary)", "")]
    3531  [StorableClass]
     
    6763      return vec;
    6864    }
    69 
    70     public static ISolutionModel<BinaryVector> CreateWithoutBias(IRandom random, IEnumerable<BinaryVector> population) {
    71       double[] model = null;
    72       var popSize = 0;
    73       foreach (var p in population) {
    74         popSize++;
    75         if (model == null) model = new double[p.Length];
    76         for (var x = 0; x < model.Length; x++) {
    77           if (p[x]) model[x]++;
    78         }
    79       }
    80       if (model == null) throw new ArgumentException("Cannot train model from empty population.");
    81       // normalize to [0;1]
    82       var factor = 1.0 / popSize;
    83       for (var x = 0; x < model.Length; x++) {
    84         model[x] *= factor;
    85       }
    86       return new UnivariateModel(random, model);
    87     }
    88 
    89     public static ISolutionModel<BinaryVector> CreateWithRankBias(IRandom random, bool maximization, IEnumerable<BinaryVector> population, IEnumerable<double> qualities) {
    90       var popSize = 0;
    91 
    92       double[] model = null;
    93       var pop = population.Zip(qualities, (b, q) => new { Solution = b, Fitness = q });
    94       foreach (var ind in maximization ? pop.OrderBy(x => x.Fitness) : pop.OrderByDescending(x => x.Fitness)) {
    95         // from worst to best, worst solution has 1 vote, best solution N votes
    96         popSize++;
    97         if (model == null) model = new double[ind.Solution.Length];
    98         for (var x = 0; x < model.Length; x++) {
    99           if (ind.Solution[x]) model[x] += popSize;
    100         }
    101       }
    102       if (model == null) throw new ArgumentException("Cannot train model from empty population.");
    103       // normalize to [0;1]
    104       var factor = 2.0 / (popSize + 1);
    105       for (var i = 0; i < model.Length; i++) {
    106         model[i] *= factor / popSize;
    107       }
    108       return new UnivariateModel(random, model);
    109     }
    110 
    111     public static ISolutionModel<BinaryVector> CreateWithFitnessBias(IRandom random, bool maximization, IEnumerable<BinaryVector> population, IEnumerable<double> qualities) {
    112       var proportions = Util.Auxiliary.PrepareProportional(qualities, true, !maximization);
    113       var factor = 1.0 / proportions.Sum();
    114       double[] model = null;
    115       foreach (var ind in population.Zip(proportions, (p, q) => new { Solution = p, Proportion = q })) {
    116         if (model == null) model = new double[ind.Solution.Length];
    117         for (var x = 0; x < model.Length; x++) {
    118           if (ind.Solution[x]) model[x] += ind.Proportion * factor;
    119         }
    120       }
    121       if (model == null) throw new ArgumentException("Cannot train model from empty population.");
    122       return new UnivariateModel(random, model);
    123     }
    12465  }
    12566}
  • branches/PerformanceComparison/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/SolutionModel/Univariate/UnivariateModelTrainer.cs

    r14685 r14776  
    2222using System;
    2323using System.Collections.Generic;
    24 using HeuristicLab.Algorithms.MemPR.Interfaces;
     24using System.Linq;
    2525using HeuristicLab.Core;
    26 using HeuristicLab.Encodings.BinaryVectorEncoding;
    2726
    28 namespace HeuristicLab.Algorithms.MemPR.Binary.SolutionModel.Univariate {
    29   public enum ModelBiasOptions { Rank, Fitness }
     27namespace HeuristicLab.Encodings.BinaryVectorEncoding.SolutionModel {
     28  public static class UnivariateModelTrainer {
     29    /// <summary>
     30    /// Creates a univariate sampling model out of a ranked population.
     31    /// The first solution in <paramref name="rankedPopulation"/> is the
     32    /// highest influential one, the last solution has the least influence.
     33    /// </summary>
     34    /// <param name="random">The model is stochastic and will use this RNG for sampling.</param>
     35    /// <param name="maximization">Whether higher or lower qualities are better</param>
     36    /// <param name="population">The population that is ranked from highest influential to least influential, e.g. best to worst.</param>
     37    /// <param name="qualities">The solution quality of the respective solution.</param>
     38    /// <returns>The sampling model which is created with the given population.</returns>
     39    public static UnivariateModel TrainWithRankBias(IRandom random, bool maximization, IEnumerable<BinaryVector> population, IEnumerable<double> qualities) {
     40      var popSize = 0;
     41      double[] model = null;
     42      var pop = population.Zip(qualities, (b, q) => new { Solution = b, Fitness = q });
     43      foreach (var ind in maximization ? pop.OrderBy(x => x.Fitness) : pop.OrderByDescending(x => x.Fitness)) {
     44        // from worst to best, worst solution has 1 vote, best solution N votes
     45        popSize++;
     46        if (model == null) model = new double[ind.Solution.Length];
     47        for (var x = 0; x < model.Length; x++) {
     48          if (ind.Solution[x]) model[x] += popSize;
     49        }
     50      }
     51      if (model == null) throw new ArgumentException("Cannot train model from empty population.");
     52      // normalize to [0;1]
     53      var factor = 2.0 / (popSize + 1);
     54      for (var i = 0; i < model.Length; i++) {
     55        model[i] *= factor / popSize;
     56      }
     57      return new UnivariateModel(random, model);
     58    }
    3059
    31   public static class Trainer {
    32     public static ISolutionModel<BinaryVector> TrainBiased(ModelBiasOptions modelBias, IRandom random, bool maximization, IEnumerable<BinaryVector> population, IEnumerable<double> qualities) {
    33       switch (modelBias) {
    34         case ModelBiasOptions.Rank:
    35           return UnivariateModel.CreateWithRankBias(random, maximization, population, qualities);
    36         case ModelBiasOptions.Fitness:
    37           return UnivariateModel.CreateWithFitnessBias(random, maximization, population, qualities);
    38         default:
    39           throw new InvalidOperationException(string.Format("Unknown bias option {0}", modelBias));
     60    /// <summary>
     61    /// Creates a univariate sampling model out of solutions and their given fitness.
     62    /// The best solution's influence is proportional to its fitness, while the worst
     63    /// solution does not have an influence at all (except if the fitness of worst and
     64    /// best are equal).
     65    /// </summary>
     66    /// <param name="random">The model is stochastic and makes use of this RNG instance for sampling.</param>
     67    /// <param name="maximization">Whether higher fitness values are better or lower ones.</param>
     68    /// <param name="population">The solutions that will be used to create the model.</param>
     69    /// <param name="qualities">The solutions' associated qualities.</param>
     70    /// <returns>The sampling model which is created with the given population.</returns>
     71    public static UnivariateModel TrainWithFitnessBias(IRandom random, bool maximization, IEnumerable<BinaryVector> population, IEnumerable<double> qualities) {
     72      var proportions = PrepareProportional(qualities, true, !maximization);
     73      var factor = 1.0 / proportions.Sum();
     74      double[] model = null;
     75      foreach (var ind in population.Zip(proportions, (p, q) => new { Solution = p, Proportion = q })) {
     76        if (model == null) model = new double[ind.Solution.Length];
     77        for (var x = 0; x < model.Length; x++) {
     78          if (ind.Solution[x]) model[x] += ind.Proportion * factor;
     79        }
     80      }
     81      if (model == null) throw new ArgumentException("Cannot train model from empty population.");
     82      return new UnivariateModel(random, model);
     83    }
     84
     85    /// <summary>
     86    /// Creates a univariate sampling model out of solutions. Each of the solutions
     87    /// has the same influence on the model.
     88    /// </summary>
     89    /// <param name="random">The model is stochastic and will make use of this RNG instance.</param>
     90    /// <param name="population">The solutions that are used to create the model.</param>
     91    /// <returns>The model created from the population.</returns>
     92    public static UnivariateModel TrainUnbiased(IRandom random, IEnumerable<BinaryVector> population) {
     93      double[] model = null;
     94      var popSize = 0;
     95      foreach (var p in population) {
     96        popSize++;
     97        if (model == null) model = new double[p.Length];
     98        for (var x = 0; x < model.Length; x++) {
     99          if (p[x]) model[x]++;
     100        }
     101      }
     102      if (model == null) throw new ArgumentException("Cannot train model from empty population.");
     103      // normalize to [0;1]
     104      var factor = 1.0 / popSize;
     105      for (var x = 0; x < model.Length; x++) {
     106        model[x] *= factor;
     107      }
     108      return new UnivariateModel(random, model);
     109    }
     110
     111    // TODO: make PrepareProportional public in EnumerableExtensions
     112    private static double[] PrepareProportional(IEnumerable<double> weights, bool windowing, bool inverseProportional) {
     113      double maxValue = double.MinValue, minValue = double.MaxValue;
     114      double[] valueArray = weights.ToArray();
     115
     116      for (int i = 0; i < valueArray.Length; i++) {
     117        if (valueArray[i] > maxValue) maxValue = valueArray[i];
     118        if (valueArray[i] < minValue) minValue = valueArray[i];
     119      }
     120      if (minValue == maxValue) {  // all values are equal
     121        for (int i = 0; i < valueArray.Length; i++) {
     122          valueArray[i] = 1.0;
     123        }
     124      } else {
     125        if (windowing) {
     126          if (inverseProportional) InverseProportionalScale(valueArray, maxValue);
     127          else ProportionalScale(valueArray, minValue);
     128        } else {
     129          if (minValue < 0.0) throw new InvalidOperationException("Proportional selection without windowing does not work with values < 0.");
     130          if (inverseProportional) InverseProportionalScale(valueArray, 2 * maxValue);
     131        }
     132      }
     133      return valueArray;
     134    }
     135    private static void ProportionalScale(double[] values, double minValue) {
     136      for (int i = 0; i < values.Length; i++) {
     137        values[i] = values[i] - minValue;
    40138      }
    41139    }
    42 
    43     public static ISolutionModel<BinaryVector> TrainUnbiased(IRandom random, IEnumerable<BinaryVector> population) {
    44       return UnivariateModel.CreateWithoutBias(random, population);
     140    private static void InverseProportionalScale(double[] values, double maxValue) {
     141      for (int i = 0; i < values.Length; i++) {
     142        values[i] = maxValue - values[i];
     143      }
    45144    }
    46145  }
  • branches/PerformanceComparison/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/HeuristicLab.Encodings.LinearLinkageEncoding-3.4.csproj

    r14663 r14776  
    8888  </PropertyGroup>
    8989  <ItemGroup>
    90     <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj">
    91       <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project>
    92       <Name>HeuristicLab.Collections-3.3</Name>
    93       <Private>False</Private>
    94     </ProjectReference>
    95     <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj">
    96       <Project>{A9AD58B9-3EF9-4CC1-97E5-8D909039FF5C}</Project>
    97       <Name>HeuristicLab.Common-3.3</Name>
    98       <Private>False</Private>
    99     </ProjectReference>
    100     <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj">
    101       <Project>{C36BD924-A541-4A00-AFA8-41701378DDC5}</Project>
    102       <Name>HeuristicLab.Core-3.3</Name>
    103       <Private>False</Private>
    104     </ProjectReference>
    105     <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj">
    106       <Project>{BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}</Project>
    107       <Name>HeuristicLab.Data-3.3</Name>
    108       <Private>False</Private>
    109     </ProjectReference>
    110     <ProjectReference Include="..\..\HeuristicLab.Operators\3.3\HeuristicLab.Operators-3.3.csproj">
    111       <Project>{23DA7FF4-D5B8-41B6-AA96-F0561D24F3EE}</Project>
    112       <Name>HeuristicLab.Operators-3.3</Name>
    113       <Private>False</Private>
    114     </ProjectReference>
    115     <ProjectReference Include="..\..\HeuristicLab.Optimization.Operators\3.3\HeuristicLab.Optimization.Operators-3.3.csproj">
    116       <Project>{25087811-F74C-4128-BC86-8324271DA13E}</Project>
    117       <Name>HeuristicLab.Optimization.Operators-3.3</Name>
    118       <Private>False</Private>
    119     </ProjectReference>
    12090    <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj">
    12191      <Project>{14AB8D24-25BC-400C-A846-4627AA945192}</Project>
     
    12393      <Private>False</Private>
    12494    </ProjectReference>
    125     <ProjectReference Include="..\..\HeuristicLab.Parameters\3.3\HeuristicLab.Parameters-3.3.csproj">
    126       <Project>{56F9106A-079F-4C61-92F6-86A84C2D84B7}</Project>
    127       <Name>HeuristicLab.Parameters-3.3</Name>
    128       <Private>False</Private>
    129     </ProjectReference>
    130     <ProjectReference Include="..\..\HeuristicLab.Persistence\3.3\HeuristicLab.Persistence-3.3.csproj">
    131       <Project>{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}</Project>
    132       <Name>HeuristicLab.Persistence-3.3</Name>
    133       <Private>False</Private>
    134     </ProjectReference>
    135     <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj">
    136       <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>
    137       <Name>HeuristicLab.PluginInfrastructure-3.3</Name>
    138       <Private>False</Private>
    139     </ProjectReference>
    140     <ProjectReference Include="..\..\HeuristicLab.Random\3.3\HeuristicLab.Random-3.3.csproj">
    141       <Project>{f4539fb6-4708-40c9-be64-0a1390aea197}</Project>
    142       <Name>HeuristicLab.Random-3.3</Name>
    143       <Private>False</Private>
    144     </ProjectReference>
    14595  </ItemGroup>
    14696  <ItemGroup>
     97    <Reference Include="HeuristicLab.Collections-3.3">
     98      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Collections-3.3.dll</HintPath>
     99      <Private>False</Private>
     100    </Reference>
     101    <Reference Include="HeuristicLab.Common-3.3">
     102      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath>
     103      <Private>False</Private>
     104    </Reference>
     105    <Reference Include="HeuristicLab.Core-3.3">
     106      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath>
     107      <Private>False</Private>
     108    </Reference>
     109    <Reference Include="HeuristicLab.Data-3.3">
     110      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Data-3.3.dll</HintPath>
     111      <Private>False</Private>
     112    </Reference>
     113    <Reference Include="HeuristicLab.Operators-3.3">
     114      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Operators-3.3.dll</HintPath>
     115      <Private>False</Private>
     116    </Reference>
     117    <Reference Include="HeuristicLab.Optimization.Operators-3.3">
     118      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Optimization.Operators-3.3.dll</HintPath>
     119      <Private>False</Private>
     120    </Reference>
     121    <Reference Include="HeuristicLab.Parameters-3.3">
     122      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Parameters-3.3.dll</HintPath>
     123      <Private>False</Private>
     124    </Reference>
     125    <Reference Include="HeuristicLab.Persistence-3.3">
     126      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Persistence-3.3.dll</HintPath>
     127      <Private>False</Private>
     128    </Reference>
     129    <Reference Include="HeuristicLab.PluginInfrastructure-3.3">
     130      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
     131      <Private>False</Private>
     132    </Reference>
     133    <Reference Include="HeuristicLab.Random-3.3">
     134      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Random-3.3.dll</HintPath>
     135      <Private>False</Private>
     136    </Reference>
    147137    <Reference Include="System" />
    148138    <Reference Include="System.Core" />
  • branches/PerformanceComparison/HeuristicLab.Optimization.Views

  • branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionRLDView.cs

    r14665 r14776  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    4242    private List<Series> invisibleTargetSeries;
    4343
    44     private const string AllRuns = "All Runs";
     44    private const string AllInstances = "All Instances";
    4545
    4646    private static readonly Color[] colors = new[] {
     
    223223      var groupings = Content.ParameterNames.OrderBy(x => x).ToArray();
    224224      groupComboBox.Items.Clear();
    225       groupComboBox.Items.Add(AllRuns);
     225      groupComboBox.Items.Add(AllInstances);
    226226      groupComboBox.Items.AddRange(groupings);
    227227      if (selectedGroupItem != null && groupComboBox.Items.Contains(selectedGroupItem)) {
     
    241241
    242242      var selectedProblemItem = (ProblemInstance)problemComboBox.SelectedItem;
     243      problemComboBox.DataSource = null;
     244      problemComboBox.Items.Clear();
    243245      problems.Clear();
    244246      problems.Add(ProblemInstance.MatchAll);
     247      problemComboBox.DataSource = new BindingSource() { DataSource = problems };
     248      problemComboBox.DataBindings.DefaultDataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged;
    245249      if (problems[0].Equals(selectedProblemItem)) problemComboBox.SelectedItem = problems[0];
    246250      foreach (var p in problemDict.ToList()) {
     
    282286    }
    283287
    284     private Dictionary<string, Dictionary<ProblemInstance, List<IRun>>> GroupRuns() {
    285       var groupedRuns = new Dictionary<string, Dictionary<ProblemInstance, List<IRun>>>();
    286 
     288    private IEnumerable<AlgorithmInstance> GroupRuns() {
    287289      var table = (string)dataTableComboBox.SelectedItem;
    288       if (string.IsNullOrEmpty(table)) return groupedRuns;
     290      if (string.IsNullOrEmpty(table)) yield break;
    289291
    290292      var selectedGroup = (string)groupComboBox.SelectedItem;
    291       if (string.IsNullOrEmpty(selectedGroup)) return groupedRuns;
     293      if (string.IsNullOrEmpty(selectedGroup)) yield break;
    292294
    293295      var selectedProblem = (ProblemInstance)problemComboBox.SelectedItem;
    294       if (selectedProblem == null) return groupedRuns;
     296      if (selectedProblem == null) yield break;
    295297     
    296298      foreach (var x in (from r in Content
    297                          where (selectedGroup == AllRuns || r.Parameters.ContainsKey(selectedGroup))
     299                         where (selectedGroup == AllInstances || r.Parameters.ContainsKey(selectedGroup))
    298300                           && selectedProblem.Match(r)
    299301                           && r.Results.ContainsKey(table)
    300302                           && r.Visible
    301                          let key = selectedGroup == AllRuns ? AllRuns : r.Parameters[selectedGroup].ToString()
     303                         let key = selectedGroup == AllInstances ? AllInstances : r.Parameters[selectedGroup].ToString()
    302304                         group r by key into g
    303                          select Tuple.Create(g.Key, g.ToList()))) {
    304         var pDict = problems.ToDictionary(r => r, _ => new List<IRun>());
    305         foreach (var y in x.Item2) {
    306           var pd = new ProblemInstance(y);
    307           List<IRun> l;
    308           if (pDict.TryGetValue(pd, out l)) l.Add(y);
    309         }
    310         groupedRuns[x.Item1] = pDict.Where(a => a.Value.Count > 0).ToDictionary(a => a.Key, a => a.Value);
    311       }
    312 
    313       return groupedRuns;
     305                         select new AlgorithmInstance(g.Key, g, problems))) {
     306        yield return x;
     307      }
    314308    }
    315309
     
    326320      if (targets == null) GenerateDefaultTargets();
    327321
    328       var groupedRuns = GroupRuns();
    329       if (groupedRuns.Count == 0) return;
     322      var algInstances = GroupRuns().ToList();
     323      if (algInstances.Count == 0) return;
    330324
    331325      var xAxisTitles = new HashSet<string>();
     
    337331      // how many targets have been left open at the point when the run ended
    338332      var misses = new Dictionary<string, SortedList<double, int>>();
     333      var totalRuns = new Dictionary<string, int>();
    339334
    340335      var aggregate = aggregateTargetsCheckBox.Checked;
    341336      double minEff = double.MaxValue, maxEff = double.MinValue;
    342       var noRuns = 0;
    343       foreach (var group in groupedRuns) {
     337      foreach (var alg in algInstances) {
     338        var noRuns = 0;
    344339        SortedList<double, int> epdfHits = null, epdfMisses = null;
    345340        if (aggregate) {
    346           hits[group.Key] = epdfHits = new SortedList<double, int>();
    347           misses[group.Key] = epdfMisses = new SortedList<double, int>();
    348         }
    349         foreach (var problem in group.Value) {
    350           var max = problem.Key.IsMaximization();
    351           var absTargets = GetAbsoluteTargets(problem.Key).ToArray();
    352           foreach (var run in problem.Value) {
     341          hits[alg.Name] = epdfHits = new SortedList<double, int>();
     342          misses[alg.Name] = epdfMisses = new SortedList<double, int>();
     343        }
     344        foreach (var problem in alg.GetProblemInstances()) {
     345          var max = problem.IsMaximization();
     346          var absTargets = GetAbsoluteTargets(problem).ToArray();
     347          foreach (var run in alg.GetRuns(problem)) {
    353348            noRuns++;
    354349            var resultsTable = (IndexedDataTable<double>)run.Results[table];
     
    361356              var e = efforts[idx];
    362357              if (!aggregate) {
    363                 var key = group.Key + "@" + (targetsAreRelative
    364                   ? (targets[idx] * 100).ToString(CultureInfo.CurrentCulture.NumberFormat) + "%"
    365                   : targets[idx].ToString(CultureInfo.CurrentCulture.NumberFormat));
     358                var key = alg.Name + "@" + (targetsAreRelative
     359                            ? (targets[idx] * 100).ToString(CultureInfo.CurrentCulture.NumberFormat) + "%"
     360                            : targets[idx].ToString(CultureInfo.CurrentCulture.NumberFormat));
    366361                if (!hits.TryGetValue(key, out epdfHits))
    367362                  hits[key] = epdfHits = new SortedList<double, int>();
    368363                if (!misses.TryGetValue(key, out epdfMisses))
    369364                  misses[key] = epdfMisses = new SortedList<double, int>();
    370               }
     365                totalRuns[key] = noRuns;
     366              };
    371367              var list = e.Item1 ? epdfHits : epdfMisses;
    372368              int v;
     
    377373          }
    378374        }
     375        if (aggregate) totalRuns[alg.Name] = noRuns;
    379376      }
    380377
    381378      UpdateTargetChartAxisXBounds(minEff, maxEff);
    382379
    383       DrawTargetsEcdf(hits, misses, noRuns);
     380      DrawTargetsEcdf(hits, misses, totalRuns);
    384381
    385382      if (targets.Length == 1) {
     
    392389      targetChart.ChartAreas[0].CursorY.Interval = 0.05;
    393390
    394       UpdateErtTables(groupedRuns);
    395     }
    396 
    397     private void DrawTargetsEcdf(Dictionary<string, SortedList<double, int>> hits, Dictionary<string, SortedList<double, int>> misses, int noRuns) {
     391      UpdateErtTables(algInstances);
     392    }
     393
     394    private void DrawTargetsEcdf(Dictionary<string, SortedList<double, int>> hits, Dictionary<string, SortedList<double, int>> misses, Dictionary<string, int> noRuns) {
    398395      var colorCount = 0;
    399396      var lineStyleCount = 0;
     
    418415        var iter = misses[list.Key].GetEnumerator();
    419416        var moreMisses = iter.MoveNext();
    420         var totalTargets = noRuns;
     417        var totalTargets = noRuns[list.Key];
    421418        if (aggregateTargetsCheckBox.Checked) totalTargets *= targets.Length;
    422419        var movingTargets = totalTargets;
     
    594591    }
    595592
    596     private void UpdateErtTables(Dictionary<string, Dictionary<ProblemInstance, List<IRun>>> groupedRuns) {
     593    private void UpdateErtTables(List<AlgorithmInstance> algorithmInstances) {
    597594      ertTableView.Content = null;
    598595      var columns = 1 + targets.Length + 1;
    599       var matrix = new string[groupedRuns.Count * groupedRuns.Max(x => x.Value.Count) + groupedRuns.Max(x => x.Value.Count), columns];
     596      var matrix = new string[algorithmInstances.Count * algorithmInstances.Max(x => x.GetNumberOfProblemInstances()) + algorithmInstances.Max(x => x.GetNumberOfProblemInstances()), columns];
    600597      var rowCount = 0;
    601598
     
    603600      if (string.IsNullOrEmpty(tableName)) return;
    604601     
    605       var problems = groupedRuns.SelectMany(x => x.Value.Keys).Distinct().ToList();
     602      var problems = algorithmInstances.SelectMany(x => x.GetProblemInstances()).Distinct().ToList();
    606603
    607604      foreach (var problem in problems) {
     
    615612        rowCount++;
    616613
    617         foreach (var group in groupedRuns) {
    618           matrix[rowCount, 0] = group.Key;
    619           if (!group.Value.ContainsKey(problem)) {
     614        foreach (var alg in algorithmInstances) {
     615          matrix[rowCount, 0] = alg.Name;
     616          var runs = alg.GetRuns(problem).ToList();
     617          if (runs.Count == 0) {
    620618            matrix[rowCount, columns - 1] = "N/A";
    621619            rowCount++;
    622620            continue;
    623621          }
    624           var runs = group.Value[problem];
    625622          var result = default(ErtCalculationResult);
    626623          for (var i = 0; i < absTargets.Length; i++) {
     
    648645      if (budgets == null) GenerateDefaultBudgets(table);
    649646
    650       var groupedRuns = GroupRuns();
    651       if (groupedRuns.Count == 0) return;
     647      var algInstances = GroupRuns().ToList();
     648      if (algInstances.Count == 0) return;
    652649
    653650      var colorCount = 0;
    654651      var lineStyleCount = 0;
    655652     
    656       foreach (var group in groupedRuns) {
     653      foreach (var alg in algInstances) {
    657654        var hits = new Dictionary<string, SortedList<double, double>>();
    658655
    659         foreach (var problem in group.Value) {
    660           foreach (var run in problem.Value) {
     656        foreach (var problem in alg.GetProblemInstances()) {
     657          foreach (var run in alg.GetRuns(problem)) {
    661658            var resultsTable = (IndexedDataTable<double>)run.Results[table];
    662659
    663660            if (aggregateBudgetsCheckBox.Checked) {
    664               CalculateHitsForAllBudgets(hits, resultsTable.Rows.First(), group.Value.Count, problem.Key, group.Key, problem.Value.Count);
     661              CalculateHitsForAllBudgets(hits, resultsTable.Rows.First(), alg.GetNumberOfProblemInstances(), problem, alg.Name, alg.GetNumberOfRuns(problem));
    665662            } else {
    666               CalculateHitsForEachBudget(hits, resultsTable.Rows.First(), group.Value.Count, problem.Key, group.Key, problem.Value.Count);
     663              CalculateHitsForEachBudget(hits, resultsTable.Rows.First(), alg.GetNumberOfProblemInstances(), problem, alg.Name, alg.GetNumberOfRuns(problem));
    667664            }
    668665          }
     
    697694
    698695    private void GenerateDefaultBudgets(string table) {
    699       var runs = GroupRuns().SelectMany(x => x.Value.Values).SelectMany(x => x).ToList();
     696      var runs = Content;
    700697      var min = runs.Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Select(y => y.Item1).Min()).Min();
    701698      var max = runs.Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Select(y => y.Item1).Max()).Max();
     
    11721169    }
    11731170
     1171    private class AlgorithmInstance : INotifyPropertyChanged {
     1172      private string name;
     1173      public string Name {
     1174        get { return name; }
     1175        set {
     1176          if (name == value) return;
     1177          name = value;
     1178          OnPropertyChanged("Name");
     1179        }
     1180      }
     1181
     1182      private Dictionary<ProblemInstance, List<IRun>> performanceData;
     1183
     1184      public int GetNumberOfProblemInstances() {
     1185        return performanceData.Count;
     1186      }
     1187
     1188      public IEnumerable<ProblemInstance> GetProblemInstances() {
     1189        return performanceData.Keys;
     1190      }
     1191
     1192      public int GetNumberOfRuns(ProblemInstance p) {
     1193        if (p == ProblemInstance.MatchAll) return performanceData.Select(x => x.Value.Count).Sum();
     1194        List<IRun> runs;
     1195        if (performanceData.TryGetValue(p, out runs))
     1196          return runs.Count;
     1197
     1198        return 0;
     1199      }
     1200
     1201      public IEnumerable<IRun> GetRuns(ProblemInstance p) {
     1202        if (p == ProblemInstance.MatchAll) return performanceData.SelectMany(x => x.Value);
     1203        List<IRun> runs;
     1204        if (performanceData.TryGetValue(p, out runs))
     1205          return runs;
     1206
     1207        return Enumerable.Empty<IRun>();
     1208      }
     1209
     1210      public AlgorithmInstance(string name, IEnumerable<IRun> runs, IEnumerable<ProblemInstance> problems) {
     1211        this.name = name;
     1212
     1213        var pDict = problems.ToDictionary(r => r, _ => new List<IRun>());
     1214        foreach (var y in runs) {
     1215          var pd = new ProblemInstance(y);
     1216          List<IRun> l;
     1217          if (pDict.TryGetValue(pd, out l)) l.Add(y);
     1218        }
     1219        performanceData = pDict.Where(x => x.Value.Count > 0).ToDictionary(x => x.Key, x => x.Value);
     1220      }
     1221
     1222      public override bool Equals(object obj) {
     1223        var other = obj as AlgorithmInstance;
     1224        if (other == null) return false;
     1225        return name == other.name;
     1226      }
     1227
     1228      public override int GetHashCode() {
     1229        return name.GetHashCode();
     1230      }
     1231
     1232      public event PropertyChangedEventHandler PropertyChanged;
     1233      protected virtual void OnPropertyChanged(string propertyName = null) {
     1234        var handler = PropertyChanged;
     1235        if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
     1236      }
     1237    }
     1238
    11741239    private class ProblemInstance : INotifyPropertyChanged {
    11751240      private readonly bool matchAll;
  • branches/PerformanceComparison/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj

    r13706 r14776  
    202202    <Compile Include="Interfaces\IMultiObjectiveOperator.cs" />
    203203    <Compile Include="Interfaces\IPreexistingSolutionCreator.cs" />
     204    <Compile Include="Interfaces\ISolutionModel.cs" />
    204205    <Compile Include="Results\IResultParameter.cs" />
    205206    <Compile Include="Interfaces\ISingleObjectiveOperator.cs" />
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Common/3.3/KnowledgeCenter.cs

    r14667 r14776  
    202202        key2Idx.Add(kvp.Key, kvp.Index);
    203203
     204      Func<double[], double[], double> euclid = (a, b) => Math.Sqrt(a.Zip(b, (x, y) => (x - y)).Sum(x => x * x));
     205      Func<DoubleArray, DoubleArray, double> euclidDArray = (a, b) => Math.Sqrt(a.Zip(b, (x, y) => (x - y)).Sum(x => x * x));
    204206      #region MDS
    205       Func<double[], double[], double> euclid = (a, b) => Math.Sqrt(a.Zip(b, (x, y) => (x - y)).Sum(x => x * x));
    206207      var num = instances.Count;
    207208      var matrix = new DoubleMatrix(num, num);
     
    243244        tsneFeatures[key2Idx.GetByFirst(instance.Key)] = new DoubleArray(instance.Value);
    244245      }
    245       var tsneCoords = TSNE<DoubleArray>.Run(tsneFeatures, 2, Math.Min((instances.Count - 1) / 3, 50), 0.1, (a, b) => Math.Sqrt(a.Zip(b, (c, d) => (c - d) * (c - d)).Sum()), new FastRandom(42));
     246      var tsne = new TSNE<DoubleArray>(new EuclidianDistance(), new FastRandom(42), stopLyingIter: 0, momSwitchIter: 0, momentum: 0, finalMomentum: 0, eta: 10);
     247      var tsneCoords = tsne.Run(tsneFeatures, 2, Math.Min((instances.Count - 1) / 4, 50), 0);
     248      //var tsneCoords = TSNE<DoubleArray>.Run(tsneFeatures, 2, Math.Min((instances.Count - 1) / 4, 50), 0, euclidDArray, new FastRandom(42));
    246249      #endregion
    247250
  • branches/PerformanceComparison/PerformanceComparison.sln

    r14691 r14776  
    2727EndProject
    2828Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.Instances.QAPLIB-3.3", "HeuristicLab.Problems.Instances.QAPLIB\3.3\HeuristicLab.Problems.Instances.QAPLIB-3.3.csproj", "{73F29D43-5714-4069-8FAB-0D18FEB5F175}"
     29EndProject
     30Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Encodings.BinaryVectorEncoding-3.3", "HeuristicLab.Encodings.BinaryVectorEncoding\3.3\HeuristicLab.Encodings.BinaryVectorEncoding-3.3.csproj", "{66D249C3-A01D-42A8-82A2-919BC8EC3D83}"
     31EndProject
     32Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Encodings.LinearLinkageEncoding-3.4", "HeuristicLab.Encodings.LinearLinkageEncoding\3.4\HeuristicLab.Encodings.LinearLinkageEncoding-3.4.csproj", "{BE698769-975A-429E-828C-72BB2B6182C8}"
    2933EndProject
    3034Global
     
    182186    {73F29D43-5714-4069-8FAB-0D18FEB5F175}.Release|x86.ActiveCfg = Release|x86
    183187    {73F29D43-5714-4069-8FAB-0D18FEB5F175}.Release|x86.Build.0 = Release|x86
     188    {66D249C3-A01D-42A8-82A2-919BC8EC3D83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     189    {66D249C3-A01D-42A8-82A2-919BC8EC3D83}.Debug|Any CPU.Build.0 = Debug|Any CPU
     190    {66D249C3-A01D-42A8-82A2-919BC8EC3D83}.Debug|x64.ActiveCfg = Debug|x64
     191    {66D249C3-A01D-42A8-82A2-919BC8EC3D83}.Debug|x64.Build.0 = Debug|x64
     192    {66D249C3-A01D-42A8-82A2-919BC8EC3D83}.Debug|x86.ActiveCfg = Debug|x86
     193    {66D249C3-A01D-42A8-82A2-919BC8EC3D83}.Debug|x86.Build.0 = Debug|x86
     194    {66D249C3-A01D-42A8-82A2-919BC8EC3D83}.Release|Any CPU.ActiveCfg = Release|Any CPU
     195    {66D249C3-A01D-42A8-82A2-919BC8EC3D83}.Release|Any CPU.Build.0 = Release|Any CPU
     196    {66D249C3-A01D-42A8-82A2-919BC8EC3D83}.Release|x64.ActiveCfg = Release|x64
     197    {66D249C3-A01D-42A8-82A2-919BC8EC3D83}.Release|x64.Build.0 = Release|x64
     198    {66D249C3-A01D-42A8-82A2-919BC8EC3D83}.Release|x86.ActiveCfg = Release|x86
     199    {66D249C3-A01D-42A8-82A2-919BC8EC3D83}.Release|x86.Build.0 = Release|x86
     200    {BE698769-975A-429E-828C-72BB2B6182C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     201    {BE698769-975A-429E-828C-72BB2B6182C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
     202    {BE698769-975A-429E-828C-72BB2B6182C8}.Debug|x64.ActiveCfg = Debug|x64
     203    {BE698769-975A-429E-828C-72BB2B6182C8}.Debug|x64.Build.0 = Debug|x64
     204    {BE698769-975A-429E-828C-72BB2B6182C8}.Debug|x86.ActiveCfg = Debug|x86
     205    {BE698769-975A-429E-828C-72BB2B6182C8}.Debug|x86.Build.0 = Debug|x86
     206    {BE698769-975A-429E-828C-72BB2B6182C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
     207    {BE698769-975A-429E-828C-72BB2B6182C8}.Release|Any CPU.Build.0 = Release|Any CPU
     208    {BE698769-975A-429E-828C-72BB2B6182C8}.Release|x64.ActiveCfg = Release|x64
     209    {BE698769-975A-429E-828C-72BB2B6182C8}.Release|x64.Build.0 = Release|x64
     210    {BE698769-975A-429E-828C-72BB2B6182C8}.Release|x86.ActiveCfg = Release|x86
     211    {BE698769-975A-429E-828C-72BB2B6182C8}.Release|x86.Build.0 = Release|x86
    184212  EndGlobalSection
    185213  GlobalSection(SolutionProperties) = preSolution
  • branches/PerformanceComparison/ProblemInstanceIdentifier/InstanceExplorer.cs

    r14696 r14776  
    7474  }
    7575
     76  public class AdaptiveWalkExplorer : InstanceExplorer {
     77    public int Iterations { get; set; }
     78
     79    public override string Name { get { return "Adaptive-Walk Explorer"; } }
     80    public override int Effort { get { return Iterations; } }
     81
     82    public AdaptiveWalkExplorer() {
     83
     84    }
     85
     86    public override InstanceDescriptor Explore(QuadraticAssignmentProblem problem, int? seed = null) {
     87      var walk = new AdaptiveWalk() {
     88        SeedParameter = { Value = { Value = seed ?? 0 } },
     89        SetSeedRandomlyParameter = { Value = { Value = seed.HasValue } },
     90        MaximumIterationsParameter = { Value = { Value = Iterations } },
     91        RepetitionsParameter = { Value = { Value = 1 } }
     92      };
     93      walk.Problem = problem;
     94      walk.Engine = new SequentialEngine();
     95      walk.MutatorParameter.Value = walk.MutatorParameter.ValidValues.First(x => x is Swap2Manipulator);
     96      var calculator = new AdaptiveWalkCalculator(walk) { Problem = problem };
     97      var features = calculator.Calculate().ToDictionary(x => x.Name, x => x.Value);
     98
     99      return new InstanceDescriptor(problem.Name, InstanceDescriptor.GetClass(problem.Name), problem.Weights.Rows,
     100        features.Keys.ToArray(), features.Values.Select(x => ((DoubleValue)x).Value).ToArray());
     101    }
     102  }
     103
    76104  public class MemPRExplorer : InstanceExplorer {
    77105    public int Seconds { get; set; }
  • branches/PerformanceComparison/ProblemInstanceIdentifier/Program.cs

    r14696 r14776  
    44using System.Linq;
    55using System.Threading.Tasks;
    6 using HeuristicLab.Algorithms.MemPR.Permutation;
    76using HeuristicLab.PluginInfrastructure;
    87using HeuristicLab.Problems.Instances;
Note: See TracChangeset for help on using the changeset viewer.