Skip to content

Abdo-N/ReservationEngine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 

Repository files navigation

ReservationEngine

A two-language restaurant management system, built for a Concepts of Programming Languages (CPL) course. The same domain — reservations, ingredients, and supply costs — is modeled twice: once declaratively in Prolog and once functionally in Haskell, to compare how each paradigm handles the same problem.

The domain

A restaurant takes reservations from groups of people, seats them at tables, cooks their orders from recipes, and needs to track when ingredients must be delivered and how much everything costs. Both halves of this project solve pieces of that puzzle:

Prolog Haskell
Models Groups, staff, tables, recipes, orders Ingredients, recipes, shopping lists, deliveries, expenses
Solves Who gets seated where, and when When ingredients must arrive, and what they cost
Style Constraint logic / backtracking search Recursive, type-driven data transformation

Prolog — scheduling & seating

sample_KB.pl / Tests/public_kb.pl define the world as facts:

  • group(Name, Count, Timing) — a group of people wanting a table, with a preferred morning/evening slot
  • staff(Day, Count) — how many staff are on duty on a given day (caps how many reservations a slot can handle)
  • tables(Tables) — the restaurant's tables and their seating capacity
  • recipe(Dish, Ingredients) and order(Group, Dishes) — what each group ordered, and what each dish needs

utilities.pl builds on top of that knowledge base:

  • schedule_all_reservations/2 — either generates a valid seating schedule from scratch (biggest groups seated first, so smaller groups still have somewhere to fit), or validates an existing schedule against the staffing and table-capacity rules, depending on whether Schedule is bound
  • check_staff/3 — confirms a given day/time doesn't have more reservations than staff can support
  • needed_ingredients/2 — works out the full list of ingredients required per day, given a finalized schedule
  • write_reservations_to_csv/2 and write_ingredients_to_csv/2 — export a schedule or shopping list to CSV

Sample CSV output (Prolog/Sample outputs (for CSV predicate)/) shows what write_reservations_to_csv and write_ingredients_to_csv produce for both the sample and public knowledge bases.

Haskell — shopping, delivery, and expenses

Starter_File.hs models the supply chain with a small set of types:

  • Ingredient — either a SimpleIngredient or a Recipe made of other ingredients (recursive, so recipes can nest)
  • Expense — either a single Item, or a Category containing other expenses (also recursive, for grouping costs)
  • Delivery — a date paired with the supplies needed on that date

On top of these types:

  • calculateDeliveryDates — given an order date and a list of ingredients, flattens nested recipes into simple ingredients and works out how many days in advance each one needs to be delivered (looking up lead time and price from ingredient_info)
  • summarizeAllDeliveries — takes a list of order dates, pulls each day's shopping list, calculates every ingredient's delivery date, then merges and sorts everything into a clean per-date delivery schedule
  • getDeliveryExpenses / calculateTotalExpenses — turns a list of deliveries into an Expense tree and sums it up
  • mostPopularDish — frequency-counts a list of dish names and returns the one(s) ordered most

Running it

Prolog (tested with SWI-Prolog):

swipl
?- consult('Prolog/utilities.pl').
?- schedule_all_reservations([day(15,2), day(16,2), day(17,2)], Schedule).

Haskell (tested with GHC/GHCi):

ghci Haskell/Starter_File.hs
ghci> summarizeAllDeliveries [(15,Feb,2026), (17,Feb,2026)]

Test cases for both halves are provided as spreadsheets (Prolog/Tests/tests.xlsx, Haskell/Public_Test_Cases.xlsx) alongside a public knowledge base (Prolog/Tests/public_kb.pl) to test against.

Team

Built by:

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors