#region License Information /* HeuristicLab * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System.ComponentModel; using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Encodings.IntegerVectorEncoding; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; using HEAL.Attic; namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment { [Item("Generalized QAP Assignment", "Represents the solution as well as the problem parameters of a GQAP instance.")] [StorableType("8DAC9356-54EE-4EDC-9AB4-0DA47F111920")] public sealed class GQAPAssignment : Item, INotifyPropertyChanged { [Storable] private GQAPSolution solution; public GQAPSolution Solution { get { return solution; } set { if (solution == value) return; solution = value; OnPropertyChanged(nameof(Solution)); } } [Storable] private GQAPInstance problemInstance; public GQAPInstance ProblemInstance { get { return problemInstance; } set { if (problemInstance == value) return; problemInstance = value; OnPropertyChanged(nameof(ProblemInstance)); } } [StorableConstructor] private GQAPAssignment(StorableConstructorFlag _) : base(_) { } private GQAPAssignment(GQAPAssignment original, Cloner cloner) : base(original, cloner) { solution = cloner.Clone(original.solution); problemInstance = cloner.Clone(original.problemInstance); } public GQAPAssignment(IntegerVector assignment, GQAPInstance problemInstance) : this(assignment, problemInstance, problemInstance.Evaluate(assignment)) { } public GQAPAssignment(IntegerVector assignment, GQAPInstance problemInstance, Evaluation evaluation) : base() { this.solution = new GQAPSolution(assignment, evaluation); this.problemInstance = problemInstance; } public GQAPAssignment(GQAPSolution solution, GQAPInstance problemInstance) : base() { this.solution = solution; this.problemInstance = problemInstance; } public override IDeepCloneable Clone(Cloner cloner) { return new GQAPAssignment(this, cloner); } public event PropertyChangedEventHandler PropertyChanged; private void OnPropertyChanged(string propertyName) { var handler = PropertyChanged; if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName)); } } }