Commit 735d9016 authored by Fredrik Bagge Carlson's avatar Fredrik Bagge Carlson
Browse files

Minor bugfixes

parent fddafd73
......@@ -25,7 +25,7 @@ The number of centers is equal to `nc` if Kmeans is used to get initial centers,
`n_state` is equal to the state dimension, possibly reduced to `inputpca` if so desired.\n
The number of nonlinear parameters is `n_centers × n_state`\n
The number of linear parameters is `outputnet ? n_state × (n_centers+1) × (na)+1) : (na)×(n_centers+1)+1)`"""
function trainRBF_ARX(y, A, state, nc; liniters=3,nonliniters=50, normalized=false, initialcenters="equidistant", inputpca=false, outputnet = true, cuckoosearch = false, cuckooiter=100)
function trainRBF_ARX(y, A, state, nc; liniters=3,nonliniters=50, normalized=false, initialcenters="equidistant", inputpca=false, outputnet = true, cuckoosearch = false, cuckooiter=100, timeout=60)
n_points = length(y)
na = isa(A,Matrix) ? size(A,2) : 1
......@@ -93,7 +93,7 @@ function trainRBF_ARX(y, A, state, nc; liniters=3,nonliniters=50, normalized=fal
tolG = 1e-7,
tolX = 1e-10,
show_trace=true,
timeout = 60,
timeout = timeout,
n_state = n_state)
X0 = deepcopy(res.minimum)
DEBUG && assert(X0 == res.minimum)
......@@ -122,7 +122,7 @@ function trainRBF_ARX(y, A, state, nc; liniters=3,nonliniters=50, normalized=fal
pa=0.25,
Tol=1.0e-5,
max_iter = i < liniters-1 ? cuckooiter : 2cuckooiter,
timeout = 120)
timeout = 2timeout)
debug("cuckoo_search done")
X0 = deepcopy(bestnest)
@ddshow rms(f(X0))
......@@ -155,7 +155,7 @@ end
function trainRBF(y, state, nc; liniters=3,nonliniters=50, normalized=false, initialcenters="equidistant", inputpca=false, cuckoosearch = false, cuckooiter=100)
function trainRBF(y, state, nc; liniters=3,nonliniters=50, normalized=false, initialcenters="equidistant", inputpca=false, cuckoosearch = false, cuckooiter=100, timeout=60)
n_points = length(y)
function predictionerror(z)
znl = RbfNonlinearParameters(z,n_state,n_centers)
......@@ -195,7 +195,7 @@ function trainRBF(y, state, nc; liniters=3,nonliniters=50, normalized=false, ini
@ddshow sum(!isfinite(Ψ))
w = fitlinear(Ψ,y); debug("fitlinear")
newplot(w,"o"); title("Linear parameters")
# newplot(w,"o"); title("Linear parameters")
@ddshow sum(!isfinite(Zl))
prediction = Ψ*w
error = y - prediction
......@@ -221,7 +221,7 @@ function trainRBF(y, state, nc; liniters=3,nonliniters=50, normalized=false, ini
tolG = 1e-7,
tolX = 1e-10,
show_trace=true,
timeout = 60,
timeout = timeout,
n_state = n_state)
X0 = deepcopy(res.minimum)
DEBUG && assert(X0 == res.minimum)
......@@ -248,7 +248,7 @@ function trainRBF(y, state, nc; liniters=3,nonliniters=50, normalized=false, ini
pa=0.25,
Tol=1.0e-5,
max_iter = i < liniters-1 ? cuckooiter : 2cuckooiter,
timeout = 120)
timeout = 2timeout)
debug("cuckoo_search done")
X0 = deepcopy(bestnest)
@ddshow rms(f(X0))
......@@ -320,7 +320,7 @@ function getcentersEq(state::VecOrMat, nc::Integer)
end
# add bandwidth parameters γ, give all centers the same bandwidth with Δc as a (hopefully) good initial guess
# display(Z)
Z[:,n_state+1:end] = ones(1*repmat(4./(Δc.^2)',nc,1)) # Spread the initial guess to all centers
Z[:,n_state+1:end] = 1*repmat(4./(Δc.^2)',nc,1) # Spread the initial guess to all centers
assert(all(Z[:,n_state+1:end].> 0))
debug("Z done")
n_centers::Int64 = nc^n_state # new number of centers wich considers gridding of 1D centers
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment