1 / 51

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 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.

Download Presentation

CS 189 today

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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 I'll meet with our teams… 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

  2. Jotto! POM-CMC-SCR-PTZ Sophs JRs SRs other diner 1 diner 1 diner 1 diner 1 diner 2 about 1 about 3 about 0 about 1 about 1 yearn 2 yearn 2 yearn 0 yearn 2 yearn 1 jotto 0 jotto 2 jotto 0 jotto 1 jotto 1 syrup 2 syrup 1 syrup 1 syrup 1 syrup 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...

  3. Projects? Alums:What do you feel you didn't get @ HMC CS? Moira Tagle Josh Ehrlich Paul Scott Josh Klontz Karen Gragg Will Scott

  4. Answers… Alums:What do you feel you didn't get @ HMC CS? web things parallelizing/distributing large computations the code check-in process don't try to teach web stuff Moira Tagle Josh Ehrlich Paul Scott Josh Klontz web technologies (at least for terminology...) web frameworks cmake and build systems Karen Gragg Will Scott

  5. 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?

  6. 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 (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: that might be one of your answers to the question, What do you feel you didn't learn @ HMC?

  7. 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 hardware project requiring programming framework, e.g., web framework (Django et al.) OpenCV Qt other UI library game dev. library console library? web basics: HTML/CSS/Javascript/JQuery "Minecraft" technology? something you've wanted to do but you wouldn't otherwise get to en.wikipedia.org/wiki/ Comparison_of_web_ application_frameworks that might be one of your answers to the question, What do you feel you didn't learn @ HMC?

  8. 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

  9. Drawbacks? Benefits? • it never hurts to have an on-line portfolio of one or more of your projects... • specific technologies should be avoided in the CS curriculum I agree. Yet this one-unit course is too small to shift that balance... John Grasel, Cris Cecka • curricular support vs. expertise support • there's not enough support to make it work • helps the limitations of DWIC letters, because it's unique + personalized True! I'm no expert at what you're working on, but here the goal's not expertise, but the "working on" … "did well in class" • sometimes the benefits don't outweigh the drawbacks • too much time is required…! 3 good-faith hours per week + write-up == 12 problems one unit!

  10. Interested? To do by 11/12: project proposal due 2-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…

  11. PHP'sWAT! php –a php > $x = "209"; php > $x++; php > print( $x ); print( "\n" ); 210

  12. PHP'sWAT! php –a 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 Now, let's try it with… $x = "2d9";

  13. Max Flow ! 12 B D 20 16 sink or target t s 10 4 9 7 source 4 13 C E 14 capacity What's the maximum flow possible, from src to sink? Ford-Fulkerson algorithm

  14. TO - 16 13 - - - - - 10 12 - - - 4 - - 14 - - - 9 - - 20 - - - 7 - 4 - - - - - - Max Flow Capacity Graph s B C D E t s B (Step #1)Use depth- or breadth-first search to find any path from s to t. C FROM D E 12 B D t 20 16 sink t s 10 4 9 7 source 4 13 C E 14 What's left ?

  15. - - 16 4 13 13 - - - - - - - 12 - - 10 10 12 0 - - - - - - 4 4 - - - - 14 14 - - - - 12 - 9 9 - - - - 8 20 - - - - - - 7 7 - - 4 4 - - - - - - - 12 - - - - Max Flow s B C D E t s B (Step #2)Compute RESIDUAL graph C D E 0/12 B D t 8/20 12 4/16 sink 12 12 t s 10 4 9 7 source 4 13 C E 14 s B C D E t What's left… s Residual capacities. B C D and the red edges? E Backwards capacities! t

  16. - - 4 16 13 13 - - - - - - - 12 - - 10 10 12 0 - - - - - - 4 4 - - - - 14 14 - - - - 12 - 9 9 - - - - 8 20 - - - - - - 7 7 - - 4 4 - - - - - - - 12 - - - - Max Flow s B C D E t s B (Step #3)Repeat until no path exists… C D E 0 B D t 8 12 4 sink 12 12 t s 10 4 9 7 source 4 13 C E 14 s B C D E t Residual capacities. s Backwards capacities. B C D E t

  17. Max Flow (Step #1)Use depth- or breadth-first search to find any path from s to t. 12/12 B D 19/20 11/16 sink s t 0/10 1/4 0/9 7/7 source 4/4 12/13 C E 11/14 (Step #2)Compute RESIDUAL graph max flow:23 (Step #3)Repeat until no path exists…

  18. 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…

  19. Python… edmonds_karp algorithm defmax_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] whileTrue: 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 inrange(n)]) # out from source

  20. Python… defBFS(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 inrange(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 notin paths: paths[v] = paths[u] + [(u,v)] if v == sink: return paths[v] queue.append(v) # go from v in the future returnNone

  21. Is maxflow good for anything else? that is, beyond solving maximum-flow problems...

  22. Matching! and some acceptable possibilities ... we have four brides and six grooms a bipartite graph

  23. Matching! and some acceptable possibilities ... we have four brides and six grooms a maximal matching == no more matchings without rearrangement

  24. Matching! and some acceptable possibilities ... we have four brides and six grooms a maximum matching == no rearrangements will yield more matchings

  25. Maximum matching is max flow... connect a source to the left side... all 1s s source

  26. Maximum matching is max flow... connect a source to the left side... make all capacities = 1 1 1 all 1s 1 1 s source 1 1

  27. Maximum matching is max flow... connect a source to the left side... make all capacities = 1 put a sink on the right 1 1 all 1s all 1s 1 sink 1 s t source 1 1 what do the source and sink constraints ensure?

  28. Max flow thought experiment... Suppose this is the flow so far (3 units): 1 1 all 1s all 1s 1 sink 1 s t source 1 1 Draw what happens in the next step of the max-flow algorithm! how to get from maximal matching to maximum matching…

  29. Max flow thought experiment... ... the path it finds ... 1 1 all 1s all 1s 1 sink 1 s t source 1 1 What's going on here?

  30. Max flow thought experiment... Done! 1 1 all 1s all 1s 1 sink 1 s t source 1 1 Maximum matching == 4

  31. This week's problems… dinner dining hardware muddy feeding all can be done with maxflow…

  32. The challenge: is often setting up the graph

  33. 4 tools & 4 tasks 4 4 42 189 10 1000 501 3 201 3 8 2 3 1 4 hardware hammer There are four toolsavailable ~ at these costs phone coffee laptop E4 each taskrequires some tools hammer PHP coding phone There are four tasksavailable ~ with these rewards sleep coffee PC coding What is flowing? Tools Tasks How do we use the results?

  34. 4 tools & 4 tasks 4 4 42 189 10 1000 501 3 201 3 8 2 3 1 4 hardware hammer There are four toolsavailable ~ at these costs phone coffee laptop E4 each taskrequires some tools hammer 50 42 20 PHP coding phone 189 There are four tasksavailable ~ with these rewards sink 8 source 10 sleep coffee 3 1000 rewards costs PC coding What is flowing? Tools Tasks How do we use the results?

  35. 4 tools & 4 tasks 4 4 42 189 10 1000 501 3 201 3 8 2 3 1 4 hardware hammer There are four toolsavailable ~ at these costs phone coffee laptop  E4 each taskrequires some tools hammer  50 42  20 PHP coding phone  189 There are four tasksavailable ~ with these rewards sink 8 source 10  sleep coffee 3 1000 rewards costs  PC Netflix What is flowing? Tools Tasks How do we use the results?

  36. Input dinner number of teams number of tables # of people in each team 4 5 4 5 3 5 3 5 2 6 4 4 5 4 5 3 5 3 5 2 6 3 0 0 Output 1 0 capacity of each table again… can an assignment be made without putting teammates together? end… tables with capacities 3 5 teams with sizes seating assignments! 4 3 no teammates 6 5 4 2 5

  37. dinner How do these edge weights reflect the problem constraints? Table Team 2 4 5 Table 3 Team 6 s sink Table 5 fully connected with edge weights of 1 t source Team 3 Table 5 4 Team Table How does maxflow help?

  38. Try max flow!

  39. 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... JRs +1.5 POMs +1 POM-CMC-SCR-PTZ Sophs JRs SRs other diner 1 diner 1 diner 1 diner 1 diner 2 about 1 about 3 about 0 about 1 about 1 yearn 2 yearn 2 yearn 0 yearn 2 yearn 1 jotto 0 jotto 2 jotto 0 jotto 1 jotto 1 syrup 2 syrup 1 syrup 2 syrup 1 syrup 1 chimp 1 chimp 0 chimp 3 chimp 2 chimp 1 today 1 today 3 today 0 today 2 today 2 flags 3 flags 1 flags 1 flags 0 flags 0 ships 2 ships 0 ships 4 ships 1 ships 1 phish 2 phish 0 phish 5 phish 1 phish 1 gapes 4 gapes 1 ----- gapes 1 gapes 0 aorta 1 aorta 5 ----- aorta 1 aorta 2 sepal 5 ---- ----- sepal 1 sepal 0

  40. Jotto! POM-CMC-SCR-PTZ Sophs JRs SRs other diner 1 diner 1 diner 1 diner 1 diner 2 about 1 about 3 about 0 about 1 about 1 yearn 2 yearn 2 yearn 0 yearn 2 yearn 1 jotto 0 jotto 2 jotto 0 jotto 1 jotto 1 syrup 2 syrup 1 syrup 1 syrup 1 syrup 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...

  41. Jotto…

  42. This code only looks obfuscated!

  43. 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/WebCS5DevelopmentPage for some (rough) guidance and sample applications on HMC's webserver...

  44. 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 impossible final demo: show off your Hyper-Turing quantum computer, since, after all, the autograder problem is uncomputable 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...)

  45. Hyper-Turing? Quantum computers are not considered likely to extend what's computable – only how efficiently computations can be done. HyperTuring computation is easy – just add coffee to your TM! http://www.amirrorclear.net/academic/papers/many-forms.pdf http://www.cs.virginia.edu/~robins/The_Limits_of_Quantum_Computers.pdf

  46. Hyper-turing computation? HyperTuring computation is easy – just add coffee to your TM!

  47. Hyper-turing computation? HyperTuring computation is easy – just add coffee to your TM!

  48. Survey Get together with same-year classmates... (0) Name: ____________________________ (1) Choose a jotto word with/for your class (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? ... and jotto, part 1 a word-guessing game similar to mastermind… Sophs JRs SRs Elderly Pomona? diner ? diner ? diner ? diner ? diner ? This term's first class to guess another's word earns 1 point... This term's last class to have its word guessed earns 1 point... Other points may be possible...

  49. Scores... Ideas! baseball: 1 Web App: 12 iPad/iOS: 3 Android: 2 OpenCV: 5 Audio analysis: 3 No idea: 8 ... and jotto: Sophs JRs SRs Others diner 0 diner 3 diner 1 diner 3 1128 576 2319 576 squid 0 squid 2 squid 1 squid 1 323 211 1076 279 neigh 1 neigh 3 neigh 0 neigh 2 103 36 213 142 This term's first class to guess another's word earns 1 point... This term's last class to have its word guessed earns 1 point... Other points may be possible...

More Related