CMPT 301 Artificial Intelligence Fall 2014 Homework #4

Similar documents
Smart Graphics: Methoden 3 Suche, Constraints

Y. Xiang, Constraint Satisfaction Problems

AI: A Modern Approach, Chpts. 3-4 Russell and Norvig

Pigeonhole Principle Solutions

Outline. NP-completeness. When is a problem easy? When is a problem hard? Today. Euler Circuits

VISUAL ALGEBRA FOR COLLEGE STUDENTS. Laurie J. Burton Western Oregon University

Introduction Solvability Rules Computer Solution Implementation. Connect Four. March 9, Connect Four

Computer Science CS 4013/5013: Artificial Intelligence

Enumerating possible Sudoku grids

Sudoku puzzles and how to solve them

CS MidTerm Exam 4/1/2004 Name: KEY. Page Max Score Total 139

Factorizations: Searching for Factor Strings

Kenken For Teachers. Tom Davis June 27, Abstract

1 Review of Least Squares Solutions to Overdetermined Systems

PARALLELIZED SUDOKU SOLVING ALGORITHM USING OpenMP

Chapter 6: Graph Theory

Design and Analysis of ACO algorithms for edge matching problems

Schneps, Leila; Colmez, Coralie. Math on Trial : How Numbers Get Used and Abused in the Courtroom. New York, NY, USA: Basic Books, p i.

Determining Degree Of Difficulty In Rogo, A TSP-based Paper Puzzle

each college c i C has a capacity q i - the maximum number of students it will admit

Genetic Algorithms and Sudoku

Sudoku Madness. Team 3: Matt Crain, John Cheng, and Rabih Sallman

Graph Theory Problems and Solutions

Informed search algorithms. Chapter 4, Sections 1 2 1

An Introduction to Data Mining. Big Data World. Related Fields and Disciplines. What is Data Mining? 2/12/2015

Search methods motivation 1

M. Sugumaran / (IJCSIT) International Journal of Computer Science and Information Technologies, Vol. 2 (3), 2011,

vii TABLE OF CONTENTS CHAPTER TITLE PAGE DECLARATION DEDICATION ACKNOWLEDGEMENT ABSTRACT ABSTRAK

PERMUTATIONS AND COMBINATIONS

Product Geometric Crossover for the Sudoku Puzzle

Measuring the Performance of an Agent

A search based Sudoku solver

6. Cholesky factorization

Analysis of Micromouse Maze Solving Algorithms

Lecture 3. Linear Programming. 3B1B Optimization Michaelmas 2015 A. Zisserman. Extreme solutions. Simplex method. Interior point method

Permutation Groups. Tom Davis April 2, 2003

Chess Algorithms Theory and Practice. Rune Djurhuus Chess Grandmaster / October 3, 2012

Data Mining: A Preprocessing Engine

Ant Colony Optimization and Constraint Programming

OA3-10 Patterns in Addition Tables

Cryptography and Network Security Department of Computer Science and Engineering Indian Institute of Technology Kharagpur

Math Quizzes Winter 2009

Guessing Game: NP-Complete?

New binary representation in Genetic Algorithms for solving TSP by mapping permutations to a list of ordered numbers

SUPPLY CHAIN OPTIMIZATION MODELS IN THE AREA OF OPERATION

(b) You draw two balls from an urn and track the colors. When you start, it contains three blue balls and one red ball.

Approximation Algorithms

Dynamic Programming. Lecture Overview Introduction

MATHEMATICS Y3 Using and applying mathematics 3810 Solve mathematical puzzles and investigate. Equipment MathSphere

ALGEBRA. sequence, term, nth term, consecutive, rule, relationship, generate, predict, continue increase, decrease finite, infinite

Solutions for Review Problems for Exam 2 Math You roll two fair dice. (a) Draw a tree diagram for this experiment.

Unit 4 DECISION ANALYSIS. Lesson 37. Decision Theory and Decision Trees. Learning objectives:

CMPSCI611: Approximating MAX-CUT Lecture 20

