Description Arguments Details Value Author(s) Examples
Note that we encourage the use of more convienient constructors for the creation of model objects.
Since this method is tightly coupled to the internal implementation of the class it is much more likely to change in the future than the other constructors, which can be kept stable much more easily in the future and are therefor encouraged for user code.
This method implements R's initialize generic for objects of class Model
It is called whenever a new object of this class is created by a call to new
with the first argument Model
.
It performs some sanity checks of its arguments and in case those tests pass returns an object of class Model
.
The checks can be turned off.( see arguments)
.Object |
|
times |
|
mat |
A decomposition Operator of some kind |
initialValues |
|
inputFluxes |
|
solverfunc |
|
pass |
Due to the mechanism of S4 object initialization (package "methods")
new
always calls initialize
.
(see the help pages for initialize and initialize-methods for details)
an Object of class Model
Carlos A. Sierra, Markus Mueller
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | #
# vim:set ff=unix expandtab ts=2 sw=2:
require(RUnit)
# We present three possible scenarios:
# 1.) create an object from valid input
# 2.) try to build an Model object with unsound parameters and
# show the savety net in action.
# 3.) force an unsound model to be created that would be rejected by default
# 4.) show some other insensible models being rejected
#
#1.) we first create a sensible model
t_start=0
t_end=10
tn=50
timestep=(t_end-t_start)/tn
t=seq(t_start,t_end,timestep)
A=BoundLinDecompOp(
function(times){
matrix(nrow=3,ncol=3,byrow=TRUE,
c(-1, 0, 0,
0.5, -2, 0,
0, 1, -0.5)
)
},
t_start,
t_end
)
I=BoundInFlux(
function(times){
matrix(nrow=3,ncol=1,byrow=TRUE,
c(-1, 0, 0)
)
},
t_start,
t_end
)
res=Model(t,A,c(0,0,0),I)
#2.)
# Now we present some examples where the constructor protests
# test.correctnessOfModel.impossibleCoefficients
t_start=0
t_end=10
tn=50
timestep=(t_end-t_start)/tn
t=seq(t_start,t_end,timestep)
A=BoundLinDecompOp(
function(times){
matrix(nrow=3,ncol=3,byrow=TRUE,
c(-1, 0, 0,
1, -0.7, 0,
0, 1, -0.5)
)
},
t_start,
t_end
)
I=BoundInFlux(
function(times){
matrix(nrow=3,ncol=1,byrow=TRUE,
c(-1, 0, 0)
)
},
t_start,
t_end
)
checkException(
Model(t,A,c(0,0,0),I),
"correctnessOfModel should have returned FALSE
because the matrix values indicate unbiological
behavior (ruwsum should be smaller than zero),
but has not",silent=TRUE)
#3.)
# force it nevertheless
Model(t,A,c(0,0,0),I,pass=TRUE)
#4.) further examples
# test.correctnessOfModel.impossibleTimeRanges
mess="correctnessOfModel should have returned FALSE, but has not"
t_start=0
t_end=10
tdiff=t_end-t_start
tn=50
timestep=(tdiff)/tn
t=seq(t_start,t_end,timestep)
#we create an A(t) with sensible coeficients
#but where the time range begins to late
A=BoundLinDecompOp(
function(t){
matrix(nrow=3,ncol=3,byrow=TRUE,
c(-1, 0, 0,
1, -0.7, 0,
0, 0.5, -0.5)
)
},
t_start+1/4*tdiff,
t_end
)
I=BoundInFlux(
function(times){
matrix(nrow=3,ncol=1,byrow=TRUE,
c(-1, 0, 0)
)
},
t_start,
t_end
)
checkException(Model(t,A,c(0,0,0),I),mess,silent=TRUE)
#now we do the same to the InFluxes(t) while A(t) is correct
A=BoundLinDecompOp(
function(times){
matrix(nrow=3,ncol=3,byrow=TRUE,
c(-1, 0, 0,
1, -0.7, 0,
0, 0.5, -0.5)
)
},
t_start,
t_end
)
I=BoundInFlux(
function(times){
matrix(nrow=3,ncol=1,byrow=TRUE,
c(-1, 0, 0)
)
},
t_start+1/4*tdiff,
t_end
)
checkException(Model(t,A,c(0,0,0),I),mess,silent=TRUE)
#we create an A(t) with sensible coeficients
#but where the time range ends to early
A=BoundLinDecompOp(
function(times){
matrix(nrow=3,ncol=3,byrow=TRUE,
c(-1, 0, 0,
1, -0.7, 0,
0, 0.5, -0.5)
)
},
t_start,
t_end-1/4*tdiff
)
I=BoundInFlux(
function(times){
matrix(nrow=3,ncol=1,byrow=TRUE,
c(-1, 0, 0)
)
},
t_start,
t_end
)
checkException(Model(t,A,c(0,0,0),I),mess,silent=TRUE)
#now we do the same to the InFluxes(t) while A(t) is correct
A=BoundLinDecompOp(
function(times){
matrix(nrow=3,ncol=3,byrow=TRUE,
c(-1, 0, 0,
1, -0.7, 0,
0, 0.5, -0.5)
)
},
t_start,
t_end
)
I=BoundInFlux(
function(times){
matrix(nrow=3,ncol=1,byrow=TRUE,
c(-1, 0, 0)
)
},
t_start,
t_end-1/4*tdiff
)
checkException(Model(t,A,c(0,0,0),I),mess,silent=TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.