Changeset 4722 for trunk/sources/HeuristicLab.Operators
- Timestamp:
- 11/06/10 01:56:04 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources
- Property svn:mergeinfo changed
/branches/CloningRefactoring (added) merged: 4656-4693,4696-4697,4711-4714,4718-4719
- Property svn:mergeinfo changed
-
trunk/sources/HeuristicLab.Operators/3.3/AlgorithmOperator.cs
r3376 r4722 44 44 } 45 45 46 [StorableConstructor] 47 protected AlgorithmOperator(bool deserializing) : base(deserializing) { } 48 protected AlgorithmOperator(AlgorithmOperator original, Cloner cloner) 49 : base(original, cloner) { 50 this.operatorGraph = cloner.Clone<OperatorGraph>(original.operatorGraph); 51 } 46 52 protected AlgorithmOperator() 47 53 : base() { 48 54 operatorGraph = new OperatorGraph(); 49 }50 51 public override IDeepCloneable Clone(Cloner cloner) {52 AlgorithmOperator clone = (AlgorithmOperator)base.Clone(cloner);53 clone.operatorGraph = (OperatorGraph)cloner.Clone(operatorGraph);54 return clone;55 55 } 56 56 -
trunk/sources/HeuristicLab.Operators/3.3/Assigner.cs
r4068 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Parameters; … … 38 39 } 39 40 41 [StorableConstructor] 42 private Assigner(bool deserializing) : base(deserializing) { } 43 private Assigner(Assigner original, Cloner cloner) 44 : base(original, cloner) { 45 } 40 46 public Assigner() 41 47 : base() { 42 48 Parameters.Add(new LookupParameter<IItem>("LeftSide", "The parameter whose value gets assigned with a clone of the other parameter's value.")); 43 49 Parameters.Add(new ValueLookupParameter<IItem>("RightSide", "The parameter whose value is cloned and assigned to the value of the other parameter.")); 50 } 51 52 public override IDeepCloneable Clone(Cloner cloner) { 53 return new Assigner(this, cloner); 44 54 } 45 55 -
trunk/sources/HeuristicLab.Operators/3.3/CheckedMultiOperator.cs
r4068 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 37 38 protected set { base.Operators = value; } 38 39 } 40 41 [StorableConstructor] 42 protected CheckedMultiOperator(bool deserializing) : base(deserializing) { } 43 protected CheckedMultiOperator(CheckedMultiOperator<T> original, Cloner cloner) 44 : base(original, cloner) { 45 } 39 46 /// <summary> 40 47 /// Creates a new instance of CheckedMultiOperator … … 44 51 Operators = new CheckedItemList<T>(); 45 52 } 46 [StorableConstructor]47 protected CheckedMultiOperator(bool deserializing) : base(deserializing) { }48 53 } 49 54 } -
trunk/sources/HeuristicLab.Operators/3.3/CombinedOperator.cs
r4477 r4722 43 43 } 44 44 45 [StorableConstructor] 46 private CombinedOperator(bool deserializing) : base(deserializing) { } 47 private CombinedOperator(CombinedOperator original, Cloner cloner) 48 : base(original, cloner) { 49 } 45 50 public CombinedOperator() : base() { } 51 52 public override IDeepCloneable Clone(Cloner cloner) { 53 return new CombinedOperator(this, cloner); 54 } 46 55 } 47 56 } -
trunk/sources/HeuristicLab.Operators/3.3/Comparator.cs
r4068 r4722 21 21 22 22 using System; 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; 24 25 using HeuristicLab.Data; … … 50 51 } 51 52 53 [StorableConstructor] 54 private Comparator(bool deserializing) : base(deserializing) { } 55 private Comparator(Comparator original, Cloner cloner) 56 : base(original, cloner) { 57 } 52 58 public Comparator() 53 59 : base() { … … 56 62 Parameters.Add(new ValueParameter<Comparison>("Comparison", "The type of comparison.", new Comparison(Data.ComparisonType.Equal))); 57 63 Parameters.Add(new LookupParameter<BoolValue>("Result", "The result of the comparison.")); 64 } 65 66 public override IDeepCloneable Clone(Cloner cloner) { 67 return new Comparator(this, cloner); 58 68 } 59 69 -
trunk/sources/HeuristicLab.Operators/3.3/ConditionalBranch.cs
r4477 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Data; … … 50 51 } 51 52 53 [StorableConstructor] 54 protected ConditionalBranch(bool deserializing) : base(deserializing) { } 55 protected ConditionalBranch(ConditionalBranch original, Cloner cloner) 56 : base(original, cloner) { 57 } 52 58 public ConditionalBranch() 53 59 : base() { … … 55 61 Parameters.Add(new OperatorParameter("TrueBranch", "The operator which is executed if the condition is true.")); 56 62 Parameters.Add(new OperatorParameter("FalseBranch", "The operator which is executed if the condition is false.")); 63 } 64 65 public override IDeepCloneable Clone(Cloner cloner) { 66 return new ConditionalBranch(this, cloner); 57 67 } 58 68 -
trunk/sources/HeuristicLab.Operators/3.3/DoubleCounter.cs
r4477 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Data; … … 43 44 } 44 45 46 [StorableConstructor] 47 private DoubleCounter(bool deserializing) : base(deserializing) { } 48 private DoubleCounter(DoubleCounter original, Cloner cloner) 49 : base(original, cloner) { 50 } 45 51 public DoubleCounter() 46 52 : base() { 47 53 Parameters.Add(new LookupParameter<DoubleValue>("Value", "The value which should be incremented.")); 48 54 Parameters.Add(new ValueLookupParameter<DoubleValue>("Increment", "The increment which is added to the value.", new DoubleValue(1))); 55 } 56 57 public override IDeepCloneable Clone(Cloner cloner) { 58 return new DoubleCounter(this, cloner); 49 59 } 50 60 -
trunk/sources/HeuristicLab.Operators/3.3/EmptyOperator.cs
r4477 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 30 31 [StorableClass] 31 32 public sealed class EmptyOperator : SingleSuccessorOperator { 33 [StorableConstructor] 34 private EmptyOperator(bool deserializing) : base(deserializing) { } 35 private EmptyOperator(EmptyOperator original, Cloner cloner) 36 : base(original, cloner) { 37 } 32 38 public EmptyOperator() 33 39 : base() { 34 40 } 41 42 public override IDeepCloneable Clone(Cloner cloner) { 43 return new EmptyOperator(this, cloner); 44 } 35 45 } 36 46 } -
trunk/sources/HeuristicLab.Operators/3.3/IntCounter.cs
r4477 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Data; … … 43 44 } 44 45 46 [StorableConstructor] 47 private IntCounter(bool deserializing) : base(deserializing) { } 48 private IntCounter(IntCounter original, Cloner cloner) 49 : base(original, cloner) { 50 } 45 51 public IntCounter() 46 52 : base() { 47 53 Parameters.Add(new LookupParameter<IntValue>("Value", "The value which should be incremented.")); 48 54 Parameters.Add(new ValueLookupParameter<IntValue>("Increment", "The increment which is added to the value.", new IntValue(1))); 55 } 56 57 public override IDeepCloneable Clone(Cloner cloner) { 58 return new IntCounter(this, cloner); 49 59 } 50 60 -
trunk/sources/HeuristicLab.Operators/3.3/MultiOperator.cs
r4068 r4722 51 51 } 52 52 53 [StorableConstructor] 54 protected MultiOperator(bool deserializing) : base(deserializing) { } 55 protected MultiOperator(MultiOperator<T> original, Cloner cloner) 56 : base(original, cloner) { 57 this.operators = cloner.Clone<IItemList<T>>(original.operators); 58 Initialize(); 59 } 53 60 public MultiOperator() 54 61 : base() { … … 57 64 } 58 65 59 [StorableConstructor]60 protected MultiOperator(bool deserializing) : base(deserializing) { }61 62 66 [StorableHook(HookType.AfterDeserialization)] 67 private void AfterDeserialization() { 68 Initialize(); 69 } 70 63 71 private void Initialize() { 64 72 if (operators != null) RegisterOperatorsEvents(); … … 69 77 opParam.ValueChanged += new EventHandler(opParam_ValueChanged); 70 78 } 71 }72 73 public override IDeepCloneable Clone(Cloner cloner) {74 MultiOperator<T> clone = (MultiOperator<T>)base.Clone(cloner);75 clone.operators = (IItemList<T>)cloner.Clone(operators);76 clone.Initialize();77 return clone;78 79 } 79 80 -
trunk/sources/HeuristicLab.Operators/3.3/Operator.cs
r4477 r4722 85 85 } 86 86 87 [StorableConstructor] 88 protected Operator(bool deserializing) : base(deserializing) { } 89 protected Operator(Operator original, Cloner cloner) 90 : base(original, cloner) { 91 this.canceled = original.canceled; 92 this.breakpoint = original.breakpoint; 93 this.executionContext = cloner.Clone<IExecutionContext>(original.executionContext); 94 } 87 95 /// <summary> 88 96 /// Initializes a new instance of <see cref="OperatorBase"/> setting the breakpoint flag and … … 113 121 canceled = false; 114 122 breakpoint = false; 115 }116 [StorableConstructor]117 protected Operator(bool deserializing) : base(deserializing) { }118 119 /// <summary>120 /// Clones the current instance (deep clone).121 /// </summary>122 /// <remarks>Clones also sub operators, variables and variable infos.</remarks>123 /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param>124 /// <returns>The cloned object as <see cref="OperatorBase"/>.</returns>125 public override IDeepCloneable Clone(Cloner cloner) {126 Operator clone = (Operator)base.Clone(cloner);127 clone.canceled = canceled;128 clone.breakpoint = breakpoint;129 clone.executionContext = (IExecutionContext)cloner.Clone(executionContext);130 return clone;131 123 } 132 124 -
trunk/sources/HeuristicLab.Operators/3.3/Placeholder.cs
r4477 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Parameters; … … 35 36 } 36 37 38 [StorableConstructor] 39 private Placeholder(bool deserializing) : base(deserializing) { } 40 private Placeholder(Placeholder original, Cloner cloner) 41 : base(original, cloner) { 42 } 37 43 public Placeholder() 38 44 : base() { 39 45 Parameters.Add(new LookupParameter<IOperator>("Operator", "The operator which is retrieved from the scope or a parent execution context and applied on the current scope.")); 46 } 47 48 public override IDeepCloneable Clone(Cloner cloner) { 49 return new Placeholder(this, cloner); 40 50 } 41 51 -
trunk/sources/HeuristicLab.Operators/3.3/ScopeCleaner.cs
r4477 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Parameters; … … 38 39 } 39 40 41 [StorableConstructor] 42 private ScopeCleaner(bool deserializing) : base(deserializing) { } 43 private ScopeCleaner(ScopeCleaner original, Cloner cloner) 44 : base(original, cloner) { 45 } 40 46 public ScopeCleaner() 41 47 : base() { 42 48 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope whose variables and sub-scopes should be removed.")); 49 } 50 51 public override IDeepCloneable Clone(Cloner cloner) { 52 return new ScopeCleaner(this, cloner); 43 53 } 44 54 -
trunk/sources/HeuristicLab.Operators/3.3/SingleSuccessorOperator.cs
r4477 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Parameters; … … 39 40 } 40 41 42 [StorableConstructor] 43 protected SingleSuccessorOperator(bool deserializing) : base(deserializing) { } 44 protected SingleSuccessorOperator(SingleSuccessorOperator original, Cloner cloner) 45 : base(original, cloner) { 46 } 41 47 public SingleSuccessorOperator() 42 48 : base() { 43 49 Parameters.Add(new OperatorParameter("Successor", "Operator which is executed next.")); 44 50 } 45 [StorableConstructor] 46 protected SingleSuccessorOperator(bool deserializing) : base(deserializing) { } 47 51 48 52 public override IOperation Apply() { 49 53 if (Successor != null) -
trunk/sources/HeuristicLab.Operators/3.3/StochasticBranch.cs
r4477 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Data; … … 53 54 } 54 55 56 [StorableConstructor] 57 protected StochasticBranch(bool deserializing) : base(deserializing) { } 58 protected StochasticBranch(StochasticBranch original, Cloner cloner) 59 : base(original, cloner) { 60 } 55 61 public StochasticBranch() 56 62 : base() { … … 59 65 Parameters.Add(new OperatorParameter("FirstBranch", "The operator which is executed with the given probability.")); 60 66 Parameters.Add(new OperatorParameter("SecondBranch", "The operator which is executed if the first branch is not executed.")); 67 } 68 69 public override IDeepCloneable Clone(Cloner cloner) { 70 return new StochasticBranch(this, cloner); 61 71 } 62 72 -
trunk/sources/HeuristicLab.Operators/3.3/StochasticMultiBranch.cs
r4477 r4722 24 24 using System.Linq; 25 25 using HeuristicLab.Collections; 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; 27 28 using HeuristicLab.Data; … … 56 57 [StorableConstructor] 57 58 protected StochasticMultiBranch(bool deserializing) : base(deserializing) { } 59 protected StochasticMultiBranch(StochasticMultiBranch<T> original, Cloner cloner) 60 : base(original, cloner) { 61 } 58 62 /// <summary> 59 63 /// Initializes a new instance of <see cref="StochasticMultiOperator"/> with two parameters … … 143 147 [StorableClass] 144 148 public class StochasticMultiBranch : StochasticMultiBranch<IOperator> { 149 [StorableConstructor] 150 protected StochasticMultiBranch(bool deserializing) : base(deserializing) { } 151 protected StochasticMultiBranch(StochasticMultiBranch original, Cloner cloner) 152 : base(original, cloner) { 153 } 154 public StochasticMultiBranch() { } 155 156 public override IDeepCloneable Clone(Cloner cloner) { 157 return new StochasticMultiBranch(this, cloner); 158 } 159 145 160 protected override bool CreateChildOperation { 146 161 get { return false; } -
trunk/sources/HeuristicLab.Operators/3.3/SubScopesCreator.cs
r4477 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Data; … … 42 43 } 43 44 45 [StorableConstructor] 46 protected SubScopesCreator(bool deserializing) : base(deserializing) { } 47 protected SubScopesCreator(SubScopesCreator original, Cloner cloner) 48 : base(original, cloner) { 49 } 44 50 public SubScopesCreator() 45 51 : base() { 46 52 Parameters.Add(new ValueLookupParameter<IntValue>("NumberOfSubScopes", "The number of new and empty sub-scopes which should be added to the current scope.")); 47 53 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope to which the new and empty sub-scopes are added.")); 54 } 55 56 public override IDeepCloneable Clone(Cloner cloner) { 57 return new SubScopesCreator(this, cloner); 48 58 } 49 59 -
trunk/sources/HeuristicLab.Operators/3.3/SubScopesMixer.cs
r4477 r4722 21 21 22 22 using System; 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; 24 25 using HeuristicLab.Data; … … 42 43 } 43 44 45 [StorableConstructor] 46 protected SubScopesMixer(bool deserializing) : base(deserializing) { } 47 protected SubScopesMixer(SubScopesMixer original, Cloner cloner) 48 : base(original, cloner) { 49 } 44 50 /// <summary> 45 51 /// Initializes a new instance of <see cref="SubScopesMixer"/> with one variable infos … … 49 55 : base() { 50 56 Parameters.Add(new ValueParameter<IntValue>("Partitions", "The number of equal-sized partitions.", new IntValue(2))); 57 } 58 59 public override IDeepCloneable Clone(Cloner cloner) { 60 return new SubScopesMixer(this, cloner); 51 61 } 52 62 -
trunk/sources/HeuristicLab.Operators/3.3/SubScopesProcessor.cs
r4477 r4722 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; 26 27 using HeuristicLab.Data; … … 51 52 } 52 53 54 [StorableConstructor] 55 private SubScopesProcessor(bool deserializing) : base(deserializing) { } 56 private SubScopesProcessor(SubScopesProcessor original, Cloner cloner) 57 : base(original, cloner) { 58 } 53 59 public SubScopesProcessor() 54 60 : base() { 55 61 Parameters.Add(new ValueLookupParameter<BoolValue>("Parallel", "True if the operators should be applied in parallel on the sub-scopes, otherwise false.", new BoolValue(false))); 56 62 Parameters.Add(new ValueParameter<IntValue>("Depth", "The number of steps to descend in the scope tree before applying operator.", new IntValue(1))); 63 } 64 65 public override IDeepCloneable Clone(Cloner cloner) { 66 return new SubScopesProcessor(this, cloner); 57 67 } 58 68 -
trunk/sources/HeuristicLab.Operators/3.3/SubScopesRemover.cs
r4477 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Data; … … 50 51 } 51 52 53 [StorableConstructor] 54 private SubScopesRemover(bool deserializing) : base(deserializing) { } 55 private SubScopesRemover(SubScopesRemover original, Cloner cloner) 56 : base(original, cloner) { 57 } 52 58 public SubScopesRemover() 53 59 : base() { … … 55 61 Parameters.Add(new ValueLookupParameter<IntValue>("SubScopeIndex", "The index of the sub-scope which should be removed. This parameter is ignored, if RemoveAllSubScopes is true.")); 56 62 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope from which one or all sub-scopes should be removed.")); 63 } 64 65 public override IDeepCloneable Clone(Cloner cloner) { 66 return new SubScopesRemover(this, cloner); 57 67 } 58 68 -
trunk/sources/HeuristicLab.Operators/3.3/SubScopesSorter.cs
r4068 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Data; … … 48 49 } 49 50 51 [StorableConstructor] 52 private SubScopesSorter(bool deserializing) : base(deserializing) { } 53 private SubScopesSorter(SubScopesSorter original, Cloner cloner) 54 : base(original, cloner) { 55 } 50 56 public SubScopesSorter() 51 57 : base() { … … 53 59 Parameters.Add(new ValueLookupParameter<BoolValue>("Descending", "True if the sub-scopes should be sorted in descending order, otherwise false.")); 54 60 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope whose sub-scopes are sorted.")); 61 } 62 63 public override IDeepCloneable Clone(Cloner cloner) { 64 return new SubScopesSorter(this, cloner); 55 65 } 56 66 -
trunk/sources/HeuristicLab.Operators/3.3/UniformSubScopesProcessor.cs
r4477 r4722 22 22 using System.Collections.Generic; 23 23 using System.Linq; 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; 25 26 using HeuristicLab.Data; … … 57 58 } 58 59 60 [StorableConstructor] 61 private UniformSubScopesProcessor(bool deserializing) : base(deserializing) { } 62 private UniformSubScopesProcessor(UniformSubScopesProcessor original, Cloner cloner) 63 : base(original, cloner) { 64 } 59 65 public UniformSubScopesProcessor() 60 66 : base() { … … 62 68 Parameters.Add(new ValueLookupParameter<BoolValue>("Parallel", "True if the operator should be applied in parallel on all sub-scopes, otherwise false.", new BoolValue(false))); 63 69 Parameters.Add(new ValueParameter<IntValue>("Depth", "The number of steps to descend in the scope tree before applying operator.", new IntValue(1))); 70 } 71 72 public override IDeepCloneable Clone(Cloner cloner) { 73 return new UniformSubScopesProcessor(this, cloner); 64 74 } 65 75 -
trunk/sources/HeuristicLab.Operators/3.3/ValuesCollector.cs
r3376 r4722 38 38 } 39 39 40 [StorableConstructor] 41 protected ValuesCollector(bool deserializing) : base(deserializing) { } 42 protected ValuesCollector(ValuesCollector original, Cloner cloner) 43 : base(original, cloner) { 44 this.collectedValues = cloner.Clone<ParameterCollection>(original.collectedValues); 45 Initialize(); 46 } 40 47 public ValuesCollector() 41 48 : base() { … … 43 50 Initialize(); 44 51 } 45 [StorableConstructor]46 protected ValuesCollector(bool deserializing) : base(deserializing) { }47 52 48 53 [StorableHook(HookType.AfterDeserialization)] 54 private void AfterDeserialization() { 55 Initialize(); 56 } 57 49 58 private void Initialize() { 50 59 collectedValues.ItemsAdded += new CollectionItemsChangedEventHandler<IParameter>(collectedValues_ItemsAdded); 51 60 collectedValues.ItemsRemoved += new CollectionItemsChangedEventHandler<IParameter>(collectedValues_ItemsRemoved); 52 61 collectedValues.CollectionReset += new CollectionItemsChangedEventHandler<IParameter>(collectedValues_CollectionReset); 53 }54 55 public override IDeepCloneable Clone(Cloner cloner) {56 ValuesCollector clone = (ValuesCollector)base.Clone(cloner);57 clone.collectedValues = (ParameterCollection)cloner.Clone(collectedValues);58 clone.Initialize();59 return clone;60 62 } 61 63 -
trunk/sources/HeuristicLab.Operators/3.3/VariableCreator.cs
r4477 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Parameters; … … 38 39 } 39 40 41 [StorableConstructor] 42 protected VariableCreator(bool deserializing) : base(deserializing) { } 43 protected VariableCreator(VariableCreator original, Cloner cloner) 44 : base(original, cloner) { 45 } 40 46 public VariableCreator() 41 47 : base() { 42 48 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope into which the parameter values are cloned.")); 49 } 50 51 public override IDeepCloneable Clone(Cloner cloner) { 52 return new VariableCreator(this, cloner); 43 53 } 44 54
Note: See TracChangeset
for help on using the changeset viewer.