Free cookie consent management tool by TermsFeed Policy Generator

source: branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/GQAPAssignment.cs @ 7063

Last change on this file since 7063 was 6956, checked in by abeham, 13 years ago

#1614

  • readded new simpler branch
File size: 3.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
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;
23using HeuristicLab.Common;
24using HeuristicLab.Core;
25using HeuristicLab.Data;
26using HeuristicLab.Encodings.IntegerVectorEncoding;
27using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
28
29namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment {
30  [Item("Generalized QAP Assignment", "Represents a solution to the generalized QAP.")]
31  [StorableClass]
32  public sealed class GQAPAssignment : Item, INotifyPropertyChanged {
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 IntegerVector assignment;
58    public IntegerVector 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 GQAPAssignment(bool deserializing) : base(deserializing) { }
80    private GQAPAssignment(GQAPAssignment 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 GQAPAssignment(DoubleMatrix weights, IntegerVector assignment) {
88      this.weights = weights;
89      this.assignment = assignment;
90    }
91    public GQAPAssignment(DoubleMatrix weights, IntegerVector assignment, DoubleValue quality)
92      : this(weights, assignment) {
93      this.quality = quality;
94    }
95
96    public override IDeepCloneable Clone(Cloner cloner) {
97      return new GQAPAssignment(this, cloner);
98    }
99
100    public event PropertyChangedEventHandler PropertyChanged;
101    private void OnPropertyChanged(string propertyName) {
102      var handler = PropertyChanged;
103      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
104    }
105  }
106}
Note: See TracBrowser for help on using the repository browser.