|
66 | 66 | "# default mean inter-arrival time (exp)\n", |
67 | 67 | "MEAN_IAT = 60 / 100\n", |
68 | 68 | "\n", |
69 | | - "## default service time parameters (triangular)\n", |
| 69 | + "# default service time parameters (triangular)\n", |
70 | 70 | "CALL_LOW = 5.0\n", |
71 | 71 | "CALL_MODE = 7.0\n", |
72 | 72 | "CALL_HIGH = 10.0\n", |
|
415 | 415 | "outputs": [], |
416 | 416 | "source": [ |
417 | 417 | "def service(identifier, env, args):\n", |
418 | | - " '''\n", |
| 418 | + " \"\"\"\n", |
419 | 419 | " simulates the service process for a call operator\n", |
420 | 420 | "\n", |
421 | 421 | " 1. request and wait for a call operator\n", |
422 | 422 | " 2. phone triage (triangular)\n", |
423 | 423 | " 3. exit system\n", |
424 | | - " \n", |
| 424 | + "\n", |
425 | 425 | " Params:\n", |
426 | 426 | " ------\n", |
427 | | - " \n", |
428 | | - " identifier: int \n", |
| 427 | + "\n", |
| 428 | + " identifier: int\n", |
429 | 429 | " A unique identifer for this caller\n", |
430 | 430 | "\n", |
431 | 431 | " env: simpy.Environment\n", |
432 | 432 | " The current environent the simulation is running in\n", |
433 | 433 | " We use this to pause and restart the process after a delay.\n", |
434 | | - " \n", |
| 434 | + "\n", |
435 | 435 | " args: Experiment\n", |
436 | 436 | " The settings and input parameters for the current experiment\n", |
437 | | - " \n", |
438 | | - " '''\n", |
439 | | - " \n", |
| 437 | + "\n", |
| 438 | + " \"\"\"\n", |
| 439 | + "\n", |
440 | 440 | " # record the time that call entered the queue\n", |
441 | 441 | " start_wait = env.now\n", |
442 | | - " \n", |
| 442 | + "\n", |
443 | 443 | " # request an operator\n", |
444 | 444 | " with args.operators.request() as req:\n", |
445 | 445 | " yield req\n", |
446 | | - " \n", |
| 446 | + "\n", |
447 | 447 | " # record the waiting time for call to be answered\n", |
448 | 448 | " waiting_time = env.now - start_wait\n", |
449 | | - " \n", |
| 449 | + "\n", |
450 | 450 | " # ######################################################################\n", |
451 | | - " # MODIFICATION: store the results for an experiment \n", |
452 | | - " args.results['waiting_times'].append(waiting_time)\n", |
| 451 | + " # MODIFICATION: store the results for an experiment\n", |
| 452 | + " args.results[\"waiting_times\"].append(waiting_time)\n", |
453 | 453 | " # ######################################################################\n", |
454 | 454 | "\n", |
455 | | - " trace(f'operator answered call {identifier} at ' \\\n", |
456 | | - " + f'{env.now:.3f}')\n", |
| 455 | + " trace(f\"operator answered call {identifier} at \" + f\"{env.now:.3f}\")\n", |
457 | 456 | "\n", |
458 | 457 | " # ######################################################################\n", |
459 | 458 | " # MODIFICATION: the sample distribution is defined by the experiment.\n", |
460 | | - " call_duration = args.call_dist.sample() \n", |
| 459 | + " call_duration = args.call_dist.sample()\n", |
461 | 460 | " # ######################################################################\n", |
462 | | - " \n", |
| 461 | + "\n", |
463 | 462 | " # schedule process to begin again after call_duration\n", |
464 | 463 | " yield env.timeout(call_duration)\n", |
465 | | - " \n", |
466 | | - " # update the total call_duration \n", |
467 | | - " args.results['total_call_duration'] += call_duration\n", |
| 464 | + "\n", |
| 465 | + " # update the total call_duration\n", |
| 466 | + " args.results[\"total_call_duration\"] += call_duration\n", |
468 | 467 | "\n", |
469 | 468 | " # print out information for patient.\n", |
470 | | - " trace(f'call {identifier} ended {env.now:.3f}; ' \\\n", |
471 | | - " + f'waiting time was {waiting_time:.3f}')" |
| 469 | + " trace(\n", |
| 470 | + " f\"call {identifier} ended {env.now:.3f}; \"\n", |
| 471 | + " + f\"waiting time was {waiting_time:.3f}\"\n", |
| 472 | + " )" |
472 | 473 | ] |
473 | 474 | }, |
474 | 475 | { |
|
561 | 562 | " / (rc_period * experiment.n_operators)\n", |
562 | 563 | " ) * 100.0\n", |
563 | 564 | "\n", |
564 | | - " print(f\"Experiment complete\")\n", |
| 565 | + " print(\"Experiment complete\")\n", |
565 | 566 | "\n", |
566 | 567 | " # return the results from the run of the model\n", |
567 | 568 | " return results" |
|
0 commit comments