Skip to content

Commit

Permalink
fix varlink
Browse files Browse the repository at this point in the history
  • Loading branch information
PharmCat committed Jan 20, 2021
1 parent 5ac84ec commit 605f0e8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MetidaNLopt"
uuid = "4e1362ca-e5a0-4237-9ffd-bca39e5440e3"
authors = ["Vladimir Arnautov <mail@pharmcat.net>"]
version = "0.1.0"
version = "0.1.1"

[deps]

Expand Down
14 changes: 9 additions & 5 deletions src/MetidaNLopt.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
module MetidaNLopt

using Metida, NLopt, ForwardDiff, LinearAlgebra
import Metida: LMM, initvar, varlinkvec, varlinkrvec, thetalength, varlinkvecapply!, lmmlog!, LMMLogMsg, reml_sweep_β_b, reml_sweep_β, fit_nlopt!, gmat_base_z2!, rmat_basep_z2!
import Metida: LMM, initvar, varlinkvec, varlinkrvec, thetalength,
varlinkrvecapply2!, varlinkvecapply2,
lmmlog!, LMMLogMsg, reml_sweep_β_b, reml_sweep_β, fit_nlopt!, gmat_base_z2!, rmat_basep_z2!

reml_sweep_β_cuda(args...) = error("MetidaCu not found. \n - Run `using MetidaCu` before.")

Expand All @@ -22,8 +24,10 @@ module MetidaNLopt
# Optimization function
if solver == :nlopt
optfunc = reml_sweep_β_nlopt
else
elseif solver == :cuda
optfunc = reml_sweep_β_cuda
else
error("Unknown solver!")
end
############################################################################
#Initial variance
Expand All @@ -41,20 +45,20 @@ module MetidaNLopt
lmmlog!(lmm, verbose, LMMLogMsg(:INFO, "Initial θ: "*string(θ)))
end
############################################################################
varlinkvecapply!(θ, fvr)
varlinkrvecapply2!(θ, lmm.covstr.ct)
############################################################################
opt = NLopt.Opt(:LN_BOBYQA, thetalength(lmm))
NLopt.ftol_rel!(opt, 1.0e-14)
NLopt.ftol_abs!(opt, f_tol)
NLopt.xtol_rel!(opt, 1.0e-14)
NLopt.xtol_abs!(opt, x_tol)
#-----------------------------------------------------------------------
obj = (x,y) -> optfunc(lmm, varlinkvecapply!(x, fv))[1]
obj = (x,y) -> optfunc(lmm, varlinkvecapply2(x, lmm.covstr.ct))[1]
NLopt.min_objective!(opt, obj)
#Optimization object
lmm.result.optim = NLopt.optimize!(opt, θ)
#Theta (θ) vector
lmm.result.theta = varlinkvecapply!(deepcopy(lmm.result.optim[2]), fv)
lmm.result.theta = varlinkvecapply2(lmm.result.optim[2], lmm.covstr.ct)
try
#Hessian
if hcalck
Expand Down

2 comments on commit 605f0e8

@PharmCat
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/28412

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.1 -m "<description of version>" 605f0e8cfac2295241d9cb2f8431a14b06ee0e9c
git push origin v0.1.1

Please sign in to comment.