Programming Languages Homework #3 Solution

$30.00 $24.90

Description

Part 1. [50pt] In this part of the homework, you are asked to write a simple expert system in Prolog for scheduling of classes. In your expert system, you will have rooms, courses and people.

  • A room has an ID, capacity (how many people it can hold), and operations hours given in one-hour increments from 8am till 5pm. Occupancy information for a room includes the hour and the name of the course taking that hour. A room can also have special equipment such as a projector, a smart board and access for the handicapped.

  • A course has an ID, an instructor, capacity, and one or more hours and the room information if they are assigned to a room. A course can have several students enrolled in it. A course can also have special needs such as a projector or a smart board. Of course, if there is a special needs student enrolled, it should be assigned to a room with proper access for the special needs.

  • An instructor has an ID and several courses taught. The instructor may have preferences for rooms with a projector or smartboard.

  • A student has an ID, and list of courses she/he attends. A student can also be handicapped.

Your expert system should be able to add a new student, course or a room to the system. It should respond to queries such as:

  • Check whether there is any scheduling conflict.

  • Check which room can be assigned to a given class.

  • Check which room can be assigned to which classes.

  • Check whether a student can be enrolled to a given class.

  • Check which classes a student can be assigned.

Part 2. In the graph below you see the possible flights between some of the cities in Turkey. Write the predicate “route(X,Y,C) – a route between X and Y exists with cost C” that checks if there is a route between any given two cities.

Your Prolog program should have all the facts and predicates/rules. See the following:

  • knowledge base

flight(istanbul,izmir,3). % fact: Istanbul and Izmir has a flight with cost 3. …

  • rules

route(X,Y,C) :- flight(X,Y,C). % a predicate indicating there exist a route between

  • X and Y if there is flight between X and Y with cost

  • C.

A single query to complete your program should check if there is a direct route between two given cities. Alternatively, it can list all the connected cities for a given city. See the following:

?- route(edirne,X,C).

X = erzurum, C = 15 ;

X = antalya, C = 7 ;