Changeset 13443 for branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/PriorityRulesVectorEncoding.cs
- Timestamp:
- 12/08/15 14:31:05 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/PriorityRulesVectorEncoding.cs
r13437 r13443 27 27 using HeuristicLab.Common; 28 28 using HeuristicLab.Core; 29 using HeuristicLab.Encodings.ScheduleEncoding; 29 using HeuristicLab.Data; 30 using HeuristicLab.Parameters; 30 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 32 using HeuristicLab.PluginInfrastructure; 32 33 33 namespace HeuristicLab.Encodings.Schedule {34 namespace HeuristicLab.Encodings.ScheduleEncoding { 34 35 [StorableClass] 35 public sealed class PriorityRulesVectorEncoding : ScheduleEncoding { 36 public sealed class PriorityRulesVectorEncoding : ScheduleEncoding<PRVEncoding> { 37 38 private IFixedValueParameter<IntValue> numberOfRulesParameter; 39 public IFixedValueParameter<IntValue> NumberOfRulesParameter { 40 get { return numberOfRulesParameter; } 41 set { 42 if (value == null) throw new ArgumentNullException("Number of Rules parameter must not be null."); 43 if (value.Value == null) throw new ArgumentNullException("Number of Rules parameter value must not be null."); 44 if (numberOfRulesParameter == value) return; 45 46 if (numberOfRulesParameter != null) Parameters.Remove(numberOfRulesParameter); 47 numberOfRulesParameter = value; 48 Parameters.Add(numberOfRulesParameter); 49 OnNumberOfRulesParameterChanged(); 50 } 51 } 52 53 36 54 [StorableConstructor] 37 55 private PriorityRulesVectorEncoding(bool deserializing) : base(deserializing) { } … … 43 61 public PriorityRulesVectorEncoding() 44 62 : base() { 63 //TODO change to meaningful value 64 numberOfRulesParameter = new FixedValueParameter<IntValue>(Name + ".NumberOfRules", new IntValue(10)); 65 Parameters.Add(numberOfRulesParameter); 66 45 67 SolutionCreator = new PRVRandomCreator(); 68 Decoder = new PRVDecoder(); 46 69 DiscoverOperators(); 70 } 71 72 private void OnNumberOfRulesParameterChanged() { 73 ConfigureOperators(Operators); 47 74 } 48 75 … … 64 91 AddOperator(@operator); 65 92 } 93 94 public override void ConfigureOperators(IEnumerable<IItem> operators) { 95 base.ConfigureOperators(operators); 96 ConfigureRulesParameter(operators.OfType<IPRVRulesOperator>()); 97 } 98 99 private void ConfigureRulesParameter(IEnumerable<IPRVRulesOperator> rulesOperators) { 100 foreach (var rulesOperator in rulesOperators) 101 rulesOperator.NumberOfRulesParameter.ActualName = numberOfRulesParameter.Name; 102 } 103 66 104 #endregion 67 105 }
Note: See TracChangeset
for help on using the changeset viewer.