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