createParticleSwarmSolver

fun createParticleSwarmSolver(problemDefinition: ProblemDefinition, modelBuilder: ModelBuilderIfc, swarmSize: Int = ParticleSwarmSolver.defaultSwarmSize, inertiaSchedule: InertiaWeightScheduleIfc? = null, cognitiveCoefficient: Double = ParticleSwarmSolver.defaultCognitiveCoefficient, socialCoefficient: Double = ParticleSwarmSolver.defaultSocialCoefficient, boundaryHandler: BoundaryHandlerIfc = ClampToBounds(), startingPoint: MutableMap<String, Double>? = null, maxIterations: Int = ParticleSwarmSolver.psoDefaultMaxIterations, replicationsPerEvaluation: Int = defaultReplicationsPerEvaluation, solutionCache: SolutionCacheIfc = MemorySolutionCache(), simulationRunCache: SimulationRunCacheIfc? = null, experimentRunParameters: ExperimentRunParametersIfc? = null, streamNum: Int = 0, streamProvider: RNStreamProviderIfc = RNStreamProvider(), name: String? = null, parallelOptions: ParallelEvaluationOptions = ParallelEvaluationOptions(enabled = true)): ParticleSwarmSolver(source)

Creates and configures a global-best particle swarm optimization (PSO) solver for a given problem definition.

Note: unlike the other create* factories (which default to sequential evaluation), this factory defaults parallelOptions to enabled = true, because PSO evaluates the whole swarm as one batch each iteration and therefore benefits directly from parallel oracle execution. As with all parallel evaluation, the supplied modelBuilder MUST return an independent, freshly built model on each call; pass ParallelEvaluationOptions() to force sequential evaluation if that is not the case.

Return

An instance of ParticleSwarmSolver that encapsulates the optimization process and results.

Parameters

problemDefinition

The definition of the optimization problem, including constraints and objectives.

modelBuilder

The model builder interface used to create models for evaluation. Must yield independent models per call when parallel.

swarmSize

The number of particles in the swarm. Defaults to ParticleSwarmSolver.defaultSwarmSize.

inertiaSchedule

The inertia-weight schedule. When omitted (null), a LinearDecreasingInertia whose horizon matches maxIterations is used, so the weight decays across the whole run.

cognitiveCoefficient

The cognitive acceleration coefficient c1. Defaults to ParticleSwarmSolver.defaultCognitiveCoefficient.

socialCoefficient

The social acceleration coefficient c2. Defaults to ParticleSwarmSolver.defaultSocialCoefficient.

boundaryHandler

How out-of-range positions are handled. Defaults to ClampToBounds.

startingPoint

Optional initial coordinates seeded as the first particle. If left null, the whole swarm is scattered over random feasible points upon initialization.

maxIterations

The maximum number of iterations the algorithm will run. Defaults to 100.

replicationsPerEvaluation

The number of replications to use during each evaluation to reduce stochastic noise.

solutionCache

Specifies if the evaluator uses a solution cache. By default, this is MemorySolutionCache.

simulationRunCache

Specifies if the simulation oracle will use a SimulationRunCache. The default is null (no cache).

experimentRunParameters

the run parameters to apply to the model during the building process

streamNum

the random number stream number; 0 (the default) means the next available stream

streamProvider

the provider of random number streams; defaults to a fresh RNStreamProvider, so each solver has its own streams