Skip to content

Commit

Permalink
Add dependencies and initial files
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelTrent committed Jun 12, 2023
1 parent 5e1bef3 commit 6e4dce5
Show file tree
Hide file tree
Showing 33 changed files with 6,468 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/Manifest.toml
/docs/Manifest.toml
/docs/build/
.vscode
26 changes: 26 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,32 @@ uuid = "af9eadfc-028e-4dd7-8324-1a9c134c7af2"
authors = ["JoelTrent <79883375+JoelTrent@users.noreply.github.com> and contributors"]
version = "1.0.0-DEV"

[deps]
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
AngleBetweenVectors = "ec570357-d46e-52ed-9726-18773498274d"
Clustering = "aaaa29a8-35af-508c-8bc3-b662a17a0fe5"
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
ConcaveHull = "7d11a335-8259-52c9-8750-e30c45c66484"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
EllipseSampling = "7d220c50-6298-48cd-9710-1d1a8ef13806"
FLoops = "cc61a311-1640-44b5-9fba-1b764f453329"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
LatinHypercubeSampling = "a5e1c1ea-c99a-51d3-a14d-a9a37257b02d"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Meshes = "eacbb407-ea5a-433e-ab97-5258b1ca43fa"
NLopt = "76087f3c-5699-56af-9a33-bf431cd00edd"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Roots = "f2b01f46-fcfa-551c-844a-d8ac1e96c665"
SnoopPrecompile = "66db9d55-30c0-4569-8b51-7e840670fc0c"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
TrackingHeaps = "d94bfb22-46ad-56c3-87d0-f6c298cb800e"
TravelingSalesmanHeuristics = "8c8f4381-2cdd-507c-846c-be2bcff6f45f"

[compat]
julia = "1.6"

Expand Down
38 changes: 38 additions & 0 deletions src/NLopt_optimiser.jl
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
97 changes: 96 additions & 1 deletion src/PlaceholderLikelihood.jl
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
11 changes: 11 additions & 0 deletions src/bivariate_methods/MPP_TSP.jl
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
Loading

0 comments on commit 6e4dce5

Please sign in to comment.