dynamicprogramming-assemblyline

Upload: tufail-khan

Post on 03-Jun-2018

229 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 DynamicProgramming-AssemblyLine

    1/4

    Dynamic Programming (Ch. III.15)

    Example 1: Assembly Line Sche !ling (Ch. 15.1)

    "i#en:two assembly lines, line 1 and line 2, with line index i $ 1%& each assembly line has n stations, with station index '$1% % n ; Example n=6, with j=1,2,,6;station j, on either line, er!orms the same tas" jtime !or er!ormin# tas" j on line i is a i%';$xam le% s 2,& is the time !or er!ormin# tas" & on line 2.'! co rse the times !or er!ormin# tas" j on di!!erent lines may be di!!erent, i.e. in #eneral s 1,j s 2,jtime !or enterin# assembly line i is e i;time !or enterin# assembly line i is xi;a!ter the com letion o! any tas" j on a #i*en line, it is ossible to contin e the assembly on the other line; o! co rse the artneeds to #et to the other line, th s it will re+ ire some trans!er time;let s denote with i%' the time !or trans!errin# a art a!ter com letion o! tas" j on line i to the other line.$xam le% t 2,&is the trans!er time !rom line 2 a!ter er!ormin# tas" &.

    *in : -he se+ ence o! stations !rom lines 1 and 2 !or which the assembly line time is minimal

    Brute Force: $n merate all ossible s bstation sets. n!ort nately there are 2 n s bsets o! a set o! n elements. -h s the roblem has a oisono s +(& n) time.

    Main Idea for Solution: /or each line trac" the !astest time !or er!ormin# all tas"s to and incl din# tas" j, with tas" j com leted on this line; 0lon#the way record the stations assed on the !astest assembly ro te.hen this is done !or all tas"s, incl din# tas" n and the corres ondin# exit time, the smallest time !or !inishin# tas" n on a#i*en line is the o timal sol tion;

  • 8/12/2019 DynamicProgramming-AssemblyLine

    2/4

    ac"trac" to !ind the station se+ ence sed in the o timal sol tion. Illustration on the Example in Figure 1 and Generalization with the help of Figure 2 Figures 1!"2 and 1!"1 in #$%S&:

    3et !ind the !astest way !or com letin# tas"s 1, 2,, j on line 1, and line 2.3et s denote with , 1-' the !astest time !or com letin# tas" j on line 1, and similarly with

    , &-' the !astest time !or com letin# tas" j on line 2-here is little choice at the be#innin#%

    ! 141 = e 1 a 1,1 = 2 7 = 8! 241 = e 2 a 2,1 = 9 : = 12

    t !or com letin# the second tas" we can either ta"e the rod ct !rom line 1, or !rom line 2 and trans!er it to line 1. -he !astest timeis the smaller o! the two ossibilities%

    !astest way o! com letin# tas" 1 on line 1 a 1,1 = ! 141 a 1,1 = 8 8 = 1/! 142 = min = 1:!astest way o! com letin# tas" 1 on line 2 trans!er time a 1,1 = ! 241 t 2,1 a 1,1 = 12 2 8=21

    i.e. the !astest time to com lete tas" 1 on line 1 is

    ! 142 = 1: and to achie*e this the re*io s tas", here tas" 1, was com leted on line 1.

    e need to remember where the re*io s tas" was com leted in order to trace bac" the station se+ ence on the !astest way.3et s l1-' denote the line n mber on the !astest way ! 14j at which the re*io s tas", i.e. tas" j 1, was er!ormed.

  • 8/12/2019 DynamicProgramming-AssemblyLine

    3/4

  • 8/12/2019 DynamicProgramming-AssemblyLine

    4/4

    -he ! i4j and l i4j tables below ill strates the times !or the exam le in /i# re 10t each ste in the ! i4j the minim m *al e and the l i4j are bold and nderlined.

    -he !astest way !or com letin# all tas"s and exitin# the assembly is denoted by ,4 and the exit line with l4

    i > j 1 2 & 9 5 6 exit, 1-' 1% 2 7 = 1: 8 8 = 1/

    2% 12 2 8 = 211% 1: & = 21&: 16 1 & = &6

    1: 2? 9 = &72% 22 2 9 = 2:

    1% 29 : = 8&2% 25 2 : = &5

    1% &2 9 = &6&% &? 1 9 = 85

    &5 & = 8/ ,4% l4$1

    , &-' 2% 9 : = 1& 2% 12 5 = 171: 8 2 5 = 13

    &: 16 6 = &&1% 1: & 6 = 27

    2% 22 9 = 261: 2? 1 9 = &5

    &% 25 5 = 861% 29 & 5 = &2

    &% &? 7 = 891% &2 9 7 = 9&

    &7 2 == &8

    i > j 2 & 9 5 6l1-' 1 2 1 1 & l4$1l&-' 1 2 1 & 2

    @rint tations(1,n)i = lA

    rint(Bline iB, BstationB n)!or j = n downto 2 i = l i4j rint(Bline iB, BstationB j 1)

    i j o t t1 = lA line 1, station 6(i = l i4j ) 62 line 2, station 5

    52 line 2, station 9

    91 line 1, station &

    &2 line 2, station 2

    22 line 2, station 1