[7407] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[15504] | 3 | * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[7407] | 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 |
|
---|
[7505] | 22 | using System.Collections.Generic;
|
---|
[15511] | 23 | using System.Linq;
|
---|
[7407] | 24 | using HeuristicLab.Common;
|
---|
| 25 | using HeuristicLab.Core;
|
---|
| 26 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 27 |
|
---|
| 28 | namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment {
|
---|
[7505] | 29 | [Item("N-Move", "An N-Move describes the relocation of n equipments to n different locations.")]
|
---|
[7407] | 30 | [StorableClass]
|
---|
| 31 | public class NMove : Item {
|
---|
| 32 | [Storable]
|
---|
[15511] | 33 | private int[] reassignments;
|
---|
| 34 | /// <summary>
|
---|
| 35 | /// Contains for each equipment the newly assigned location.
|
---|
| 36 | /// </summary>
|
---|
| 37 | /// <remarks>
|
---|
| 38 | /// Locations are 1-based. A 0 indicates that this equipment is not reassigned.
|
---|
| 39 | /// </remarks>
|
---|
| 40 | public IReadOnlyList<int> Reassignments {
|
---|
| 41 | get { return reassignments; }
|
---|
| 42 | }
|
---|
[7407] | 43 | [Storable]
|
---|
[15511] | 44 | private List<int> indices;
|
---|
| 45 | /// <summary>
|
---|
| 46 | /// Which indices (=equipments) are reassigned.
|
---|
| 47 | /// </summary>
|
---|
| 48 | /// <remarks>
|
---|
| 49 | /// Equipments are 0-based.
|
---|
| 50 | /// </remarks>
|
---|
| 51 | public IReadOnlyList<int> Indices {
|
---|
| 52 | get { return indices; }
|
---|
| 53 | }
|
---|
[7407] | 54 |
|
---|
[15511] | 55 | public int N { get { return Indices.Count; } }
|
---|
[7407] | 56 |
|
---|
| 57 | [StorableConstructor]
|
---|
| 58 | protected NMove(bool deserializing) : base(deserializing) { }
|
---|
| 59 | protected NMove(NMove original, Cloner cloner)
|
---|
| 60 | : base(original, cloner) {
|
---|
[15511] | 61 | reassignments = original.reassignments.ToArray();
|
---|
| 62 | indices = original.indices.ToList();
|
---|
[7407] | 63 | }
|
---|
[15511] | 64 | public NMove(int[] reassignments, List<int> indices)
|
---|
[7407] | 65 | : base() {
|
---|
[15511] | 66 | this.reassignments = reassignments;
|
---|
| 67 | this.indices = indices;
|
---|
[7407] | 68 | }
|
---|
| 69 |
|
---|
| 70 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 71 | return new NMove(this, cloner);
|
---|
| 72 | }
|
---|
| 73 | }
|
---|
| 74 | }
|
---|