[Yuima-commits] r280 - in pkg/yuima: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Mar 18 22:40:48 CET 2014


Author: lorenzo
Date: 2014-03-18 22:40:47 +0100 (Tue, 18 Mar 2014)
New Revision: 280

Modified:
   pkg/yuima/DESCRIPTION
   pkg/yuima/R/sim.euler.R
   pkg/yuima/R/sim.euler.space.discretized.R
Log:
Modified sim.euler.R and sim.euler.space.discretized.R for random starting values

Modified: pkg/yuima/DESCRIPTION
===================================================================
--- pkg/yuima/DESCRIPTION	2014-03-17 21:30:53 UTC (rev 279)
+++ pkg/yuima/DESCRIPTION	2014-03-18 21:40:47 UTC (rev 280)
@@ -1,8 +1,8 @@
 Package: yuima
 Type: Package
 Title: The YUIMA Project package (unstable version)
-Version: 0.1.227
-Date: 2014-03-17
+Version: 0.1.228
+Date: 2014-03-18
 Depends: methods, zoo, stats4, utils, expm
 Suggests: cubature, mvtnorm
 Author: YUIMA Project Team.

Modified: pkg/yuima/R/sim.euler.R
===================================================================
--- pkg/yuima/R/sim.euler.R	2014-03-17 21:30:53 UTC (rev 279)
+++ pkg/yuima/R/sim.euler.R	2014-03-18 21:40:47 UTC (rev 280)
@@ -15,27 +15,40 @@
 #	dX <- xinit
   
 	# 06/11 xinit is an expression: the structure is equal to that of V0   
-	dX_dummy <- xinit
-	if(length(modelstate)==length(dX_dummy)){
-	  for(i in 1:length(modelstate)) {
+  if(length(unique(as.character(xinit)))==1 &&
+       is.numeric(tryCatch(eval(dX_dummy[i],env),error=function(...) FALSE))){
+    dX_dummy<-xinit[1]
+    dummy.val<-eval(dX_dummy, env)
+    for(i in 1:length(modelstate)){
+      assign(modelstate[i],dummy.val[i] ,env)
+    }
+    dX<-vector(mode="numeric",length(dX_dummy))
+    
+    for(i in 1:length(xinit)){
+      dX[i] <- dummy.val[i]
+    }
+  }else{
+    dX_dummy <- xinit
+	  if(length(modelstate)==length(dX_dummy)){
+	    for(i in 1:length(modelstate)) {
 	    if(is.numeric(tryCatch(eval(dX_dummy[i],env),error=function(...) FALSE))){
 	      assign(modelstate[i], eval(dX_dummy[i], env),env)
 	    }else{
 	      assign(modelstate[i], 0, env)
-	    }}
-	} else{ 
-	  yuima.warn("the number of model states do not match the number of initial conditions")
-	  return(NULL)
-	}
+	    }
+	  }
+	}else{ 
+	    yuima.warn("the number of model states do not match the number of initial conditions")
+	    return(NULL)
+	  }
+  
 	# 06/11 we need a initial variable for X_0
-	dX<-vector(mode="numeric",length(dX_dummy))
+	  dX<-vector(mode="numeric",length(dX_dummy))
 	
-	for(i in 1:length(dX_dummy)){
-	  dX[i] <- eval(dX_dummy[i], env)
-	}
-	
-  
-	
+	  for(i in 1:length(dX_dummy)){
+	    dX[i] <- eval(dX_dummy[i], env)
+	  }
+  }
 ##:: set time step	
 	delta <- Terminal/n 
 	

Modified: pkg/yuima/R/sim.euler.space.discretized.R
===================================================================
--- pkg/yuima/R/sim.euler.space.discretized.R	2014-03-17 21:30:53 UTC (rev 279)
+++ pkg/yuima/R/sim.euler.space.discretized.R	2014-03-18 21:40:47 UTC (rev 280)
@@ -13,25 +13,39 @@
 	Terminal <- yuima at sampling@Terminal[1]
 	n <- yuima at sampling@n[1]
 #	dX <- xinit
+  if(length(unique(as.character(xinit)))==1 &&
+       is.numeric(tryCatch(eval(dX_dummy[i],env),error=function(...) FALSE))){
+    dX_dummy<-xinit[1]
+    dummy.val<-eval(dX_dummy, env)
+    for(i in 1:length(modelstate)){
+      assign(modelstate[i],dummy.val[i] ,env)
+    }
+    dX<-vector(mode="numeric",length(dX_dummy))
   
-	dX_dummy <- xinit
-	if(length(modelstate)==length(dX_dummy)){
-	  for(i in 1:length(modelstate)) {
-	    if(is.numeric(tryCatch(eval(dX_dummy[i],env),error=function(...) FALSE))){
-	      assign(modelstate[i], eval(dX_dummy[i], env),env)
-	    }else{
-	      assign(modelstate[i], 0, env)
-	    }}
-	} else{ 
-	  yuima.warn("the number of model states do not match the number of initial conditions")
-	  return(NULL)
-	}
+    for(i in 1:length(xinit)){
+      dX[i] <- dummy.val[i]
+    }
+  }else{
+	  dX_dummy <- xinit
+	  if(length(modelstate)==length(dX_dummy)){
+	    for(i in 1:length(modelstate)) {
+	      if(is.numeric(tryCatch(eval(dX_dummy[i],env),error=function(...) FALSE))){
+	        assign(modelstate[i], eval(dX_dummy[i], env),env)
+	      }else{
+	        assign(modelstate[i], 0, env)
+	      }
+	    }
+	  }else{ 
+	    yuima.warn("the number of model states do not match the number of initial conditions")
+	    return(NULL)
+	  }
 	# 20/11 we need a initial variable for X_0
-	dX<-vector(mode="numeric",length(dX_dummy))
+	  dX<-vector(mode="numeric",length(dX_dummy))
 
-	for(i in 1:length(dX_dummy)){
-	  dX[i] <- eval(dX_dummy[i], env)
-	}
+	  for(i in 1:length(dX_dummy)){
+	    dX[i] <- eval(dX_dummy[i], env)
+	  }
+  }
 	
 	
 ##:: set time step	



More information about the Yuima-commits mailing list