Changeset 15511 for branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Moves/NMove.cs
- Timestamp:
- 12/11/17 23:06:32 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Moves/NMove.cs
r15504 r15511 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 23 using System.Linq; 24 24 using HeuristicLab.Common; 25 25 using HeuristicLab.Core; 26 using HeuristicLab.Encodings.IntegerVectorEncoding;27 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 27 … … 32 31 public class NMove : Item { 33 32 [Storable] 34 public Dictionary<int, int> NewAssignments { get; private set; } 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 } 35 43 [Storable] 36 public IntegerVector OriginalVector { get; private set; } 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 } 37 54 38 public int N { get { return NewAssignments.Count; } }55 public int N { get { return Indices.Count; } } 39 56 40 57 [StorableConstructor] … … 42 59 protected NMove(NMove original, Cloner cloner) 43 60 : base(original, cloner) { 44 NewAssignments = new Dictionary<int, int>(original.NewAssignments); 45 if (original.OriginalVector != null) 46 OriginalVector = cloner.Clone(original.OriginalVector); 61 reassignments = original.reassignments.ToArray(); 62 indices = original.indices.ToList(); 47 63 } 48 public NMove() : this(new int[0], new int[0], null) { } 49 public NMove(int[] equipments, int[] locations) : this(equipments, locations, null) { } 50 public NMove(int[] equipments, int[] locations, IntegerVector originalVector) 64 public NMove(int[] reassignments, List<int> indices) 51 65 : base() { 52 if (equipments == null) throw new ArgumentNullException("equipments", "NMove: Equipments must not be null."); 53 if (locations == null) throw new ArgumentNullException("locations", "NMove: Locations must not be null."); 54 if (equipments.Length != locations.Length) throw new ArgumentException("NMove: Length of equipments and locations is not identical."); 55 NewAssignments = new Dictionary<int, int>(); 56 for (int i = 0; i < equipments.Length; i++) 57 NewAssignments[equipments[i]] = locations[i]; 58 OriginalVector = originalVector; 66 this.reassignments = reassignments; 67 this.indices = indices; 59 68 } 60 69
Note: See TracChangeset
for help on using the changeset viewer.