State space search using prolog and lisp

Assignment Help Programming Languages
Reference no: EM1378419

Part A - State Space Search using LISP

This part of the assignment requires you to solve the following problem using the LISP computer programming language:

A merchant has a beaker containing 24 ounces of a precious fluid. He also has empty 5-ounce, 11- ounce, and 13-ounce beakers. How can he divide the fluid into three equal portions?

For this part of the assignment you are required to solve this problem as a state space search problem using the A-star algorithm that has been described in lectures.

You have been supplied with LISP code for A-star search. The code is contained in the file a-star.lisp. You should not make any changes to the code in this file. All the problem-specific code you write should be contained in a file called precious.lisp.

The code in precious.lisp should contain only the following:

  Definition of a global variable *start-state* whose value represents the initial state.

  Definition of a global variable *operators* which lists the names of the operators.

  Definition of a predicate solution-state? that takes a state as argument and returns T if that state is a solution, and nil otherwise.

  Function definitions for each of the operators listed in *operators*.

  Definition of a function cost-of-applying-operator that takes a state and an operator as arguments, and returns the cost of applying the operator to that state. We will assume that all costs are equal, and hence this function should always return 1, irrespective of the state or the operator.

  Definition of a function estimated-distance-from-goal that takes a state as an argument, and returns an estimate of the number of steps required to get from this state to the goal. Note that this function will determine the number of states examined in the search-the fewer the better. You can, of course, write any number of helper functions which are called by the functions above.

Compare the performance of A-star search (using the heuristic you have defined) with the performance of breadth first search. You should compare the number of states examined, the length of the solution and the maximum depth of the search tree. You can obtain this information by examining the value of the variable *stats* after the search has completed.

Notes:
  Using A-star search with a heuristic that evaluates all states as 0 results in a breadth first search. In order to run breadth first search, all you need to do is replace the function estimateddistance- from-goal with the following:

(defun estimated-distance-from-goal (state) 0)

  Don't forget to reset the value of *stats* before running the search again.

Write a short report on your findings (approx. 150 words). The report should contain a table that compares the number of states examined, the length of the solution, and the maximum depth of the search tree.

Part B - State Space Search using Prolog

This part of the assignment requires you to solve the following problem using the Prolog computer programming language:

Ten cannibals and ten missionaries come to the left bank of a crocodile infested river, where there is a boat that can be used by one or two persons. There is an island in the middle of the river. If cannibals outnumber the missionaries at any time, the cannibals eat the missionaries. How can they use the boat to cross the river so that all missionaries survive? All trips must be either to or from the island; i.e., crossings directly from bank to bank are not allowed.

For this part of the assignment you are required to solve this problem as a state space search problem using the best-first-search algorithm.

You have been supplied with two Prolog files: adts.pl and bfs.pl. The file adts.pl contains Prolog code implementing various abstract data types. The file bfs.pl contains code that can be used to perform bestfirst- search in Prolog. Note that the file bfs.pl consults adts.pl.

For this task you are required to write Prolog code to solve the missionaries and cannibals problem. To assist you, two example files have been made available on the LMS: fwgc.pl and jugs.pl, which implement the farmer, wolf, goat and cabbage problem, and the water jugs problem, respectively. Note that these files contain all of the code in bfs.pl, in addition to the problem-specific operators, coded in a procedure move(Current_State, Next_State). It is suggested that you study the code in these files before commencing your solution to the missionaries and cannibals problem.

