This project analyzes the parking lot capacity of a university campus based on the number of students attending classes in various buildings and their distribution to different parking lots.
The goal of the project is to determine the availability of parking spaces in each parking lot and the excess capacity needed to accommodate all the students. The analysis is performed for each time slot of the day for all 7 days of the week.
The project uses the following input data:
output.json
: Contains the number of students attending classes in each building for every time slot throughout the week. The data is structured as a nested dictionary with the keys being the building names and the values being a list of 7 lists, each containing 96 time slots.buildingToParkingLot.json
: Contains the distribution of students from each building to the parking lots. It is a dictionary where the keys are building names and the values are dictionaries representing the distribution of students to each parking lot.
The project's output includes:
daily_parking_lot_availability.json
: Contains the parking lot availability for each time slot throughout the week. It is structured as a dictionary with keys as day numbers (0-6) and values as dictionaries with parking lot names as keys and lists of 96 time slots as values.daily_excess_capacity_needed.json
: Contains the excess capacity needed for each time slot throughout the week. It is structured as a dictionary with keys as day numbers (0-6) and values as dictionaries with time slots as keys and excess capacity as values.
- Clone the repository:
git clone https://github.com/user/repo.git
- Change to the repository's directory:
cd repo
- Make sure you have Python 3 installed. If not, download and install it from here.
- Place the input files (
output.json
andbuildingToParkingLot.json
) in the same directory as the main script (parking_lot_capacity_analysis.py
). - Run the script using the following command:
python parking_lot_capacity_analysis.py
This will generate the output files daily_parking_lot_availability.json
and daily_excess_capacity_needed.json
in the same directory.
The project is implemented using an object-oriented approach with a ParkingLotCapacityAnalyzer
class that contains methods for processing the data and performing the capacity analysis. The main components of the class include:
- Initialization: Loads input data, initializes parking lot capacities and other relevant data structures
process_day()
: Processes a single day, calculating the parking lot availability and excess capacity needed for each time slot.distribute_students()
: Helper method to distribute students to the parking lots based on the given distribution.normalize_distribution()
: Helper method to normalize the distribution of students to parking lots after updating availability.assign_remaining_students()
: Helper method to assign remaining students to available parking lots.analyze()
: Main method to perform the analysis for all 7 days of the week and save the results to output files.
To use the ParkingLotCapacityAnalyzer
class in your own projects, simply import the class and create an instance with the input file paths. Then, call the analyze()
method to perform the analysis and save the results to output files:
from parking_lot_capacity_analysis import ParkingLotCapacityAnalyzer
analyzer = ParkingLotCapacityAnalyzer("output.json", "buildingToParkingLot.json")
analyzer.analyze()
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.