cs 189 today

51
CS 189 today Open-ended project option… A few more problems… … and one more algorithm! Jotto game finale?! Rest of the term No meeting on Tuesday, November 4 th Riverside contest on Saturday, November 9 th Final meeting of CS 189 on Tuesday, Nov. 12 th - quick review of the contest - project proposals due (optional…) - remember : problems can be submitted to term's end: 12/23 I'll meet with our teams…

Upload: margaret-william

Post on 02-Jan-2016

25 views

Category:

Documents


0 download

DESCRIPTION

CS 189 today. Open-ended project option…. A few more problems…. … and one more algorithm!. Jotto game finale?!. Rest of the term. No meeting on Tuesday, November 4 th. I'll meet with our teams…. Riverside contest on Saturday, November 9 th. Final meeting of CS 189 on Tuesday, Nov. 12 th. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: CS 189 today

CS 189 today

Open-ended project option…

A few more problems… … and one more algorithm!

Jotto game finale?!

Rest of the term

No meeting on Tuesday, November 4th

Riverside contest on Saturday, November 9th

Final meeting of CS 189 on Tuesday, Nov. 12th - quick review of the contest- project proposals due (optional…)- remember: problems can be submitted to term's end: 12/23

I'll meet with

our teams…

Page 2: CS 189 today

Jotto!

JRs SRs other

diner 1

This term's first class to guess another's word earns 1 problem...

diner 1 diner 2

This term's last class to have its word guessed earns 1 problem...

Sophs

diner 1

POM-CMC-SCR-PTZ

diner 1

about 3 about 0 about 1about 1 about 1yearn 2 yearn 0 yearn 1yearn 2 yearn 2

jotto 2 jotto 0 jotto 1jotto 0 jotto 1

syrup 1 syrup 1 syrup 1syrup 2 syrup 1

Page 3: CS 189 today

Projects? Alums: What do you feel you didn't get @ HMC CS?

Paul Scott

Josh Klontz

Josh Ehrlich Moira Tagle

Karen GraggWill Scott

Page 4: CS 189 today

Answers… Alums: What do you feel you didn't get @ HMC CS?

Paul Scott

Josh Klontz

Josh Ehrlich Moira Tagle

Will Scott

web technologies (at

least for te

rminology...)

cmake and build systems

the code check-in process

web things

parallelizing/distributing

large computations

web frameworks

don't try to teach web stuff

Karen Gragg

Page 5: CS 189 today

Optional open-ended project

• worth up to +12 problems ~ also, an opportunity…

• … to try out / get familiar with / learn about a technology, domain, library, or project

that might be one of your answers to the question, What do you feel you didn't learn @ HMC?

Page 6: CS 189 today

Optional open-ended project

that might be one of your answers to the question, What do you feel you didn't learn @ HMC?

(0) decide what you'd like to learn…

(1) find a reasonable resource for it…

(2) create a project and a write-up…

(3) time expectation: 3 hours per week

Plan:

• worth up to +12 problems ~ also, an opportunity…

• … to try out / get familiar with / learn about a technology, domain, library, or project

Page 7: CS 189 today

Optional open-ended project

that might be one of your answers to the question, What do you feel you didn't learn @ HMC?

OpenCVQt

other UI librarygame dev. libraryconsole library?

hardware project requiring programming

something you've wanted to do but

you wouldn't otherwise get to

web basics: HTML/CSS/Javascript/JQuery

"Minecraft" technology?

framework, e.g., web

framework (Django et al.)

en.wikipedia.org/wiki/ Comparison_of_web_

application_frameworks

• worth up to +12 problems ~ also, an opportunity…

• … to try out / get familiar with / learn about a technology, domain, library, or project

Page 8: CS 189 today

Drawbacks?

• specific technologies should be avoided in the CS curriculum

I agree. Yet this one-unit course is too small to shift

that balance...

• there's not enough support to make it work

True! I'm no expert at what you're working on, but here the goal's not expertise, but

the "working on" …

• too much time is required…!3 good-faith hours per week +

write-up == 12 problems

Page 9: CS 189 today

Drawbacks? Benefits?• it never hurts to have an on-line portfolio of one or more of your projects...

• helps the limitations of DWIC letters, because it's unique + personalized

• curricular support vs. expertise support

• sometimes the benefits don't outweigh the drawbacks

one unit!

John Grasel, Cris Cecka

"did well in class"

• specific technologies should be avoided in the CS curriculum

I agree. Yet this one-unit course is too small to shift

that balance...

• there's not enough support to make it work

True! I'm no expert at what you're working on, but here the goal's not expertise, but

the "working on" …

• too much time is required…!3 good-faith hours per week +

write-up == 12 problems

