Free cookie consent management tool by TermsFeed Policy Generator

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

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

#1614

  • updated GQAP
File size: 4.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    [Storable]
79    private StringArray equipmentNames;
80    public StringArray EquipmentNames {
81      get { return equipmentNames; }
82      set {
83        bool changed = (equipmentNames != value);
84        equipmentNames = value;
85        if (changed) OnPropertyChanged("EquipmentNames");
86      }
87    }
88
89    [Storable]
90    private StringArray locationNames;
91    public StringArray LocationNames {
92      get { return locationNames; }
93      set {
94        bool changed = (locationNames != value);
95        locationNames = value;
96        if (changed) OnPropertyChanged("LocationNames");
97      }
98    }
99
100    [StorableConstructor]
101    private GQAPAssignment(bool deserializing) : base(deserializing) { }
102    private GQAPAssignment(GQAPAssignment original, Cloner cloner)
103      : base(original, cloner) {
104      distances = cloner.Clone(original.distances);
105      weights = cloner.Clone(original.weights);
106      assignment = cloner.Clone(original.assignment);
107      quality = cloner.Clone(original.quality);
108      equipmentNames = cloner.Clone(original.equipmentNames);
109      locationNames = cloner.Clone(original.locationNames);
110    }
111    public GQAPAssignment(DoubleMatrix weights, IntegerVector assignment) {
112      this.weights = weights;
113      this.assignment = assignment;
114    }
115    public GQAPAssignment(DoubleMatrix weights, IntegerVector assignment, DoubleValue quality)
116      : this(weights, assignment) {
117      this.quality = quality;
118    }
119    public GQAPAssignment(DoubleMatrix weights, IntegerVector assignment, DoubleValue quality, StringArray equipmentNames, StringArray locationNames)
120      : this(weights, assignment, quality) {
121      this.equipmentNames = equipmentNames;
122      this.locationNames = locationNames;
123    }
124
125    public override IDeepCloneable Clone(Cloner cloner) {
126      return new GQAPAssignment(this, cloner);
127    }
128
129    public event PropertyChangedEventHandler PropertyChanged;
130    private void OnPropertyChanged(string propertyName) {
131      var handler = PropertyChanged;
132      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
133    }
134  }
135}
Note: See TracBrowser for help on using the repository browser.