Free cookie consent management tool by TermsFeed Policy Generator

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

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

#1330

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