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 |
|
---|
13 | [Storable]
|
---|
14 | private DoubleMatrix distances;
|
---|
15 | public DoubleMatrix Distances {
|
---|
16 | get { return distances; }
|
---|
17 | set {
|
---|
18 | bool changed = (distances != value);
|
---|
19 | distances = value;
|
---|
20 | if (changed) OnPropertyChanged("Distances");
|
---|
21 | }
|
---|
22 | }
|
---|
23 |
|
---|
24 | [Storable]
|
---|
25 | private DoubleMatrix weights;
|
---|
26 | public DoubleMatrix Weights {
|
---|
27 | get { return weights; }
|
---|
28 | set {
|
---|
29 | bool changed = (weights != value);
|
---|
30 | weights = value;
|
---|
31 | if (changed) OnPropertyChanged("Weights");
|
---|
32 | }
|
---|
33 | }
|
---|
34 |
|
---|
35 | [Storable]
|
---|
36 | private Permutation assignment;
|
---|
37 | public Permutation Assignment {
|
---|
38 | get { return assignment; }
|
---|
39 | set {
|
---|
40 | bool changed = (assignment != value);
|
---|
41 | assignment = value;
|
---|
42 | if (changed) OnPropertyChanged("Assignment");
|
---|
43 | }
|
---|
44 | }
|
---|
45 |
|
---|
46 | [Storable]
|
---|
47 | private DoubleValue quality;
|
---|
48 | public DoubleValue Quality {
|
---|
49 | get { return quality; }
|
---|
50 | set {
|
---|
51 | bool changed = (quality != value);
|
---|
52 | quality = value;
|
---|
53 | if (changed) OnPropertyChanged("Quality");
|
---|
54 | }
|
---|
55 | }
|
---|
56 |
|
---|
57 | [StorableConstructor]
|
---|
58 | private QAPAssignment(bool deserializing) : base(deserializing) { }
|
---|
59 | private QAPAssignment(QAPAssignment original, Cloner cloner)
|
---|
60 | : base(original, cloner) {
|
---|
61 | distances = cloner.Clone(original.distances);
|
---|
62 | weights = cloner.Clone(original.weights);
|
---|
63 | assignment = cloner.Clone(original.assignment);
|
---|
64 | quality = cloner.Clone(original.quality);
|
---|
65 | }
|
---|
66 | public QAPAssignment(DoubleMatrix weights, Permutation assignment) {
|
---|
67 | this.weights = weights;
|
---|
68 | this.assignment = assignment;
|
---|
69 | }
|
---|
70 | public QAPAssignment(DoubleMatrix weights, Permutation assignment, DoubleValue quality)
|
---|
71 | : this(weights, assignment) {
|
---|
72 | this.quality = quality;
|
---|
73 | }
|
---|
74 |
|
---|
75 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
76 | return new QAPAssignment(this, cloner);
|
---|
77 | }
|
---|
78 |
|
---|
79 |
|
---|
80 | public event PropertyChangedEventHandler PropertyChanged;
|
---|
81 | private void OnPropertyChanged(string propertyName) {
|
---|
82 | var handler = PropertyChanged;
|
---|
83 | if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
|
---|
84 | }
|
---|
85 | }
|
---|
86 | }
|
---|