Page 10: CS 189 today

Interested? To do by 11/12:

project proposal due2-3 paragraphs:

(0) Use the CS wiki or some similar site…(1) Describe your overall project idea(s)(2) Describe your plan/resources• online tutorial or course?• do you have a "Hello, World!" version?

(3) Document your time-spent(4) Check-in with me on 11/12 (or before…)

grading ~ worth up to 12 problems…

Page 11: CS 189 today

PHP's WAT!php > $x = "209";

php > $x++;

php > print( $x ); print( "\n" );

210

php –a

Page 12: CS 189 today

PHP's WAT!php > $x = "209";

php > $x++;

php > print( $x ); print( "\n" );

210

php > $x = "may";

php > $x++;

php > print( $x ); print ( "\n" );

maz

php > $x++;

php > print( $x ); print ( "\n" );

mba

php –a

$x = "2d9";Now, let's try it with…

Page 13: CS 189 today

Ford-Fulkerson algorithm

What's the maximum flow possible, from src to sink?

s

B

E

D

C13

t

16

10 4 9

12

14

7

20

4source

capacity

Max Flow !

sink or target

Page 14: CS 189 today

s

B

E

D

C13

sB

C

D

E

FROM

s B C D E

t

- 16 13 - -- - 10 12 -

- 4 - - 14

- - 9 - -

- - - 7 -

--

-

20

4

- - - - - -t

t

16

10 4 9

12

14

7

20

4

TO

Capacity Graph

source

sink