Branch-and-Price Approach to the Vehicle Routing Problem with Time Windows

Comparison of Non-linear Dimensionality Reduction Techniques for Classification with Gene Expression Microarray Data

1 Combinations, Permutations, and Elementary Probability

Lesson #13 Congruence, Symmetry and Transformations: Translations, Reflections, and Rotations

Reductions & NP-completeness as part of Foundations of Computer Science undergraduate course

Tessellations. Practice 1 Identifying Tessellations. In each tessellation, color the repeated shape. Example

CHOOSING THE BEST HEURISTIC FOR A NP-PROBLEM

Session 6 Number Theory

EXAM. Exam #3. Math 1430, Spring April 21, 2001 ANSWERS

Complexity Theory. IE 661: Scheduling Theory Fall 2003 Satyaki Ghosh Dastidar

Course Outline Department of Computing Science Faculty of Science. COMP Applied Artificial Intelligence (3,1,0) Fall 2015

Green = 0,255,0 (Target Color for E.L. Gray Construction) CIELAB RGB Simulation Result for E.L. Gray Match (43,215,35) Equal Luminance Gray for Green

Gamesman: A Graphical Game Analysis System

Full and Complete Binary Trees

Hoover High School Math League. Counting and Probability

Lesson Plans for (9 th Grade Main Lesson) Possibility & Probability (including Permutations and Combinations)

DIRECTIONS FOR SOLVING THE 5x5x5 (Professor) CUBE

ARTIFICIAL INTELLIGENCE METHODS IN EARLY MANUFACTURING TIME ESTIMATION

Ready, Set, Go! Math Games for Serious Minds

Binary Search Trees. Data in each node. Larger than the data in its left child Smaller than the data in its right child

2. (a) Explain the strassen s matrix multiplication. (b) Write deletion algorithm, of Binary search tree. [8+8]

A Quick Guide to Constructing an SPSS Code Book Prepared by Amina Jabbar, Centre for Research on Inner City Health

MATRIX MULTIPLICATION

SAP Business Intelligence ( BI ) Financial and Budget Reporting. 7.0 Edition. (Best Seller At Least 43 copies Sold)

How To Solve The Social Studies Test

Question: What is the probability that a five-card poker hand contains a flush, that is, five cards of the same suit?

Chess Algorithms Theory and Practice. Rune Djurhuus Chess Grandmaster / September 23, 2014

Classification/Decision Trees (II)

Math 408, Actuarial Statistics I, Spring Solutions to combinatorial problems

IE 680 Special Topics in Production Systems: Networks, Routing and Logistics*

Efficient Data Structures for Decision Diagrams

HSI BASED COLOUR IMAGE EQUALIZATION USING ITERATIVE n th ROOT AND n th POWER

I. GROUPS: BASIC DEFINITIONS AND EXAMPLES

Module1. x y 800.

Game Theory 1. Introduction

Integrated System Modeling for Handling Big Data in Electric Utility Systems

Chapter 7: Products and quotients

How To Understand And Solve A Linear Programming Problem

Microsoft Word 2010 Basics

VEHICLE ROUTING PROBLEM

10/13/11 Solution: Minimax with Alpha-Beta Pruning and Progressive Deepening

Web Data Extraction: 1 o Semestre 2007/2008

One pile, two pile, three piles

An Introduction to Number Theory Prime Numbers and Their Applications.

Transcription:

