Changeset 4525
- Timestamp:
- 09/27/10 17:38:55 (14 years ago)
- Location:
- branches/HeuristicLab.MetaOptimization
- Files:
-
- 3 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization.Views/3.3/ParameterConfigurationView.cs
r4516 r4525 35 35 base.OnContentChanged(); 36 36 if (Content != null) { 37 optimizeCheckBox.Checked = Content.Optimize;38 37 viewHost.Content = Content.Parameter; 39 38 } else { 40 optimizeCheckBox.Checked = false;41 39 viewHost.Content = null; 42 40 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Creators/RandomParameterSetCreator.cs
r4516 r4525 7 7 using HeuristicLab.Operators; 8 8 using HeuristicLab.Parameters; 9 using HeuristicLab.Common; 9 10 10 11 namespace HeuristicLab.Problems.MetaOptimization { … … 26 27 } 27 28 29 [Storable] 28 30 private ParameterConfigurationList parametersToOptimize; 29 31 public ParameterConfigurationList ParametersToOptimize { … … 42 44 return base.Apply(); 43 45 } 46 47 #region Cloning 48 public override IDeepCloneable Clone(Cloner cloner) { 49 RandomParameterSetCreator clone = (RandomParameterSetCreator) base.Clone(cloner); 50 clone.parametersToOptimize = (ParameterConfigurationList)this.parametersToOptimize.Clone(); 51 return clone; 52 } 53 #endregion 44 54 } 45 55 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encodings/NumericParameterConfiguration.cs
r4516 r4525 6 6 using HeuristicLab.Core; 7 7 using HeuristicLab.Collections; 8 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 8 9 9 10 namespace HeuristicLab.Problems.MetaOptimization { 11 [StorableClass] 10 12 public class NumericParameterConfiguration : ParameterConfiguration { 13 [Storable] 11 14 private NumericRangeList ranges; 12 15 public NumericRangeList Ranges { … … 15 18 16 19 protected NumericParameterConfiguration() { } 20 21 [StorableConstructor] 22 protected NumericParameterConfiguration(bool deserializing) : base(deserializing) { } 23 17 24 public NumericParameterConfiguration(IParameter parameter, string category) 18 25 : base(parameter, category) { … … 22 29 this.ranges.CollectionReset += new CollectionItemsChangedEventHandler<INumericRange>(ranges_CollectionReset); 23 30 } 31 32 24 33 25 34 void ranges_CollectionReset(object sender, CollectionItemsChangedEventArgs<INumericRange> e) { … … 55 64 } 56 65 66 #region Cloning 57 67 public override Common.IDeepCloneable Clone(Common.Cloner cloner) { 58 68 NumericParameterConfiguration clone = (NumericParameterConfiguration)base.Clone(cloner); … … 63 73 return clone; 64 74 } 75 #endregion 65 76 66 77 void range_ToStringChanged(object sender, EventArgs e) { … … 72 83 } 73 84 74 public override IParameter GetParameterWithRandomValue(IRandom random) {85 public override void SetParameterWithRandomValue(IRandom random) { 75 86 int rangeIndex = random.Next(ranges.Count); 76 87 int value = random.Next(ranges.ElementAt(rangeIndex).LowerBound.Value, ranges.ElementAt(rangeIndex).UpperBound.Value); // TODO: respect StepSize parameter 77 IParameter clone = (IParameter)this.Parameter.Clone(); 78 clone.ActualValue = new IntValue(value); 79 return clone; 88 this.Parameter.ActualValue = new IntValue(value); 80 89 } 81 90 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encodings/ParameterConfiguration.cs
r4516 r4525 5 5 using HeuristicLab.Core; 6 6 using HeuristicLab.Common; 7 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 7 8 8 9 namespace HeuristicLab.Problems.MetaOptimization { 10 [StorableClass] 9 11 public abstract class ParameterConfiguration : IParameterConfiguration { 10 public bool Optimize { get; set; }12 [Storable] 11 13 public IParameter Parameter { get; set; } 14 15 [Storable] 12 16 public string Category { get; set; } 13 17 14 18 public ParameterConfiguration() { } 19 20 [StorableConstructor] 21 protected ParameterConfiguration(bool deserializing) { } 22 15 23 public ParameterConfiguration(IParameter parameter, string category) { 16 24 this.Parameter = parameter; … … 74 82 cloner.RegisterClonedObject(this, clone); 75 83 clone.Parameter = (IParameter)cloner.Clone(this.Parameter); 76 clone. Optimize = this.Optimize;84 clone.Category = this.Category; 77 85 return clone; 78 86 } … … 87 95 } 88 96 89 public abstract IParameter GetParameterWithRandomValue(IRandom random);97 public abstract void SetParameterWithRandomValue(IRandom random); 90 98 91 99 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encodings/ParameterSet.cs
r4516 r4525 4 4 using System.Text; 5 5 using HeuristicLab.Core; 6 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 6 7 7 8 namespace HeuristicLab.Problems.MetaOptimization { 9 [StorableClass] 8 10 public class ParameterSet : Item, IParameterSet { 9 private List<KeyValuePair<string, IParameter>> parameters; 10 public IEnumerable<KeyValuePair<string, IParameter>> Parameters { 11 [Storable] 12 private List<IParameterConfiguration> parameters; 13 public IEnumerable<IParameterConfiguration> Parameters { 11 14 get { return parameters; } 12 15 } 13 16 14 17 public ParameterSet() { 15 this.parameters = new List< KeyValuePair<string, IParameter>>();18 this.parameters = new List<IParameterConfiguration>(); 16 19 } 20 21 [StorableConstructor] 22 protected ParameterSet(bool deserializing) : base(deserializing) { } 23 17 24 public ParameterSet(ParameterConfigurationList parametersToOptimize, IRandom random) 18 25 : this() { 19 26 foreach (IParameterConfiguration config in parametersToOptimize.CheckedItems) { 20 parameters.Add(new KeyValuePair<string, IParameter>(config.Category, config.GetParameterWithRandomValue(random))); 27 IParameterConfiguration clone = (IParameterConfiguration)config.Clone(); 28 clone.SetParameterWithRandomValue(random); 29 parameters.Add(clone); 21 30 } 22 31 } 23 32 24 33 #region Cloning 34 public override Common.IDeepCloneable Clone(Common.Cloner cloner) { 35 ParameterSet clone = (ParameterSet)base.Clone(cloner); 36 clone.parameters = new List<IParameterConfiguration>(); 37 foreach (var param in this.parameters) { 38 clone.parameters.Add((IParameterConfiguration)param.Clone(cloner)); 39 } 40 return clone; 41 } 42 #endregion 25 43 } 26 44 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Evaluators/MetaOptimizationEvaluator.cs
r4516 r4525 57 57 58 58 private void ParametrizeAlgorithm() { 59 foreach ( KeyValuePair<string, IParameter>parameter in ParameterSetParameter.ActualValue.Parameters) {60 if (parameter. Key == "Algorithm") {61 this.AlgorithmParameter.ActualValue.Parameters[parameter. Value.Name].ActualValue = parameter.Value.ActualValue;62 } else if (parameter. Key == "Problem") {63 this.AlgorithmParameter.ActualValue.Problem.Parameters[parameter. Value.Name].ActualValue = parameter.Value.ActualValue;59 foreach (IParameterConfiguration parameter in ParameterSetParameter.ActualValue.Parameters) { 60 if (parameter.Category == "Algorithm") { 61 this.AlgorithmParameter.ActualValue.Parameters[parameter.Parameter.Name].ActualValue = parameter.Parameter.ActualValue; 62 } else if (parameter.Category == "Problem") { 63 this.AlgorithmParameter.ActualValue.Problem.Parameters[parameter.Parameter.Name].ActualValue = parameter.Parameter.ActualValue; 64 64 } 65 65 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/HeuristicLab.Problems.MetaOptimization-3.3.csproj
r4516 r4525 54 54 <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Data-3.3.dll</HintPath> 55 55 </Reference> 56 <Reference Include="HeuristicLab.Encodings.BinaryVectorEncoding-3.3"> 57 <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.BinaryVectorEncoding-3.3.dll</HintPath> 58 </Reference> 59 <Reference Include="HeuristicLab.Encodings.IntegerVectorEncoding-3.3"> 60 <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.IntegerVectorEncoding-3.3.dll</HintPath> 61 </Reference> 62 <Reference Include="HeuristicLab.Encodings.RealVectorEncoding-3.3"> 63 <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.RealVectorEncoding-3.3.dll</HintPath> 64 </Reference> 56 65 <Reference Include="HeuristicLab.Operators-3.3"> 57 66 <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Operators-3.3.dll</HintPath> … … 81 90 <Compile Include="Creators\RandomParameterSetCreator.cs" /> 82 91 <Compile Include="Encodings\BooleanParameterConfiguration.cs" /> 92 <Compile Include="Encodings\Crossovers\ParameterSetCrossover.cs" /> 93 <Compile Include="Interfaces\IParameterSetOperator.cs" /> 83 94 <Compile Include="NumericRangeList.cs" /> 84 95 <Compile Include="Encodings\EnumerableParameterConfiguration.cs" /> -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Interfaces/IParameterConfiguration.cs
r4516 r4525 7 7 namespace HeuristicLab.Problems.MetaOptimization { 8 8 public interface IParameterConfiguration : INamedItem { 9 bool Optimize { get; set; }10 9 IParameter Parameter { get; set; } 11 10 string Category { get; set; } 12 11 13 IParameter GetParameterWithRandomValue(IRandom random);12 void SetParameterWithRandomValue(IRandom random); 14 13 } 15 14 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Interfaces/IParameterSet.cs
r4516 r4525 7 7 namespace HeuristicLab.Problems.MetaOptimization { 8 8 public interface IParameterSet : IItem { 9 IEnumerable< KeyValuePair<string, IParameter>> Parameters { get; }9 IEnumerable<IParameterConfiguration> Parameters { get; } 10 10 } 11 11 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/MetaOptimizationProblem.cs
r4516 r4525 172 172 } 173 173 174 #region Cloning 174 175 public override IDeepCloneable Clone(Cloner cloner) { 175 176 MetaOptimizationProblem clone = (MetaOptimizationProblem)base.Clone(cloner); … … 179 180 return clone; 180 181 } 182 #endregion 181 183 182 184 #region Helpers … … 195 197 operators.Add(new BestQualityAnalyzer()); 196 198 ParameterizeAnalyzer(); 199 operators.AddRange(ApplicationManager.Manager.GetInstances<IParameterSetOperator>().Cast<IOperator>()); 197 200 ParameterizeOperators(); 201 202 //UpdateMoveEvaluators(); 203 //InitializeMoveGenerators(); 198 204 } 199 205 private void ParameterizeSolutionCreator() { -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/NumericRange.cs
r4516 r4525 5 5 using HeuristicLab.Core; 6 6 using HeuristicLab.Data; 7 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 7 8 8 9 namespace HeuristicLab.Problems.MetaOptimization { 10 [StorableClass] 9 11 public class NumericRange : Item, INumericRange { 12 [Storable] 10 13 private IntValue lowerBound; 11 14 public IntValue LowerBound { … … 25 28 } 26 29 30 [Storable] 27 31 private IntValue upperBound; 28 32 public IntValue UpperBound { … … 42 46 } 43 47 48 [Storable] 44 49 private IntValue stepSize; 45 50 public IntValue StepSize { … … 63 68 UpperBound = new IntValue(0); 64 69 StepSize = new IntValue(1); 70 } 71 72 [StorableConstructor] 73 protected NumericRange(bool deserializing) : base(deserializing) { } 74 75 [StorableHook(HookType.AfterDeserialization)] 76 private void AfterDeserialization() { 77 if (lowerBound != null) { 78 lowerBound.ValueChanged += new EventHandler(lowerBound_ValueChanged); 79 } 80 if (upperBound != null) { 81 upperBound.ValueChanged += new EventHandler(upperBound_ValueChanged); 82 } 83 if (stepSize != null) { 84 stepSize.ValueChanged += new EventHandler(stepSize_ValueChanged); 85 } 65 86 } 66 87 … … 95 116 return string.Format("[{0},{1}:{2}]", LowerBound.ToString(), UpperBound.ToString(), StepSize.ToString()); 96 117 } 118 119 #region Cloning 120 public override Common.IDeepCloneable Clone(Common.Cloner cloner) { 121 NumericRange clone = (NumericRange)base.Clone(cloner); 122 clone.LowerBound = (IntValue)this.LowerBound.Clone(); 123 clone.UpperBound = (IntValue)this.UpperBound.Clone(); 124 clone.StepSize = (IntValue)this.StepSize.Clone(); 125 return base.Clone(cloner); 126 } 127 #endregion 97 128 } 98 129 }
Note: See TracChangeset
for help on using the changeset viewer.