[6956] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[16077] | 3 | * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[6956] | 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.Encodings.IntegerVectorEncoding;
|
---|
| 26 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
[16712] | 27 | using HEAL.Attic;
|
---|
[6956] | 28 |
|
---|
| 29 | namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment {
|
---|
[7432] | 30 | [Item("Generalized QAP Assignment", "Represents the solution as well as the problem parameters of a GQAP instance.")]
|
---|
[16712] | 31 | [StorableType("8DAC9356-54EE-4EDC-9AB4-0DA47F111920")]
|
---|
[6956] | 32 | public sealed class GQAPAssignment : Item, INotifyPropertyChanged {
|
---|
| 33 |
|
---|
| 34 | [Storable]
|
---|
[16077] | 35 | private GQAPSolution solution;
|
---|
| 36 | public GQAPSolution Solution {
|
---|
| 37 | get { return solution; }
|
---|
[6956] | 38 | set {
|
---|
[16077] | 39 | if (solution == value) return;
|
---|
| 40 | solution = value;
|
---|
| 41 | OnPropertyChanged(nameof(Solution));
|
---|
[6956] | 42 | }
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 | [Storable]
|
---|
[15504] | 46 | private GQAPInstance problemInstance;
|
---|
| 47 | public GQAPInstance ProblemInstance {
|
---|
| 48 | get { return problemInstance; }
|
---|
[7470] | 49 | set {
|
---|
[15504] | 50 | if (problemInstance == value) return;
|
---|
| 51 | problemInstance = value;
|
---|
| 52 | OnPropertyChanged(nameof(ProblemInstance));
|
---|
[7470] | 53 | }
|
---|
| 54 | }
|
---|
| 55 |
|
---|
[6956] | 56 | [StorableConstructor]
|
---|
[16712] | 57 | private GQAPAssignment(StorableConstructorFlag _) : base(_) { }
|
---|
[6956] | 58 | private GQAPAssignment(GQAPAssignment original, Cloner cloner)
|
---|
| 59 | : base(original, cloner) {
|
---|
[16077] | 60 | solution = cloner.Clone(original.solution);
|
---|
[15504] | 61 | problemInstance = cloner.Clone(original.problemInstance);
|
---|
[6956] | 62 | }
|
---|
[15504] | 63 | public GQAPAssignment(IntegerVector assignment, GQAPInstance problemInstance)
|
---|
| 64 | : this(assignment, problemInstance, problemInstance.Evaluate(assignment)) { }
|
---|
| 65 | public GQAPAssignment(IntegerVector assignment, GQAPInstance problemInstance, Evaluation evaluation)
|
---|
[7415] | 66 | : base() {
|
---|
[16077] | 67 | this.solution = new GQAPSolution(assignment, evaluation);
|
---|
[15504] | 68 | this.problemInstance = problemInstance;
|
---|
[7415] | 69 | }
|
---|
[16077] | 70 | public GQAPAssignment(GQAPSolution solution, GQAPInstance problemInstance)
|
---|
| 71 | : base() {
|
---|
| 72 | this.solution = solution;
|
---|
| 73 | this.problemInstance = problemInstance;
|
---|
| 74 | }
|
---|
[6956] | 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 | }
|
---|