summaryrefslogtreecommitdiff
path: root/R/estUtil.R
diff options
context:
space:
mode:
authorSuraj Yerramilli2016-02-12 13:30:11 +0530
committerSuraj Yerramilli2016-02-12 13:30:11 +0530
commit9f8588f539178b9eb42235b9b131702534e42c49 (patch)
tree2182650eb2a159dbea4a8011e9f18a5614eb796b /R/estUtil.R
parent40f4055e6ba4ed836dc4765501c8147a2f5961c9 (diff)
downloadSysID-R-code-9f8588f539178b9eb42235b9b131702534e42c49.tar.gz
SysID-R-code-9f8588f539178b9eb42235b9b131702534e42c49.tar.bz2
SysID-R-code-9f8588f539178b9eb42235b9b131702534e42c49.zip
added new termination criteria
Diffstat (limited to 'R/estUtil.R')
-rw-r--r--R/estUtil.R10
1 files changed, 6 insertions, 4 deletions
diff --git a/R/estUtil.R b/R/estUtil.R
index f6f5619..989b910 100644
--- a/R/estUtil.R
+++ b/R/estUtil.R
@@ -30,13 +30,15 @@ levbmqdt <- function(...,obj,theta0,N,opt){
Hinv <- solve(H); g <- t(l$grad)%*%e
theta <- theta0 + Hinv%*%g
- # Update residuals
+ termPar <- norm(g,"2")/sumsq0/100
+ if(termPar < tol) break
+ # Evaulate sum square error
fn <- l$Y-l$X%*%theta
sumsq <- sum(fn^2)
sumSqDiff <- sumsq0-sumsq
countObj <- countObj + 1
- if(abs(sumSqDiff)/100 < tol) break
+
# If sum square error with the updated parameters is less than the
# previous one, the updated parameters become the current parameters
# and the damping coefficient is reduced by a factor of mu
@@ -51,10 +53,10 @@ levbmqdt <- function(...,obj,theta0,N,opt){
}
}
- if((abs(sumSqDiff)/100 < tol)||(i == maxIter)) break
+ if(termPar < tol)||(i == maxIter)) break
}
- if(abs(sumSqDiff)/100 < tol){
+ if(termPar < tol){
WhyStop <- "Tolerance"
} else{
WhyStop <- "Maximum Iteration Limit"