- Timestamp:
- 02/12/15 16:32:37 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.Binary/3.3/BinaryProblem.cs
r11987 r11990 22 22 #endregion 23 23 24 using System; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; … … 33 34 [StorableClass] 34 35 public abstract class BinaryProblem : SingleObjectiveBasicProblem<BinaryVectorEncoding> { 35 36 36 public virtual int Length { 37 37 get { return Encoding.Length; } … … 39 39 } 40 40 41 private IFixedValueParameter<IntValue> LengthParameter { 42 get { return (IFixedValueParameter<IntValue>)Parameters["Length"]; } 43 } 44 41 45 [StorableConstructor] 42 46 protected BinaryProblem(bool deserializing) : base(deserializing) { } 43 protected BinaryProblem(BinaryProblem original, Cloner cloner) : base(original, cloner) { } 44 protected BinaryProblem() : base() { } 47 [StorableHook(HookType.AfterDeserialization)] 48 private void AfterDeserialization() { 49 RegisterEventHandlers(); 50 } 51 52 protected BinaryProblem(BinaryProblem original, Cloner cloner) 53 : base(original, cloner) { 54 RegisterEventHandlers(); 55 } 56 57 protected BinaryProblem() 58 : base() { 59 var lengthParameter = new FixedValueParameter<IntValue>("Length", "The length of the BinaryVector.", new IntValue(10)); 60 Parameters.Add(lengthParameter); 61 Encoding.LengthParameter = lengthParameter; 62 RegisterEventHandlers(); 63 } 45 64 46 65 public virtual bool IsBetter(double quality, double bestQuality) { … … 53 72 54 73 public abstract double Evaluate(BinaryVector vector, IRandom random); 74 75 protected override void OnEncodingChanged() { 76 base.OnEncodingChanged(); 77 Encoding.LengthParameter = LengthParameter; 78 } 79 80 81 private void RegisterEventHandlers() { 82 LengthParameter.Value.ValueChanged += LengthParameter_ValueChanged; 83 } 84 85 protected virtual void LengthParameter_ValueChanged(object sender, EventArgs e) { } 55 86 } 56 87 }
Note: See TracChangeset
for help on using the changeset viewer.