Preview

Prolog Sample Program

Powerful Essays
Open Document
Open Document
1219 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Prolog Sample Program
CPT114 – LOGIC & APPLICATIONS
Academic Session 2014/2015, Semester 1

Prolog Assignment 1
WORLD TRAVEL ROUTE FINDING PROGRAM

Page Number
1.0
Problem Statement
1
2.0
Prolog Program
2-3
3.0
List of Queries
4-5

4.0

Sample Input – Output

6-8

1.0 Problem Statement This assignment required us to make a prolog program to determine best route to travel from a city to another city using both number of cities pass through along the journey and the shortest distance between the departure and arrival city. We decided that the best route given to user with priority of least transits, followed by shortest distance between departure and arrival city. This will reduce the time spend on transit between city. We believed that this is the primary concern of the passengers. However, if the user still wants to have another route with shortest distance between departure and arrival city regardless of increase number of transit city, the program will provide the respective route. We will prompt the user to select between these two types of best routes.
List of available cities:
New York
London
San Francisco
Tokyo
Rome
Calcutta
Cairo
Sydney
Cape Town
Panama

2.0 Prolog Program distance(london,rome,0.8). distance(london,newyork,3.2). distance(london,panama,4.5). distance(london,capetown,5.8). distance(panama,sydney,7.7). distance(newyork,panama,1.9). distance(newyork,sanfrancisco,2.5). distance(sanfrancisco,tokyo,4.5). distance(sanfrancisco,sydney,6.2). distance(tokyo,calcutta,2.5). distance(tokyo,sydney,4.1). distance(calcutta,cairo,2.2). distance(sydney,calcutta,4.4). distance(sydney,capetown,6.0). distance(capetown,rome,5.1). distance(cairo,rome,0.9).

connected(X,Y,L) :- distance(X,Y,L) ; distance(Y,X,L).

path2(A,B,Path,Len,Num) :- travel(A,B,[A],Q,Len), reverse(Q,Path),length(Path,N),Num is N-2.

travel(A,B,P,[B|P],L) :- connected(A,B,L). travel(A,B,Visited,Path,L) :- connected(A,C,D), C \== B,
\+member(C,Visited),

You May Also Find These Documents Helpful

  • Good Essays

    Programming Logic

    • 1499 Words
    • 6 Pages

    2. Design the logic for a program that outputs every number from 1 through 10.…

    • 1499 Words
    • 6 Pages
    Good Essays
  • Good Essays

    2. The transportation problem described above can be solved mathematically using a computer package. The solution to the problem using excel solver are given in the following table.…

    • 1284 Words
    • 6 Pages
    Good Essays
  • Good Essays

    wish to drive to point B by the shortest route, take roads X, Y, and Z.” On the other hand, the…

    • 1037 Words
    • 5 Pages
    Good Essays
  • Better Essays

    Southwest Airline

    • 1110 Words
    • 5 Pages

    1) Focus on point-to-point service. This service provides more direct nonstop flights that can minimize delays and total trip time.…

    • 1110 Words
    • 5 Pages
    Better Essays
  • Good Essays

    To help Bill Binder pick the best route to transport his bottles from his plant to his warehouse we can use the shortest path model. The shortest path model finds how to transport items/people from on location to another while minimizing the total distance traveled, time taken or some other measures.…

    • 402 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    income statement

    • 309 Words
    • 2 Pages

    As a college student traveling between these two cities I would definitely choose Megabus over all other modes of transportation, because the two cities are at a discounted fare, environmentally safer, free wi-fi for school work or movies, and outlets to power my devices. Also the fact that many other young college types ride the same bus gives a better atmosphere to travel opposed to mix crowds of children and elderly.…

    • 309 Words
    • 2 Pages
    Satisfactory Essays
  • Better Essays

    Tsp - Problem

    • 6143 Words
    • 25 Pages

    One of the most common problems in urban service systems is the design of routes for vehicles or people. In some instances, these routes must be designed so that they traverse in an exhaustive way the streets in a neighborhood or in a specific part of a city or, occasionally, in a whole city. Alternatively, the objective may be to visit a set of given geographical points in a city in order to provide some service there or to deliver or collect goods.…

    • 6143 Words
    • 25 Pages
    Better Essays
  • Powerful Essays

    Dijkstra shortest path is shown and described with the example. Pseudo code and algorithm are also included along with their efficiency and applications. The different aspects of related algorithms were discussed, such as A* algorithm, Bellman–Ford algorithm and Prim’s algorithm…

    • 1927 Words
    • 8 Pages
    Powerful Essays
  • Powerful Essays

    Let us assume there are m sources supplying n destinations. Source capacities, destinations requirements and costs of material shipping from each source to each destination are given constantly. The transportation problem can be described using following linear programming mathematical model and usually it appears in a transportation tableau.…

    • 2672 Words
    • 11 Pages
    Powerful Essays
  • Good Essays

    Analysis of Meru Cabs

    • 743 Words
    • 3 Pages

    four metros and also the timely delivery of the promised service to the customer. Managing the demand of the cabs requires to develop realtime tracking of vehicles, Intelligent route planning and also understand the needs of the customers. Timely delivery of the promised service requires efficient communication , resource allocation and process automation…

    • 743 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    (a) What is the optimal transport policy that the Dalmia group should follow after the availability of the broad gauge rail link from Dalmiapuram? This decision will have to be taken by comparing the various possible transport mixes and then zeroing in on the most cost-effective one.…

    • 2727 Words
    • 11 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Applying for a job

    • 391 Words
    • 2 Pages

    3.2 plan a route and means of transport to arrive on time for the interview…

    • 391 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Network Algorithms

    • 386 Words
    • 2 Pages

    ❑ Grading: Grading will be based on a midterm exam [20%], a final exam [20%], homework [20%], midterm projects [20%], and final project [20%].…

    • 386 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Shenzhen Subway

    • 705 Words
    • 2 Pages

    Currently there are five subway routes in total. Number one is the Luohu route, the starting and ending stations are the train station and the airport. It’s convenient for people who don’t…

    • 705 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    Travelling at short distances is an everyday experience for many people. They often need to go to work in the near town, or visit family and friends, or just to have a rest in their small village. There are several ways for transportation, but which one is the most convenient?…

    • 340 Words
    • 1 Page
    Satisfactory Essays