7COM1034: Theory and Practice of Artificial Intelligence – Search and Bayesian Update – Python Assessment Answer

Responsive Centered Red Button

Need Help with this Question or something similar to this? We got you! Just fill out the order form (follow the link below), and your paper will be assigned to an expert to help you ASAP.

Unit Code: 7COM1034
1AGJBE
Python Assessment Answer
TASK:
1 Task: Search — Decanting Problem
1.1 Description
The task consists of programming a Python implementation of a solver for the Decanting Task.
1.1.1 Example
Assume you have 3 vessels, vessel 1 capable of holding 5 litres of milk, vessel 2 capable of holding 3 litres and vessel 3 capable of holding 8 litres. The starting state is the first vessel is filled to the limit (i.e. 5 litres), vessel 2 is also filled to the limit (3 litres), and vessel 3 is empty:
Python Assessment
One can now pour the contents of one vessel into another one, without spilling, and stopping when the target vessel is filled. The task is the following: by pouring back and forth, how can one split the total of 8 litres of milk into two equal portions of 4 litres each? How can one pour the contents of the vessels from one to another such that at the end of the pouring process, one
vessel should contain 4 litres and another one also 4 litres. The following considerations apply: it is not allowed to estimate quantities “by eye”. In pouring the contents from one vessel to another, one stops either when the pouring vessel is empty, or
when the target vessel is full. One can not do a “partial decanting”.
1.1.2 The Rules for the General Decanting Task
State Consider a number of vessels 1,2,. . . ,n. Each vessel i has a capacity ci (which is an integer larger than 0). In each state, there is given a fill level fi (which is an integer ranging from 0 to the capacity of the vessel: 0 ? fi ? ci).
In above example, we had: (c1, c2, c3) = (5, 3, 8) and for the start fill level (f1, f2, f3) = (5, 3, 0).
Move A move consists of pouring the contents of one vessel i into another vessel j such that
1. nothing is spilled or added (conservation of liquid);
2. decanting stops when
• i is empty; or
• j is full; (or both).
Goal Starting with a particular start configuration, find a sequence of moves such that a goal configuration is reached (in the example from Sec. 1.1.1, that is (f1, f2, f3) = (4, 0, 4).
1.1.3 The Task
Based on the search algorithms covered in the lecture, write a Python program that starts from some starting state, (f1, f2, f3) and moves according to the rules until it reaches a given goal state for the decanting task. Your solution must at least be able to solve the example from Sec. 1.1.1, but should be more general than that, in that it allows for larger number of vessels and different fillings (see below for a variant).
For this, you have to adapt the search algorithms introduced in the lecture presented in the lecture and apply it to a Decant class which you have to write. Keep in mind that a naive depth-first search need not work, as the problem can repeat positions.
1.1.4 Detailed Instructions and Marking Scheme
Core Tasks You need to write a class Decant and define for it (at least) the following class methods:
1. start(self): returns the starting state for the decanting task.
2. goal(self, node): returns True if the configuration node is a goal configuration, i.e. if it fulfils the target requirement (in the example from Sec. 1.1.1, two vessels with 4 liters each).
3. such(self, node): yields successively all the successors of the configuration indicated by the node.
Furthermore, you will have to write
4. the code importing the various modules
5. the code running the search and printing the results
2 Advanced Tasks Once you have successfully implemented the depth-first or breadth-first solution for the Decanting Task, you can proceed to implement a variant of the problem for additional marks.
6. demonstrate the operation of your solution by solving a variant of the first task, with capacities (c1, c2, c3) = (7, 4, 3), initial state (f1, f2, f3) = (7, 0, 0) (all 7 litres in the first vessel at the beginning), target state (2, 2, 3). [2 mark]
7. modify your class to handle the following variations of the problem:
You have two vessels, one with 4 and one with 9 litres volume. You also have a tap (which allows you to completely fill a vessel) and a sink (which allows you to completely empty a vessel). How can you use the vessels to obtain exactly 6 litres of liquid (collected in a single vessel)?
2 Task: Bayesian Update — A “Whale Watching” Scenario
2.1 Description
The task consists of writing a Python program which simulates a ship trying to reach a whale in a 10 × 10 grid world. More precisely, the ship moves through the grid world and measures (e.g. by “sonar”) a distance to the whale. From it, it deduces where the whale could be (using a Bayesian model), moves, measures again, etc. until it knows where the whale is.
More precisely, the skeleton of the Python program is provided with the file whale_fillin.py (Fig. 1) and the task consists of filling in the missing components.
2.1.1 The Rules for the “Whale Watching” Scenario World The world consists of a 10 × 10 array, both x and y coordinates are numbered from 0 to 9 inclusive, in standard Python convention. Both, whale and ship are located on one of these
(x, y) positions, and the initial positions are randomly chosen (see the __init__() methods of the Whale and the Ship class in the whale_fillin.py file, Fig. 1).
Scenario Run Loop The scenario run loop is already implemented in the whale_fillin.py file (Fig. 1), via the function run(whale, ship) and the main body of the program.
The run loop of the Whale Watching scenario has the following phases:
1. It is first checked whether the whale has been found by the ship, which means that the ship has moved to the same location as the whale.
2. If this is the case, the scenario is completed successfully.
3. If not, the whale performs its move (to be filled in according to the specification in the
Tasks sections, Secs. 2.1.2 and 2.1.3).
4. The ship now obtains the measurement of its distance to the whale — implemented in method whale. estimated by(ship). The distance between two locations l1 = (x1, y1) and l2 = (x2, y2) is computed via
Python Assessment
(In the code, we use the integer part thereof). This distance measure is already implemented in whale_fillin.py.
5. Based on this measurement and its own position, the ship now has to perform a Bayesian estimate of the new position — needs to be filled in in method ship.measure(d).
6. The ship’s internal Bayesian model of the whale’s position is printed by ship.show_model()
(to be filled in).
7. The ship now moves — ship.move() — to a new position according to the movement
rules specified in the Tasks sections, Secs. 2.1.2 and 2.1.3.
8. The scenario run loop now repeats.
2.1.2 The Task
The task of this assignment is to fill in the missing parts of the program, indicated by three dots “…” in the Python program whale_fillin.py (Fig. 1).
Unless stated, the tasks are core tasks.
2.1.3 Detailed Instructions and Marking Scheme
In the file whale_fillin.py (Fig. 1), fill in the following missing code snippets denoted by “…”.
1. In the ship.__init__(xwhale, ywhale) initialization method, the missing initialization of the entries of p_w for the probability of the location of the whale should be filled in.
This Computer Science Assignment has been solved by our Computer Science experts at TVAssignmentHelp. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing style.

Be it a used or new solution, the quality of the work submitted by our assignment experts remains unhampered. You may continue to expect the same or even better quality with the used and new assignment solution files respectively. There’s one thing to be noticed that you could choose one between the two and acquire an HD either way. You could choose a new assignment solution file to get yourself an exclusive, plagiarism (with free Turnitin file), expert quality assignment or order an old solution file that was considered worthy of the highest distinction.

How to create Testimonial Carousel using Bootstrap5

Clients' Reviews about Our Services