Learn R Programming

mtk (version 1.0)

mtkNativeEvaluator-class: The mtkNativeEvaluator class

Description

The mtkNativeEvaluator class is a sub-class of the class mtkEvaluator used to manage the simulation task implemented locally (i.e. tasks don't need to call services from the Web). It provides all the slots and methods defined in the class mtkEvaluator.

Arguments

Class Hierarchy

Parent classes :
mtkEvaluator
Direct Known Subclasses :

Constructor

mtkNativeEvaluator
signature(model=NULL, Y=NULL, information=NULL)

Slots

model:
(ANY) a string, an R fonction, or NULL to inform the model to simulate.
name:
(character) always takes the string "evaluate".
protocol:
(character) a string to name the protocol used to run the process: http, system, R, etc. Here, it always takes "R".
site:
(character) a string to indicate where the service is located. Here, it always takes "mtk".
service:
(character) a string to name the service to invoke.
parameters:
(vector) a vector of [mtkParameter] containing the parameters to pass while calling the service.
ready:
(logical) a logical to tell if the process is ready to run.
state:
(logical) a logical to tell if the results produced by the process are available and ready to be consumed.
result:
(ANY) a data holder to hold the results produced by the process

Methods

setName
signature(this = "mtkNativeEvaluator", name = "character"): Not used, method inherited from the parent class.
setParameters
signature(this = "mtkNativeEvaluator", f = "vector"): Assigns new parameters to the process.
getParameters
signature(this = "mtkNativeEvaluator"): Returns the parameters as a named list.
is.ready
signature( = "mtkNativeEvaluator"): Tests if the process is ready to run.
setReady
signature(this = "mtkNativeEvaluator", switch = "logical"): Makes the process ready to run.
is.ready
signature( = "mtkNativeEvaluator"): Tests if the results produced by the process are available.
setReady
signature(this = "mtkNativeEvaluator", switch = "logical"): Marks the process as already executed.
getResult
signature(this = "mtkNativeEvaluator"): Returns the results produced by the process as a [mtkEvaluatorResult].
getData
signature(this = "mtkNativeEvaluator"): Returns the results produced by the process as a data.frame.
serializeOn
signature(this = "mtkNativeEvaluator"): Returns all data managed by the process as a named list.
run
signature(this = "mtkNativeEvaluator", context= "mtkExpWorkflow"): runs the simulation.
summary
signature(object = "mtkNativeEvaluator"): Provides a summary of the results produced by the process.
print
signature(x = "mtkNativeEvaluator"): Prints a report of the results produced by the process.
plot
signature(x = "mtkNativeEvaluator"): Plots the results produced by the process.
report
signature(this = "mtkNativeEvaluator"): Reports the results produced by the process.

Details

We can construct an object of the mtkNativeEvaluator class from the following situations: 1) 2) 3) the experimental design is produced off-line and available as a data.frame. We can construct an object of the mtkNativeEvaluator class from the following situations:
  1. The evaluator is provided within the package "mtk";
  2. The evaluator is provided as an R function outside the package "mtk";
  3. The simulation is carried out off-line. We just want to use the "mtk" package for reporting.

References

J. Wang, H. Richard, R. Faivre, H. Monod (2013). Le package mtk, une bibliothèque R pour l'exploration numérique des modèles. In: Analyse de sensibilité et exploration de modèles : Application aux sciences de la nature et de l'environnement (R. Faivre, B. Iooss, S. Mahévas, D. Makowski, H. Monod, Eds). Editions Quae, Versailles.

Examples

Run this code
## 1) Create a model simulation  with the model "Ishigami" implemented in the package "mtk"
	
	evaluator <- mtkNativeEvaluator(model="Ishigami")
	
## 2) Create a model simulation  with a R function implemented outside the package "mtk"

#	a) Create a R function to represent the model of population

	ME <- function(K, Y0, a, t=5, ...){
	
	res <- exp(-a*t)
	res <- Y0+res*(K-Y0)
	res <- K*Y0/res
	out <- as.integer(res)
	
	return(out)	
	}
#	b) Do the sensitivity analysis for the function "ME"

	K <- make.mtkFactor(name="K", nominal=400, distribName="unif",
		distribPara=list(min=100, max=1000))
	Y0 <- make.mtkFactor(name="Y0", nominal=20, distribName="unif",
		distribPara=list(min=1, max=40))
	a <- make.mtkFactor(name="a", nominal=0.1, distribName="unif", 
		distribPara=list(min=0.05, max=0.2))
	factors <- mtkExpFactors(list(K,Y0,a))


	plan <- mtkNativeDesigner ("BasicMonteCarlo", 
		information=c(size=500))

	model <- mtkNativeEvaluator(model=ME, information=c(t=5))

	index<- mtkNativeAnalyser("Regression", information=c(nboot=20) )

	expt <- mtkExpWorkflow( expFactors=factors,
		processesVector=c(
				design= plan,
				evaluate= model,
				analyze= index)
		)
	run(expt)
	summary(expt)
	
##	3) Import the results of model simulation produced off-line 
##	   into an object of mtkNativeEvaluator

	data <- data.frame()
	model <- mtkNativeEvaluator(Y=data, 
		information = list(model="Ishigami"))

Run the code above in your browser using DataLab