Changeset 13403 for branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators
- Timestamp:
- 11/25/15 23:24:01 (9 years ago)
- 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 57 57 get { return (ILookupParameter<RealVector>)Parameters["RealVector"]; } 58 58 } 59 public I LookupParameter<DoubleMatrix> BoundsParameter {60 get { return (I LookupParameter<DoubleMatrix>)Parameters["Bounds"]; }59 public IValueLookupParameter<DoubleMatrix> BoundsParameter { 60 get { return (IValueLookupParameter<DoubleMatrix>)Parameters["Bounds"]; } 61 61 } 62 62 public ILookupParameter<DoubleMatrix> CurrentVelocityBoundsParameter { … … 124 124 Parameters.Add(new LookupParameter<RealVector>("BestRealVector", "Global best position.")); 125 125 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.")); 127 127 Parameters.Add(new LookupParameter<DoubleMatrix>("CurrentVelocityBounds", "Upper and lower bounds for the particle's velocity vector.")); 128 128 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 54 54 get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["NeighborBestQuality"]; } 55 55 } 56 public IScopeTreeLookupParameter<RealVector> RealVector Parameter {57 get { return (IScopeTreeLookupParameter<RealVector>)Parameters["RealVector "]; }56 public IScopeTreeLookupParameter<RealVector> RealVectorsParameter { 57 get { return (IScopeTreeLookupParameter<RealVector>)Parameters["RealVectors"]; } 58 58 } 59 59 public IScopeTreeLookupParameter<RealVector> PersonalBestParameter { … … 131 131 set { NeighborBestQualityParameter.ActualValue = value; } 132 132 } 133 private ItemArray<RealVector> RealVector {134 get { return RealVector Parameter.ActualValue; }133 private ItemArray<RealVector> RealVectors { 134 get { return RealVectorsParameter.ActualValue; } 135 135 } 136 136 private ItemArray<RealVector> PersonalBest { … … 186 186 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("PersonalBestQuality", "Particles' personal best qualities.")); 187 187 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.")); 189 189 Parameters.Add(new ScopeTreeLookupParameter<RealVector>("PersonalBest", "Particles' personal best positions.")); 190 190 Parameters.Add(new ScopeTreeLookupParameter<RealVector>("NeighborBest", "Neighborhood (or global in case of totally connected neighborhood) best particle positions.")); … … 288 288 SwarmBestQuality = new DoubleValue(); 289 289 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(); 291 291 } 292 292 … … 296 296 var neighborBestQuality = new ItemArray<DoubleValue>(Neighbors.Length); 297 297 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 }) 299 299 .Where((p, i) => i == n || Neighbors[n].Contains(i)); 300 300 var bestNeighbor = Maximization ? … … 312 312 if (PersonalBestQuality.Length == 0) 313 313 PersonalBestQuality = (ItemArray<DoubleValue>)Quality.Clone(); 314 for (int i = 0; i < RealVector .Length; i++) {314 for (int i = 0; i < RealVectors.Length; i++) { 315 315 if (Maximization && Quality[i].Value > PersonalBestQuality[i].Value || 316 316 !Maximization && Quality[i].Value < PersonalBestQuality[i].Value) { 317 317 PersonalBestQuality[i].Value = Quality[i].Value; 318 PersonalBest[i] = RealVector [i];318 PersonalBest[i] = RealVectors[i]; 319 319 } 320 320 }
Note: See TracChangeset
for help on using the changeset viewer.