Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/25/10 01:04:14 (14 years ago)
Author:
abeham
Message:

#1090

  • Fixed initialization of operators and made operator list storable
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/SupportVectorMachine/ParameterAdjustmentProblem/SupportVectorMachineParameterAdjustmentProblem.cs

    r4068 r4098  
    107107      set { BestKnownQualityParameter.Value = value; }
    108108    }
    109     private List<IOperator> operators;
    110109    public override IEnumerable<IOperator> Operators {
    111110      get { return operators; }
     
    120119    }
    121120
     121    [Storable]
     122    private List<IOperator> operators;
    122123    [Storable]
    123124    private StdDevStrategyVectorCreator strategyVectorCreator;
     
    160161      ParameterizeEvaluator();
    161162
    162       Initialize();
     163      InitializeOperators();
     164      AttachEventHandlers();
    163165      UpdateStrategyVectorBounds();
    164166    }
     
    166168    public override IDeepCloneable Clone(Cloner cloner) {
    167169      SupportVectorMachineParameterAdjustmentProblem clone = (SupportVectorMachineParameterAdjustmentProblem)base.Clone(cloner);
     170      clone.operators = operators.Where(x => IsNotFieldReferenced(x)).Select(x => (IOperator)cloner.Clone(x)).ToList();
    168171      clone.strategyVectorCreator = (StdDevStrategyVectorCreator)cloner.Clone(strategyVectorCreator);
     172      clone.operators.Add(clone.strategyVectorCreator);
    169173      clone.strategyVectorCrossover = (StdDevStrategyVectorCrossover)cloner.Clone(strategyVectorCrossover);
     174      clone.operators.Add(strategyVectorCrossover);
    170175      clone.strategyVectorManipulator = (StdDevStrategyVectorManipulator)cloner.Clone(strategyVectorManipulator);
    171       clone.Initialize();
     176      clone.operators.Add(strategyVectorManipulator);
     177      clone.AttachEventHandlers();
    172178      return clone;
     179    }
     180
     181    private bool IsNotFieldReferenced(IOperator x) {
     182      return !(x == strategyVectorCreator
     183        || x == strategyVectorCrossover
     184        || x == strategyVectorManipulator);
    173185    }
    174186
     
    204216    #region Helpers
    205217    [StorableHook(HookType.AfterDeserialization)]
    206     private void Initialize() {
    207       InitializeOperators();
     218    private void AttachEventHandlers() {
     219      // Start BackwardsCompatibility3.3 (remove with 3.4)
     220      if (operators == null) InitializeOperators();
     221      // End BackwardsCompatibility3.3
    208222      SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);
    209223      SolutionCreator.RealVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_RealVectorParameter_ActualNameChanged);
Note: See TracChangeset for help on using the changeset viewer.