Free cookie consent management tool by TermsFeed Policy Generator

source: branches/1614_GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/GQAPSolution.cs @ 17485

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

#1614: updated to new persistence and .NET 4.6.1

File size: 2.7 KB
RevLine 
[7418]1#region License Information
2/* HeuristicLab
[16728]3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[7418]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;
[16728]23using HEAL.Attic;
[7418]24using HeuristicLab.Common;
25using HeuristicLab.Core;
26using HeuristicLab.Encodings.IntegerVectorEncoding;
[16728]27using HEAL.Attic;
[7418]28
29namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment {
30  [Item("GQAPSolution", "A solution to the Generalized Quadratic Assignment Problem.")]
[16728]31  [StorableType("D4CC7924-87BF-4499-9149-D18000AD8151")]
[7418]32  public class GQAPSolution : Item, INotifyPropertyChanged {
33
34    [Storable]
35    private IntegerVector assignment;
36    public IntegerVector Assignment {
37      get { return assignment; }
38      set {
[15553]39        if (assignment == value) return;
[7418]40        assignment = value;
[15553]41        OnPropertyChanged(nameof(Assignment));
[7418]42      }
43    }
44
45    [Storable]
[15504]46    private Evaluation evaluation;
47    public Evaluation Evaluation {
48      get { return evaluation; }
[7418]49      set {
[15504]50        if (evaluation == value) return;
51        evaluation = value;
52        OnPropertyChanged(nameof(Evaluation));
[7418]53      }
54    }
55
56    [StorableConstructor]
[16728]57    protected GQAPSolution(StorableConstructorFlag _) : base(_) { }
[7418]58    protected GQAPSolution(GQAPSolution original, Cloner cloner)
59      : base(original, cloner) {
60      assignment = cloner.Clone(original.assignment);
[15504]61      evaluation = cloner.Clone(original.evaluation);
[7418]62    }
[15504]63    public GQAPSolution(IntegerVector assignment, Evaluation evaluation)
[7418]64      : base() {
65      this.assignment = assignment;
[15504]66      this.evaluation = evaluation;
[7418]67    }
68
69    public override IDeepCloneable Clone(Cloner cloner) {
70      return new GQAPSolution(this, cloner);
71    }
72
73    public event PropertyChangedEventHandler PropertyChanged;
74    protected virtual void OnPropertyChanged(string propertyName) {
75      var handler = PropertyChanged;
76      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
77    }
78  }
79}
Note: See TracBrowser for help on using the repository browser.