80
Variables is to be the value of a variable.” - William Quine

Variables “To be is to be the value of a variable.” - William Quine

Embed Size (px)

Citation preview

Page 1: Variables “To be is to be the value of a variable.” - William Quine

Variables

“To be is to be the value of a variable.” - William Quine

Page 2: Variables “To be is to be the value of a variable.” - William Quine

Announcements

• Pset 1 and prog 1 were due yesterday• Pset 2 and prog 2 are going out today• Tiny (intro) email backlog• Probability Review is… TBA still• Mistake on Alpha / Beta agent algorithm

Page 3: Variables “To be is to be the value of a variable.” - William Quine

def miniMax(self, node, depth, alpha, beta, isMax): if node.isTerminal(): if isMax return node.utility() return –node.utility() if depth == 0: return self.getHeuristic(node) if isMax: for action in node.getLegalActions(): child = node.getSuccessorState(action) value = miniMax(child, depth -1, alpha, beta, not isMax) alpha = max(alpha, value) if beta <= alpha: break return alpha else: for action in node.getLegalActions(): child = node.getSuccessorState(action) value = self.miniMax(child, depth -1, alpha, beta, not isMax) beta = min(value, beta) if beta <= alpha: break return beta

Alpha Beta Pruning

return node.utility()

Page 4: Variables “To be is to be the value of a variable.” - William Quine

0 to 55 to 10

10 to 1515 to 20

20 to 2525 to 30

over 300

5

10

15

20

25

Hours

Num

ber o

f Stu

dent

s

Programming Assignment Time

Page 5: Variables “To be is to be the value of a variable.” - William Quine

0 to 55 to 10

10 to 1515 to 20

20 to 2525 to 30

over 300

5

10

15

20

25

Hours

Num

ber o

f Stu

dent

s

Programming Assignment Time

Consider asking for help.Email your TA (or rock on)

Page 6: Variables “To be is to be the value of a variable.” - William Quine

0 1 2 3 4 5 60

2

4

6

8

10

12

14

16

18

Hours

Num

Stu

dent

s

Problem Set Question Time

Page 7: Variables “To be is to be the value of a variable.” - William Quine

0 1 2 3 4 5 60

2

4

6

8

10

12

14

16

18

Hours

Num

Stu

dent

s

Problem Set Question Time

Total:28 Hours / StudentIdeal:

26 Hours / StudentUnits:4.2 unit class

Page 8: Variables “To be is to be the value of a variable.” - William Quine

Homework Preference

Page 9: Variables “To be is to be the value of a variable.” - William Quine

Driverless Car

Important Algo.

Easy to Visualize

Less Time

Driverless Car

Page 10: Variables “To be is to be the value of a variable.” - William Quine

Search

Variable Based

Machine Learning

CS221

Page 11: Variables “To be is to be the value of a variable.” - William Quine

Search

Variable Based

Machine Learning

CS221

Page 12: Variables “To be is to be the value of a variable.” - William Quine
Page 13: Variables “To be is to be the value of a variable.” - William Quine
Page 14: Variables “To be is to be the value of a variable.” - William Quine
Page 15: Variables “To be is to be the value of a variable.” - William Quine
Page 16: Variables “To be is to be the value of a variable.” - William Quine
Page 17: Variables “To be is to be the value of a variable.” - William Quine
Page 18: Variables “To be is to be the value of a variable.” - William Quine

Image Segmentation

Page 19: Variables “To be is to be the value of a variable.” - William Quine

Image Segmentation

ChrisClaire

Home

Page 20: Variables “To be is to be the value of a variable.” - William Quine

Image Segmentation

Page 21: Variables “To be is to be the value of a variable.” - William Quine

Image Segmentation

Page 22: Variables “To be is to be the value of a variable.” - William Quine

Motivating Example

Page 23: Variables “To be is to be the value of a variable.” - William Quine

Motivating Example

Page 24: Variables “To be is to be the value of a variable.” - William Quine

CSPs

Commutatively: the order of application of actions has no

effect on outcome

Page 25: Variables “To be is to be the value of a variable.” - William Quine

CSPs

Page 26: Variables “To be is to be the value of a variable.” - William Quine

CSPs

Interesting in their own right

Introduction to variable based models

Inference is very similar to … [super secret stuff]

