Question: How can decrease the evaluation time of NLPSolve or are there better methods?

Hi,

I am trying to curve fit data using NLPSolve. I noticed that the evaluation time for NLPSolve seems really long. Did I mess up in using NLPSolve? 

 

Thanks you for any suggests or comments.
 

restart; kernelopts(version); interface(version); multithread_capability := kernelopts(multithreaded); Number_of_CPUs := kernelopts(numcpus)
NULL

8

(1)

``

``

"#` How` can I decrease the evaluation time of NLPSolve or are there better methods"?"" ""

``

SoS:=proc(E0::float,E00::float,alpha::float,beta:: float)::float;

NULL

NULL

Experimental Data

 

Erealm := Vector[row]([1235.773, 1383.61, 1457.262, 1500.264, 1550.184, 1612.161, 512.7612, 656.6554, 743.6461, 793.375, 855.7937, 939.1199, 79.9523, 128.1375, 167.1459, 193.592, 230.5401, 287.8348, 22.389, 29.41424, 35.91883, 40.86366, 48.79128, 63.4475, 15.34275, 17.10101, 18.63288, 19.77424, 21.5671, 24.84739, 13.8321, 14.52843, 15.07626, 15.47014, 16.07713, 17.16574, 13.13383, 13.63704, 13.95888, 14.16849, 14.46123, 14.93971, 12.76736, 13.2203, 13.50072, 13.673, 13.89852, 14.23242]); LFm := Vector[row]([.156795, .1248161, .1108722, .1032334, 0.9474591e-1, 0.8496174e-1, .361361, .3020133, .2706018, .2546556, .2356126, .2121333, .6883826, .6532309, .6155578, .5906291, .5578895, .5123917, .394458, .5326358, .6095816, .6489291, .6894866, .7232845, .1456468, .2226473, .2826954, .3228541, .3789496, .4632182, 0.6758032e-1, 0.9437384e-1, .1198126, .1387971, .1680719, .2181531, 0.5173809e-1, 0.586771e-1, 0.6591736e-1, 0.7206892e-1, 0.8243504e-1, .1024519, 0.457877e-1, 0.493836e-1, 0.5191291e-1, 0.539114e-1, 0.5708074e-1, 0.6330242e-1])

NULL``

Enter Initial Guesses for HN equation

 

ind0 := min[index](Erealm); ind00 := max[index](Erealm); indLF := max[index](LFm); E0_g := Erealm(ind0); E00_g := 3*Erealm(ind00); `α_g` := 2.0*LFm(indLF)/Pi; `β_g` := `α_g`/(10.0); m := ArrayTools[Dimensions](LFm); maxx := rhs(m[1]); Ecomplex := Vector[row]([seq(Complex(Erealm[k], Erealm[k]*LFm[k]), k = 1 .. maxx)]); `ωτ` := Vector[row]([seq(abs((((E0_g-E00_g)/(Ecomplex[k]-E00_g))^(1/`β_g`)-1)^(1/`α_g`)/(I)), k = 1 .. maxx)]); Erealc := Vector[row]([seq(Re(E00_g+(E0_g-E00_g)/(1+(I*`ωτ`[k])^`α_g`)^`β_g`), k = 1 .. maxx)]); Eimagc := Vector[row]([seq(Im(E00_g+(E0_g-E00_g)/(1+(I*`ωτ`[k])^`α_g`)^`β_g`), k = 1 .. maxx)]); LFc := Vector[row]([seq(Eimagc[k]/Erealc[k], k = 1 .. maxx)]); pltm := plots:-loglogplot(Erealm, LFm, style = point, symbol = solidcircle, gridlines = true, color = red); pltc := plots:-loglogplot(Erealc, LFc, style = point, symbol = diamond, gridlines = true, color = blue); plots:-display(pltm, pltc, title = "Wicket Plot from Guesses       measured - red    calculated - blue"); Sum_of_Squares := SoS(E0_g, E00_g, `α_g`, `β_g`)

.2049941769

(2.1)

``

NULL

NULL

NULL

Run Optimizer

 

lol := .7; hil := 1.3; le0 := lol*E0_g; he0 := hil*E0_g; le00 := lol*E00_g; he00 := hil*E00_g; al := lol*`α_g`; ah := hil*`α_g`; bl := lol*`β_g`; bh := hil*`β_g`; parameterRange := le0 .. he0, le00 .. he00, al .. ah, bl .. bh; soln := Optimization:-NLPSolve(SoS, parameterRange); HN := soln[2]; E0_s := HN[1]; E00_s := HN[2]; `α_s` := HN[3]; `β_s` := HN[4]; `ωτ_s` := Vector[row]([seq(abs((((E0_s-E00_s)/(Ecomplex[k]-E00_s))^(1/`β_s`)-1)^(1/`α_s`)/(I)), k = 1 .. maxx)]); Erealc_s := Vector[row]([seq(Re(E00_s+(E0_s-E00_s)/(1+(I*`ωτ_s`[k])^`α_s`)^`β_s`), k = 1 .. maxx)]); Eimagc_s := Vector[row]([seq(Im(E00_s+(E0_s-E00_s)/(1+(I*`ωτ_s`[k])^`α_s`)^`β_s`), k = 1 .. maxx)]); LFc_s := Vector[row]([seq(Eimagc_s[k]/Erealc_s[k], k = 1 .. maxx)])

[0.648163470800135894e-2, Vector[column](%id = 18446747242105787086)]

(3.1)

NULL

NULL

NULL

Plot Wicket Plot with Optimized HN Parameters

 

pltm_s := plots:-loglogplot(Erealm, LFm, style = point, symbol = solidcircle, gridlines = true, color = red); pltc_s := plots:-loglogplot(Erealc_s, LFc_s, style = point, symbol = diamond, gridlines = true, color = blue); plots:-display(pltm_s, pltc_s, title = "Wicket Plot after Optimization  (measured - red    calculated - blue)"); E0_soln := E0_s; E00_soln := E00_s; `α_soln` := `α_s`; `β_soln` := `β_s`; Sum_of_Squares := soln[1]

0.648163470800135894e-2

(4.1)

NULL


 

Download HN_fit_of_DMA_data_ss_proc_v5a.mw

Please Wait...