CSC-40068 - Advanced Programming in Python. Coursework Assignment
CSC-40068 - Advanced Programming in Python. Coursework Assignment
Coursework Assignment
Mr Andrew Cook
Deadline: 1pm BST 6th May 2022
Problem Description
A popular pizza company is opening a new store nearby to accept online orders
for delivery. They have asked you to create a simulation for their store.
We will simplify the scenario somewhat using only a few ingredients for each
type of pizza.
The store will offer three sizes of Pizza; Small, Medium and Large. An
Order can contain any combination of the three sizes and may include multiple
pizzas of the same size.
Orders will be provided in the form of a JSON file which will need to be
read and processed appropriately (an example JSON is provided). When a chef
is available they will collect an order from the order point. These should be
collected in order of their Order-ID.
The chef will then create each pizza using ingredients collected from a storage
area for each ingredient which will be periodically refilled. These shared storage
areas should have a configurable size N items.
Once all pizzas in an order have been created the order should be cooked in
a Pizza Oven and then placed into a Collection Queue, after which a chef
can get the next available order. Orders will be collected for delivery with a
priority based upon the number of pizzas in the order.
All pizzas take 20ms to make and 10ms to cook. A delivery Driver can collect
an order for delivery at most once every 50ms.
An Order with three pizzas would therefore take 60ms to make and a further
30ms to cook.
Pizzas require the following components:
• Small Pizza: 1 Dough, 1 Sauce, 2 Toppings
1
• Order-ID
• Time Accepted
• Time Collected
Once all orders from the Input JSON have been collected your simulation
should end.
There are a few restrictions on the operations of the store:
• The Ingredient storage has limited space. When they are full no more
items can be added until some have been taken out.
• No Pizza can be created until all ingredients are available for that Pizza.
• Pizza Orders must be collected for delivery in order of the number of
Pizzas in the order.
This coursework is split into two parts, each worth half of the programming
assessment marks (90% total). With a further 10% for Demonstration of your
solution.
2
Component 1: Programming coursework. (90%)
Task 1: Sequential simulation.
The goal of this task is to simulate the operations of the store sequentially,
there is one Chef and one Delivery driver. You are required to create appro-
priate classes to represent the Orders, Pizzas and the processes involved in the
operation of the store.
Store operation will proceed as follows:
3
Task 2: Concurrent Simulation
Following the success of the initial store processes the Pizza company have
decided to hire additional chefs and delivery drivers to increase output.
The number of Chefs and Delivery Drivers should be configurable.
This will create a more dynamic environment where multiple orders may be
processed concurrently.
Ingredient stores cannot be refilled while a chef is accessing them. A Pizza
cannot be started until all ingredients are available. Only one order can be
cooked at a time.
Orders must be collected based upon how many pizzas are in the order.
You must be aware of how your data structures are managed to ensure
Mutually Exclusive Access and Synchronisation where appropriate.
Note that:
• Each ingredient store can be refilled independently, but chefs cannot re-
trieve ingredients while the store is being refilled. Similarly the store
cannot be refilled while a chef is collecting the ingredients. These stores
have limited size.
• The chef will need to access multiple stores simultaneously but cannot
begin production of a Pizza unless all ingredients are available (in the
correct quantities).
• All chefs will require access to the Pizza Oven and Delivery Drivers will
require access to the Collection queue.
4
Assessment criteria for Task 2 (45%)
• 40% Management of contention for Shared data structures (Order Queue,
Ingredient Stores, Pizza Oven and Collection Queue).
5
Component 2: Code demonstration (10%)
Once your solutions have been submitted we will arrange a short demonstration
of your solution either in person or via MS Teams where you will be expected to
provide a short explanation of your code and justify how it meets the specified
requirements. This demonstration is worth 10% of the module marks.
Guidance
Your submission should be in the form of a single zipped file containing a folder
for each of Task 1 and Task 2. This zipped file should be named with your
Student Number (8 digits).
Your solution for each task should be able to run independently (you should
not import classes/modules from Task 1 into Task 2, however you can re-use
code if required.)
You should test your solutions on the Lab computers to ensure they run
correctly.
You should submit .py files for each component in your solution.
You can use any data structures in the standard Python installation on the
Lab computers which you require (you do not have to write these data structures
yourself).
The included data is provided as an example of the format orders will be
received in. For thorough testing of your solution you will need to generate a
much larger selection of orders to identify any unusual behaviour.
Your code should be documented appropriately, using Comments and Doc-
strings.