Changeset 5381 for trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/RealVectorCrossover.cs
- Timestamp:
- 01/26/11 18:39:49 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/RealVectorCrossover.cs
r4722 r5381 51 51 get { return (IValueLookupParameter<DoubleMatrix>)Parameters["Bounds"]; } 52 52 } 53 public OptionalValueParameter<IRealVectorBoundsChecker> BoundsCheckerParameter { 54 get { return (OptionalValueParameter<IRealVectorBoundsChecker>)Parameters["BoundsChecker"]; } 55 } 53 56 54 57 [StorableConstructor] … … 63 66 ChildParameter.ActualName = "RealVector"; 64 67 Parameters.Add(new ValueLookupParameter<DoubleMatrix>("Bounds", "The lower and upper bounds of the real vector.")); 68 Parameters.Add(new OptionalValueParameter<IRealVectorBoundsChecker>("BoundsChecker", "The bounds checker that ensures that the values stay within the bounds.", new BoundsChecker())); 65 69 } 70 71 // BackwardsCompatibility3.3 72 #region Backwards compatible code (remove with 3.4) 73 [StorableHook(HookType.AfterDeserialization)] 74 private void AfterDeserialization() { 75 if (!Parameters.ContainsKey("BoundsChecker")) 76 Parameters.Add(new OptionalValueParameter<IRealVectorBoundsChecker>("BoundsChecker", "The bounds checker that ensures that the values stay within the bounds.", new BoundsChecker())); 77 } 78 #endregion 66 79 67 80 public sealed override IOperation Apply() { 68 81 RealVector result = Cross(RandomParameter.ActualValue, ParentsParameter.ActualValue); 69 DoubleMatrix bounds = BoundsParameter.ActualValue; 70 if (bounds != null) BoundsChecker.Apply(result, bounds); 71 ChildParameter.ActualValue = result; 72 return base.Apply(); 82 83 IRealVectorBoundsChecker checker = BoundsCheckerParameter.Value; 84 IOperation successor = base.Apply(); 85 if (checker != null) { 86 IOperation checkerOperation = ExecutionContext.CreateChildOperation(checker); 87 if (successor == null) return checkerOperation; 88 else return new OperationCollection(checkerOperation, successor); 89 } else return successor; 73 90 } 74 91
Note: See TracChangeset
for help on using the changeset viewer.