Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/27/17 13:45:50 (7 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)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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  }
Note: See TracChangeset for help on using the changeset viewer.