Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computability Reports. More examples. Homework: Optimization. Other follow- ups. Start to plan presentation.

Similar presentations


Presentation on theme: "Computability Reports. More examples. Homework: Optimization. Other follow- ups. Start to plan presentation."— Presentation transcript:

1 Computability Reports. More examples. Homework: Optimization. Other follow- ups. Start to plan presentation.

2 Reports FYK algorithm Other shuffles Other searches.

3 Overview Describe certain problems –what are the critical metrics? –general description You MAY investigate for topic for your presentation –Note: computability topics also okay

4 Minimal spanning tree Consider a directed weighted graph: vertices and edges, with weights for the edges. Find (a) tree: a subset of all the edges that connects all the vertices, no cycles, and has minimal total weight. Many solutions –O(e* log(e)) where e is number of edges. Trying everything is e!

5 Kruskal's algorithm Class of algorithms called greedy: does the immediate best thing. sort the edges in order of weights start off with each vertex in a partition by itself. The idea is to produce a partition containing all the vertices. –partition represented by a list of its vertices. There also is a list of vertices with a name/representative of its current partition. –add edges, next smallest first, say V to W check if V and W in same partition. If so, don't add edge. If different partitions, combine those two stop when new partition has all the vertices http://www.unf.edu/~wkloster/foundations/KruskalApplet/ KruskalApplet.htmhttp://www.unf.edu/~wkloster/foundations/KruskalApplet/ KruskalApplet.htm

6 Path finding Find possible, shortest, cheapest path from a starting point to an end point in place with obstacles. –May or may not know address (coordinates of end point) –Problem represented using map and/or graph –Specific case: Traveling Salesman's problem Two forms: find shortest route hitting all stops (cities) on a list Find a route shorter than distance L.

7 Algorithms See A*: http://www.policyalmanac.org/games/aStarTutori al.htm http://www.policyalmanac.org/games/aStarTutori al.htm Research map / direction programs. Very general case: find path of robot through crowded workspace –Space is more than 3D: robot has position and orientation

8 Optimization problem General description A situation involves picking a set (vector) of values, x 1, x 2, …, x n There are constraints (specified as inequalities or equalities) and there is a single objective function: something to minimize or maximize. What is the set of x's that satisfy constraints AND yield the best objective function? If constraints and objective function linear equations, then this is linear programming problem.

9 Example Let's suppose that a merry farmer has 75 roods (4 roods = 1 acre) on which to plant two crops: wheat and corn. To produce these crops, it costs the farmer (for seed, water, fertilizer, etc. ) $120 per rood for the wheat, and $210 per rood for the corn. The farmer has $15,000 available for expenses, but after the harvest the farmer must store the crops while awaiting favorable or good market conditions. The farmer has storage space for 4,000 bushels. Each rood yields an average of 110 bushels of wheat or 30 bushels of corn. If the net profit per bushel of wheat (after all the expenses) is $1.30 and for corn is $2.00, how should the merry farmer plant the 75 roods to maximize profit?

10 Farmer example, cont. Constraints: –120x + 210y <= 15000 expenses –110x + 307 <= 4000 storage –x+y <=75 space Objective function is Profit =(110)(1.3)x + (30)(2)y = 143x + 60y See http://www.matrixlab- examples.com/linear-programming.htmlhttp://www.matrixlab- examples.com/linear-programming.html

11 Aside General remark on decisions in life: –can be useful to distinguish constraints from objective function. –For best results in mathematical/formal terms, need to focus on one objective function. –May not be guaranteed best answer, but perhaps a pretty good one. –???

12 Encoding: compression How to take a data set and compress it in order to store or transmit. Then decompress Methods are –lossless: get back to original Examples: zipped files –lossy: don't get back to original, but good enough Example: jpg, others.

13 Huffman encoding Consider a text made up of symbols or words. Initially, all symbols take the same amount of space. All words depend on their length. But what if certain symbols are much more common? Say the letter e. What if certain words are much more common, say the? Approach: use small(er) number of bits for e and progressively more for other symbols. Do similar thing for words. Complexity O(n*log(n)) Alternative: use a common list of frequent symbols/words and encode accordingly. That is, assume the is most common.

14 Run length encoding Consider a picture (best to NOT think of photograph) Instead of storing w * h pixels, consider row by row and store run information: n pixels of the name color gets stored as (row,color,start,n)

15 Vector images Consider again an image, say constructed using Flash or Illustrator. Previous picture stored as –background: aqua rectangle (w * h) –smaller green circle at center x,y, radius r –rectangle at top x, top y, bottom x, bottom y You can do experiment of comparing bitmapped images with rasterized/vectorized.

16 Media formats Images: jpg,png, bmp Audio –music mpg3 –speech ? Video

17 Graphs Existence of path from node a to node b in a directed graph PATH = { |G is a directed graph that has a directed path from s to t} Proof: Don't just do brute-force seach starting from s and trying all edges. Instead, 1) Mark node s. 2) Consider list of edges. If an edge (a,b) is from a marked node to an unmarked node, mark b. Were any new nodes marked? If no, stop. If yes, repeat. 3) If t is marked, there is a path.

18 Analysis of algorithm Size of problem is m = number of edges. Step 2 happens at most m times. Each step 2 takes at most m operations. So adding in constant for start and at most m for scanning to see if t is in the marked set, this is O(n 2 ).

19 Hierarchy constant O(log(n)) linear O(n) polynomial, strictly highest term O(n p ) exponential, O(2 n ) factorial, O(n!)

20 Homework/preview Follow up on topics Formulate a real-life problem that you are willing to share in optimization terms. Preview: will now define the class P and the class NP.


Download ppt "Computability Reports. More examples. Homework: Optimization. Other follow- ups. Start to plan presentation."

Similar presentations


Ads by Google