Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/19/10 02:15:10 (14 years ago)
Author:
swagner
Message:

Operator architecture refactoring (#95)

  • worked on operators and SGA
  • improved performance
Location:
trunk/sources/HeuristicLab.Operators/3.3
Files:
1 added
5 edited

Legend:

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

    r2796 r2830  
    2727namespace HeuristicLab.Operators {
    2828  /// <summary>
    29   /// Operator which contains an operator graph.
     29  /// An operator which contains an operator graph.
    3030  /// </summary>
    3131  [Item("CombinedOperator", "An operator which contains an operator graph.")]
    3232  [Creatable("Test")]
    33   public sealed class CombinedOperator : SingleSuccessorOperator, IOperator {
    34     public override Image ItemImage {
    35       get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Module; }
    36     }
    37     [Storable]
    38     private OperatorGraph operatorGraph;
    39     public OperatorGraph OperatorGraph {
    40       get { return operatorGraph; }
    41     }
     33  public sealed class CombinedOperator : AlgorithmOperator, IOperator {
    4234    public new ParameterCollection Parameters {
    4335      get {
     
    5244    }
    5345
    54     public CombinedOperator()
    55       : base() {
    56       operatorGraph = new OperatorGraph();
    57     }
    58 
    59     public override IDeepCloneable Clone(Cloner cloner) {
    60       CombinedOperator clone = (CombinedOperator)base.Clone(cloner);
    61       clone.operatorGraph = (OperatorGraph)cloner.Clone(operatorGraph);
    62       return clone;
    63     }
    64 
    65     public override IExecutionSequence Apply() {
    66       ExecutionContextCollection next = new ExecutionContextCollection(base.Apply());
    67       if (operatorGraph.InitialOperator != null)
    68         next.Insert(0, ExecutionContext.CreateChildContext(operatorGraph.InitialOperator));
    69       return next;
    70     }
     46    public CombinedOperator() : base() { }
    7147  }
    7248}
  • trunk/sources/HeuristicLab.Operators/3.3/HeuristicLab.Operators-3.3.csproj

    r2818 r2830  
    9090    <Compile Include="Comparator.cs" />
    9191    <Compile Include="Assigner.cs" />
     92    <Compile Include="AlgorithmOperator.cs" />
    9293    <Compile Include="MultipleCallsOperator.cs" />
    9394    <Compile Include="Operator.cs" />
  • trunk/sources/HeuristicLab.Operators/3.3/ParallelSubScopesProcessor.cs

    r2796 r2830  
    3939        inner.Parallel = true;
    4040        for (int i = 0; (i < ExecutionContext.Scope.SubScopes.Count) && (i < Operators.Count); i++)
    41           inner.Add(ExecutionContext.CreateContext(Operators[i], ExecutionContext.Scope.SubScopes[i]));
     41          if (Operators[i] != null) inner.Add(ExecutionContext.CreateContext(Operators[i], ExecutionContext.Scope.SubScopes[i]));
    4242        next.Insert(0, inner);
    4343      }
  • trunk/sources/HeuristicLab.Operators/3.3/SequentialSubScopesProcessor.cs

    r2796 r2830  
    3838        ExecutionContextCollection inner = new ExecutionContextCollection();
    3939        for (int i = 0; (i < ExecutionContext.Scope.SubScopes.Count) && (i < Operators.Count); i++)
    40           inner.Add(ExecutionContext.CreateContext(Operators[i], ExecutionContext.Scope.SubScopes[i]));
     40          if (Operators[i] != null) inner.Add(ExecutionContext.CreateContext(Operators[i], ExecutionContext.Scope.SubScopes[i]));
    4141        next.Insert(0, inner);
    4242      }
  • trunk/sources/HeuristicLab.Operators/3.3/SubScopesRemover.cs

    r2794 r2830  
    2727namespace HeuristicLab.Operators {
    2828  /// <summary>
    29   /// An operator which removes one specified or (if not specified) all sub-scopes from the current scope.
     29  /// An operator which removes all sub-scopes or one specified sub-scope from the current scope.
    3030  /// </summary>
    31   [Item("SubScopesRemover", "An operator which removes one specified or (if not specified) all sub-scopes from the current scope.")]
     31  [Item("SubScopesRemover", "An operator which removes all sub-scopes or one specified sub-scope from the current scope.")]
    3232  [EmptyStorableClass]
    3333  [Creatable("Test")]
    34   public class SubScopesRemover : SingleSuccessorOperator {
     34  public sealed class SubScopesRemover : SingleSuccessorOperator {
     35    private ValueParameter<BoolData> RemoveAllSubScopesParameter {
     36      get { return (ValueParameter<BoolData>)Parameters["RemoveAllSubScopes"]; }
     37    }
    3538    public ValueLookupParameter<IntData> SubScopeIndexParameter {
    3639      get { return (ValueLookupParameter<IntData>)Parameters["SubScopeIndex"]; }
    3740    }
    38     protected ScopeParameter CurrentScopeParameter {
     41    private ScopeParameter CurrentScopeParameter {
    3942      get { return (ScopeParameter)Parameters["CurrentScope"]; }
     43    }
     44
     45    public bool RemoveAllSubScopes {
     46      get { return RemoveAllSubScopesParameter.Value.Value; }
     47      set { RemoveAllSubScopesParameter.Value.Value = value; }
    4048    }
    4149    public IScope CurrentScope {
     
    4553    public SubScopesRemover()
    4654      : base() {
    47       Parameters.Add(new ValueLookupParameter<IntData>("SubScopeIndex", "The index of the sub-scope which should be removed. If this parameter has no value, all sub-scopes of the current scope are removed."));
     55      Parameters.Add(new ValueParameter<BoolData>("RemoveAllSubScopes", "True if all sub-scopes of the current scope should be removed, otherwise false.", new BoolData(true)));
     56      Parameters.Add(new ValueLookupParameter<IntData>("SubScopeIndex", "The index of the sub-scope which should be removed. This parameter is ignored, if RemoveAllSubScopes is true."));
    4857      Parameters.Add(new ScopeParameter("CurrentScope", "The current scope from which one or all sub-scopes should be removed."));
    4958    }
    5059
    5160    public override IExecutionSequence Apply() {
    52       IntData index = SubScopeIndexParameter.ActualValue;
    53       if (index != null)
    54         CurrentScope.SubScopes.RemoveAt(index.Value);
    55       else
     61      if (RemoveAllSubScopes)
    5662        CurrentScope.SubScopes.Clear();
     63      else {
     64        CurrentScope.SubScopes.RemoveAt(SubScopeIndexParameter.ActualValue.Value);
     65      }
    5766      return base.Apply();
    5867    }
Note: See TracChangeset for help on using the changeset viewer.