- Timestamp:
- 05/13/19 15:21:54 (6 years ago)
- Location:
- branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorMultiObjectiveProblem.cs
r16876 r16948 28 28 using HeuristicLab.Common; 29 29 using HeuristicLab.Core; 30 using HeuristicLab.Data;31 30 using HeuristicLab.Optimization; 32 using HeuristicLab.Parameters;33 31 34 32 namespace HeuristicLab.Encodings.BinaryVectorEncoding { … … 38 36 get { return Encoding.Length; } 39 37 set { Encoding.Length = value; } 40 }41 42 private IFixedValueParameter<IntValue> LengthParameter {43 get { return (IFixedValueParameter<IntValue>)Parameters["Length"]; }44 38 } 45 39 … … 56 50 } 57 51 58 protected BinaryVectorMultiObjectiveProblem() : base(new BinaryVectorEncoding()) { 59 var lengthParameter = new FixedValueParameter<IntValue>("Length", "The length of the BinaryVector.", new IntValue(10)); 60 Parameters.Add(lengthParameter); 61 Encoding.LengthParameter = lengthParameter; 52 protected BinaryVectorMultiObjectiveProblem() : this(new BinaryVectorEncoding() { Length = 10 }) { } 53 protected BinaryVectorMultiObjectiveProblem(BinaryVectorEncoding encoding) : base(encoding) { 54 EncodingParameter.ReadOnly = true; 62 55 63 56 Operators.Add(new HammingSimilarityCalculator()); … … 75 68 protected override void OnEncodingChanged() { 76 69 base.OnEncodingChanged(); 77 Encoding.LengthParameter = LengthParameter;78 70 Parameterize(); 79 71 } … … 87 79 88 80 private void RegisterEventHandlers() { 89 LengthParameter.Value.ValueChanged += LengthParameter_ValueChanged;81 Encoding.LengthParameter.Value.ValueChanged += LengthParameter_ValueChanged; 90 82 } 91 83 -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorProblem.cs
r16814 r16948 28 28 using HeuristicLab.Common; 29 29 using HeuristicLab.Core; 30 using HeuristicLab.Data;31 30 using HeuristicLab.Optimization; 32 31 using HeuristicLab.Optimization.Operators; 33 using HeuristicLab.Parameters;34 32 35 33 namespace HeuristicLab.Encodings.BinaryVectorEncoding { … … 39 37 get { return Encoding.Length; } 40 38 set { Encoding.Length = value; } 41 }42 43 private IFixedValueParameter<IntValue> LengthParameter {44 get { return (IFixedValueParameter<IntValue>)Parameters["Length"]; }45 39 } 46 40 … … 57 51 } 58 52 59 protected BinaryVectorProblem() : base(new BinaryVectorEncoding()) { 60 var lengthParameter = new FixedValueParameter<IntValue>("Length", "The length of the BinaryVector.", new IntValue(10)); 61 Parameters.Add(lengthParameter); 62 Encoding.LengthParameter = lengthParameter; 53 protected BinaryVectorProblem() : this(new BinaryVectorEncoding() { Length = 10 }) { } 54 protected BinaryVectorProblem(BinaryVectorEncoding encoding) : base(encoding) { 55 EncodingParameter.ReadOnly = true; 63 56 64 57 Operators.Add(new HammingSimilarityCalculator()); … … 75 68 var best = Maximization ? orderedIndividuals.Last().Individual : orderedIndividuals.First().Individual; 76 69 77 if (!results.ContainsKey("Best Solution")) { 78 results.Add(new Result("Best Solution", typeof(BinaryVector))); 79 } 80 results["Best Solution"].Value = (IItem)best.Clone(); 70 results.AddOrUpdateResult("Best Solution", (IItem)best.Clone()); 81 71 } 82 72 83 73 protected override void OnEncodingChanged() { 84 74 base.OnEncodingChanged(); 85 Encoding.LengthParameter = LengthParameter;86 75 Parameterize(); 87 76 } … … 95 84 96 85 private void RegisterEventHandlers() { 97 LengthParameter.Value.ValueChanged += LengthParameter_ValueChanged;86 Encoding.LengthParameter.Value.ValueChanged += LengthParameter_ValueChanged; 98 87 } 99 88
Note: See TracChangeset
for help on using the changeset viewer.