#region License Information /* HeuristicLab * Copyright (C) 2002-2017 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; namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment { [Item("Generalized QAP Assignment", "Represents the solution as well as the problem parameters of a GQAP instance.")] [StorableClass] public sealed class GQAPAssignment : Item, INotifyPropertyChanged { [Storable] private IntegerVector assignment; public IntegerVector Assignment { get { return assignment; } set { if (assignment == value) return; assignment = value; OnPropertyChanged(nameof(Assignment)); } } [Storable] private Evaluation evaluation; public Evaluation Evaluation { get { return evaluation; } set { if (evaluation == value) return; evaluation = value; OnPropertyChanged(nameof(Evaluation)); } } [Storable] private GQAPInstance problemInstance; public GQAPInstance ProblemInstance { get { return problemInstance; } set { if (problemInstance == value) return; problemInstance = value; OnPropertyChanged(nameof(ProblemInstance)); } } [StorableConstructor] private GQAPAssignment(bool deserializing) : base(deserializing) { } private GQAPAssignment(GQAPAssignment original, Cloner cloner) : base(original, cloner) { assignment = cloner.Clone(original.assignment); evaluation = cloner.Clone(original.evaluation); 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.assignment = assignment; this.evaluation = evaluation; 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)); } } }