Skip to content

How can i use optim.jl ? #327

Closed
Closed
@leaoshark

Description

@leaoshark

i have a main program ( but not all the program, is too big )

aRe = [1.28; 1.47; 1.65; 1.94; 2.25; 2.39; 2.68; 2.91; 3.13; 3.75; 4.46]
aΩ11e = [2.52; 2.26; 2.07; 1.92; 1.90; 2.08; 2.31; 2.53; 2.68; 2.51; 2.27]

function dΩ11(x,g,sigma,T)
R = 0.388/sigma
α = x[3]
ϕ = 0.9*(1-1/(1+(R/x[1])^x[2]))
θ = ϕexp(-x[3]g^2/T)
γ = x[4]
g^5
θ
Qb(g,α)exp(-g^2/T) + g^5(1-θ)γQa(g)exp(-g^2/T) +
g^5
(1-θ)*(1-γ)*Qc(g)exp(-g^2/T)
end
Ω11(x,sigma,T) = 1/T^3
quadgk(g-> dΩ11(x,g,sigma,T) ,0 , 10, abstol=1e-3)[1]

function X2(x)
aΩ11 = zeros( lenR )
for i in lenR
aΩ11[i] = afΩ11i
end
sum((aΩ11-aΩ11e).^2)
end

for R in aRe
tic()
sigma=0.388/R
rc0,bc0,gc0 = rc0bc0gc0(sigma)
println(“sigma = $sigma, rc0 = $rc0, bc0 = $bc0, gc0 = $gc0”)
Qa = interpQa(sigma) # retorna a função Qa(g) para este sigma
Qb = interpQb(sigma) # retorna a função Qb(g,α) para este sigma
Qc = interpQc(sigma) # retorna a função Qc(g) para este sigma
push!(afΩ11, x->Ω11(x,sigma,T)) # array de funções
toc()
end

xi = ones( lenR )
x, X2min = NelderMead(x->X2(x), [2.50;17.2;0.5;0.5])
#println(x[1]," “,x[2],” “,x[3])
println(x[1],” “,x[2],” “,x[3],” ",x[4])

i am using neldermead method to find x[1] x[2] x[3] and x[4] ... how can i use optim.jl ? neldermead gives me wrong answers

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions