Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 9844 was 7970, checked in by abeham, 13 years ago

#1614: restructured architecture to allow for different evaluator with different penalty strategies

File size: 8.4 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 expectedRandomQuality;
179    public DoubleValue ExpectedRandomQuality {
180      get { return expectedRandomQuality; }
181      set {
182        bool changed = (expectedRandomQuality != value);
183        expectedRandomQuality = value;
184        if (changed) OnPropertyChanged("ExpectedRandomQuality");
185      }
186    }
187
188    [Storable]
189    private IGQAPEvaluator evaluator;
190    public IGQAPEvaluator Evaluator {
191      get { return evaluator; }
192      set {
193        bool changed = (evaluator != value);
194        evaluator = value;
195        if (changed) OnPropertyChanged("Evaluator");
196      }
197    }
198
199    [StorableConstructor]
200    private GQAPAssignment(bool deserializing) : base(deserializing) { }
201    private GQAPAssignment(GQAPAssignment original, Cloner cloner)
202      : base(original, cloner) {
203      assignment = cloner.Clone(original.assignment);
204      quality = cloner.Clone(original.quality);
205      flowDistanceQuality = cloner.Clone(original.flowDistanceQuality);
206      installationQuality = cloner.Clone(original.installationQuality);
207      overbookedCapacity = cloner.Clone(original.overbookedCapacity);
208      equipmentNames = cloner.Clone(original.equipmentNames);
209      locationNames = cloner.Clone(original.locationNames);
210      distances = cloner.Clone(original.distances);
211      weights = cloner.Clone(original.weights);
212      installationCosts = cloner.Clone(original.installationCosts);
213      demands = cloner.Clone(original.demands);
214      capacities = cloner.Clone(original.capacities);
215      transportationCosts = cloner.Clone(original.transportationCosts);
216      expectedRandomQuality = cloner.Clone(original.expectedRandomQuality);
217      evaluator = cloner.Clone(original.evaluator);
218    }
219    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 expectedRandomQuality, IGQAPEvaluator evaluator)
220      : base() {
221      this.assignment = assignment;
222      this.quality = quality;
223      this.flowDistanceQuality = flowDistanceQuality;
224      this.installationQuality = installationQuality;
225      this.overbookedCapacity = overbookedCapacity;
226      this.equipmentNames = equipmentNames;
227      this.locationNames = locationNames;
228      this.distances = distances;
229      this.weights = weights;
230      this.installationCosts = installationCosts;
231      this.demands = demands;
232      this.capacities = capacities;
233      this.transportationCosts = transportationCosts;
234      this.expectedRandomQuality = expectedRandomQuality;
235      this.evaluator = evaluator;
236    }
237
238    public override IDeepCloneable Clone(Cloner cloner) {
239      return new GQAPAssignment(this, cloner);
240    }
241
242    public event PropertyChangedEventHandler PropertyChanged;
243    private void OnPropertyChanged(string propertyName) {
244      var handler = PropertyChanged;
245      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
246    }
247  }
248}
Note: See TracBrowser for help on using the repository browser.