Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5645


Ignore:
Timestamp:
03/09/11 13:46:14 (13 years ago)
Author:
epitzer
Message:

Set CurrentInertia inside operator graph and make sure all operators use it
Set default end value to epsilon instead of zero (#852)

Location:
trunk/sources
Files:
3 edited

Legend:

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

    r5643 r5645  
    166166      RandomCreator randomCreator = new RandomCreator();
    167167      VariableCreator variableCreator = new VariableCreator();
     168      Assigner assigner = new Assigner();
    168169      solutionsCreator = new SolutionsCreator();
    169170      SubScopesCounter subScopesCounter = new SubScopesCounter();
     
    180181      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("CurrentIteration", new IntValue(0)));
    181182      variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("CurrentVelocityBounds", new DoubleValue(0)));
    182       variableCreator.Successor = solutionsCreator;
     183      variableCreator.Successor = assigner;
     184
     185      assigner.Name = "CurrentInertia := Inertia";
     186      assigner.LeftSideParameter.ActualName = "CurrentInertia";
     187      assigner.RightSideParameter.ActualName = "Inertia";
     188      assigner.Successor = solutionsCreator;
    183189
    184190      solutionsCreator.NumberOfSolutionsParameter.ActualName = "SwarmSize";
     
    195201
    196202      mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
    197       mainLoop.InertiaParameter.ActualName = InertiaParameter.Name;
     203      mainLoop.InertiaParameter.ActualName = "CurrentInertia";
    198204      mainLoop.MaxIterationsParameter.ActualName = MaxIterationsParameter.Name;
    199205      mainLoop.NeighborBestAttractionParameter.ActualName = NeighborBestAttractionParameter.Name;
     
    231237      if (Problem != null && ParticleCreator != null && ParticleUpdater != null) {
    232238        base.Prepare();
    233         VariableCreator creator = (VariableCreator)((RandomCreator)OperatorGraph.InitialOperator).Successor;
    234         ValueParameter<DoubleValue> currentInertia = null;
    235         if (creator.CollectedValues.ContainsKey("CurrentInertia")) {
    236           currentInertia = (ValueParameter<DoubleValue>) creator.CollectedValues["CurrentInertia"];
    237         } else {
    238           currentInertia = new ValueParameter<DoubleValue>("CurrentInertia");
    239           creator.CollectedValues.Add(currentInertia);
    240         }
    241         currentInertia.ActualValue = InertiaParameter.ActualValue;
    242239      }
    243240    }
     
    257254      this.UpdateTopologyParameters();
    258255    }
    259 
    260     //void VelocityBoundsUpdaterParameter_ValueChanged(object sender, EventArgs e) {
    261     //  if (VelocityBoundsParameter.Value != null) {
    262     //    foreach (IDiscreteDoubleMatrixModifier matrixOp in VelocityBoundsUpdaterParameter.Value.ScalingOperatorParameter.ValidValues) {
    263     //      matrixOp.ValueParameter.ActualName = VelocityBoundsUpdater.ScaleParameter.Name;
    264     //      matrixOp.StartValueParameter.Value = new DoubleValue(VelocityBoundsUpdater.ScaleParameter.ActualValue.Value);
    265     //    }
    266     //  }
    267     //}
    268256    #endregion
    269257
     
    315303        updater.StartIndexParameter.Value = new IntValue(0);
    316304        updater.IndexParameter.ActualName = "CurrentIteration";
    317         updater.ValueParameter.ActualName = "CurrentInertia"; 
     305        updater.ValueParameter.ActualName = "CurrentInertia";
    318306        updater.StartValueParameter.Value = new DoubleValue(1);
    319         updater.EndValueParameter.Value = new DoubleValue(0);
     307        updater.EndValueParameter.Value = new DoubleValue(double.Epsilon);
    320308      }
    321309    }
  • trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ParticleSwarmOptimizationMainLoop.cs

    r5643 r5645  
    4848    }
    4949    public IValueLookupParameter<DoubleValue> InertiaParameter {
    50       get { return (IValueLookupParameter<DoubleValue>)Parameters["Inertia"]; }
     50      get { return (IValueLookupParameter<DoubleValue>)Parameters["CurrentInertia"]; }
    5151    }
    5252    public IValueLookupParameter<DoubleValue> PersonalBestAttractionParameter {
     
    105105      Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to analyze each generation."));
    106106
    107       Parameters.Add(new ValueLookupParameter<DoubleValue>("Inertia", "Inertia weight on a particle's movement (omega)."));
     107      Parameters.Add(new ValueLookupParameter<DoubleValue>("CurrentInertia", "Inertia weight on a particle's movement (omega)."));
    108108      Parameters.Add(new ValueLookupParameter<DoubleValue>("PersonalBestAttraction", "Weight for particle's pull towards its personal best soution (phi_p)."));
    109109      Parameters.Add(new ValueLookupParameter<DoubleValue>("NeighborBestAttraction", "Weight for pull towards the neighborhood best solution or global best solution in case of a totally connected topology (phi_g)."));
     
    141141      #region Create operator graph
    142142      OperatorGraph.InitialOperator = resultsCollector;
    143       resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Iterations", null, "CurrentIteration"));
    144       resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Inertia", null, "CurrentInertia"));
     143      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Iterations"));
     144      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("CurrentInertia"));
    145145      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", null, "EvaluatedSolutions"));
    146146      resultsCollector.ResultsParameter.ActualName = "Results";
     
    170170      subScopesCounter.Name = "Increment EvaluatedSolutions";
    171171      subScopesCounter.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name;
    172       subScopesCounter.Successor = topologyUpdaterPlaceholder; 
     172      subScopesCounter.Successor = topologyUpdaterPlaceholder;
    173173
    174174      topologyUpdaterPlaceholder.Name = "(TopologyUpdater)";
  • trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorParticleUpdater.cs

    r5643 r5645  
    6363    }
    6464    public ILookupParameter<DoubleValue> InertiaParameter {
    65       get { return (ILookupParameter<DoubleValue>)Parameters["Inertia"]; }
     65      get { return (ILookupParameter<DoubleValue>)Parameters["CurrentInertia"]; }
    6666    }
    6767    public ILookupParameter<DoubleValue> PersonalBestAttractionParameter {
     
    125125      Parameters.Add(new LookupParameter<DoubleMatrix>("Bounds", "The lower and upper bounds for each dimension of the position vector for the current problem."));
    126126      Parameters.Add(new LookupParameter<DoubleMatrix>("VelocityBounds", "Upper and lower bounds for the particle's velocity vector."));
    127       Parameters.Add(new LookupParameter<DoubleValue>("Inertia", "The weight for the particle's velocity vector."));
     127      Parameters.Add(new LookupParameter<DoubleValue>("CurrentInertia", "The weight for the particle's velocity vector."));
    128128      Parameters.Add(new LookupParameter<DoubleValue>("PersonalBestAttraction", "The weight for the particle's personal best position."));
    129129      Parameters.Add(new LookupParameter<DoubleValue>("NeighborBestAttraction", "The weight for the global best position."));
Note: See TracChangeset for help on using the changeset viewer.