Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/24/11 19:22:39 (14 years ago)
Author:
mkofler
Message:

#852: Code refactoring. Worked on swarm updater.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ParticleSwarmOptimization.cs

    r5560 r5561  
    114114    private ParticleSwarmOptimizationMainLoop mainLoop;
    115115
     116    [Storable]
     117    private CombinedOperator swarmUpdater;
     118
    116119    public ITopologyInitializer TopologyInitializer {
    117120      get { return TopologyInitializerParameter.Value; }
     
    141144      qualityAnalyzer = cloner.Clone(original.qualityAnalyzer);
    142145      solutionsCreator = cloner.Clone(original.solutionsCreator);
    143       mainLoop = cloner.Clone(original.mainLoop);
     146      mainLoop = cloner.Clone(original.mainLoop);
     147      swarmUpdater = cloner.Clone(original.swarmUpdater);
    144148      Initialize();
    145149    }
     
    166170      ResultsCollector resultsCollector = new ResultsCollector();
    167171      Placeholder analyzerPlaceholder = new Placeholder();
    168       RealVectorSwarmUpdater swarmUpdater = new RealVectorSwarmUpdater();
     172      swarmUpdater = new CombinedOperator();
    169173      mainLoop = new ParticleSwarmOptimizationMainLoop();
    170174
     
    206210      mainLoop.RandomParameter.ActualName = randomCreator.RandomParameter.ActualName;
    207211      mainLoop.ResultsParameter.ActualName = "Results";
    208       mainLoop.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
    209212     // mainLoop.EvaluatedMovesParameter.ActualName = "EvaluatedMoves";
    210213
     
    212215      ////InitVelocityBoundsUpdater();
    213216      InitializeParticleCreator();
     217      InitializeSwarmUpdater();
    214218      ParameterizeSolutionsCreator();
    215219      UpdateAnalyzers();
     
    252256      UpdateTopologyParameters();
    253257      InitializeParticleCreator();
     258      InitializeSwarmUpdater();
    254259      ParameterizeSolutionsCreator();
    255260      base.OnProblemChanged();
     
    395400
    396401    private void ParameterizeMainLoop() {
    397       mainLoop.MaxIterationsParameter.ActualName = MaxIterationsParameter.Name;
     402      if (Problem != null) {
     403        mainLoop.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
     404      }
     405    }
     406
     407    private void InitializeSwarmUpdater() {
     408      if (Problem != null) {
     409        ISwarmUpdater updater = Problem.Operators.OfType<ISwarmUpdater>().FirstOrDefault();
     410        swarmUpdater.OperatorGraph.InitialOperator = updater;
     411      }
    398412    }
    399413    #endregion
Note: See TracChangeset for help on using the changeset viewer.