Last active
September 2, 2018 11:09
-
-
Save Vaibhavdixit02/1e658020c19995b19edd9605e6379a50 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"using DiffEqSensitivity, OrdinaryDiffEq, DiffEqParamEstim,\n", | |
" ParameterizedFunctions, BlackBoxOptim, NLopt, Calculus, ForwardDiff, Optim, BenchmarkTools, RecursiveArrayTools" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"(::FitzhughNagumo{getfield(Main, Symbol(\"##3#9\")),getfield(Main, Symbol(\"##4#10\")),getfield(Main, Symbol(\"##5#11\")),getfield(Main, Symbol(\"##6#12\")),getfield(Main, Symbol(\"##7#13\")),getfield(Main, Symbol(\"##8#14\")),Expr,Expr}) (generic function with 2 methods)" | |
] | |
}, | |
"execution_count": 2, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"fitz = @ode_def FitzhughNagumo begin\n", | |
" dv = v - v^3/3 -w + 0.5\n", | |
" dw = 0.08*(v + a - 0.8*w)\n", | |
"end a " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"\u001b[36mODEProblem\u001b[0m with uType \u001b[36mArray{Float64,1}\u001b[0m and tType \u001b[36mFloat64\u001b[0m. In-place: \u001b[36mtrue\u001b[0m\n", | |
"timespan: (0.0, 3.0)\n", | |
"u0: [1.0, 1.0]" | |
] | |
}, | |
"execution_count": 3, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"p = [0.7] # Parameters used to construct the dataset\n", | |
"r0 = [1.0; 1.0] # initial value\n", | |
"tspan = (0.0, 3.0) # sample of 3000 observations over the (0,30) timespan\n", | |
"prob = ODEProblem(fitz, r0, tspan,p)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"retcode: Success\n", | |
"Interpolation: 1st order linear\n", | |
"t: 1000-element Array{Float64,1}:\n", | |
" 0.0 \n", | |
" 0.003003003003003003\n", | |
" 0.006006006006006006\n", | |
" 0.009009009009009009\n", | |
" 0.012012012012012012\n", | |
" 0.015015015015015015\n", | |
" 0.018018018018018018\n", | |
" 0.021021021021021023\n", | |
" 0.024024024024024024\n", | |
" 0.02702702702702703 \n", | |
" 0.03003003003003003 \n", | |
" 0.03303303303303303 \n", | |
" 0.036036036036036036\n", | |
" ⋮ \n", | |
" 2.966966966966967 \n", | |
" 2.96996996996997 \n", | |
" 2.972972972972973 \n", | |
" 2.975975975975976 \n", | |
" 2.978978978978979 \n", | |
" 2.981981981981982 \n", | |
" 2.984984984984985 \n", | |
" 2.987987987987988 \n", | |
" 2.990990990990991 \n", | |
" 2.993993993993994 \n", | |
" 2.996996996996997 \n", | |
" 3.0 \n", | |
"u: 1000-element Array{Array{Float64,1},1}:\n", | |
" [1.0, 1.0, 0.0, 0.0] \n", | |
" [1.0005, 1.00022, -3.60698e-7, 0.000240217]\n", | |
" [1.001, 1.00043, -1.4427e-6, 0.000480388] \n", | |
" [1.0015, 1.00065, -3.24584e-6, 0.000720512]\n", | |
" [1.002, 1.00087, -5.76998e-6, 0.00096059] \n", | |
" [1.00249, 1.00108, -9.01496e-6, 0.00120062]\n", | |
" [1.00299, 1.0013, -1.29806e-5, 0.0014406] \n", | |
" [1.00349, 1.00152, -1.76667e-5, 0.00168054]\n", | |
" [1.00398, 1.00173, -2.30731e-5, 0.00192043]\n", | |
" [1.00448, 1.00195, -2.91997e-5, 0.00216027]\n", | |
" [1.00497, 1.00217, -3.60461e-5, 0.00240007]\n", | |
" [1.00547, 1.00238, -4.36122e-5, 0.00263981]\n", | |
" [1.00596, 1.0026, -5.18979e-5, 0.00287951] \n", | |
" ⋮ \n", | |
" [1.11497, 1.22039, -0.237672, 0.196355] \n", | |
" [1.11477, 1.22059, -0.238089, 0.196501] \n", | |
" [1.11457, 1.22079, -0.238506, 0.196646] \n", | |
" [1.11437, 1.22099, -0.238923, 0.196791] \n", | |
" [1.11416, 1.2212, -0.23934, 0.196936] \n", | |
" [1.11396, 1.2214, -0.239759, 0.197081] \n", | |
" [1.11375, 1.2216, -0.240177, 0.197225] \n", | |
" [1.11355, 1.2218, -0.240596, 0.19737] \n", | |
" [1.11334, 1.222, -0.241016, 0.197514] \n", | |
" [1.11313, 1.2222, -0.241436, 0.197659] \n", | |
" [1.11293, 1.2224, -0.241856, 0.197803] \n", | |
" [1.11272, 1.2226, -0.242277, 0.197947] " | |
] | |
}, | |
"execution_count": 4, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"global t = collect(range(0, stop=3.0, length=1000))\n", | |
"data = Array(solve(prob,Tsit5(),saveat=t,abstol=1e-3,reltol=1e-3))\n", | |
"ourprob = ODELocalSensitivityProblem(fitz,r0,tspan,p)\n", | |
"oursol = solve(ourprob,Tsit5(),saveat=t,abstol=1e-6,reltol=1e-6)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"myl2loss (generic function with 1 method)" | |
] | |
}, | |
"execution_count": 5, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"function myl2loss(oursol_type, data)\n", | |
" my_l2loss = zero(eltype(data))\n", | |
" for i in 1:size(data)[1]\n", | |
" for j in 1:size(data)[2]\n", | |
" my_l2loss += (oursol_type[i,j] - data[i,j])^2\n", | |
" end\n", | |
" end\n", | |
" my_l2loss\n", | |
"end" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"#15 (generic function with 1 method)" | |
] | |
}, | |
"execution_count": 6, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"prob_generator = (prob,p) -> remake(ourprob;p=p)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"#17 (generic function with 1 method)" | |
] | |
}, | |
"execution_count": 7, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"costfunc = function (p)\n", | |
" tmp_prob = prob_generator(ourprob,p)\n", | |
" sol = solve(tmp_prob,Tsit5(),saveat=t,abstol=1e-6,reltol=1e-6)\n", | |
" loss = myl2loss(sol,data)\n", | |
" loss\n", | |
"end" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"costfunc_gradient (generic function with 1 method)" | |
] | |
}, | |
"execution_count": 8, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"function costfunc_gradient(p,grad)\n", | |
" tmp_prob = prob_generator(ourprob,p)\n", | |
" sol = solve(tmp_prob,Tsit5(),saveat=t,abstol=1e-6,reltol=1e-6)\n", | |
" myl2lossgradient!(grad,sol,data,length(p))\n", | |
" costfunc(p)\n", | |
"end" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"myl2lossgradient! (generic function with 1 method)" | |
] | |
}, | |
"execution_count": 9, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"function myl2lossgradient!(grad,oursol_type,data,num_p)\n", | |
" data_x_size = size(data)[1]\n", | |
" my_grad = -1 .*2 .*(data .- oursol_type[1:data_x_size,:])\n", | |
" for i in 1:num_p\n", | |
" for j in i*data_x_size+1:(i+1)*data_x_size\n", | |
" for k in 1:size(my_grad)[2]\n", | |
" grad[i] += my_grad[j-i*data_x_size,k]*oursol_type[j,k]\n", | |
" end\n", | |
" end\n", | |
" end\n", | |
"end" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 10, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"-0.0034862362357598866" | |
] | |
}, | |
"execution_count": 10, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"oursol[3,100]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 11, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"1.4591534767036414e-7" | |
] | |
}, | |
"execution_count": 11, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"out = Array{Float64}(undef,1)\n", | |
"p = [0.7]\n", | |
"costfunc_gradient(p,out)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 12, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"1-element Array{Float64,1}:\n", | |
" 0.00010425580660985826" | |
] | |
}, | |
"execution_count": 12, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"out" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 13, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"1-element Array{Float64,1}:\n", | |
" 2.1219957915e-314" | |
] | |
}, | |
"execution_count": 13, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"out = Array{Float64}(undef,1)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 14, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"Calculus.finite_difference!(costfunc,p,out,:central)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 15, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"1-element Array{Float64,1}:\n", | |
" 0.00010425648566874457" | |
] | |
}, | |
"execution_count": 15, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"out" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 16, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"BenchmarkTools.Trial: \n", | |
" memory estimate: 575.72 KiB\n", | |
" allocs estimate: 2886\n", | |
" --------------\n", | |
" minimum time: 463.392 μs (0.00% GC)\n", | |
" median time: 534.183 μs (0.00% GC)\n", | |
" mean time: 614.679 μs (10.46% GC)\n", | |
" maximum time: 7.181 ms (84.50% GC)\n", | |
" --------------\n", | |
" samples: 8086\n", | |
" evals/sample: 1" | |
] | |
}, | |
"execution_count": 16, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"p = [0.5]\n", | |
"@benchmark begin\n", | |
" out = Array{Float64}(undef,2)\n", | |
" costfunc_gradient(p,out)\n", | |
"end" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 17, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"1.1077934720011857" | |
] | |
}, | |
"execution_count": 17, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"out = Array{Float64}(undef,1)\n", | |
"costfunc_gradient(p,out)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 18, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"1-element Array{Float64,1}:\n", | |
" -10.980977186241835" | |
] | |
}, | |
"execution_count": 18, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"out" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 19, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"1-element Array{Float64,1}:\n", | |
" 2.244801728e-314" | |
] | |
}, | |
"execution_count": 19, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"out = Array{Float64}(undef,1)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 20, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"BenchmarkTools.Trial: \n", | |
" memory estimate: 544.19 KiB\n", | |
" allocs estimate: 2887\n", | |
" --------------\n", | |
" minimum time: 450.946 μs (0.00% GC)\n", | |
" median time: 507.216 μs (0.00% GC)\n", | |
" mean time: 582.422 μs (10.36% GC)\n", | |
" maximum time: 5.007 ms (85.99% GC)\n", | |
" --------------\n", | |
" samples: 8552\n", | |
" evals/sample: 1" | |
] | |
}, | |
"execution_count": 20, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"@benchmark Calculus.finite_difference!(costfunc,p,out,:central)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 21, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"1-element Array{Float64,1}:\n", | |
" -10.980978094091105" | |
] | |
}, | |
"execution_count": 21, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"out" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 22, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"(1.107793472001184, [0.5], :XTOL_REACHED)" | |
] | |
}, | |
"execution_count": 22, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"opt = Opt(:LD_MMA, 1)\n", | |
"min_objective!(opt, costfunc_gradient)\n", | |
"lower_bounds!(opt,[0.0])\n", | |
"upper_bounds!(opt,[1.0])\n", | |
"xtol_rel!(opt,1e-12)\n", | |
"maxeval!(opt, 100000)\n", | |
"(minf,minx,ret) = NLopt.optimize(opt,[0.5])" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 23, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"g! (generic function with 1 method)" | |
] | |
}, | |
"execution_count": 23, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"function g!(grad,p)\n", | |
" costfunc_gradient(p,grad)\n", | |
"end" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 24, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"┌ Warning: First function call produced NaNs. Exiting.\n", | |
"└ @ OrdinaryDiffEq /Users/vaibhav/.julia/packages/OrdinaryDiffEq/c746g/src/initdt.jl:74\n", | |
"┌ Warning: Automatic dt set the starting dt as NaN, causing instability.\n", | |
"└ @ OrdinaryDiffEq /Users/vaibhav/.julia/packages/OrdinaryDiffEq/c746g/src/solve.jl:328\n", | |
"┌ Warning: Instability detected. Aborting\n", | |
"└ @ DiffEqBase /Users/vaibhav/.julia/packages/DiffEqBase/YSk7M/src/integrator_interface.jl:128\n" | |
] | |
}, | |
{ | |
"ename": "BoundsError", | |
"evalue": "BoundsError: attempt to access 1-element Array{Array{Float64,1},1} at index [2]", | |
"output_type": "error", | |
"traceback": [ | |
"BoundsError: attempt to access 1-element Array{Array{Float64,1},1} at index [2]", | |
"", | |
"Stacktrace:", | |
" [1] getindex at ./array.jl:731 [inlined]", | |
" [2] getindex at /Users/vaibhav/.julia/packages/RecursiveArrayTools/ukc19/src/vector_of_array.jl:44 [inlined]", | |
" [3] myl2loss(::ODESolution{Float64,2,Array{Array{Float64,1},1},Nothing,Nothing,Array{Float64,1},Array{Array{Array{Float64,1},1},1},ODEProblem{Array{Float64,1},Tuple{Float64,Float64},true,Array{Float64,1},ODELocalSensitvityFunction{true,FitzhughNagumo{getfield(Main, Symbol(\"##3#9\")),getfield(Main, Symbol(\"##4#10\")),getfield(Main, Symbol(\"##5#11\")),getfield(Main, Symbol(\"##6#12\")),getfield(Main, Symbol(\"##7#13\")),getfield(Main, Symbol(\"##8#14\")),Expr,Expr},Nothing,getfield(Main, Symbol(\"##4#10\")),getfield(Main, Symbol(\"##8#14\")),DiffEqDiffTools.UJacobianWrapper{FitzhughNagumo{getfield(Main, Symbol(\"##3#9\")),getfield(Main, Symbol(\"##4#10\")),getfield(Main, Symbol(\"##5#11\")),getfield(Main, Symbol(\"##6#12\")),getfield(Main, Symbol(\"##7#13\")),getfield(Main, Symbol(\"##8#14\")),Expr,Expr},Float64,Array{Float64,1}},DiffEqDiffTools.ParamJacobianWrapper{FitzhughNagumo{getfield(Main, Symbol(\"##3#9\")),getfield(Main, Symbol(\"##4#10\")),getfield(Main, Symbol(\"##5#11\")),getfield(Main, Symbol(\"##6#12\")),getfield(Main, Symbol(\"##7#13\")),getfield(Main, Symbol(\"##8#14\")),Expr,Expr},Float64,Array{Float64,1}},Nothing,Nothing,DiffEqSensitivity.SensitivityAlg{0,true,DataType},Array{Float64,1},Float64,LinearAlgebra.UniformScaling{Bool}},CallbackSet{Tuple{},Tuple{}},DiffEqBase.StandardODEProblem},Tsit5,OrdinaryDiffEq.InterpolationData{ODELocalSensitvityFunction{true,FitzhughNagumo{getfield(Main, Symbol(\"##3#9\")),getfield(Main, Symbol(\"##4#10\")),getfield(Main, Symbol(\"##5#11\")),getfield(Main, Symbol(\"##6#12\")),getfield(Main, Symbol(\"##7#13\")),getfield(Main, Symbol(\"##8#14\")),Expr,Expr},Nothing,getfield(Main, Symbol(\"##4#10\")),getfield(Main, Symbol(\"##8#14\")),DiffEqDiffTools.UJacobianWrapper{FitzhughNagumo{getfield(Main, Symbol(\"##3#9\")),getfield(Main, Symbol(\"##4#10\")),getfield(Main, Symbol(\"##5#11\")),getfield(Main, Symbol(\"##6#12\")),getfield(Main, Symbol(\"##7#13\")),getfield(Main, Symbol(\"##8#14\")),Expr,Expr},Float64,Array{Float64,1}},DiffEqDiffTools.ParamJacobianWrapper{FitzhughNagumo{getfield(Main, Symbol(\"##3#9\")),getfield(Main, Symbol(\"##4#10\")),getfield(Main, Symbol(\"##5#11\")),getfield(Main, Symbol(\"##6#12\")),getfield(Main, Symbol(\"##7#13\")),getfield(Main, Symbol(\"##8#14\")),Expr,Expr},Float64,Array{Float64,1}},Nothing,Nothing,DiffEqSensitivity.SensitivityAlg{0,true,DataType},Array{Float64,1},Float64,LinearAlgebra.UniformScaling{Bool}},Array{Array{Float64,1},1},Array{Float64,1},Array{Array{Array{Float64,1},1},1},OrdinaryDiffEq.Tsit5Cache{Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}}}, ::Array{Float64,2}) at ./In[5]:5", | |
" [4] (::getfield(Main, Symbol(\"##17#18\")))(::Array{Float64,1}) at ./In[7]:4", | |
" [5] value!!(::OnceDifferentiable{Float64,Array{Float64,1},Array{Float64,1}}, ::Array{Float64,1}) at /Users/vaibhav/.julia/packages/NLSolversBase/Cvvki/src/interface.jl:9", | |
" [6] value!(::OnceDifferentiable{Float64,Array{Float64,1},Array{Float64,1}}, ::Array{Float64,1}) at /Users/vaibhav/.julia/packages/NLSolversBase/Cvvki/src/interface.jl:31", | |
" [7] value!(::Optim.ManifoldObjective{OnceDifferentiable{Float64,Array{Float64,1},Array{Float64,1}}}, ::Array{Float64,1}) at /Users/vaibhav/.julia/packages/Optim/fabGe/src/Manifolds.jl:31", | |
" [8] (::getfield(LineSearches, Symbol(\"#ϕ#1\")){Optim.ManifoldObjective{OnceDifferentiable{Float64,Array{Float64,1},Array{Float64,1}}},Array{Float64,1},Array{Float64,1},Array{Float64,1}})(::Float64) at /Users/vaibhav/.julia/packages/LineSearches/SrdrY/src/LineSearches.jl:25", | |
" [9] _hzI12(::Float64, ::Optim.ManifoldObjective{OnceDifferentiable{Float64,Array{Float64,1},Array{Float64,1}}}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Bool, ::Base.RefValue{Bool}) at /Users/vaibhav/.julia/packages/LineSearches/SrdrY/src/initialguess.jl:225", | |
" [10] InitialHagerZhang at /Users/vaibhav/.julia/packages/LineSearches/SrdrY/src/initialguess.jl:196 [inlined]", | |
" [11] perform_linesearch!(::Optim.ConjugateGradientState{Array{Float64,1},Float64,Array{Float64,1}}, ::ConjugateGradient{Float64,Nothing,getfield(Optim, Symbol(\"##33#35\")),LineSearches.InitialHagerZhang{Float64},LineSearches.HagerZhang{Float64,Base.RefValue{Bool}}}, ::Optim.ManifoldObjective{OnceDifferentiable{Float64,Array{Float64,1},Array{Float64,1}}}) at /Users/vaibhav/.julia/packages/Optim/fabGe/src/utilities/perform_linesearch.jl:32", | |
" [12] update_state!(::OnceDifferentiable{Float64,Array{Float64,1},Array{Float64,1}}, ::Optim.ConjugateGradientState{Array{Float64,1},Float64,Array{Float64,1}}, ::ConjugateGradient{Float64,Nothing,getfield(Optim, Symbol(\"##33#35\")),LineSearches.InitialHagerZhang{Float64},LineSearches.HagerZhang{Float64,Base.RefValue{Bool}}}) at /Users/vaibhav/.julia/packages/Optim/fabGe/src/multivariate/solvers/first_order/cg.jl:153", | |
" [13] optimize(::OnceDifferentiable{Float64,Array{Float64,1},Array{Float64,1}}, ::Array{Float64,1}, ::ConjugateGradient{Float64,Nothing,getfield(Optim, Symbol(\"##33#35\")),LineSearches.InitialHagerZhang{Float64},LineSearches.HagerZhang{Float64,Base.RefValue{Bool}}}, ::Optim.Options{Float64,Nothing}, ::Optim.ConjugateGradientState{Array{Float64,1},Float64,Array{Float64,1}}) at /Users/vaibhav/.julia/packages/Optim/fabGe/src/multivariate/optimize/optimize.jl:57", | |
" [14] optimize at /Users/vaibhav/.julia/packages/Optim/fabGe/src/multivariate/optimize/optimize.jl:33 [inlined]", | |
" [15] #optimize#88(::Bool, ::Symbol, ::Function, ::Function, ::Function, ::Array{Float64,1}, ::ConjugateGradient{Float64,Nothing,getfield(Optim, Symbol(\"##33#35\")),LineSearches.InitialHagerZhang{Float64},LineSearches.HagerZhang{Float64,Base.RefValue{Bool}}}, ::Optim.Options{Float64,Nothing}) at /Users/vaibhav/.julia/packages/Optim/fabGe/src/multivariate/optimize/interface.jl:121", | |
" [16] optimize(::Function, ::Function, ::Array{Float64,1}, ::ConjugateGradient{Float64,Nothing,getfield(Optim, Symbol(\"##33#35\")),LineSearches.InitialHagerZhang{Float64},LineSearches.HagerZhang{Float64,Base.RefValue{Bool}}}, ::Optim.Options{Float64,Nothing}) at /Users/vaibhav/.julia/packages/Optim/fabGe/src/multivariate/optimize/interface.jl:119 (repeats 2 times)", | |
" [17] top-level scope at In[24]:1" | |
] | |
} | |
], | |
"source": [ | |
"Optim.optimize(costfunc, g!, [0.5], ConjugateGradient())" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Julia 1.0.0", | |
"language": "julia", | |
"name": "julia-1.0" | |
}, | |
"language_info": { | |
"file_extension": ".jl", | |
"mimetype": "application/julia", | |
"name": "julia", | |
"version": "1.0.0" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment