Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please provide answers in SWI-Prolog. Im mainly stuck on 3.2 and 3.3, i'm not sure how to define a meeting point predicate for two points

Please provide answers in SWI-Prolog. Im mainly stuck on 3.2 and 3.3, i'm not sure how to define a meeting point predicate for two points and append it to a list. and im not sure how to deal with costs when weighing out where to go. Thanks.

image text in transcribedimage text in transcribedimage text in transcribed

3.1 Finding a path Consider the plan of a house as shown in Fig. 1. Write a Prolog description of this plan that allows a Prolog program search for paths between locations indicated on the plan. For example, if one is Outside and wishes to find a path to the WC, then a possible answer can be: Outside Porch 1 Kitchen Leaving Room Corridor WC. Your program should Figure 1: Top view of a two bedroom house showing how different locations in and out of the house are connected. avoid loops and be as general as possible, in that, given any two locations representing an origin O and a destination D, it returns: - a path P from O to D, if it exists; - every possible path P from O to D, if there are more than one; - meaningful error messages, if the wrong input is provided for O and D. Comment the code submitted for this part to contain the name of the search algorithm that you selected to find the path. [40\%] 3.2 Paths ending at a common destination Define a Prolog program that searches bi-directionally from two origins O1 and O2 to meet up at a common destination D. It is up to you how you define that, perhaps by reusing parts of the program you developed for section 3.1, however this time you do not have to check that 3 the input parameters are correct, simply assume they are. Your program should combine a path P1 from O1 to D, with a path P2 from O2 to D, if they exist, to produce a combined path P, showing how you reach meeting point D from O1 and O2 respectively. You are expected to produce all possible combinations P1 and P2 to construct P non-deterministically, if we ask for more answers. Test your program using Fig. 1 by asking different queries and see whether your work produces the expected outcomes. Maximum marks will be obtained for also providing a program that returns only the shortest paths P1 and P2 combined to produce P. [30\%] 3.3 Paths with Costs Rewrite the problem description for the program you defined in section 3.1, to include the individual cost C (an integer describing the distance in meters) between locations of the house as shown in Fig. 2. Once you have a new representation that takes individual cost between locations into account, rewrite also you search program to calculate the total cost of a path, so that when you return a path P as a solution, you also return Ctotal. Your new program should also return every path, if there is more than one, returning the cheap ones first, and then the more expensive ones, in rank order. Then use your new program to define how to meet up from two origins O1 and O2 to a destination D (as in 3.2), only if the cost Ctotal is the same from both O1 and O2 respectively. Cnct ac dictanco Figure 2: Cost between locations. Test your program using Fig. 1 by asking different queries and see whether your work produces the expected outcomes. [30\%]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 19 21 2012 Proceedings Part 3 Lnai 7198

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284922, 978-3642284922

More Books

Students also viewed these Databases questions

Question

4. I can tell when team members dont mean what they say.

Answered: 1 week ago

Question

2. How were various roles filled?

Answered: 1 week ago