Q

CMPT 317 Introduction to Artificial Intelligence Assignment Help

CMPT 317 Introduction to Artificial Intelligence Assignment Help - Obtain A++ grades by taking CMPT 317 Introduction to Artificial Intelligence Assignment Help Services!!
Previous << >> Next

ARE YOU LOOKING FOR RELIABLE CMPT 317 INTRODUCTION TO ARTIFICIAL INTELLIGENCE ASSIGNMENT HELP SERVICES? MIRACLESKILLS.COM IS RIGHT CHOICE AS YOUR STUDY PARTNER!

CMPT 317 Introduction to Artificial Intelligence - University of Saskatchewan

AIMA Chapter - Constraint Satisfaction

Problem 1

Purpose: To learn the API of the CMPT 317 CSP Solver. To express a simple Constraint Satisfaction Problem in terms of variables, domains, and constraints, and get a Solver to solve it.

(a) A simple map is shown below. There are 5 regions, labelled O-4. It can be coloured with three colours.

Note: labels are identifiers for each region; labels are not colours!

0

 

4

1

3

2


Using the example, and Python, write a short script that sets up the problem, solves it, and produces an answer.

(b) A more complicated map is shown below. There are 8 regions, labelled O-7.

This map cannot be coloured with 3 colours, but it can be coloured with 4 colours. Using the example, and the solver, write a short script that solves the problem with 4 colours, but fails when just 3 colours are used.

When completed, your script should run on the command-line, as follows:

UNIX$ python 3 A 3 Q 1 _ A . py
...
UNIX$ python 3 A 3 Q 1 _ B . py
...

ORDER NEW COPY OF CMPT 317 INTRODUCTION TO ARTIFICIAL INTELLIGENCE ASSIGNMENT & GET HIGH QUALITY SOLUTIONS FROM SUBJECT'S TUTORS!

Problem 2:

Purpose: To make use of unary constraints provided by the Solver API. To use the solution provided by the Solver API in a simple Python script.

In class we've been using the Latin Square problem, which is informally described as follows: We take a N x N grid, and fill it with the numbers 1 through N , so that each number appears exactly once on each row and column. Problems of varying degree of difficulty can be created this way, if some of the cells in the grid are already filled in. The puzzle is to fill in the remainder of the cells. This problem is a little simpler than the popular Sudoku problems.

We can formulate this problem in terms of variables (the blank cells) and domain values (1 through N ), and constraints (cells on the same row and column cannot be equal). But as you have noticed, there is information in the square in the form of cells that are already filled in by numbers.

The main purpose of this Problem is to give you good reason to work with unary constraints. Given the square above, you could reason that the top left cell cannot be 2, 3, or 4, using the numbers on its row and its column. In your script, you might hard-code an initial domain for this variable using the result of that reasoning. In a sense, you worked out some of the solution yourself. But imagine a bigger problem, e.g., size N = 100. You wouldn't want to do this reasoning yourself for all the cells before getting the computer to solve the rest.

Unary constraints allow us to automate the reasoning. In the Solver API, there is a Unary constraint class called UnaryNotEquals which lets you tell the Solver that a given variable cannot take a given value. For example, the top left cell cannot be 2. The unary constraint API requires one variable, and a single value, so you'll need more than one unary constraint for each blank cell.

This is a simple idea, but we can now imagine a program that could read a Latin Square problem from a file. For blank cells, we create variables. Binary constraints (not equals) are added between all pairs of variables appearing in the same row and column. And unary constraints are created for the numbers already entered in the grid.

There are a few details left to work out. Write a script that can solve the above problem, using unary constraints, and binary constraints without "hard-coding the initial domain" as described above. Don't worry about reading problems from a file (see Problem 5). Figure out how to use the unary constraints with your variables and domains.

Finally, the Solver API returns a SearchTerminationRecord object, similar to the one in Assignment 1. It's a bit simpler, because the Solver only uses DFS, so we really don't need to keep track of the space used by the frontier. The record has the following public attributes:

• success: A Boolean value indicating whether a solution was found in the time available.

• result: A Python dictionary, whose keys are the variable identifiers you specified in your script, and the values the Solver worked out to satisfy the constraint.

• time: A floating point value showing the time taken in seconds. If this value is larger than your time limit, the Solver process was terminated before an answer was given. If the time is less than your time limit, then the CSP you specified has no solution; there is no way to satisfy the constraints.

• nodes: An integer value showing how many nodes the Solver expanded in the search. This is a time- independent measure of computational effort.

In Assignment 1, it was enough to use the display() method.

In your script for this Problem, you should use the result dictionary to discover the values the Solver found for each variable, and then display a nice square with all the solution values in the right places. This will require a bit of thoughtful programming, but it is not an AI problem.

