# Optim.jl: bracketing with Newton()

Is it possible to use Newton() methods with limiting some variables? Like FMinbox?

Thank you, I read the manual. I think I know how Fminbox() works, but it doesn’t work with Newton(). (L)BFGS() works fine with Fminbox(), but I hope to have some solution for Newton().

We have a Newton method for bound-constrained problems here: Solvers · JSOSolvers.jl

See this issue you may be running into, and particularly this comment:

https://github.com/JuliaNLSolvers/Optim.jl/issues/600#issuecomment-420946414

Thanks, i will try!

Thanks, this issue is wery close to my project. I also need to maximize likelihood function and one of parameter of covariance matrix - rho - changing in limits 0 - 1.0, and when i use LBFGS - it’s works fine, but to slow. Newton() works fast, but i need to do things like this: `if rho > 1 rho = 1 end` and this is not good, because last step of optimization some time > 1.0 end it can leads to “stuck” in value 1.0 when real value close to 1.0 ( f.e. 0.988). I try to use “link function” like sigmoid, but at marginal values it works not good: `1/(1+exp(x))` not works correctly, `1/(1+x^4)` works nearly good, but not not better when rho “force limited”. Now i use LBFGS till rho is stable and then use Newton(), or Newton() at first step and then LBFGS, but i think there must be a better way.

It is hard to say more about this without an MWE (eg do you provide derivatives manually or use AD, what is rho [stepsize correction?], …).

Hi! I use AD, and likelihood function based on derivation of variance-covariance matrix. For example 2x2 matrix (ρ, σ₁, σ₂ - should be found)

``````σ²₁             ρσ₁σ₂
ρσ₁σ₂           σ²₂
``````

where ρ covariation coefficient that should be also found - and it can be in the range 0 - 1.

You might have better luck transforming your variables, as done here: Optim.jl . They work with the log variance which can take on any value. For ρ you could use tanh and atanh to go back and forth between `(-1, 1)` and `(-inf, inf)`

1 Like
{"ft_lang_label":"__label__en","ft_lang_prob":0.8547934,"math_prob":0.7306855,"size":1971,"snap":"2022-40-2023-06","text_gpt3_token_len":544,"char_repetition_ratio":0.10269446,"word_repetition_ratio":0.0,"special_character_ratio":0.2678843,"punctuation_ratio":0.13785046,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.96133405,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-02-07T18:28:41Z\",\"WARC-Record-ID\":\"<urn:uuid:972d3d8a-1807-4da3-91ad-b4a127092530>\",\"Content-Length\":\"43170\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:93a43214-7b47-41df-8e3a-2c4e62298e44>\",\"WARC-Concurrent-To\":\"<urn:uuid:2f434d8f-8979-468d-97e9-e2922a1af735>\",\"WARC-IP-Address\":\"64.71.144.205\",\"WARC-Target-URI\":\"https://discourse.julialang.org/t/optim-jl-bracketing-with-newton/30332/8\",\"WARC-Payload-Digest\":\"sha1:EPNOIFZDQ6FHWNR6OHNE7OCIY5SGBGZJ\",\"WARC-Block-Digest\":\"sha1:2Q5XY7PGBMYHWQEL5ZW64VZH3EDIEIVV\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-06/CC-MAIN-2023-06_segments_1674764500628.77_warc_CC-MAIN-20230207170138-20230207200138-00521.warc.gz\"}"}