CMPT 301 Artificial Intelligence Fall 2014 Homework #4 75 Total Points Due Date: No Later than 5:30 PM on Monday, October 6, 2014. You may either hand-in this homework written or submit it to the drop box on Canvas. It is expected that you write neatly and legibly and that you provide support for all answers. 1. [10 points] Given a set of locations and distances between them, the Traveling Salesperson Problem (TSP) is to find a shortest tour that visits each location exactly once, and returns to the starting location. We would like to solve the TSP [this] using a greedy hill-climbing algorithm. Each state corresponds to a permutation of locations (a tour). The successor operator Successor(s) generates all neighboring states of s by swapping two locations. For example, if s = (A B C) is a tour, then (B A C), (C B A) and (A C B) are the three neighbors generated by Successor(s). We can set the evaluation function for a state to be the total distance of the tour where each pairwise distance is looked up from a distance matrix. Assume that ties in the evaluation function are broken randomly. (a) [2 points] If there are n locations, how many neighboring states does the Successor() function produce? Solution Because we are just swapping two locations out of a possible n locations, the number of neighboring states is ( ) n 2 (b) [3 points] If there are n locations, how many total states are possible? Solution This is a classic factorial example problem O(n!) (c) [5 points] Imagine you wish to hang posters that mention the incredible career opportunities for computer science majors and minors (especially those that have taken a course in Artificial Intelligence!) The buildings that must be visited are Malouf, Converse, Wellness, Eccles, and Shaw. The goal is to find a tour as short as possible. The distance matrix is as follows: M C W E S M 0.9.6.8.7 C.9 0 1.3 1.5 1.3 W.6 1.3 0.2.3 E.8 1.5.2 0.2 S.7 1.3.3.2 0 1

The student starts applying the hill-climbing algorithm from the initial state of (M E C S W ) (which is cost 3.9). (a) What is the next state reached by hill-climbing? (b) Will a global optimal solution be found by hill-climbing from this initial state, or will it get stuck at some local maxima? Solution From the starting state of (M E C S W ) there are ten possible tours where we exchange any 2 buildings: i. (E M C S W ) = 3.3 ii. (C E M S W ) = 3.3 iii. (S E C M W ) = 3.2 iv. (W E C S M) = 3.7 v. (M C E S W ) = 2.9 vi. (M S C E W ) = 3.7 vii. (M W C S E) = 3.4 viii. (M E S C W ) = 3.6 ix. (M E W S C) = 2.6 x. (M E C W S) = 3.9 The hill climbing algorithm will select (M E W S C) with a cost of 2.6 as the next state. The hill climbing algorithm will repeat, beginning from (M E W S C), and it will find the global optimal solution in one more step with the tour of (S E W M C) with a cost of 1.9. We don t actually know if this is a local or global maximum. In general, the algorithm repeats until the successors return higher costs (it has hit a maximum), or the same costs (it has hit a plateau.) If we knew ahead of time what the actual global maximum was, we could determine if we were at a local or global maximum. (But obviously in most searching situations we do not know what the maximum is!) The tsp.py Python script demonstrates how the solution is found using hill climbing. It is worthwhile looking through this code to determine how hill climbing operates. This program also generates a brute force listing of all tours, and shows what the optimal tour is. As the optimal tour from the brute force is also 1.9, we know the tour (S E W M C) is a global maximum. 2

2. [10 points] The Class Scheduling Problem is where there are a fixed number of professors and classrooms, a list of classes to be offered, and a list of possible time slots that classes may be offered. Each professor has a set of classes that he or she can teach. Consider the Class Scheduling Problem as a constraint satisfaction problem. In particular: (a) What are the variables? Solution Class, Classroom and Instructor. (b) What is the domain of each variable? Solution Class = { list of possible time slots } Instructor = { list of classes he or she is teaching } Classroom = { list of classes being taught } (c) What are the constraints? Solution They include (a) only one class can be in the same classroom at the same time, (b) an instructor can only teach one class at a time. 3. [10 points] Consider the problem of constructing (not solving) crossword puzzles where you fit words into a rectangular grid. The grid given as part of the problem specifies which squares are blank and which are shaded. Assume that a list of words (i.e. a dictionary) is provided and that the task is to fill in the blank squares by using subset of the list of words. Formulate this problem in two ways: (a) As a general search problem (using algorithms we went over in Chapters 3 and 4). Choose an appropriate search algorithm and specify its heuristic. Is it better to fill in blanks one letter at a time or one word at a time? Solution A simple idea is a depth-first search where each successor fills in a word in the puzzle with one of the words from the dictionary. A possible heuristic is assigning each word in the dictionary some level of difficulty (i.e. the word stochastic would be assigned a higher difficulty level than the word cat) and try to achieve a certain difficulty level for a particular puzzle. Given this approach, it is probably a better idea to fill blanks in one word at a time rather than one letter at a time. (b) As a constraint satisfaction problem. Should the variables be letters or words? Solution If we choose letters, a variable is each box in the puzzle and the constraints are the variables must combine to make a word in the dictionary. If strings of boxes are variables, the domain is the set of words from the dictionary with the constraint that the intersection of two words must have the same letter in the intersecting box. 3

