This project generates a virtual mall with multiple floors and shops, then visualizes it in 3D using Plotly.
It also calculates an efficient walking path to visit all shops, based on a Traveling Salesman Problem (TSP) heuristic.
You are most welcome to use this code in your commercial projects, all that I ask in return is that you credit my work by providing a link back to this repository. Thank you & Enjoy!
Note: Wait a few seconds for the demo GIF below to load...

-
Mall generation:
- Randomly places shops on multiple floors.
- Stores mall layout in JSON (
mall_coordinates.json).
-
Visualization:
- 3D scatter plot of shops (with floor as the z-axis).
- Interactive Plotly figure with shop labels.
- Option to highlight an efficient walking path.
-
Path optimization:
- Uses a Nearest-Neighbor + 2-opt heuristic to approximate the optimal tour through all shops.
- Includes a floor-change penalty to reduce unnecessary trips between floors.
-
generate_mall.py- Generates a random mall with a specified number of floors and shops per floor.
- Saves the mall layout as
mall_coordinates.json.
-
view_mall_optimized.py- Loads mall coordinates (or generates them if missing).
- Computes a near-optimal path to visit all shops using a TSP heuristic.
- Visualizes both the shops and the computed walking path.
- Displays the total path distance, including floor penalties.
Install dependencies in a virtual environment:
pip install -r requirements.txtpython generate_mall.pyThis creates mall_coordinates.json with random shop coordinates.
python view_mall.pyOpens an interactive 3D scatter plot of the Mall with:
- All shops (blue dots)
- An optimized walking path (blue line)
- Start (Diamond) and end point (X) marked
- Path length displayed in the title
- Click and drag to rotate mall
- Middle scroll to zoom in and out
- Number of floors/shops per floor: Edit
generate_mall.pyor pass custom logic toMall. - Floor-change penalty: Adjust
FLOOR_CHANGE_PENALTYinview_mall_optimized.py:
FLOOR_CHANGE_PENALTY = 50.0 # higher = fewer floor changes