Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 7759 was 7470, checked in by abeham, 13 years ago

#1614

  • Removed incompatible problem linhp318.tsp (contains fixed edges)
  • Fixed AssemblyInfo for TSPLIB
  • Added unit tests
  • Worked on assignment / solution view
File size: 8.1 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 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 the solution as well as the problem parameters of a GQAP instance.")]
31  [StorableClass]
32  public sealed class GQAPAssignment : Item, INotifyPropertyChanged {
33
34    [Storable]
35    private IntegerVector assignment;
36    public IntegerVector Assignment {
37      get { return assignment; }
38      set {
39        bool changed = (assignment != value);
40        assignment = value;
41        if (changed) OnPropertyChanged("Assignment");
42      }
43    }
44
45    [Storable]
46    private DoubleValue quality;
47    public DoubleValue Quality {
48      get { return quality; }
49      set {
50        bool changed = (quality != value);
51        quality = value;
52        if (changed) OnPropertyChanged("Quality");
53      }
54    }
55
56    [Storable]
57    private DoubleValue flowDistanceQuality;
58    public DoubleValue FlowDistanceQuality {
59      get { return flowDistanceQuality; }
60      set {
61        bool changed = (flowDistanceQuality != value);
62        flowDistanceQuality = value;
63        if (changed) OnPropertyChanged("FlowDistanceQuality");
64      }
65    }
66
67    [Storable]
68    private DoubleValue installationQuality;
69    public DoubleValue InstallationQuality {
70      get { return installationQuality; }
71      set {
72        bool changed = (installationQuality != value);
73        installationQuality = value;
74        if (changed) OnPropertyChanged("InstallationQuality");
75      }
76    }
77
78    [Storable]
79    private DoubleValue overbookedCapacity;
80    public DoubleValue OverbookedCapacity {
81      get { return overbookedCapacity; }
82      set {
83        bool changed = (overbookedCapacity != value);
84        overbookedCapacity = value;
85        if (changed) OnPropertyChanged("OverbookedCapacity");
86      }
87    }
88
89    [Storable]
90    private StringArray equipmentNames;
91    public StringArray EquipmentNames {
92      get { return equipmentNames; }
93      set {
94        bool changed = (equipmentNames != value);
95        equipmentNames = value;
96        if (changed) OnPropertyChanged("EquipmentNames");
97      }
98    }
99
100    [Storable]
101    private StringArray locationNames;
102    public StringArray LocationNames {
103      get { return locationNames; }
104      set {
105        bool changed = (locationNames != value);
106        locationNames = value;
107        if (changed) OnPropertyChanged("LocationNames");
108      }
109    }
110
111    [Storable]
112    private DoubleMatrix distances;
113    public DoubleMatrix Distances {
114      get { return distances; }
115      set {
116        bool changed = (distances != value);
117        distances = value;
118        if (changed) OnPropertyChanged("Distances");
119      }
120    }
121
122    [Storable]
123    private DoubleMatrix weights;
124    public DoubleMatrix Weights {
125      get { return weights; }
126      set {
127        bool changed = (weights != value);
128        weights = value;
129        if (changed) OnPropertyChanged("Weights");
130      }
131    }
132
133    [Storable]
134    private DoubleMatrix installationCosts;
135    public DoubleMatrix InstallationCosts {
136      get { return installationCosts; }
137      set {
138        bool changed = (installationCosts != value);
139        installationCosts = value;
140        if (changed) OnPropertyChanged("InstallationCosts");
141      }
142    }
143
144    [Storable]
145    private DoubleArray demands;
146    public DoubleArray Demands {
147      get { return demands; }
148      set {
149        bool changed = (demands != value);
150        demands = value;
151        if (changed) OnPropertyChanged("Demands");
152      }
153    }
154
155    [Storable]
156    private DoubleArray capacities;
157    public DoubleArray Capacities {
158      get { return capacities; }
159      set {
160        bool changed = (capacities != value);
161        capacities = value;
162        if (changed) OnPropertyChanged("Capacities");
163      }
164    }
165
166    [Storable]
167    private DoubleValue transportationCosts;
168    public DoubleValue TransportationCosts {
169      get { return transportationCosts; }
170      set {
171        bool changed = (transportationCosts != value);
172        transportationCosts = value;
173        if (changed) OnPropertyChanged("TransportationCosts");
174      }
175    }
176
177    [Storable]
178    private DoubleValue overbookedCapacityPenalty;
179    public DoubleValue OverbookedCapacityPenalty {
180      get { return overbookedCapacityPenalty; }
181      set {
182        bool changed = (overbookedCapacityPenalty != value);
183        overbookedCapacityPenalty = value;
184        if (changed) OnPropertyChanged("OverbookedCapacityPenalty");
185      }
186    }
187
188    [StorableConstructor]
189    private GQAPAssignment(bool deserializing) : base(deserializing) { }
190    private GQAPAssignment(GQAPAssignment original, Cloner cloner)
191      : base(original, cloner) {
192      assignment = cloner.Clone(original.assignment);
193      quality = cloner.Clone(original.quality);
194      flowDistanceQuality = cloner.Clone(original.flowDistanceQuality);
195      installationQuality = cloner.Clone(original.installationQuality);
196      overbookedCapacity = cloner.Clone(original.overbookedCapacity);
197      equipmentNames = cloner.Clone(original.equipmentNames);
198      locationNames = cloner.Clone(original.locationNames);
199      distances = cloner.Clone(original.distances);
200      weights = cloner.Clone(original.weights);
201      installationCosts = cloner.Clone(original.installationCosts);
202      demands = cloner.Clone(original.demands);
203      capacities = cloner.Clone(original.capacities);
204      transportationCosts = cloner.Clone(original.transportationCosts);
205      overbookedCapacityPenalty = cloner.Clone(original.overbookedCapacityPenalty);
206    }
207    public GQAPAssignment(IntegerVector assignment, DoubleValue quality, DoubleValue flowDistanceQuality, DoubleValue installationQuality, DoubleValue overbookedCapacity, StringArray equipmentNames, StringArray locationNames, DoubleMatrix distances, DoubleMatrix weights, DoubleMatrix installationCosts, DoubleArray demands, DoubleArray capacities, DoubleValue transportationCosts, DoubleValue overbookedCapacityPenalty)
208      : base() {
209      this.assignment = assignment;
210      this.quality = quality;
211      this.flowDistanceQuality = flowDistanceQuality;
212      this.installationQuality = installationQuality;
213      this.overbookedCapacity = overbookedCapacity;
214      this.equipmentNames = equipmentNames;
215      this.locationNames = locationNames;
216      this.distances = distances;
217      this.weights = weights;
218      this.installationCosts = installationCosts;
219      this.demands = demands;
220      this.capacities = capacities;
221      this.transportationCosts = transportationCosts;
222      this.overbookedCapacityPenalty = overbookedCapacityPenalty;
223    }
224
225    public override IDeepCloneable Clone(Cloner cloner) {
226      return new GQAPAssignment(this, cloner);
227    }
228
229    public event PropertyChangedEventHandler PropertyChanged;
230    private void OnPropertyChanged(string propertyName) {
231      var handler = PropertyChanged;
232      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
233    }
234  }
235}
Note: See TracBrowser for help on using the repository browser.