Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/30/12 13:36:29 (12 years ago)
Author:
jkarder
Message:

#1906:

  • added parameter
  • adapted logic
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Operators/3.3/SubScopesCounter.cs

    r7259 r8357  
    3434      get { return (ILookupParameter<IntValue>)Parameters["Value"]; }
    3535    }
     36    public IValueParameter<BoolValue> AccumulateParameter {
     37      get { return (IValueParameter<BoolValue>)Parameters["Accumulate"]; }
     38    }
    3639
    3740    [StorableConstructor]
     
    4245    public SubScopesCounter() {
    4346      Parameters.Add(new LookupParameter<IntValue>("Value", "The value that should be incremented by the number of direct sub-scopes. It will be created in the current scope if the value is not found."));
     47      Parameters.Add(new ValueParameter<BoolValue>("Accumulate", ".", new BoolValue(true)));
     48    }
     49
     50    [StorableHook(HookType.AfterDeserialization)]
     51    private void AfterDeserialization() {
     52      if (!Parameters.ContainsKey("Accumulate"))
     53        Parameters.Add(new ValueParameter<BoolValue>("Accumulate", ".", new BoolValue(true)));
    4454    }
    4555
     
    4959
    5060    public override IOperation Apply() {
    51       int increment = ExecutionContext.Scope.SubScopes.Count;
     61      int count = ExecutionContext.Scope.SubScopes.Count;
    5262      if (ValueParameter.ActualValue == null) ValueParameter.ActualValue = new IntValue();
    53       ValueParameter.ActualValue.Value += increment;
     63      if (AccumulateParameter.Value.Value) ValueParameter.ActualValue.Value += count;
     64      else ValueParameter.ActualValue.Value = count;
    5465      return base.Apply();
    5566    }
Note: See TracChangeset for help on using the changeset viewer.