Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/29/10 16:58:29 (14 years ago)
Author:
mkommend
Message:

Refactored Optimization (ticket #922).

Location:
branches/CloningRefactoring/HeuristicLab.Optimization/3.3
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • branches/CloningRefactoring/HeuristicLab.Optimization/3.3/Algorithm.cs

    r4437 r4665  
    165165      storeAlgorithmInEachRun = true;
    166166    }
    167 
    168167    [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
    169184    private void Initialize() {
    170185      if (problem != null) RegisterProblemEvents();
    171186      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       }
    201187    }
    202188
  • branches/CloningRefactoring/HeuristicLab.Optimization/3.3/BatchRun.cs

    r4533 r4665  
    167167      stopPending = false;
    168168    }
    169 
    170169    [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
    171190    private void Initialize() {
    172191      if (algorithm != null) RegisterAlgorithmEvents();
    173192      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;
    188193    }
    189194
  • branches/CloningRefactoring/HeuristicLab.Optimization/3.3/EngineAlgorithm.cs

    r3770 r4665  
    114114    [StorableConstructor]
    115115    protected EngineAlgorithm(bool deserializing) : base(deserializing) { }
    116 
    117116    [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
    118129    private void Initialize() {
    119130      operatorGraph.InitialOperatorChanged += new EventHandler(OperatorGraph_InitialOperatorChanged);
     
    127138    }
    128139
    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 
    148140    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());
    154142    }
    155143
     
    183171    public event EventHandler EngineChanged;
    184172    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);
    187175    }
    188176    public event EventHandler OperatorGraphChanged;
  • branches/CloningRefactoring/HeuristicLab.Optimization/3.3/Experiment.cs

    r4551 r4665  
    128128      stopPending = false;
    129129    }
    130 
    131130    [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
    132148    private void Initialize() {
    133149      RegisterOptimizersEvents();
     
    135151        RegisterOptimizerEvents(optimizer);
    136152      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;
    149153    }
    150154
  • branches/CloningRefactoring/HeuristicLab.Optimization/3.3/OptimizerList.cs

    r4419 r4665  
    3232    public OptimizerList(int capacity) : base(capacity) { }
    3333    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    }
    3442  }
    3543}
  • branches/CloningRefactoring/HeuristicLab.Optimization/3.3/Problem.cs

    r4597 r4665  
    4444    [StorableConstructor]
    4545    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
    4652    protected Problem()
    4753      : base() {
     
    5561    private void AfterDeserialization() {
    5662      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;
    6463    }
    6564
  • branches/CloningRefactoring/HeuristicLab.Optimization/3.3/Result.cs

    r4419 r4665  
    104104    [StorableConstructor]
    105105    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    }
    106118
    107     [StorableHook(HookType.AfterDeserialization)]
    108119    private void Initialize() {
    109120      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;
    118121    }
    119122
  • branches/CloningRefactoring/HeuristicLab.Optimization/3.3/ResultCollection.cs

    r4068 r4665  
    2121
    2222using System.Collections.Generic;
     23using HeuristicLab.Common;
    2324using HeuristicLab.Core;
    2425using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3132    public ResultCollection(int capacity) : base(capacity) { }
    3233    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    }
    3342  }
    3443}
  • branches/CloningRefactoring/HeuristicLab.Optimization/3.3/Run.cs

    r4419 r4665  
    3838    [StorableConstructor]
    3939    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
    4057    public Run()
    4158      : base() {
     
    8198    }
    8299    [StorableHook(HookType.AfterDeserialization)]
    83     private void AfterDeserializationHook() {
     100    private void AfterDeserialization() {
    84101      if (color == Color.Empty) color = Color.Black;
    85102    }
     
    128145        handler(this, EventArgs.Empty);
    129146    }
    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     }
    141147  }
    142148}
  • branches/CloningRefactoring/HeuristicLab.Optimization/3.3/RunCollection.cs

    r4518 r4665  
    3838    [StorableConstructor]
    3939    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    }
    4060    public RunCollection() : base() { Initialize(); }
    4161    public RunCollection(int capacity) : base(capacity) { Initialize(); }
     
    175195
    176196    [StorableHook(HookType.AfterDeserialization)]
    177     private void AfterDeserializationHook() {
     197    private void AfterDeserialization() {
    178198      if (constraints == null) constraints = new RunCollectionConstraintCollection();
    179199      RegisterConstraintsEvents();
    180200      RegisterConstraintEvents(constraints);
    181201      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;
    200202    }
    201203
     
    257259    public event EventHandler<EventArgs<int, int>> ItemChanged;
    258260    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));
    261263      OnToStringChanged();
    262264    }
    263265    public event EventHandler Reset;
    264266    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);
    267269      OnToStringChanged();
    268270    }
     
    270272    protected virtual void OnColumnNamesChanged() {
    271273      EventHandler handler = ColumnNamesChanged;
    272       if (handler != null)
    273         handler(this, EventArgs.Empty);
     274      if (handler != null) handler(this, EventArgs.Empty);
    274275    }
    275276    public event EventHandler RowNamesChanged;
    276277    protected virtual void OnRowNamesChanged() {
    277278      EventHandler handler = RowNamesChanged;
    278       if (handler != null)
    279         handler(this, EventArgs.Empty);
     279      if (handler != null) handler(this, EventArgs.Empty);
    280280    }
    281281    public event EventHandler SortableViewChanged;
    282282    protected virtual void OnSortableViewChanged() {
    283283      EventHandler handler = SortableViewChanged;
    284       if (handler != null)
    285         handler(this, EventArgs.Empty);
     284      if (handler != null) handler(this, EventArgs.Empty);
    286285    }
    287286
  • branches/CloningRefactoring/HeuristicLab.Optimization/3.3/RunCollectionConstraints/RunCollectionComparisonConstraint.cs

    r4157 r4665  
    3333    [StorableConstructor]
    3434    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    }
    3553
    3654    public RunCollectionComparisonConstraint() : base() { }
     
    128146      return s;
    129147    }
    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       else
    141         clone.ConstraintData = this.ConstraintData;
    142 
    143       clone.ConstraintOperation = this.ConstraintOperation;
    144       clone.constraintColumn = this.constraintColumn;
    145 
    146       return clone;
    147     }
    148148  }
    149149}
  • branches/CloningRefactoring/HeuristicLab.Optimization/3.3/RunCollectionConstraints/RunCollectionConstraintCollection.cs

    r4068 r4665  
    2020#endregion
    2121using System.Collections.Generic;
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3233    [StorableConstructor]
    3334    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    }
    3441  }
    3542}
  • branches/CloningRefactoring/HeuristicLab.Optimization/3.3/RunCollectionConstraints/RunCollectionEqualityConstraint.cs

    r4157 r4665  
    3333    [StorableConstructor]
    3434    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    }
    3545
    3646    public RunCollectionEqualityConstraint()
     
    127137      return s;
    128138    }
    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     }
    138139  }
    139140}
  • branches/CloningRefactoring/HeuristicLab.Optimization/3.3/RunCollectionConstraints/RunCollectionTypeCompatiblityConstraint.cs

    r4157 r4665  
    3131  [Item("RunCollectionTypeCompatibilityConstraint", "A constraint which checks the members of the contained runs for type compabitiliby to the constraint data.")]
    3232  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
    3346    public RunCollectionTypeCompatibilityConstraint()
    3447      : base() {
    35     }
    36     [StorableConstructor]
    37     protected RunCollectionTypeCompatibilityConstraint(bool deserializing) {
    3848    }
    3949    public RunCollectionTypeCompatibilityConstraint(RunCollection constrainedValue, ConstraintOperation constraintOperation, Type constraintData)
     
    120130      return s;
    121131    }
    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     }
    131132  }
    132133}
  • branches/CloningRefactoring/HeuristicLab.Optimization/3.3/SingleObjectiveProblem.cs

    r4596 r4665  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Data;
     
    3435    private const string BestKnownQualityParameterName = "BestKnownQuality";
    3536
     37    [StorableConstructor]
     38    protected SingleObjectiveProblem(bool deserializing) : base(deserializing) { }
     39    protected SingleObjectiveProblem(SingleObjectiveProblem<T, U> original, Cloner cloner)
     40      : base(original, cloner) {
     41    }
     42
    3643    protected SingleObjectiveProblem()
    3744      : base() {
     
    3946      Parameters.Add(new ValueParameter<DoubleValue>(BestKnownQualityParameterName, "The quality of the best known solution of this problem."));
    4047    }
    41     [StorableConstructor]
    42     protected SingleObjectiveProblem(bool deserializing) : base(deserializing) { }
     48
    4349
    4450    #region properties
  • branches/CloningRefactoring/HeuristicLab.Optimization/3.3/UserDefinedAlgorithm.cs

    r4437 r4665  
    5555    [StorableConstructor]
    5656    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    }
    5766  }
    5867}
  • branches/CloningRefactoring/HeuristicLab.Optimization/3.3/UserDefinedProblem.cs

    r4419 r4665  
    117117    [StorableConstructor]
    118118    private UserDefinedProblem(bool deserializing) : base(deserializing) { }
     119    [StorableHook(HookType.AfterDeserialization)]
     120    private void AfterDeserialization() {
     121      AttachEventHandlers();
     122    }
    119123    public UserDefinedProblem()
    120124      : base() {
     
    129133    }
    130134
     135    private UserDefinedProblem(UserDefinedProblem original, Cloner cloner)
     136      : base(original, cloner) {
     137      AttachEventHandlers();
     138    }
    131139    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);
    135141    }
    136142
     
    186192
    187193    #region Helpers
    188     [StorableHook(HookType.AfterDeserialization)]
    189194    private void AttachEventHandlers() {
    190195      SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);
     
    217222    [StorableClass]
    218223    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
    219234      #region ISingleObjectiveEvaluator Members
    220235
     
    231246      #region IOperator Members
    232247
    233       public bool Breakpoint {
    234         get;
    235         set;
    236       }
     248      public bool Breakpoint { get; set; }
    237249
    238250      public IOperation Execute(IExecutionContext context) {
     
    244256      }
    245257
    246       #pragma warning disable 67
     258#pragma warning disable 67
    247259      public event EventHandler BreakpointChanged;
    248260
    249261      public event EventHandler Executed;
    250       #pragma warning restore 67
     262#pragma warning restore 67
    251263
    252264      #endregion
     
    255267        get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Method; }
    256268      }
    257     } 
     269    }
    258270  }
    259271}
Note: See TracChangeset for help on using the changeset viewer.