Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/25/15 23:24:01 (9 years ago)
Author:
abeham
Message:

#2521:

  • Adapted single-objective test function problem to new problem infrastructure
  • Added additional interfaces to RealVectorEncoding
  • Fixed IParticleUpdater interface (must implement IStochasticOperator if it contains a Random parameter)
Location:
branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorParticleUpdater.cs

    r12012 r13403  
    5757      get { return (ILookupParameter<RealVector>)Parameters["RealVector"]; }
    5858    }
    59     public ILookupParameter<DoubleMatrix> BoundsParameter {
    60       get { return (ILookupParameter<DoubleMatrix>)Parameters["Bounds"]; }
     59    public IValueLookupParameter<DoubleMatrix> BoundsParameter {
     60      get { return (IValueLookupParameter<DoubleMatrix>)Parameters["Bounds"]; }
    6161    }
    6262    public ILookupParameter<DoubleMatrix> CurrentVelocityBoundsParameter {
     
    124124      Parameters.Add(new LookupParameter<RealVector>("BestRealVector", "Global best position."));
    125125      Parameters.Add(new LookupParameter<RealVector>("NeighborBest", "Best neighboring solution."));
    126       Parameters.Add(new LookupParameter<DoubleMatrix>("Bounds", "The lower and upper bounds for each dimension of the position vector for the current problem."));
     126      Parameters.Add(new ValueLookupParameter<DoubleMatrix>("Bounds", "The lower and upper bounds for each dimension of the position vector for the current problem."));
    127127      Parameters.Add(new LookupParameter<DoubleMatrix>("CurrentVelocityBounds", "Upper and lower bounds for the particle's velocity vector."));
    128128      Parameters.Add(new LookupParameter<DoubleValue>("CurrentInertia", "The weight for the particle's velocity vector."));
  • branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorSwarmUpdater.cs

    r12012 r13403  
    5454      get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["NeighborBestQuality"]; }
    5555    }
    56     public IScopeTreeLookupParameter<RealVector> RealVectorParameter {
    57       get { return (IScopeTreeLookupParameter<RealVector>)Parameters["RealVector"]; }
     56    public IScopeTreeLookupParameter<RealVector> RealVectorsParameter {
     57      get { return (IScopeTreeLookupParameter<RealVector>)Parameters["RealVectors"]; }
    5858    }
    5959    public IScopeTreeLookupParameter<RealVector> PersonalBestParameter {
     
    131131      set { NeighborBestQualityParameter.ActualValue = value; }
    132132    }
    133     private ItemArray<RealVector> RealVector {
    134       get { return RealVectorParameter.ActualValue; }
     133    private ItemArray<RealVector> RealVectors {
     134      get { return RealVectorsParameter.ActualValue; }
    135135    }
    136136    private ItemArray<RealVector> PersonalBest {
     
    186186      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("PersonalBestQuality", "Particles' personal best qualities."));
    187187      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("NeighborBestQuality", "Best neighbor particles' qualities."));
    188       Parameters.Add(new ScopeTreeLookupParameter<RealVector>("RealVector", "Particles' positions."));
     188      Parameters.Add(new ScopeTreeLookupParameter<RealVector>("RealVectors", "Particles' positions."));
    189189      Parameters.Add(new ScopeTreeLookupParameter<RealVector>("PersonalBest", "Particles' personal best positions."));
    190190      Parameters.Add(new ScopeTreeLookupParameter<RealVector>("NeighborBest", "Neighborhood (or global in case of totally connected neighborhood) best particle positions."));
     
    288288        SwarmBestQuality = new DoubleValue();
    289289      SwarmBestQuality.Value = Maximization ? Quality.Max(v => v.Value) : Quality.Min(v => v.Value);
    290       BestRealVector = (RealVector)RealVector[Quality.FindIndex(v => v.Value == SwarmBestQuality.Value)].Clone();
     290      BestRealVector = (RealVector)RealVectors[Quality.FindIndex(v => v.Value == SwarmBestQuality.Value)].Clone();
    291291    }
    292292
     
    296296        var neighborBestQuality = new ItemArray<DoubleValue>(Neighbors.Length);
    297297        for (int n = 0; n < Neighbors.Length; n++) {
    298           var pairs = Quality.Zip(RealVector, (q, p) => new { Quality = q, Point = p })
     298          var pairs = Quality.Zip(RealVectors, (q, p) => new { Quality = q, Point = p })
    299299            .Where((p, i) => i == n || Neighbors[n].Contains(i));
    300300          var bestNeighbor = Maximization ?
     
    312312      if (PersonalBestQuality.Length == 0)
    313313        PersonalBestQuality = (ItemArray<DoubleValue>)Quality.Clone();
    314       for (int i = 0; i < RealVector.Length; i++) {
     314      for (int i = 0; i < RealVectors.Length; i++) {
    315315        if (Maximization && Quality[i].Value > PersonalBestQuality[i].Value ||
    316316          !Maximization && Quality[i].Value < PersonalBestQuality[i].Value) {
    317317          PersonalBestQuality[i].Value = Quality[i].Value;
    318           PersonalBest[i] = RealVector[i];
     318          PersonalBest[i] = RealVectors[i];
    319319        }
    320320      }
Note: See TracChangeset for help on using the changeset viewer.