-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
608 lines (605 loc) · 29.4 KB
/
Copy pathindex.html
File metadata and controls
608 lines (605 loc) · 29.4 KB
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-MXPNPC63XE"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-MXPNPC63XE');
</script>
<script src="https://analytics.ahrefs.com/analytics.js" data-key="XXjnJNtZV6bAICAw3Uqc6A" async></script>
<meta name="ahrefs-site-verification" content="b1f1573b895ead5763166ba77346fa86ecb9449ac31144c6786475fa1c2e1e5f">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="color-scheme" content="light">
<meta http-equiv="x-ua-compatible" content="IE=edge">
<meta name="theme-color" content="#14532d">
<meta name="geo.region" content="TW-TAO">
<meta name="geo.placename" content="Guishan, Taoyuan, Taiwan">
<meta name="geo.position" content="25.0375;121.3892">
<meta name="ICBM" content="25.0375, 121.3892">
<title>CASMIM — SARS Epidemic Dynamics Simulation | CANS Lab</title>
<meta name="description" content="CASMIM SARS Epidemic Dynamics Simulation with Public Health Policy Assessments 基於元胞自動機的社會鏡像身份模型(CASMIM)模擬器,用於探索身份認同與社會動態。">
<meta name="author" content="Prof. Chung-Yuan Huang (黃崇源教授)">
<meta property="og:title" content="CASMIM — SARS Epidemic Dynamics Simulation | CANS Lab">
<meta property="og:description" content="CASMIM SARS Epidemic Dynamics Simulation with Public Health Policy Assessments">
<meta property="og:url" content="https://canslab1.github.io/CASMIM/">
<meta property="og:type" content="website">
<meta property="og:locale" content="en_US">
<meta property="og:locale:alternate" content="zh_TW">
<meta property="og:site_name" content="CANS Lab — Complex Adaptive Networks and Systems">
<meta property="og:image" content="https://canslab1.github.io/images/software/casmim-gui.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:image:alt" content="CASMIM SARS epidemic simulation on a 500x500 cellular automata lattice">
<meta property="og:see_also" content="https://github.com/canslab1/CASMIM">
<meta property="og:see_also" content="https://canslab1.github.io/">
<meta property="og:see_also" content="https://doi.org/10.1177/0037549705061519">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="CASMIM — SARS Epidemic Dynamics Simulation | CANS Lab">
<meta name="twitter:description" content="CASMIM SARS Epidemic Dynamics Simulation with Public Health Policy Assessments">
<meta name="twitter:image" content="https://canslab1.github.io/images/software/casmim-gui.png">
<meta name="twitter:image:alt" content="CASMIM SARS epidemic simulation on a 500x500 cellular automata lattice">
<meta name="twitter:label1" content="Language">
<meta name="twitter:data1" content="Python">
<meta name="twitter:label2" content="License">
<meta name="twitter:data2" content="MIT">
<meta name="keywords" content="CASMIM, SARS, epidemic simulation, cellular automata, agent-based model, CANS Lab, 黃崇源, 長庚大學, 元胞自動機, 社會模擬, 鏡像身份, 身份認同, 複雜系統">
<meta name="robots" content="index, follow, max-image-preview:large, max-snippet:-1">
<link rel="canonical" href="https://canslab1.github.io/CASMIM/">
<link rel="alternate" hreflang="en" href="https://canslab1.github.io/CASMIM/">
<link rel="alternate" hreflang="x-default" href="https://canslab1.github.io/CASMIM/">
<link rel="icon" href="https://canslab1.github.io/images/csie.png" type="image/png">
<link rel="apple-touch-icon" href="https://canslab1.github.io/images/icon-192.png" sizes="192x192">
<link rel="dns-prefetch" href="https://cdnjs.cloudflare.com">
<link rel="dns-prefetch" href="https://www.googletagmanager.com">
<link rel="preconnect" href="https://cdnjs.cloudflare.com" crossorigin>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/styles/github-dark.min.css">
<link rel="stylesheet" href="https://canslab1.github.io/css/project-page.css">
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "SoftwareSourceCode",
"name": "CASMIM",
"description": "A small-world epidemiological simulation model combining cellular automata with social mirror identities to simulate SARS transmission dynamics and evaluate public health policy interventions.",
"codeRepository": "https://github.com/canslab1/CASMIM",
"url": "https://canslab1.github.io/CASMIM/",
"programmingLanguage": "Python",
"license": "https://opensource.org/licenses/MIT",
"author": {
"@type": "Person",
"@id": "https://canslab1.github.io/#person",
"name": "Chung-Yuan Huang",
"alternateName": ["黃崇源", "黃崇源教授", "CY Huang", "C.-Y. Huang", "Huang, Chung-Yuan", "Prof. Chung-Yuan Huang", "GSCOTT"],
"url": "https://canslab1.github.io/",
"affiliation": {
"@type": "CollegeOrUniversity",
"name": "Chang Gung University",
"alternateName": "長庚大學"
},
"sameAs": [
"https://canslab1.github.io/",
"https://scholar.google.com/citations?user=0klfzfAAAAAJ&hl=en",
"https://orcid.org/0000-0002-8680-6755",
"https://github.com/canslab1",
"https://www.wikidata.org/wiki/Q138673497"
]
},
"version": "2.1.0",
"dateModified": "2026-03-11",
"keywords": ["SARS", "epidemic simulation", "cellular automata", "agent-based model", "public health"]
},
{
"@type": "WebPage",
"name": "CASMIM — README",
"url": "https://canslab1.github.io/CASMIM/",
"isPartOf": {
"@type": "WebSite",
"name": "CANS Lab",
"url": "https://canslab1.github.io/"
}
}
]
}
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{ "@type": "ListItem", "position": 1, "name": "CANS Lab", "item": "https://canslab1.github.io/" },
{ "@type": "ListItem", "position": 2, "name": "CASMIM", "item": "https://canslab1.github.io/CASMIM/" }
]
}
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "ScholarlyArticle",
"name": "A Novel Small-World Model: Using Social Mirror Identities for Epidemic Simulations",
"headline": "A Novel Small-World Model: Using Social Mirror Identities for Epidemic Simulations",
"author": [
{ "@type": "Person", "name": "Chung-Yuan Huang", "@id": "https://canslab1.github.io/#person" },
{ "@type": "Person", "name": "Chuen-Tsai Sun" },
{ "@type": "Person", "name": "Ji-Lung Hsieh" },
{ "@type": "Person", "name": "Yi-Ming Arthur Chen" },
{ "@type": "Person", "name": "Holin Lin" }
],
"datePublished": "2005",
"isPartOf": {
"@type": "PublicationIssue",
"issueNumber": "10",
"isPartOf": {
"@type": "PublicationVolume",
"volumeNumber": "81",
"isPartOf": {
"@type": "Periodical",
"name": "SIMULATION"
}
}
},
"pageStart": "671",
"pageEnd": "699",
"url": "https://doi.org/10.1177/0037549705061519",
"sameAs": "https://doi.org/10.1177/0037549705061519",
"publisher": { "@type": "Organization", "name": "SAGE Publications" }
}
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "ResearchOrganization",
"name": "Complex Adaptive Networks and Systems Laboratory",
"alternateName": ["CANS Lab", "複雜適應性網絡與系統實驗室"],
"url": "https://canslab1.github.io/",
"parentOrganization": {
"@type": "CollegeOrUniversity",
"name": "Chang Gung University",
"alternateName": "長庚大學",
"url": "https://www.cgu.edu.tw/"
},
"member": { "@type": "Person", "@id": "https://canslab1.github.io/#person" }
}
</script>
<!-- Dublin Core -->
<meta name="DC.title" content="CASMIM — Cellular Automata and Social Mirror Identities SARS Simulation">
<meta name="DC.creator" content="Chung-Yuan Huang (黃崇源)">
<meta name="DC.subject" content="SARS; Epidemic Simulation; Cellular Automata; Agent-Based Model; Public Health">
<meta name="DC.description" content="Small-world epidemiological simulation model combining cellular automata with social mirror identities">
<meta name="DC.publisher" content="CANS Lab, Chang Gung University">
<meta name="DC.type" content="Software">
<meta name="DC.format" content="text/html">
<meta name="DC.language" content="en">
<meta name="DC.identifier" content="https://canslab1.github.io/CASMIM/">
<meta name="DC.date" content="2026-03-11">
<meta name="DC.rights" content="MIT License">
<meta name="DCTERMS.modified" content="2026-03-11">
<meta name="DC.coverage" content="Taiwan; International">
<meta name="DC.contributor" content="Chuen-Tsai Sun; Ji-Lung Hsieh; Yi-Ming Arthur Chen; Holin Lin">
<meta name="DC.relation" content="https://github.com/canslab1/CASMIM">
<meta name="DC.relation" content="https://canslab1.github.io/">
<meta name="DC.relation" content="https://doi.org/10.1177/0037549705061519">
<meta name="DCTERMS.audience" content="Researchers; Graduate Students; Epidemiologists">
<!-- Highwire Press (Google Scholar) -->
<meta name="citation_title" content="A Novel Small-World Model: Using Social Mirror Identities for Epidemic Simulations">
<meta name="citation_author" content="Huang, Chung-Yuan">
<meta name="citation_author" content="黃崇源">
<meta name="citation_author_institution" content="Chang Gung University">
<meta name="citation_author_orcid" content="0000-0002-8680-6755">
<meta name="citation_author" content="Sun, Chuen-Tsai">
<meta name="citation_author_institution" content="National Yang Ming Chiao Tung University">
<meta name="citation_author" content="Hsieh, Ji-Lung">
<meta name="citation_author_institution" content="National Taiwan University">
<meta name="citation_author" content="Chen, Yi-Ming Arthur">
<meta name="citation_author_institution" content="National Central University">
<meta name="citation_author" content="Lin, Holin">
<meta name="citation_author_institution" content="National Taiwan University">
<meta name="citation_journal_title" content="SIMULATION">
<meta name="citation_volume" content="81">
<meta name="citation_issue" content="10">
<meta name="citation_firstpage" content="671">
<meta name="citation_lastpage" content="699">
<meta name="citation_publication_date" content="2005">
<meta name="citation_doi" content="10.1177/0037549705061519">
<link rel="author" href="https://canslab1.github.io/humans.txt">
<link rel="security" type="text/plain" href="https://canslab1.github.io/security.txt">
</head>
<body>
<a href="#content" class="skip-link">Skip to content</a>
<header class="site-header">
<div class="header-inner">
<a class="header-brand" href="https://canslab1.github.io/">
<img src="https://canslab1.github.io/images/csie.png" alt="CANS Lab logo" width="32" height="32">
<span>CANS Lab</span>
</a>
<nav class="header-nav" aria-label="CASMIM navigation">
<a href="https://canslab1.github.io/">Lab Home</a>
<a href="https://github.com/canslab1/CASMIM" target="_blank" rel="noopener noreferrer">GitHub Repo</a>
</nav>
</div>
</header>
<main class="content-wrapper">
<article class="markdown-body" id="content" aria-live="polite">
<h1>CASMIM — Cellular Automata with Social Mirror Identities Model</h1>
<!-- PRERENDER-START -->
<p><img alt="Python 3.10+" src="https://img.shields.io/badge/Python-3.10%2B-blue">
<img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-green">
<a href="https://canslab1.github.io/"><img alt="CANS Lab" src="https://img.shields.io/badge/CANS_Lab-Homepage-orange"></a></p>
<p>A Python 3 implementation of the <strong>CASMIM</strong> model for simulating SARS transmission dynamics and evaluating public health policy interventions on a small-world epidemiological network.</p>
<h2 id="overview">Overview</h2>
<p>In the early 2000s, SARS outbreaks in cities such as Singapore, Taipei, and Toronto demonstrated how daily-contact social networks and long-distance movement could rapidly amplify disease spread. CASMIM addresses this by combining cellular automata with a "social mirror identity" mechanism: each person owns multiple <em>agents</em> (mirrors) scattered across a 500 × 500 torus lattice, representing the different social spheres (home, workplace, hospital, etc.) that a single individual participates in daily.</p>
<p>The model integrates:</p>
<ul>
<li><strong>Cellular Automata</strong> on a 2D torus lattice (500 × 500) for spatial agent interactions</li>
<li><strong>Social Mirror Identities</strong> to represent daily-contact social networks and long-distance movement</li>
<li><strong>SEIR+D compartmental model</strong> (Susceptible → Exposed → Infective → Recovered → Immune → Susceptible, with Death branch)</li>
<li><strong>8 public health policies</strong> (mask wearing, temperature screening, hospitalization, home quarantine, contact reduction, visit restriction, vaccination, medical policy)</li>
<li><strong>Contact tracing</strong> via BFS-based algorithms with level-1 and level-2 quarantine</li>
<li><strong>Super-spreader modeling</strong> and <strong>age-stratified mortality</strong></li>
</ul>
<p>The model was originally developed in Borland C++ Builder (2003-2005) and has been ported to Python 3 with a PySide6 (Qt) GUI.</p>
<h2 id="features">Features</h2>
<ul>
<li><strong>Interactive lattice visualization</strong> — 500 × 500 macro lattice and 100 × 100 micro lattice with click-to-navigate</li>
<li><strong>Real-time SEIR+D display</strong> — Color-coded agents (sky-blue = susceptible/exposed/immune, red = infective, silver = recovered, black = died)</li>
<li><strong>6 chart types</strong> — Accumulation, incidence, notification, infection, accumulative quarantine, daily quarantine</li>
<li><strong>8 configurable policies</strong> — Each policy can be toggled on/off during simulation with adjustable effect and coverage rates</li>
<li><strong>Dynamic policy activation</strong> — Policies can be enabled or disabled mid-simulation to study intervention timing</li>
<li><strong>Super-spreader modeling</strong> — Configurable probability for super-spreader designation</li>
<li><strong>Excel output</strong> — Simulation statistics exported via openpyxl with 4 output sheets (cumulative counts, daily deltas, action log, running averages)</li>
<li><strong>Numba JIT acceleration</strong> — Core simulation loop compiled to native code via Numba <code>@njit</code>, achieving ~8x speedup over pure Python; fallback to Python path via <code>CASMIM_NO_NUMBA=1</code></li>
<li><strong>NumPy-accelerated</strong> — Structure-of-Arrays (SoA) data layout with vectorized operations for population-level computations</li>
</ul>
<h2 id="installation">Installation</h2>
<pre><code class="language-bash">git clone https://github.com/canslab1/CASMIM.git
cd CASMIM
pip install -r requirements.txt
</code></pre>
<h3 id="dependencies">Dependencies</h3>
<table>
<thead>
<tr>
<th>Package</th>
<th>Version</th>
</tr>
</thead>
<tbody>
<tr>
<td>PySide6</td>
<td>≥ 6.5</td>
</tr>
<tr>
<td>NumPy</td>
<td>≥ 1.24</td>
</tr>
<tr>
<td>Numba</td>
<td>≥ 0.60.0</td>
</tr>
<tr>
<td>pyqtgraph</td>
<td>≥ 0.13</td>
</tr>
<tr>
<td>openpyxl</td>
<td>≥ 3.1</td>
</tr>
</tbody>
</table>
<h2 id="usage">Usage</h2>
<pre><code class="language-bash">python main.py
</code></pre>
<p>This launches the GUI application with:</p>
<ul>
<li><strong>Left panel</strong>: Disease parameters (Disease tab), population parameters (World tab), policy controls (Policy tab) with checkboxes and effect/coverage sliders</li>
<li><strong>Center panel</strong>: Macro tab (500 × 500 lattice) with real-time color-coded agent states; click to navigate the Micro tab (100 × 100 magnified view)</li>
<li><strong>Right panel</strong>: 6 pyqtgraph chart widgets displaying accumulation, incidence, notification, infection, and quarantine statistics</li>
<li><strong>Bottom panel</strong>: 9-panel status bar showing coordinates, agent state, identity, current day, and mortality summary</li>
</ul>
<h3 id="controls">Controls</h3>
<table>
<thead>
<tr>
<th>Control</th>
<th>Function</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Stop</strong></td>
<td>Pause the simulation</td>
</tr>
<tr>
<td><strong>Go</strong></td>
<td>Execute continuous simulation (one day per step)</td>
</tr>
<tr>
<td><strong>Setup</strong></td>
<td>Initialize (or re-initialize) the population and lattice</td>
</tr>
<tr>
<td><strong>Policy checkboxes</strong></td>
<td>Toggle individual policies on/off during simulation</td>
</tr>
<tr>
<td><strong>Vaccine button</strong></td>
<td>Administer a batch of vaccines to random unvaccinated individuals</td>
</tr>
</tbody>
</table>
<h3 id="environment-variables">Environment Variables</h3>
<table>
<thead>
<tr>
<th>Variable</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>CASMIM_NO_NUMBA=1</code></td>
<td>Disable Numba JIT and use the pure Python engine (useful for debugging or when Numba is unavailable)</td>
</tr>
</tbody>
</table>
<h2 id="disease-parameters">Disease Parameters</h2>
<table>
<thead>
<tr>
<th>Parameter</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>exposed_period</code></td>
<td>5</td>
<td>Average incubation period (days)</td>
</tr>
<tr>
<td><code>symptomatic_period</code></td>
<td>23</td>
<td>Average symptomatic duration (days)</td>
</tr>
<tr>
<td><code>infective_period</code></td>
<td>3</td>
<td>Average infectious period (days)</td>
</tr>
<tr>
<td><code>recovered_period</code></td>
<td>7</td>
<td>Average recovery period (days)</td>
</tr>
<tr>
<td><code>immune_period</code></td>
<td>60</td>
<td>Average immunity duration (days)</td>
</tr>
<tr>
<td><code>quarantine_period</code></td>
<td>10</td>
<td>Quarantine/isolation duration (days)</td>
</tr>
<tr>
<td><code>transmission_prob</code></td>
<td>0.05</td>
<td>Per-contact infection probability</td>
</tr>
<tr>
<td><code>immune_prob</code></td>
<td>0.02</td>
<td>Natural immunity probability</td>
</tr>
<tr>
<td><code>detect_rate</code></td>
<td>0.9</td>
<td>Symptom detection rate</td>
</tr>
<tr>
<td><code>super_rate</code></td>
<td>0.0001</td>
<td>Super-spreader designation probability</td>
</tr>
<tr>
<td><code>mortality_old</code></td>
<td>0.52</td>
<td>Mortality rate for elderly</td>
</tr>
<tr>
<td><code>mortality_prime</code></td>
<td>0.17</td>
<td>Mortality rate for prime-age adults</td>
</tr>
<tr>
<td><code>mortality_young</code></td>
<td>0.05</td>
<td>Mortality rate for young individuals</td>
</tr>
</tbody>
</table>
<h2 id="policy-parameters">Policy Parameters</h2>
<table>
<thead>
<tr>
<th>Policy</th>
<th>Effect</th>
<th>Coverage</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>Mask wearing</td>
<td>0.9</td>
<td>0.9</td>
<td>Reduces transmission probability</td>
</tr>
<tr>
<td>Temperature screening</td>
<td>0.9</td>
<td>0.9</td>
<td>Increases detection rate for early isolation</td>
</tr>
<tr>
<td>Hospital isolation</td>
<td>0.5</td>
<td>0.95</td>
<td>Isolates infective individuals in hospital</td>
</tr>
<tr>
<td>Home quarantine</td>
<td>—</td>
<td>0.81</td>
<td>Quarantines contacts at home</td>
</tr>
<tr>
<td>Visit restriction</td>
<td>—</td>
<td>0.9</td>
<td>Restricts hospital visitors to reduce nosocomial infection</td>
</tr>
<tr>
<td>Contact reduction</td>
<td>—</td>
<td>0.9</td>
<td>Reduces social contacts (e.g., school/workplace closure)</td>
</tr>
<tr>
<td>Vaccination</td>
<td>—</td>
<td>count</td>
<td>Administers vaccines to random unvaccinated individuals</td>
</tr>
<tr>
<td>Medical policy</td>
<td>0.9</td>
<td>0.9</td>
<td>Applies antiviral treatment to infective individuals</td>
</tr>
</tbody>
</table>
<h2 id="algorithm-overview">Algorithm Overview</h2>
<p>CASMIM simulates epidemic dynamics through a daily step cycle:</p>
<ol>
<li>
<p><strong>Population initialization</strong> — 100,000 individuals are created with age-stratified demographics (young/prime/old). Each person is assigned multiple "social mirror" agents distributed across the 500 × 500 torus lattice using a Gaussian quota distribution, representing their presence in different social spheres.</p>
</li>
<li>
<p><strong>Daily traversal</strong> — Each day, all individuals are traversed in a randomly chosen direction (forward or reverse) to eliminate ordering bias. For each person, the engine executes:</p>
</li>
<li>
<p><strong>State transition</strong> — The SEIR+D state machine advances:</p>
</li>
<li><strong>Susceptible</strong>: Agents interact with Moore-neighborhood neighbors; transmission occurs with probability <code>transmission_prob</code> (modified by mask and medical policies).</li>
<li><strong>Exposed</strong>: Counter increments; transitions to Infective after <code>exposed_period</code> days.</li>
<li><strong>Infective</strong>: May be detected (with probability <code>detect_rate</code>) and isolated/quarantined. Transmission to neighbors continues. After <code>infective_period</code> days, transitions to Recovered or Died (age-stratified mortality).</li>
<li><strong>Recovered</strong>: After <code>recovered_period</code> days, transitions to Immune.</li>
<li>
<p><strong>Immune</strong>: After <code>immune_period</code> days, returns to Susceptible (unless permanently immunized by vaccine).</p>
</li>
<li>
<p><strong>Contact tracing</strong> — When an infective individual is detected, BFS-based contact tracing identifies level-1 (direct contacts) and optionally level-2 (contacts of contacts) neighbors for home quarantine.</p>
</li>
<li>
<p><strong>Super-spreader effect</strong> — Super-spreaders interact with all 8 Moore-neighborhood cells instead of a randomly selected single neighbor, dramatically increasing their transmission reach.</p>
</li>
</ol>
<h2 id="implementation-notes">Implementation Notes</h2>
<ul>
<li><strong>Numba JIT compilation</strong>: The core simulation loop (<code>change_society</code>) and all subroutines (13 functions total) are compiled to native code via <code>@nb.njit(cache=True)</code>, yielding ~8x speedup. BFS contact tracing uses pre-allocated arrays with head/tail pointers instead of Python <code>deque</code>.</li>
<li><strong>AoS → SoA conversion</strong>: The original C++ Array-of-Structures (<code>society.people[i].state</code>) is converted to Structure-of-Arrays (<code>people_state[i]</code>) using NumPy for cache-friendly vectorized operations.</li>
<li><strong>Contact tracing</strong>: Changed from recursive DFS (C++) to iterative BFS (Python/Numba) to avoid stack overflow on large populations.</li>
<li><strong>Policy vectorization</strong>: All policy applications (except vaccination) use <code>np.random.random(N) < available</code> for O(1) per-person Bernoulli trials instead of scalar loops.</li>
<li><strong>Incremental rendering</strong>: A dirty-set mechanism (<code>dirty_pids</code>) tracks only agents whose state changed each day, avoiding full-lattice repaints.</li>
<li><strong>Chart rendering</strong>: Migrated from VCL TChart (C++) to pyqtgraph (Python) for real-time chart updates.</li>
</ul>
<h2 id="project-structure">Project Structure</h2>
<pre><code>CASMIM/
├── main.py # Entry point
├── requirements.txt # Python dependencies
├── pyproject.toml # Package metadata (PEP 621)
├── CITATION.cff # Citation metadata
├── CHANGELOG.md # Version history
├── CONTRIBUTING.md # Contribution guidelines
├── LICENSE # MIT License
├── index.html # GitHub Pages landing page
├── 404.html # Custom 404 error page
├── sitemap.xml # XML sitemap for search engines
├── robots.txt # Crawler directives
├── llms.txt # AI-readable project summary
└── sars_sim/
├── __init__.py
├── models.py # Data structures (StateEnum, SimulationParams, SimulationData)
├── world.py # Lattice management, population initialization, agent distribution
├── engine.py # Core SEIR+D simulation engine, transmission and state transition logic
├── engine_numba.py # Numba JIT-compiled kernels (13 @njit functions, ~8x speedup)
├── policies.py # 8 public health policy implementations (vectorized)
├── statistics.py # Statistics tracking, Excel output (4 sheets)
└── gui/
├── __init__.py
├── main_window.py # Main application window (PySide6)
├── lattice_view.py # Macro/micro lattice visualization (QImage ARGB32)
├── charts.py # 6 pyqtgraph chart widgets
├── controls.py # Parameter, disease, and policy control panels
└── status_bar.py # 9-panel status bar
</code></pre>
<h2 id="authors">Authors</h2>
<ul>
<li><strong>Chung-Yuan Huang</strong> (黃崇源) — Department of Computer Science and Information Engineering, Chang Gung University, Taiwan (gscott@mail.cgu.edu.tw)</li>
<li><strong>Chuen-Tsai Sun</strong> — Department of Computer Science, National Yang Ming Chiao Tung University, Taiwan</li>
<li><strong>Ji-Lung Hsieh</strong> — Graduate Institute of Journalism, National Taiwan University, Taiwan</li>
<li><strong>Yi-Ming Arthur Chen</strong> — Department of Information Management, National Central University, Taiwan</li>
<li><strong>Holin Lin</strong> — Department of Sociology, National Taiwan University, Taiwan</li>
</ul>
<h2 id="citation">Citation</h2>
<p>If you use this software in your research, please cite:</p>
<blockquote>
<p>Huang, C.-Y., Sun, C.-T., Hsieh, J.-L., Chen, Y.-M. A., & Lin, H. (2005). A Novel Small-World Model: Using Social Mirror Identities for Epidemic Simulations. <em>SIMULATION</em>, 81(10), 671-699. https://doi.org/10.1177/0037549705061519</p>
</blockquote>
<p>See <code>CITATION.cff</code> for machine-readable citation metadata.</p>
<h2 id="references">References</h2>
<ol>
<li>
<p>Huang, C.-Y., Sun, C.-T., Hsieh, J.-L., & Lin, H. (2004). Simulating SARS: Small-World Epidemiological Modeling and Public Health Policy Assessments. <em>Journal of Artificial Societies and Social Simulation</em>, 7(4), 2. http://jasss.soc.surrey.ac.uk/7/4/2.html</p>
</li>
<li>
<p>Huang, C.-Y., Sun, C.-T., Hsieh, J.-L., Chen, Y.-M. A., & Lin, H. (2005). A Novel Small-World Model: Using Social Mirror Identities for Epidemic Simulations. <em>SIMULATION</em>, 81(10), 671-699. https://doi.org/10.1177/0037549705061519</p>
</li>
</ol>
<h2 id="license">License</h2>
<p>This project is licensed under the MIT License. See <a href="LICENSE">LICENSE</a> for details.</p>
<!-- PRERENDER-END -->
</article>
</main>
<footer class="site-footer">
<nav class="footer-nav" aria-label="CANS Lab Software">
<a href="https://canslab1.github.io/EpiRank/">EpiRank</a>
<span class="footer-sep">·</span>
<a href="https://canslab1.github.io/MV17/">MV17</a>
<span class="footer-sep">·</span>
<span class="current">CASMIM</span>
<span class="footer-sep">·</span>
<a href="https://canslab1.github.io/HETA/">HETA</a>
<span class="footer-sep">·</span>
<a href="https://canslab1.github.io/HATA/">HATA</a>
<span class="footer-sep">·</span>
<a href="https://canslab1.github.io/BCAT/">BCAT</a>
<span class="footer-sep">·</span>
<a href="https://canslab1.github.io/SRAC-Agent/">SRAC-Agent</a>
<span class="footer-sep">·</span>
<a href="https://canslab1.github.io/AED2/">AED2</a>
</nav>
<p>© CANS Lab, Chang Gung University ·
<a href="https://canslab1.github.io/">canslab1.github.io</a></p>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/16.3.0/lib/marked.umd.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/highlight.min.js"></script>
<script src="https://canslab1.github.io/js/readme-loader.js"></script>
</body>
</html>