Changeset 11363 for branches/SimSharp/HeuristicLab.Problems.Programmable/3.3/Datastructures/ParameterVector.cs
- Timestamp:
- 09/15/14 10:23:34 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SimSharp/HeuristicLab.Problems.Programmable/3.3/Datastructures/ParameterVector.cs
r10850 r11363 22 22 using System.Collections.Generic; 23 23 using System.Linq; 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Encodings.BinaryVectorEncoding; 25 26 using HeuristicLab.Encodings.IntegerVectorEncoding; … … 28 29 29 30 namespace HeuristicLab.Problems.Programmable { 30 public class ParameterVector{31 pr otectedDictionary<string, BinaryVector> BinaryParameters;32 pr otectedDictionary<string, IntegerVector> IntegerParameters;33 pr otectedDictionary<string, RealVector> RealParameters;34 pr otectedDictionary<string, Permutation> PermutationParameters;31 public sealed class ParameterVector : IDeepCloneable { 32 private Dictionary<string, BinaryVector> BinaryParameters; 33 private Dictionary<string, IntegerVector> IntegerParameters; 34 private Dictionary<string, RealVector> RealParameters; 35 private Dictionary<string, Permutation> PermutationParameters; 35 36 36 37 public ParameterVector(IEnumerable<KeyValuePair<string, BinaryVector>> binaryVectors = null, … … 42 43 if (realVectors != null) RealParameters = realVectors.ToDictionary(x => x.Key, x => x.Value); 43 44 if (permutations != null) PermutationParameters = permutations.ToDictionary(x => x.Key, x => x.Value); 45 } 46 private ParameterVector(ParameterVector original, Cloner cloner) { 47 cloner.RegisterClonedObject(original, this); 48 if (original.BinaryParameters != null) { 49 BinaryParameters = new Dictionary<string, BinaryVector>(original.BinaryParameters.Comparer); 50 foreach (var param in original.BinaryParameters) 51 BinaryParameters[param.Key] = cloner.Clone(param.Value); 52 } 53 if (original.IntegerParameters != null) { 54 IntegerParameters = new Dictionary<string, IntegerVector>(original.IntegerParameters.Comparer); 55 foreach (var param in original.IntegerParameters) 56 IntegerParameters[param.Key] = cloner.Clone(param.Value); 57 } 58 if (original.RealParameters != null) { 59 RealParameters = new Dictionary<string, RealVector>(original.RealParameters.Comparer); 60 foreach (var param in original.RealParameters) 61 RealParameters[param.Key] = cloner.Clone(param.Value); 62 } 63 if (original.PermutationParameters != null) { 64 PermutationParameters = new Dictionary<string, Permutation>(original.PermutationParameters.Comparer); 65 foreach (var param in original.PermutationParameters) 66 PermutationParameters[param.Key] = cloner.Clone(param.Value); 67 } 68 } 69 70 public object Clone() { 71 return Clone(new Cloner()); 72 } 73 74 public IDeepCloneable Clone(Cloner cloner) { 75 return new ParameterVector(this, cloner); 44 76 } 45 77 … … 53 85 54 86 public IEnumerable<string> BinaryNames { 55 get { return BinaryParameters .Keys; }87 get { return BinaryParameters != null ? BinaryParameters.Keys : Enumerable.Empty<string>(); } 56 88 } 57 89 … … 65 97 66 98 public IEnumerable<string> IntegerNames { 67 get { return IntegerParameters .Keys; }99 get { return IntegerParameters != null ? IntegerParameters.Keys : Enumerable.Empty<string>(); } 68 100 } 69 101 … … 77 109 78 110 public IEnumerable<string> RealNames { 79 get { return RealParameters .Keys; }111 get { return RealParameters != null ? RealParameters.Keys : Enumerable.Empty<string>(); } 80 112 } 81 113 … … 85 117 86 118 public IEnumerable<string> PermutationNames { 87 get { return PermutationParameters .Keys; }119 get { return PermutationParameters != null ? PermutationParameters.Keys : Enumerable.Empty<string>(); } 88 120 } 89 121 }
Note: See TracChangeset
for help on using the changeset viewer.