Presentation is loading. Please wait.

Presentation is loading. Please wait.

Decision Mathematics 1 Course Overview.

Similar presentations


Presentation on theme: "Decision Mathematics 1 Course Overview."— Presentation transcript:

1 Decision Mathematics 1 Course Overview

2 What is Decision Maths ? A course on modelling situations that can be solved by the use of Algorithms. We will encounter algorithms that are applied to: Sets of Data ( Sorts, Searches, Packing, Flow diag.) Networks/graphs ( Kruskal, Prim, Dijkstra, …) Standard graphs ( Linear Programming)

3 Who uses this type of Maths ?
People who : Manage people !! Manage projects Manage transportation and delivery Work as Software developers Work as System Analysts Etc ……. !!

4 Language Like all branches of Mathematics Decision Math’s has its own terminology that must be learnt ! Figure Intro 1

5 Key Terms A graph G consists of points (vertices or nodes) which are connected by lines (edges or arcs). A subgraph of G is a graph, each of whose vertices belongs to G and each of whose edges belongs to G. If a graph has a number associated with each edge (usually called its weight) then the graph is called a weighted graph or network. The degree or valency of a vertex is the number of edges incident to it. A vertex is odd (even) if it has odd (even) degree. A path is a finite sequence of edges, such that the end vertex of one edge in the sequence is the start vertex of the next, and in which no vertex appears more then once.

6 A cycle (circuit) is a closed path, ie the end vertex of the last edge is the start vertex of the first edge. A cycle that passes through every vertex of a graph is called a Hamiltonian cycle and a graph in which a Hamiltonian cycle exists is said to be Hamiltonian. Two vertices are connected if there is a path between them. A graph is connected if all its vertices are connected.( Called Kn) If the edges of a graph have a direction associated with them they are known as directed edges and the graph is known as a digraph. A tree is a connected graph with no cycles.

7 A spanning tree of a graph G is a subgraph which includes all the vertices of G and is also a tree.
A minimum spanning tree (MST) is a spanning tree such that the total length of its edges is as small as possible. (This is sometimes called a minimum connector.) A graph in which each of the n vertices is connected to every other vertex is called a complete graph. (The notation Kn will be used for such a graph with n vertices.) A graph that consists of 2 sets of vertices ,X and Y such that Edges only exist between the 2 sets, with not within either set is called Bi-partile. If X contains n vertices, and Y contains m vertices, and all vertices in X are connected to all vertices in Y then we call the graph K n,m A graph G is planar if it can be drawn in a plane in such a way that no two edges meet each other except at a vertex to which they are both incident.

8 Identify a Subgraph of G
Is the graph a) Weighted ? b) A Digraph ? c) Hamiltonian ? d) Planar ? iii) Identify a spanning tree. iv) Can you find a MST ? v) What is the shortest route from C to H ? vi) Can you draw the graph without removing pen from paper, without traveling along any arc more then once.

9 Kruskal’s Algorithm for M.S.T.
The M.S.T. Has a weight of = 61

10 The Syllabus Algorithms Graphs and Networks Algorithms on Graphs
The Route Inspection Problem Critical Path Analysis Linear Programming Matchings Flows in Networks

11 Algorithms Flow Charts Sorting Bin-Packing Full-Bin Combinations
Bubble Sort Quick Sort Bin-Packing Full-Bin Combinations First Fit Algorithm First-Fit Decreasing Algorithm Binary-Search This Chapter is fairly easy overall, however Flow charts can cause some problems. Students Must be very precise in showing the Methods used.

12 U(1) = 6.1, U(2) = 6.9, U(3) = 5.71, U(4) = 4.8, U(5) = 5.3.
Flow Diagrams U(1) = 6.1, U(2) = 6.9, U(3) = 5.71, U(4) = 4.8, U(5) = 5.3. I M Box (1st Question) A Temp Box (2nd Question) Initial conditions 1 - 6.1 1.1 First pass 2 1.9 no yes Second pass 3 0.71 Yes 5.71 0.71 Yes Third Pass 4 0.2 Yes 4.8 0.2 Yes - - 5 0.3 No No Fourth Pass The flow chart finds the value closest to 5 What change would you make so that the Flow diagram finds the Value furthest from 5 ? Reverse the inequality sign in box 4.

