Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/05/16 12:27:19 (8 years ago)
Author:
abeham
Message:

#2701:

  • Worked on MemPR algorithm for permutations
    • Made Evaluate() method mostly thread-safe and moved evaluated solutions counting to caller
  • Removed TSP specific similarity calculator (it is actually not specific to the TSP) and added it to the permutation encoding as HammingSimilarityCalculator
  • Fixed bug in qap basicproblem
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/MemPRAlgorithm/HeuristicLab.Problems.QuadraticAssignment/3.3/QAPBasicProblem.cs

    r14451 r14453  
    2020#endregion
    2121
     22using System.Linq;
     23using HeuristicLab.Analysis;
    2224using HeuristicLab.Common;
    2325using HeuristicLab.Core;
     
    2527using HeuristicLab.Encodings.PermutationEncoding;
    2628using HeuristicLab.Optimization;
     29using HeuristicLab.Optimization.Operators;
    2730using HeuristicLab.Parameters;
    2831using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3033
    3134namespace HeuristicLab.Problems.QuadraticAssignment {
    32   [Item("Basic Quadratic Assignment Problem (BQAP)", "The Quadratic Assignment Problem (QAP) can be described as the problem of assigning N facilities to N fixed locations such that there is exactly one facility in each location and that the sum of the distances multiplied by the connection strength between the facilities becomes minimal.")]
     35  [Item("Basic Quadratic Assignment Problem (QAP)", "The Quadratic Assignment Problem (QAP) can be described as the problem of assigning N facilities to N fixed locations such that there is exactly one facility in each location and that the sum of the distances multiplied by the connection strength between the facilities becomes minimal.")]
    3336  [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 141)]
    3437  [StorableClass]
     
    6265      Parameters.Add(weightsParameter = new ValueParameter<DoubleMatrix>("Weights", "The weights matrix.", new DoubleMatrix(5, 5)));
    6366      Parameters.Add(distancesParameter = new ValueParameter<DoubleMatrix>("Distances", "The distances matrix.", new DoubleMatrix(5, 5)));
     67
     68      Operators.Add(new HammingSimilarityCalculator());
     69      Operators.Add(new QualitySimilarityCalculator());
     70      Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
     71
     72      Parameterize();
    6473    }
    6574
    6675    public override IDeepCloneable Clone(Cloner cloner) {
    6776      return new QAPBasicProblem(this, cloner);
     77    }
     78
     79    protected override void OnEncodingChanged() {
     80      base.OnEncodingChanged();
     81      Parameterize();
     82    }
     83
     84    private void Parameterize() {
     85      foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) {
     86        similarityCalculator.SolutionVariableName = Encoding.SolutionCreator.PermutationParameter.ActualName;
     87        similarityCalculator.QualityVariableName = Evaluator.QualityParameter.ActualName;
     88      }
    6889    }
    6990
     
    116137      Weights = weights;
    117138      Distances = distances;
     139      Encoding.Length = Weights.Rows;
    118140
    119141      BestKnownQuality = double.NaN;
Note: See TracChangeset for help on using the changeset viewer.