Changeset 11990
- Timestamp:
- 02/12/15 16:32:37 (10 years ago)
- Location:
- trunk/sources
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization/3.3/BasicProblems/SingleObjectiveBasicProblem.cs
r11970 r11990 33 33 ISingleObjectiveProblemDefinition, ISingleObjectiveHeuristicOptimizationProblem 34 34 where TEncoding : class, IEncoding { 35 36 protected IValueParameter<DoubleValue> BestKnownQualityParameter { 37 get { return (IValueParameter<DoubleValue>)Parameters["BestKnownQuality"]; } 38 } 39 40 public double BestKnownQuality { 41 get { 42 if (BestKnownQualityParameter.Value == null) return double.NaN; 43 return BestKnownQualityParameter.Value.Value; 44 } 45 set { 46 if (BestKnownQualityParameter.Value == null) BestKnownQualityParameter.Value = new DoubleValue(value); 47 else BestKnownQualityParameter.Value.Value = value; 48 } 49 } 50 35 51 [StorableConstructor] 36 52 protected SingleObjectiveBasicProblem(bool deserializing) : base(deserializing) { } -
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 } -
trunk/sources/HeuristicLab.Problems.Binary/3.3/HeuristicLab.Problems.Binary-3.3.csproj
r11987 r11990 86 86 <Compile Include="DeceptiveTrapProblem.cs" /> 87 87 <Compile Include="HIFFProblem.cs" /> 88 <Compile Include="OneMaxProblem.cs" /> 88 89 <Compile Include="Plugin.cs" /> 89 90 <Compile Include="Properties\AssemblyInfo.cs" />
Note: See TracChangeset
for help on using the changeset viewer.