Changeset 17587 for branches/2521_ProblemRefactoring
- Timestamp:
- 06/04/20 18:16:58 (4 years ago)
- Location:
- branches/2521_ProblemRefactoring
- Files:
-
- 1 added
- 3 deleted
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorEncoding.cs
r17567 r17587 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.ComponentModel;25 24 using System.Linq; 26 25 using HEAL.Attic; 27 26 using HeuristicLab.Common; 28 27 using HeuristicLab.Core; 29 using HeuristicLab.Data;30 28 using HeuristicLab.Optimization; 31 using HeuristicLab.Parameters;32 29 using HeuristicLab.PluginInfrastructure; 33 30 … … 35 32 [Item("BinaryVectorEncoding", "Describes a binary vector encoding.")] 36 33 [StorableType("889C5E1A-3FBF-4AB3-AB2E-199A781503B5")] 37 public sealed class BinaryVectorEncoding : Encoding<BinaryVector>, INotifyPropertyChanged { 38 #region Encoding Parameters 39 [Storable] public IValueParameter<IntValue> LengthParameter { get; private set; } 40 #endregion 41 42 public int Length { 43 get { return LengthParameter.Value.Value; } 44 set { 45 if (Length == value) return; 46 LengthParameter.Value = new IntValue(value, @readonly: LengthParameter.Value.ReadOnly); 47 } 48 } 34 public sealed class BinaryVectorEncoding : VectorEncoding<BinaryVector> { 49 35 50 36 [StorableConstructor] … … 53 39 private void AfterDeserialization() { 54 40 DiscoverOperators(); 55 RegisterEventHandlers();56 41 } 57 42 public override IDeepCloneable Clone(Cloner cloner) { return new BinaryVectorEncoding(this, cloner); } 58 private BinaryVectorEncoding(BinaryVectorEncoding original, Cloner cloner) 59 : base(original, cloner) { 60 LengthParameter = cloner.Clone(original.LengthParameter); 61 RegisterEventHandlers(); 62 } 63 43 private BinaryVectorEncoding(BinaryVectorEncoding original, Cloner cloner) : base(original, cloner) { } 64 44 public BinaryVectorEncoding() : this("BinaryVector", 10) { } 65 45 public BinaryVectorEncoding(string name) : this(name, 10) { } 66 46 public BinaryVectorEncoding(int length) : this("BinaryVector", length) { } 67 47 public BinaryVectorEncoding(string name, int length) 68 : base(name) { 69 Parameters.Add(LengthParameter = new ValueParameter<IntValue>(Name + ".Length", new IntValue(length)) { ReadOnly = true }); 70 48 : base(name, length) { 71 49 SolutionCreator = new RandomBinaryVectorCreator(); 50 72 51 DiscoverOperators(); 73 74 RegisterEventHandlers();75 }76 77 private void RegisterEventHandlers() {78 IntValueParameterChangeHandler.Create(LengthParameter, () => OnPropertyChanged(nameof(Length)));79 52 } 80 53 … … 153 126 } 154 127 #endregion 155 156 public event PropertyChangedEventHandler PropertyChanged;157 private void OnPropertyChanged(string property) {158 PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property));159 }160 128 } 161 129 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVectorEncoding.cs
r17567 r17587 34 34 [Item("IntegerVectorEncoding", "Describes an integer vector encoding.")] 35 35 [StorableType("15D6E55E-C39F-4784-8350-14A0FD47CF0E")] 36 public sealed class IntegerVectorEncoding : Encoding<IntegerVector> { 37 #region Encoding Parameters 38 [Storable] 39 private IFixedValueParameter<IntValue> lengthParameter; 40 public IFixedValueParameter<IntValue> LengthParameter { 41 get { return lengthParameter; } 42 set { 43 if (value == null) throw new ArgumentNullException("Length parameter must not be null."); 44 if (value.Value == null) throw new ArgumentNullException("Length parameter value must not be null."); 45 if (lengthParameter == value) return; 46 47 if (lengthParameter != null) Parameters.Remove(lengthParameter); 48 lengthParameter = value; 49 Parameters.Add(lengthParameter); 50 OnLengthParameterChanged(); 51 } 52 } 53 54 [Storable] 55 private IValueParameter<IntMatrix> boundsParameter; 56 public IValueParameter<IntMatrix> BoundsParameter { 57 get { return boundsParameter; } 58 set { 59 if (value == null) throw new ArgumentNullException("Bounds parameter must not be null."); 60 if (boundsParameter == value) return; 61 62 if (boundsParameter != null) Parameters.Remove(boundsParameter); 63 boundsParameter = value; 64 Parameters.Add(boundsParameter); 65 OnBoundsParameterChanged(); 66 } 67 } 68 #endregion 69 70 public int Length { 71 get { return LengthParameter.Value.Value; } 72 set { LengthParameter.Value.Value = value; } 73 } 36 public sealed class IntegerVectorEncoding : VectorEncoding<IntegerVector> { 37 [Storable] public IValueParameter<IntMatrix> BoundsParameter { get; private set; } 38 74 39 public IntMatrix Bounds { 75 40 get { return BoundsParameter.Value; } 76 set { BoundsParameter.Value = value; } 41 set { 42 if (value == null) throw new ArgumentNullException("Bounds must not be null."); 43 if (Bounds == value) return; 44 BoundsParameter.Value = value; 45 } 77 46 } 78 47 … … 81 50 [StorableHook(HookType.AfterDeserialization)] 82 51 private void AfterDeserialization() { 83 RegisterParameterEvents();84 52 DiscoverOperators(); 53 RegisterEventHandlers(); 85 54 } 86 55 87 56 private IntegerVectorEncoding(IntegerVectorEncoding original, Cloner cloner) 88 57 : base(original, cloner) { 89 lengthParameter = cloner.Clone(original.lengthParameter); 90 boundsParameter = cloner.Clone(original.boundsParameter); 91 RegisterParameterEvents(); 58 BoundsParameter = cloner.Clone(original.BoundsParameter); 59 RegisterEventHandlers(); 92 60 } 93 61 public override IDeepCloneable Clone(Cloner cloner) { return new IntegerVectorEncoding(this, cloner); } … … 98 66 public IntegerVectorEncoding(int length) : this("integerVector", length) { } 99 67 public IntegerVectorEncoding(string name, int length, int min = int.MinValue, int max = int.MaxValue, int? step = null) 100 : base(name ) {68 : base(name, length) { 101 69 if (min >= max) throw new ArgumentException("min must be less than max", "min"); 102 70 if (step.HasValue && step.Value <= 0) throw new ArgumentException("step must be greater than zero or null", "step"); … … 107 75 if (step.HasValue) bounds[0, 2] = step.Value; 108 76 109 lengthParameter = new FixedValueParameter<IntValue>(Name + ".Length", new IntValue(length)); 110 boundsParameter = new ValueParameter<IntMatrix>(Name + ".Bounds", bounds); 111 Parameters.Add(lengthParameter); 112 Parameters.Add(boundsParameter); 77 BoundsParameter = new ValueParameter<IntMatrix>(Name + ".Bounds", bounds); 78 Parameters.Add(BoundsParameter); 113 79 114 80 SolutionCreator = new UniformRandomIntegerVectorCreator(); 115 RegisterParameterEvents();116 81 DiscoverOperators(); 82 RegisterEventHandlers(); 117 83 } 118 84 public IntegerVectorEncoding(string name, int length, IList<int> min, IList<int> max, IList<int> step = null) 119 : base(name ) {85 : base(name, length) { 120 86 if (min.Count == 0) throw new ArgumentException("Bounds must be given for the integer parameters."); 121 87 if (min.Count != max.Count) throw new ArgumentException("min must be of the same length as max", "min"); … … 130 96 } 131 97 132 lengthParameter = new FixedValueParameter<IntValue>(Name + ".Length", new IntValue(length)); 133 boundsParameter = new ValueParameter<IntMatrix>(Name + ".Bounds", bounds); 134 Parameters.Add(lengthParameter); 135 Parameters.Add(boundsParameter); 98 BoundsParameter = new ValueParameter<IntMatrix>(Name + ".Bounds", bounds); 99 Parameters.Add(BoundsParameter); 136 100 137 101 SolutionCreator = new UniformRandomIntegerVectorCreator(); 138 RegisterParameterEvents();139 102 DiscoverOperators(); 140 } 141 142 private void OnLengthParameterChanged() { 143 RegisterLengthParameterEvents(); 144 ConfigureOperators(Operators); 145 } 146 private void OnBoundsParameterChanged() { 147 RegisterBoundsParameterEvents(); 148 ConfigureOperators(Operators); 149 } 150 151 private void RegisterParameterEvents() { 152 RegisterLengthParameterEvents(); 153 RegisterBoundsParameterEvents(); 154 } 155 private void RegisterLengthParameterEvents() { 156 LengthParameter.ValueChanged += (o, s) => ConfigureOperators(Operators); 157 LengthParameter.Value.ValueChanged += (o, s) => ConfigureOperators(Operators); 158 } 159 private void RegisterBoundsParameterEvents() { 160 BoundsParameter.ValueChanged += (o, s) => ConfigureOperators(Operators); 161 boundsParameter.Value.ToStringChanged += (o, s) => ConfigureOperators(Operators); 103 RegisterEventHandlers(); 104 } 105 106 private void RegisterEventHandlers() { 107 IntMatrixParameterChangeHandler.Create(BoundsParameter, () => { 108 ConfigureOperators(Operators); 109 OnBoundsChanged(); 110 }); 162 111 } 163 112 … … 271 220 } 272 221 #endregion 222 223 protected override void OnLengthChanged() { 224 ConfigureOperators(Operators); 225 base.OnLengthChanged(); 226 } 227 228 public event EventHandler BoundsChanged; 229 private void OnBoundsChanged() { 230 BoundsChanged?.Invoke(this, EventArgs.Empty); 231 } 273 232 } 274 233 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVectorMultiObjectiveProblem.cs
r17544 r17587 22 22 #endregion 23 23 24 using System;25 24 using System.Linq; 26 25 using HEAL.Attic; … … 38 37 public IResultDefinition<ParetoFrontScatterPlot<IntegerVector>> BestResult { get { return BestResultParameter; } } 39 38 [Storable] protected ReferenceParameter<IntValue> DimensionRefParameter { get; private set; } 40 public IValueParameter<IntValue> DimensionParameter => DimensionRefParameter;39 [Storable] protected ReferenceParameter<IntMatrix> BoundsRefParameter { get; private set; } 41 40 42 41 public int Dimension { 43 42 get { return DimensionRefParameter.Value.Value; } 44 43 set { DimensionRefParameter.Value.Value = value; } 44 } 45 46 public IntMatrix Bounds { 47 get { return BoundsRefParameter.Value; } 48 set { BoundsRefParameter.Value = value; } 45 49 } 46 50 … … 56 60 BestResultParameter = cloner.Clone(original.BestResultParameter); 57 61 DimensionRefParameter = cloner.Clone(original.DimensionRefParameter); 62 BoundsRefParameter = cloner.Clone(original.BoundsRefParameter); 58 63 RegisterEventHandlers(); 59 64 } … … 64 69 Parameters.Add(BestResultParameter = new ResultParameter<ParetoFrontScatterPlot<IntegerVector>>("Best Pareto Front", "The best Pareto front found.")); 65 70 Parameters.Add(DimensionRefParameter = new ReferenceParameter<IntValue>("Dimension", "The dimension of the integer vector problem.", Encoding.LengthParameter)); 71 Parameters.Add(BoundsRefParameter = new ReferenceParameter<IntMatrix>("Bounds", "The bounds of the integer vector problem.", Encoding.BoundsParameter)); 66 72 67 73 Operators.Add(new HammingSimilarityCalculator()); … … 94 100 95 101 private void RegisterEventHandlers() { 96 DimensionRefParameter.Value.ValueChanged += DimensionParameter_Value_ValueChanged; 97 } 98 99 private void DimensionParameter_Value_ValueChanged(object sender, EventArgs e) { 100 DimensionOnChanged(); 102 IntValueParameterChangeHandler.Create(DimensionRefParameter, DimensionOnChanged); 103 IntMatrixParameterChangeHandler.Create(BoundsRefParameter, BoundsOnChanged); 101 104 } 102 105 103 106 protected virtual void DimensionOnChanged() { } 107 108 protected virtual void BoundsOnChanged() { } 104 109 } 105 110 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVectorProblem.cs
r17544 r17587 22 22 #endregion 23 23 24 using System;25 24 using System.Linq; 26 25 using HEAL.Attic; … … 39 38 public IResultDefinition<IntegerVector> BestResult { get => BestResultParameter; } 40 39 [Storable] protected ReferenceParameter<IntValue> DimensionRefParameter { get; private set; } 41 public IValueParameter<IntValue> DimensionParameter => DimensionRefParameter;42 40 [Storable] protected ReferenceParameter<IntMatrix> BoundsRefParameter { get; private set; } 43 public IValueParameter<IntMatrix> BoundsParameter => BoundsRefParameter;44 41 45 42 public int Dimension { 46 43 get { return DimensionRefParameter.Value.Value; } 47 set { DimensionRefParameter.Value.Value = value; }44 protected set { DimensionRefParameter.Value.Value = value; } 48 45 } 49 46 50 47 public IntMatrix Bounds { 51 48 get { return BoundsRefParameter.Value; } 52 set { BoundsRefParameter.Value = value; }49 protected set { BoundsRefParameter.Value = value; } 53 50 } 54 51 … … 103 100 104 101 private void RegisterEventHandlers() { 105 DimensionRefParameter.Value.ValueChanged += DimensionParameter_Value_ValueChanged; 106 BoundsRefParameter.ValueChanged += BoundsParameter_ValueChanged; 107 } 108 109 private void DimensionParameter_Value_ValueChanged(object sender, EventArgs e) { 110 DimensionOnChanged(); 111 } 112 113 private void BoundsParameter_ValueChanged(object sender, EventArgs e) { 114 BoundsOnChanged(); 102 IntValueParameterChangeHandler.Create(DimensionRefParameter, DimensionOnChanged); 103 IntMatrixParameterChangeHandler.Create(BoundsRefParameter, BoundsOnChanged); 115 104 } 116 105 -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/LinearLinkageEncoding.cs
r17567 r17587 26 26 using HeuristicLab.Common; 27 27 using HeuristicLab.Core; 28 using HeuristicLab.Data;29 28 using HeuristicLab.Optimization; 30 using HeuristicLab.Parameters;31 29 using HeuristicLab.PluginInfrastructure; 32 30 … … 34 32 [Item("Linear Linkage Encoding", "Describes a linear linkage (LLE) encoding.")] 35 33 [StorableType("7AE11F39-E6BD-4FC7-8112-0A5EDCBFBDB6")] 36 public sealed class LinearLinkageEncoding : Encoding<LinearLinkage> { 37 #region encoding parameters 38 [Storable] 39 private IFixedValueParameter<IntValue> lengthParameter; 40 public IFixedValueParameter<IntValue> LengthParameter { 41 get { return lengthParameter; } 42 set { 43 if (value == null) throw new ArgumentNullException("Length parameter must not be null."); 44 if (value.Value == null) throw new ArgumentNullException("Length parameter value must not be null."); 45 if (lengthParameter == value) return; 46 47 if (lengthParameter != null) Parameters.Remove(lengthParameter); 48 lengthParameter = value; 49 Parameters.Add(lengthParameter); 50 OnLengthParameterChanged(); 51 } 52 } 53 #endregion 54 55 public int Length { 56 get { return LengthParameter.Value.Value; } 57 set { LengthParameter.Value.Value = value; } 58 } 34 public sealed class LinearLinkageEncoding : VectorEncoding<LinearLinkage> { 59 35 60 36 [StorableConstructor] … … 62 38 [StorableHook(HookType.AfterDeserialization)] 63 39 private void AfterDeserialization() { 64 RegisterParameterEvents();65 40 DiscoverOperators(); 66 41 } 67 42 68 43 public override IDeepCloneable Clone(Cloner cloner) { return new LinearLinkageEncoding(this, cloner); } 69 private LinearLinkageEncoding(LinearLinkageEncoding original, Cloner cloner) 70 : base(original, cloner) { 71 lengthParameter = cloner.Clone(original.lengthParameter); 72 RegisterParameterEvents(); 73 } 74 44 private LinearLinkageEncoding(LinearLinkageEncoding original, Cloner cloner) : base(original, cloner) { } 75 45 76 46 public LinearLinkageEncoding() : this("LLE", 10) { } … … 78 48 public LinearLinkageEncoding(int length) : this("LLE", length) { } 79 49 public LinearLinkageEncoding(string name, int length) 80 : base(name) { 81 lengthParameter = new FixedValueParameter<IntValue>(Name + ".Length", new IntValue(length)); 82 Parameters.Add(lengthParameter); 83 50 : base(name, length) { 84 51 SolutionCreator = new RandomLinearLinkageCreator(); 85 RegisterParameterEvents();86 52 DiscoverOperators(); 87 }88 89 private void OnLengthParameterChanged() {90 RegisterLengthParameterEvents();91 ConfigureOperators(Operators);92 }93 94 private void RegisterParameterEvents() {95 RegisterLengthParameterEvents();96 }97 private void RegisterLengthParameterEvents() {98 LengthParameter.Value.ValueChanged += (o, s) => ConfigureOperators(Operators);99 53 } 100 54 … … 167 121 } 168 122 #endregion 169 170 123 } 171 124 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/LinearLinkageMultiObjectiveProblem.cs
r17544 r17587 22 22 #endregion 23 23 24 using System;25 24 using System.Linq; 26 25 using HEAL.Attic; … … 90 89 91 90 private void RegisterEventHandlers() { 92 DimensionRefParameter.Value.ValueChanged += DimensionParameter_Value_ValueChanged; 93 } 94 95 private void DimensionParameter_Value_ValueChanged(object sender, EventArgs e) { 96 DimensionOnChanged(); 91 IntValueParameterChangeHandler.Create(DimensionRefParameter, DimensionOnChanged); 97 92 } 98 93 -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/LinearLinkageProblem.cs
r17544 r17587 22 22 #endregion 23 23 24 using System;25 24 using System.Linq; 26 25 using HEAL.Attic; … … 37 36 public abstract class LinearLinkageProblem : SingleObjectiveProblem<LinearLinkageEncoding, LinearLinkage> { 38 37 [Storable] protected ReferenceParameter<IntValue> DimensionRefParameter { get; private set; } 39 public IValueParameter<IntValue> DimensionParameter => DimensionRefParameter;40 38 41 39 public int Dimension { … … 90 88 91 89 private void RegisterEventHandlers() { 92 DimensionRefParameter.Value.ValueChanged += DimensionParameter_Value_ValueChanged; 93 } 94 95 private void DimensionParameter_Value_ValueChanged(object sender, EventArgs e) { 96 DimensionOnChanged(); 90 IntValueParameterChangeHandler.Create(DimensionRefParameter, DimensionOnChanged); 97 91 } 98 92 -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding.Views/3.3/HeuristicLab.Encodings.PermutationEncoding.Views-3.3.csproj
r16723 r17587 116 116 </ItemGroup> 117 117 <ItemGroup> 118 <Compile Include="PermutationTypeView.cs">119 <SubType>UserControl</SubType>120 </Compile>121 <Compile Include="PermutationTypeView.Designer.cs">122 <DependentUpon>PermutationTypeView.cs</DependentUpon>123 </Compile>124 118 <Compile Include="PermutationView.cs"> 125 119 <SubType>UserControl</SubType> -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding.Views/3.3/PermutationView.Designer.cs
r17226 r17587 19 19 */ 20 20 #endregion 21 22 using HeuristicLab.Data.Views; 21 23 22 24 namespace HeuristicLab.Encodings.PermutationEncoding.Views { … … 45 47 /// </summary> 46 48 private void InitializeComponent() { 47 this.permutationTypeView = new HeuristicLab. Encodings.PermutationEncoding.Views.PermutationTypeView();49 this.permutationTypeView = new HeuristicLab.Data.Views.EnumValueView<PermutationTypes>(); 48 50 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 49 51 this.SuspendLayout(); … … 83 85 #endregion 84 86 85 private PermutationTypeViewpermutationTypeView;87 private EnumValueView<PermutationTypes> permutationTypeView; 86 88 87 89 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding.Views/3.3/PermutationView.cs
r17226 r17587 58 58 permutationTypeView.Content = null; 59 59 } else { 60 permutationTypeView.Content = new PermutationType(Content.PermutationType);60 permutationTypeView.Content = new Data.EnumValue<PermutationTypes>(Content.PermutationType); 61 61 permutationTypeView.Content.ValueChanged += new System.EventHandler(PermutationTypeView_ValueChanged); 62 62 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/Creators/RandomPermutationCreator.cs
r17226 r17587 48 48 get { return (ILookupParameter<Permutation>)Parameters["Permutation"]; } 49 49 } 50 public IValueParameter< PermutationType> PermutationTypeParameter {51 get { return (IValueParameter< PermutationType>)Parameters["PermutationType"]; }50 public IValueParameter<EnumValue<PermutationTypes>> PermutationTypeParameter { 51 get { return (IValueParameter<EnumValue<PermutationTypes>>)Parameters["PermutationType"]; } 52 52 } 53 53 … … 65 65 Parameters.Add(new ValueLookupParameter<IntValue>("Length", "The length of the new random permutation.")); 66 66 Parameters.Add(new LookupParameter<Permutation>("Permutation", "The new random permutation.")); 67 Parameters.Add(new ValueParameter< PermutationType>("PermutationType", "The type of the permutation.", new PermutationType(PermutationTypes.RelativeUndirected)));67 Parameters.Add(new ValueParameter<EnumValue<PermutationTypes>>("PermutationType", "The type of the permutation.", new EnumValue<PermutationTypes>(PermutationTypes.RelativeUndirected))); 68 68 } 69 69 -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/HeuristicLab.Encodings.PermutationEncoding-3.3.csproj
r16948 r17587 207 207 <Compile Include="PermutationCrossover.cs" /> 208 208 <Compile Include="Permutation.cs" /> 209 <Compile Include="PermutationType.cs" />210 209 <Compile Include="PermutationTypes.cs" /> 211 210 <Compile Include="Plugin.cs" /> -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/Interfaces/IPermutationCreator.cs
r17226 r17587 20 20 #endregion 21 21 22 using HEAL.Attic; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Data; 24 25 using HeuristicLab.Optimization; 25 using HEAL.Attic;26 26 27 27 namespace HeuristicLab.Encodings.PermutationEncoding { … … 32 32 public interface IPermutationCreator : IPermutationSolutionOperator, ISolutionCreator<Permutation> { 33 33 IValueLookupParameter<IntValue> LengthParameter { get; } 34 IValueParameter< PermutationType> PermutationTypeParameter { get; }34 IValueParameter<EnumValue<PermutationTypes>> PermutationTypeParameter { get; } 35 35 } 36 36 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/PermutationEncoding.cs
r17567 r17587 34 34 [Item("PermutationEncoding", "Describes a permutation encoding.")] 35 35 [StorableType("E30E7507-44BA-4021-8F56-C3FC5569A6FE")] 36 public sealed class PermutationEncoding : Encoding<Permutation> {36 public sealed class PermutationEncoding : VectorEncoding<Permutation> { 37 37 #region encoding parameters 38 [Storable] 39 private IFixedValueParameter<IntValue> lengthParameter; 40 public IFixedValueParameter<IntValue> LengthParameter { 41 get { return lengthParameter; } 38 [Storable] public IValueParameter<EnumValue<PermutationTypes>> PermutationTypeParameter { get; private set; } 39 public PermutationTypes Type { 40 get { return PermutationTypeParameter.Value.Value; } 42 41 set { 43 if (value == null) throw new ArgumentNullException("Length parameter must not be null."); 44 if (value.Value == null) throw new ArgumentNullException("Length parameter value must not be null."); 45 if (lengthParameter == value) return; 46 47 if (lengthParameter != null) Parameters.Remove(lengthParameter); 48 lengthParameter = value; 49 Parameters.Add(lengthParameter); 50 OnLengthParameterChanged(); 51 } 52 } 53 54 [Storable] 55 private IFixedValueParameter<PermutationType> permutationTypeParameter; 56 public IFixedValueParameter<PermutationType> PermutationTypeParameter { 57 get { return permutationTypeParameter; } 58 set { 59 if (value == null) throw new ArgumentNullException("Permutation type parameter must not be null."); 60 if (value.Value == null) throw new ArgumentNullException("Permutation type parameter value must not be null."); 61 if (permutationTypeParameter == value) return; 62 63 if (permutationTypeParameter != null) Parameters.Remove(permutationTypeParameter); 64 permutationTypeParameter = value; 65 Parameters.Add(permutationTypeParameter); 66 OnPermutationTypeParameterChanged(); 42 if (Type == value) return; 43 PermutationTypeParameter.Value.Value = value; 67 44 } 68 45 } 69 46 #endregion 70 71 public int Length {72 get { return LengthParameter.Value.Value; }73 set { LengthParameter.Value.Value = value; }74 }75 76 public PermutationTypes Type {77 get { return PermutationTypeParameter.Value.Value; }78 set { PermutationTypeParameter.Value.Value = value; }79 }80 47 81 48 [StorableConstructor] … … 83 50 [StorableHook(HookType.AfterDeserialization)] 84 51 private void AfterDeserialization() { 52 DiscoverOperators(); 85 53 RegisterParameterEvents(); 86 DiscoverOperators();87 54 } 88 55 … … 90 57 private PermutationEncoding(PermutationEncoding original, Cloner cloner) 91 58 : base(original, cloner) { 92 lengthParameter = cloner.Clone(original.lengthParameter); 93 permutationTypeParameter = cloner.Clone(original.permutationTypeParameter); 59 PermutationTypeParameter = cloner.Clone(original.PermutationTypeParameter); 94 60 RegisterParameterEvents(); 95 61 } … … 100 66 public PermutationEncoding(int length) : this("Permutation", length, PermutationTypes.Absolute) { } 101 67 public PermutationEncoding(string name, int length, PermutationTypes type) 102 : base(name) { 103 lengthParameter = new FixedValueParameter<IntValue>(Name + ".Length", new IntValue(length)); 104 permutationTypeParameter = new FixedValueParameter<PermutationType>(Name + ".Type", new PermutationType(type)); 105 Parameters.Add(lengthParameter); 106 Parameters.Add(permutationTypeParameter); 68 : base(name, length) { 69 PermutationTypeParameter = new ValueParameter<EnumValue<PermutationTypes>>(Name + ".Type", new EnumValue<PermutationTypes>(type)); 70 Parameters.Add(PermutationTypeParameter); 107 71 108 72 SolutionCreator = new RandomPermutationCreator(); 73 DiscoverOperators(); 109 74 RegisterParameterEvents(); 110 DiscoverOperators();111 }112 113 private void OnLengthParameterChanged() {114 RegisterLengthParameterEvents();115 ConfigureOperators(Operators);116 }117 118 private void OnPermutationTypeParameterChanged() {119 RegisterPermutationTypeParameterEvents();120 ConfigureOperators(Operators);121 75 } 122 76 123 77 private void RegisterParameterEvents() { 124 RegisterLengthParameterEvents(); 125 RegisterPermutationTypeParameterEvents(); 126 } 127 private void RegisterLengthParameterEvents() { 128 LengthParameter.Value.ValueChanged += (o, s) => ConfigureOperators(Operators); 129 } 130 private void RegisterPermutationTypeParameterEvents() { 131 PermutationTypeParameter.Value.ValueChanged += (o, s) => ConfigureOperators(Operators); 78 EnumValueParameterChangeHandler<PermutationTypes>.Create(PermutationTypeParameter, () => { 79 ConfigureOperators(Operators); 80 OnTypeChanged(); 81 }); 132 82 } 133 83 … … 239 189 } 240 190 #endregion 191 192 public event EventHandler TypeChanged; 193 private void OnTypeChanged() { 194 TypeChanged?.Invoke(this, EventArgs.Empty); 195 } 241 196 } 242 197 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/PermutationMultiObjectiveProblem.cs
r17544 r17587 22 22 #endregion 23 23 24 using System;25 24 using System.Linq; 26 25 using HEAL.Attic; … … 36 35 public abstract class PermutationMultiObjectiveProblem : MultiObjectiveProblem<PermutationEncoding, Permutation> { 37 36 [Storable] protected ReferenceParameter<IntValue> DimensionRefParameter { get; private set; } 38 public IValueParameter<IntValue> DimensionParameter => DimensionRefParameter;37 [Storable] protected ReferenceParameter<EnumValue<PermutationTypes>> PermutationTypeRefParameter { get; private set; } 39 38 40 39 public int Dimension { 41 40 get { return DimensionRefParameter.Value.Value; } 42 41 set { DimensionRefParameter.Value.Value = value; } 42 } 43 44 public PermutationTypes Type { 45 get { return PermutationTypeRefParameter.Value.Value; } 46 set { PermutationTypeRefParameter.Value.Value = value; } 43 47 } 44 48 … … 53 57 : base(original, cloner) { 54 58 DimensionRefParameter = cloner.Clone(original.DimensionRefParameter); 59 PermutationTypeRefParameter = cloner.Clone(original.PermutationTypeRefParameter); 55 60 RegisterEventHandlers(); 56 61 } … … 60 65 EncodingParameter.ReadOnly = true; 61 66 Parameters.Add(DimensionRefParameter = new ReferenceParameter<IntValue>("Dimension", "The dimension of the permutation problem.", Encoding.LengthParameter)); 67 Parameters.Add(PermutationTypeRefParameter = new ReferenceParameter<EnumValue<PermutationTypes>>("Type", "The type of the permutation.", Encoding.PermutationTypeParameter)); 62 68 63 69 Operators.Add(new HammingSimilarityCalculator()); … … 89 95 90 96 private void RegisterEventHandlers() { 91 DimensionRefParameter.Value.ValueChanged += DimensionParameter_Value_ValueChanged; 92 } 93 94 private void DimensionParameter_Value_ValueChanged(object sender, EventArgs e) { 95 DimensionOnChanged(); 97 IntValueParameterChangeHandler.Create(DimensionRefParameter, DimensionOnChanged); 98 EnumValueParameterChangeHandler<PermutationTypes>.Create(PermutationTypeRefParameter, TypeOnChanged); 96 99 } 97 100 98 101 protected virtual void DimensionOnChanged() { } 102 103 protected virtual void TypeOnChanged() { } 99 104 } 100 105 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/PermutationProblem.cs
r17544 r17587 22 22 #endregion 23 23 24 using System;25 24 using System.Linq; 26 25 using HEAL.Attic; … … 37 36 public abstract class PermutationProblem : SingleObjectiveProblem<PermutationEncoding, Permutation> { 38 37 [Storable] protected ReferenceParameter<IntValue> DimensionRefParameter { get; private set; } 39 public IValueParameter<IntValue> DimensionParameter => DimensionRefParameter;38 [Storable] protected ReferenceParameter<EnumValue<PermutationTypes>> PermutationTypeRefParameter { get; private set; } 40 39 41 40 public int Dimension { 42 41 get { return DimensionRefParameter.Value.Value; } 43 42 set { DimensionRefParameter.Value.Value = value; } 43 } 44 45 public PermutationTypes Type { 46 get { return PermutationTypeRefParameter.Value.Value; } 47 set { PermutationTypeRefParameter.Value.Value = value; } 44 48 } 45 49 … … 54 58 : base(original, cloner) { 55 59 DimensionRefParameter = cloner.Clone(original.DimensionRefParameter); 60 PermutationTypeRefParameter = cloner.Clone(original.PermutationTypeRefParameter); 56 61 RegisterEventHandlers(); 57 62 } … … 61 66 EncodingParameter.ReadOnly = true; 62 67 Parameters.Add(DimensionRefParameter = new ReferenceParameter<IntValue>("Dimension", "The dimension of the permutation problem.", Encoding.LengthParameter)); 63 68 Parameters.Add(PermutationTypeRefParameter = new ReferenceParameter<EnumValue<PermutationTypes>>("Type", "The type of the permutation.", Encoding.PermutationTypeParameter)); 64 69 Operators.Add(new HammingSimilarityCalculator()); 65 70 Operators.Add(new QualitySimilarityCalculator()); … … 89 94 90 95 private void RegisterEventHandlers() { 91 DimensionRefParameter.Value.ValueChanged += DimensionParameter_Value_ValueChanged; 92 } 93 94 private void DimensionParameter_Value_ValueChanged(object sender, EventArgs e) { 95 DimensionOnChanged(); 96 IntValueParameterChangeHandler.Create(DimensionRefParameter, DimensionOnChanged); 97 EnumValueParameterChangeHandler<PermutationTypes>.Create(PermutationTypeRefParameter, TypeOnChanged); 96 98 } 97 99 98 100 protected virtual void DimensionOnChanged() { } 101 102 protected virtual void TypeOnChanged() { } 99 103 } 100 104 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/RealVectorEncoding.cs
r17571 r17587 34 34 [Item("RealVectorEncoding", "Describes a real vector encoding.")] 35 35 [StorableType("155FFE02-931F-457D-AC95-A0389B0BFECD")] 36 public sealed class RealVectorEncoding : Encoding<RealVector> { 37 #region Encoding Parameters 38 [Storable] 39 private IFixedValueParameter<IntValue> lengthParameter; 40 public IFixedValueParameter<IntValue> LengthParameter { 41 get { return lengthParameter; } 42 set { 43 if (value == null) throw new ArgumentNullException("Length parameter must not be null."); 44 if (value.Value == null) throw new ArgumentNullException("Length parameter value must not be null."); 45 if (lengthParameter == value) return; 46 47 if (lengthParameter != null) Parameters.Remove(lengthParameter); 48 lengthParameter = value; 49 Parameters.Add(lengthParameter); 50 OnLengthParameterChanged(); 51 } 52 } 53 [Storable] 54 private IValueParameter<DoubleMatrix> boundsParameter; 55 public IValueParameter<DoubleMatrix> BoundsParameter { 56 get { return boundsParameter; } 36 public sealed class RealVectorEncoding : VectorEncoding<RealVector> { 37 [Storable] public IValueParameter<DoubleMatrix> BoundsParameter { get; private set; } 38 39 public DoubleMatrix Bounds { 40 get { return BoundsParameter.Value; } 57 41 set { 58 42 if (value == null) throw new ArgumentNullException("Bounds parameter must not be null."); 59 if (boundsParameter == value) return; 60 61 if (boundsParameter != null) Parameters.Remove(boundsParameter); 62 boundsParameter = value; 63 Parameters.Add(boundsParameter); 64 OnBoundsParameterChanged(); 65 } 66 } 67 #endregion 68 69 public int Length { 70 get { return LengthParameter.Value.Value; } 71 set { LengthParameter.Value.Value = value; } 72 } 73 public DoubleMatrix Bounds { 74 get { return BoundsParameter.Value; } 75 set { BoundsParameter.Value = value; } 43 if (Bounds == value) return; 44 BoundsParameter.Value = value; 45 } 76 46 } 77 47 … … 80 50 [StorableHook(HookType.AfterDeserialization)] 81 51 private void AfterDeserialization() { 82 RegisterParameterEvents();83 52 DiscoverOperators(); 53 RegisterParameterEvents(); 84 54 } 85 55 … … 87 57 private RealVectorEncoding(RealVectorEncoding original, Cloner cloner) 88 58 : base(original, cloner) { 89 lengthParameter = cloner.Clone(original.lengthParameter); 90 boundsParameter = cloner.Clone(original.boundsParameter); 59 BoundsParameter = cloner.Clone(original.BoundsParameter); 91 60 RegisterParameterEvents(); 92 61 } … … 96 65 public RealVectorEncoding(int length) : this("RealVector", length) { } 97 66 public RealVectorEncoding(string name, int length, double min = -1000, double max = 1000) 98 : base(name ) {67 : base(name, length) { 99 68 if (min >= max) throw new ArgumentException("min must be less than max", "min"); 100 69 … … 103 72 bounds[0, 1] = max; 104 73 105 lengthParameter = new FixedValueParameter<IntValue>(Name + ".Length", new IntValue(length)) { ReadOnly = true }; 106 boundsParameter = new ValueParameter<DoubleMatrix>(Name + ".Bounds", bounds) { ReadOnly = true }; 107 Parameters.Add(lengthParameter); 108 Parameters.Add(boundsParameter); 74 BoundsParameter = new ValueParameter<DoubleMatrix>(Name + ".Bounds", bounds); 75 Parameters.Add(BoundsParameter); 109 76 110 77 SolutionCreator = new UniformRandomRealVectorCreator(); … … 114 81 115 82 public RealVectorEncoding(string name, int length, IList<double> min, IList<double> max) 116 : base(name ) {83 : base(name, length) { 117 84 if (min.Count == 0) throw new ArgumentException("Bounds must be given for the real parameters."); 118 85 if (min.Count != max.Count) throw new ArgumentException("min must be of the same length as max", "min"); … … 124 91 bounds[i, 1] = max[i]; 125 92 } 126 lengthParameter = new FixedValueParameter<IntValue>(Name + ".Length", new IntValue(length)); 127 boundsParameter = new ValueParameter<DoubleMatrix>(Name + ".Bounds", bounds); 128 Parameters.Add(lengthParameter); 129 Parameters.Add(boundsParameter); 93 BoundsParameter = new ValueParameter<DoubleMatrix>(Name + ".Bounds", bounds); 94 Parameters.Add(BoundsParameter); 130 95 131 96 SolutionCreator = new UniformRandomRealVectorCreator(); 132 RegisterParameterEvents();133 97 DiscoverOperators(); 134 } 135 136 private void OnLengthParameterChanged() { 137 RegisterLengthParameterEvents(); 138 ConfigureOperators(Operators); 139 } 140 private void OnBoundsParameterChanged() { 141 RegisterBoundsParameterEvents(); 142 ConfigureOperators(Operators); 98 RegisterParameterEvents(); 143 99 } 144 100 145 101 private void RegisterParameterEvents() { 146 RegisterLengthParameterEvents(); 147 RegisterBoundsParameterEvents(); 148 } 149 private void RegisterLengthParameterEvents() { 150 LengthParameter.ValueChanged += (o, s) => ConfigureOperators(Operators); 151 LengthParameter.Value.ValueChanged += (o, s) => ConfigureOperators(Operators); 152 } 153 private void RegisterBoundsParameterEvents() { 154 BoundsParameter.ValueChanged += (o, s) => ConfigureOperators(Operators); 155 boundsParameter.Value.ToStringChanged += (o, s) => ConfigureOperators(Operators); 102 DoubleMatrixParameterChangeHandler.Create(BoundsParameter, () => { 103 ConfigureOperators(Operators); 104 OnBoundsChanged(); 105 }); 156 106 } 157 107 … … 316 266 } 317 267 #endregion 268 269 protected override void OnLengthChanged() { 270 ConfigureOperators(Operators); 271 base.OnLengthChanged(); 272 } 273 274 public event EventHandler BoundsChanged; 275 private void OnBoundsChanged() { 276 BoundsChanged?.Invoke(this, EventArgs.Empty); 277 } 318 278 } 319 279 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/RealVectorMultiObjectiveProblem.cs
r17544 r17587 22 22 #endregion 23 23 24 using System;25 24 using System.Linq; 26 25 using HEAL.Attic; … … 36 35 public abstract class RealVectorMultiObjectiveProblem : MultiObjectiveProblem<RealVectorEncoding, RealVector> { 37 36 [Storable] protected ReferenceParameter<IntValue> DimensionRefParameter { get; private set; } 38 public IValueParameter<IntValue> DimensionParameter => DimensionRefParameter;39 37 [Storable] protected ReferenceParameter<DoubleMatrix> BoundsRefParameter { get; private set; } 40 public IValueParameter<DoubleMatrix> BoundsParameter => BoundsRefParameter;41 38 42 39 public int Dimension { … … 47 44 public DoubleMatrix Bounds { 48 45 get { return BoundsRefParameter.Value; } 49 set { Bounds Parameter.Value = value; }46 set { BoundsRefParameter.Value = value; } 50 47 } 51 48 … … 99 96 100 97 private void RegisterEventHandlers() { 101 DimensionRefParameter.Value.ValueChanged += DimensionParameter_Value_ValueChanged; 102 BoundsRefParameter.ValueChanged += BoundsParameter_ValueChanged; 103 } 104 105 private void DimensionParameter_Value_ValueChanged(object sender, EventArgs e) { 106 DimensionOnChanged(); 107 } 108 109 private void BoundsParameter_ValueChanged(object sender, EventArgs e) { 110 BoundsOnChanged(); 98 IntValueParameterChangeHandler.Create(DimensionRefParameter, DimensionOnChanged); 99 DoubleMatrixParameterChangeHandler.Create(BoundsRefParameter, BoundsOnChanged); 111 100 } 112 101 -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/RealVectorProblem.cs
r17544 r17587 22 22 #endregion 23 23 24 using System;25 24 using System.Linq; 26 25 using HEAL.Attic; … … 37 36 public abstract class RealVectorProblem : SingleObjectiveProblem<RealVectorEncoding, RealVector> { 38 37 [Storable] protected ReferenceParameter<IntValue> DimensionRefParameter { get; private set; } 39 public IValueParameter<IntValue> DimensionParameter => DimensionRefParameter;40 38 [Storable] protected ReferenceParameter<DoubleMatrix> BoundsRefParameter { get; private set; } 41 public IValueParameter<DoubleMatrix> BoundsParameter => BoundsRefParameter;42 39 43 40 public int Dimension { … … 48 45 public DoubleMatrix Bounds { 49 46 get { return BoundsRefParameter.Value; } 50 set { Bounds Parameter.Value = value; }47 set { BoundsRefParameter.Value = value; } 51 48 } 52 49 … … 99 96 100 97 private void RegisterEventHandlers() { 101 DimensionRefParameter.Value.ValueChanged += DimensionParameter_Value_ValueChanged; 102 BoundsRefParameter.ValueChanged += BoundsParameter_ValueChanged; 103 } 104 105 private void DimensionParameter_Value_ValueChanged(object sender, EventArgs e) { 106 DimensionOnChanged(); 107 } 108 109 private void BoundsParameter_ValueChanged(object sender, EventArgs e) { 110 BoundsOnChanged(); 98 IntValueParameterChangeHandler.Create(DimensionRefParameter, DimensionOnChanged); 99 DoubleMatrixParameterChangeHandler.Create(BoundsRefParameter, BoundsOnChanged); 111 100 } 112 101 -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj
r17577 r17587 160 160 <Compile Include="BasicProblems\SingleObjectiveProblem.cs" /> 161 161 <Compile Include="BasicProblems\SolutionContext.cs" /> 162 <Compile Include="BasicProblems\VectorEncoding.cs" /> 162 163 <Compile Include="Interfaces\ICharacteristicCalculator.cs" /> 163 164 <Compile Include="Interfaces\ILocalImprovementAlgorithmOperator.cs" /> -
branches/2521_ProblemRefactoring/HeuristicLab.Parameters/3.3/ParameterChangeHandler.cs
r17546 r17587 39 39 } 40 40 41 public class ParameterChangeHandler<TItem, TValue> : ParameterChangeHandler<TItem>41 public class ValueTypeValueParameterChangeHandler<TItem, TValue> : ParameterChangeHandler<TItem> 42 42 where TValue : struct 43 43 where TItem : ValueTypeValue<TValue> { 44 44 private ValueTypeValue<TValue> last; 45 45 46 protected ParameterChangeHandler(IValueParameter<TItem> parameter, Action handler)46 protected ValueTypeValueParameterChangeHandler(IValueParameter<TItem> parameter, Action handler) 47 47 : base(parameter, handler) { 48 48 last = parameter.Value; … … 63 63 } 64 64 65 public static ParameterChangeHandler<TItem, TValue> Create(IValueParameter<TItem> parameter, Action handler) 66 => new ParameterChangeHandler<TItem, TValue>(parameter, handler); 67 } 68 69 public class BoolValueParameterChangeHandler : ParameterChangeHandler<BoolValue, bool> { 65 public static ValueTypeValueParameterChangeHandler<TItem, TValue> Create(IValueParameter<TItem> parameter, Action handler) 66 => new ValueTypeValueParameterChangeHandler<TItem, TValue>(parameter, handler); 67 } 68 public class ValueTypeArrayParameterChangeHandler<TItem, TValue> : ParameterChangeHandler<TItem> 69 where TValue : struct 70 where TItem : ValueTypeArray<TValue> { 71 private ValueTypeArray<TValue> last; 72 73 protected ValueTypeArrayParameterChangeHandler(IValueParameter<TItem> parameter, Action handler) 74 : base(parameter, handler) { 75 last = parameter.Value; 76 if (last != null && !last.ReadOnly) 77 last.ToStringChanged += ParameterValueOnValueChanged; 78 } 79 80 protected override void ParameterOnValueChanged(object sender, EventArgs e) { 81 if (last != null) last.ToStringChanged -= ParameterValueOnValueChanged; 82 last = ((IValueParameter<TItem>)sender).Value; 83 if (last != null && !last.ReadOnly) 84 last.ToStringChanged += ParameterValueOnValueChanged; 85 base.ParameterOnValueChanged(sender, e); 86 } 87 88 protected void ParameterValueOnValueChanged(object sender, EventArgs e) { 89 handler(); 90 } 91 92 public static ValueTypeArrayParameterChangeHandler<TItem, TValue> Create(IValueParameter<TItem> parameter, Action handler) 93 => new ValueTypeArrayParameterChangeHandler<TItem, TValue>(parameter, handler); 94 } 95 96 public class ValueTypeMatrixParameterChangeHandler<TItem, TValue> : ParameterChangeHandler<TItem> 97 where TValue : struct 98 where TItem : ValueTypeMatrix<TValue> { 99 private ValueTypeMatrix<TValue> last; 100 101 protected ValueTypeMatrixParameterChangeHandler(IValueParameter<TItem> parameter, Action handler) 102 : base(parameter, handler) { 103 last = parameter.Value; 104 if (last != null && !last.ReadOnly) 105 last.ToStringChanged += ParameterValueOnValueChanged; 106 } 107 108 protected override void ParameterOnValueChanged(object sender, EventArgs e) { 109 if (last != null) last.ToStringChanged -= ParameterValueOnValueChanged; 110 last = ((IValueParameter<TItem>)sender).Value; 111 if (last != null && !last.ReadOnly) 112 last.ToStringChanged += ParameterValueOnValueChanged; 113 base.ParameterOnValueChanged(sender, e); 114 } 115 116 protected void ParameterValueOnValueChanged(object sender, EventArgs e) { 117 handler(); 118 } 119 120 public static ValueTypeMatrixParameterChangeHandler<TItem, TValue> Create(IValueParameter<TItem> parameter, Action handler) 121 => new ValueTypeMatrixParameterChangeHandler<TItem, TValue>(parameter, handler); 122 } 123 124 public class BoolValueParameterChangeHandler : ValueTypeValueParameterChangeHandler<BoolValue, bool> { 70 125 private BoolValueParameterChangeHandler(IValueParameter<BoolValue> parameter, Action handler) : base(parameter, handler) { } 71 126 public static new BoolValueParameterChangeHandler Create(IValueParameter<BoolValue> parameter, Action handler) 72 127 => new BoolValueParameterChangeHandler(parameter, handler); 73 128 } 74 public class IntValueParameterChangeHandler : ParameterChangeHandler<IntValue, int> {129 public class IntValueParameterChangeHandler : ValueTypeValueParameterChangeHandler<IntValue, int> { 75 130 private IntValueParameterChangeHandler(IValueParameter<IntValue> parameter, Action handler) : base(parameter, handler) { } 76 131 public static new IntValueParameterChangeHandler Create(IValueParameter<IntValue> parameter, Action handler) 77 132 => new IntValueParameterChangeHandler(parameter, handler); 78 133 } 79 public class DoubleValueParameterChangeHandler : ParameterChangeHandler<DoubleValue, double> {134 public class DoubleValueParameterChangeHandler : ValueTypeValueParameterChangeHandler<DoubleValue, double> { 80 135 private DoubleValueParameterChangeHandler(IValueParameter<DoubleValue> parameter, Action handler) : base(parameter, handler) { } 81 136 public static new DoubleValueParameterChangeHandler Create(IValueParameter<DoubleValue> parameter, Action handler) 82 137 => new DoubleValueParameterChangeHandler(parameter, handler); 83 138 } 84 public class PercentValueParameterChangeHandler : ParameterChangeHandler<PercentValue, double> {139 public class PercentValueParameterChangeHandler : ValueTypeValueParameterChangeHandler<PercentValue, double> { 85 140 private PercentValueParameterChangeHandler(IValueParameter<PercentValue> parameter, Action handler) : base(parameter, handler) { } 86 141 public static new PercentValueParameterChangeHandler Create(IValueParameter<PercentValue> parameter, Action handler) 87 142 => new PercentValueParameterChangeHandler(parameter, handler); 88 143 } 89 public class DateTimeValueParameterChangeHandler : ParameterChangeHandler<DateTimeValue, DateTime> {144 public class DateTimeValueParameterChangeHandler : ValueTypeValueParameterChangeHandler<DateTimeValue, DateTime> { 90 145 private DateTimeValueParameterChangeHandler(IValueParameter<DateTimeValue> parameter, Action handler) : base(parameter, handler) { } 91 146 public static new DateTimeValueParameterChangeHandler Create(IValueParameter<DateTimeValue> parameter, Action handler) 92 147 => new DateTimeValueParameterChangeHandler(parameter, handler); 93 148 } 94 public class TimeSpanValueParameterChangeHandler : ParameterChangeHandler<TimeSpanValue, TimeSpan> {149 public class TimeSpanValueParameterChangeHandler : ValueTypeValueParameterChangeHandler<TimeSpanValue, TimeSpan> { 95 150 private TimeSpanValueParameterChangeHandler(IValueParameter<TimeSpanValue> parameter, Action handler) : base(parameter, handler) { } 96 151 public static new TimeSpanValueParameterChangeHandler Create(IValueParameter<TimeSpanValue> parameter, Action handler) 97 152 => new TimeSpanValueParameterChangeHandler(parameter, handler); 98 153 } 99 public class EnumValueParameterChangeHandler<TEnum> : ParameterChangeHandler<EnumValue<TEnum>, TEnum> where TEnum : struct, IComparable {154 public class EnumValueParameterChangeHandler<TEnum> : ValueTypeValueParameterChangeHandler<EnumValue<TEnum>, TEnum> where TEnum : struct, IComparable { 100 155 private EnumValueParameterChangeHandler(IValueParameter<EnumValue<TEnum>> parameter, Action handler) : base(parameter, handler) { } 101 156 public static new EnumValueParameterChangeHandler<TEnum> Create(IValueParameter<EnumValue<TEnum>> parameter, Action handler) 102 157 => new EnumValueParameterChangeHandler<TEnum>(parameter, handler); 103 158 } 159 public class BoolArrayParameterChangeHandler : ValueTypeArrayParameterChangeHandler<BoolArray, bool> { 160 private BoolArrayParameterChangeHandler(IValueParameter<BoolArray> parameter, Action handler) : base(parameter, handler) { } 161 public static new BoolArrayParameterChangeHandler Create(IValueParameter<BoolArray> parameter, Action handler) 162 => new BoolArrayParameterChangeHandler(parameter, handler); 163 } 164 public class IntArrayParameterChangeHandler : ValueTypeArrayParameterChangeHandler<IntArray, int> { 165 private IntArrayParameterChangeHandler(IValueParameter<IntArray> parameter, Action handler) : base(parameter, handler) { } 166 public static new IntArrayParameterChangeHandler Create(IValueParameter<IntArray> parameter, Action handler) 167 => new IntArrayParameterChangeHandler(parameter, handler); 168 } 169 public class DoubleArrayParameterChangeHandler : ValueTypeArrayParameterChangeHandler<DoubleArray, double> { 170 private DoubleArrayParameterChangeHandler(IValueParameter<DoubleArray> parameter, Action handler) : base(parameter, handler) { } 171 public static new DoubleArrayParameterChangeHandler Create(IValueParameter<DoubleArray> parameter, Action handler) 172 => new DoubleArrayParameterChangeHandler(parameter, handler); 173 } 174 public class BoolMatrixParameterChangeHandler : ValueTypeMatrixParameterChangeHandler<BoolMatrix, bool> { 175 private BoolMatrixParameterChangeHandler(IValueParameter<BoolMatrix> parameter, Action handler) : base(parameter, handler) { } 176 public static new BoolMatrixParameterChangeHandler Create(IValueParameter<BoolMatrix> parameter, Action handler) 177 => new BoolMatrixParameterChangeHandler(parameter, handler); 178 } 179 public class IntMatrixParameterChangeHandler : ValueTypeMatrixParameterChangeHandler<IntMatrix, int> { 180 private IntMatrixParameterChangeHandler(IValueParameter<IntMatrix> parameter, Action handler) : base(parameter, handler) { } 181 public static new IntMatrixParameterChangeHandler Create(IValueParameter<IntMatrix> parameter, Action handler) 182 => new IntMatrixParameterChangeHandler(parameter, handler); 183 } 184 public class DoubleMatrixParameterChangeHandler : ValueTypeMatrixParameterChangeHandler<DoubleMatrix, double> { 185 private DoubleMatrixParameterChangeHandler(IValueParameter<DoubleMatrix> parameter, Action handler) : base(parameter, handler) { } 186 public static new DoubleMatrixParameterChangeHandler Create(IValueParameter<DoubleMatrix> parameter, Action handler) 187 => new DoubleMatrixParameterChangeHandler(parameter, handler); 188 } 104 189 public class StringValueParameterChangeHandler : ParameterChangeHandler<StringValue> { // StringValue does not derive from ValueTypeValue 105 190 private StringValue last; -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/MultiObjectiveTestFunctionProblem.cs
r17544 r17587 124 124 Parameters.Add(new FixedValueParameter<DoubleArray>(ReferencePointParameterName, "The reference point for hypervolume calculations on this problem", new DoubleArray(TestFunction.ReferencePoint(Objectives)))); 125 125 126 Bounds Parameter.Value = new DoubleMatrix(TestFunction.Bounds(Objectives));126 BoundsRefParameter.Value = new DoubleMatrix(TestFunction.Bounds(Objectives)); 127 127 } 128 128 -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/SingleObjectiveTestFunctionProblem.cs
r17571 r17587 70 70 71 71 BestKnownQuality = TestFunction.BestKnownQuality; 72 72 Bounds = (DoubleMatrix)TestFunction.Bounds.Clone(); 73 Dimension = TestFunction.MinimumProblemSize; 74 BestKnownSolutionParameter.Value = TestFunction.GetBestKnownSolution(Dimension); 73 75 InitializeOperators(); 74 76 RegisterEventHandlers(); … … 118 120 TestFunctionParameter.Value) { 119 121 BestKnownRealVector = bestKnownSolution, 120 Bounds = Bounds Parameter.Value122 Bounds = BoundsRefParameter.Value 121 123 }; 122 124 results.Add(new Result("Best Solution", solution)); … … 200 202 op.RealVectorParameter.ActualName = ((IRealVectorSolutionOperator)Encoding.SolutionCreator).RealVectorParameter.ActualName; 201 203 op.RealVectorParameter.Hidden = true; 202 op.BoundsParameter.ActualName = Bounds Parameter.Name;204 op.BoundsParameter.ActualName = BoundsRefParameter.Name; 203 205 op.BoundsParameter.Hidden = true; 204 206 } … … 207 209 op.RealVectorParameter.ActualName = ((IRealVectorSolutionOperator)Encoding.SolutionCreator).RealVectorParameter.ActualName; 208 210 op.RealVectorParameter.Hidden = true; 209 op.BoundsParameter.ActualName = Bounds Parameter.Name;211 op.BoundsParameter.ActualName = BoundsRefParameter.Name; 210 212 op.BoundsParameter.Hidden = true; 211 213 }
Note: See TracChangeset
for help on using the changeset viewer.