When completed, your script should run on the command-line, as follows:
UNIX$ python 3 A3Q2 . py
Before :
_ 2 _ _ 4
3 _ 1 _ _
_ 4 _ _ 1
2 _ _ _ 3
_ _ 2 1 _
After :
1 2 5 3 4
3 5 1 4 2
5 4 3 2 1
2 1 4 5 3
4 3 2 1 5

NEVER LOSE YOUR CHANCE TO EXCEL IN CMPT 317 INTRODUCTION TO ARTIFICIAL INTELLIGENCE ASSIGNMENT - HIRE BEST QUALITY TUTOR FOR ASSIGNMENT HELP!

Problem 3

Purpose: To practice creating constraints using the relation representation.

The N-Queens problem is to place N Queens on a N x N grid so that no two Queens are in the same row, column or diagonal. Below is an example of one solution to the N = 8 case:

Formulate this problem as a Constraint Satisfaction Problem in terms of variables, domains, and constraints. Then use the Solver API to solve it. When you're finished, your script should take a value for N on the command-line, and display a solution (if given enough time).

The Solver API does not have a built-in constraint for checking diagonals. But this is not a big problem: the constraint class BinaryRelation can represent any arbitrary binary constraint. All you need to do is figure out which pairs of values are allowed, if two queens cannot be on the same diagonal.

When completed, your script should run on the command-line, where N is given as an argument. Option- ally, you can allow the time limit to be set on the command-line as well. E.g.

UNIX$ python 3 A3Q3 . py 8 10
Search successful ( 0 . 0019 sec , 92 nodes )
Solution diagram :
....... Q
... Q ....
Q .......
.. Q .....
..... Q..
. Q ......
...... Q.
.... Q ...

The diagram above is optional. However, your script should use the result dictionary returned in the SearchTerminationRecord object, and check the solution. This is not optional.

Write a simple script hard-coded for N = 4 first. When you get correct solutions to that, you can generalize for any given N . Don't worry if your script can't solve for large N in reasonable time.

GETTING STUCK WITH SIMILAR CMPT 317 INTRODUCTION TO ARTIFICIAL INTELLIGENCE ASSIGNMENT? ENROL WITH MIRACLESKILLS'S CMPT 317 INTRODUCTION TO ARTIFICIAL INTELLIGENCE ASSIGNMENT HELP SERVICES AND GET DISTRESSED WITH YOUR ASSIGNMENT WORRIES!

Problem 4

Purpose: To formulate a non-trivial problem in two different ways, and compare the results.

Exercise 6.3 describes a problem to construct crossword puzzles. The idea is to try to fill a grid with letters so that sequences of grids horizontally and vertically form real words. The problem came up in lecture as well.

