Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/12/17 21:02:01 (7 years ago)
Author:
abeham
Message:

#2666, #2706, #2730, #2736: merged revisions 14412, 14475, 14476, 14659, 14660, 14663, 14779, 14780, 14912, 15050, 15067, 15069, 15079, 15162, 15166, 15172, 15173 to stable

Location:
stable
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.BinPacking/3.3/3D/IntegerVectorEncoding/IntegerVectorProblem.cs

    r14170 r15217  
    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.