-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
6,468 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
/Manifest.toml | ||
/docs/Manifest.toml | ||
/docs/build/ | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Numerical optimisation | ||
function optimise(fun, θ₀, lb, ub; | ||
dv = false, | ||
method = dv ? :LD_LBFGS : :LN_BOBYQA, | ||
) | ||
|
||
if dv || String(method)[2] == 'D' | ||
tomax = fun | ||
else | ||
tomax = (θ,∂θ) -> fun(θ) | ||
end | ||
|
||
opt = Opt(method,length(θ₀)) | ||
opt.max_objective = tomax | ||
opt.lower_bounds = lb # Lower bound | ||
opt.upper_bounds = ub # Upper bound | ||
opt.local_optimizer = Opt(:LN_NELDERMEAD, length(θ₀)) | ||
res = optimize(opt, θ₀) | ||
return res[[2,1]] | ||
end | ||
|
||
function optimise_unbounded(fun, θ₀; | ||
dv = false, | ||
method = dv ? :LD_LBFGS : :LN_BOBYQA, | ||
) | ||
|
||
if dv || String(method)[2] == 'D' | ||
tomax = fun | ||
else | ||
tomax = (θ,∂θ) -> fun(θ) | ||
end | ||
|
||
opt = Opt(method,length(θ₀)) | ||
opt.max_objective = tomax | ||
opt.local_optimizer = Opt(:LN_NELDERMEAD, length(θ₀)) | ||
res = optimize(opt, θ₀) | ||
return res[[2,1]] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,100 @@ | ||
module PlaceholderLikelihood | ||
|
||
# Write your package code here. | ||
using NLopt, Roots | ||
using ForwardDiff, LinearAlgebra | ||
using Random, StatsBase, Combinatorics | ||
using DataStructures, DataFrames, Accessors, StaticArrays | ||
using EllipseSampling | ||
using LatinHypercubeSampling | ||
using Distributed, FLoops | ||
using ConcaveHull | ||
using Distances, TravelingSalesmanHeuristics | ||
using Clustering, Meshes | ||
using AngleBetweenVectors | ||
using TrackingHeaps | ||
|
||
using ProgressMeter | ||
const global PROGRESS__METER__DT = 1.0 | ||
|
||
|
||
export AbstractEllipseMLEApprox, AbstractCoreLikelihoodModel, AbstractLikelihoodModel, | ||
EllipseMLEApprox, CoreLikelihoodModel, LikelihoodModel, | ||
|
||
AbstractProfileType, AbstractEllipseProfileType, LogLikelihood, EllipseApprox, EllipseApproxAnalytical | ||
AbstractSampleType, UniformGridSamples, UniformRandomSamples, LatinHypercubeSamples | ||
|
||
AbstractConfidenceStruct, PointsAndLogLikelihood, | ||
SampledConfidenceStruct, UnivariateConfidenceStruct, BivariateConfidenceStruct, | ||
|
||
AbstractBivariateMethod, AbstractBivariateVectorMethod, bivariate_methods, | ||
IterativeBoundaryMethod, RadialMLEMethod, RadialRandomMethod, SimultaneousMethod, Fix1AxisMethod, | ||
AnalyticalEllipseMethod, ContinuationMethod, | ||
|
||
AbstractPredictionStruct, PredictionStruct, | ||
|
||
initialiseLikelihoodModel, | ||
getMLE_ellipse_approximation!, check_ellipse_approx_exists! | ||
setθmagnitudes!, setbounds!, | ||
|
||
transformbounds, transformbounds_NLopt, | ||
|
||
univariate_confidenceintervals!, get_points_in_interval!, | ||
bivariate_confidenceprofiles!, minimum_perimeter_polygon!, | ||
dimensional_likelihood_sample!, bivariate_concave_hull, | ||
full_likelihood_sample!, | ||
|
||
add_prediction_function!, check_prediction_function_exists, | ||
generate_predictions_bivariate!, generate_predictions_univariate!, generate_predictions_dim_samples! | ||
|
||
include("NLopt_optimiser.jl") | ||
|
||
# TYPES ############################################################## | ||
include("types/bivariate_methods.jl") | ||
include("types/levelsets.jl") | ||
include("types/predictions.jl") | ||
include("types/profiletype.jl") | ||
include("types/likelihoodmodel.jl") | ||
|
||
|
||
include("model_initialiser.jl") | ||
# include("combination_relationships.jl") | ||
include("transform_bounds.jl") | ||
include("common_profile_likelihood.jl") | ||
include("ellipse_likelihood.jl") | ||
include("predictions.jl") | ||
include("plotting_functions.jl") | ||
|
||
|
||
# UNIVARIATE METHODS ################################################# | ||
include("univariate_methods/init_and_array_mapping.jl") | ||
include("univariate_methods/loglikelihood_functions.jl") | ||
include("univariate_methods/univariate_profile_likelihood.jl") | ||
include("univariate_methods/points_in_interval.jl") | ||
|
||
|
||
# BIVARIATE METHODS ################################################## | ||
include("bivariate_methods/init_and_array_mapping.jl") | ||
include("bivariate_methods/findpointon2Dbounds.jl") | ||
include("bivariate_methods/loglikelihood_functions.jl") | ||
include("bivariate_methods/fix1axis.jl") | ||
include("bivariate_methods/vectorsearch.jl") | ||
include("bivariate_methods/continuation_polygon_manipulation.jl") | ||
include("bivariate_methods/continuation.jl") | ||
include("bivariate_methods/iterativeboundary.jl") | ||
include("bivariate_methods/bivariate_profile_likelihood.jl") | ||
include("bivariate_methods/MPP_TSP.jl") | ||
|
||
|
||
# SAMPLING METHODS ################################################### | ||
include("dimensional_methods/full_likelihood_sampling.jl") | ||
include("dimensional_methods/dimensional_likelihood_sampling.jl") | ||
include("dimensional_methods/bivariate_concave_hull.jl") | ||
|
||
|
||
import SnoopPrecompile | ||
|
||
SnoopPrecompile.@precompile_all_calls begin | ||
1==2 | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
""" | ||
minimum_perimeter_polygon!(points::Array{<:Real,2}) | ||
Given a set of N points that define a boundary polygon in a 2 row, N column array, solve a minimum perimeter polygon TSP problem, reorder these points in place and return the path used (vertices in order of visitation). Uses [TravelingSalesmanHeuristics.jl](https://github.com/evanfields/TravelingSalesmanHeuristics.jl). | ||
""" | ||
function minimum_perimeter_polygon!(points::Array{<:Real,2}) | ||
Dij = pairwise(Euclidean(), points, dims=2) | ||
path, _ = solve_tsp(Dij) | ||
points .= points[:,path[1:end-1]] | ||
return path | ||
end |
Oops, something went wrong.