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.OneMax/3.3/OnemaxProblem.cs

    r3797 r4098  
    9797      get { return BestKnownQualityParameter.Value; }
    9898    }
    99     private List<IOperator> operators;
    10099    public IEnumerable<IOperator> Operators {
    101100      get { return operators.Cast<IOperator>(); }
     
    106105    #endregion
    107106
     107    [Storable]
     108    private List<IOperator> operators;
     109
     110    [StorableConstructor]
     111    private OneMaxProblem(bool deserializing) : base() { }
    108112    public OneMaxProblem()
    109113      : base() {
     
    122126      ParameterizeEvaluator();
    123127
    124       Initialize();
    125     }
    126 
    127     [StorableConstructor]
    128     private OneMaxProblem(bool deserializing) : base() { }
     128      InitializeOperators();
     129      AttachEventHandlers();
     130    }
    129131
    130132    public override IDeepCloneable Clone(Cloner cloner) {
    131133      OneMaxProblem clone = (OneMaxProblem)base.Clone(cloner);
    132       clone.Initialize();
     134      clone.operators = operators.Select(x => (IOperator)cloner.Clone(x)).ToList();
     135      clone.AttachEventHandlers();
    133136      return clone;
    134137    }
     
    195198    #region Helpers
    196199    [StorableHook(HookType.AfterDeserialization)]
    197     private void Initialize() {
    198       InitializeOperators();
     200    private void AttachEventHandlers() {
     201      // Start BackwardsCompatibility3.3 (remove with 3.4)
     202      if (operators == null) InitializeOperators();
     203      // End BackwardsCompatibility3.3
    199204      SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);
    200205      SolutionCreator.BinaryVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_BinaryVectorParameter_ActualNameChanged);
Note: See TracChangeset for help on using the changeset viewer.