Free cookie consent management tool by TermsFeed Policy Generator

source: branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/QAPAssignment.cs @ 5648

Last change on this file since 5648 was 5648, checked in by abeham, 12 years ago

#1330

  • Unified QAP visualization in solution and problem view
  • Fixed bug in gradient-descent gradient calculation when performing multidimensional scaling
  • Extended QAPLIB parsers to cover some file format variations
  • Added unit tests to check if all QAPLIB instances import without error
  • Changed BestKnownSolution to be an OptionalValueParameter
File size: 2.9 KB
Line 
1using System.ComponentModel;
2using HeuristicLab.Common;
3using HeuristicLab.Core;
4using HeuristicLab.Data;
5using HeuristicLab.Encodings.PermutationEncoding;
6using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
7
8namespace HeuristicLab.Problems.QuadraticAssignment {
9  [Item("QAP Assignment", "Represents a solution to the QAP.")]
10  [StorableClass]
11  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    }
22
23    [Storable]
24    private DoubleMatrix distances;
25    public DoubleMatrix Distances {
26      get { return distances; }
27      set {
28        bool changed = (distances != value);
29        distances = value;
30        if (changed) OnPropertyChanged("Distances");
31      }
32    }
33
34    [Storable]
35    private DoubleMatrix weights;
36    public DoubleMatrix Weights {
37      get { return weights; }
38      set {
39        bool changed = (weights != value);
40        weights = value;
41        if (changed) OnPropertyChanged("Weights");
42      }
43    }
44
45    [Storable]
46    private Permutation assignment;
47    public Permutation Assignment {
48      get { return assignment; }
49      set {
50        bool changed = (assignment != value);
51        assignment = value;
52        if (changed) OnPropertyChanged("Assignment");
53      }
54    }
55
56    [Storable]
57    private DoubleValue quality;
58    public DoubleValue Quality {
59      get { return quality; }
60      set {
61        bool changed = (quality != value);
62        quality = value;
63        if (changed) OnPropertyChanged("Quality");
64      }
65    }
66
67    [StorableConstructor]
68    private QAPAssignment(bool deserializing) : base(deserializing) { }
69    private QAPAssignment(QAPAssignment original, Cloner cloner)
70      : base(original, cloner) {
71      coordinates = cloner.Clone(original.coordinates);
72      distances = cloner.Clone(original.distances);
73      weights = cloner.Clone(original.weights);
74      assignment = cloner.Clone(original.assignment);
75      quality = cloner.Clone(original.quality);
76    }
77    public QAPAssignment(DoubleMatrix weights, Permutation assignment) {
78      this.weights = weights;
79      this.assignment = assignment;
80    }
81    public QAPAssignment(DoubleMatrix weights, Permutation assignment, DoubleValue quality)
82      : this(weights, assignment) {
83      this.quality = quality;
84    }
85
86    public override IDeepCloneable Clone(Cloner cloner) {
87      return new QAPAssignment(this, cloner);
88    }
89
90
91    public event PropertyChangedEventHandler PropertyChanged;
92    private void OnPropertyChanged(string propertyName) {
93      var handler = PropertyChanged;
94      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
95    }
96  }
97}
Note: See TracBrowser for help on using the repository browser.