1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2019 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 |
|
---|
22 | using System.ComponentModel;
|
---|
23 | using HeuristicLab.Common;
|
---|
24 | using HeuristicLab.Core;
|
---|
25 | using HeuristicLab.Data;
|
---|
26 | using HeuristicLab.Encodings.PermutationEncoding;
|
---|
27 | using HEAL.Attic;
|
---|
28 |
|
---|
29 | namespace HeuristicLab.Problems.LinearAssignment {
|
---|
30 | [Item("LAP Assignment", "Represents a solution to the LAP.")]
|
---|
31 | [StorableType("8F255E15-291B-44D5-BF8B-AC79264274C0")]
|
---|
32 | public sealed class LAPAssignment : Item, INotifyPropertyChanged, IStorableContent {
|
---|
33 | public string Filename { get; set; }
|
---|
34 |
|
---|
35 | [Storable]
|
---|
36 | private DoubleMatrix costs;
|
---|
37 | public DoubleMatrix Costs {
|
---|
38 | get { return costs; }
|
---|
39 | set {
|
---|
40 | bool changed = (costs != value);
|
---|
41 | costs = value;
|
---|
42 | if (changed) OnPropertyChanged("Costs");
|
---|
43 | }
|
---|
44 | }
|
---|
45 |
|
---|
46 | [Storable]
|
---|
47 | private StringArray rowNames;
|
---|
48 | public StringArray RowNames {
|
---|
49 | get { return rowNames; }
|
---|
50 | set {
|
---|
51 | bool changed = (rowNames != value);
|
---|
52 | rowNames = value;
|
---|
53 | if (changed) OnPropertyChanged("RowNames");
|
---|
54 | }
|
---|
55 | }
|
---|
56 |
|
---|
57 | [Storable]
|
---|
58 | private StringArray columnNames;
|
---|
59 | public StringArray ColumnNames {
|
---|
60 | get { return columnNames; }
|
---|
61 | set {
|
---|
62 | bool changed = (columnNames != value);
|
---|
63 | columnNames = value;
|
---|
64 | if (changed) OnPropertyChanged("ColumnNames");
|
---|
65 | }
|
---|
66 | }
|
---|
67 |
|
---|
68 | [Storable]
|
---|
69 | private Permutation assignment;
|
---|
70 | public Permutation Assignment {
|
---|
71 | get { return assignment; }
|
---|
72 | set {
|
---|
73 | bool changed = (assignment != value);
|
---|
74 | assignment = value;
|
---|
75 | if (changed) OnPropertyChanged("Assignment");
|
---|
76 | }
|
---|
77 | }
|
---|
78 |
|
---|
79 | [Storable]
|
---|
80 | private DoubleValue quality;
|
---|
81 | public DoubleValue Quality {
|
---|
82 | get { return quality; }
|
---|
83 | set {
|
---|
84 | bool changed = (quality != value);
|
---|
85 | quality = value;
|
---|
86 | if (changed) OnPropertyChanged("Quality");
|
---|
87 | }
|
---|
88 | }
|
---|
89 |
|
---|
90 | [StorableConstructor]
|
---|
91 | private LAPAssignment(StorableConstructorFlag _) : base(_) { }
|
---|
92 | private LAPAssignment(LAPAssignment original, Cloner cloner)
|
---|
93 | : base(original, cloner) {
|
---|
94 | costs = cloner.Clone(original.costs);
|
---|
95 | assignment = cloner.Clone(original.assignment);
|
---|
96 | rowNames = cloner.Clone(original.rowNames);
|
---|
97 | columnNames = cloner.Clone(original.columnNames);
|
---|
98 | quality = cloner.Clone(original.quality);
|
---|
99 | }
|
---|
100 | public LAPAssignment(DoubleMatrix costs, Permutation assignment) {
|
---|
101 | this.costs = costs;
|
---|
102 | this.assignment = assignment;
|
---|
103 | }
|
---|
104 | public LAPAssignment(DoubleMatrix costs, Permutation assignment, DoubleValue quality)
|
---|
105 | : this(costs, assignment) {
|
---|
106 | this.quality = quality;
|
---|
107 | }
|
---|
108 | public LAPAssignment(DoubleMatrix costs, StringArray rowNames, StringArray columnNames, Permutation assignment)
|
---|
109 | : this(costs, assignment) {
|
---|
110 | this.rowNames = rowNames;
|
---|
111 | this.columnNames = columnNames;
|
---|
112 | }
|
---|
113 | public LAPAssignment(DoubleMatrix costs, StringArray rowNames, StringArray columnNames, Permutation assignment, DoubleValue quality)
|
---|
114 | : this(costs, rowNames, columnNames, assignment) {
|
---|
115 | this.quality = quality;
|
---|
116 | }
|
---|
117 |
|
---|
118 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
119 | return new LAPAssignment(this, cloner);
|
---|
120 | }
|
---|
121 |
|
---|
122 | public event PropertyChangedEventHandler PropertyChanged;
|
---|
123 | private void OnPropertyChanged(string propertyName) {
|
---|
124 | var handler = PropertyChanged;
|
---|
125 | if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
|
---|
126 | }
|
---|
127 | }
|
---|
128 | }
|
---|