Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.LinearAssignment/3.3/LAPAssignment.cs @ 8022

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

#1855:

  • Transformed LAP into a SingleObjectiveHeuristicOptimizationProblem
  • Added HungarianAlgorithm as separate algorithm for solving the problem
File size: 3.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.PermutationEncoding;
27using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
28
29namespace 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]
46    private Permutation assignment;
47    public Permutation Assignment {
48      get { return assignment; }
49      set {
50        bool changed = (assignment != value);
51        assignment = value;
52        if (changed) OnPropertyChanged("Assignment");
53      }
54    }
55
56    [Storable]
57    private DoubleValue quality;
58    public DoubleValue Quality {
59      get { return quality; }
60      set {
61        bool changed = (quality != value);
62        quality = value;
63        if (changed) OnPropertyChanged("Quality");
64      }
65    }
66
67    [StorableConstructor]
68    private LAPAssignment(bool deserializing) : base(deserializing) { }
69    private LAPAssignment(LAPAssignment original, Cloner cloner)
70      : base(original, cloner) {
71      costs = cloner.Clone(original.costs);
72      assignment = cloner.Clone(original.assignment);
73      quality = cloner.Clone(original.quality);
74    }
75    public LAPAssignment(DoubleMatrix costs, Permutation assignment) {
76      this.costs = costs;
77      this.assignment = assignment;
78    }
79    public LAPAssignment(DoubleMatrix costs, Permutation assignment, DoubleValue quality)
80      : this(costs, assignment) {
81      this.quality = quality;
82    }
83
84    public override IDeepCloneable Clone(Cloner cloner) {
85      return new LAPAssignment(this, cloner);
86    }
87
88
89    public event PropertyChangedEventHandler PropertyChanged;
90    private void OnPropertyChanged(string propertyName) {
91      var handler = PropertyChanged;
92      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
93    }
94  }
95}
Note: See TracBrowser for help on using the repository browser.