44 enum event_t {toDeath, toPCDeath, toLocalised, toDxLocalised,
46 toLocallyAdvanced, toMetastatic, toDxMetastatic};
58 static std::map<std::string, std::vector<double> >
report;
59 static std::map<std::string, Rng *> rng;
61 static void resetPopulation ();
65 virtual void handleMessage(
const cMessage* msg);
66 virtual Time age() {
return now(); }
75 std::map<std::string, Rng *> Person::rng;
92 (gleason==
gleason7 ? 1.3874 : 1.4027 * 1.3874);
100 if (R::runif(0.0,1.0)<0.2241)
101 scheduleAt(R::rweibull(exp(2.3525),64.0218),toLocalised);
102 scheduleAt(R::rexp(80.0),toDeath);
112 report[
"id"].push_back(
id);
113 report[
"startTime"].push_back(previousEventTime);
115 report[
"state"].push_back(stage);
120 if (msg->
kind == toDeath) {
121 Sim::stop_simulation();
124 else if (msg->
kind == toPCDeath) {
125 Sim::stop_simulation();
128 else if (msg->
kind == toLocalised) {
130 gleason = (R::runif(0.0,1.0)<0.6812) ?
gleasonLt7 :
136 pDx = 1.1308/(2.1308);
137 if (R::runif(0.0,1.0)<pDx) {
138 scheduleAt(dwellTime, toDxLocalised);
141 scheduleAt(dwellTime,toLocallyAdvanced);
145 else if (msg->
kind == toLocallyAdvanced) {
151 pDx = 0.5900/(1.0+0.5900);
152 if (R::runif(0.0,1.0)<pDx) {
153 scheduleAt(dwellTime, toDxLocallyAdvanced);
156 scheduleAt(dwellTime,toMetastatic);
160 else if (msg->
kind == toMetastatic) {
166 pDx = 1.3147/(1.0+1.3147);
167 if (R::runif(0.0,1.0)<pDx) {
168 scheduleAt(dwellTime, toDxMetastatic);
171 scheduleAt(dwellTime,toPCDeath);
175 else if (msg->
kind == toDxLocalised) {
180 else if (msg->
kind == toDxLocallyAdvanced) {
185 else if (msg->
kind == toDxMetastatic) {
196 Rcpp::List parmsl(parms);
197 Rcpp::IntegerVector inseed2(inseed);
198 int nin = Rcpp::as<int>(parmsl[
"n"]);
200 for (
int i=0; i<6; i++) {
204 RngStream::SetPackageSeed(seed);
206 Person::rng[
"NH"] =
new Rng();
207 Person::rng[
"S"] =
new Rng();
208 Person::rng[
"NH"]->set();
210 for (
int i = 0; i < nin; i++) {
212 Person::rng[
"NH"]->nextSubstream();
213 Person::rng[
"S"]->nextSubstream();
215 Sim::create_process(&person);
216 Sim::run_simulation();
220 delete Person::rng[
"NH"];
221 delete Person::rng[
"S"];
234 class VerySimple :
public cProcess {
237 scheduleAt(10.0,
"a message");
238 scheduleAt(11.0,
"another message");
240 virtual void handleMessage(
const cMessage* msg) {};
245 RcppExport SEXP callSpeedTest() {
247 for (
int i = 0; i < 1000000; i++) {
248 simple = VerySimple();
249 Sim::create_process(&simple);
250 Sim::run_simulation();