- Notifications
You must be signed in to change notification settings - Fork2
A CLI that simulates the operation of the cargo delivery process of a Shipping Company and calculates some related statistics. This is an Educational Project for Data Structures course taken during Spring 2022 semester.
michaelehab/Shipping-Company-Simulator
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This is an educational Project for Data Structures and Algorithms course taken during Spring 2022 semester.
A shipping company needs to handle cargo delivery the most efficient and profitable way.
The company needs to automate the cargo-truck assignment process to achieve good and fair useof its trucks.
This CLI program that simulates the operation of the cargo delivery process of a Shipping Company and calculates some related statistics.
The following pieces of information are available for each cargo:
- Preparation (Ready) Time: the Time (day:hour) when the cargo is ready to beassigned to a truck.
- Load/Unload Time: Time (in hours) to load/unload the cargo to/from the truck.
- Cargo Type: There are 3 types of cargos: VIP, Special and Normal cargos.
- VIP cargos must be assigned first before other cargos.
- Special cargos are cargos to need special trucks like frozen cargos orchemical cargos,… etc
- Normal cargos: all other cargos
- Delivery Distance: The distance (in kilometers) from the company to the deliverylocation of the cargo.
- Cost: The cost of delivering the cargo.
Trucks:At startup, the system loads (from a file) information about the available trucks. Foreach truck, the system will load the following information:
- Truck Type: There are 3 types of trucks: VIP trucks, Normal trucks, and Specialtrucks.
- VIP trucks (VT) are trucks that are used basically for VIP cargos.
- Special trucks (ST) are trucks that are equipped to carry special cargos.
- Normal trucks (NT)
- Truck Capacity (TC): A truck can deliver many cargos in the same journey. TC isthe number of cargos a truck can carry to be fully loaded. (TC is read from inputfile).
- Maintenance (Checkup) time: The duration (in hours) of checkups/maintenancethat a truck needs to perform after finishing J delivery journeys. (J is read frominput file)
- Speed: in kilometers/hour.
- Delivery interval (DI): The time a truck takes to deliver all its cargos. and comeback to the company. It can be calculated as:
DI = (Delivery Distance of furthest cargo)/truck speed + Sum of unload times of allits cargos + time to come back
To determine the next cargo to assign (if a truck is available), the following assignment criteria is applied for all the ready un-assigned cargos on each hour:
- The Company working hours are from 5:00 to 23:00. Otherwise, it is off-hours.
- New Assignment can be done ONLY during working hours.
- The allowed activities during off-hours are: truck maintenance and trucks movingfor delivery or returning back to the company.
- All trucks of the same type have the same capacity.
- Loading Rule: If some cargos are ready and waiting to be assigned to a truck,don’t start loading cargos as long as the number of ready cargos is less thancapacity of the fist available truck (TC).For example: if you have 3 ready normal cargos and you have an available normaltruck but with TC=4, don’t load those cargos until a 4th cargo is ready. Only thenstart loading the cargos. This rule may be ignored in favor of Maximum Wait Rule(See next point).
- Maximum Wait Rule: If there is an available truck that is suitable for a cargo thathas been waiting for MaxW hours (or more), such cargo should be immediatelyloaded and moved to its destination. MaxW is loaded from input file. Ignore“Loading Rule” in this case.
- A truck can’t be loaded with more than one cargo type in the same journey.
- First, assign VIP cargos to ANY available truck of any type. However, there is apriority based on the truck type: first choose from VIP trucks THEN normaltrucks THEN special trucks. This means that we do not use normal trucks unlessall VIP trucks are out, and we do not use special trucks unless trucks of all othertypes are out.
- Second, assign special cargos using the available special trucks ONLY. If nospecial truck is available, wait until one comes back.
- Third, assign normal cargos using any type of trucks EXCEPT special trucks.First use the available normal trucks THEN VIP trucks (if all normal trucks areout).
- If a cargo cannot be assigned on the current hour, it should wait for the nexthour. On the next hour, it should be checked whether the cargo can be assignednow or not. If not, it should wait again and so on.
This is how we prioritize the assignment of cargos of different types, but how will we prioritize the assignment of cargos of the same type?
- For special and normal cargos, assign them based on a first-come first-servebasis. Cargos that are ready first are assigned first.
- For VIP cargos, you should design a priority equation for deciding which of theavailable VIP cargos should be assigned first. VIP cargos with a higher priorityare the ones to be assigned first.
VIP Priority = (20 * Cost) + (10 * Delivery distance) + (4 * ready day)
- For normal cargos ONLY, a request can be issued to promote the cargo tobecome a VIP one. A request of cargo cancellation could also be issued.A Cargo that has been already loaded to a truck cannot be canceled orpromoted.
- For normal cargos ONLY, if a cargo waits more than AutoP days from itspreparation time to be assigned to a truck, it should be automaticallypromoted to be an VIP cargo. (AutoP is read from the input file).
3 3 2 🡺 no. of trucks of each type (N, S, V)80 70 140 🡺 truck speeds of each type (km/h)6 4 2 🡺 Capacity of each truck type (N, S, V)12 9 8 7 🡺 no. of journeys before checkup and the checkup durations10 20 🡺 auto promotion limit (days), MaxW (hours)8 🡺 no. of events in this fileR N 1:3 1 200 2 500 🡺 Ready event exampleR N 1:10 2 25 1 413R S 1:10 3 50 2 356R V 2:22 4 90 3 400X 4:12 1 🡺 cancellation event exampleR N 5:7 5 56 2 187P 9:3 2 200 🡺 promotion event exampleR V 11:6 6 19 3 1006
The following numbers are just for clarification and are not produced by actualcalculations.
CDT ID PT WT TID18:3 1 7:4 0:9 320:5 10 2:10 12:5 520:5 4 15:1 3:6 15………………………………………………………………………………………………Cargos: 124 [N: 100, S: 15, V: 9]Cargo Avg Wait = 3:10Auto-promoted Caros: 4%Trucks: 20 [N: 13, S: 5, V: 2]Avg Active time = 91%Avg utilization = 87%
Allows user to monitor the cargos and trucks. Theprogram should print an output like that shown below. In this mode, the programprints the current time then pauses for an input from the user (“Enter” key) to display the output of the next time.
Step-By-Step Mode is identical to the interactive mode except that aftereach hour, the program waits for one second (not for user input) then resumesautomatically.
The program produces only an output file. It does not print any simulation steps on the console. It just printsthe following screen
NOTE: No matter what mode of operation your program is running in, the output file is produced.
About
A CLI that simulates the operation of the cargo delivery process of a Shipping Company and calculates some related statistics. This is an Educational Project for Data Structures course taken during Spring 2022 semester.
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Contributors3
Uh oh!
There was an error while loading.Please reload this page.