Free cookie consent management tool by TermsFeed Policy Generator

Changeset 18102


Ignore:
Timestamp:
12/02/21 17:04:41 (2 years ago)
Author:
dpiringe
Message:

#3139

  • split if statement for tree length parameter to allow the possiblity to add the parameter (without removal)
  • change the if statement structure of UpdateCounterParameter to be consistent
File:
1 edited

Legend:

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

    r18080 r18102  
    119119    private void AfterDeserialization() {
    120120      // reset MaximumSymbolicExpressionTreeLengthParameterName to ValueLookupParameter
    121       if (Parameters.TryGetValue(MaximumSymbolicExpressionTreeLengthParameterName, out IParameter parameter) && !(parameter is ValueLookupParameter<IntValue>)) {
     121      if (Parameters.TryGetValue(MaximumSymbolicExpressionTreeLengthParameterName, out IParameter treeLengthParam) && !(treeLengthParam is ValueLookupParameter<IntValue>))
    122122        Parameters.Remove(MaximumSymbolicExpressionTreeLengthParameterName);
     123      if(!Parameters.ContainsKey(MaximumSymbolicExpressionTreeLengthParameterName))
    123124        Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, "The maximum allowed symbolic expression tree length"));
    124       }
     125
    125126      // check if all the parameters are present and accounted for
    126       if (!Parameters.ContainsKey(StoreHistoryParameterName)) {
     127      if (!Parameters.ContainsKey(StoreHistoryParameterName))
    127128        Parameters.Add(new ValueParameter<BoolValue>(StoreHistoryParameterName, "True if the tree lengths history of the population should be stored.", new BoolValue(false)));
    128       }
    129       if (!Parameters.ContainsKey(UpdateIntervalParameterName)) {
     129     
     130      if (!Parameters.ContainsKey(UpdateIntervalParameterName))
    130131        Parameters.Add(new ValueParameter<IntValue>(UpdateIntervalParameterName, "The interval in which the tree length analysis should be applied.", new IntValue(1)));
    131       }
     132
    132133      //necessary code to correct UpdateCounterParameter - type was changed from LookupParameter to ValueParameter
    133       if (Parameters.ContainsKey(UpdateCounterParameterName) && (Parameters[UpdateCounterParameterName] is LookupParameter<IntValue>))
     134      if (Parameters.TryGetValue(UpdateCounterParameterName, out IParameter updateCounterParam) && updateCounterParam is LookupParameter<IntValue>)
    134135        Parameters.Remove(UpdateCounterParameterName);
    135136      if (!Parameters.ContainsKey(UpdateCounterParameterName)) {
Note: See TracChangeset for help on using the changeset viewer.