Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/06/08 00:35:25 (16 years ago)
Author:
swagner
Message:

Worked on ticket #48

  • simplified CombinedOperator and OperatorExtractor
File:
1 edited

Legend:

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

    r47 r48  
    4141      : base() {
    4242      myDescription =
    43         "A combined operator contains a whole operator graph. It is useful for modularization to assemble complex operators out of simpler ones.\r\n\r\n" +
    44         "A combined operator can automatically inject its sub-operators into the scope it is applied on. Those operators can be extracted again in the contained operator graph by using an OperatorExtractor. So it is possible to parameterize a combined operator with custom operators. To activate sub-operator injection take a look at the local variables InjectSubOperators and SubOperatorNames.";
     43        @"A combined operator contains a whole operator graph. It is useful for modularization to assemble complex operators out of simpler ones.
     44
     45A combined operator automatically inject its sub-operators into the scope it is applied on. Thereby the names of the sub-operators are used as variable names. Those operators can be extracted again in the contained operator graph by using an OperatorExtractor. So it is possible to parameterize a combined operator with custom operators.";
    4546      myOperatorGraph = new OperatorGraph();
    46       AddVariableInfo(new VariableInfo("InjectSubOperators", "true if the sub-operators of this combined operator should be injected into the scope", typeof(BoolData), VariableKind.In));
    47       GetVariableInfo("InjectSubOperators").Local = true;
    48       AddVariable(new Variable("InjectSubOperators", new BoolData(false)));
    49       AddVariableInfo(new VariableInfo("SubOperatorNames", "Variable names for injecting the sub-operators", typeof(ItemList<StringData>), VariableKind.In));
    50       GetVariableInfo("SubOperatorNames").Local = true;
    51       ItemList<StringData> subOperatorNames = new ItemList<StringData>();
    52       AddVariable(new Variable("SubOperatorNames", subOperatorNames));
    5347    }
    5448
     
    7266    public override IOperation Apply(IScope scope) {
    7367      if (OperatorGraph.InitialOperator != null) {
    74         bool inject = GetVariableValue<BoolData>("InjectSubOperators", scope, false).Data;
    75         if (inject) {
    76           ItemList<StringData> names = GetVariableValue<ItemList<StringData>>("SubOperatorNames", scope, false);
    77           for (int i = 0; i < SubOperators.Count; i++) {
    78             if (scope.GetVariable(names[i].Data) != null)
    79               scope.RemoveVariable(names[i].Data);
    80             scope.AddVariable(new Variable(names[i].Data, SubOperators[i]));
    81           }
     68        for (int i = 0; i < SubOperators.Count; i++) {
     69          if (scope.GetVariable(SubOperators[i].Name) != null)
     70            scope.RemoveVariable(SubOperators[i].Name);
     71          scope.AddVariable(new Variable(SubOperators[i].Name, SubOperators[i]));
    8272        }
    8373        return new AtomicOperation(OperatorGraph.InitialOperator, scope);
Note: See TracChangeset for help on using the changeset viewer.