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
Location:
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Analyzers/BestSingleObjectiveTestFunctionSolutionAnalyzer.cs

    r4086 r4098  
    9090    [StorableHook(HookType.AfterDeserialization)]
    9191    private void CompatibilityMethod() {
     92      // BackwardsCompatibility3.3
    9293      // Bounds are introduced in 3.3.0.3894
    9394      if (!Parameters.ContainsKey("Bounds"))
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/SingleObjectiveTestFunctionProblem.cs

    r4068 r4098  
    119119      set { BestKnownQualityParameter.Value = value; }
    120120    }
    121     private List<IOperator> operators;
    122121    public IEnumerable<IOperator> Operators {
    123122      get { return operators; }
     
    127126    }
    128127    #endregion
     128
     129    [Storable]
     130    private List<IOperator> operators;
    129131
    130132    [StorableConstructor]
     
    154156      ParameterizeEvaluator();
    155157
    156       Initialize();
     158      InitializeOperators();
     159      AttachEventHandlers();
    157160      UpdateStrategyVectorBounds();
    158161    }
     
    160163    public override IDeepCloneable Clone(Cloner cloner) {
    161164      SingleObjectiveTestFunctionProblem clone = (SingleObjectiveTestFunctionProblem)base.Clone(cloner);
     165      clone.operators = operators.Where(x => IsNotFieldReferenced(x)).Select(x => (IOperator)cloner.Clone(x)).ToList();
    162166      clone.strategyVectorCreator = (StdDevStrategyVectorCreator)cloner.Clone(strategyVectorCreator);
     167      clone.operators.Add(clone.strategyVectorCreator);
    163168      clone.strategyVectorCrossover = (StdDevStrategyVectorCrossover)cloner.Clone(strategyVectorCrossover);
     169      clone.operators.Add(strategyVectorCrossover);
    164170      clone.strategyVectorManipulator = (StdDevStrategyVectorManipulator)cloner.Clone(strategyVectorManipulator);
    165       clone.Initialize();
     171      clone.operators.Add(strategyVectorManipulator);
     172      clone.AttachEventHandlers();
    166173      return clone;
     174    }
     175
     176    private bool IsNotFieldReferenced(IOperator x) {
     177      return !(x == strategyVectorCreator
     178        || x == strategyVectorCrossover
     179        || x == strategyVectorManipulator);
    167180    }
    168181
     
    284297    #region Helpers
    285298    [StorableHook(HookType.AfterDeserialization)]
    286     private void Initialize() {
    287       InitializeOperators();
     299    private void AttachEventHandlers() {
     300      // Start BackwardsCompatibility3.3 (remove with 3.4)
     301      if (operators == null) InitializeOperators();
     302      // End BackwardsCompatibility3.3
    288303      ProblemSizeParameter.ValueChanged += new EventHandler(ProblemSizeParameter_ValueChanged);
    289304      ProblemSize.ValueChanged += new EventHandler(ProblemSize_ValueChanged);
Note: See TracChangeset for help on using the changeset viewer.