Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/08/15 14:31:05 (8 years ago)
Author:
mkommend
Message:

#2521: Adapted decoders for SchedulingProblem.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/PriorityRulesVectorEncoding.cs

    r13437 r13443  
    2727using HeuristicLab.Common;
    2828using HeuristicLab.Core;
    29 using HeuristicLab.Encodings.ScheduleEncoding;
     29using HeuristicLab.Data;
     30using HeuristicLab.Parameters;
    3031using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3132using HeuristicLab.PluginInfrastructure;
    3233
    33 namespace HeuristicLab.Encodings.Schedule {
     34namespace HeuristicLab.Encodings.ScheduleEncoding {
    3435  [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
    3654    [StorableConstructor]
    3755    private PriorityRulesVectorEncoding(bool deserializing) : base(deserializing) { }
     
    4361    public PriorityRulesVectorEncoding()
    4462      : base() {
     63      //TODO change to meaningful value
     64      numberOfRulesParameter = new FixedValueParameter<IntValue>(Name + ".NumberOfRules", new IntValue(10));
     65      Parameters.Add(numberOfRulesParameter);
     66
    4567      SolutionCreator = new PRVRandomCreator();
     68      Decoder = new PRVDecoder();
    4669      DiscoverOperators();
     70    }
     71
     72    private void OnNumberOfRulesParameterChanged() {
     73      ConfigureOperators(Operators);
    4774    }
    4875
     
    6491        AddOperator(@operator);
    6592    }
     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
    66104    #endregion
    67105  }
Note: See TracChangeset for help on using the changeset viewer.