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