Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/15/12 09:11:17 (13 years ago)
Author:
gkronber
Message:

#1081 merged r7462:7609 from trunk into time series branch

Location:
branches/HeuristicLab.TimeSeries
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.TimeSeries

  • branches/HeuristicLab.TimeSeries/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ParticleSwarmOptimization.cs

    r7268 r7615  
    288288      if (Problem != null) {
    289289        IParticleCreator oldParticleCreator = ParticleCreator;
     290        IParticleCreator defaultParticleCreator = Problem.Operators.OfType<IParticleCreator>().FirstOrDefault();
    290291        ParticleCreatorParameter.ValidValues.Clear();
    291292        foreach (IParticleCreator Creator in Problem.Operators.OfType<IParticleCreator>().OrderBy(x => x.Name)) {
     
    295296          IParticleCreator creator = ParticleCreatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldParticleCreator.GetType());
    296297          if (creator != null) ParticleCreator = creator;
    297         }
     298          else oldParticleCreator = null;
     299        }
     300        if (oldParticleCreator == null && defaultParticleCreator != null)
     301          ParticleCreator = defaultParticleCreator;
    298302      }
    299303    }
     
    372376      ClearTopologyParameters();
    373377      if (Problem != null) {
     378        IParticleUpdater defaultParticleUpdater = null;
    374379        if (TopologyInitializer != null) {
    375380          foreach (ITopologyUpdater topologyUpdater in ApplicationManager.Manager.GetInstances<ITopologyUpdater>())
    376381            TopologyUpdaterParameter.ValidValues.Add(topologyUpdater);
     382          defaultParticleUpdater = Problem.Operators.OfType<ILocalParticleUpdater>().FirstOrDefault();
    377383          foreach (IParticleUpdater particleUpdater in Problem.Operators.OfType<ILocalParticleUpdater>().OrderBy(x => x.Name))
    378384            ParticleUpdaterParameter.ValidValues.Add(particleUpdater);
    379385        } else {
     386          defaultParticleUpdater = Problem.Operators.OfType<IGlobalParticleUpdater>().FirstOrDefault();
    380387          foreach (IParticleUpdater particleUpdater in Problem.Operators.OfType<IGlobalParticleUpdater>().OrderBy(x => x.Name))
    381388            ParticleUpdaterParameter.ValidValues.Add(particleUpdater);
     
    388395          IParticleUpdater newParticleUpdater = ParticleUpdaterParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldParticleUpdater.GetType());
    389396          if (newParticleUpdater != null) ParticleUpdater = newParticleUpdater;
    390         }
     397          else oldParticleUpdater = null;
     398        }
     399        if (oldParticleUpdater == null && defaultParticleUpdater != null)
     400          ParticleUpdater = defaultParticleUpdater;
    391401
    392402        ParameterizeTopologyUpdaters();
Note: See TracChangeset for help on using the changeset viewer.