Class KNeighbors
- Namespace
- NanoQL.Experimental
- Assembly
- NanoQL.dll
The K-neighbours topology: each particle's social best is the best of the K particles before and the K after it,
the swarm a ring: QuantLib's KNeighbors.
[Experimental("NQL0001")]
public sealed class KNeighbors : ParticleSwarmOptimizationTopology
- Inheritance
-
KNeighbors
- Inherited Members
Remarks
For particle i the window is [i − K, i + K], wrapping around, as the class documents, and a particle that is its
window's best is its own social best: QuantLib's window runs from i − K − 1 to i + K − 1, and its search starts from
particle i's value paired with particle 0's position, so a particle that is its window's best takes particle 0's
position (Divergences/ParticleSwarmTopologyTests.cs).
Constructors
KNeighbors(int)
Initializes a new instance of the KNeighbors class.
public KNeighbors(int K = 1)
Parameters
KintThe neighbours on each side, positive; QuantLib's default 1.
Exceptions
- ArgumentException
Kisn't positive, with QuantLib's text.
Methods
Clone()
A copy for a minimization, unbound, its generators at their seeds.
public override ParticleSwarmOptimizationTopology Clone()
Returns
- ParticleSwarmOptimizationTopology
The copy.
FindSocialBest()
Sets each particle's social best for the iteration (QuantLib's findSocialBest).
public override void FindSocialBest()
SetSize(int)
Initializes the state for the problem (QuantLib's setSize).
public override void SetSize(int M)
Parameters
MintThe swarm's size.
Exceptions
- NanoQLException
K isn't below the swarm's size, with QuantLib's text.