Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Csci 4511W Fall 22 Homework 2, Section 1

Questions 1 though 5 require below written answers (and a picture).

You will upload  a file named: HW2_YourLastName.pdf file with your written solutions (and a picture) to questions 1 through 5 to the assignment named  Homework 2  Short Answer on GradeScope

Question 6 is a programming question.  You will answer question 6 by adding the code necessary to answer the sub questions correctly to the file student_code.py and submitting the updated file with your solutions to GradeScope. See the           instructions with question 6 below for further instruction. And note, you must      complete question 5 successfully before you can complete question 6

1.   [10 points] Answer the following questions precisely and briefly - explain your reasoning:

a.   Does the performance measure chosen for an agent affect the agent’s function? If yes, how? If not, why not?

Feel free to use the vacuum cleaner problem or any other problem to support your explanation.

b.    Does an agent need to keep the history of percepts to be rational? If yes, why? If not, why not?

2.   [30 points] Consider the travelling salesperson problem (TSP).

A salesperson has to visit a set of cities, visiting each city only once and then returning back to the starting city. The objective is to minimize the total distance traveled when visiting all the   cities

Assume each city is directly connected to each other city.

As an example, consider a set of 4 cities to be visited, Atlanta, Boston, Chicago, and Detroit, all connected directly to each other with connections of different lengths (the length on each       connecting edge is the distance between the cities.

You start in one of the cities and need to get back to city you began in at the end of the tour after taking the shortest path through all the cities on the tour.

Answer precisely and briefly:

a. How you would represent the states (i.e., what information needs to be included in any state to make sure the state describes all the information you need to apply the actions)

b. What is the initial state. The representation of the initial state has to be consistent with the way states are represented

c. What goal test you would use?

d. What are the actions? Be specific

e. Draw a picture of a set of 4 cities with each city directly connected to each other, with           different lengths on each connecting edge in your picture, and include it in your answer to this

question. Is the state space a tree or graph? Justify your answer.

f.  Suppose the number of cities in increased to 40 or 50, Can uniformed search strategies be   used to find a solution to the TSP for the picture you drew in part e?  If so, which ones?  If not, why not?

3.   [20 points] – 5 points each. No partial credit for a wrong answer to parts a, b, c, or d. You are given the following tree:

 

Give the order of the nodes are expanded for the following uninformed search strategies.

a)   Breadth-first search (BFS)

b)   Depth-first search (DFS)

c)   Iterative-deepening search

d)   Depth-limiting with a limit of 3

4.   [10 points] For each state space given bellows specify which uniformed search algorithm(s) are guaranteed to find a solution if a solution exists, or find that there is no solution. Consider the following cases:

a.   The search space is finite. Which algorithm(s) have the guarantee specified above?

b. The search space is finite and has cycles. Would your answer to part a change? If so why? If not, why not?

Instructions for problems 5 and 6:

5)   [10 points] Install the aima-python software on your computer or on your cselab account. If  you have issues installing on your computer, login to a CSELabs machine and answer questions  5 and 6 there so you can finish the work and then circle back to work on your own machine.  It is probably a path problem that may take time to figure out.

You can copy the code from the github directory or clone it from:

https://github.com/aimacode/aima-python

1)   zip, download, and uzip OR create git repository on your own machine and clone

2)   make HW directory on your machine

3)   uzip or clone aima python code into your new HW directory  (aima-python

folder/directory should be installed or copied into the HW folder/directory and reside in its own folder/directory named aima-python”)

4)   create a “ .py”  file for each Programming HW file (Or use the one we give you) The “ .py”  file should include the following directives:

import sys

sys.path.append('aima-python')

from (insert a file name here) import * // name of file(s) you are using

For example, for agents.py:

from agents.py import *

To clone, you can find the instructions at   https://github.com/aimacode/aima-

python/blob/master/README.md

Here are the setup instructions for cloning into a github repository :

1.   Run the following commands:

git clonehttps://github.com/aimacode/aima-python.git

Go to the new aima-python directory and run:

pip3 install -r requirements.txt

pip3 install ipythonblocks

pip3 install sortedcontainers

2.   To pass all the tests, you need to download data files in your copied repository.  Do the following:

git submodule init

git submodule update

3.   To test the install, in the aima-python directory, execute the command

python3 -m doctest -v *.py 

python3 -m doctest -v agents.py

python3 -m doctest -v search.py

python3 -m doctest -v search.py

The "-v" is optional; it means "verbose".  Various output lines are printed, but if  all goes well there should be no instances of the word "Failure", nor a long line of "".  If you do use the "-v" option, the last line printed should be "Test passed."      The important part is to pass the tests for agents.py and search.py, which we will  use next.

A student in the class last semester found errors in some tests in the deep learning and perception modules.  You can find the updated version in his repository at     https://github.com/nik312123/aima-python  .  We will not use those modules, but this is useful if you plan on using those modules.

>When you have installed the aima-python code on your computer, take a screen shot of the contents of the aima-python directory on YOUR computer and save it as a jpg or jpeg. Insert the picture into the file with your written solutions to problems 1-4 above.   Then     create a .pdf file of your written solutions and the picture

6.   [20 pointt] You will use the student_code.py file to add your own code.    The file

template you will begin with is called student_code.py and it accompanies this write-up on Canvas. Add the code necessary to answer the questions below to file                         student_code.py (and make sure it executes correctly). Then upload the file to the          assignment named: Homework 2  Programming

For the questions below, you need to use the code in the aima-python file agents.py.  Read the   code in agents.py to see which functions you need to use. The code includes examples of how to call the functions.

An example of how to determine how to run the program is below.  If you look at the              ReflexVacuumAgent, the instructions to run the program are in the comments immediately     following the def statement.  The statements you want to run are indicated by the “>>>” (what follows).    To control the number of runs you can pass in an integer argument run().  Eg.        environment.run(10)

def ReflexVacuumAgent():

"""

[Figure 2.8]

A reflex agent for the two-state vacuum environment.

>>> agent = ReflexVacuumAgent()

>>> environment = TrivialVacuumEnvironment()

>>> environment.add_thing(agent)

>>> environment.run()

>>> environment.status == {(1,0):'Clean' , (0,0) : 'Clean'}

True

"""

a.   (5 points)  Run the reflex vacuum agent for 25 steps in the trivial vacuum environment. Use the TraceAgent function to print the perceptions and actions.

b.   (5 points)  Run f the model based vacuum agent for 25 steps in the trivial vacuum environment again using TraceAgent to print the perceptions and actions.

c.   (5 points)  Run the random vacuum agent for 25 steps in the trivial vacuum environment again using TraceAgent to print the perceptions and actions.  Run the program a second time and show the results again. Are they the same or not?

d.   (5 points)  Compare the three agents in the trivial vacuum environment using the compare_agents function and print the performance for each of the agents.