Changeset 18080


Ignore:
Timestamp:
11/12/21 16:48:23 (3 weeks ago)
Author:
dpiringe
Message:

#3139

  • changed the type of MaximumSymbolicExpressionTreeLengthParameter from ILookupParameter to IValueLookupParameter
  • added logic in AfterDeserialization to handle serialized data with old parameter type
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3139_ParameterChange_SymbolicExpressionTreeLengthAnalyzer/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Analyzers/SymbolicExpressionTreeLengthAnalyzer.cs

    r17180 r18080  
    5252    }
    5353
    54     public ILookupParameter<IntValue> MaximumSymbolicExpressionTreeLengthParameter {
    55       get { return (ILookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeLengthParameterName]; }
     54    public IValueLookupParameter<IntValue> MaximumSymbolicExpressionTreeLengthParameter {
     55      get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeLengthParameterName]; }
    5656    }
    5757    public ValueLookupParameter<DataTable> SymbolicExpressionTreeLengthsParameter {
     
    102102      : base() {
    103103      Parameters.Add(new ScopeTreeLookupParameter<ISymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree whose length should be calculated."));
    104       Parameters.Add(new LookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, "The maximum allowed symbolic expression tree length"));
     104      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, "The maximum allowed symbolic expression tree length"));
    105105      Parameters.Add(new ValueLookupParameter<DataTable>(SymbolicExpressionTreeLengthsParameterName, "The data table to store the symbolic expression tree lengths."));
    106106      Parameters.Add(new ValueLookupParameter<DataTableHistory>(SymbolicExpressionTreeLengthsHistoryParameterName, "The data table to store the symbolic expression tree lengths history."));
     
    118118    [StorableHook(HookType.AfterDeserialization)]
    119119    private void AfterDeserialization() {
     120      // reset MaximumSymbolicExpressionTreeLengthParameterName to ValueLookupParameter
     121      if (Parameters.TryGetValue(MaximumSymbolicExpressionTreeLengthParameterName, out IParameter parameter) && !(parameter is ValueLookupParameter<IntValue>)) {
     122        Parameters.Remove(MaximumSymbolicExpressionTreeLengthParameterName);
     123        Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, "The maximum allowed symbolic expression tree length"));
     124      }
    120125      // check if all the parameters are present and accounted for
    121126      if (!Parameters.ContainsKey(StoreHistoryParameterName)) {
Note: See TracChangeset for help on using the changeset viewer.