Changeset 4665
- Timestamp:
- 10/29/10 16:58:29 (14 years ago)
- Location:
- branches/CloningRefactoring/HeuristicLab.Optimization/3.3
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CloningRefactoring/HeuristicLab.Optimization/3.3/Algorithm.cs
r4437 r4665 165 165 storeAlgorithmInEachRun = true; 166 166 } 167 168 167 [StorableHook(HookType.AfterDeserialization)] 168 private void AfterDeserialization() { 169 Initialize(); 170 } 171 172 protected Algorithm(Algorithm original, Cloner cloner) 173 : base(original, cloner) { 174 if (ExecutionState == ExecutionState.Started) throw new InvalidOperationException(string.Format("Clone not allowed in execution state \"{0}\".", ExecutionState)); 175 executionState = original.executionState; 176 executionTime = original.executionTime; 177 problem = cloner.Clone(original.problem); 178 storeAlgorithmInEachRun = original.storeAlgorithmInEachRun; 179 runsCounter = original.runsCounter; 180 runs = cloner.Clone(original.runs); 181 Initialize(); 182 } 183 169 184 private void Initialize() { 170 185 if (problem != null) RegisterProblemEvents(); 171 186 if (runs != null) RegisterRunsEvents(); 172 }173 174 public override IDeepCloneable Clone(Cloner cloner) {175 if (ExecutionState == ExecutionState.Started) throw new InvalidOperationException(string.Format("Clone not allowed in execution state \"{0}\".", ExecutionState));176 Algorithm clone = (Algorithm)base.Clone(cloner);177 clone.executionState = executionState;178 clone.executionTime = executionTime;179 clone.problem = (IProblem)cloner.Clone(problem);180 clone.storeAlgorithmInEachRun = storeAlgorithmInEachRun;181 clone.runsCounter = runsCounter;182 clone.runs = (RunCollection)cloner.Clone(runs);183 clone.Initialize();184 return clone;185 }186 protected virtual void Clone(IDeepCloneable clone, Cloner cloner) {187 Algorithm algorithm = clone as Algorithm;188 if (algorithm != null) {189 algorithm.name = name;190 algorithm.description = description;191 foreach (IParameter param in Parameters)192 algorithm.Parameters.Add((IParameter)cloner.Clone(param));193 algorithm.executionState = executionState;194 algorithm.executionTime = executionTime;195 algorithm.problem = (IProblem)cloner.Clone(problem);196 algorithm.storeAlgorithmInEachRun = storeAlgorithmInEachRun;197 algorithm.runsCounter = runsCounter;198 algorithm.runs = (RunCollection)cloner.Clone(runs);199 algorithm.Initialize();200 }201 187 } 202 188 -
branches/CloningRefactoring/HeuristicLab.Optimization/3.3/BatchRun.cs
r4533 r4665 167 167 stopPending = false; 168 168 } 169 170 169 [StorableHook(HookType.AfterDeserialization)] 170 private void AfterDeserialization() { 171 Initialize(); 172 } 173 174 protected BatchRun(BatchRun original, Cloner cloner) 175 : base(original, cloner) { 176 executionState = original.executionState; 177 executionTime = original.executionTime; 178 algorithm = cloner.Clone(original.algorithm); 179 repetitions = original.repetitions; 180 repetitionsCounter = original.repetitionsCounter; 181 runs = cloner.Clone(original.runs); 182 stopPending = original.stopPending; 183 Initialize(); 184 } 185 public override IDeepCloneable Clone(Cloner cloner) { 186 if (ExecutionState == ExecutionState.Started) throw new InvalidOperationException(string.Format("Clone not allowed in execution state \"{0}\".", ExecutionState)); 187 return new BatchRun(this, cloner); 188 } 189 171 190 private void Initialize() { 172 191 if (algorithm != null) RegisterAlgorithmEvents(); 173 192 if (runs != null) RegisterRunsEvents(); 174 }175 176 public override IDeepCloneable Clone(Cloner cloner) {177 if (ExecutionState == ExecutionState.Started) throw new InvalidOperationException(string.Format("Clone not allowed in execution state \"{0}\".", ExecutionState));178 BatchRun clone = (BatchRun)base.Clone(cloner);179 clone.executionState = executionState;180 clone.executionTime = executionTime;181 clone.algorithm = (IAlgorithm)cloner.Clone(algorithm);182 clone.repetitions = repetitions;183 clone.repetitionsCounter = repetitionsCounter;184 clone.runs = (RunCollection)cloner.Clone(runs);185 clone.stopPending = stopPending;186 clone.Initialize();187 return clone;188 193 } 189 194 -
branches/CloningRefactoring/HeuristicLab.Optimization/3.3/EngineAlgorithm.cs
r3770 r4665 114 114 [StorableConstructor] 115 115 protected EngineAlgorithm(bool deserializing) : base(deserializing) { } 116 117 116 [StorableHook(HookType.AfterDeserialization)] 117 private void AfterDeserialization() { 118 Initialize(); 119 } 120 121 protected EngineAlgorithm(EngineAlgorithm original, Cloner cloner) 122 : base(original, cloner) { 123 globalScope = cloner.Clone(original.globalScope); 124 engine = cloner.Clone(original.engine); 125 operatorGraph = cloner.Clone(original.operatorGraph); 126 Initialize(); 127 } 128 118 129 private void Initialize() { 119 130 operatorGraph.InitialOperatorChanged += new EventHandler(OperatorGraph_InitialOperatorChanged); … … 127 138 } 128 139 129 public override IDeepCloneable Clone(Cloner cloner) {130 EngineAlgorithm clone = (EngineAlgorithm)base.Clone(cloner);131 clone.globalScope = (IScope)cloner.Clone(globalScope);132 clone.engine = (IEngine)cloner.Clone(engine);133 clone.operatorGraph = (OperatorGraph)cloner.Clone(operatorGraph);134 clone.Initialize();135 return clone;136 }137 protected override void Clone(IDeepCloneable clone, Cloner cloner) {138 base.Clone(clone, cloner);139 EngineAlgorithm algorithm = clone as EngineAlgorithm;140 if (algorithm != null) {141 algorithm.globalScope = (IScope)cloner.Clone(globalScope);142 algorithm.engine = (IEngine)cloner.Clone(engine);143 algorithm.operatorGraph = (OperatorGraph)cloner.Clone(operatorGraph);144 algorithm.Initialize();145 }146 }147 148 140 public virtual IAlgorithm CreateUserDefinedAlgorithm() { 149 UserDefinedAlgorithm algorithm = new UserDefinedAlgorithm(); 150 Cloner cloner = new Cloner(); 151 cloner.RegisterClonedObject(this, algorithm); 152 Clone(algorithm, cloner); 153 return algorithm; 141 return new UserDefinedAlgorithm(this, new Cloner()); 154 142 } 155 143 … … 183 171 public event EventHandler EngineChanged; 184 172 protected virtual void OnEngineChanged() { 185 if (EngineChanged != null)186 EngineChanged(this, EventArgs.Empty);173 EventHandler handler = EngineChanged; 174 if (handler != null) handler(this, EventArgs.Empty); 187 175 } 188 176 public event EventHandler OperatorGraphChanged; -
branches/CloningRefactoring/HeuristicLab.Optimization/3.3/Experiment.cs
r4551 r4665 128 128 stopPending = false; 129 129 } 130 131 130 [StorableHook(HookType.AfterDeserialization)] 131 private void AfterDeserialization() { 132 Initialize(); 133 } 134 protected Experiment(Experiment original, Cloner cloner) 135 : base(original, cloner) { 136 executionState = original.executionState; 137 executionTime = original.executionTime; 138 optimizers = cloner.Clone(original.optimizers); 139 runs = cloner.Clone(original.runs); 140 stopPending = original.stopPending; 141 Initialize(); 142 } 143 public override IDeepCloneable Clone(Cloner cloner) { 144 if (ExecutionState == ExecutionState.Started) throw new InvalidOperationException(string.Format("Clone not allowed in execution state \"{0}\".", ExecutionState)); 145 return new Experiment(this, cloner); 146 } 147 132 148 private void Initialize() { 133 149 RegisterOptimizersEvents(); … … 135 151 RegisterOptimizerEvents(optimizer); 136 152 if (runs != null) RegisterRunsEvents(); 137 }138 139 public override IDeepCloneable Clone(Cloner cloner) {140 if (ExecutionState == ExecutionState.Started) throw new InvalidOperationException(string.Format("Clone not allowed in execution state \"{0}\".", ExecutionState));141 Experiment clone = (Experiment)base.Clone(cloner);142 clone.executionState = executionState;143 clone.executionTime = executionTime;144 clone.optimizers = (OptimizerList)cloner.Clone(optimizers);145 clone.runs = (RunCollection)cloner.Clone(runs);146 clone.stopPending = stopPending;147 clone.Initialize();148 return clone;149 153 } 150 154 -
branches/CloningRefactoring/HeuristicLab.Optimization/3.3/OptimizerList.cs
r4419 r4665 32 32 public OptimizerList(int capacity) : base(capacity) { } 33 33 public OptimizerList(IEnumerable<IOptimizer> collection) : base(collection) { } 34 [StorableConstructor] 35 protected OptimizerList(bool deserializing) : base(deserializing) { } 36 protected OptimizerList(OptimizerList original, Cloner cloner) 37 : base(original, cloner) { 38 } 39 public override IDeepCloneable Clone(Cloner cloner) { 40 return new OptimizerList(this, cloner); 41 } 34 42 } 35 43 } -
branches/CloningRefactoring/HeuristicLab.Optimization/3.3/Problem.cs
r4597 r4665 44 44 [StorableConstructor] 45 45 protected Problem(bool deserializing) : base(deserializing) { } 46 protected Problem(Problem<T, U> original, Cloner cloner) 47 : base(original, cloner) { 48 operators = cloner.Clone(original.operators); 49 RegisterEventHandlers(); 50 } 51 46 52 protected Problem() 47 53 : base() { … … 55 61 private void AfterDeserialization() { 56 62 RegisterEventHandlers(); 57 }58 59 public override IDeepCloneable Clone(Cloner cloner) {60 Problem<T, U> clone = (Problem<T, U>)base.Clone(cloner);61 clone.operators = (OperatorCollection)cloner.Clone(operators);62 clone.RegisterEventHandlers();63 return clone;64 63 } 65 64 -
branches/CloningRefactoring/HeuristicLab.Optimization/3.3/Result.cs
r4419 r4665 104 104 [StorableConstructor] 105 105 private Result(bool deserializing) : base(deserializing) { } 106 [StorableHook(HookType.AfterDeserialization)] 107 private void AfterDeserialization() { 108 Initialize(); 109 } 110 protected Result(Result original, Cloner cloner) 111 : base(original, cloner) { 112 value = cloner.Clone(original.value); 113 Initialize(); 114 } 115 public override IDeepCloneable Clone(Cloner cloner) { 116 return new Result(this, cloner); 117 } 106 118 107 [StorableHook(HookType.AfterDeserialization)]108 119 private void Initialize() { 109 120 RegisterValueEvents(); 110 }111 112 public override IDeepCloneable Clone(Cloner cloner) {113 Result clone = new Result(Name, Description, DataType);114 cloner.RegisterClonedObject(this, clone);115 clone.value = (IItem)cloner.Clone(value);116 clone.Initialize();117 return clone;118 121 } 119 122 -
branches/CloningRefactoring/HeuristicLab.Optimization/3.3/ResultCollection.cs
r4068 r4665 21 21 22 22 using System.Collections.Generic; 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; 24 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 31 32 public ResultCollection(int capacity) : base(capacity) { } 32 33 public ResultCollection(IEnumerable<IResult> collection) : base(collection) { } 34 [StorableConstructor] 35 protected ResultCollection(bool deserializing) : base(deserializing) { } 36 protected ResultCollection(ResultCollection original, Cloner cloner) 37 : base(original, cloner) { 38 } 39 public override IDeepCloneable Clone(Cloner cloner) { 40 return new ResultCollection(this, cloner); 41 } 33 42 } 34 43 } -
branches/CloningRefactoring/HeuristicLab.Optimization/3.3/Run.cs
r4419 r4665 38 38 [StorableConstructor] 39 39 private Run(bool deserializing) : base(deserializing) { } 40 protected Run(Run original, Cloner cloner) 41 : base(original, cloner) { 42 color = original.color; 43 algorithm = cloner.Clone(original.algorithm); 44 45 parameters = new Dictionary<string, IItem>(); 46 foreach (string key in original.parameters.Keys) 47 parameters.Add(key, cloner.Clone(original.parameters[key])); 48 49 results = new Dictionary<string, IItem>(); 50 foreach (string key in original.results.Keys) 51 results.Add(key, cloner.Clone(original.results[key])); 52 } 53 public override IDeepCloneable Clone(Cloner cloner) { 54 return new Run(this, cloner); 55 } 56 40 57 public Run() 41 58 : base() { … … 81 98 } 82 99 [StorableHook(HookType.AfterDeserialization)] 83 private void AfterDeserialization Hook() {100 private void AfterDeserialization() { 84 101 if (color == Color.Empty) color = Color.Black; 85 102 } … … 128 145 handler(this, EventArgs.Empty); 129 146 } 130 131 public override IDeepCloneable Clone(Cloner cloner) {132 Run clone = (Run)base.Clone(cloner);133 clone.color = this.color;134 clone.algorithm = (IAlgorithm)cloner.Clone(algorithm);135 foreach (string key in parameters.Keys)136 clone.parameters.Add(key, (IItem)cloner.Clone(parameters[key]));137 foreach (string key in results.Keys)138 clone.results.Add(key, (IItem)cloner.Clone(results[key]));139 return clone;140 }141 147 } 142 148 } -
branches/CloningRefactoring/HeuristicLab.Optimization/3.3/RunCollection.cs
r4518 r4665 38 38 [StorableConstructor] 39 39 protected RunCollection(bool deserializing) : base(deserializing) { } 40 41 protected RunCollection(RunCollection original, Cloner cloner) 42 : base(original, cloner) { 43 resultNames = new List<string>(original.resultNames); 44 parameterNames = new List<string>(original.parameterNames); 45 dataTypes = new Dictionary<string, HashSet<Type>>(); 46 foreach (string s in original.dataTypes.Keys) 47 dataTypes[s] = new HashSet<Type>(original.dataTypes[s]); 48 49 constraints = new RunCollectionConstraintCollection(original.constraints.Select(x => cloner.Clone(x))); 50 foreach (IRunCollectionConstraint constraint in constraints) 51 constraint.ConstrainedValue = this; 52 RegisterConstraintsEvents(); 53 RegisterConstraintEvents(constraints); 54 55 UpdateFiltering(true); 56 } 57 public override IDeepCloneable Clone(Cloner cloner) { 58 return new RunCollection(this, cloner); 59 } 40 60 public RunCollection() : base() { Initialize(); } 41 61 public RunCollection(int capacity) : base(capacity) { Initialize(); } … … 175 195 176 196 [StorableHook(HookType.AfterDeserialization)] 177 private void AfterDeserialization Hook() {197 private void AfterDeserialization() { 178 198 if (constraints == null) constraints = new RunCollectionConstraintCollection(); 179 199 RegisterConstraintsEvents(); 180 200 RegisterConstraintEvents(constraints); 181 201 UpdateFiltering(true); 182 }183 184 public override IDeepCloneable Clone(Cloner cloner) {185 RunCollection clone = (RunCollection)base.Clone(cloner);186 clone.resultNames = new List<string>(this.resultNames);187 clone.parameterNames = new List<string>(this.parameterNames);188 clone.dataTypes = new Dictionary<string, HashSet<Type>>();189 foreach (string s in this.dataTypes.Keys)190 clone.dataTypes[s] = new HashSet<Type>(this.dataTypes[s]);191 192 clone.constraints = new RunCollectionConstraintCollection(this.constraints.Select(x => (IRunCollectionConstraint)cloner.Clone(x)));193 foreach (IRunCollectionConstraint constraint in clone.constraints)194 constraint.ConstrainedValue = clone;195 clone.RegisterConstraintsEvents();196 clone.RegisterConstraintEvents(clone.constraints);197 198 clone.UpdateFiltering(true);199 return clone;200 202 } 201 203 … … 257 259 public event EventHandler<EventArgs<int, int>> ItemChanged; 258 260 protected virtual void OnItemChanged(int rowIndex, int columnIndex) { 259 if (ItemChanged != null)260 ItemChanged(this, new EventArgs<int, int>(rowIndex, columnIndex));261 EventHandler<EventArgs<int, int>> handler = ItemChanged; 262 if (handler != null) handler(this, new EventArgs<int, int>(rowIndex, columnIndex)); 261 263 OnToStringChanged(); 262 264 } 263 265 public event EventHandler Reset; 264 266 protected virtual void OnReset() { 265 if (Reset != null)266 Reset(this, EventArgs.Empty);267 EventHandler handler = Reset; 268 if (handler != null) handler(this, EventArgs.Empty); 267 269 OnToStringChanged(); 268 270 } … … 270 272 protected virtual void OnColumnNamesChanged() { 271 273 EventHandler handler = ColumnNamesChanged; 272 if (handler != null) 273 handler(this, EventArgs.Empty); 274 if (handler != null) handler(this, EventArgs.Empty); 274 275 } 275 276 public event EventHandler RowNamesChanged; 276 277 protected virtual void OnRowNamesChanged() { 277 278 EventHandler handler = RowNamesChanged; 278 if (handler != null) 279 handler(this, EventArgs.Empty); 279 if (handler != null) handler(this, EventArgs.Empty); 280 280 } 281 281 public event EventHandler SortableViewChanged; 282 282 protected virtual void OnSortableViewChanged() { 283 283 EventHandler handler = SortableViewChanged; 284 if (handler != null) 285 handler(this, EventArgs.Empty); 284 if (handler != null) handler(this, EventArgs.Empty); 286 285 } 287 286 -
branches/CloningRefactoring/HeuristicLab.Optimization/3.3/RunCollectionConstraints/RunCollectionComparisonConstraint.cs
r4157 r4665 33 33 [StorableConstructor] 34 34 protected RunCollectionComparisonConstraint(bool deserializing) : base(deserializing) { } 35 36 protected RunCollectionComparisonConstraint(RunCollectionComparisonConstraint original, Cloner cloner) 37 : base(original, cloner) { 38 IDeepCloneable constraintDataDeepCloneable = original.ConstraintData as IDeepCloneable; 39 ICloneable constraintDataCloneable = original.ConstraintData as ICloneable; 40 if (constraintDataDeepCloneable != null) 41 ConstraintData = (IStringConvertibleValue)cloner.Clone(constraintDataDeepCloneable); 42 else if (constraintDataCloneable != null) 43 ConstraintData = (IStringConvertibleValue)constraintDataCloneable.Clone(); 44 else 45 ConstraintData = original.ConstraintData; 46 47 ConstraintOperation = original.ConstraintOperation; 48 ConstraintColumn = original.constraintColumn; 49 } 50 public override IDeepCloneable Clone(Cloner cloner) { 51 return new RunCollectionComparisonConstraint(this, cloner); 52 } 35 53 36 54 public RunCollectionComparisonConstraint() : base() { } … … 128 146 return s; 129 147 } 130 131 public override IDeepCloneable Clone(HeuristicLab.Common.Cloner cloner) {132 RunCollectionComparisonConstraint clone = (RunCollectionComparisonConstraint)base.Clone(cloner);133 134 IItem constraintDataItem = this.ConstraintData as IItem;135 ICloneable constraintDataCloneable = this.ConstraintData as ICloneable;136 if (constraintDataItem != null)137 clone.ConstraintData = (IStringConvertibleValue)cloner.Clone(constraintDataItem);138 else if (constraintDataCloneable != null)139 clone.ConstraintData = (IStringConvertibleValue)constraintDataCloneable.Clone();140 else141 clone.ConstraintData = this.ConstraintData;142 143 clone.ConstraintOperation = this.ConstraintOperation;144 clone.constraintColumn = this.constraintColumn;145 146 return clone;147 }148 148 } 149 149 } -
branches/CloningRefactoring/HeuristicLab.Optimization/3.3/RunCollectionConstraints/RunCollectionConstraintCollection.cs
r4068 r4665 20 20 #endregion 21 21 using System.Collections.Generic; 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 32 33 [StorableConstructor] 33 34 protected RunCollectionConstraintCollection(bool deserializing) : base(deserializing) { } 35 protected RunCollectionConstraintCollection(RunCollectionConstraintCollection original, Cloner cloner) 36 : base(original, cloner) { 37 } 38 public override IDeepCloneable Clone(Cloner cloner) { 39 return new RunCollectionConstraintCollection(this, cloner); 40 } 34 41 } 35 42 } -
branches/CloningRefactoring/HeuristicLab.Optimization/3.3/RunCollectionConstraints/RunCollectionEqualityConstraint.cs
r4157 r4665 33 33 [StorableConstructor] 34 34 protected RunCollectionEqualityConstraint(bool deserializing) : base(deserializing) { } 35 36 protected RunCollectionEqualityConstraint(RunCollectionEqualityConstraint original, Cloner cloner) 37 : base(original, cloner) { 38 ConstraintData = original.ConstraintData; 39 ConstraintOperation = original.ConstraintOperation; 40 constraintColumn = original.constraintColumn; 41 } 42 public override IDeepCloneable Clone(Cloner cloner) { 43 return new RunCollectionEqualityConstraint(this, cloner); 44 } 35 45 36 46 public RunCollectionEqualityConstraint() … … 127 137 return s; 128 138 } 129 130 public override IDeepCloneable Clone(HeuristicLab.Common.Cloner cloner) {131 RunCollectionEqualityConstraint clone = (RunCollectionEqualityConstraint)base.Clone(cloner);132 clone.ConstraintData = this.ConstraintData;133 clone.ConstraintOperation = this.ConstraintOperation;134 clone.constraintColumn = this.constraintColumn;135 136 return clone;137 }138 139 } 139 140 } -
branches/CloningRefactoring/HeuristicLab.Optimization/3.3/RunCollectionConstraints/RunCollectionTypeCompatiblityConstraint.cs
r4157 r4665 31 31 [Item("RunCollectionTypeCompatibilityConstraint", "A constraint which checks the members of the contained runs for type compabitiliby to the constraint data.")] 32 32 public class RunCollectionTypeCompatibilityConstraint : TypeCompatibilityConstraint, IRunCollectionConstraint { 33 [StorableConstructor] 34 protected RunCollectionTypeCompatibilityConstraint(bool deserializing) { 35 } 36 protected RunCollectionTypeCompatibilityConstraint(RunCollectionTypeCompatibilityConstraint original, Cloner cloner) 37 : base(original, cloner) { 38 ConstraintData = original.ConstraintData; 39 ConstraintOperation = original.ConstraintOperation; 40 constraintColumn = original.constraintColumn; 41 } 42 public override IDeepCloneable Clone(Cloner cloner) { 43 return new RunCollectionTypeCompatibilityConstraint(this, cloner); 44 } 45 33 46 public RunCollectionTypeCompatibilityConstraint() 34 47 : base() { 35 }36 [StorableConstructor]37 protected RunCollectionTypeCompatibilityConstraint(bool deserializing) {38 48 } 39 49 public RunCollectionTypeCompatibilityConstraint(RunCollection constrainedValue, ConstraintOperation constraintOperation, Type constraintData) … … 120 130 return s; 121 131 } 122 123 public override IDeepCloneable Clone(HeuristicLab.Common.Cloner cloner) {124 RunCollectionTypeCompatibilityConstraint clone = (RunCollectionTypeCompatibilityConstraint)base.Clone(cloner);125 clone.ConstraintData = this.ConstraintData;126 clone.ConstraintOperation = this.ConstraintOperation;127 clone.constraintColumn = this.constraintColumn;128 129 return clone;130 }131 132 } 132 133 } -
branches/CloningRefactoring/HeuristicLab.Optimization/3.3/SingleObjectiveProblem.cs
r4596 r4665 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Data; … … 34 35 private const string BestKnownQualityParameterName = "BestKnownQuality"; 35 36 37 [StorableConstructor] 38 protected SingleObjectiveProblem(bool deserializing) : base(deserializing) { } 39 protected SingleObjectiveProblem(SingleObjectiveProblem<T, U> original, Cloner cloner) 40 : base(original, cloner) { 41 } 42 36 43 protected SingleObjectiveProblem() 37 44 : base() { … … 39 46 Parameters.Add(new ValueParameter<DoubleValue>(BestKnownQualityParameterName, "The quality of the best known solution of this problem.")); 40 47 } 41 [StorableConstructor] 42 protected SingleObjectiveProblem(bool deserializing) : base(deserializing) { } 48 43 49 44 50 #region properties -
branches/CloningRefactoring/HeuristicLab.Optimization/3.3/UserDefinedAlgorithm.cs
r4437 r4665 55 55 [StorableConstructor] 56 56 private UserDefinedAlgorithm(bool deserializing) : base(deserializing) { } 57 private UserDefinedAlgorithm(UserDefinedAlgorithm original, Cloner cloner) 58 : base(original, cloner) { 59 } 60 private UserDefinedAlgorithm(EngineAlgorithm original, Cloner cloner) 61 : base(original, cloner) { 62 } 63 public override IDeepCloneable Clone(Cloner cloner) { 64 return new UserDefinedAlgorithm(this, cloner); 65 } 57 66 } 58 67 } -
branches/CloningRefactoring/HeuristicLab.Optimization/3.3/UserDefinedProblem.cs
r4419 r4665 117 117 [StorableConstructor] 118 118 private UserDefinedProblem(bool deserializing) : base(deserializing) { } 119 [StorableHook(HookType.AfterDeserialization)] 120 private void AfterDeserialization() { 121 AttachEventHandlers(); 122 } 119 123 public UserDefinedProblem() 120 124 : base() { … … 129 133 } 130 134 135 private UserDefinedProblem(UserDefinedProblem original, Cloner cloner) 136 : base(original, cloner) { 137 AttachEventHandlers(); 138 } 131 139 public override IDeepCloneable Clone(Cloner cloner) { 132 UserDefinedProblem clone = (UserDefinedProblem)base.Clone(cloner); 133 clone.AttachEventHandlers(); 134 return clone; 140 return new UserDefinedProblem(this, cloner); 135 141 } 136 142 … … 186 192 187 193 #region Helpers 188 [StorableHook(HookType.AfterDeserialization)]189 194 private void AttachEventHandlers() { 190 195 SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged); … … 217 222 [StorableClass] 218 223 private class EmptyUserDefinedProblemEvaluator : ParameterizedNamedItem, ISingleObjectiveEvaluator { 224 public EmptyUserDefinedProblemEvaluator() : base() { } 225 [StorableConstructor] 226 private EmptyUserDefinedProblemEvaluator(bool deserializing) : base(deserializing) { } 227 private EmptyUserDefinedProblemEvaluator(EmptyUserDefinedProblemEvaluator original, Cloner cloner) 228 : base(original, cloner) { 229 } 230 public override IDeepCloneable Clone(Cloner cloner) { 231 return new EmptyUserDefinedProblemEvaluator(this, cloner); 232 } 233 219 234 #region ISingleObjectiveEvaluator Members 220 235 … … 231 246 #region IOperator Members 232 247 233 public bool Breakpoint { 234 get; 235 set; 236 } 248 public bool Breakpoint { get; set; } 237 249 238 250 public IOperation Execute(IExecutionContext context) { … … 244 256 } 245 257 246 258 #pragma warning disable 67 247 259 public event EventHandler BreakpointChanged; 248 260 249 261 public event EventHandler Executed; 250 262 #pragma warning restore 67 251 263 252 264 #endregion … … 255 267 get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Method; } 256 268 } 257 } 269 } 258 270 } 259 271 }
Note: See TracChangeset
for help on using the changeset viewer.