In addition to outputting the sequence of steps required to move from the start state to the goal state, your code should also show the total number of states examined (i.e., the sum of the number of states on the Open and Closed lists), the maximum depth of the search tree, and the length of the solution. All code (with the exception of code in the file adts.pl) should be contained in a file called mc.pl.
Procedures that you will need to include in mc.pl are:

  A procedure move(Current_State, Next_State) that described the problem solving operator for moving from Current_State to Next_State .

  A procedure heuristic(State, Goal, H) where state is the state being evaluated, Goal is the goal state, and H is the heuristic evaluation for state. (Note that bfs.pl contains the procedure heuristic(State, Goal, 0).

This assigns a H value of 0 to every state, and thus results in breadth first search. You should replace this with a procedure that implements your proposed heuristic).

  Procedures to find the the total number of states on the Open and Closed lists, the maximum depth of the search tree, and the length of the solution.

  Any helper procedures required. (For example, you may wish to write a procedure unsafe(State) that returns False if state State is unsafe (i.e., if the number of cannibals at any location outnumber the number of missionaries at that location).

Compare the performance of A-star search (using the heuristic you have defined) with the performance of breadth first search. You should compare the number of states examined, the length of the solution and the maximum depth of the search tree.

Write a short report on your findings. The report should contain a table that compares the number of states 

Reference no: EM1378419

Questions Cloud

Determine the upper and lower control limits : A procedure for manufacturing electronic circuits has achieved very high yield levels. An average of only 10 defective parts per million is currently manufactured.
Prepare a contribution income statement for the month : Prepare a contribution income statement for the month based on the actual sales. Present the income statement - Determine whether the company should discontinue operating the Consumer Division.
Survey analysis questions : You are interpreting results of an opinion poll. In a random sample of one hundred small business owners, you discover that of the forty large business owners, a total of thirty support a proposal to implement a local sales tax.
Difference in the mean number of months : A senior accounting major at Midsouth State University has job offers from 4-CPA companies. To explore the offers further, she asked a sample of recent trainees how many months each worked for the company before receiving a increase in salary.
State space search using prolog and lisp : State Space Search using Prolog and LISP - solve problem using the Prolog computer programming language
Determine the legal or political barriers : The company you work for is interested in developing their business overseas. You have been tasked to gather some preliminary data to help management decide on whether to pursue this idea further.
Comparing teams and work groups : Discuss are the differences in Leadership at Green River and FMC Aberdeen and will work groups and teams work at Green River, explain your answer?
Sources of potential process losses : Assume you will be a part of the newly formed assignment staff team. This team will require to realize process gains within its first three months.
Constructing a decision tree : We are considering an event for next June. Assume if we select an outdoor venue, we make 350,000 dollars, but if it rains we lose 40,000. If we select an indoor venue, we make 150,000 rain or not.

Reviews

Write a Review

Programming Languages Questions & Answers

  Automate the task of invigilator allocation

you are required to carry out the following to automate the task of invigilator allocation which may not be limited to one's own department.

  Design a class-based solution to a problem

To design a class-based solution to a problem using multiple data structures.

  Creating loop to find number of items bought based on price

Make a block using a loop that will find the number of items that can be bought based on the price of the item and the total amount available to spend.

  Distinguish class templates and program with heading

Clearly distinguish each class templates and their program with heading. Elaborate each step and give it without errors. Develop classes or class templates for the following.

  Write a program to compute the probability

Write a program (or a peudocode) to compute the probability that at least 2 people have the same birthday, given there are 2, 3, 4,....,60 people in the room.

  Write program for grocery that reads products data

Write a program for a grocery that reads products data and determine and display the product that has the highest price and the average price.

  Matrix multiplication code with mpi

Matrix multiplication code with MPI. At the beginning of each of the programs, write names of group members in the comment line.

  Statement to assig nnew value to first element of array

Suppose that array of integers named a has been declared and initialized. Write single statement which assigns a new value to first element of the array.

  Write down two ways to execute the shell script

Write down two ways you can execute the shell script when you don't have executive access permission for file containing the script?

  Program to display aggregate information for state

For each state, display aggregate information for that state, including: the total number of counties in the state, the total number of tax returns.

  Develop logic for program to read customer records

Develop the logic for a program that reads in 100 customer records and stores the first and last name and total purchases in three parallel arrays.

  Write temperature conversion program

You will write a temperature conversion program. GUI and event handling setup must be done in the constructor of the class that implements the GUI.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd