Changeset 2830 for trunk/sources/HeuristicLab.Operators
- Timestamp:
- 02/19/10 02:15:10 (15 years ago)
- 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 27 27 namespace HeuristicLab.Operators { 28 28 /// <summary> 29 /// Operator which contains an operator graph.29 /// An operator which contains an operator graph. 30 30 /// </summary> 31 31 [Item("CombinedOperator", "An operator which contains an operator graph.")] 32 32 [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 { 42 34 public new ParameterCollection Parameters { 43 35 get { … … 52 44 } 53 45 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() { } 71 47 } 72 48 } -
trunk/sources/HeuristicLab.Operators/3.3/HeuristicLab.Operators-3.3.csproj
r2818 r2830 90 90 <Compile Include="Comparator.cs" /> 91 91 <Compile Include="Assigner.cs" /> 92 <Compile Include="AlgorithmOperator.cs" /> 92 93 <Compile Include="MultipleCallsOperator.cs" /> 93 94 <Compile Include="Operator.cs" /> -
trunk/sources/HeuristicLab.Operators/3.3/ParallelSubScopesProcessor.cs
r2796 r2830 39 39 inner.Parallel = true; 40 40 for (int i = 0; (i < ExecutionContext.Scope.SubScopes.Count) && (i < Operators.Count); i++) 41 i nner.Add(ExecutionContext.CreateContext(Operators[i], ExecutionContext.Scope.SubScopes[i]));41 if (Operators[i] != null) inner.Add(ExecutionContext.CreateContext(Operators[i], ExecutionContext.Scope.SubScopes[i])); 42 42 next.Insert(0, inner); 43 43 } -
trunk/sources/HeuristicLab.Operators/3.3/SequentialSubScopesProcessor.cs
r2796 r2830 38 38 ExecutionContextCollection inner = new ExecutionContextCollection(); 39 39 for (int i = 0; (i < ExecutionContext.Scope.SubScopes.Count) && (i < Operators.Count); i++) 40 i nner.Add(ExecutionContext.CreateContext(Operators[i], ExecutionContext.Scope.SubScopes[i]));40 if (Operators[i] != null) inner.Add(ExecutionContext.CreateContext(Operators[i], ExecutionContext.Scope.SubScopes[i])); 41 41 next.Insert(0, inner); 42 42 } -
trunk/sources/HeuristicLab.Operators/3.3/SubScopesRemover.cs
r2794 r2830 27 27 namespace HeuristicLab.Operators { 28 28 /// <summary> 29 /// An operator which removes one specified or (if not specified) all sub-scopesfrom the current scope.29 /// An operator which removes all sub-scopes or one specified sub-scope from the current scope. 30 30 /// </summary> 31 [Item("SubScopesRemover", "An operator which removes one specified or (if not specified) all sub-scopesfrom the current scope.")]31 [Item("SubScopesRemover", "An operator which removes all sub-scopes or one specified sub-scope from the current scope.")] 32 32 [EmptyStorableClass] 33 33 [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 } 35 38 public ValueLookupParameter<IntData> SubScopeIndexParameter { 36 39 get { return (ValueLookupParameter<IntData>)Parameters["SubScopeIndex"]; } 37 40 } 38 pr otectedScopeParameter CurrentScopeParameter {41 private ScopeParameter CurrentScopeParameter { 39 42 get { return (ScopeParameter)Parameters["CurrentScope"]; } 43 } 44 45 public bool RemoveAllSubScopes { 46 get { return RemoveAllSubScopesParameter.Value.Value; } 47 set { RemoveAllSubScopesParameter.Value.Value = value; } 40 48 } 41 49 public IScope CurrentScope { … … 45 53 public SubScopesRemover() 46 54 : 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.")); 48 57 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope from which one or all sub-scopes should be removed.")); 49 58 } 50 59 51 60 public override IExecutionSequence Apply() { 52 IntData index = SubScopeIndexParameter.ActualValue; 53 if (index != null) 54 CurrentScope.SubScopes.RemoveAt(index.Value); 55 else 61 if (RemoveAllSubScopes) 56 62 CurrentScope.SubScopes.Clear(); 63 else { 64 CurrentScope.SubScopes.RemoveAt(SubScopeIndexParameter.ActualValue.Value); 65 } 57 66 return base.Apply(); 58 67 }
Note: See TracChangeset
for help on using the changeset viewer.