Starting from:
$35

$29

Homework 3 Solution




Hand-in Policy: Source code and documentation should be submitted online as a single .zip or .rar file with naming convention studentid_lastname_firstname_h3.zip via Moodle by the submission deadline. No late submissions will be accepted.




Collaboration Policy: No collaboration is permitted. Any cheating (copying someone elses work in any form) will result in a grade of -100 for the first offense and -200 for the subsequent attempts. Grading: Each homework will be graded on the scale 100. Unless otherwise noted, the questions/parts will be weighed equal.










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 ;




More products