Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.QuadraticAssignment/3.3/QAPAssignment.cs @ 11624

Last change on this file since 11624 was 11171, checked in by ascheibe, 10 years ago

#2115 merged r11170 (copyright update) into trunk

File size: 3.4 KB
RevLine 
[5932]1#region License Information
2/* HeuristicLab
[11171]3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[5932]4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System.ComponentModel;
[5583]23using HeuristicLab.Common;
24using HeuristicLab.Core;
25using HeuristicLab.Data;
26using HeuristicLab.Encodings.PermutationEncoding;
27using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
28
29namespace HeuristicLab.Problems.QuadraticAssignment {
30  [Item("QAP Assignment", "Represents a solution to the QAP.")]
31  [StorableClass]
32  public sealed class QAPAssignment : Item, INotifyPropertyChanged {
33
[5641]34    [Storable]
[5583]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      distances = cloner.Clone(original.distances);
83      weights = cloner.Clone(original.weights);
84      assignment = cloner.Clone(original.assignment);
85      quality = cloner.Clone(original.quality);
86    }
87    public QAPAssignment(DoubleMatrix weights, Permutation assignment) {
88      this.weights = weights;
89      this.assignment = assignment;
90    }
91    public QAPAssignment(DoubleMatrix weights, Permutation assignment, DoubleValue quality)
92      : this(weights, assignment) {
93      this.quality = quality;
94    }
95
96    public override IDeepCloneable Clone(Cloner cloner) {
97      return new QAPAssignment(this, cloner);
98    }
99
100
101    public event PropertyChangedEventHandler PropertyChanged;
102    private void OnPropertyChanged(string propertyName) {
103      var handler = PropertyChanged;
104      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
105    }
106  }
107}
Note: See TracBrowser for help on using the repository browser.