Public API Documentation
Documentation for GlobalOptimization's public interface.
Contents
- Contents
- Problems
- Search Space
- Optimization
- Population Initialization
- Function Evaluation Methods
- Algorithms
- Trace Options
- Index
Problems
GlobalOptimization.NonlinearLeastSquaresProblem — Type
NonlinearLeastSquaresProblem{has_penalty, SS, F, G}A nonlinear least squares problem. Contains the nonlinear equations and search space.
Fields
f::F: The nonlinear equations.g!::G: The jacobian of the nonlinear equations.ss::SS: The search space.n::Int: The number of residuals.
GlobalOptimization.NonlinearLeastSquaresProblem — Method
NonlinearLeastSquaresProblem(f, [g], LB, UB)Constructs a nonlinear least squares problem with nonlinear function f, optional Jacobian g, and a search space.
Arguments
f::F: The nonlinear function.g::G: The Jacobian of the nonlinear function.LB::AbstractVector{<:Real}: The lower bounds of the search space.UB::AbstractVector{<:Real}: The upper bounds of the search space.
Returns
NonlinearLeastSquaresProblem{has_penalty, ContinuousRectangularSearchSpace, F, G}
Examples
julia> using GlobalOptimization;
julia> f(x) = [x[1] - x[3], x[2] - x[3]]
julia> LB = [-5.0, -5.0, -5.0];
julia> UB = [ 5.0, 5.0, 5.0];
julia> prob = NonlinearLeastSquaresProblem(f, ss, LB, UB, 2)
NonlinearLeastSquaresProblem{Val{false}(), ContinuousRectangularSearchSpace{Float64}, typeof(f), Nothing}(f, nothing, ContinuousRectangularSearchSpace{Float64}([-5.0, -5.0, -5.0], [5.0, 5.0, 5.0], [10.0, 10.0, 10.0]), 2)GlobalOptimization.NonlinearLeastSquaresProblem — Method
NonlinearLeastSquaresProblem{has_penalty}(f::F, [g::G], ss::SS, num_resid::Int)Constructs a nonlinear least squares problem with nonlinear functions f, optional jacobian g, and search space ss. If has_penalty is specified as true, then the nonlinear function must return a Tuple{AbstractArray{T},T} for a given x of type AbstractArray{T}.
Arguments
f::F: The nonlinear function.g::G: The Jacobian of the nonlinear function.ss::SS: The search space.num_resid::Int: The number of residuals.
Returns
NonlinearLeastSquaresProblem{has_penalty, SS, F, G}
Examples
julia> using GlobalOptimization;
julia> f(x) = [x[1] - x[3], x[2] - x[3]]
julia> LB = [-5.0, -5.0, -5.0];
julia> UB = [ 5.0, 5.0, 5.0];
julia> ss = ContinuousRectangularSearchSpace(LB, UB);
julia> prob = NonlinearLeastSquaresProblem(f, ss, 2)
NonlinearLeastSquaresProblem{Val{false}(), ContinuousRectangularSearchSpace{Float64}, typeof(f), Nothing}(f, nothing, ContinuousRectangularSearchSpace{Float64}([-5.0, -5.0, -5.0], [5.0, 5.0, 5.0], [10.0, 10.0, 10.0]), 2)GlobalOptimization.NonlinearLeastSquaresProblem — Method
NonlinearLeastSquaresProblem(f, [g], ss)Constructs a nonlinear least squares problem with nonlinear function f, optional Jacobian g, and a search space.
Arguments
f::F: The nonlinear function.g::G: The Jacobian of the nonlinear function.ss::SS: The search space.
Returns
NonlinearLeastSquaresProblem{has_penalty, ContinuousRectangularSearchSpace, F, G}
Examples
julia> using GlobalOptimization;
julia> f(x) = [x[1] - x[3], x[2] - x[3]]
julia> LB = [-5.0, -5.0, -5.0];
julia> UB = [ 5.0, 5.0, 5.0];
julia> ss = ContinuousRectangularSearchSpace(LB, UB);
julia> prob = NonlinearLeastSquaresProblem(f, ss, 2)
NonlinearLeastSquaresProblem{Val{false}(), ContinuousRectangularSearchSpace{Float64}, typeof(f), Nothing}(f, nothing, ContinuousRectangularSearchSpace{Float64}([-5.0, -5.0, -5.0], [5.0, 5.0, 5.0], [10.0, 10.0, 10.0]), 2)GlobalOptimization.NonlinearProblem — Type
NonlinearProblem{has_penalty, SS, F, G}A nonlinear problem. Contains the nonlinear equations and search space.
Fields
f::F: The nonlinear equations.g!::G: The jacobian of the nonlinear equations.ss::SS: The search space.
GlobalOptimization.NonlinearProblem — Method
NonlinearProblem(f, [g], LB, UB)Constructs a nonlinear problem with nonlinear function f, optional Jacobian g, and a continuous rectangular search space defined by the bounds LB and UB.
Arguments
f::F: The nonlinear function.g::G: The Jacobian of the nonlinear function.LB::AbstractVector{<:Real}: The lower bounds of the search space.UB::AbstractVector{<:Real}: The upper bounds of the search space.
Returns
NonlinearProblem{has_penalty, ContinuousRectangularSearchSpace, F, G}
Examples
julia> using GlobalOptimization;
julia> f(x) = [x[1] - 2.0, x[2] - 2.0]
julia> LB = [-5.0, -5.0];
julia> UB = [ 5.0, 5.0];
julia> prob = NonlinearProblem(f, LB, UB)
NonlinearProblem{Val{false}(), ContinuousRectangularSearchSpace{Float64}, typeof(f), Nothing}(f, nothing, ContinuousRectangularSearchSpace{Float64}([-5.0, -5.0], [5.0, 5.0], [10.0, 10.0]))GlobalOptimization.NonlinearProblem — Method
NonlinearProblem{has_penalty}(f::F, [g::G], ss::SS)Constructs a nonlinear problem with nonlinear functions f, optional jacobian g, and search space ss. If has_penalty is specified as true, then the nonlinear function must return a Tuple{AbstractArray{T},T} for a given x of type AbstractArray{T}.
Arguments
f::F: The nonlinear function.g::G: The Jacobian of the nonlinear function.ss::SS: The search space.
Returns
NonlinearProblem{has_penalty, SS, F, G}
Examples
julia> using GlobalOptimization;
julia> f(x) = [x[1] - 2.0, x[2] - 2.0]
julia> LB = [-5.0, -5.0];
julia> UB = [ 5.0, 5.0];
julia> ss = ContinuousRectangularSearchSpace(LB, UB);
julia> prob = NonlinearProblem(f, ss)
NonlinearProblem{Val{false}(), ContinuousRectangularSearchSpace{Float64}, typeof(f), Nothing}(f, nothing, ContinuousRectangularSearchSpace{Float64}([-5.0, -5.0], [5.0, 5.0], [10.0, 10.0]))GlobalOptimization.NonlinearProblem — Method
NonlinearProblem(f, [g], ss)Constructs a nonlinear problem with nonlinear function f, optional Jacobian g, and a search space.
Arguments
f::F: The nonlinear function.g::G: The Jacobian of the nonlinear function.ss::SS: The search space.
Returns
NonlinearProblem{has_penalty, ContinuousRectangularSearchSpace, F, G}
Examples
julia> using GlobalOptimization;
julia> f(x) = [x[1] - 2.0, x[2] - 2.0]
julia> LB = [-5.0, -5.0];
julia> UB = [ 5.0, 5.0];
julia> ss = ContinuousRectangularSearchSpace(LB, UB);
julia> prob = NonlinearProblem(f, ss)
NonlinearProblem{Val{false}(), ContinuousRectangularSearchSpace{Float64}, typeof(f), Nothing}(f, nothing, ContinuousRectangularSearchSpace{Float64}([-5.0, -5.0], [5.0, 5.0], [10.0, 10.0]))GlobalOptimization.OptimizationProblem — Type
OptimizationProblem{has_penalty, SS, F, G}An optimization problem. Contains the objective function and search space.
Fields
f::F: The objective function.g!::G: The gradient of the objective function.ss::SS: The search space.
GlobalOptimization.OptimizationProblem — Method
OptimizationProblem(f, [g], LB, UB)Constructs an optimization problem with objective function f, optional gradient g, and a ContinuousRectangularSearchSpace defined by LB and UB.
Arguments
f::F: The objective function.LB::AbstractVector{<:Real}: The lower bounds of the search space.UB::AbstractVector{<:Real}: The upper bounds of the search space.
Returns
OptimizationProblem{ContinuousRectangularSearchSpace, F}
Examples
julia> using GlobalOptimization;
julia> f(x) = sum(x.^2); # Simple sphere function
julia> LB = [-1.0, 0.0];
julia> UB = [ 1.0, 2.0];
julia> prob = OptimizationProblem(f, LB, UB)
OptimizationProblem{ContinuousRectangularSearchSpace{Float64}, typeof(f)}(f, ContinuousRectangularSearchSpace{Float64}([-1.0, 0.0], [1.0, 2.0], [2.0, 2.0]))GlobalOptimization.OptimizationProblem — Method
OptimizationProblem{has_penalty}(f::F, [g::G], ss::SS)Constructs an optimization problem with objective function f, optional gradient g, and search space ss. If has_penalty is specified as true, then the objective function must return a Tuple{T,T} for a given x of type AbstractArray{T}.
Arguments
f::F: The objective function.g::G: The gradient of the objective function.ss::SS: The search space.
Returns
OptimizationProblem{SS, F}
Examples
julia> using GlobalOptimization;
julia> f(x) = sum(x.^2); # Simple sphere function
julia> LB = [-1.0, 0.0];
julia> UB = [ 1.0, 2.0];
julia> ss = ContinuousRectangularSearchSpace(LB, UB);
julia> prob = OptimizationProblem(f, ss)
OptimizationProblem{ContinuousRectangularSearchSpace{Float64}, typeof(f)}(f, ContinuousRectangularSearchSpace{Float64}([-1.0, 0.0], [1.0, 2.0], [2.0, 2.0]))GlobalOptimization.OptimizationProblem — Method
OptimizationProblem(f, [g], ss)Constructs an optimization problem with objective function f, optimal gradient g, and a search space.
Arguments
f::F: The objective function.g::G: The gradient of the objective function.ss::SS: The search space.
Returns
OptimizationProblem{ContinuousRectangularSearchSpace, F}
Examples
julia> using GlobalOptimization;
julia> f(x) = sum(x.^2); # Simple sphere function
julia> LB = [-1.0, 0.0];
julia> UB = [ 1.0, 2.0];
julia> prob = OptimizationProblem(f, ContinuousRectangularSearchSpace(LB, UB))
OptimizationProblem{ContinuousRectangularSearchSpace{Float64}, typeof(f)}(f, ContinuousRectangularSearchSpace{Float64}([-1.0, 0.0], [1.0, 2.0], [2.0, 2.0]))Search Space
GlobalOptimization.ContinuousRectangularSearchSpace — Type
ContinuousRectangularSearchSpace{T <: AbstractFloat}A RectangularSearchSpace formed by a single continuous set.
Fields
dim_min::Vector{T}: A vector of minimum values for each dimension.dim_max::Vector{T}: A vector of maximum values for each dimension.dim_delta::Vector{T}: A vector of the difference between the maximum and minimum values for each dimension.
GlobalOptimization.ContinuousRectangularSearchSpace — Method
ContinuousRectangularSearchSpace(dim_min::AbstractVector{T}, dim_max::AbstractVector{T})Constructs a new ContinuousRectangularSearchSpace with minimum values dim_min and maximum values dim_max.
Arguments
dim_min::AbstractVector{T}: A vector of minimum values for each dimension.dim_max::AbstractVector{T}: A vector of maximum values for each dimension.
Returns
ContinuousRectangularSearchSpace{T}
Examples
julia> using GlobalOptimization;
julia> LB = [-1.0, 0.0];
julia> UB = [ 1.0, 2.0];
julia> ss = ContinuousRectangularSearchSpace(LB, UB)
ContinuousRectangularSearchSpace{Float64}([-1.0, 0.0], [1.0, 2.0], [2.0, 2.0])Optimization
GlobalOptimization.optimize! — Method
optimize!(opt::AbstractOptimizer)Perform optimization using the optimizer opt. Returns the results of the optimization.
Arguments
opt::AbstractOptimizer: The optimizer to use.
Returns
Results: The results of the optimization. See the Results docstring for details on its contents.
Example
julia> using GlobalOptimization
julia> f(x) = sum(x.^2) # Simple sphere function
julia> prob = OptimizationProblem(f, [-1.0, 0.0], [1.0, 2.0])
julia> pso = SerialPSO(prob)
julia> results = optimize!(pso)
Results:
- Best function value: 6.696180996034206e-20
- Best candidate: [-2.587698010980842e-10, 0.0]
- Iterations: 26
- Time: 0.004351139068603516 seconds
- Exit flag: MAXIMUM_STALL_ITERATIONS_EXCEEDEDPopulation Initialization
GlobalOptimization.LatinHypercubeInitialization — Type
LatinHypercubeInitializationInitializes a population using optimal Latin hypercube sampling as implemented in LatinHypercubeSampling.jl.
Fields:
gens::Int: Number of GA generations to use to generate the Latin hypercube samples.rng::U: Random number generator to use for the Latin hypercube sampling.pop_size::Int: Size of the GA population used to generate the Latin hypercube samples.n_tour::Int: Number of tours to use in the GA.p_tour::Float64: Probability of tour to use in the GA.inter_sample_weight::Float64: Weight of the inter-sample distance in the GA.periodic_ae::Bool: Whether to use periodic adaptive evolution in the GA.ae_power::Float64: Power of the adaptive evolution in the GA.
GlobalOptimization.LatinHypercubeInitialization — Method
LatinHypercubeInitialization(gens::Int = 10; kwargs...)Initializes a Latin hypercube sampling method with the given parameters.
Arguments
gens::Int: Number of GA generations to use to generate the Latin hypercube samples. Defaults to 10.
Keyword Arguments
rng::U: Random number generator to use for the Latin hypercube sampling. Defaults toRandom.GLOBAL_RNG.pop_size::Int: Size of the GA population used to generate the Latin hypercube samples. Defaults to 100.n_tour::Int: Number of tours to use in the GA. Defaults to 2.p_tour::Float64: Probability of tour to use in the GA. Defaults to 0.8.inter_sample_weight::Float64: Weight of the inter-sample distance in the GA. Defaults to 1.0.periodic_ae::Bool: Whether to use periodic adaptive evolution in the GA. Defaults to false.ae_power::Float64: Power of the adaptive evolution in the GA. Defaults to 2.0.
Function Evaluation Methods
GlobalOptimization.SerialFunctionEvaluation — Type
SerialFunctionEvaluationA function evaluation method that evaluates the fitness of a candidate in serial.
GlobalOptimization.SerialFunctionEvaluation — Method
SerialFunctionEvaluation()Construct a SerialFunctionEvaluation object.
GlobalOptimization.ThreadedFunctionEvaluation — Type
ThreadedFunctionEvaluation{S <: ChunkSplitters.Split}A function evaluation method that evaluates the fitness of a candidate in parallel using multi-threading from Base.Threads.jl.
Fields
n::Int: The number of batch jobs to split the workload into using ChunkSplitters.jl.split::S: The chunk splitter to use. See ChunkSplitters.jl for more information.
GlobalOptimization.ThreadedFunctionEvaluation — Method
ThreadedFunctionEvaluation(
n::Int=Threads.nthreads(),
split::S=ChunkSplitters.RoundRobin(),
)Construct a ThreadedFunctionEvaluation object.
Keyword Arguments
n::Int: The number of batch jobs to split the workload into using ChunkSplitters.jl.split::S: The chunk splitter to use. See ChunkSplitters.jl for more information.
GlobalOptimization.PolyesterFunctionEvaluation — Type
PolyesterFunctionEvaluationA function evaluation method that evaluates the fitness of a candidate in parallel using Polyester.jl.
GlobalOptimization.PolyesterFunctionEvaluation — Method
PolyesterFunctionEvaluation()Construct a PolyesterFunctionEvaluation object.
Algorithms
Particle Swarm Optimization
GlobalOptimization.PSO — Type
PSOParticle Swarm Optimization (PSO) algorithm.
GlobalOptimization.PSO — Method
PSO(prob::AbstractProblem{has_penalty,SS}; kwargs...)Constructs a PSO algorithm with the given options.
Arguments
prob::AbstractProblem{has_penalty,SS}: The problem to solve.
Keyword Arguments
eval_method::AbstractFunctionEvaluationMethod=SerialFunctionEvaluation(): The method to use for evaluating the objective function.num_particles::Int = 100: The number of particles to use.population_initialization::AbstractPopulationInitialization = UniformInitialization(): The method to use for initializing the population.velocity_update::AbstractVelocityUpdateScheme = MATLABVelocityUpdate(): The method to use for updating the velocity of the particles.initial_space::Union{Nothing,ContinuousRectangularSearchSpace}=nothing: The initial bounds for the search space.max_iterations::Integer=1000: The maximum number of iterations.function_tolerance::Real=1e-6: The function tolerance (stall-based stopping criteria).max_stall_time::Real=60.0: The maximum stall time (in seconds).max_stall_iterations::Integer=100: The maximum number of stall iterations.max_time::Real=60.0: The maximum time (in seconds) to allow for optimization.min_cost::Real=(-Inf): The minimum cost to allow for optimization.function_value_check::Union{Val{false},Val{true}}=Val(true): Whether to check the function value for bad values (i.e., Inf or NaN).show_trace::Union{Val{false},Val{true}}=Val(false): Whether to show the trace.save_trace::Union{Val{false},Val{true}}=Val(false): Whether to save the trace.save_file::String="trace.txt": The file to save the trace to.trace_level::TraceLevel=TraceMinimal(1): The trace level to use.
Returns
PSO: The PSO algorithm.
Velocity Update Schemes
The PSO velocity update is the primary mechanism that drives the stochastic optimization process. The currently implemented velocity update schemes can be described by the following:
Consider a swarm of $n$ particles $\mathcal{S} = \{\mathbf{p}_i\}_{i=1,2,\dots,n}$. Each particle $\mathbf{p}_i$ has the following attributes associated with it:
- position: $\mathbf{x}_i$
- velocity: $\mathbf{v}_i$,
- best position: $\mathbf{x}_{i,b}$
- best fitness: $f_{i,b} = f(\mathbf{x}_{i,b})$
At each iteration of the PSO algorithm, the velocity of each particle is updated prior to updating the position of each particle with $\mathbf{x}_i = \mathbf{x}_i + \mathbf{v}_i$. This velocity update is described (for the $i$-th particle) by the following expression:
$\mathbf{v}_i = w \mathbf{v}_i + y_1 \mathbf{r}_1 (\mathbf{x}_{i,b} - \mathbf{x}_i) + y_2 \mathbf{r}_2 (\mathbf{x}_b - \mathbf{x}_i)$
where $w$ is the inertia, $r_1$ and $r_2$ are realizations of a random vector described by the multivariate uniform distribution $\mathcal{U}(\mathbf{0}, \mathbf{1})$, $y_1$ is the self-adjustment weight, $y_2$ is the social adjustment weight, and $\mathbf{x}_{b}$ is the best position in the neighborhood of the $i$-th particle $\mathcal{N}_i$. That is, $\mathbf{x}_b = \underset{x\in\mathcal{X}_b}{\mathrm{argmin}}(f(x))$ where $\mathcal{X}_{b,i} = \{ \mathbf{x}_{i,b} \}_{\mathbf{p}_i \in \mathcal{N}_i}$ and $\mathcal{N}_i$ is a set containing a randomly selected subset of the particles in $\mathcal{S}$ (not including $\mathbf{p}_i$). Both the size of $\mathcal{N}_i$ and the inertia $w$ are handle differently depending on the velocity update scheme used.
GlobalOptimization.MATLABVelocityUpdate — Type
MATLABVelocityUpdate <: AbstractRandomNeighborhoodVelocityUpdateSchemeA velocity update scheme employed by the MATLAB PSO algorithm. This scheme is described as follows:
In this velocity update scheme, the size of the neighborhood, as well as the inertia weight, are adaptively updated as follows:
Prior to First Iteration:
Set the inertial weight $w$:
w = inertia_range[2]Set the minimum neighborhood size:
minimum_neighborhood_size = max(2, floor(Int, swarm_size * minimum_neighborhood_fraction))Set the neighborhood size:
N = minimum_neighborhood_sizeSet counter:
c = 0
After Evaluating Swarm Fitness Each Iteration:
- If the best fitness of the swarm has improved:
- Decrease the counter:
c = max(0, c - 1) - Set the neighborhood size to the minimum:
N = minimum_neighborhood_size - Update the inertia weight:
- If
c < 2; w = 2.0 * w - If
c > 5; w = 0.5 * w - Clamp
wto lie in[inertia_range[1], inertia_range[2]]
- If
- Decrease the counter:
- If the best fitness of the swarm has not improved:
- Increase the counter:
c += 1 - Increase the neighborhood size:
N = min(N + minimum_neighborhood_size, swarm_size - 1)
- Increase the counter:
Fields
swarm_size::Int: The size of the swarm.inertia_range::Tuple{Float64,Float64}: The range of inertia weights.minimum_neighborhood_fraction::Float64: The minimum fraction of the swarm size to be used as the neighborhood size.minimum_neighborhood_size::Int: The minimum neighborhood size.self_adjustment_weight::Float64: The self-adjustment weight.social_adjustment_weight::Float64: The social adjustment weight.w::Float64: The inertia weight.c::Int: The stall iteration counter.N::Int: The neighborhood size.index_vector::Vector{UInt16}: A vector used to store the indices of the particles in the swarm. Used for random neighborhood selection without allocations.
GlobalOptimization.MATLABVelocityUpdate — Method
MATLABVelocityUpdate(;
inertia_range::Tuple{AbstractFloat,AbstractFloat}=(0.1, 1.0),
minimum_neighborhood_fraction::AbstractFloat=0.25,
self_adjustment_weight::AbstractFloat=1.49,
social_adjustment_weight::AbstractFloat=1.49,
)Create a new instance of the MATLABVelocityUpdate velocity update scheme.
Keyword Arguments
inertia_range::Tuple{AbstractFloat,AbstractFloat}: The range of inertia weights.minimum_neighborhood_fraction::AbstractFloat: The minimum fraction of the swarm size to be used as the neighborhood size.self_adjustment_weight::AbstractFloat: The self-adjustment weight.social_adjustment_weight::AbstractFloat: The social adjustment weight.
GlobalOptimization.CSRNVelocityUpdate — Type
CSRNVelocityUpdate <: AbstractRandomNeighborhoodVelocityUpdateSchemeA velocity update scheme employed a Constant Size Random Neighborhood (CSRN).
In this velocity update scheme, the size of the neighborhood is constant and set based on the specified neighborhood_fraction (i.e., the fraction of the swarm size to be considered to lie in a neighborhood). However, the inertia is adaptively updated as follows:
Prior to First Iteration: Set the inertial weight $w$: w = inertia_range[2]
After Evaluating Swarm Fitness Each Iteration:
- If
stall_iteration < 2; w = 2.0 * w - If
stall_iteration > 5; w = 0.5 * w - Clamp
wto lie in[inertia_range[1], inertia_range[2]]
Note that stall_iteration is the number of iterations since the global best position found so far was improved by a specified function_tolerance (see PSO keyword arguments).
Fields
inertia_range::Tuple{Float64,Float64}: The range of inertia weights.neighborhood_fraction::Float64: The fraction of the swarm size to be used as the neighborhood size.N::Int: The neighborhood size.self_adjustment_weight::Float64: The self-adjustment weight.social_adjustment_weight::Float64: The social adjustment weight.w::Float64: The inertia weight.index_vector::Vector{UInt16}: A vector used to store the indices of the particles in the swarm. Used for random neighborhood selection without allocations.
GlobalOptimization.CSRNVelocityUpdate — Method
CSRNVelocityUpdate(;
inertia_range::Tuple{AbstractFloat,AbstractFloat}=(0.1, 1.0),
neighborhood_fraction::AbstractFloat=0.25,
self_adjustment_weight::AbstractFloat=1.49,
social_adjustment_weight::AbstractFloat=1.49,
)Create a new instance of the CSRNVelocityUpdate velocity update scheme.
Differential Evolution
GlobalOptimization.DE — Type
DE
Differential Evolution (DE) algorithm.
GlobalOptimization.DE — Method
DE(prob::AbstractProblem{has_penalty,SS}; kwargs...)Construct a serial Differential Evolution (DE) algorithm with the given options.
Arguments
prob::AbstractProblem{has_penalty,SS}: The problem to solve.
Keyword Arguments
eval_method::AbstractFunctionEvaluationMethod=SerialFunctionEvaluation(): The method to use for evaluating the objective function.num_candidates::Integer=100: The number of candidates in the population.population_initialization::AbstractPopulationInitialization=UniformInitialization(): The population initialization method.mutation_params::MP=SelfMutationParameters(Rand1()): The mutation strategy parameters.crossover_params::CP=BinomialCrossoverParameters(0.6): The crossover strategy parameters.initial_space::Union{Nothing,ContinuousRectangularSearchSpace}=nothing: The initial bounds for the search space.max_iterations::Integer=1000: The maximum number of iterations.function_tolerance::Real=1e-6: The function tolerance (stall-based stopping criteria).max_stall_time::Real=60.0: The maximum stall time (in seconds).max_stall_iterations::Integer=100: The maximum number of stall iterations.max_time::Real=60.0: The maximum time (in seconds) to allow for optimization.min_cost::Real=(-Inf): The minimum cost to allow for optimization.function_value_check::Union{Val{false},Val{true}}=Val(true): Whether to check the function value for bad values (i.e., Inf or NaN).show_trace::Union{Val{false},Val{true}}=Val(false): Whether to show the trace.save_trace::Union{Val{false},Val{true}}=Val(false): Whether to save the trace.save_file::String="trace.txt": The file to save the trace to.trace_level::TraceLevel=TraceMinimal(1): The trace level to use.
Mutation Parameters
GlobalOptimization.MutationParameters — Type
MutationParameters{
AS<:AbstractAdaptationStrategy,
MS<:AbstractMutationOperator,
S<:AbstractSelector,
D,
}The parameters for a DE mutation strategy that applies to all current and future candidates in the population.
Fields
F1::Float64: The F₁ weight in the unified mutation strategy.F2::Float64: The F₂ weight in the unified mutation strategy.F3::Float64: The F₃ weight in the unified mutation strategy.F4::Float64: The F₄ weight in the unified mutation strategy.sel<:AbstractSelector: The selector used to select the candidates considered in mutation.dist<:Distribution{Univariate,Continuous}: The distribution used to adapt the mutation parameters. Note that this should generally be a distribution from Distributions.jl, but the only strict requirement is that rand(dist) returns a floating point value.
GlobalOptimization.MutationParameters — Method
MutationParameters(F1, F2, F3, F4; sel=SimpleSelector())Creates a MutationParameters object with the specified (constant) mutation parameters. These constant mutation parameters are used for all candidates in the population and define a unified mutation strategy as defined in Ji Qiang and Chad Mitchell "A Unified Differential Evolution Algorithm for Global Optimization," 2014, https://www.osti.gov/servlets/purl/1163659
Arguments
F1::Float64: The F₁ weight in the unified mutation strategy.F2::Float64: The F₂ weight in the unified mutation strategy.F3::Float64: The F₃ weight in the unified mutation strategy.F4::Float64: The F₄ weight in the unified mutation strategy.
Keyword Arguments
sel::AbstractSelector: The selector used to select the candidates considered in mutation. Defaults toSimpleSelector().
Returns
MutationParameters{NoAdaptation,Unified,typeof(sel),Nothing}: A mutation parameters object with the specified mutation parameters and selector.
Examples
julia> using GlobalOptimization
julia> params = MutationParameters(0.5, 0.5, 0.5, 0.5)
MutationParameters{GlobalOptimization.NoAdaptation, Unified, SimpleSelector, Nothing}(0.5, 0.5, 0.5, 0.5, SimpleSelector(), nothing)julia> using GlobalOptimization
julia> params = MutationParameters(0.5, 0.5, 0.5, 0.5; sel=RadiusLimitedSelector(2))
MutationParameters{GlobalOptimization.NoAdaptation, Unified, RadiusLimitedSelector, Nothing}(0.5, 0.5, 0.5, 0.5, RadiusLimitedSelector(2, UInt16[0x6cf0, 0x0c33, 0x0001, 0x0000, 0x0560]), nothing)GlobalOptimization.MutationParameters — Method
MutationParameters(
strategy::MS;
dist=default_mutation_dist,
sel=SimpleSelector(),
)Creates a MutationParameters object with the specified mutation strategy with mutation parameter random adaptation. The mutation parameters are adaptively sampled from the provided dist, clamped to the range (0, 1].
Arguments
strategy::MS: The mutation strategy to use. This should be one of the mutation strategies defined in this module (e.g.,Rand1,Best2, etc.).
Keyword Arguments
dist::Distribution{Univariate,Continuous}: The distribution used to adapt the mutation parameters each iteration. Note that this should generally be a distribution from Distributions.jl, but the only strict requirement is that rand(dist) returns a floating point value. Defaults toGlobalOptimization.default_mutation_dist, which is a mixture model comprised of two Cauchy distributions, with probability density given by:$f_{mix}(x; \mu, \sigma) = 0.5 f(x;\mu_1,\sigma_1) + 0.5 f(x;\mu_2,\sigma_2)$.
where $\mu = \{0.65, 1.0\}$ and $\sigma = \{0.1, 0.1\}$.
sel::AbstractSelector: The selector used to select the candidates considered in mutation. Defaults toSimpleSelector().
Returns
MutationParameters{RandomAdaptation,typeof(strategy),typeof(sel),typeof(dist)}: A mutation parameters object with the specified mutation strategy and selector.
Examples
julia> using GlobalOptimization
julia> params = MutationParameters(Rand1())
MutationParameters{GlobalOptimization.RandomAdaptation, Rand1, SimpleSelector, Distributions.MixtureModel{Distributions.Univariate, Distributions.Continuous, Distributions.Cauchy, Distributions.Categorical{Float64, Vector{Float64}}}}(0.0, 1.0, 0.8450801042502032, 0.0, SimpleSelector(), MixtureModel{Distributions.Cauchy}(K = 2)
components[1] (prior = 0.5000): Distributions.Cauchy{Float64}(μ=0.65, σ=0.1)
components[2] (prior = 0.5000): Distributions.Cauchy{Float64}(μ=1.0, σ=0.1)
)julia> using GlobalOptimization
julia> using Distributions
julia> params = MutationParameters(Rand1(); dist=Normal(0.5, 0.1))
MutationParameters{GlobalOptimization.RandomAdaptation, Rand1, SimpleSelector, Normal{Float64}}(0.0, 1.0, 0.5061103661726901, 0.0, SimpleSelector(), Normal{Float64}(μ=0.5, σ=0.1))GlobalOptimization.SelfMutationParameters — Type
SelfMutationParameters{
AS<:AbstractAdaptationStrategy,
MS<:AbstractMutationOperator,
S<:AbstractSelector,
D,
}The parameters for a DE mutation strategy that applies a mutation strategy with unique parameters for each candidate in the population.
Fields
Fs::Vector{SVector{4,Float64}}: The mutation parameters for each candidate in the population. Each element of the vector is an SVector{4} containing the F₁, F₂, F₃, and F₄ weights for the unified mutation strategy.sel<:AbstractSelector: The selector used to select the candidates considered in mutation.dist<:Distribution{Univariate,Continuous}: The distribution used to adapt the mutation parameters. Note that this should generally be a distribution from Distributions.jl, but the only strict requirement is that rand(dist) returns a floating point value.
GlobalOptimization.SelfMutationParameters — Method
SelfMutationParameters(
strategy::MS;
dist=default_mutation_dist,
sel=SimpleSelector(),
)Creates a SelfMutationParameters object with the specified mutation strategy and mutation parameter random adaptation. The mutation parameters are adaptively sampled from the provided dist, clamped to the range (0, 1].
Arguments
strategy::MS: The mutation strategy to use. This should be one of the mutation strategies defined in this module (e.g.,Rand1,Best2, etc.).
Keyword Arguments
dist::Distribution{Univariate,Continuous}: The distribution used to adapt the mutation parameters each iteration. Note that this should generally be a distribution from Distributions.jl, but the only strict requirement is that rand(dist) returns a floating point value. Defaults toGlobalOptimization.default_mutation_dist, which is a mixture model comprised of two Cauchy distributions, with probability density given by:$f_{mix}(x; \mu, \sigma) = 0.5 f(x;\mu_1,\sigma_1) + 0.5 f(x;\mu_2,\sigma_2)$.
where $\mu = \{0.65, 1.0\}$ and $\sigma = \{0.1, 0.1\}$.
sel::AbstractSelector: The selector used to select the candidates considered in mutation. Defaults toSimpleSelector().
Returns
SelfMutationParameters{RandomAdaptation,typeof(strategy),typeof(sel),typeof(dist)}: A mutation parameters object with the specified mutation strategy and selector.
Examples
julia> using GlobalOptimization
julia> params = SelfMutationParameters(Rand1())
SelfMutationParameters{GlobalOptimization.RandomAdaptation, Rand1, SimpleSelector, MixtureModel{Univariate, Continuous, Cauchy, Categorical{Float64, Vector{Float64}}}}(StaticArraysCore.SVector{4, Float64}[], SimpleSelector(), MixtureModel{Cauchy}(K = 2)
components[1] (prior = 0.5000): Cauchy{Float64}(μ=0.65, σ=0.1)
components[2] (prior = 0.5000): Cauchy{Float64}(μ=1.0, σ=0.1)
)GlobalOptimization.Rand1 — Type
Rand1The DE/rand/1 mutation strategy given by:
$\mathbf{v}_i = \mathbf{x}_{r_1} + F\left(\mathbf{x}_{r_2} - \mathbf{x}_{r_3}\right)$
where $\mathbf{v}_i$ is the target ($i$-th) mutant, $\mathbf{x}_j$ denotes the $j$-th candidate, $F$ is a scaling factor, and $r_1$, $r_2$, and $r_3$ are randomly selected integers in the set returned by the selector.
GlobalOptimization.Rand2 — Type
Rand2The DE/rand/2 mutation strategy given by:
$\mathbf{v}_i = \mathbf{x}_{r_1} + F\left(\mathbf{x}_{r_2} - \mathbf{x}_{r_3}\right) + F\left(\mathbf{x}_{r_4} - \mathbf{x}_{r_5}\right)$
where $\mathbf{v}_i$ is the target ($i$-th) mutant, $\mathbf{x}_j$ denotes the $j$-th candidate, $F$ is a scaling factor, and $r_1$, $r_2$, $r_3$, $r_4$, and $r_5$ are randomly selected integers in the set returned by the selector.
GlobalOptimization.Best1 — Type
Best1The DE/best/1 mutation strategy given by:
$\mathbf{v}_i = \mathbf{x}_{b} + F\left(\mathbf{x}_{r_1} - \mathbf{x}_{r_2}\right)$
where $\mathbf{v}_i$ is the target ($i$-th) mutant, $\mathbf{x}_j$ denotes the $j$-th candidate, $F$ is a scaling factor, subscript $b$ denotes the best candidate (in terms of the objective/fitness function), and $r_1$ and $r_2$ are randomly selected integers in the set returned by the selector.
GlobalOptimization.Best2 — Type
Best2The DE/best/2 mutation strategy given by:
$\mathbf{v}_i = \mathbf{x}_{b} + F\left(\mathbf{x}_{r_1} - \mathbf{x}_{r_2}\right) + F\left(\mathbf{x}_{r_3} - \mathbf{x}_{r_4}\right)$
where $\mathbf{v}_i$ is the target ($i$-th) mutant, $\mathbf{x}_j$ denotes the $j$-th candidate, $F$ is a scaling factor, subscript $b$ denotes the best candidate, and $r_1$, $r_2$, $r_3$, and $r_4$ are randomly selected integers in the set returned by the selector.
GlobalOptimization.CurrentToBest1 — Type
CurrentToBest1The DE/current-to-best/1 mutation strategy given by:
$\mathbf{v}_i = \mathbf{x}_{i} + F_{cr}\left(\mathbf{x}_{b} - \mathbf{x}_{i}\right) + F\left(\mathbf{x}_{r_1} - \mathbf{x}_{r_2}\right)$
where $\mathbf{v}_i$ is the target ($i$-th) mutant, $\mathbf{x}_j$ denotes the $j$-th candidate, $F_{cs}$ and $F$ are a scaling factors, subscript $b$ denotes the best candidate, and $r_1$ and $r_2$ are randomly selected integers in the set returned by the selector.
GlobalOptimization.CurrentToBest2 — Type
CurrentToBest2The DE/current-to-best/2 mutation strategy given by:
$\mathbf{v}_i = \mathbf{x}_{i} + F_{cr}\left(\mathbf{x}_{b} - \mathbf{x}_{i}\right) + F\left(\mathbf{x}_{r_1} - \mathbf{x}_{r_2}\right) + F\left(\mathbf{x}_{r_3} - \mathbf{x}_{r_4}\right)$
where $\mathbf{v}_i$ is the target ($i$-th) mutant, $\mathbf{x}_j$ denotes the $j$-th candidate, $F_{cs}$ and $F$ are a scaling factors, subscript $b$ denotes the best candidate, and $r_1$, $r_2$, $r_3$, and $r_4$ are randomly selected integers in the set returned by the selector.
GlobalOptimization.CurrentToRand1 — Type
CurrentToRand1The DE/current-to-rand/1 mutation strategy given by:
$\mathbf{v}_i = \mathbf{x}_{i} + F_{cr}\left(\mathbf{x}_{r_1} - \mathbf{x}_{i}\right) + F\left(\mathbf{x}_{r_2} - \mathbf{x}_{r_3}\right)$
where $\mathbf{v}_i$ is the target ($i$-th) mutant, $\mathbf{x}_j$ denotes the $j$-th candidate, $F_{cs}$ and $F$ are a scaling factors, and $r_1$, $r_2$, and $r_3$ are randomly selected integers in the set returned by the selector.
GlobalOptimization.CurrentToRand2 — Type
CurrentToRand2The DE/current-to-rand/2 mutation strategy given by:
$\mathbf{v}_i = \mathbf{x}_{i} + F_{cr}\left(\mathbf{x}_{r_1} - \mathbf{x}_{i}\right) + F\left(\mathbf{x}_{r_2} - \mathbf{x}_{r_3}\right) + F\left(\mathbf{x}_{r_4} - \mathbf{x}_{r_5}\right)$
where $\mathbf{v}_i$ is the target ($i$-th) mutant, $\mathbf{x}_j$ denotes the $j$-th candidate, $F_{cs}$ and $F$ are a scaling factors, and $r_1$, $r_2$, $r_3$, $r_4$, and $r_5$ are randomly selected integers in the set returned by the selector.
GlobalOptimization.RandToBest1 — Type
RandToBest1The DE/rand-to-best/1 mutation strategy given by:
$\mathbf{v}_i = \mathbf{x}_{r_1} + F_{cr}\left(\mathbf{x}_{b} - \mathbf{x}_i\right) + F\left(\mathbf{x}_{r_2} - \mathbf{x}_{r_3}\right)$
where $\mathbf{v}_i$ is the target ($i$-th) mutant, $\mathbf{x}_j$ denotes the $j$-th candidate, $F_{cs}$ and $F$ are a scaling factors, subscript $b$ denotes the best candidate, and $r_1$, $r_2$, and $r_3$ are randomly selected integers in the set returned by the selector.
GlobalOptimization.RandToBest2 — Type
RandToBest2The DE/rand-to-best/2 mutation strategy given by:
$\mathbf{v}_i = \mathbf{x}_{r_1} + F_{cr}\left(\mathbf{x}_{b} - \mathbf{x}_i\right) + F\left(\mathbf{x}_{r_2} - \mathbf{x}_{r_3}\right) + F\left(\mathbf{x}_{r_4} - \mathbf{x}_{r_5}\right)$
where $\mathbf{v}_i$ is the target ($i$-th) mutant, $\mathbf{x}_j$ denotes the $j$-th candidate, $F_{cs}$ and $F$ are a scaling factors, subscript $b$ denotes the best candidate, and $r_1$, $r_2$, $r_3$, $r_4$, and $r_5$ are randomly selected integers in the set returned by the selector.
GlobalOptimization.Unified — Type
UnifiedThe unified DE mutation strategy proposed by Ji Qiang and Chad Mitchell in "A Unified Differential Evolution Algorithm for Global Optimization," 2014, https://www.osti.gov/servlets/purl/1163659.
This mutation strategy is given by:
$\mathbf{v}_i = \mathbf{x}_i + F_1\left(\mathbf{x}_b - \mathbf{x}_i\right) + F_2\left(\mathbf{x}_{r_1} - \mathbf{x}_i\right) + F_3\left(\mathbf{x}_{r_2} - \mathbf{x}_{r_3}\right) + F_4\left(\mathbf{x}_{r_4} - \mathbf{x}_{r_5}\right)$
where $\mathbf{v}_i$ is the target ($i$-th) mutant, $\mathbf{x}_j$ denotes the $j$-th candidate, $F_1$, $F_2$, $F_3$, and $F_4$ are scaling factors, subscript $b$ denotes the best candidate, and $r_1$, $r_2$, $r_3$, $r_4$, and $r_5$ are randomly selected integers in the set returned by the selector.
Note that in the underlying implementation, all mutation strategies are implemented with this formulation, where each unique strategy has a different set of $\{F_i : i \in \{1,2,3,4\}\}$ that are set to 0.0.
GlobalOptimization.SimpleSelector — Type
SimpleSelectorA selector that simply selects all candidates in the population.
GlobalOptimization.RadiusLimitedSelector — Type
RadiusLimitedSelectorA selector that selects candidates within a given radius of the target candidate.
For example, for population size of 10 and a radius of 2, the following will be selected for the given target indices:
target = 5 will select [3, 4, 5, 6, 7]
target = 1 will select [9, 10, 1, 2, 3]
target = 9 will select [7, 8, 9, 10, 1]
GlobalOptimization.RandomSubsetSelector — Type
RandomSubsetSelectorA selector that selects a random subset of candidates from the population. The size of the subset is determined by the size parameter.
DE Crossover Strategies
GlobalOptimization.BinomialCrossoverParameters — Type
BinomialCrossoverParameters{
AS<:AbstractAdaptationStrategy,
T<:AbstractCrossoverTransformation,
D,
}The parameters for a DE binomial crossover strategy.
Fields
CR::Float64: The crossover rate.transform::T: The transformation to apply to the candidate and mutant.dist<:Distribution{Univariate,Continuous}: The distribution used to adapt the crossover rate parameter. Note that this should generally be a distribution from Distributions.jl, but the only strict requirement is that rand(dist) returns a floating point value.
GlobalOptimization.BinomialCrossoverParameters — Method
BinomialCrossoverParameters(CR::Float64; transform=NoTransformation())Creates a BinomialCrossoverParameters object with a fixed crossover rate CR and optional transformation transform.
Arguments
CR::Float64: The crossover rate.
Keyword Arguments
transform::AbstractCrossoverTransformation: The transformation to apply to the candidate and mutant. Defaults toNoTransformation().
Returns
BinomialCrossoverParameters{NoAdaptation,typeof(transform),Nothing}: ABinomialCrossoverParametersobject with a fixed crossover rate and the optionally specified transformation.
Examples
julia> using GlobalOptimization
julia> params = BinomialCrossoverParameters(0.5)
BinomialCrossoverParameters{GlobalOptimization.NoAdaptation, GlobalOptimization.NoTransformation, Nothing}(0.5, GlobalOptimization.NoTransformation(), nothing)julia> using GlobalOptimization
julia> params = BinomialCrossoverParameters(0.5, transform=CovarianceTransformation(0.5, 0.5, 10))
BinomialCrossoverParameters{GlobalOptimization.NoAdaptation, CovarianceTransformation, Nothing}(0.5, CovarianceTransformation(0.5, 0.5, [0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0; … ; 0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]), nothing)GlobalOptimization.BinomialCrossoverParameters — Method
BinomialCrossoverParameters(; dist=default_binomial_crossover_dist, transform=NoTransformation())Creates a BinomialCrossoverParameters object with an adaptive crossover rate and optional transformation transform.
Keyword Arguments
dist::Distribution{Univariate,Continuous}: The distribution used to adapt the crossover rate parameter. Note that this should generally be a distribution from Distributions.jl, but the only strict requirement is that rand(dist) returns a floating point value. Defaults todefault_binomial_crossover_dist, which is a mixture model comprised of two Cauchy distributions, with probability density given by:$f_{mix}(x; \mu, \sigma) = 0.5 f(x;\mu_1,\sigma_1) + 0.5 f(x;\mu_2,\sigma_2)$
where $\mu = \{0.1, 0.95\}$ and $\sigma = \{0.1, 0.1\}$.
transform::AbstractCrossoverTransformation: The transformation to apply to the candidate and mutant. Defaults toNoTransformation().
Returns
BinomialCrossoverParameters{RandomAdaptation,typeof(transform),typeof(dist)}: ABinomialCrossoverParametersobject with an adaptive crossover rate and the optionally specified transformation.
Examples
julia> using GlobalOptimization
julia> params = BinomialCrossoverParameters()
BinomialCrossoverParameters{GlobalOptimization.RandomAdaptation, GlobalOptimization.NoTransformation, Distributions.MixtureModel{Distributions.Univariate, Distributions.Continuous, Distributions.Cauchy, Distributions.Categorical{Float64, Vector{Float64}}}}(0.0, GlobalOptimization.NoTransformation(), MixtureModel{Distributions.Cauchy}(K = 2)
components[1] (prior = 0.5000): Distributions.Cauchy{Float64}(μ=0.1, σ=0.1)
components[2] (prior = 0.5000): Distributions.Cauchy{Float64}(μ=0.95, σ=0.1)
)julia> using GlobalOptimization
julia> params = BinomialCrossoverParameters(transform=CovarianceTransformation(0.5, 0.5, 10))
BinomialCrossoverParameters{GlobalOptimization.RandomAdaptation, CovarianceTransformation, Distributions.MixtureModel{Distributions.Univariate, Distributions.Continuous, Distributions.Cauchy, Distributions.Categorical{Float64, Vector{Float64}}}}(0.0, CovarianceTransformation(0.5, 0.5, [2.195780764e-314 2.2117846174e-314 … 2.1293782266e-314 1.5617889024864e-311; 2.366805627e-314 2.316670011e-314 … 2.3355803934e-314 1.4259811738567e-311; … ; 2.195781025e-314 2.195781096e-314 … 1.4531427176862e-310 1.27319747493e-313; 2.366805627e-314 2.366805627e-314 … 1.0270459628367e-310 2.121995795e-314], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]), MixtureModel{Distributions.Cauchy}(K = 2)
components[1] (prior = 0.5000): Distributions.Cauchy{Float64}(μ=0.1, σ=0.1)
components[2] (prior = 0.5000): Distributions.Cauchy{Float64}(μ=0.95, σ=0.1)
)julia> using GlobalOptimization
julia> using Distributions
julia> params = BinomialCrossoverParameters(dist=Uniform(0.0, 1.0))
BinomialCrossoverParameters{GlobalOptimization.RandomAdaptation, GlobalOptimization.NoTransformation, Uniform{Float64}}(0.0, GlobalOptimization.NoTransformation(), Uniform{Float64}(a=0.0, b=1.0))GlobalOptimization.SelfBinomialCrossoverParameters — Type
SelfBinomialCrossoverParameters{
AS<:AbstractAdaptationStrategy,
T<:AbstractCrossoverTransformation,
D,
}The parameters for a DE self-adaptive binomial crossover strategy.
Fields
CRs::Vector{Float64}: The crossover rates for each candidate in the population.transform::T: The transformation to apply to the candidate and mutant.dist<:Distribution{Univariate,Continuous}: The distribution used to adapt the crossover rate parameter. Note that this should generally be a distribution from Distributions.jl, but the only strict requirement is that rand(dist) returns a floating point value.
GlobalOptimization.SelfBinomialCrossoverParameters — Method
SelfBinomialCrossoverParameters(;
dist=default_binomial_crossover_dist,
transform=NoTransformation()
)Creates a SelfBinomialCrossoverParameters object with an adaptive crossover rate for each candidate in the population and an optional transformation transform.
Keyword Arguments
dist::Distribution{Univariate,Continuous}: The distribution used to adapt the crossover rate parameter. Note that this should generally be a distribution from Distributions.jl, but the only strict requirement is that rand(dist) returns a floating point value. Defaults todefault_binomial_crossover_dist, which is a mixture model comprised of two Cauchy distributions, with probability density given by:$f_{mix}(x; \mu, \sigma) = 0.5 f(x;\mu_1,\sigma_1) + 0.5 f(x;\mu_2,\sigma_2)$
where $\mu = \{0.1, 0.95\}$ and $\sigma = \{0.1, 0.1\}$.
transform::AbstractCrossoverTransformation: The transformation to apply to the candidate and mutant. Defaults toNoTransformation().
Returns
SelfBinomialCrossoverParameters{RandomAdaptation,typeof(transform),typeof(dist)}: ASelfBinomialCrossoverParametersobject with an adaptive crossover rate for each candidate and the optionally specified transformation.
Examples
julia> using GlobalOptimization
julia> params = SelfBinomialCrossoverParameters()
SelfBinomialCrossoverParameters{GlobalOptimization.RandomAdaptation, GlobalOptimization.NoTransformation, MixtureModel{Univariate, Continuous, Cauchy, Categorical{Float64, Vector{Float64}}}}(Float64[], GlobalOptimization.NoTransformation(), MixtureModel{Cauchy}(K = 2)
components[1] (prior = 0.5000): Cauchy{Float64}(μ=0.1, σ=0.1)
components[2] (prior = 0.5000): Cauchy{Float64}(μ=0.95, σ=0.1)
)GlobalOptimization.CovarianceTransformation — Type
CovarianceTransformation{T<:AbstractCrossoverTransformation}A transformation for performing crossover in the eigen-space of the covariance matrix of the best candidates in the population.
This is an implementation of the method proposed by Wang and Li in "Differential Evolution Based on Covariance Matrix Learning and Bimodal Distribution Parameter Setting, " 2014, DOI: 10.1016/j.asoc.2014.01.038.
Fields
ps::Float64: The proportion of candidates to consider in the covariance matrix. That is, for a population size ofN, the covariance matrix is calculated using theclamp(ceil(ps * N), 2, N)best candidates.pb::Float64: The probability of applying the transformation.B::Matrix{Float64}: The real part of the eigenvectors of the covariance matrix.ct::Vector{Float64}: The transformed candidate.mt::Vector{Float64}: The transformed mutant.
GlobalOptimization.CovarianceTransformation — Method
CovarianceTransformation(ps::Float64, pb::Float64, num_dims::Int)Creates a CovarianceTransformation object with the specified proportion of candidates to consider in the covariance matrix ps, the probability of applying the transformation pb, and the number of dimensions num_dims.
This is an implementation of the method proposed by Wang and Li in "Differential Evolution Based on Covariance Matrix Learning and Bimodal Distribution Parameter Setting, " 2014, DOI: 10.1016/j.asoc.2014.01.038.
Arguments
ps::Float64: The proportion of candidates to consider in the covariance matrix.pb::Float64: The probability of applying the transformation.num_dims::Int: The number of dimensions in the search space.
Returns
CovarianceTransformation: ACovarianceTransformationobject with the specified parameters.
Examples
julia> using GlobalOptimization
julia> transformation = CovarianceTransformation(0.5, 0.5, 10)
CovarianceTransformation(0.5, 0.5, [2.3352254645e-314 6.3877104275e-314 … 1.0e-323 5.0e-324; 6.3877051114e-314 6.3877104196e-314 … 6.3877054276e-314 6.387705455e-314; … ; 2.3352254645e-314 2.333217732e-314 … 0.0 6.3877095184e-314; 6.387705143e-314 2.130067282e-314 … 6.387705459e-314 6.387705463e-314], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])GlobalOptimization.UncorrelatedCovarianceTransformation — Type
UncorrelatedCovarianceTransformation{T<:AbstractCrossoverTransformation}A transformation for performing crossover in the eigen-space of the covariance matrix of the best candidates in the population which are also not too closely correlated.
This is an implementation of the method proposed by Wang and Li in "Differential Evolution Based on Covariance Matrix Learning and Bimodal Distribution Parameter Setting, " 2014, DOI: 10.1016/j.asoc.2014.01.038.
Correlation alteration based on "Covariance Matrix Learning Differential Evolution Algorithm Based on Correlation" DOI: https://doi.org/10.4236/ijis.2021.111002
Fields
ps::Float64: The proportion of candidates to consider in the covariance matrix. That is, for a population size ofNwithMcandidates remaining after the correlation check, the covariance matrix is calculated using theclamp(ceil(ps * M), 2, M)best candidates.pb::Float64: The probability of applying the transformation.a::Float64: The correlation threshold for which two candidates are considered 'too close' to both be used in the covariance matrix construction.B::Matrix{Float64}: The real part of the eigenvectors of the covariance matrix.ct::Vector{Float64}: The transformed candidate.mt::Vector{Float64}: The transformed mutant.idxs::Vector{UInt16}: A vector of indexes for the populationcidxs::Vector{UInt16}: A vector of uniquecorrelatedindexes for the population set for removal
GlobalOptimization.UncorrelatedCovarianceTransformation — Method
UncorrelatedCovarianceTransformation{T<:AbstractCrossoverTransformation}A transformation for performing crossover in the eigen-space of the covariance matrix of the best candidates in the population which are also not too closely correlated.
This is an implementation of the method proposed by Yuan and Feng in "Covariance Matrix Learning Differential Evolution Algorithm Based on Correlation" DOI: https://doi.org/10.4236/ijis.2021.111002
Arguments
pb::Float64: The probability of applying the transformation.a::Float64: The correlation threshold for two candidates being 'too close'.num_dims::Int: The number of dimensions in the search space.
Keyword Arguments:
ps::Float64: The proportion of candidates to consider in the covariance matrix. Defaults to 1.0 (i.e., all uncorrelated candidates are considered)
Returns
UncorrelatedCovarianceTransformation: AUncorrelatedCovarianceTransformationobject with the specified parameters.
Examples
julia> using GlobalOptimization
julia> transformation = UncorrelatedCovarianceTransformation(0.5, .95, 10; ps = 1.0)
UncorrelatedCovarianceTransformation(1.0, 0.5, 0.95, [1.0630691323565e-311 1.0630691151907e-311 … 1.063069230316e-311 1.063069119645e-311; 1.0630691158705e-311 1.063069115333e-311 … 1.063069172704e-311 1.0630692904614e-311; … ; 1.063069115428e-311 1.063069114246e-311 … 1.063069124886e-311 1.0630694190924e-311; 1.0630691153804e-311 1.0630691141986e-311 … 1.0630691348624e-311 1.063069428614e-311], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], UInt16[], UInt16[])Monotonic Basin Hopping
GlobalOptimization.MBH — Type
MBHMonotonic Basin Hopping (MBH) algorithm.
This implementation employs a single candidate rather than a population.
GlobalOptimization.MBH — Method
MBH(prob::AbstractOptimizationProblem{SS}; kwargs...)Construct the standard Monotonic Basin Hopping (MBJ) algorithm with the specified options.
Keyword Arguments
hopper_type::AbstractHopperType: The type of hopper to use. Default isSingleHopper().hop_distribution::AbstractMBHDistribution{T}: The distribution from which hops are drawn. Default isMBHAdaptiveDistribution{T}(100, 5).local_search::AbstractLocalSearch{T}: The local search algorithm to use. Default isLBFGSLocalSearch{T}().initial_space::Union{Nothing,ContinuousRectangularSearchSpace}=nothing: The initial bounds for the search space.max_iterations::Integer=1000: The maximum number of iterations.function_tolerance::Real=1e-6: The function tolerance (stall-based stopping criteria).max_stall_time::Real=60.0: The maximum stall time (in seconds).max_stall_iterations::Integer=100: The maximum number of stall iterations.max_time::Real=60.0: The maximum time (in seconds) to allow for optimization.min_cost::Real=(-Inf): The minimum cost to allow for optimization.function_value_check::Union{Val{false},Val{true}}=Val(true): Whether to check the function value for bad values (i.e., Inf or NaN).show_trace::Union{Val{false},Val{true}}=Val(false): Whether to show the trace.save_trace::Union{Val{false},Val{true}}=Val(false): Whether to save the trace.save_file::String="trace.txt": The file to save the trace to.trace_level::TraceLevel=TraceMinimal(1): The trace level to use.
Hopper Types
GlobalOptimization.MCH — Type
MCH{EM<:AbstractFunctionEvaluationMethod} <: GlobalOptimization.AbstractHopperTypeEmploys the method of Multiple Communicating Hoppers (MCH) to explore the search space as described in Englander, Arnold C., "Speeding-Up a Random Search for the Global Minimum of a Non-Convex, Non-Smooth Objective Function" (2021). Doctoral Dissertations. 2569. https://scholars.unh.edu/dissertation/2569.
The struct fields are the same as the constructor arguments.
GlobalOptimization.MCH — Method
MCH(;
num_hoppers::Integer=4,
eval_method<:AbstractFunctionEvaluationMethod=SerialFunctionEvaluation(),
)Constructs a new MCH object with the specified number of hoppers and evaluation method.
Keyword Arguments
num_hoppers::Integer: The number of hoppers to use. Default is 4.eval_method<:AbstractFunctionEvaluationMethod: The evaluation method to use. Default isSerialFunctionEvaluation().
GlobalOptimization.SingleHopper — Type
SingleHopper <: GlobalOptimization.AbstractHopperTypeA single hopper that is used to explore the search space. Note that no parallelism is employed.
Hop Distributions
GlobalOptimization.MBHAdaptiveDistribution — Type
MBHAdaptiveDistribution{T}An adaptive distribution for MBH. In this implementation, each element of a hop is drawn from a univariate adaptive mixture model comprised of two Laplace distributions as defined in Englander, Arnold C., "Speeding-Up a Random Search for the Global Minimum of a Non-Convex, Non-Smooth Objective Function" (2021). Doctoral Dissertations. 2569. https://scholars.unh.edu/dissertation/2569.
The univariate mixture model for the $i$-th element of a hop has a PDF given by:
$f_{\text{mix},i}(x; b, c, \hat{\lambda}_i) = k_i\left[(1 - b) f(x;\mu = 0,\theta = c*\hat{\lambda}_i) + b f(x;\mu = 0, \theta = 1)\right]$
where $\mu$ denotes the location parameter and $\theta$ the scale parameter of a Laplace distribution (i.e., with probability density $f(x;\mu,\theta)$). Note that $k_i$ denotes half of the length of the search space in the $i$-th dimension.
The scale parameter $\hat{\lambda}_i$ is adaptively updated after each successful hop with a low-delay estimate given by:
$\hat{\lambda}_i = (1 - a) \Psi_i + a \hat{\lambda}_i$
Note that $\hat{\lambda}_i$ is held constant at λhat0 until min_memory_update successful steps have been made. Englander (2021) proposed taking $\Psi_i$ to be the standard deviation of the $i$-th element of the last step_memory successful hops. Alternatively, the mean absolute deviation (MAD) around the median of the last step_memory steps can be used. Note that the MAD median is the maximum likelihood estimator for a Laplace distribution's shape parameter. In this implementation, setting use_mad = true will take $\Psi_i$ to be the MAD median, otherwise, the standard deviation is used.
Fields
step_memory::MBHStepMemoory{T}: The step memory for the distributionmin_memory_update::Int: The minimum number of steps in memory before updating the scale parametera: A parameter that defines the influence of a new successful step in the adaptation of the distribution.b::T: The mixing parameter for the two Laplace distributionsc::T: The scale parameter for the first Laplace distributionλhat::Vector{T}: The estimated scale parameter of the first Laplace distributionλhat0::T: The initial value of the scale parameteruse_mad::Bool: Flag to indicate if we will use the STD (proposed by Englander) or MAD median (MVE) to update the estimated scale parameterdim_delta::Vector{T}: The length of the search space in each dimension
GlobalOptimization.MBHAdaptiveDistribution — Method
MBHAdaptiveDistribution{T}(
memory_len::Int, min_memory_update::Int;
a=0.93,
b=0.05,
c=1.0,
λhat0=1.0,
) where TCreates a new MBHAdaptiveDistribution with the given parameters.
Arguments
memory_len::Int: The length of the memory for the distribution adaptation.min_memory_update::Int: The minimum number of steps in memory before updating the scale parameter.
Keyword Arguments
a: A parameter that defines the influence of a new successful step in the adaptation of the distribution.b: The mixing parameter for the two Laplace distributionsc: The scale parameter for the first Laplace distributionλhat0: The initial value of the scale parameteruse_mad::Bool: Flag to indicate which metric to use for estimating the scale parameter. Iftrue, the MAD median is used, which is the maximum likelihood estimator for a Laplace distribution's shape parameter. Iffalse, the standard deviation is used as proposed by Englander (2021).
GlobalOptimization.MBHStaticDistribution — Type
MBHStaticDistribution{T}A static distribution for MBH. In this implementation, each element of a hop is drawn from a mixture model comprised of two Laplace distributions with PDF given by:
$f_{mix}(x; b, \lambda) = k_i\left[(1 - b) f(x;\mu = 0,\theta = \lambda) + b f(x;\mu = 0, \theta = 1)\right]$
where $\mu$ denotes the location parameter and $\theta$ the scale parameter of a Laplace distribution (i.e., with probability density $f(x;\mu,\theta)$). Additionally, $k_i$ is half of the length of the search space in the $i$-th dimension.
Fields
b::T: The mixing parameter for the two Laplace distributionsλ::T: The scale parameter for the first Laplace distribution in the mixture modeldim_delta::Vector{T}: The length of the search space in each dimension
GlobalOptimization.MBHStaticDistribution — Method
MBHStaticDistribution{T}(; b=0.05, λ=0.7) where {T}Creates a new MBHStaticDistribution with the given parameters.
Keyword Arguments
b: The mixing parameter for the two Laplace distributionsλ: The scale parameter for the first Laplace distribution in the mixture model
Local Search Methods
GlobalOptimization.LocalStochasticSearch — Type
LocalStochasticSearch{T}A local search algorithm that uses a stochastic approach to locally improve the candidate solution.
Note that this local search algorithm is able to guarantee satisfaction of both the box constraints and the nonlinear inequality constraint (if any).
Fields
b::T: The local step standard deviation.iters::Int: The number of iterations to perform.step::Vector{T}: The candidate step and candidate storage.
GlobalOptimization.LocalStochasticSearch — Method
LocalStochasticSearch{T}(b::Real, iters::Int) where {T<:AbstractFloat}Create a new LocalStochasticSearch object with the given step size and number of iterations.
Arguments
b::Real: The local step standard deviation.iters::Int: The number of iterations to perform.
GlobalOptimization.UserLocalSearch — Type
UserLocalSearch{T,F<:Function}
A user provided local search algorithm to locally improve the candidate solution.
# Fields
- `user_search_fun!::F`: The user provided function. This must accept a Hopper{T} as the
first argument and an evaluator as the second, mutating the Hopper{T} after
performing the local search. The user defined local search should ensure that the
final solution is feasible (checking that it resides in the search space and that
penalty is approximately zero -- see LocalStochasticSearch search implementation for
an example), and should set the candidate fitness via
evaluate_with_penalty(evaluator, new_candidate).GlobalOptimization.UserLocalSearch — Method
UserLocalSearch{T}(user_search_fun!::F) where {T<:AbstractFloat,F<:Function}Create a new UserLocalSearch object with the provided user_search_fun!.
Note that this essentially exposes the entire MBH local search step to the user. Thus, care must be taken to ensure candidates updated via the user defined algorithm are feasible and actually improve the objective/fitness function. If this is not done, erroneous results may be produced.
Arguments
user_search_fun::F:The user provided function. This must accept a Hopper{T} as the first argument and an evaluator as the second, mutating the Hopper{T} after performing the local search. The user defined local search should ensure that the final solution is feasible (checking that it resides in the search space and that penalty is approximately zero – see LocalStochasticSearch search implementation for an example), and should set the candidate fitness via evaluatewithpenalty(evaluator, new_candidate).
Trace Options
Each algorithm provides the ability trace solve information to the terminal or a specified file through setting the keyword arguments show_trace = Val(true) and save_trace = Val(true), respectively. Additionally, the amount of information provided in the trace can be controlled by setting the trace_level keyword argument with one of the following TraceLevel constructors:
GlobalOptimization.TraceMinimal — Method
TraceMinimal(freq)
TraceMinimal(; print_frequency = 1, save_frequency = 1)Trace Minimal information about the optimization process.
For example, this will set PSO or DE to print the elapsed time, iteration number, stall iterations, and global best fitness.
Returns
TraceLevel{Val{:minimal}}: A trace level object with the minimal trace level.
GlobalOptimization.TraceDetailed — Method
TraceDetailed(freq)
TraceDetailed(; print_frequency = 1, save_frequency = 1)Trace Detailed information about the optimization process (including the information in the minimal trace).
Returns
TraceLevel{Val{:detailed}}: A trace level object with the detailed trace level.
GlobalOptimization.TraceAll — Method
TraceAll(freq)
TraceAll(; print_frequency = 1, save_frequency = 1)Trace All information about the optimization process (including the information in the detailed trace). This trace option should likely only be used for debugging purposes.
Returns
TraceLevel{Val{:all}}: A trace level object with the all trace level.
Index
GlobalOptimization.Best1GlobalOptimization.Best2GlobalOptimization.BinomialCrossoverParametersGlobalOptimization.BinomialCrossoverParametersGlobalOptimization.BinomialCrossoverParametersGlobalOptimization.CSRNVelocityUpdateGlobalOptimization.CSRNVelocityUpdateGlobalOptimization.ContinuousRectangularSearchSpaceGlobalOptimization.ContinuousRectangularSearchSpaceGlobalOptimization.CovarianceTransformationGlobalOptimization.CovarianceTransformationGlobalOptimization.CurrentToBest1GlobalOptimization.CurrentToBest2GlobalOptimization.CurrentToRand1GlobalOptimization.CurrentToRand2GlobalOptimization.DEGlobalOptimization.DEGlobalOptimization.LatinHypercubeInitializationGlobalOptimization.LatinHypercubeInitializationGlobalOptimization.LocalStochasticSearchGlobalOptimization.LocalStochasticSearchGlobalOptimization.MATLABVelocityUpdateGlobalOptimization.MATLABVelocityUpdateGlobalOptimization.MBHGlobalOptimization.MBHGlobalOptimization.MBHAdaptiveDistributionGlobalOptimization.MBHAdaptiveDistributionGlobalOptimization.MBHStaticDistributionGlobalOptimization.MBHStaticDistributionGlobalOptimization.MCHGlobalOptimization.MCHGlobalOptimization.MutationParametersGlobalOptimization.MutationParametersGlobalOptimization.MutationParametersGlobalOptimization.NonlinearLeastSquaresProblemGlobalOptimization.NonlinearLeastSquaresProblemGlobalOptimization.NonlinearLeastSquaresProblemGlobalOptimization.NonlinearLeastSquaresProblemGlobalOptimization.NonlinearProblemGlobalOptimization.NonlinearProblemGlobalOptimization.NonlinearProblemGlobalOptimization.NonlinearProblemGlobalOptimization.OptimizationProblemGlobalOptimization.OptimizationProblemGlobalOptimization.OptimizationProblemGlobalOptimization.OptimizationProblemGlobalOptimization.PSOGlobalOptimization.PSOGlobalOptimization.PolyesterFunctionEvaluationGlobalOptimization.PolyesterFunctionEvaluationGlobalOptimization.RadiusLimitedSelectorGlobalOptimization.Rand1GlobalOptimization.Rand2GlobalOptimization.RandToBest1GlobalOptimization.RandToBest2GlobalOptimization.RandomSubsetSelectorGlobalOptimization.SelfBinomialCrossoverParametersGlobalOptimization.SelfBinomialCrossoverParametersGlobalOptimization.SelfMutationParametersGlobalOptimization.SelfMutationParametersGlobalOptimization.SerialFunctionEvaluationGlobalOptimization.SerialFunctionEvaluationGlobalOptimization.SimpleSelectorGlobalOptimization.SingleHopperGlobalOptimization.ThreadedFunctionEvaluationGlobalOptimization.ThreadedFunctionEvaluationGlobalOptimization.UncorrelatedCovarianceTransformationGlobalOptimization.UncorrelatedCovarianceTransformationGlobalOptimization.UnifiedGlobalOptimization.UserLocalSearchGlobalOptimization.UserLocalSearchGlobalOptimization.TraceAllGlobalOptimization.TraceDetailedGlobalOptimization.TraceMinimalGlobalOptimization.optimize!