From bd59ba10bb4131cefcaca1ce8870d90acc2c7ac6 Mon Sep 17 00:00:00 2001 From: JoelTrent <79883375+JoelTrent@users.noreply.github.com> Date: Wed, 28 Jun 2023 18:06:26 +1200 Subject: [PATCH] Improve performance of simultaneous method by allowing one of the internal or external points vectors to contain non-unique points for point pairs (using random numbers more efficiently) --- .../bivariate_profile_likelihood.jl | 9 +++-- src/bivariate_methods/vectorsearch.jl | 35 ++++++++++++++++--- src/types/bivariate_methods.jl | 31 ++++++++++++---- 3 files changed, 59 insertions(+), 16 deletions(-) diff --git a/src/bivariate_methods/bivariate_profile_likelihood.jl b/src/bivariate_methods/bivariate_profile_likelihood.jl index b7d0d1f..953d38e 100644 --- a/src/bivariate_methods/bivariate_profile_likelihood.jl +++ b/src/bivariate_methods/bivariate_profile_likelihood.jl @@ -177,7 +177,8 @@ function bivariate_confidenceprofile(bivariate_optimiser::Function, boundary, internal = bivariate_confidenceprofile_vectorsearch( bivariate_optimiser, model, num_points, consistent, ind1, ind2, - mle_targetll, save_internal_points, channel) + mle_targetll, save_internal_points, channel, + min_proportion_unique=method.min_proportion_unique) elseif method isa RadialRandomMethod boundary, internal = bivariate_confidenceprofile_vectorsearch( @@ -370,10 +371,8 @@ function bivariate_confidenceprofiles!(model::LikelihoodModel, len_θcombinations = length(θcombinations) len_θcombinations > 0 || return nothing - - - tasks_per_profile = get_bivariate_method_tasknumbers(method, num_points) - totaltasks = tasks_per_profile * len_θcombinations + tasks_per_profile = get_bivariate_method_tasknumbers.(Ref(method), num_new_points) + totaltasks = sum(tasks_per_profile) # channel_buffer_size = min(ceil(Int, tasks_per_profile * 0.05), 30) channel_buffer_size = 2 channel = RemoteChannel(() -> Channel{Bool}(channel_buffer_size)) diff --git a/src/bivariate_methods/vectorsearch.jl b/src/bivariate_methods/vectorsearch.jl index 56718ec..8ac8b22 100644 --- a/src/bivariate_methods/vectorsearch.jl +++ b/src/bivariate_methods/vectorsearch.jl @@ -16,13 +16,16 @@ function findNpointpairs_simultaneous!(p::NamedTuple, ind2::Int, mle_targetll::Float64, save_internal_points::Bool, - biv_opt_is_ellipse_analytical::Bool) + biv_opt_is_ellipse_analytical::Bool, + min_proportion_unique::Real) internal = zeros(2,num_points) internal_all = zeros(model.core.num_pars, save_internal_points ? num_points : 0) ll_values = zeros(save_internal_points ? num_points : 0) external = zeros(2,num_points) + min_num_unique = ceil(Int, min_proportion_unique*num_points) + Ninside=0; Noutside=0 iters=0 while Noutside 1). @@ -253,18 +261,27 @@ This method can find multiple boundaries (if they exist). ## Impact of parameter bounds -If a parameter bound is in the way of reaching the boundary, points will not be put on that bound. Additionally, if the true boundary is very close to a parameter bound, the method will struggle to find this region of the boundary. This is because finding the boundary in this location requires generating a random point between the boundary and the parameter bound, which becomes more difficult the closer they are. Interest parameter bounds that have ranges magnitudes larger than the range of the boundary will make finding internal points very difficult, requiring a lot of computational effort. Similarly, the inverse will be true if external points are hard to find. The method will fail if the interest parameter bounds are fully contained by the boundary. +If a parameter bound is in the way of reaching the boundary, points will not be put on that bound. Additionally, if the true boundary is very close to a parameter bound, the method will struggle to find this region of the boundary. This is because finding the boundary in this location requires generating a random point between the boundary and the parameter bound, which becomes more difficult the closer they are. + +Interest parameter bounds that have ranges magnitudes larger than the range of the boundary will make finding internal points difficult, requiring a lot of computational effort. Similarly, the inverse will be true if external points are hard to find. Smaller values of `min_proportion_unique` will improve performance in these cases. + +The method will fail if the interest parameter bounds are fully contained by the boundary. # Internal Points -Finds `num_points` internal points. +Finds at least `ceil(min_proportion_unique * num_points)` internal points. # Supertype Hiearachy `SimultaneousMethod <: AbstractBivariateVectorMethod <: AbstractBivariateMethod <: Any` """ -struct SimultaneousMethod <: AbstractBivariateVectorMethod end - +struct SimultaneousMethod <: AbstractBivariateVectorMethod + min_proportion_unique::Real + function SimultaneousMethod(min_proportion_unique::Real=0.5) + (0.0 < min_proportion_unique && min_proportion_unique <= 1.0) || throw(DomainError("min_proportion_unique must be in the interval (0.0,1.0]")) + return new(min_proportion_unique) + end +end """ Fix1AxisMethod()