Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/28/11 15:34:30 (14 years ago)
Author:
abeham
Message:

#1330

  • Renamed the DistanceMatrix parameter to Distances
  • Renamed the SwapMove to Swap2Move and renamed operators accordingly
  • Integrated changes in HeuristicLab.Analysis.Views regarding description text box
Location:
branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Analyzers/BestQAPSolutionAnalyzer.cs

    r5583 r5838  
    8989
    9090    public override IOperation Apply() {
    91       DoubleMatrix coordinates = CoordinatesParameter.ActualValue;
    9291      DoubleMatrix distances = DistancesParameter.ActualValue;
    9392      DoubleMatrix weights = WeightsParameter.ActualValue;
     
    113112      if (assignment == null) {
    114113        assignment = new QAPAssignment(weights, (Permutation)permutations[i].Clone(), new DoubleValue(qualities[i].Value));
    115         assignment.Coordinates = coordinates;
    116114        assignment.Distances = distances;
    117115        BestSolutionParameter.ActualValue = assignment;
     
    120118        if (max && assignment.Quality.Value < qualities[i].Value ||
    121119          !max && assignment.Quality.Value > qualities[i].Value) {
    122           assignment.Coordinates = coordinates;
    123120          assignment.Distances = distances;
    124121          assignment.Weights = weights;
  • branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Evaluators/QAPEvaluator.cs

    r5598 r5838  
    3535      get { return (ILookupParameter<Permutation>)Parameters["Permutation"]; }
    3636    }
    37     public ILookupParameter<DoubleMatrix> DistanceMatrixParameter {
    38       get { return (ILookupParameter<DoubleMatrix>)Parameters["DistanceMatrix"]; }
    39     }
    40     public ILookupParameter<DoubleMatrix> CoordinatesParameter {
    41       get { return (ILookupParameter<DoubleMatrix>)Parameters["Coordinates"]; }
     37    public ILookupParameter<DoubleMatrix> DistancesParameter {
     38      get { return (ILookupParameter<DoubleMatrix>)Parameters["Distances"]; }
    4239    }
    4340    public ILookupParameter<DoubleMatrix> WeightsParameter {
     
    5350    public QAPEvaluator() {
    5451      Parameters.Add(new LookupParameter<Permutation>("Permutation", "The permutation that represents the current solution."));
    55       Parameters.Add(new LookupParameter<DoubleMatrix>("DistanceMatrix", "The distance matrix that contains the distances between the locations."));
    56       Parameters.Add(new LookupParameter<DoubleMatrix>("Coordinates", "The coordinates in case the distance matrix should not be used."));
     52      Parameters.Add(new LookupParameter<DoubleMatrix>("Distances", "The distance matrix that contains the distances between the locations."));
    5753      Parameters.Add(new LookupParameter<DoubleMatrix>("Weights", "The matrix with the weights between the facilities, that is how strongly they're connected to each other."));
    5854      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality value aka fitness value of the solution."));
     
    7672      Permutation assignment = PermutationParameter.ActualValue;
    7773      DoubleMatrix weights = WeightsParameter.ActualValue;
    78       DoubleMatrix distanceMatrix = DistanceMatrixParameter.ActualValue;
     74      DoubleMatrix distanceMatrix = DistancesParameter.ActualValue;
    7975
    8076      double quality = Apply(assignment, weights, distanceMatrix);
  • branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Evaluators/QAPInversionMoveEvaluator.cs

    r5785 r5838  
    7373      if (move == null) throw new InvalidOperationException("Inversion move is not found.");
    7474      Permutation assignment = PermutationParameter.ActualValue;
    75       DoubleMatrix distances = DistanceMatrixParameter.ActualValue;
     75      DoubleMatrix distances = DistancesParameter.ActualValue;
    7676      DoubleMatrix weights = WeightsParameter.ActualValue;
    7777
  • branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Evaluators/QAPMoveEvaluator.cs

    r5785 r5838  
    4949      get { return (ILookupParameter<Permutation>)Parameters["Permutation"]; }
    5050    }
    51     public ILookupParameter<DoubleMatrix> DistanceMatrixParameter {
    52       get { return (ILookupParameter<DoubleMatrix>)Parameters["DistanceMatrix"]; }
     51    public ILookupParameter<DoubleMatrix> DistancesParameter {
     52      get { return (ILookupParameter<DoubleMatrix>)Parameters["Distances"]; }
    5353    }
    5454    public ILookupParameter<DoubleMatrix> WeightsParameter {
     
    6464      Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The evaluated quality of a move on a QAP solution."));
    6565      Parameters.Add(new LookupParameter<Permutation>("Permutation", "The solution as permutation."));
    66       Parameters.Add(new LookupParameter<DoubleMatrix>("DistanceMatrix", "The matrix which contains the distances between the facilities."));
     66      Parameters.Add(new LookupParameter<DoubleMatrix>("Distances", "The matrix which contains the distances between the facilities."));
    6767      Parameters.Add(new LookupParameter<DoubleMatrix>("Weights", "The matrix with the weights between the facilities, that is how strongly they're connected to each other."));
    6868    }
  • branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Evaluators/QAPSwapMoveEvaluator.cs

    r5785 r5838  
    2929
    3030namespace HeuristicLab.Problems.QuadraticAssignment {
    31   [Item("QAPSwapMoveEvaluator", "Evaluated a swap move on a QAP solution.")]
     31  [Item("QAPSwap2MoveEvaluator", "Evaluated a swap-2 move on a QAP solution.")]
    3232  [StorableClass]
    33   public class QAPSwapMoveEvaluator : QAPMoveEvaluator, IPermutationSwapMoveOperator {
    34     public ILookupParameter<SwapMove> SwapMoveParameter {
    35       get { return (ILookupParameter<SwapMove>)Parameters["SwapMove"]; }
     33  public class QAPSwap2MoveEvaluator : QAPMoveEvaluator, IPermutationSwap2MoveOperator {
     34    public ILookupParameter<Swap2Move> Swap2MoveParameter {
     35      get { return (ILookupParameter<Swap2Move>)Parameters["Swap2Move"]; }
    3636    }
    3737
    3838    [StorableConstructor]
    39     protected QAPSwapMoveEvaluator(bool deserializing) : base(deserializing) { }
    40     protected QAPSwapMoveEvaluator(QAPSwapMoveEvaluator original, Cloner cloner)
     39    protected QAPSwap2MoveEvaluator(bool deserializing) : base(deserializing) { }
     40    protected QAPSwap2MoveEvaluator(QAPSwap2MoveEvaluator original, Cloner cloner)
    4141      : base(original, cloner) {
    4242    }
    43     public QAPSwapMoveEvaluator() {
    44       Parameters.Add(new LookupParameter<SwapMove>("SwapMove", "The move to evaluate."));
     43    public QAPSwap2MoveEvaluator() {
     44      Parameters.Add(new LookupParameter<Swap2Move>("Swap2Move", "The move to evaluate."));
    4545    }
    4646
    4747    public override IDeepCloneable Clone(Cloner cloner) {
    48       return new QAPSwapMoveEvaluator(this, cloner);
     48      return new QAPSwap2MoveEvaluator(this, cloner);
    4949    }
    5050
    51     public static double Apply(Permutation assignment, SwapMove move, DoubleMatrix weights, DoubleMatrix distances) {
     51    public static double Apply(Permutation assignment, Swap2Move move, DoubleMatrix weights, DoubleMatrix distances) {
    5252      if (move.Index1 == move.Index2) return 0;
    5353      double moveQuality = 0;
     
    7070
    7171    public override IOperation Apply() {
    72       SwapMove move = SwapMoveParameter.ActualValue;
    73       if (move == null) throw new InvalidOperationException("Swap move is not found.");
     72      Swap2Move move = Swap2MoveParameter.ActualValue;
     73      if (move == null) throw new InvalidOperationException("Swap-2 move is not found.");
    7474      Permutation assignment = PermutationParameter.ActualValue;
    75       DoubleMatrix distances = DistanceMatrixParameter.ActualValue;
     75      DoubleMatrix distances = DistancesParameter.ActualValue;
    7676      DoubleMatrix weights = WeightsParameter.ActualValue;
    7777
  • branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Evaluators/QAPTranslocationMoveEvaluator.cs

    r5801 r5838  
    8585      if (move == null) throw new InvalidOperationException("Translocation move is not found.");
    8686      Permutation assignment = PermutationParameter.ActualValue;
    87       DoubleMatrix distances = DistanceMatrixParameter.ActualValue;
     87      DoubleMatrix distances = DistancesParameter.ActualValue;
    8888      DoubleMatrix weights = WeightsParameter.ActualValue;
    8989
  • branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Interfaces/IQAPEvaluator.cs

    r5598 r5838  
    2828  public interface IQAPEvaluator : ISingleObjectiveEvaluator {
    2929    ILookupParameter<Permutation> PermutationParameter { get; }
    30     ILookupParameter<DoubleMatrix> DistanceMatrixParameter { get; }
    31     ILookupParameter<DoubleMatrix> CoordinatesParameter { get; }
     30    ILookupParameter<DoubleMatrix> DistancesParameter { get; }
    3231    ILookupParameter<DoubleMatrix> WeightsParameter { get; }
    3332  }
  • branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Interfaces/IQAPMoveEvaluator.cs

    r5785 r5838  
    2828  public interface IQAPMoveEvaluator : ISingleObjectiveMoveEvaluator, IMoveOperator {
    2929    ILookupParameter<Permutation> PermutationParameter { get; }
    30     ILookupParameter<DoubleMatrix> DistanceMatrixParameter { get; }
     30    ILookupParameter<DoubleMatrix> DistancesParameter { get; }
    3131    ILookupParameter<DoubleMatrix> WeightsParameter { get; }
    3232  }
  • branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Parsers/QAPLIBParser.cs

    r5648 r5838  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
    223using System.IO;
    324
  • branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Parsers/QAPLIBSolutionParser.cs

    r5814 r5838  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
    223using System.Globalization;
    324using System.IO;
  • branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Plugin.cs.frame

    r5563 r5838  
    2525  [Plugin("HeuristicLab.Problems.QuadraticAssignment", "3.3.3.$WCREV$")]
    2626  [PluginFile("HeuristicLab.Problems.QuadraticAssignment-3.3.dll", PluginFileType.Assembly)]
    27   [PluginDependency("HeuristicLab.Collections", "3.3.3")]
    28   [PluginDependency("HeuristicLab.Common", "3.3.3")]
    29   [PluginDependency("HeuristicLab.Common.Resources", "3.3.3")]
    30   [PluginDependency("HeuristicLab.Core", "3.3.3")]
    31   [PluginDependency("HeuristicLab.Data", "3.3.3")]
    32   [PluginDependency("HeuristicLab.Encodings.PermutationEncoding", "3.3.3")]
    33   [PluginDependency("HeuristicLab.Operators", "3.3.3")]
    34   [PluginDependency("HeuristicLab.Optimization", "3.3.3")]
    35   [PluginDependency("HeuristicLab.Parameters", "3.3.3")]
    36   [PluginDependency("HeuristicLab.Persistence", "3.3.3")]
     27  [PluginDependency("HeuristicLab.Collections", "3.3")]
     28  [PluginDependency("HeuristicLab.Common", "3.3")]
     29  [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
     30  [PluginDependency("HeuristicLab.Core", "3.3")]
     31  [PluginDependency("HeuristicLab.Data", "3.3")]
     32  [PluginDependency("HeuristicLab.Encodings.PermutationEncoding", "3.3")]
     33  [PluginDependency("HeuristicLab.Operators", "3.3")]
     34  [PluginDependency("HeuristicLab.Optimization", "3.3")]
     35  [PluginDependency("HeuristicLab.Parameters", "3.3")]
     36  [PluginDependency("HeuristicLab.Persistence", "3.3")]
    3737  public class HeuristicLabProblemsQuadraticAssignmentPlugin : PluginBase { }
    3838}
  • branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/QAPAssignment.cs

    r5648 r5838  
    1010  [StorableClass]
    1111  public sealed class QAPAssignment : Item, INotifyPropertyChanged {
    12     [Storable]
    13     private DoubleMatrix coordinates;
    14     public DoubleMatrix Coordinates {
    15       get { return coordinates; }
    16       set {
    17         bool changed = (coordinates != value);
    18         coordinates = value;
    19         if (changed) OnPropertyChanged("Coordinates");
    20       }
    21     }
    2212
    2313    [Storable]
     
    6959    private QAPAssignment(QAPAssignment original, Cloner cloner)
    7060      : base(original, cloner) {
    71       coordinates = cloner.Clone(original.coordinates);
    7261      distances = cloner.Clone(original.distances);
    7362      weights = cloner.Clone(original.weights);
  • branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/QuadraticAssignmentProblem.cs

    r5814 r5838  
    3636
    3737namespace HeuristicLab.Problems.QuadraticAssignment {
    38   [Item("Quadratic Assignment Problem", "The Quadratic Assignment Problem (QAP) is the problem of assigning N facilities to N fixed locations such that there is exactly one facility in each location and that the distances multiplied by the connection strength between the facilities becomes minimal.")]
     38  [Item("Quadratic Assignment Problem", "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.")]
    3939  [Creatable("Problems")]
    4040  [StorableClass]
     
    5656      get { return (IValueParameter<DoubleMatrix>)Parameters["Weights"]; }
    5757    }
    58     public IValueParameter<DoubleMatrix> DistanceMatrixParameter {
    59       get { return (IValueParameter<DoubleMatrix>)Parameters["DistanceMatrix"]; }
     58    public IValueParameter<DoubleMatrix> DistancesParameter {
     59      get { return (IValueParameter<DoubleMatrix>)Parameters["Distances"]; }
    6060    }
    6161    #endregion
     
    7474      set { WeightsParameter.Value = value; }
    7575    }
    76     public DoubleMatrix DistanceMatrix {
    77       get { return DistanceMatrixParameter.Value; }
    78       set { DistanceMatrixParameter.Value = value; }
     76    public DoubleMatrix Distances {
     77      get { return DistancesParameter.Value; }
     78      set { DistancesParameter.Value = value; }
    7979    }
    8080
     
    106106      Parameters.Add(new ValueParameter<DoubleMatrix>("Coordinates", "The coordinates of the locations. If this is changed the distance matrix is calculated automatically using the euclidean distance."));
    107107      Parameters.Add(new ValueParameter<DoubleMatrix>("Weights", "The strength of the connection between the facilities.", new DoubleMatrix(5, 5)));
    108       Parameters.Add(new ValueParameter<DoubleMatrix>("DistanceMatrix", "The distance matrix which can either be specified directly without the coordinates, or can be calculated automatically from the coordinates.", new DoubleMatrix(5, 5)));
     108      Parameters.Add(new ValueParameter<DoubleMatrix>("Distances", "The distance matrix which can either be specified directly without the coordinates, or can be calculated automatically from the coordinates.", new DoubleMatrix(5, 5)));
    109109
    110110      Maximization = new BoolValue(false);
     
    126126      });
    127127
    128       DistanceMatrix = new DoubleMatrix(new double[,] {
     128      Distances = new DoubleMatrix(new double[,] {
    129129        {   0, 360, 582, 582, 360 },
    130130        { 360,   0, 360, 582, 582 },
     
    231231      if (Evaluator != null) {
    232232        Evaluator.PermutationParameter.ActualName = SolutionCreator.PermutationParameter.ActualName;
    233         Evaluator.DistanceMatrixParameter.ActualName = DistanceMatrixParameter.Name;
    234         Evaluator.CoordinatesParameter.ActualName = CoordinatesParameter.Name;
     233        Evaluator.DistancesParameter.ActualName = DistancesParameter.Name;
    235234        Evaluator.WeightsParameter.ActualName = WeightsParameter.Name;
    236235      }
     
    240239        BestQAPSolutionAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
    241240        BestQAPSolutionAnalyzer.CoordinatesParameter.ActualName = CoordinatesParameter.Name;
    242         BestQAPSolutionAnalyzer.DistancesParameter.ActualName = DistanceMatrixParameter.Name;
     241        BestQAPSolutionAnalyzer.DistancesParameter.ActualName = DistancesParameter.Name;
    243242        BestQAPSolutionAnalyzer.WeightsParameter.ActualName = WeightsParameter.Name;
    244243        BestQAPSolutionAnalyzer.PermutationParameter.ActualName = SolutionCreator.PermutationParameter.ActualName;
     
    267266        foreach (IPermutationTranslocationMoveOperator op in Operators.OfType<IPermutationTranslocationMoveOperator>())
    268267          op.TranslocationMoveParameter.ActualName = translocationMove;
    269         string swapMove = Operators.OfType<IMoveGenerator>().OfType<IPermutationSwapMoveOperator>().First().SwapMoveParameter.ActualName;
    270         foreach (IPermutationSwapMoveOperator op in Operators.OfType<IPermutationSwapMoveOperator>()) {
    271           op.SwapMoveParameter.ActualName = swapMove;
     268        string swapMove = Operators.OfType<IMoveGenerator>().OfType<IPermutationSwap2MoveOperator>().First().Swap2MoveParameter.ActualName;
     269        foreach (IPermutationSwap2MoveOperator op in Operators.OfType<IPermutationSwap2MoveOperator>()) {
     270          op.Swap2MoveParameter.ActualName = swapMove;
    272271        }
    273272      }
     
    282281            double dy = Coordinates[i, 1] - Coordinates[j, 1];
    283282            distance[i, j] = Math.Sqrt(dx * dx + dy * dy);
    284             distance[j, i] = DistanceMatrix[i, j];
     283            distance[j, i] = Distances[i, j];
    285284          }
    286285        }
    287         DistanceMatrix = distance;
     286        Distances = distance;
    288287      }
    289288    }
     
    295294      if (parser.Error != null) throw parser.Error;
    296295      Coordinates = new DoubleMatrix();
    297       DistanceMatrix = new DoubleMatrix(parser.Distances);
     296      Distances = new DoubleMatrix(parser.Distances);
    298297      Weights = new DoubleMatrix(parser.Weights);
    299298      Name = "Quadratic Assignment Problem (imported from " + Path.GetFileNameWithoutExtension(filename) + ")";
     
    311310        if (parser.Error != null) throw parser.Error;
    312311        Coordinates = new DoubleMatrix();
    313         DistanceMatrix = new DoubleMatrix(parser.Distances);
     312        Distances = new DoubleMatrix(parser.Distances);
    314313        Weights = new DoubleMatrix(parser.Weights);
    315314        Name = "Quadratic Assignment Problem (loaded instance " + instance + ")";
     
    327326          solParser.Parse(solStream, false); // most sln's seem to be of the type index = location => value = facility
    328327          if (solParser.Error != null) throw solParser.Error;
    329           if (!solParser.Quality.IsAlmost(QAPEvaluator.Apply(new Permutation(PermutationTypes.Absolute, solParser.Assignment), Weights, DistanceMatrix))) {
     328          if (!solParser.Quality.IsAlmost(QAPEvaluator.Apply(new Permutation(PermutationTypes.Absolute, solParser.Assignment), Weights, Distances))) {
    330329            solStream.Seek(0, SeekOrigin.Begin);
    331330            solParser.Parse(solStream, true); // some sln's seem to be of the type index = facility => value = location
    332331            if (solParser.Error != null) throw solParser.Error;
    333             if (solParser.Quality.IsAlmost(QAPEvaluator.Apply(new Permutation(PermutationTypes.Absolute, solParser.Assignment), Weights, DistanceMatrix))) {
     332            if (solParser.Quality.IsAlmost(QAPEvaluator.Apply(new Permutation(PermutationTypes.Absolute, solParser.Assignment), Weights, Distances))) {
    334333              BestKnownQuality = new DoubleValue(solParser.Quality);
    335334              BestKnownSolution = new Permutation(PermutationTypes.Absolute, solParser.Assignment);
  • branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Tests/QAPLIBInstancesTest.cs

    r5814 r5838  
    3535          double quality = double.NaN;
    3636          try {
    37             quality = QAPEvaluator.Apply(qap.BestKnownSolution, qap.Weights, qap.DistanceMatrix);
     37            quality = QAPEvaluator.Apply(qap.BestKnownSolution, qap.Weights, qap.Distances);
    3838          } catch (Exception ex) {
    3939            failedInstances.AppendLine("An unknown problem occurred evaluating solution of instance " + instance + ": " + ex.Message);
  • branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Tests/QAPMoveEvaluatorTest.cs

    r5801 r5838  
    9797        double after = QAPEvaluator.Apply(assignment, weights, distances);
    9898        // evaluate swap back
    99         double move = QAPSwapMoveEvaluator.Apply(assignment, new SwapMove(index1, index2, assignment), weights, distances);
     99        double move = QAPSwap2MoveEvaluator.Apply(assignment, new Swap2Move(index1, index2, assignment), weights, distances);
    100100        Assert.IsTrue(move.IsAlmost(before - after));
    101101      }
Note: See TracChangeset for help on using the changeset viewer.