Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/27/17 13:45:50 (8 years ago)
Author:
abeham
Message:

#2706:

  • Added or updated similarity calculators and population similarity analysis for several problems (BinPacking, LAP, Orienteering, Parameter optimization, PTSP, QAP, TF, TSP, VRP)
  • Made TSPSimilarityCalculator obsolete since it's essentially the same as the one in the permutation plugin
  • Made QAPPopulationDiversityAnalyzer obsolete as it is replaced by the newer PopulationSimilarityAnalyzer
  • Removed genotype specific similarity code in QAPPermutationProximityCalculator (again identical to the permutation plugin)
  • Changed QAPSimilarityCalculator to perform phenotype similarity instead of genotype similarity (has not been previously used)
Location:
trunk/sources/HeuristicLab.Problems.BinPacking/3.3
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.BinPacking/3.3/2D/IntegerVectorEncoding/IntegerVectorProblem.cs

    r14162 r15069  
    2424using System.Collections.Generic;
    2525using System.Linq;
     26using HeuristicLab.Analysis;
    2627using HeuristicLab.Common;
    2728using HeuristicLab.Core;
    2829using HeuristicLab.Encodings.IntegerVectorEncoding;
    2930using HeuristicLab.Optimization;
     31using HeuristicLab.Optimization.Operators;
    3032using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3133
     
    5254      Encoding = new IntegerVectorEncoding(EncodedSolutionName, Items.Count, min: 0, max: LowerBound + 1); // NOTE: assumes that all items can be packed into LowerBound+1 bins
    5355      AddOperators();
     56      Parameterize();
    5457      RegisterEventHandlers();
    5558    }
     
    6366    }
    6467
     68    protected override void OnEncodingChanged() {
     69      base.OnEncodingChanged();
     70      Parameterize();
     71    }
    6572
    6673    private void AddOperators() {
    67 
    6874      // move operators are not yet supported (TODO)
    6975      Operators.RemoveAll(x => x is SingleObjectiveMoveGenerator);
    7076      Operators.RemoveAll(x => x is SingleObjectiveMoveMaker);
    7177      Operators.RemoveAll(x => x is SingleObjectiveMoveEvaluator);
     78      Operators.Add(new HammingSimilarityCalculator());
     79      Operators.Add(new EuclideanSimilarityCalculator());
     80      Operators.Add(new QualitySimilarityCalculator());
     81      Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
    7282
    73       Encoding.ConfigureOperators(Operators.OfType<IOperator>()); // gkronber: not strictly necessary (only when customer ops are added)
     83      Encoding.ConfigureOperators(Operators.OfType<IOperator>());
    7484    }
    7585
    7686    private void RegisterEventHandlers() {
    7787      // update encoding length when number of items is changed
    78       ItemsParameter.ValueChanged += (sender, args) => Encoding.Length = Items.Count;
    79       LowerBoundParameter.Value.ValueChanged += (sender, args) => {
    80         for (int i = 0; i < Encoding.Bounds.Rows; i++) {
    81           Encoding.Bounds[i, 1] = LowerBound + 1;
    82         }
    83       };
     88      ItemsParameter.ValueChanged += (sender, args) => Parameterize();
     89      LowerBoundParameter.Value.ValueChanged += (sender, args) => Parameterize();
    8490    }
    8591
     
    96102      return result;
    97103    }
     104
     105    private void Parameterize() {
     106      Encoding.Length = Items.Count;
     107      for (int i = 0; i < Encoding.Bounds.Rows; i++) {
     108        Encoding.Bounds[i, 1] = LowerBound + 1;
     109      }
     110      foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) {
     111        similarityCalculator.SolutionVariableName = Encoding.SolutionCreator.IntegerVectorParameter.ActualName;
     112        similarityCalculator.QualityVariableName = Evaluator.QualityParameter.ActualName;
     113      }
     114    }
    98115    #endregion
    99116  }
  • trunk/sources/HeuristicLab.Problems.BinPacking/3.3/2D/PermutationEncoding/PermutationProblem.cs

    r14162 r15069  
    2323
    2424using System.Linq;
    25 using System.Windows.Forms;
     25using HeuristicLab.Analysis;
    2626using HeuristicLab.Common;
    2727using HeuristicLab.Core;
    2828using HeuristicLab.Encodings.PermutationEncoding;
    2929using HeuristicLab.Optimization;
     30using HeuristicLab.Optimization.Operators;
    3031using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3132
     
    5152      Encoding = new PermutationEncoding(EncodedSolutionName, Items.Count, PermutationTypes.Absolute);
    5253      AddOperators();
     54      Parameterize();
    5355      RegisterEventHandlers();
    5456    }
     
    6264    }
    6365
     66    protected override void OnEncodingChanged() {
     67      base.OnEncodingChanged();
     68      Parameterize();
     69    }
    6470
    6571    private void AddOperators() {
     
    7076      Operators.RemoveAll(x => x is SingleObjectiveMoveMaker);
    7177      Operators.RemoveAll(x => x is SingleObjectiveMoveEvaluator);
     78      Operators.Add(new HammingSimilarityCalculator());
     79      Operators.Add(new QualitySimilarityCalculator());
     80      Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
    7281
    7382      Encoding.ConfigureOperators(Operators.OfType<IOperator>());
     
    8392    private void RegisterEventHandlers() {
    8493      // update encoding length when number of items is changed
    85       ItemsParameter.ValueChanged += (sender, args) => Encoding.Length = Items.Count;
     94      ItemsParameter.ValueChanged += (sender, args) => Parameterize();
     95    }
     96
     97    private void Parameterize() {
     98      Encoding.Length = Items.Count;
     99      foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) {
     100        similarityCalculator.SolutionVariableName = Encoding.SolutionCreator.PermutationParameter.ActualName;
     101        similarityCalculator.QualityVariableName = Evaluator.QualityParameter.ActualName;
     102      }
    86103    }
    87104  }
  • trunk/sources/HeuristicLab.Problems.BinPacking/3.3/3D/IntegerVectorEncoding/IntegerVectorProblem.cs

    r14167 r15069  
    2424using System.Collections.Generic;
    2525using System.Linq;
     26using HeuristicLab.Analysis;
    2627using HeuristicLab.Common;
    2728using HeuristicLab.Core;
    2829using HeuristicLab.Encodings.IntegerVectorEncoding;
    2930using HeuristicLab.Optimization;
     31using HeuristicLab.Optimization.Operators;
    3032using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3133
     
    5153      Encoding = new IntegerVectorEncoding(EncodedSolutionName, Items.Count, min: 0, max: LowerBound + 1); // NOTE: assumes that all items can be packed into LowerBound+1 bins
    5254      AddOperators();
     55      Parameterize();
    5356      RegisterEventHandlers();
    5457    }
     
    6265    }
    6366
     67    protected override void OnEncodingChanged() {
     68      base.OnEncodingChanged();
     69      Parameterize();
     70    }
    6471
    6572    private void AddOperators() {
    66 
    6773      // move operators are not yet supported (TODO)
    6874      Operators.RemoveAll(x => x is SingleObjectiveMoveGenerator);
    6975      Operators.RemoveAll(x => x is SingleObjectiveMoveMaker);
    7076      Operators.RemoveAll(x => x is SingleObjectiveMoveEvaluator);
     77      Operators.Add(new HammingSimilarityCalculator());
     78      Operators.Add(new EuclideanSimilarityCalculator());
     79      Operators.Add(new QualitySimilarityCalculator());
     80      Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
    7181
    7282      Encoding.ConfigureOperators(Operators.OfType<IOperator>()); // gkronber: not strictly necessary (only when customer ops are added)
     
    7585    private void RegisterEventHandlers() {
    7686      // update encoding length when number of items is changed
    77       ItemsParameter.ValueChanged += (sender, args) => Encoding.Length = Items.Count;
    78       LowerBoundParameter.Value.ValueChanged += (sender, args) => {
    79         for (int i = 0; i < Encoding.Bounds.Rows; i++) {
    80           Encoding.Bounds[i, 1] = LowerBound + 1;
    81         }
    82       };
     87      ItemsParameter.ValueChanged += (sender, args) => Parameterize();
     88      LowerBoundParameter.Value.ValueChanged += (sender, args) => Parameterize();
    8389    }
    8490
    8591    #region helpers
    86 
    8792    public static List<List<int>> GenerateSequenceMatrix(IntegerVector intVec) {
    8893      List<List<int>> result = new List<List<int>>();
     
    95100      return result;
    96101    }
     102
     103    private void Parameterize() {
     104      Encoding.Length = Items.Count;
     105      for (int i = 0; i < Encoding.Bounds.Rows; i++) {
     106        Encoding.Bounds[i, 1] = LowerBound + 1;
     107      }
     108      foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) {
     109        similarityCalculator.SolutionVariableName = Encoding.SolutionCreator.IntegerVectorParameter.ActualName;
     110        similarityCalculator.QualityVariableName = Evaluator.QualityParameter.ActualName;
     111      }
     112    }
    97113    #endregion
    98114  }
  • trunk/sources/HeuristicLab.Problems.BinPacking/3.3/3D/PermutationEncoding/PermutationProblem.cs

    r14167 r15069  
    2323
    2424using System.Linq;
     25using HeuristicLab.Analysis;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
    2728using HeuristicLab.Encodings.PermutationEncoding;
    2829using HeuristicLab.Optimization;
     30using HeuristicLab.Optimization.Operators;
    2931using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3032
     
    4951      Encoding = new PermutationEncoding(EncodedSolutionName, Items.Count, PermutationTypes.Absolute);
    5052      AddOperators();
     53      Parameterize();
    5154      RegisterEventHandlers();
    5255    }
     
    6063    }
    6164
     65    protected override void OnEncodingChanged() {
     66      base.OnEncodingChanged();
     67      Parameterize();
     68    }
    6269
    6370    private void AddOperators() {
     
    6875      Operators.RemoveAll(x => x is SingleObjectiveMoveMaker);
    6976      Operators.RemoveAll(x => x is SingleObjectiveMoveEvaluator);
     77      Operators.Add(new HammingSimilarityCalculator());
     78      Operators.Add(new QualitySimilarityCalculator());
     79      Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
    7080
    7181      Encoding.ConfigureOperators(Operators.OfType<IOperator>());
     
    8292    private void RegisterEventHandlers() {
    8393      // update encoding length when number of items is changed
    84       ItemsParameter.ValueChanged += (sender, args) => Encoding.Length = Items.Count;
     94      ItemsParameter.ValueChanged += (sender, args) => Parameterize();
     95    }
     96
     97    private void Parameterize() {
     98      Encoding.Length = Items.Count;
     99      foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) {
     100        similarityCalculator.SolutionVariableName = Encoding.SolutionCreator.PermutationParameter.ActualName;
     101        similarityCalculator.QualityVariableName = Evaluator.QualityParameter.ActualName;
     102      }
    85103    }
    86104  }
  • trunk/sources/HeuristicLab.Problems.BinPacking/3.3/HeuristicLab.Problems.BinPacking-3.3.csproj

    r14273 r15069  
    150150  <ItemGroup />
    151151  <ItemGroup>
     152    <ProjectReference Include="..\..\HeuristicLab.Analysis\3.3\HeuristicLab.Analysis-3.3.csproj">
     153      <Project>{887425B4-4348-49ED-A457-B7D2C26DDBF9}</Project>
     154      <Name>HeuristicLab.Analysis-3.3</Name>
     155      <Private>False</Private>
     156    </ProjectReference>
    152157    <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj">
    153158      <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project>
     
    183188      <Project>{23DA7FF4-D5B8-41B6-AA96-F0561D24F3EE}</Project>
    184189      <Name>HeuristicLab.Operators-3.3</Name>
     190      <Private>False</Private>
     191    </ProjectReference>
     192    <ProjectReference Include="..\..\HeuristicLab.Optimization.Operators\3.3\HeuristicLab.Optimization.Operators-3.3.csproj">
     193      <Project>{25087811-F74C-4128-BC86-8324271DA13E}</Project>
     194      <Name>HeuristicLab.Optimization.Operators-3.3</Name>
    185195      <Private>False</Private>
    186196    </ProjectReference>
  • trunk/sources/HeuristicLab.Problems.BinPacking/3.3/Plugin.cs.frame

    r14174 r15069  
    2828  [Plugin("HeuristicLab.Problems.BinPacking", "3.3.14.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Problems.BinPacking-3.3.dll", PluginFileType.Assembly)]
     30  [PluginDependency("HeuristicLab.Analysis", "3.3")]
    3031  [PluginDependency("HeuristicLab.Collections", "3.3")]
    3132  [PluginDependency("HeuristicLab.Common", "3.3")]
     
    3637  [PluginDependency("HeuristicLab.Operators", "3.3")]
    3738  [PluginDependency("HeuristicLab.Optimization", "3.3")]
     39  [PluginDependency("HeuristicLab.Optimization.Operators", "3.3")]
    3840  [PluginDependency("HeuristicLab.Parameters", "3.3")]
    3941  [PluginDependency("HeuristicLab.Persistence", "3.3")]
Note: See TracChangeset for help on using the changeset viewer.