I have some working code that i cant optmization to find some x x x x constants.
A link for all the code is:
aRe = [1.28; 1.47; 1.67; 1.95; 2.26; 2.38; 2.68; 2.92; 3.16; 3.77; 4.47]
aΩ11e = [2.52; 2.26; 2.07; 1.92; 1.90; 2.08; 2.31; 2.53; 2.68; 2.51; 2.27]
R = 0.388/sigma
α = x
ϕ = 0.9*(1-1/(1+(R/x)^x))
θ(g) = ϕ*exp(-x*g^2/T)
γ = x
g^5*θ(g)*Qb(g,sigma,α)*exp(-g^2/T) + g^5*(1-θ(g))*γ*Qa(g,sigma)*exp(-g^2/T) +
1/T^3*quadgk(g -> dΩ11(x,g,sigma) ,0.01 , 1.51, atol=1e-3)
soma = 0
for (i,sigma) in enumerate(aσ)
soma = soma + (Ω11(x,sigma)-aΩ11e[i])^2
lower = [1.0; 0 ; 0.0 ; 0.7 ]
upper = [5.0; 30.0; 1.0 ; 1.0]
initial_x = [3; 20; 0.5 ; 1.0 ]
opt = optimize(x->X2(x), initial_x, lower, upper,NelderMead())
x = Optim.minimizer( opt )
Optim.minimum( opt )
Is there any error in the code ?
Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer.
Keywords are highlighted to make it easier to refer to specific points.
Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …
Please read this post. That will facilitate everyone to help you.
The template that I use for this kind of request, and for bug reports, is:
What I did
What I expected to happen when I did that
What actually happened
You’ve told us 1. To help you, we need to know 2 and 3 as well. Did Optim throw an error? Does this function have a known minimum that Optim didn’t find? Or is there some other reason that you suspect there is an error in the code?
I have a range for alpha, but i use lower and upper values in that range, but optim do not respect it …
i will upgrade the code
Oh right. I think you’re trying to optimise a multivariate function, but using the syntax for a univariate one. Here’s the relevant part of
the manual. I haven’t used
Fminbox myself, and I don’t know if it works with Nelder-Mead.
yes, it works … but i do not know what happening because the lower and upper limits does not be respect by the program
Please post code (complete and working that people can copy and paste), not screenshots.
Hello man … i cannot post my entire code because needs a .dat files …
a link from google drive in the beggining have my entire code.
i use interpolate, so i have .dat files
can you know how to solve it ?
I am just guessing but it seems that you did not use the correct syntax for
Fminbox, which should be
even if i take off the FminBox, leave only the lower and upper, the algoritm fails to respect the limits
It looks like you are confusing the argument order in your
optimize call - the example given in the docs is
inner_optimizer = GradientDescent()
results = optimize(f, g!, lower, upper, initial_x, Fminbox(inner_optimizer))
(note the order of lower, upper, and initial in comparison to your call)
As mentioned by David above it’s very hard to help you without an MWE, please consider the advice in
Please read: make it easier to help you - #81