Changeset 5087 for branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encodings/ParameterConfigurationTree.cs
- Timestamp:
- 12/12/10 11:34:13 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encodings/ParameterConfigurationTree.cs
r5023 r5087 13 13 [StorableClass] 14 14 public class ParameterConfigurationTree : ValueConfiguration { 15 [Storable]16 public EngineAlgorithm Algorithm {17 get { return (EngineAlgorithm)base.ActualValue.Value; }18 set {19 base.ActualValue.Value = value;20 }21 }15 //[Storable] 16 //public EngineAlgorithm Algorithm { 17 // get { return (EngineAlgorithm)base.ActualValue.Value; } 18 // set { 19 // base.ActualValue.Value = value; 20 // } 21 //} 22 22 23 23 [Storable] … … 48 48 set { worstQuality = value; } 49 49 } 50 50 51 51 [Storable] 52 52 private DoubleValue qualityVariance; … … 55 55 set { qualityVariance = value; } 56 56 } 57 57 58 58 [Storable] 59 59 private DoubleValue qualityStandardDeviation; … … 62 62 set { qualityStandardDeviation = value; } 63 63 } 64 64 65 65 [Storable] 66 66 private TimeSpanValue averageExecutionTime; … … 78 78 79 79 [Storable] 80 public RunCollection Runs { get; set; } 81 80 protected RunCollection runs; 81 public RunCollection Runs { 82 get { return runs; } 83 set { runs = value; } 84 } 85 86 protected IDictionary<string, IItem> parameters; 87 public IDictionary<string, IItem> Parameters { 88 get { return parameters; } 89 set { parameters = value; } 90 } 91 82 92 #region constructors and cloning 83 public ParameterConfigurationTree(EngineAlgorithm algorithm) : base(algorithm, algorithm.GetType()) { 93 public ParameterConfigurationTree(EngineAlgorithm algorithm) 94 : base(null, algorithm.GetType()) { 84 95 this.Optimize = true; // root must always be optimized 85 96 this.BestQuality = new DoubleValue(); 97 this.parameters = new Dictionary<string, IItem>(); 98 99 PopulateParameterConfigurations(algorithm); 100 Initialize(); 86 101 } 87 102 public ParameterConfigurationTree() { … … 90 105 [StorableConstructor] 91 106 protected ParameterConfigurationTree(bool deserializing) : base(deserializing) { } 92 protected ParameterConfigurationTree(ParameterConfigurationTree original, Cloner cloner) : base(original, cloner) { 107 protected ParameterConfigurationTree(ParameterConfigurationTree original, Cloner cloner) 108 : base(original, cloner) { 93 109 this.bestQuality = cloner.Clone(original.BestQuality); 94 this.Algorithm.Prepare(); 95 this.Algorithm.Runs.Clear(); 110 this.parameters = new Dictionary<string, IItem>(); 111 foreach (var p in original.parameters) { 112 this.parameters.Add(p.Key, cloner.Clone(p.Value)); 113 } 96 114 Initialize(); 97 115 } … … 121 139 } 122 140 141 public virtual void CollectParameterValues(IDictionary<string, IItem> values) { 142 foreach (var p in parameters) { 143 values.Add(p); 144 } 145 } 146 123 147 #region Events 124 148 //public event EventHandler AlgorithmChanged; … … 134 158 135 159 //private void RegisterAlgorithmEvents() { 136 160 137 161 //} 138 162 //private void DeregisterAlgorithmEvents() { … … 151 175 #endregion 152 176 177 public override void Parameterize(IParameterizedItem item) { 178 base.Parameterize(item); 179 this.parameters.Clear(); 180 ((IAlgorithm)item).CollectParameterValues(this.Parameters); 181 } 153 182 } 154 183 }
Note: See TracChangeset
for help on using the changeset viewer.