Docsity

Basic Travel Agent Prolog - Assignment 1 | CS 181, Study Guides, Projects, Research of Computer Science

Toggle sidebar
bg1
Programming Languages
Fall of 2001
Programming Assignment #1
Basic Travel Agent in Prolog
Due: Tuesday, November 20, 2001
Available flights:
Query:
connection(From, To, Departure, Price, Duration, ListOfFlights).
Testing data: (provided by me during testing - do not include in the submitted file!)
cancelled(FlightNr).
rescheduled(FlightNr,NewDeparture, NewDuration).
airport_closed(City, FromTime, ToTime).
la
dallas
denver
chicago
newYork
co145, 6am,
$150, 4 hours
aa12, 2pm,
$250, 2 hours
de111, 9pm,
$200, 2 hours
aa45,3pm
$150, 2 hours
nw145, 8pm,
$350, 6 hours
de333, 7pm,
$450, 5 hours
co156, 10am,
$150, 3 hours
aa555, 8am,
$250, 4 hours
aa123, 10am,
$250, 3 hours
pf2

Partial preview of the text

Download Basic Travel Agent Prolog - Assignment 1 | CS 181 and more Study Guides, Projects, Research Computer Science in PDF only on Docsity!

Programming Languages

Fall of 2001

Programming Assignment # Basic Travel Agent in Prolog Due: Tuesday, November 20, 2001

Available flights:

Query:

connection(From, To, Departure, Price, Duration, ListOfFlights).

Testing data: (provided by me during testing - do not include in the submitted file!)

cancelled(FlightNr).

rescheduled(FlightNr,NewDeparture, NewDuration).

airport_closed(City, FromTime, ToTime).

la

dallas

denver

chicago

newYork

co145, 6am, $150, 4 hours

aa12, 2pm, $250, 2 hours

de111, 9pm, $200, 2 hours

aa45,3pm $150, 2 hours nw145, 8pm, $350, 6 hours

de333, 7pm, $450, 5 hours

co156, 10am, aa555, 8am, $150, 3 hours $250, 4 hours

aa123, 10am, $250, 3 hours

Additional information:

  • All times are in full hours using the 24 hour clock.
  • No connection should last more than 24 hours.
  • There must be at least one hour of waiting time between connecting flights.
  • If the airport is closed during some hours than no flight can depart or land during those hours. All such flights are therefore effectively cancelled.
  • Do not use negation in your premises. Use " !, fail " if necesary.
  • Make sure to preserve the exact names and lists of arguments in the query and test data predicates.
  • Make sure to preserve the exact names of the airports and flight numbers.

Examples of test data:

cancelled(de66).

rescheduled(aa125, 12, 7). rescheduled(aa34, 17, 2).

airport_closed(newYork, 8, 12).

Sample program run (not using the above data):

?- connection(la,newYork, Departure, Price, Duration, FlightNrs).

Departure = 12 Price = 510 Duration = 9 FlightNrs = [aa125|co24|de234] ;

Departure = 9 Price = 410 Duration = 14 FlightNrs = [co244|co24|aa23] ;

No more connections available.

Good Luck!