[Pomp-commits] r774 - branches/mif2/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Aug 14 16:24:22 CEST 2012


Author: nxdao2000
Date: 2012-08-14 16:24:21 +0200 (Tue, 14 Aug 2012)
New Revision: 774

Modified:
   branches/mif2/R/mif.R
Log:
checking condition for mif2 with cooling.fraction and not mif2 with cooling.factor

Modified: branches/mif2/R/mif.R
===================================================================
--- branches/mif2/R/mif.R	2012-08-13 16:44:22 UTC (rev 773)
+++ branches/mif2/R/mif.R	2012-08-14 14:24:21 UTC (rev 774)
@@ -163,9 +163,17 @@
 		)
 	}
 	
-	if (missing(cooling.factor))
+	if (missing(option) && missing(method))
+		stop("mif error: ",sQuote("option")," must be specified",call.=FALSE)
+	if (missing(option) && !missing(method) )
+	{	option <- method
+		warning(sQuote("mif")," warning: ",sQuote("method")," flag is deprecated, use ",sQuote("option"))
+	}
+	if (missing(cooling.factor)&&(option=="mif2"))	##Default value for the slot cooling.fraction
+		cooling.factor=1
+	if (missing(cooling.factor)&&(option!="mif2"))
 		stop("mif error: ",sQuote("cooling.factor")," must be specified",call.=FALSE)
-	if ((length(cooling.factor)!=1)||(cooling.factor < 0)||(cooling.factor>1))
+	if ((option!="mif2")&&((length(cooling.factor)!=1)||(cooling.factor < 0)||(cooling.factor>1)))
 		stop("mif error: ",sQuote("cooling.factor")," must be a number between 0 and 1",call.=FALSE)
 	
 	if (missing(var.factor))
@@ -178,13 +186,6 @@
 	Nmif <- as.integer(Nmif)
 	if (Nmif<0)
 		stop("mif error: ",sQuote("Nmif")," must be a positive integer",call.=FALSE)
-	
-	if (missing(option) && missing(method))
-		stop("mif error: ",sQuote("option")," must be specified",call.=FALSE)
-	if (missing(option) && !missing(method) )
-	{	option <- method
-		warning(sQuote("mif")," warning: ",sQuote("method")," flag is deprecated, use ",sQuote("option"))
-	}	
 	if (option=="mif2" && missing(cooling.fraction))
 		stop("mif error: ",sQuote("cooling.fraction")," must be specified for method mif2",call.=FALSE)
 	if (option=="mif2")
@@ -353,12 +354,23 @@
 				stop("mif error: ",sQuote("ic.lag")," must be specified",call.=FALSE)
 			if (missing(var.factor))
 				stop("mif error: ",sQuote("var.factor")," must be specified",call.=FALSE)
-			if (missing(cooling.factor))
-				stop("mif error: ",sQuote("cooling.factor")," must be specified",call.=FALSE)
+			
 			if (missing(option)&& missing(method))
 				stop("mif error: ",sQuote("option")," must be specified",call.=FALSE)
+			if (missing(option) && !missing(method) )
+			{	option <- method
+				warning(sQuote("mif")," warning: ",sQuote("method")," flag is deprecated, use ",sQuote("option"))
+			}
+			if (!missing(option))
+				option <- match.arg(option)
+			if (missing(cooling.factor)&&(option=="mif2"))	##Default value for the slot cooling.fraction
+				cooling.factor=1
+			if (missing(cooling.factor)&&(option!="mif2"))
+				stop("mif error: ",sQuote("cooling.factor")," must be specified",call.=FALSE)
+			if ((option!="mif2")&&((length(cooling.factor)!=1)||(cooling.factor < 0)||(cooling.factor>1)))
+				stop("mif error: ",sQuote("cooling.factor")," must be a number between 0 and 1",call.=FALSE)
+				
 			
-			option <- match.arg(option)
 			if (option=="mif2" && missing(cooling.fraction))
 				stop("mif error: ",sQuote("cooling.fraction")," must be specified for method mif2",call.=FALSE)
 			if (!missing(weighted)) {
@@ -444,10 +456,12 @@
 				stop("mif error: ",sQuote("ic.lag")," must be specified",call.=FALSE)
 			if (missing(var.factor))
 				stop("mif error: ",sQuote("var.factor")," must be specified",call.=FALSE)
-			if (missing(cooling.factor))
-				stop("mif error: ",sQuote("cooling.factor")," must be specified",call.=FALSE)
+			
 			if (missing(option))
 				option <- object at option
+			if ((option!="mif2") && missing(cooling.factor))
+				cooling.factor <-object at cooling.factor
+			
 			if (option=="mif2" && missing(cooling.fraction))
 				cooling.fraction <- object at cooling.fraction
 			if (option=="mif2" && (missing(paramMatrix)))
@@ -535,7 +549,10 @@
 			
 			if (missing(option))
 				option <- object at option
+			if ((option!="mif2") && missing(cooling.factor))
+				cooling.factor <-object at cooling.factor
 			
+			
 			if (option=="mif2" && missing(cooling.fraction))
 				cooling.fraction <- object at cooling.fraction
 			if (option=="mif2" && (missing(paramMatrix)))
@@ -602,15 +619,16 @@
 			if (missing(Np)) Np <- object at Np
 			if (missing(ic.lag)) ic.lag <- object at ic.lag
 			if (missing(var.factor)) var.factor <- object at var.factor
-			if (missing(cooling.factor)) cooling.factor <- object at cooling.factor
 			if (missing(tol)) tol <- object at tol
 			if (missing(transform)) transform <- object at transform
 			transform <- as.logical(transform)
+			if (missing(option))
+				option <- object at option
+			if ((option!="mif2") && missing(cooling.factor))
+				cooling.factor <-object at cooling.factor
+			
 			if (option!=object at option && option =="mif2")
 				stop("mif error: ",sQuote("option")," for continue should be the same for mif2 option",call.=FALSE)
-			
-			if (missing(option))
-				option <- object at option
 			if (option=="mif2" && missing(cooling.fraction))
 				cooling.fraction <- object at cooling.fraction
 			if (option=="mif2" && (missing(paramMatrix)))



More information about the pomp-commits mailing list