Free cookie consent management tool by TermsFeed Policy Generator

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

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

#1614

  • Allowed to view the solution of a certain point in the pareto chart
  • Added multi crossovers and manipulators
  • Added population diversity analyzer
  • Fixed a few bugs
File size: 6.6 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 GQAPSolution solution;
36    public GQAPSolution Solution {
37      get { return solution; }
38      set {
39        bool changed = (solution != value);
40        solution = value;
41        if (changed) OnPropertyChanged("Solution");
42      }
43    }
44
45    [Storable]
46    private StringArray equipmentNames;
47    public StringArray EquipmentNames {
48      get { return equipmentNames; }
49      set {
50        bool changed = (equipmentNames != value);
51        equipmentNames = value;
52        if (changed) OnPropertyChanged("EquipmentNames");
53      }
54    }
55
56    [Storable]
57    private StringArray locationNames;
58    public StringArray LocationNames {
59      get { return locationNames; }
60      set {
61        bool changed = (locationNames != value);
62        locationNames = value;
63        if (changed) OnPropertyChanged("LocationNames");
64      }
65    }
66
67    [Storable]
68    private DoubleMatrix distances;
69    public DoubleMatrix Distances {
70      get { return distances; }
71      set {
72        bool changed = (distances != value);
73        distances = value;
74        if (changed) OnPropertyChanged("Distances");
75      }
76    }
77
78    [Storable]
79    private DoubleMatrix weights;
80    public DoubleMatrix Weights {
81      get { return weights; }
82      set {
83        bool changed = (weights != value);
84        weights = value;
85        if (changed) OnPropertyChanged("Weights");
86      }
87    }
88
89    [Storable]
90    private DoubleMatrix installationCosts;
91    public DoubleMatrix InstallationCosts {
92      get { return installationCosts; }
93      set {
94        bool changed = (installationCosts != value);
95        installationCosts = value;
96        if (changed) OnPropertyChanged("InstallationCosts");
97      }
98    }
99
100    [Storable]
101    private DoubleArray demands;
102    public DoubleArray Demands {
103      get { return demands; }
104      set {
105        bool changed = (demands != value);
106        demands = value;
107        if (changed) OnPropertyChanged("Demands");
108      }
109    }
110
111    [Storable]
112    private DoubleArray capacities;
113    public DoubleArray Capacities {
114      get { return capacities; }
115      set {
116        bool changed = (capacities != value);
117        capacities = value;
118        if (changed) OnPropertyChanged("Capacities");
119      }
120    }
121
122    [Storable]
123    private DoubleValue transportationCosts;
124    public DoubleValue TransportationCosts {
125      get { return transportationCosts; }
126      set {
127        bool changed = (transportationCosts != value);
128        transportationCosts = value;
129        if (changed) OnPropertyChanged("TransportationCosts");
130      }
131    }
132
133    [Storable]
134    private DoubleValue overbookedCapacityPenalty;
135    public DoubleValue OverbookedCapacityPenalty {
136      get { return overbookedCapacityPenalty; }
137      set {
138        bool changed = (overbookedCapacityPenalty != value);
139        overbookedCapacityPenalty = value;
140        if (changed) OnPropertyChanged("OverbookedCapacityPenalty");
141      }
142    }
143
144    [StorableConstructor]
145    private GQAPAssignment(bool deserializing) : base(deserializing) { }
146    private GQAPAssignment(GQAPAssignment original, Cloner cloner)
147      : base(original, cloner) {
148      equipmentNames = cloner.Clone(original.equipmentNames);
149      locationNames = cloner.Clone(original.locationNames);
150      distances = cloner.Clone(original.distances);
151      weights = cloner.Clone(original.weights);
152      installationCosts = cloner.Clone(original.installationCosts);
153      demands = cloner.Clone(original.demands);
154      capacities = cloner.Clone(original.capacities);
155      transportationCosts = cloner.Clone(original.transportationCosts);
156      overbookedCapacityPenalty = cloner.Clone(original.overbookedCapacityPenalty);
157    }
158    public GQAPAssignment(IntegerVector assignment, DoubleValue quality, DoubleValue flowDistanceQuality, DoubleValue installationQuality, DoubleValue overbookedCapacity)
159      : base() {
160      this.solution = new GQAPSolution(assignment, quality, flowDistanceQuality, installationQuality, overbookedCapacity);
161    }
162    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)
163      : this(assignment, quality, flowDistanceQuality, installationQuality, overbookedCapacity) {
164      this.equipmentNames = equipmentNames;
165      this.locationNames = locationNames;
166      this.distances = distances;
167      this.weights = weights;
168      this.installationCosts = installationCosts;
169      this.demands = demands;
170      this.capacities = capacities;
171      this.transportationCosts = transportationCosts;
172      this.overbookedCapacityPenalty = overbookedCapacityPenalty;
173    }
174
175    public override IDeepCloneable Clone(Cloner cloner) {
176      return new GQAPAssignment(this, cloner);
177    }
178
179    public event PropertyChangedEventHandler PropertyChanged;
180    private void OnPropertyChanged(string propertyName) {
181      var handler = PropertyChanged;
182      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
183    }
184  }
185}
Note: See TracBrowser for help on using the repository browser.