1 | using System.ComponentModel;
|
---|
2 | using HeuristicLab.Common;
|
---|
3 | using HeuristicLab.Core;
|
---|
4 | using HeuristicLab.Data;
|
---|
5 | using HeuristicLab.Encodings.PermutationEncoding;
|
---|
6 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
7 |
|
---|
8 | namespace 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 | }
|
---|