(Step #1) Use depth- or breadth-first search to find any path from s to t.

Max Flow

What's left ?

Page 15: CS 189 today

s

B

E

D

C13

sB

C

D

E

s B C D E

t

- 16 13 - -- - 10 12 -

- 4 - - 14

- - 9 - -

- - - 7 -

--

-

20

4

- - - - - -t

t

4/16

10 4 9

0/12

14

7

8/20

4source

sink

(Step #2) Compute RESIDUAL graph

Max Flow

What's left… sB

C

D

E

s B C D E

- 4 13 - -12 - 10 0 -

- 4 - - 14

- 12 9 - -

- - - 7 -

--

-

8

4

- - - 12 - -t

t

Residual capacities.

and the red edges?Backwards capacities!

12 12

12

Page 16: CS 189 today

s

B

E

D

C13

sB

C

D

E

s B C D E

t

- 16 13 - -- - 10 12 -

- 4 - - 14

- - 9 - -

- - - 7 -

--

-

20

4

- - - - - -t

t

4

10 4 9

0

14

7

8

4source

sink

(Step #3) Repeat until no path exists…

Max Flow

sB

C

D

E

s B C D E

- 4 13 - -12 - 10 0 -

- 4 - - 14

- 12 9 - -

- - - 7 -

--

-

8

4

- - - 12 - -t

t

12 12

12

Residual capacities.

Backwards capacities.

Page 17: CS 189 today

B

E

D

C12/13

11/16

0/10 1/4 0/9

12/12

11/14

7/7

19/20

4/4

max flow: 23

Max Flow

ssource

t

sink

(Step #3) Repeat until no path exists…

(Step #2) Compute RESIDUAL graph

(Step #1) Use depth- or breadth-first search to find any path from s to t.

Page 18: CS 189 today

Python…

if __name__ == "__main__":

# make a capacity graph # node A B C D E F C = [ [ 00, 16, 13, 00, 00, 00 ], # A [ 00, 00, 10, 12, 00, 00 ], # B [ 00, 04, 00, 00, 14, 00 ], # C [ 00, 00, 9, 00, 00, 20 ], # D [ 00, 00, 00, 7, 00, 4 ], # E [ 00, 00, 00, 00, 00, 00 ] ] # F

print "C is", C source = 0 # A sink = 5 # F

max_flow_value = max_flow( C, source, sink ) print "max_flow_value is", max_flow_value

Linked at the ACM website by the slides…

Page 19: CS 189 today

def max_flow(C, source, sink): n = len(C) # C is the capacity matrix F = [[0] * n for i in range(n)] # F is the flow matrix # residual capacity from u to v is C[u][v] - F[u][v]

while True: path = BFS(C, F, source, sink) if not path: break # no path - we're done!

# find the path's flow, that is, the "bottleneck" edges = [C[u][v]-F[u][v] for u,v in path] path_flow = min( edges ) print "Augmenting by", path_flow for u,v in path: # traverse path to update flow F[u][v] += path_flow # forward edge up F[v][u] -= path_flow # backward edge down

return sum([F[source][i] for i in range(n)]) # out from source

edmonds_karp algorithmPython…

Page 20: CS 189 today

def BFS(C, F, source, sink): queue = [source] # the BFS queue paths = {source: []} # stores 1 path per graph node while queue:

u = queue.pop(0) # next node to explore (expand) for v in range(len(C)): # for each possible next node

# path from u to v? and not yet at v? if C[u][v] - F[u][v] > 0 and v not in paths: paths[v] = paths[u] + [(u,v)] if v == sink: return paths[v]

queue.append(v) # go from v in the future return None

Python…

Page 21: CS 189 today

Is maxflow good for anything else?

that is, beyond solving maximum-flow problems...

Page 22: CS 189 today

we have four brides and six grooms

and some acceptable possibilities ...

a bipartite graph

Matching!

Page 23: CS 189 today

we have four brides and six grooms

and some acceptable possibilities ...

a maximal matching == no more matchings without rearrangement

Matching!

Page 24: CS 189 today

we have four brides and six grooms

Matching! and some acceptable possibilities ...

a maximum matching == no rearrangements will yield more matchings

Page 25: CS 189 today

Maximum matching is max flow...

ssource

connect a source to the left side...

all 1s

Page 26: CS 189 today

Maximum matching is max flow...

ssource

connect a source to the left side...

make all capacities = 1

1

1

11

1

1

all 1s

Page 27: CS 189 today

Maximum matching is max flow...

ssource

t

sink

connect a source to the left side...

put a sink on the right

make all capacities = 1

1

1

11

1

1

all 1sall 1s

what do the source and sink constraints ensure?

Page 28: CS 189 today

Max flow thought experiment...

ssource

t

sink

1

1

11

1

1

all 1sall 1s

Suppose this is the flow so far (3 units):

Draw what happens in the next step of the max-flow algorithm!how to get from maximal matching to maximum matching…

Page 29: CS 189 today

Max flow thought experiment...

ssource

t

sink

1

1

11

1

1

all 1sall 1s

... the path it finds ...

What's going on here?

Page 30: CS 189 today

Max flow thought experiment...

ssource

t

sink

1

1

11

1

1

all 1sall 1s

Done!

Maximum matching == 4

Page 31: CS 189 today

This week's problems…

dinner

dining

hardware

muddy

feeding

all can be done with maxflow…

Page 32: CS 189 today

The challenge:

is often setting up the graph

Page 33: CS 189 today

Tools

4 44218910100050 1 320 1 3 8 2 3 1 4

TasksHow do we use the results?

What is flowing?

There are four tools available ~ at these costs

hammer

phone

coffee

laptop

There are four tasks available ~ with these rewards

hammer

phone

coffee

PC

4 tools & 4 tasks

each task requires some tools

E4

PHP coding

sleep

coding

hardware

Page 34: CS 189 today

Tools

4 44218910100050 1 320 1 3 8 2 3 1 4

source

Tasks

sink

42

189

10

1000costs

rewards

50

20

8

3

How do we use the results?

What is flowing?

There are four tools available ~ at these costs

hammer

phone

coffee

laptop

There are four tasks available ~ with these rewards

4 tools & 4 tasks

each task requires some tools

hammer

phone

coffee

PC

E4

PHP coding

sleep

coding

hardware

Page 35: CS 189 today

Tools

4 44218910100050 1 320 1 3 8 2 3 1 4

source

Tasks

sink

42

189

10

1000costs

rewards

50

20

8

3

How do we use the results?

What is flowing?

hardwareThere are four tools available ~ at these costs

hammer

phone

coffee

laptop

There are four tasks available ~ with these rewards

4 tools & 4 tasks

each task requires some tools

hammer

phone

coffee

PC

E4

PHP coding

sleep

Netflix

Page 36: CS 189 today

4 54 5 3 53 5 2 6 44 54 5 3 53 5 2 6 30 0

number of teams Input

Output

number of tables

# of people in each team

can an assignment be made without putting teammates together?

10

capacity of each table

again…

end…

35

2 6 4

tables with capacities

teams with sizes

5

34

5

seating assignments!

no teammates

dinner

Page 37: CS 189 today

ssource t

sink

How does maxflow help?

Team

Team

Team

Team

Table

Table

Table

Table

Table

4

3

6

5

2

5

5

3

4

fully connected with edge

weights of 1

How do these edge weights reflect the problem constraints?

dinner

Page 38: CS 189 today

Try max flow!

Page 39: CS 189 today

JRs SRs other

diner 1 diner 1 diner 2

Sophs

diner 1

POM-CMC-SCR-PTZ

diner 1

about 3 about 0 about 1about 1 about 1yearn 2 yearn 0 yearn 1yearn 2 yearn 2

jotto 2 jotto 0 jotto 1jotto 0 jotto 1syrup 1 syrup 2 syrup 1syrup 2 syrup 1

chimp 0 chimp 3 chimp 1chimp 1 chimp 2today 3 today 0 today 2today 1 today 2flags 1 flags 1 flags 0flags 3 flags 0

ships 0 ships 4 ships 1ships 2 ships 1 phish 0 phish 5 phish 1phish 2 phish 1

This term's first class to guess another's word earns 1 problem...This term's last class to have its word guessed earns 1 problem...

gapes 1 ----- gapes 0gapes 4 gapes 1

JRs +1.5POMs +1

aorta 5 ----- aorta 2aorta 1 aorta 1 ---- ----- sepal 0sepal 5 sepal 1

Page 40: CS 189 today

Jotto!

JRs SRs other

diner 1

This term's first class to guess another's word earns 1 problem...

diner 1 diner 2

This term's last class to have its word guessed earns 1 problem...

Sophs

diner 1

POM-CMC-SCR-PTZ

diner 1

about 3 about 0 about 1about 1 about 1yearn 2 yearn 0 yearn 1yearn 2 yearn 2

jotto 2 jotto 0 jotto 1jotto 0 jotto 1

syrup 1 syrup 1 syrup 1syrup 2 syrup 1

Page 41: CS 189 today

Jotto…

Page 42: CS 189 today

This code only looks

obfuscated!

Page 43: CS 189 today

No ideas? Default projects...

goal: to get familiar with a variety of web technologies

Project #1: build a web jotto-player and advisor

demo 1: use HTML, CSS, and CGI forms with Python to choose a random hidden word and score guesses against that hidden word

demo 2: use an SQL database to help analyze the comparative effectiveness of guessing a particular word next, without scoring them all

final demo: use javascript and AJAX (and/or HTML 5 canvas) features to make the interface more slick, as befits the noble game of Jotto!

See https://www.cs.hmc.edu/twiki/bin/view/CS5/WebCS5DevelopmentPagefor some (rough) guidance and sample applications on HMC's webserver...

Page 44: CS 189 today

No ideas? Default projects...

goal: to get familiar with a variety of web technologies

Project #1: build a web jotto-player and advisor

demo 1: use HTML, CSS, and CGI forms with Python to choose a random hidden word and score guesses against that hidden word

demo 2: use an SQL database to help analyze the comparative effectiveness of guessing a particular word next, without scoring them all

final demo: use javascript and AJAX (and/or HTML 5 canvas) features to make the interface more slick, as befits the noble game of Jotto!

Project #2: build a web-based Python autograder

alternative final demo: allow a user to submit a program and get "immediate" feedback as to whether it passed a series of tests or not (time out as necessary to avoid uncomputability...)

impossible final demo: show off your Hyper-Turing quantum computer, since, after all, the autograder problem is uncomputable

Page 45: CS 189 today

http://www.amirrorclear.net/academic/papers/many-forms.pdf http://www.cs.virginia.edu/~robins/The_Limits_of_Quantum_Computers.pdf

HyperTuring computation is easy – just add coffee to your TM!

Hyper-Turing? Quantum computers are not considered likely to extend what's computable – only

how efficiently computations can be done.

Page 46: CS 189 today

Hyper-turing computation?

HyperTuring computation is easy – just add coffee to your TM!

Page 47: CS 189 today

Hyper-turing computation?

HyperTuring computation is easy – just add coffee to your TM!

Page 48: CS 189 today

Survey

JRs SRs Elderly

a word-guessing game similar to mastermind…

diner ?

This term's first class to guess another's word earns 1 point...

diner ? diner ?

This term's last class to have its word guessed earns 1 point...

Sophs

diner ?

Pomona?

diner ?

Other points may be possible...

Get together with same-year classmates...

(1) Choose a jotto word with/for your class

... and jotto, part 1

(2) Have you built software on your own with technologies not typically part of Mudd's curriculum? If not, no problem! If so, great! - please mention a detail or two:

(3) Do you already have a plan (or an idea) for a CS189 project you might want to pursue? If so, what are you considering?

(0) Name: ____________________________

Page 49: CS 189 today
Page 50: CS 189 today

Scores...

JRs SRs Others

diner 3

This term's first class to guess another's word earns 1 point...

diner 1 diner 3

This term's last class to have its word guessed earns 1 point...

Sophs

diner 0

Other points may be possible...

Ideas!

... and jotto:

squid 2 squid 1 squid 1 squid 0 neigh 3 neigh 0 neigh 2 neigh 1

No idea: 8

Web App: 12iPad/iOS: 3

OpenCV: 5

baseball: 1

Android: 2

Audio analysis: 3

576 2319 5761128

211 1076 279323

36 213 142 103

Page 51: CS 189 today