Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/23/09 16:43:34 (14 years ago)
Author:
swagner
Message:

Refactored cloning (#806)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.SGA/3.3/SGA.cs

    r2520 r2526  
    462462      set {
    463463        value.Name = "ProblemInjector";
    464         mySGA.OperatorGraph.RemoveOperator(ProblemInjector.Guid);
     464        mySGA.OperatorGraph.RemoveOperator(ProblemInjector);
    465465        mySGA.OperatorGraph.AddOperator(value);
    466466        myVariableInjection.AddSubOperator(value, 0);
     
    477477      set {
    478478        value.Name = "SolutionGenerator";
    479         mySGA.OperatorGraph.RemoveOperator(SolutionGenerator.Guid);
     479        mySGA.OperatorGraph.RemoveOperator(SolutionGenerator);
    480480        mySGA.OperatorGraph.AddOperator(value);
    481481        myPopulationInitialization.AddSubOperator(value, 0);
     
    490490      set {
    491491        value.Name = "Evaluator";
    492         mySGA.OperatorGraph.RemoveOperator(Evaluator.Guid);
     492        mySGA.OperatorGraph.RemoveOperator(Evaluator);
    493493        mySGA.OperatorGraph.AddOperator(value);
    494494        myPopulationInitialization.AddSubOperator(value, 1);
     
    507507      set {
    508508        value.Name = "Selector";
    509         mySGA.OperatorGraph.RemoveOperator(Selector.Guid);
     509        mySGA.OperatorGraph.RemoveOperator(Selector);
    510510        mySGA.OperatorGraph.AddOperator(value);
    511511        mySGAMain.AddSubOperator(value, 0);
     
    520520      set {
    521521        value.Name = "Crossover";
    522         mySGA.OperatorGraph.RemoveOperator(Crossover.Guid);
     522        mySGA.OperatorGraph.RemoveOperator(Crossover);
    523523        mySGA.OperatorGraph.AddOperator(value);
    524524        mySGAMain.AddSubOperator(value, 1);
     
    533533      set {
    534534        value.Name = "Mutator";
    535         mySGA.OperatorGraph.RemoveOperator(Mutator.Guid);
     535        mySGA.OperatorGraph.RemoveOperator(Mutator);
    536536        mySGA.OperatorGraph.AddOperator(value);
    537537        mySGAMain.AddSubOperator(value, 2);
     
    552552    /// Clones the current instance (deep clone).
    553553    /// </summary>
    554     /// <remarks>Deep clone through <see cref="Auxiliary.Clone"/> method of helper class
     554    /// <remarks>Deep clone through <see cref="cloner.Clone"/> method of helper class
    555555    /// <see cref="Auxiliary"/>.</remarks>
    556556    /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param>
    557557    /// <returns>The cloned object as <see cref="SGA"/>.</returns>
    558     public override object Clone(IDictionary<Guid, object> clonedObjects) {
     558    public override IItem Clone(ICloner cloner) {
    559559      SGA clone = new SGA();
    560       clonedObjects.Add(Guid, clone);
    561       clone.myEngine = (IEngine)Auxiliary.Clone(Engine, clonedObjects);
     560      cloner.RegisterClonedObject(this, clone);
     561      clone.myEngine = (IEngine)cloner.Clone(Engine);
    562562      return clone;
    563563    }
Note: See TracChangeset for help on using the changeset viewer.