#region License Information /* HeuristicLab * Copyright (C) 2002-2012 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; using System.Collections.Generic; using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Encodings.IntegerVectorEncoding; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment { [Item("N-Move", "An N-Move describes the relocation of n equipments to n different locations.")] [StorableClass] public class NMove : Item { [Storable] public Dictionary NewAssignments { get; private set; } [Storable] public IntegerVector OriginalVector { get; private set; } public int N { get { return NewAssignments.Count; } } [StorableConstructor] protected NMove(bool deserializing) : base(deserializing) { } protected NMove(NMove original, Cloner cloner) : base(original, cloner) { NewAssignments = new Dictionary(original.NewAssignments); if (original.OriginalVector != null) OriginalVector = cloner.Clone(original.OriginalVector); } public NMove() : this(new int[0], new int[0], null) { } public NMove(int[] equipments, int[] locations) : this(equipments, locations, null) { } public NMove(int[] equipments, int[] locations, IntegerVector originalVector) : base() { if (equipments == null) throw new ArgumentNullException("equipments", "NMove: Equipments must not be null."); if (locations == null) throw new ArgumentNullException("locations", "NMove: Locations must not be null."); if (equipments.Length != locations.Length) throw new ArgumentException("NMove: Length of equipments and locations is not identical."); NewAssignments = new Dictionary(); for (int i = 0; i < equipments.Length; i++) NewAssignments[equipments[i]] = locations[i]; OriginalVector = originalVector; } public override IDeepCloneable Clone(Cloner cloner) { return new NMove(this, cloner); } } }