private ParticleSwarmOptimization(ParticleSwarmOptimization original, Cloner cloner) : base(original, cloner) { qualityAnalyzer = cloner.Clone(original.qualityAnalyzer); solutionsCreator = cloner.Clone(original.solutionsCreator); mainLoop = cloner.Clone(original.mainLoop); Initialize(); }
public ParticleSwarmOptimization() : base() { Parameters.Add(new ValueParameter <IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0))); Parameters.Add(new ValueParameter <BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true))); Parameters.Add(new ValueParameter <IntValue>("SwarmSize", "Size of the particle swarm.", new IntValue(40))); Parameters.Add(new ValueParameter <IntValue>("MaxIterations", "Maximal number of iterations.", new IntValue(1000))); Parameters.Add(new ValueParameter <MultiAnalyzer>("Analyzer", "The operator used to analyze each generation.", new MultiAnalyzer())); Parameters.Add(new ValueParameter <DoubleValue>("Inertia", "Inertia weight on a particle's movement (omega).", new DoubleValue(0.721))); Parameters.Add(new ValueParameter <DoubleValue>("PersonalBestAttraction", "Weight for particle's pull towards its personal best soution (phi_p).", new DoubleValue(1.193))); Parameters.Add(new ValueParameter <DoubleValue>("NeighborBestAttraction", "Weight for pull towards the neighborhood best solution or global best solution in case of a totally connected topology (phi_g).", new DoubleValue(1.193))); Parameters.Add(new ConstrainedValueParameter <IParticleCreator>("ParticleCreator", "Operator that creates a new particle.")); Parameters.Add(new ConstrainedValueParameter <IParticleUpdater>("ParticleUpdater", "Operator that updates a particle.")); Parameters.Add(new OptionalConstrainedValueParameter <ITopologyInitializer>("TopologyInitializer", "Creates neighborhood description vectors.")); Parameters.Add(new OptionalConstrainedValueParameter <ITopologyUpdater>("TopologyUpdater", "Updates the neighborhood description vectors.")); Parameters.Add(new OptionalConstrainedValueParameter <IDiscreteDoubleValueModifier>("InertiaUpdater", "Updates the omega parameter.")); Parameters.Add(new ConstrainedValueParameter <ISwarmUpdater>("SwarmUpdater", "Encoding-specific parameter which is provided by the problem. May provide additional encoding-specific parameters, such as velocity bounds for real valued problems")); RandomCreator randomCreator = new RandomCreator(); VariableCreator variableCreator = new VariableCreator(); Assigner currentInertiaAssigner = new Assigner(); solutionsCreator = new SolutionsCreator(); SubScopesCounter subScopesCounter = new SubScopesCounter(); Placeholder topologyInitializerPlaceholder = new Placeholder(); mainLoop = new ParticleSwarmOptimizationMainLoop(); OperatorGraph.InitialOperator = randomCreator; randomCreator.SetSeedRandomlyParameter.Value = null; randomCreator.SeedParameter.Value = null; randomCreator.Successor = variableCreator; variableCreator.CollectedValues.Add(new ValueParameter <IntValue>("Iterations", new IntValue(0))); variableCreator.Successor = currentInertiaAssigner; currentInertiaAssigner.Name = "CurrentInertia := Inertia"; currentInertiaAssigner.LeftSideParameter.ActualName = "CurrentInertia"; currentInertiaAssigner.RightSideParameter.ActualName = "Inertia"; currentInertiaAssigner.Successor = solutionsCreator; solutionsCreator.NumberOfSolutionsParameter.ActualName = "SwarmSize"; ParameterizeSolutionsCreator(); solutionsCreator.Successor = subScopesCounter; subScopesCounter.Name = "Initialize EvaluatedSolutions"; subScopesCounter.ValueParameter.ActualName = "EvaluatedSolutions"; subScopesCounter.Successor = topologyInitializerPlaceholder; topologyInitializerPlaceholder.Name = "(TopologyInitializer)"; topologyInitializerPlaceholder.OperatorParameter.ActualName = "TopologyInitializer"; topologyInitializerPlaceholder.Successor = mainLoop; mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name; mainLoop.InertiaParameter.ActualName = "CurrentInertia"; mainLoop.MaxIterationsParameter.ActualName = MaxIterationsParameter.Name; mainLoop.NeighborBestAttractionParameter.ActualName = NeighborBestAttractionParameter.Name; mainLoop.InertiaUpdaterParameter.ActualName = InertiaUpdaterParameter.Name; mainLoop.ParticleUpdaterParameter.ActualName = ParticleUpdaterParameter.Name; mainLoop.PersonalBestAttractionParameter.ActualName = PersonalBestAttractionParameter.Name; mainLoop.RandomParameter.ActualName = randomCreator.RandomParameter.ActualName; mainLoop.SwarmSizeParameter.ActualName = SwarmSizeParameter.Name; mainLoop.TopologyUpdaterParameter.ActualName = TopologyUpdaterParameter.Name; mainLoop.RandomParameter.ActualName = randomCreator.RandomParameter.ActualName; mainLoop.ResultsParameter.ActualName = "Results"; InitializeAnalyzers(); InitializeParticleCreator(); InitializeSwarmUpdater(); ParameterizeSolutionsCreator(); UpdateAnalyzers(); UpdateInertiaUpdater(); InitInertiaUpdater(); UpdateTopologyInitializer(); Initialize(); ParameterizeMainLoop(); }
public ParticleSwarmOptimization() : base() { Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0))); Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true))); Parameters.Add(new ValueParameter<IntValue>("SwarmSize", "Size of the particle swarm.", new IntValue(10))); Parameters.Add(new ValueParameter<IntValue>("MaxIterations", "Maximal number of iterations.", new IntValue(1000))); Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze each generation.", new MultiAnalyzer())); Parameters.Add(new ValueParameter<DoubleValue>("Inertia", "Inertia weight on a particle's movement (omega).", new DoubleValue(1))); Parameters.Add(new ValueParameter<DoubleValue>("PersonalBestAttraction", "Weight for particle's pull towards its personal best soution (phi_p).", new DoubleValue(-0.01))); Parameters.Add(new ValueParameter<DoubleValue>("NeighborBestAttraction", "Weight for pull towards the neighborhood best solution or global best solution in case of a totally connected topology (phi_g).", new DoubleValue(3.7))); Parameters.Add(new ConstrainedValueParameter<IParticleCreator>("ParticleCreator", "Operator that creates a new particle.")); Parameters.Add(new ConstrainedValueParameter<IParticleUpdater>("ParticleUpdater", "Operator that updates a particle.")); Parameters.Add(new OptionalConstrainedValueParameter<ITopologyInitializer>("TopologyInitializer", "Creates neighborhood description vectors.")); Parameters.Add(new OptionalConstrainedValueParameter<ITopologyUpdater>("TopologyUpdater", "Updates the neighborhood description vectors.")); Parameters.Add(new OptionalConstrainedValueParameter<IDiscreteDoubleValueModifier>("InertiaUpdater", "Updates the omega parameter.")); Parameters.Add(new ConstrainedValueParameter<ISwarmUpdater>("SwarmUpdater", "Encoding-specific parameter which is provided by the problem. May provide additional encoding-specific parameters, such as velocity bounds for real valued problems")); ParticleUpdaterParameter.Hidden = true; RandomCreator randomCreator = new RandomCreator(); VariableCreator variableCreator = new VariableCreator(); Assigner currentInertiaAssigner = new Assigner(); solutionsCreator = new SolutionsCreator(); SubScopesCounter subScopesCounter = new SubScopesCounter(); Placeholder topologyInitializerPlaceholder = new Placeholder(); mainLoop = new ParticleSwarmOptimizationMainLoop(); OperatorGraph.InitialOperator = randomCreator; randomCreator.SetSeedRandomlyParameter.Value = null; randomCreator.SeedParameter.Value = null; randomCreator.Successor = variableCreator; variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Iterations", new IntValue(0))); variableCreator.Successor = currentInertiaAssigner; currentInertiaAssigner.Name = "CurrentInertia := Inertia"; currentInertiaAssigner.LeftSideParameter.ActualName = "CurrentInertia"; currentInertiaAssigner.RightSideParameter.ActualName = "Inertia"; currentInertiaAssigner.Successor = solutionsCreator; solutionsCreator.NumberOfSolutionsParameter.ActualName = "SwarmSize"; ParameterizeSolutionsCreator(); solutionsCreator.Successor = subScopesCounter; subScopesCounter.Name = "Initialize EvaluatedSolutions"; subScopesCounter.ValueParameter.ActualName = "EvaluatedSolutions"; subScopesCounter.Successor = topologyInitializerPlaceholder; topologyInitializerPlaceholder.Name = "(TopologyInitializer)"; topologyInitializerPlaceholder.OperatorParameter.ActualName = "TopologyInitializer"; topologyInitializerPlaceholder.Successor = mainLoop; mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name; mainLoop.InertiaParameter.ActualName = "CurrentInertia"; mainLoop.MaxIterationsParameter.ActualName = MaxIterationsParameter.Name; mainLoop.NeighborBestAttractionParameter.ActualName = NeighborBestAttractionParameter.Name; mainLoop.InertiaUpdaterParameter.ActualName = InertiaUpdaterParameter.Name; mainLoop.ParticleUpdaterParameter.ActualName = ParticleUpdaterParameter.Name; mainLoop.PersonalBestAttractionParameter.ActualName = PersonalBestAttractionParameter.Name; mainLoop.RandomParameter.ActualName = randomCreator.RandomParameter.ActualName; mainLoop.SwarmSizeParameter.ActualName = SwarmSizeParameter.Name; mainLoop.TopologyUpdaterParameter.ActualName = TopologyUpdaterParameter.Name; mainLoop.RandomParameter.ActualName = randomCreator.RandomParameter.ActualName; mainLoop.ResultsParameter.ActualName = "Results"; InitializeAnalyzers(); InitializeParticleCreator(); InitializeSwarmUpdater(); ParameterizeSolutionsCreator(); UpdateAnalyzers(); UpdateInertiaUpdater(); InitInertiaUpdater(); UpdateTopologyInitializer(); Initialize(); ParameterizeMainLoop(); }
protected ParticleSwarmOptimizationMainLoop(ParticleSwarmOptimizationMainLoop original, Cloner cloner) : base(original, cloner) { }