Page 27: Variables “To be is to be the value of a variable.” - William Quine

• Formalization• Inference

• Search• Improved Search• Arc Consistency• Graph Structure• Genetic Algorithms

• Weighted CSPs• Image Segmentation

CSPs

Page 28: Variables “To be is to be the value of a variable.” - William Quine

Real World Problem

Formal Problem

Solution

Model the problem

Apply an Algorithm

Evaluate

The AI Pipeline

Page 29: Variables “To be is to be the value of a variable.” - William Quine

Formally

Page 30: Variables “To be is to be the value of a variable.” - William Quine

Factor Graphs

Page 31: Variables “To be is to be the value of a variable.” - William Quine

Types of Domains

Page 32: Variables “To be is to be the value of a variable.” - William Quine

Constraints

Page 33: Variables “To be is to be the value of a variable.” - William Quine

Variables WA, NT, Q, NSW, V, SA, T Domains Di = {red,green,blue}Constraints: adjacent regions must have different colors

e.g., WA ≠ NT, or (WA,NT) in {(red,green),(red,blue),(green,red), (green,blue),(blue,red),(blue,green)}

Example: Map Coloring

Page 34: Variables “To be is to be the value of a variable.” - William Quine

CS 3243 - Constraint Satisfaction 344 Feb 2004

Variables: F T U W R O X1 X2 X3

Domains: {0,1,2,3,4,5,6,7,8,9}Constraints:

– Alldiff (F,T,U,W,R,O)– O + O = R + 10 · X1

– X1 + W + W = U + 10 · X2

– X2 + T + T = O + 10 · X3

– X3 = F, T ≠ 0, F ≠ 0

Example: Crypto

Page 35: Variables “To be is to be the value of a variable.” - William Quine

Example: Student Seats

Go!

Page 36: Variables “To be is to be the value of a variable.” - William Quine

Real World Problem

Formal Problem

Solution

Model the problem

Apply an Algorithm

Evaluate

The AI Pipeline

Page 37: Variables “To be is to be the value of a variable.” - William Quine

Inference

1. Search

2. Constraint Propagation

Page 38: Variables “To be is to be the value of a variable.” - William Quine

Variables WA, NT, Q, NSW, V, SA, T Domains Di = {red,green,blue}Constraints: adjacent regions must have different colors

e.g., WA ≠ NT, or (WA,NT) in {(red,green),(red,blue),(green,red), (green,blue),(blue,red),(blue,green)}

Example 2: Map Coloring

Page 39: Variables “To be is to be the value of a variable.” - William Quine

Solutions are complete and consistent assignments, e.g., WA = red, NT = green,Q = red,NSW = green,V = red,SA = blue,T = green

Example 2: Map Coloring

Page 40: Variables “To be is to be the value of a variable.” - William Quine

Binary CSP: each constraint relates two variables

Constraint graph: nodes are variables, arcs are constraints

Example 2: Map Coloring

Page 41: Variables “To be is to be the value of a variable.” - William Quine

Inference

1. Search

2. Constraint Propagation

Page 42: Variables “To be is to be the value of a variable.” - William Quine

CS 3243 - Constraint Satisfaction 424 Feb 2004

Search

Page 43: Variables “To be is to be the value of a variable.” - William Quine

Search

Page 44: Variables “To be is to be the value of a variable.” - William Quine

Search

Page 45: Variables “To be is to be the value of a variable.” - William Quine

Search

Page 46: Variables “To be is to be the value of a variable.” - William Quine

General-purpose methods can give huge gains in speed:

• Which variable should be assigned next?• In what order should its values be tried?• Can we detect inevitable failure early?

Improved Search

Page 47: Variables “To be is to be the value of a variable.” - William Quine

Choose the variable with the fewest legal values

a.k.a. minimum remaining values (MRV) heuristic

Most Constrained Variable

Page 48: Variables “To be is to be the value of a variable.” - William Quine

Tie-breaker among most constrained variables

Choose the variable with the most constraints on remaining variables

Most Constraining Variable

Page 49: Variables “To be is to be the value of a variable.” - William Quine

Given a variable, choose the assignment that rules out the fewest values in the remaining variables

Least Constraining Assignment

Fun fact: Combining these heuristics makes 1000 queens feasible

