Free cookie consent management tool by TermsFeed Policy Generator

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

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

#1330

  • worked on visualization (and MDS)
File size: 3.3 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 viewCoordinates;
25    public DoubleMatrix ViewCoordinates {
26      get { return viewCoordinates; }
27      set {
28        bool changed = (viewCoordinates != value);
29        viewCoordinates = value;
30        if (changed) OnPropertyChanged("ViewCoordinates");
31      }
32    }
33
34    [Storable]
35    private DoubleMatrix distances;
36    public DoubleMatrix Distances {
37      get { return distances; }
38      set {
39        bool changed = (distances != value);
40        distances = value;
41        if (changed) OnPropertyChanged("Distances");
42      }
43    }
44
45    [Storable]
46    private DoubleMatrix weights;
47    public DoubleMatrix Weights {
48      get { return weights; }
49      set {
50        bool changed = (weights != value);
51        weights = value;
52        if (changed) OnPropertyChanged("Weights");
53      }
54    }
55
56    [Storable]
57    private Permutation assignment;
58    public Permutation Assignment {
59      get { return assignment; }
60      set {
61        bool changed = (assignment != value);
62        assignment = value;
63        if (changed) OnPropertyChanged("Assignment");
64      }
65    }
66
67    [Storable]
68    private DoubleValue quality;
69    public DoubleValue Quality {
70      get { return quality; }
71      set {
72        bool changed = (quality != value);
73        quality = value;
74        if (changed) OnPropertyChanged("Quality");
75      }
76    }
77
78    [StorableConstructor]
79    private QAPAssignment(bool deserializing) : base(deserializing) { }
80    private QAPAssignment(QAPAssignment original, Cloner cloner)
81      : base(original, cloner) {
82      coordinates = cloner.Clone(original.coordinates);
83      distances = cloner.Clone(original.distances);
84      weights = cloner.Clone(original.weights);
85      assignment = cloner.Clone(original.assignment);
86      quality = cloner.Clone(original.quality);
87      viewCoordinates = cloner.Clone(original.viewCoordinates);
88    }
89    public QAPAssignment(DoubleMatrix weights, Permutation assignment) {
90      this.weights = weights;
91      this.assignment = assignment;
92    }
93    public QAPAssignment(DoubleMatrix weights, Permutation assignment, DoubleValue quality)
94      : this(weights, assignment) {
95      this.quality = quality;
96    }
97
98    public override IDeepCloneable Clone(Cloner cloner) {
99      return new QAPAssignment(this, cloner);
100    }
101
102
103    public event PropertyChangedEventHandler PropertyChanged;
104    private void OnPropertyChanged(string propertyName) {
105      var handler = PropertyChanged;
106      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
107    }
108  }
109}
Note: See TracBrowser for help on using the repository browser.