13 Sorting Techniques 2 Sorting techniques are required: The Bubble Sort
The Quick Sort The data can be either numeric or Alphanumeric. The bubble sort is easy to program but is not very efficient. The quick sort is much more efficient, but requires more advanced programming techniques. There are many other sorting techniques, which interesting students may like to research !

14 Bubble Sort The bubble sort works by
comparing adjacent values in a list swapping their positions if they are in the wrong order. Repeated passes are made through the list Termination occurs when a pass produces no changes to the order of the list. The first pass should be shown in full, for other passes just show the end states. Sort: into ascending order. 1st Pass 5 6 9 1 7 2nd 3rd 4th 5 6 9 1 7 5 6 9 1 7 Note the 4th pass is required !!! Each pass puts at least one item in its correct place 5 6 1 9 7 5 6 1 7 9

15 Quick sort Algorithm 6 9 16 8 4 12 The Quicksort is completed !!
With N members in a list, we will define the midpoint to be ½ [N+1] (note The notation means [5.5]=6. Step 1: Select the Midpoint of The unsorted data as the pivot Step 2: Write all numbers smaller Than the pivot to the left of it, all Numbers larger to the right. Do not re-order these sublists. Step 3: repeat steps 1 and 2 to the Sublists until each sublist contains Only one member. 6 9 16 8 4 12 6 4 8 9 16 12 4 6 9 12 16 9 12 4 6 8 9 12 16 The Quicksort is completed !!

16 Bin Packing Consider a set of identical bins of a fixed height.
Now consider a set of boxes of varying heights, but with the same x-section as the bins. The objective is to pack the boxes using as few bins as possible. There is no known Algorithm to obtain the optimal solution. There are 3 Algorithms that produce reasonable results. Full bin combinations : Manually try to find such combinations First-fit Algorithm: Taking the boxes in the order listed, place them in the first available space. First-Fit decreasing Algorithm: As above but sorted first.

17 D B I H G E C F A File A B C D E F G H I Size 100 80 160 40 170 200 70
90 File G E C F A I B H D Size 200 170 160 100 90 80 70 40 250 240 230 220 210 200 190 180 170 160 150 140 130 120 110 100 90 80 70 60 50 40 30 20 10 B I D H G E C F A

18 Graphs & Networks Definitions of Terms used modelling situations
Recommend using prepared list with blanks for Students to fill in. Emphasis placed on the importance of learning the terms for future work. modelling situations How we can model real world problems on Graphs. This is not the most exciting of Chapters !!

19 Algorithms on Graphs Minimum Spanning Tree/Minimum Connector
Kruskal’s Algorithm Primm’s Algorithm Directly from a Graph On a Matrix Shortest Path across a Graph Dijkstra’s Algorithm Planar Graphs Planarity Algorithm Straight forwards chapter, Primm on a matrix needs care.

20 Kruskal Algorithm Sort the edges into Ascending order
Select the edge of least weight Include the edge from the unselected edges the edge of least weight so long as it does not form a cycle Repeat step 3 until a spanning tree is formed (the MST) Note: The students must draw a new diagram each time an edge is added to the solution !

21 Prim’s Algorithm Choose a start vertex
Choose the nearest unselected vertex and connect it Choose the vertex from the unselected set that is closest to any of the connected vertices Repeat until all vertices are connected

22 Start with D A is closest: Add edge DA B is closest: Add edge AB C is closest: Add edge AC F is closest: Add edge DF H is closest: Add edge FH G is closest: Add edge HG J is closest: Add edge GI E is closest: Add edge DE

23 Prim´s Algorithm on a Matrix
Select a starting column label this 1: Cross out the relevant row Circle the lowest value in this column and “delete” the other entries in the corresponding row. Label the column with the same letter as the circled values row With the next column label (2 etc…) From the labelled columns circle the lowest value Repeat form 2 until all rows have been “deleted” 3 4 1 5 2 A B C D E F - 8 11 9 4 6 5 10 7 12 3 13 A B D E F C Weight=26

24 Dijkstra’s algorithm This is an algorithm that finds the shortest distance between 2 points on a graph, without the need for complete enumeration. The algorithm is a labelling algorithm. At each iteration one vertex is assigned a final label. The label gives the shortest distance From the start vertex to this point. Each vertex on the graph will be annotated with the following ‘symbol’. Order of labelling Final value Working values 1 - Label start vertex 0, and mark is as the first vertex Update all working values that can be reached from the last labelled vertex (if a working value is already present, then replace if new value is lower). From ALL unlabelled with working values, choose the one with the lowest working value. Label this vertex with this working valu, and record the order of the labelling

25 Find the shortest route from A to K
2 7 9 32 7 32 5 13 13 1 15 8 25 3 11 44 8 44 8 27 25 49 6 15 17 15 10 35 4 10 35 10 7 18 18

26 The route inspection problem A.K.A Chinese postman problem
Before meeting the R.I.P. the course discusses: Traversable Graphs Eulerian Semi-Eulerian Handshaking Theorem Including Corallary “n(odd vertices) is even The route inspection problem/ Algorithm Special cases This Chapter is relatively easy .

27 Eulerian and semi-Eulerian Graphs
Draw the graph without taking the pen from the paper and without traveling more than once along Each arc.

28 If the valencies of the vertices of a graph are all even, then the graph is EULERIAN, and can be
drawn in such a way using any point as the start/stop vertex. If the graph has precisely 2 odd vertices than the graph is SEMI-EULERIAN , one odd vertex is the start point and the other the end point. The previous example was Semi-Eulerian…You needed to start at an odd vertex.

29 The Route inspection problem/ (CPP)
In an undirected network a route of minimum weight has to be found that traverses every Edge at least once, returning to the starting vertex. Obviously if the network is Eulerian then this is immediately possible. If not then the odd vertices have to be paired up in the most economical way, (thus making them even) and a route can then be found. Students need to List all odd vertices List all possible pairings For each pairing find the best way to connect them Choose the pairing set with the least sum. Obtain the route

30 A postman need to walk along all streets, starting an finishing at A, find the minimum walk
Odd vertices: F, I , H , D Possible pairings: F & I + H & D = 59 F & H + I & D = 87 F & D + I & H = 55 Best pairings.

31 19 36 The minimum distance can now be found by adding all weights together + FD & IH an extra time… A suitable route can also be planned. Special Cases In an exam it is possible that students will be given different start and finish nodes. In such questions the Start and finish nodes must be odd, the others even.

32 Critical Path Analysis
Precedence tables Activity Networks Drawing the networks Dummies Analyzing the project (CPA Algorithm) Time Analysis of a network Float Gantt/Cascade Charts Scheduling Concentration required, care must be taken with scheduling

33 Precedence Tables The table indicates the relationships between certain activities involved in the first stage of a manufacturing process. (a) Draw an activity network to show this information.

34 Critical Path Analysis
1 3 2 4 5 6 A(4) B(5) C(2) D(3) E(5) F(4) G(2) I(4) H(3) J(5) K(6)

35 The Critical Path algorithm
The algorithm finds the longest path from the source node to the sink node ( The longest path Is required to ensure that enough time is allowed for the completion of all jobs). The algorithm allows us to identify the activities that are critical, i.e. the ones that must be finished on time to ensure that the project is completed in the allowed time frame. The completed algorithm also simplifies the creation of Cascade / Gant charts. With each event we associate 2 values: Earliest event time ( ei ) The earliest time that an event node can be arrived at such that all incoming activities are completed. Latest event time ( li ) The latest time that an event can be left such that the critical path is not extended. Critical events: early event time = latest event time Critical activities: node M (l) – node N (e) – duration [n,m] = 0

36 Critical Path Analysis
1 3 2 4 5 6 A(4) B(5) C(2) D(3) E(5) F(4) G(2) I(4) H(3) J(5) K(6) 4 4 7 11 18 18 13 13 6 6 10 10

37 Start Finish A 4 B 5 1 6 C 2 D 3 8 7 11 E 9 10 F G 13 H I 14 18 J K 12
Activity Duration Earliest Latest Float A 4 B 5 1 6 C 2 D 3 8 7 11 E 9 10 F G 13 H I 14 18 J K 12 16

38 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 A C F H J B B D D E E G G I I K K

39 How many workers are needed to complete the job in 18 days ??
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 A C F H J B B D D E E G G I I K K

40 Linear Programming Formulating problems
Graphical solutions (2-variable problems) Including Integer solutions Simplex Algorithm Formulating can be tricky, Simplex is fairly in depth procedure.

41 Graphical approach John grows flowers. He buys tulip bulbs for $2 each and rose bulbs for $3. He has $96 to spend. A tulip bulbs requires 30 cm^2 and a rose bulb 20 cm^2, he has an area of 900cm^2. he gets a profit of $1 dollar for each tulip and $1.10 for each rose. How many of each should he buy ? Formulate the problem Let x= no. of tulips bought, y=no. of roses bought x ≥ 0 , y ≥ 0 Financial Constraint 2x + 3y ≤ 96 Space Constraint 30x + 20y ≤ 900 Profit Function: p = 1x + 1.1y

42 Optimal point Feasible region 50 45 45 40 35 30 f ( x ) g ( x ) 25 p (
20 15 Feasible region 10 5 5 10 15 20 25 30 35 40 45 50 x 50

43 A note on Integer solutions
The previous question obviously requires an integer solution. If the optimal point on the graph fails this criteria, we cannot simply round up/down. We need to test the 4 surrounding integer ordered pairs.

44 Simplex Algorithm A clocksmith makes three types of luxury wristwatch. The mechanism or each watch is assembled by hand by a skilled watchmaker and then the complete watch is formed, weatherproofed and packaged for sale by a fitter.The table shows the times, in minutes, for each stage of the process.The watchmaker works for a maximum of 30 hours per week and the fitter for a maximum of 25 hours per week. The profit made on type A, B and C watches is £12, £24 and £20 respectively. Watch type Watchmaker Fitter A 54 60 B 72 36 C 48 Express the data as a series of inequalities and write down the profit function Let x = no. of type A, y=no. type B, z = no. of type C Non-negativity constraints x≥0, y≥0, z≥0 Watchmakers constraint 54x + 72y + 36z ≤ 30 ( 60) Fitters Constraint 60x + 36y + 48z ≤ 25 (60) Profit: P = 12x + 24y + 20z

45 With 3 unknowns a graphical solution is
Impractical Complex Instead the Simplex Algorithm is used. The first job is to transform the problem into standard form. 54x + 72y +36z ≤  x + 4y + 2z ≤ 100 60x + 36y + 48z ≤  x + 3y + 4z ≤ 125 Objective Function: Maximize P = 12x +24y +20z The Problem is now in standard form ( all inequalities ax + by +cz ≤ m ) We can now start with the Simplex Algorithm Next : Add slack variables to turn the inequalities into equations 3x + 4y + 2z + s = 100  3x + 4y + 2z + s +0t = 100 5x + 3y + 4z + t = 125  5x + 3y + 4z +0s + t = 125 And rewrite the profit function ( P –ax – by – cz = 0) P = 12x +24y +20z +0s + 0t  P - 12x - 24y - 20z +0s + 0t = 0

46 We now have: 3x + 4y + 2z + s +0t = 100 5x + 3y + 4z +0s + t = 125 Along with x,y,z,s,t ≥ 0 We have 2 simultaneous equations with 5 unknowns. We observed in the graphical problem that optimal points lie at the “vertices of the feasible region” ( which can be found graphically or by solving The simultaneous equations) We need to solve our simultaneous equations, and valid solutions can be found by Setting 3 of the variables to zero and solving for the remaining variables Note We set [ n(variables) – n(equations) ] variables to zero With 3 initial variables and two bounding inequalities, the max profit will only rely on 2 of the variables {consider a 2d graphing problem with only one boundary  P depends on 1 variable} We actually need to try all possible combinations when setting variables to zero, this would take ages, luckily the Simplex does this in a Greedy Fashion

47 Observe that the current profit it zero
3x + 4y + 2z + s +0t = 100 5x + 3y + 4z +0s + t = 125 We start by setting x, y, z to zero (these are now called Non basic variables). This gives us s = 100 and t =125 ( s and t are now called Basic Variables). Observe that the current profit it zero This information is now stored in a Tableau. Basic variable x y z s t Value 3 4 2 1 100 5 125 P -12 -24 -20 Before starting with the Algorithm, we will first look at the stopping condition ! The optimality condition states that the Objective function is maximised if the objective row of the table is such that 1 Basic variable columns have zero’s in them. 2 Non-basic variable columns have non negative values.

48 Step 1: Find the pivot Choose the most negative value in the objective row, the column it lies in is now called the pivotal column. Divide the entries in the value column by the respective entry in the pivotal Column, these quotients are called the theta values. Choose the smallest +ve theta value, the corresponding row is called the Pivotal row. The pivot is the intersection of the P.C. and P.R. Tableau 1 Basic variable x y z s t Value 3 4 2 1 100 5 125 P -12 -24 -20 4 Pivot row Ө = 100/4 = 25 Ө = 125/3 = 41 2/3 Pivot column The y value is called the entering variable The s value is called the leaving variable

49 Divide the pivot row by the pivot value ( divide by 4 in our example)
Step 2: Make the pivot 1 and use the pivot to obtain zeros in the rest of P.C. Divide the pivot row by the pivot value ( divide by 4 in our example) Add/Subtract a multiple of the pivot row to obtain zero’s in the other entries in the pivot column) (for row (ii):  (ii) – 3(i) for row (iii):  (iii) + 24(i) Note we are really just adding equations !! Tableau 2 Basic variable x y z s t Value 3 4 2 1 100 5 125 P -12 -24 -20 y 3/4 1 (i) 1/2 1/4 25 (ii) 11/4 5/2 -3/4 50 6 -8 6 600 (iii)

50 Condition is satisfied
Step 3: If optimality condition has not been met, find the next pivot go back to step 2 Tableau 2 Basic variable x y z s t Value 1 25 11/4 5/2 -3/4 50 P 6 -8 600 (i) Ө = 25/(1/2) = 50 5/2 Pivot row (ii) Ө = 50/(5/2) = 20 (iii) Pivot column New row (ii) = old (ii) / (5/2) New row (i) = old (i) – (1/2) (new row(ii)) New row (iii) = old (iii) + 8 (new row (ii)) Basic variable x y z s t Value 1/5 1 2/5 -1/5 15 11/10 -3/10 20 P 74/5 18/5 16/5 760 The Optimality Condition is satisfied

51 We can now read the solution from the tableau:
Basic variable x y z s t Value 1/5 1 2/5 -1/5 15 11/10 -3/10 20 P 74/5 18/5 16/5 760 We can now read the solution from the tableau: y =15 : z = 20 : x = s = t = 0 Max profit = 760 Note: There is 0 slack in either inequality in this example This is not always the case !

52 Question 1 A craft worker makes three types of wooden animals for sale in wildlife parks. Each animal has to be carved and then sanded. Each Lion takes 2 hours to carve and 25 minutes to sand. Each Giraffe takes 2 ½ hours to carve and 20 minutes to sand. Each Elephant takes 1 ½ hours to carve and 30 mins to sand Each day the craftworker wishes to spend at most 8 hours carving and at most 2 hours sanding. Let x be the number of Lions, y the number of Giraffes and z the number of Elephants he produces each day. The craftworker makes a profit of £14 on each Lion, £12 on each Giraffe and £13 on each Elephant. He wishes to maximise his profit, P. Model this as a Linear Programming problem, simplifying your expressions so that they have integer coefficients. Use the Simplex algorithm to solve this problem.

53 Basic variable Value P Basic variable Value P

54 Matchings Modelling using a bi-partile graph Maximal Matchings
Matching improvement /alternating path algorithm This Chapter very easy

55 Matchings Mr Andrews P1, P2, M1 Miss Baker P1, M1 Mrs Claire P1,P2,P3
Consider a Maths department with the following teachers: Mr Andrews P1, P2, M1 Miss Baker P1, M1 Mrs Claire P1,P2,P3 Mr Dale M1,M3 Miss Eves M2,M3 Mrs Frank P3,M3 Now suppose that each module requires one teacher, And each teacher will only teach one module. Who will teach what ?? We can represent this data on a Bi-partile graph. A B C D E F P1 P3 M2 M1 P2 M3 This is typical of the type of problem solved within this topic.

56 A B C D E F P1 P3 M2 M1 P2 M3 A matching is defined as a subset of the edges, such that no 2 edges share a common vertex. For instance: A P1 A P1 A P1 B B B P2 P2 P2 C P3 C C P3 P3 D M1 D D M1 M1 E M2 E E M2 M2 F M3 F M3 F M3

57 A Maximal Matching is one in which the number of edges is as large as possible
A Complete Matching is one in which all vertices have a partner !! We can use the alternating path algorithm to find a maximal matching. Start with a non trivial matching Find an alternating path which links an unmatched vertex from each set……(write BREAKTHROUGH) Change the status of the path Stop when no further alternating paths can be found. A B C D E F P1 P3 M2 M1 P2 M3 A P1 B P2 C P3 Start with: D M1 E M2 F M3

58 A P1 Another alternating path B P2 F – P3 = C – P2 ……Breakthrough Change the status F = P3 – C = P2 C P3 D M1 A P1 E M2 B P2 F M3 C P3 D An alternating path M1 D – M3 = E – M ………Breakthrough Change the status D = M3 – E =M2 E M2 F M3 No more alternating paths…We have the Maximal Matching. It is in fact a Complete Matching. A P1 A P1 B P2 B C P2 P3 C D P3 M1 D E M1 M2 E M2 F M3 F M3

59 Flows in Networks Sources, Sinks and Flows The labelling procedure
Flow augmenting paths and back flows Max cut/ Min flow Multiple source/sinks Back flows and Min cut can cause confusion

60 source/sink must be added.
The object is to determine the maximum flow across a network, from the (S) Source to the (T) Sink. The source is identified as being the node with only outgoing arcs, the sink has only ingoing arcs. If more than one of either exist then an extra source/sink called a super source/sink must be added. When the flow along an arc is equal to the capacity of the arc then the arc is saturated, Otherwise it is unsaturated. We also use the constraint that what flows into an arc, must flow out !! 4 12 9 6 3 S T 5 7 8 10 4

61 The first task is to draw a new diagram using the labelling procedure.
Instead of showing the current flow and actual capacity of each arc, we replace This information with Excess capacity A B Flow (back capacity) 12 4 S A S A 8 4 Becomes We then Find an initial flow Find flow augmenting paths using the labelling procedure Check the flow is maximal by using the min cut/max flow algorithm Lets consider an example

62 Use the labelling procedure to find the maximum flow from the
Source to the Sink. 4 4 12 9 4 4 6 3 5 5 5 5 7 8 5 10 4

63 4 5 4 9 8 12 6 4 3 4 5 5 5 5 7 8 5 5 10 4

64 A D 5 4 6 4 8 3 C 4 S T 5 2 5 5 3 5 5 4 E B

65 Flow augmenting Paths SACDT: 3 SBET: 2 SACBET: 2 A D 5 2 4 5 3 6 4 3 5 3 7 3 8 1 3 9 C 7 4 S T 5 7 9 2 5 5 5 3 7 3 1 5 3 4 2 5 4 2 E B

66 And use the min cut/ max flow algorithm.
4 D 9 7 5 3 C S T 3 9 5 7 4 E B We have a flow of 16, to test whether this is the max flow, consider the original diagram And use the min cut/ max flow algorithm.

67 The Exam 7 /8 Questions Answered in a GCSE style booklet.
Students have to be able to work fast, can be a long exam. General advice: approx 1 mark per minute, detailed solutions are required, bulleted points can be used.

68 Short/ Medium length Questions
A fairly typical paper would contain the following questions ( Some of the not so common algorithms do make the occasional appearance !) Short/ Medium length Questions A Sort followed by either bin packing or a binary Search: Normally very easy Matchings : Alternating path Algorithm. Solution Clarity vital: very easy MST: Kruskal or Prim. Very Easy Flow chart: Needs to be answered systematically, can be tricky. Longer Questions Flows in networks: Time consuming and can be complex Linear programming: Formulating problem then either Graph or Simplex: Can be complex Critical Path Analysis: Dummies/ Finding Path/ Gant/Scheduling: can be complex Dijkstra’s Algorithm: Straight forwards R.I.P./ Chinese postman problem: Straight forwards.

69

70


Download ppt "Decision Mathematics 1 Course Overview."

Similar presentations


Ads by Google