4. [10 points] The diagram shown in Figure 1 represents a map of a country with 6 states. Each state must be colored in Red, Green, or Blue, such that no two adjacent states get the same color. We represent this as a constraint satisfaction problem with 6 variables (A, B, C, D, E, and F) each having the same domain of {Red, Blue, Green} of values. Use CSP-Backtracking with forward checking algorithm to assign each state a color according to the constraint that no two adjacent states are assigned the same color. Use the minimum-remaining-value MRV as a heuristic. Solution Since you were never asked which state to begin with, we ll choose the initial state alphabetically. The solution is trivial. A B C D E F Domain RGB RGB RGB RGB RGB RGB R GB GB RGB RGB GB G B RB RGB B B R RGB B R G B G B B Figure 1: Map. 5. Consider the 5-Queens problem as such: Variables: Q 1, Q 2, Q 3, Q 4, Q 5 (One variable per row of the chessboard.) Domains: {1, 2, 3, 4, 5} (The column in which a Queen is placed.) Constraints: i, j {1..5}, NON-THREATENING (Q i, Q j ) Solution Note Because chessboards are symmetric (i.e. N N) this works if we consider the variables as representing each row or each column on a chessboard. 4

(a) [5 points] Suppose we try the assignment Q 1 = 3. Run the forward checking algorithm and draw a map of the chessboard indicating the remaining domains for Q 2,...Q 5. Solution If we assign Q 1 = 3, the remaining domains are: Q 2 = {1, 5} Q 3 = {2, 4} Q 4 = {1, 2, 4, 5} Q 5 = {1, 2, 4, 5} (b) [10 points] Now run the AC-3 algorithm and draw a new map of the chessboard indicating the remaining domains for Q 2,...Q 5. Did AC-3 help? Solution When we run AC-3 we do not reduce the size of the domains for Q 2, Q 3, or Q 4. However, when we consider assigning Q 5 = 2, we see that the current domain of {2,4} for Q 3 = {2, 4} does not allow it, so we remove 2 from the domain of Q 5. The same thing occurs when we consider assigning Q 5 = 4. The resulting domains after running AC-3 are Q 2 = {1, 5} Q 3 = {2, 4} Q 4 = {1, 2, 4, 5} Q 5 = {1, 5} So yes, AC-3 did help because it reduced the domain of Q 5. 6. [10 points] The tree shown in Figure 2 begins with Max at the root. You may find it is easiest to answer these questions by redrawing the tree, illustrating the values being returned at each node, and in the case of α β pruning, showing which subtrees were pruned. (a) What is the value of Minimax at the root? Solution 2 is returned at the root. (b) Repeat the problem, but this time using α β pruning. Solution: Figure 3 7. [10 points] The tree shown in Figure 4 begins with Max at the root. You may find it is easiest to answer these questions by redrawing the tree, illustrating the values being returned at each node, and in the case of α β pruning, showing which subtrees were pruned. 5

Figure 2: Example of 2-ply Minimax tree. (a) What is the value of Minimax at the root? Solution: Figure 5 (b) Repeat the problem, but this time using α β pruning. Solution: Figure 6 6

Figure 3: Solution of 2-ply Minimax tree with α β pruning. Figure 4: Example of 3-ply Minimax tree. 7

Figure 5: Solution of 3-ply Minimax tree. Figure 6: Solution of 3-ply Minimax tree with α β pruning. 8