Free cookie consent management tool by TermsFeed Policy Generator

source: branches/1614_GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/GQAPAssignment.cs @ 16728

Last change on this file since 16728 was 16728, checked in by abeham, 6 years ago

#1614: updated to new persistence and .NET 4.6.1

File size: 3.1 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2018 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 HEAL.Attic;
24using HeuristicLab.Common;
25using HeuristicLab.Core;
26using HeuristicLab.Encodings.IntegerVectorEncoding;
27using HEAL.Attic;
28
29namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment {
30  [Item("Generalized QAP Assignment", "Represents the solution as well as the problem parameters of a GQAP instance.")]
31  [StorableType("8DAC9356-54EE-4EDC-9AB4-0DA47F111920")]
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        if (solution == value) return;
40        solution = value;
41        OnPropertyChanged(nameof(Solution));
42      }
43    }
44
45    [Storable]
46    private GQAPInstance problemInstance;
47    public GQAPInstance ProblemInstance {
48      get { return problemInstance; }
49      set {
50        if (problemInstance == value) return;
51        problemInstance = value;
52        OnPropertyChanged(nameof(ProblemInstance));
53      }
54    }
55
56    [StorableConstructor]
57    private GQAPAssignment(StorableConstructorFlag _) : base(_) { }
58    private GQAPAssignment(GQAPAssignment original, Cloner cloner)
59      : base(original, cloner) {
60      solution = cloner.Clone(original.solution);
61      problemInstance = cloner.Clone(original.problemInstance);
62    }
63    public GQAPAssignment(IntegerVector assignment, GQAPInstance problemInstance)
64      : this(assignment, problemInstance, problemInstance.Evaluate(assignment)) { }
65    public GQAPAssignment(IntegerVector assignment, GQAPInstance problemInstance, Evaluation evaluation)
66      : base() {
67      this.solution = new GQAPSolution(assignment, evaluation);
68      this.problemInstance = problemInstance;
69    }
70    public GQAPAssignment(GQAPSolution solution, GQAPInstance problemInstance)
71      : base() {
72      this.solution = solution;
73      this.problemInstance = problemInstance;
74    }
75
76    public override IDeepCloneable Clone(Cloner cloner) {
77      return new GQAPAssignment(this, cloner);
78    }
79
80    public event PropertyChangedEventHandler PropertyChanged;
81    private void OnPropertyChanged(string propertyName) {
82      var handler = PropertyChanged;
83      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
84    }
85  }
86}
Note: See TracBrowser for help on using the repository browser.