Changeset 4200 for trunk/sources/HeuristicLab.Optimization
- Timestamp:
- 08/11/10 17:40:00 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Optimization/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization/3.3/Run.cs
r4161 r4200 34 34 [StorableClass] 35 35 public sealed class Run : NamedItem, IRun { 36 [StorableConstructor] 37 private Run(bool deserializing) : base(deserializing) { } 38 public Run() 39 : base() { 40 name = ItemName; 41 description = ItemDescription; 42 color = Color.Black; 43 algorithm = null; 44 parameters = new Dictionary<string, IItem>(); 45 results = new Dictionary<string, IItem>(); 46 } 47 public Run(IAlgorithm algorithm) 48 : base() { 49 if (algorithm == null) throw new ArgumentNullException(); 50 name = algorithm.Name + " Run (" + algorithm.ExecutionTime.ToString() + ")"; 51 description = ItemDescription; 52 color = Color.Black; 53 Initialize(algorithm); 54 } 55 public Run(string name, IAlgorithm algorithm) 56 : base(name) { 57 if (algorithm == null) throw new ArgumentNullException(); 58 color = Color.Black; 59 description = ItemDescription; 60 Initialize(algorithm); 61 } 62 public Run(string name, string description, IAlgorithm algorithm) 63 : base(name, description) { 64 if (algorithm == null) throw new ArgumentNullException(); 65 color = Color.Black; 66 Initialize(algorithm); 67 } 68 69 private void Initialize(IAlgorithm algorithm) { 70 IAlgorithm clone = (IAlgorithm)algorithm.Clone(); 71 parameters = new Dictionary<string, IItem>(); 72 results = new Dictionary<string, IItem>(); 73 clone.CollectParameterValues(parameters); 74 clone.CollectResultValues(results); 75 if (clone.StoreAlgorithmInEachRun) { 76 clone.Prepare(true); 77 this.algorithm = clone; 78 } 79 } 80 [StorableHook(HookType.AfterDeserialization)] 81 private void AfterDeserializationHook() { 82 if (color == Color.Empty) color = Color.Black; 83 } 84 36 85 [Storable] 37 86 private IAlgorithm algorithm; … … 78 127 } 79 128 80 [StorableConstructor]81 private Run(bool deserializing) : base(deserializing) { }82 public Run()83 : base() {84 name = ItemName;85 description = ItemDescription;86 color = Color.Black;87 algorithm = null;88 parameters = new Dictionary<string, IItem>();89 results = new Dictionary<string, IItem>();90 }91 public Run(IAlgorithm algorithm)92 : base() {93 if (algorithm == null) throw new ArgumentNullException();94 name = algorithm.Name + " Run (" + algorithm.ExecutionTime.ToString() + ")";95 description = ItemDescription;96 color = Color.Black;97 Initialize(algorithm);98 }99 public Run(string name, IAlgorithm algorithm)100 : base(name) {101 if (algorithm == null) throw new ArgumentNullException();102 color = Color.Black;103 description = ItemDescription;104 Initialize(algorithm);105 }106 public Run(string name, string description, IAlgorithm algorithm)107 : base(name, description) {108 if (algorithm == null) throw new ArgumentNullException();109 color = Color.Black;110 Initialize(algorithm);111 }112 113 private void Initialize(IAlgorithm algorithm) {114 IAlgorithm clone = (IAlgorithm)algorithm.Clone();115 parameters = new Dictionary<string, IItem>();116 results = new Dictionary<string, IItem>();117 clone.CollectParameterValues(parameters);118 clone.CollectResultValues(results);119 if (clone.StoreAlgorithmInEachRun) {120 clone.Prepare(true);121 this.algorithm = clone;122 }123 }124 125 [StorableHook(HookType.AfterDeserialization)]126 private void AfterDeserializationHook() {127 if (color == Color.Empty) color = Color.Black;128 }129 130 129 public override IDeepCloneable Clone(Cloner cloner) { 131 130 Run clone = (Run)base.Clone(cloner); -
trunk/sources/HeuristicLab.Optimization/3.3/RunCollection.cs
r4164 r4200 72 72 base.OnCollectionReset(items, oldItems); 73 73 OnReset(); 74 columnNameCache = null; 74 75 OnColumnNamesChanged(); 76 rowNamesCache = null; 75 77 OnRowNamesChanged(); 76 78 } … … 85 87 base.OnItemsAdded(items); 86 88 OnReset(); 87 if (columnNamesChanged) 89 if (columnNamesChanged) { 90 columnNameCache = null; 88 91 OnColumnNamesChanged(); 92 } 93 rowNamesCache = null; 89 94 OnRowNamesChanged(); 90 95 this.UpdateFiltering(false); … … 100 105 base.OnItemsRemoved(items); 101 106 OnReset(); 102 if (columnNamesChanged) 107 if (columnNamesChanged) { 108 columnNameCache = null; 103 109 OnColumnNamesChanged(); 110 } 111 rowNamesCache = null; 104 112 OnRowNamesChanged(); 105 113 } … … 207 215 set { throw new NotSupportedException(); } 208 216 } 217 private List<string> columnNameCache; 209 218 IEnumerable<string> IStringConvertibleMatrix.ColumnNames { 210 219 get { 211 List<string> value = new List<string>(parameterNames); 212 value.AddRange(resultNames); 213 value.Sort(); 214 return value; 215 } 216 set { throw new NotSupportedException(); } 217 } 220 if (columnNameCache == null) { 221 columnNameCache = new List<string>(parameterNames); 222 columnNameCache.AddRange(resultNames); 223 columnNameCache.Sort(); 224 } 225 return columnNameCache; 226 } 227 set { throw new NotSupportedException(); } 228 } 229 private List<string> rowNamesCache; 218 230 IEnumerable<string> IStringConvertibleMatrix.RowNames { 219 get { return list.Select(x => x.Name).ToList(); } 231 get { 232 if (rowNamesCache == null) 233 rowNamesCache = list.Select(x => x.Name).ToList(); 234 return rowNamesCache; 235 } 220 236 set { throw new NotSupportedException(); } 221 237 }
Note: See TracChangeset
for help on using the changeset viewer.