Page 50: Variables “To be is to be the value of a variable.” - William Quine

Inference

1. Search

2. Constraint Propagation

Page 51: Variables “To be is to be the value of a variable.” - William Quine

CS 3243 - Constraint Satisfaction 514 Feb 2004

Idea: • Keep track of remaining legal values for unassigned variables• Terminate search when any variable has no legal values

Forward Checking

Page 52: Variables “To be is to be the value of a variable.” - William Quine

CS 3243 - Constraint Satisfaction 524 Feb 2004

Idea: • Keep track of remaining legal values for unassigned variables• Terminate search when any variable has no legal values

Forward Checking

Page 53: Variables “To be is to be the value of a variable.” - William Quine

CS 3243 - Constraint Satisfaction 534 Feb 2004

Idea: • Keep track of remaining legal values for unassigned variables• Terminate search when any variable has no legal values

Forward Checking

Page 54: Variables “To be is to be the value of a variable.” - William Quine

CS 3243 - Constraint Satisfaction 544 Feb 2004

Idea: • Keep track of remaining legal values for unassigned variables• Terminate search when any variable has no legal values

Forward Checking

Other ways to catch other failures

Page 55: Variables “To be is to be the value of a variable.” - William Quine

CS 3243 - Constraint Satisfaction 554 Feb 2004

At each iteration, make each arc consistent

Arc Consistency

Page 56: Variables “To be is to be the value of a variable.” - William Quine

CS 3243 - Constraint Satisfaction 564 Feb 2004

At each iteration, make each arc consistent

Arc Consistency

Page 57: Variables “To be is to be the value of a variable.” - William Quine

CS 3243 - Constraint Satisfaction 574 Feb 2004

At each iteration, make each arc consistent

Arc Consistency

Page 58: Variables “To be is to be the value of a variable.” - William Quine

CS 3243 - Constraint Satisfaction 584 Feb 2004

At each iteration, make each arc consistent

Arc Consistency

Page 59: Variables “To be is to be the value of a variable.” - William Quine

Graph Structure

Page 60: Variables “To be is to be the value of a variable.” - William Quine

Theorem: • If a constraint graph has no loops then the CSP can be

solved in O(nd 2) time• linear in the number of variables!• Compare difference with general CSP, where worst case is

O(d n)

Trees are Easy

Page 61: Variables “To be is to be the value of a variable.” - William Quine

Non Trees

Page 62: Variables “To be is to be the value of a variable.” - William Quine

Tree Decomposition

Page 63: Variables “To be is to be the value of a variable.” - William Quine

Motivating Example

Sudoku becomes easy (under 0.1s)

Page 64: Variables “To be is to be the value of a variable.” - William Quine

Flavors

Page 65: Variables “To be is to be the value of a variable.” - William Quine

Weighted CSP

A B

weight

Page 66: Variables “To be is to be the value of a variable.” - William Quine

Demo Example

Page 67: Variables “To be is to be the value of a variable.” - William Quine

Demo Example

Page 68: Variables “To be is to be the value of a variable.” - William Quine

Image Segmentation?

Page 69: Variables “To be is to be the value of a variable.” - William Quine

Image Segmentation?

Page 70: Variables “To be is to be the value of a variable.” - William Quine

Genetic Algorithms

Variables D = (D1, D2 … Dn) each with domain = {A, T, G, C}

Try searching by creating populations, mating them with one another and mutating every once in a while.

Just for fun!

Page 71: Variables “To be is to be the value of a variable.” - William Quine

Genetic Algorithms

Just for fun!

Page 72: Variables “To be is to be the value of a variable.” - William Quine

Genetic Algorithms

Just for fun!

Page 73: Variables “To be is to be the value of a variable.” - William Quine

Theme?

Page 74: Variables “To be is to be the value of a variable.” - William Quine
Page 75: Variables “To be is to be the value of a variable.” - William Quine
Page 76: Variables “To be is to be the value of a variable.” - William Quine
Page 77: Variables “To be is to be the value of a variable.” - William Quine

Mehran Sahami

Probability

Page 78: Variables “To be is to be the value of a variable.” - William Quine

Motivating Example

Page 79: Variables “To be is to be the value of a variable.” - William Quine
Page 80: Variables “To be is to be the value of a variable.” - William Quine

And The Revolution Starts…