|
7 | 7 | "source": [ |
8 | 8 | "# Implementing a warm-up period\n", |
9 | 9 | "\n", |
10 | | - "We will implement warm-up as an event that resets all of our results collection variables. \n", |
| 10 | + "We will implement warm-up as a single event that resets all of our results collection variables. \n", |
11 | 11 | "\n", |
12 | 12 | "This is a simpler approach than including lots of if statements in `simpy` processes." |
13 | 13 | ] |
|
309 | 309 | }, |
310 | 310 | { |
311 | 311 | "cell_type": "code", |
312 | | - "execution_count": 8, |
| 312 | + "execution_count": 33, |
313 | 313 | "id": "b3e686ce-5371-4471-a052-b9d43309bc85", |
314 | 314 | "metadata": {}, |
315 | 315 | "outputs": [], |
|
334 | 334 | " inter_arrival_time = args.arrival_strokes.sample()\n", |
335 | 335 | " yield env.timeout(inter_arrival_time)\n", |
336 | 336 | "\n", |
337 | | - " args.results[\"n_arrivals\"] = patient_id\n", |
| 337 | + " args.results[\"n_arrivals\"] += 1\n", |
338 | 338 | " \n", |
339 | 339 | " trace(f\"{env.now:.2f}: Stroke arrival.\")\n", |
340 | 340 | "\n", |
|
352 | 352 | }, |
353 | 353 | { |
354 | 354 | "cell_type": "code", |
355 | | - "execution_count": 10, |
| 355 | + "execution_count": 34, |
356 | 356 | "id": "0d0ea6cf-7d95-4d2c-9690-fcdbdae35d84", |
357 | 357 | "metadata": {}, |
358 | 358 | "outputs": [], |
|
414 | 414 | " return results" |
415 | 415 | ] |
416 | 416 | }, |
| 417 | + { |
| 418 | + "cell_type": "markdown", |
| 419 | + "id": "c13f5e57-723c-409b-a1ce-cdb831b4e166", |
| 420 | + "metadata": {}, |
| 421 | + "source": [ |
| 422 | + "## Quick check 1: No warm-up" |
| 423 | + ] |
| 424 | + }, |
417 | 425 | { |
418 | 426 | "cell_type": "code", |
419 | | - "execution_count": 23, |
| 427 | + "execution_count": 35, |
420 | 428 | "id": "caf52390-5455-4fa1-bb22-60b5b91ad8d0", |
421 | 429 | "metadata": {}, |
| 430 | + "outputs": [ |
| 431 | + { |
| 432 | + "name": "stdout", |
| 433 | + "output_type": "stream", |
| 434 | + "text": [ |
| 435 | + "0.00: 🥵 Warm up complete.\n", |
| 436 | + "3.29: Stroke arrival.\n", |
| 437 | + "3.29: Patient 1 admitted to acute ward.(waited 0.00 days)\n", |
| 438 | + "4.06: Stroke arrival.\n", |
| 439 | + "4.06: Patient 2 admitted to acute ward.(waited 0.00 days)\n" |
| 440 | + ] |
| 441 | + }, |
| 442 | + { |
| 443 | + "data": { |
| 444 | + "text/plain": [ |
| 445 | + "{'mean_acute_wait': 0.0}" |
| 446 | + ] |
| 447 | + }, |
| 448 | + "execution_count": 35, |
| 449 | + "metadata": {}, |
| 450 | + "output_type": "execute_result" |
| 451 | + } |
| 452 | + ], |
| 453 | + "source": [ |
| 454 | + "TRACE = True\n", |
| 455 | + "experiment = Experiment()\n", |
| 456 | + "results = single_run(experiment, rep=0, wu_period=0.0, rc_period=5.0)\n", |
| 457 | + "results" |
| 458 | + ] |
| 459 | + }, |
| 460 | + { |
| 461 | + "cell_type": "code", |
| 462 | + "execution_count": 36, |
| 463 | + "id": "ddedb4f1-207d-4295-9ae4-c49b2c7cdcaf", |
| 464 | + "metadata": {}, |
| 465 | + "outputs": [ |
| 466 | + { |
| 467 | + "data": { |
| 468 | + "text/plain": [ |
| 469 | + "{'n_arrivals': 2, 'waiting_acute': [0.0, 0.0]}" |
| 470 | + ] |
| 471 | + }, |
| 472 | + "execution_count": 36, |
| 473 | + "metadata": {}, |
| 474 | + "output_type": "execute_result" |
| 475 | + } |
| 476 | + ], |
| 477 | + "source": [ |
| 478 | + "# check how many patient waiting times recorded.\n", |
| 479 | + "experiment.results" |
| 480 | + ] |
| 481 | + }, |
| 482 | + { |
| 483 | + "cell_type": "markdown", |
| 484 | + "id": "660ea2e1-d9c2-4355-876c-43dfd9dab0fe", |
| 485 | + "metadata": {}, |
| 486 | + "source": [ |
| 487 | + "## Quick check 1: Include a warm-up" |
| 488 | + ] |
| 489 | + }, |
| 490 | + { |
| 491 | + "cell_type": "code", |
| 492 | + "execution_count": 37, |
| 493 | + "id": "72b5284a-1fcb-4126-b663-c0ef0002e4bf", |
| 494 | + "metadata": {}, |
422 | 495 | "outputs": [ |
423 | 496 | { |
424 | 497 | "name": "stdout", |
|
443 | 516 | "{'mean_acute_wait': 0.0}" |
444 | 517 | ] |
445 | 518 | }, |
446 | | - "execution_count": 23, |
| 519 | + "execution_count": 37, |
447 | 520 | "metadata": {}, |
448 | 521 | "output_type": "execute_result" |
449 | 522 | } |
|
457 | 530 | }, |
458 | 531 | { |
459 | 532 | "cell_type": "code", |
460 | | - "execution_count": 24, |
461 | | - "id": "ddedb4f1-207d-4295-9ae4-c49b2c7cdcaf", |
| 533 | + "execution_count": 38, |
| 534 | + "id": "7f5e282b-0f41-41df-bdca-f128e7d418c1", |
462 | 535 | "metadata": {}, |
463 | 536 | "outputs": [ |
464 | 537 | { |
465 | 538 | "data": { |
466 | 539 | "text/plain": [ |
467 | | - "{'n_arrivals': 5, 'waiting_acute': [0.0, 0.0, 0.0]}" |
| 540 | + "{'n_arrivals': 3, 'waiting_acute': [0.0, 0.0, 0.0]}" |
468 | 541 | ] |
469 | 542 | }, |
470 | | - "execution_count": 24, |
| 543 | + "execution_count": 38, |
471 | 544 | "metadata": {}, |
472 | 545 | "output_type": "execute_result" |
473 | 546 | } |
|
0 commit comments