There are 8 boxes (we don't use the grey box). This grid can 2t four 3-letter words. The words read hori- zontally, left to right, and vertically top down. As is common for crosswords, we can label the 4 sequences using the numbers in the top left corner of some boxes. The grid needs a 3-letter word starting at box 1, going across, and another word starting at box 1 going down. Similarly, we need a 3-letter word vertically starting at box 2, and a 3-letter word horizontally starting at box 3.

The problem is to find 3-letter words that 2t into the grid. Words that intersect have to use the same letter at the intersection. In the example above, the word at 1 Across could be ACE so the word at 2 Down has to start with E, maybe EYE.

This is a construction problem, because we are just trying to find words that 2t. There are no clues to give hints for the words. You might use a program like this to construct a crossword puzzle, and then add clues later.

To keep things simple, we'll only use 3 letter words, and we'll have 3 examples to work on. The above grid (the donut), and the following two grids (a square, and a braid):

On Moodle, you'll find a text file containing the 3 letter words you're allowed to use. This list was borrowed from a website for other word games.

The problem can be formulated in two rather distinct ways (as mentioned in AIMA Execise 6.3): 1.Variables are sequences of locations for complete words, e.g., 1-Across, 1-Down, 2-Down, etc. 2.Variables are the locations for individual letters.

Of course, you'll need to think about domains and constraints for the two formulations, and thinking about those is part of the problem. What are appropriate domains? What are appropriate constraints? This Problem is about trying to work out these issues with little guidance from the Problem.


UNIX$ python 3 A 3 Q 3_ A . py
...
UNIX$ python 3 A 3 Q 3_ B . py
...

Compare the performance of the Solver, in terms of time, and nodes expanded (use the information in the SearchTerminationRecord). Which of the two methods was better (time, or nodes expanded)? Which was easier to formulate?

MIRACLESKILLS.COM GIVES ACCOUNTABILITY OF YOUR TIME AND MONEY - AVAIL TOP RESULTS ORIGINATED CMPT 317 INTRODUCTION TO ARTIFICIAL INTELLIGENCE ASSIGNMENT HELP SERVICES AT BEST RATES!

Problem 5

Purpose: To apply the Solver API to the Graph Colouring Problem.

In this Problem, you'll write a Python script to solve the Graph Colouring Problem. Like Assignments 1 and 2, there are a bunch of files full of problem instances to solve. You'll write the script here, and generate results which you will present and discuss in the next Problem.

The graph colouring problem is basically the same as the map colouring problem (Problem 1), except we colour vertices in a graph instead of regions in a map. In Problem 1, you were given a couple of diagrams, and it was your task to identify which regions were adjacent, and specify the appropriate constraints.

In this Problem, we will use the language of undirected graphs to represent the map. A vertex in the graph is a region, and the edges in the graph indicate which regions are adjacent. For example, here's a small graph (on the left) and a corresponding map-like diagram on the right. You might recognize this one from Problem 1.

The vertices (and regions) have identifiers consisting of the integers O through 4 (inclusive). These are vertex names, not colours! There are 6 edges in the graph, and 5 vertices. This particular example can be coloured with k = 3 colours.

A number of example files have been provided. Each file defines some number of graphs. All examples, even the very largest, can be labelled with k = 4 colours; some of the smaller ones can be labelled with just k = 3 colours.

Each example graph is described using an adjacency list representation, as follows. Suppose there are 5 vertices in an example graph. The vertices will be represented by integers O through 4. Each vertex will appear as the first number on a line, which is then followed by a sequence of all of its neighbours in the graph. For example, the small example above will represented as follows:

UNIX$ python 3 A3Q5 . py simple GC . txt 4 10
...

The first line indicates that there are exactly 5 vertices in the graph, and therefore exactly 5 lines in the description. Each line after the first describes one of the vertices. The line starting with O indicates that there is an edge from vertex O to vertex 3, and another edge from vertex O to vertex 4. The vertex 1 has edges to vertices 2 and 4. The vertex 2 has edges to vertices 1 and 4. Etc.

There are multiple graphs in each file. Each file of graphs will start with single integer that indicates how many graphs are in the file. There is exactly one blank line following each example graph. The files gen- erally describe graphs of increasing size, and so will provide more challenge for your implementation. But they are randomized, so they are not strictly increasing in diffculty. By chance, it might be easier to colour a specific graph with 5OO vertices than some other graph with only 4OO vertices.

Write a Python script that reads a given file of example problems and uses the Solver API to solve the problems in the file simpleGC.txt as follows.

The command-line above has 3 command-line arguments: the file of problems to solve (simpleGC.txt), the number of colours to try (4), and the time limit in seconds (1O). Most of the problems can be solved in less than a second.

ORDER NEW COPY OF CMPT 317 INTRODUCTION TO ARTIFICIAL INTELLIGENCE ASSIGNMENT AND SECURE HIGHER MARKS!

Problem 6

Purpose: To apply local search to a search problem, and present results.

Use the program you wrote from Problem 5, and use it to solve the problems in the given problem set files:
• a200.txt: 1O graphs with 2OO vertices each.
• b200.txt: 1O graphs with 2OO vertices each.
• c400.txt: 1O graphs with 4OO vertices each.
• d400.txt: 1O graphs with 4OO vertices each. Produce the following table (one for each file):

 

Number of Colours

 

k = 3

k = 4

Problem set

# solved

Ave Time

Ave Nodes

# solved

Ave Time

Ave Nodes

a200.txt

 

 

 

 

 

 

b200.txt

 

 

 

 

 

 

c400.txt

 

 

 

 

 

 

d400.txt

 

 

 

 

 

 

For this table, use a time limit of 1O seconds, and include in your averages all the data, even if no solution was found.
In your tables, limit your precision to 5 significant figures (roughly). In other words, don't produce tables that show all 15 digits of a double-precision floating point number. Only the first 5 or so digits are meaningful. You can do this in your program by formatting your output, or you can do this by hand as you enter the data.

Problems to answer

1. For a graph colouring problem with N vertices and k colours, how big is the search tree?

2. Using your data for k = 4 on the problem set a200.txt, calculate an average number of nodes per second to solve the problems, then predict how much time it would take to search the full search tree for N = 200 and k = 4 (i.e., if every option were tried, and only a complete assignment was checked for consistency with the constraints - this is the very worst case).

3. Compare the average number of nodes reported by the Solver with the value for N on each set.
Explain why the average number of nodes explored is so close to N .

4. Some of the problems in d400.txt may have been terminated before the Solver was able to 2nd a solution. But the Solver probably found a solution for every single problem in c400.txt in much less than a second. Explain why.

5. For fun, let your program run for a long time to try to solve the problems that did not get solved in the 10 second time limit. Did you eventually find a solution, and if so, how long did it take. If not, what is the longest amount of time that you tried?

WORK TOGETHER WITH MIRACLESKILLS'S TUTOR TO ACHIEVE SUCCESS IN CMPT 317 INTRODUCTION TO ARTIFICIAL INTELLIGENCE ASSIGNMENT!


Want to Excel in Course? Hire Trusted Writers for Help! —> https://miracleskills.com/

Lists of comments


Leave a comment


Captcha