Chapter 15: Vectorized Spatial Models with NumPy¶
Part III — Discrete Spatial Modeling
Learning Objectives¶
By the end of this chapter you will be able to:
- Implement Game of Life with full NumPy vectorization
- Use shift operations and boolean masks instead of loops
- Measure the speedup over the naive implementation
{note}
End of chapter: the reader now has both pieces (salabim + NumPy). Ch 16 shows how DisSModel combines them cleanly.
In [ ]:
Copied!
# Standard imports — add chapter-specific imports below
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# Standard imports — add chapter-specific imports below
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
Shift Operations on 2D Arrays¶
TODO: write content.
In [ ]:
Copied!
# Code for section: Shift Operations on 2D Arrays
# Code for section: Shift Operations on 2D Arrays
Boolean Masks as Neighborhood Queries¶
TODO: write content.
In [ ]:
Copied!
# Code for section: Boolean Masks as Neighborhood Queries
# Code for section: Boolean Masks as Neighborhood Queries
Game of Life: Vectorized Rule¶
TODO: write content.
In [ ]:
Copied!
# Code for section: Game of Life: Vectorized Rule
# Code for section: Game of Life: Vectorized Rule
Benchmarking: Loop vs NumPy vs salabim+NumPy¶
TODO: write content.
In [ ]:
Copied!
# Code for section: Benchmarking: Loop vs NumPy vs salabim+NumPy
# Code for section: Benchmarking: Loop vs NumPy vs salabim+NumPy
Combining salabim and NumPy¶
TODO: write content.
In [ ]:
Copied!
# Code for section: Combining salabim and NumPy
# Code for section: Combining salabim and NumPy
Further Reading¶
- TODO: add references.