ielm 231: it for logistics and manufacturing

32
ELM 231: IT for Logistics and Manufacturing Course Agenda Introduction IT applications design: Human-Computer Interface Fundamental IT tools: sorting, searching The Client-Server architecture, Interacting applicatio IT in logistics, Case study 1: web-based auctions IT in logistics, Case study 2: web-search How auctions work Web issues: session tracking Web issues: secure communications Web issues: cash transactions Search robots Data processing, Data storage/retrieval (DB, ind Data presentation: page ranking techniques

Upload: kamala

Post on 01-Feb-2016

35 views

Category:

Documents


0 download

DESCRIPTION

IELM 231: IT for Logistics and Manufacturing. Course Agenda. Introduction. IT applications design: Human-Computer Interface. Fundamental IT tools: sorting, searching. The Client-Server architecture, Interacting applications. IT in logistics, Case study 1: web-based auctions. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: IELM 231: IT for Logistics and Manufacturing

IELM 231: IT for Logistics and Manufacturing

Course Agenda

Introduction

IT applications design: Human-Computer Interface

Fundamental IT tools: sorting, searching

The Client-Server architecture, Interacting applications

IT in logistics, Case study 1: web-based auctions

IT in logistics, Case study 2: web-search

How auctions workWeb issues: session trackingWeb issues: secure communicationsWeb issues: cash transactions

Search robotsData processing, Data storage/retrieval (DB, indexes)Data presentation: page ranking techniques

Page 2: IELM 231: IT for Logistics and Manufacturing

Examples of Sorting

Google, Yahoo, … - User inputs search word(s) - Search engine finds many web-pages containing the search word(s) - Search engine determines relative importance rating (IR) for each page - Search engine presents the links to pages, ordered by decreasing IR

sort

Job scheduling - T-shirt manufacturer must produce 100 different shirt types in next month - Production manager ranks the jobs using some heuristic, e.g.

EDD: Earliest due date do the job with earliest due date firstSPT: Do the job with minimum expected time to complete first

- Manager sorts the 100 jobs according to heuristic, makes schedule

sort

Page 3: IELM 231: IT for Logistics and Manufacturing

Examples of Searching.

Windows - Search for a file of given name in the C: drive - Search for a computer with given IP address in a network

search

Page 4: IELM 231: IT for Logistics and Manufacturing

Examples of Searching..

Electric Power Supply for Show @ WanChai

Lamma

Power Station

WanC

haiNorthPoint

RepulseBay

Aberdeen

PokFuLam

WesternCentral

HappyValley

30

50

40

2020

2020

10 20

5

40

15 15

4025

1520

Lines in graph show maximum available capacity of wiresWhat is the maximum power that can be sent from Power station in Lammato Wan Chai sub-station ?

Page 5: IELM 231: IT for Logistics and Manufacturing

Examples of Searching…

Graph shows maximum daily capacity (no. of train bogeys) along railway routes

Detroit

Kansas City

Minneapolis

San Francisco

Boise

Phoenix

8

14

146

12

10

10

7

17

6

Detroit

Kansas City

Minneapolis

San Francisco

Boise

Phoenix

8

14

146

12

10

10

7

17

6

What is the maximum daily volume we can transport from Detroit to San Fran?

Page 6: IELM 231: IT for Logistics and Manufacturing

A simple sorting method: Bubble Sort

Input: a list of unsorted numbersOutput: the numbers sorted in increasing order

Easy extensions:words/names instead of numberssort in decreasing order

Main idea of bubble sort for n number

Push the largest to the right (n-th position): - Go from left to right - For each pair, if the two numbers are [larger, smaller], swap them

// only (n-1) numbers remain to be sorted (why?)

- In the remaining unsorted list, push the largest to the right (repeat this until there are no more swaps).

Page 7: IELM 231: IT for Logistics and Manufacturing

A simple sorting method: Bubble Sort..

Bubble sort example

The first pass

23 12 34 14 1 2

12 23 34 14 1 2

Sort:

12 23 34 14 1 2

12 23 14 34 1 2

12 23 14 1 34 2

12 23 14 1 2 34

The 2nd pass 12 23 14 1 2 34

12 14 23 1 2 34

12 14 1 23 2 34

12 14 1 2 23 34

After 3rd pass 12 1 2 14 23 34

After 4th pass

1 2 12 14 23 34

5th pass: no swaps done!

1 2 12 14 23 34

Page 8: IELM 231: IT for Logistics and Manufacturing

A simple sorting method: Bubble Sort…

Algorithm Bubble sort( input: array A of number)

n = number of elements in Arepeat

flag = falsefor counter = 1 to n-1 do

if A[counter] > A[counter+1] thenswap( A[counter], A[counter+1])set flag = true

end ifend for

n = n-1until (flag = false) or (n=1)

Page 9: IELM 231: IT for Logistics and Manufacturing

Improved Bubble Sort: Comb sort

Problem with bubble sort:small numbers at the end of list take many steps to move to the front

Main idea of comb sort:Initially, instead of comparing neighboring elements (gap = 1),compare numbers at larger distance

Slowly reduce the gap of comparison

When gap reduces to 1, and no more swaps, sorting is done

Page 10: IELM 231: IT for Logistics and Manufacturing

Improved Bubble Sort: Comb sort..

Algorithm Combsort( input array A of numbers)

gap = A.lengthrepeat

//update the gap value for a next combif gap > 1

gap = gap / 1.3end ifi = 0flag = falserepeat

if A[i] > A[i+gap]swap( A[i], A[i+gap])flag = true

end ifi = i + 1

until i + gap >= A.lengthuntil gap = 1 and flag = false

onecomb(pass)

start with large gap, to push small numbers on right side quickly to the left;

reduce the gap after each pass

Page 11: IELM 231: IT for Logistics and Manufacturing

Searching: definitions.

Search: Looking for optimal solutions to discrete problems

Terminology:

Discrete problem there are countable (though possibly infinite) feasible solutions

Search space the set of all feasible [partial] solutions

There are several variables; for each variable, there are several possible values

A solution: assign a value to each of the variables

A solution may be: infeasible or feasible

A feasible solution may be: optimal or not optimal.

Page 12: IELM 231: IT for Logistics and Manufacturing

Exhaustive searches: modeling

Search: Looking for optimal solutions to discrete problems

Exhaustive search:

- List all values for one variable ( discrete!)- For the selected value, list all possible values of the next variable- …etc.

Common exhaustive search methods:

- Depth first- Breadth first- Best first

Common method to model search space: GraphEach node a decision (e.g. a value of a variable)Each arc next possible decision after making some choice

Page 13: IELM 231: IT for Logistics and Manufacturing

Search example: the n-Queens problem

Place N queens on an NxN chess board such that no Queen attacks any other

QQ

Q

QQ

Q

Example: partial solution of an 8-queens problem(only 3 queens have been placed yet)

Page 14: IELM 231: IT for Logistics and Manufacturing

Search methods: terminology

We will restrict to search over a Graph, G

Zero or more node(s) of the graph are the Target, or GOAL

Search starts at some node, S

Each step, we ‘exploring’ the graph a little more:(i) Select some node we have reached before(ii) Check which other nodes we can directly go from it (Expand it)

We maintain two lists: CLOSED = Set of nodes that

(i) the search has reached,(ii) are not the GOAL node(ii) explored one step beyond

OPEN = Set of nodes that(i) the search has reached, but not yet explored

Page 15: IELM 231: IT for Logistics and Manufacturing

Depth first search: Last In First Out (LIFO)

INPUTS: Graph G, MAX-DEPTH, start node S, GOAL.

1. OPEN = {}, CLOSED = {};

2. Put S into OPEN, depth( S) = 0;

3. If OPEN is empty, exit (FAIL);

4. Remove topmost node from OPEN and put it into CLOSED; call it node n;

5. If depth( n) = MAX-DEPTH, go to Step 3.

6. Expand n, generating all its successors.For each successor, Snj,

Depth (Snj) = depth(n) +1make a pointer from Snj to nif Snj = GOAL, exit(SUCCESS: report all nodes from Snj to start) insert Snj at the beginning of OPEN;

7. If any successor is a dead-end, remove it from OPEN.

8. Go to step 3

Page 16: IELM 231: IT for Logistics and Manufacturing

Depth first exampleQ Q

Q

Q

Q

Q

Q

Q

a b c d e

Q Q

Q

Q

Q

Q

Q

Q

Q

Q

f g h i

fb

j

ka

f

j

ka

dc

b f

j

ka

b

dc

f

j

ka

b

dc

e

f

j

ka

c

e

d

b

g

j

ka

c

e

d

b f

j

ka

c

e

d

b f

h

g

ja

c

e

d

b f

g

h

i

ksolution

Q Q

Q

Q

Q

Q

Q

Q

a b c d e

Q Q

Q

Q

Q

Q

Q

Q

Q

Q

f g h i

fb

j

ka

f

j

ka

dc

b f

j

ka

b

dc

f

j

ka

b

dc

e

f

j

ka

c

e

d

b

g

j

ka

c

e

d

b f

j

ka

c

e

d

b f

h

g

ja

c

e

d

b f

g

h

i

ksolution

The 4 Queens problem:

Note: We can place exactly 1 Q in each row Search starts at top row MAX-DEPTH = 4

Page 17: IELM 231: IT for Logistics and Manufacturing

Summary of Depth First

Main idea:

Start at S, and put it in set OPEN

At each step:Pick FIRST element of OPEN

If it is the GOAL: we are done. Else

Expand it,Insert all the expanded nodes in the FRONT of OPEN

Exercise: Write how a depth first search of your computer’s “My Documents”folder will explore different sub-folders.

Page 18: IELM 231: IT for Logistics and Manufacturing

Breadth First: First In First Out (FIFO)

Breadth first search tree for the 4-Queens problem

a

h

c

b

gd

f j k

e

i

a

h

c

b

gd

f j k

e

i

Main idea: First explore all possible nodes at lower depth, and only then look in the next deeper level.

Page 19: IELM 231: IT for Logistics and Manufacturing

Depth first vs. Breadth first

If the search tree can be very deep, but you expect the GOAL isnot too far from the Start node, then use Breadth first

Both, LIFO and FIFO are exhaustive search methods

In the worst case, we will need to go around the entire graph to find GOAL

Both are simple to implement (in a computer program), but only useful forsmall or mid-sized problems

Page 20: IELM 231: IT for Logistics and Manufacturing

Best first: guided search methods

Main idea:

Use a Heuristic function to identify more promising paths

Explore along the more promising path first

more likely to lead to GOAL

Most popular ‘best first’ method: Branch and Bound search

Page 21: IELM 231: IT for Logistics and Manufacturing

Branch and Bound search in Scheduling

A simple job-scheduling problem: 1 machine, n tasks waiting to be done.

Pi = Process time for the i-th task

Di = Due date for the i-th task

Li = Cost charged per unit time of tardiness for task i.

Cost = (Li X t), where t = no of time units of delay

Objective: find the task sequence that will minimize the total tardiness cost

Page 22: IELM 231: IT for Logistics and Manufacturing

Background on task scheduling..

From your production controls class, recall that:

In general, for most Real-world scheduling problems, it is notpossible to find the optimum solution in reasonable time (even ifusing a super-computer)

[Why ?]

Real-world scheduling methods:

Production managers usually use some heuristic to schedule jobs

Heuristic : a sensible choice, but no guarantee of being optimal

Common heuristics: Earliest Due Date (EDD), Shortest Process Time (SPT)

Page 23: IELM 231: IT for Logistics and Manufacturing

Background on task scheduling..

Real-world scheduling heuristics:

Earliest Due Date (EDD), Shortest Process Time (SPT)

EDD: Arrange tasks in sequence of earliest due dates

Question: Using EDD or SPT, do we need to search for a solution?

SPT: Arrange tasks in sequence of increasing processing time

Page 24: IELM 231: IT for Logistics and Manufacturing

Scheduling using Branch and Bound.

An example problem Task Pi Di Li

1 37 49 1

2 27 36 5

3 1 1 1

4 28 37 5

4 tasks 4! = 24 possible sequences to do the tasks

Which is the best?

(1) We can list all permutations, calculate Tardiness Cost for each, and select the best one BUT(2) What if we had 50 tasks ? 100 tasks ?

Page 25: IELM 231: IT for Logistics and Manufacturing

Scheduling using Branch and Bound..

An example problem Task Pi Di Li

1 37 49 1

2 27 36 5

3 1 1 1

4 28 37 5

Best first searching:We need to find, for a partial solution, an estimate of how good/bad it is.

For example, suppose we decided to do task 3 first (e.g. guided by SPT)

How to estimate whether this is a good choice or not ?

Page 26: IELM 231: IT for Logistics and Manufacturing

Scheduling using Branch and Bound…

An example problem Task Pi Di Li

1 37 49 1

2 27 36 5

3 1 1 1

4 28 37 5

A backward planning approach:

Suppose we know that task 2 will be done last,What is the worst case delay cost in that case?

Answer: No matter what sequence the other tasks are done, Task 2 will begin at t=(37+1+28) = 66, and finish at t=66+27=93 Therefore Tardiness cost for Task 2 = W = (93-36)*5 = 285

Page 27: IELM 231: IT for Logistics and Manufacturing

Scheduling using Branch and Bound….

An example problem Task Pi Di Li

1 37 49 1

2 27 36 5

3 1 1 1

4 28 37 5

We can say that W is a lower bound on the total tardiness cost

We can compute W for each possible choice of “which task is done last”

We select the most promising among these choices, to explore further

At each step, we expand the node with minimum W untilthe optimum schedule is found

Page 28: IELM 231: IT for Logistics and Manufacturing

Scheduling using Branch and Bound.….

An example problem Task Pi Di Li

1 37 49 1

2 27 36 5

3 1 1 1

4 28 37 5

Position 4

Position 3

Position 2

Position 1

Node1 task 1

W = 44

Node2 task 2

W = 285

Node3 task 3

W = 92

Node4 task 4

W = 280

Node5 task 2

W = 144

Node6 task 3

W = 99

Node7 task 4

W = 139

Node19 task 1

W = 135

Node18 task 2

W = 372

Node17 task 4

W = 367

Node11 task 3

W = 172

Node12 task 4

W = 144

Node8 task 2

W = 194

Node15 task 3

W = 166

Node20 task 2

W = 235

Node21 task 4

W = 230

Node9 task 4

W = 189

Node14 task 2

W = 139

Node13 task 3

W = 144

Node10 task 2

W = 189

Node16 task 3

W = 139

Page 29: IELM 231: IT for Logistics and Manufacturing

Best first algorithm..….

Algorithm: BranchAndBound_SchedulingOPEN = {}1. Each task that may be done last is a successor of START. Construct the search tree by adding one node for each such task to START. Add each node to OPEN

2. Calculate lower bound on total penalty, W = Li ( Di - Pj -Pi), for each node found in step 1. Pj is the sum of all tasks that remain to be assigned beyond task i in the tree.

3. Let the node with the lowest W in OPEN be node k; expand k: Each successor of k is a task that is not on the path from START to k. Add pointers from each successor to k; Add each successor of k to OPEN; Calculate W for each successor: Remove k from open and put it in CLOSED;

4. Repeat step 3 until one sequence is completely determined. The cost of this solution is the Current_best.

5. Remove all nodes in OPEN with W Current_best; (these are dead-ends!)

6. If OPEN is not empty, expand the node with minimum W in OPEN, as in Step 3; Update the current minimum penalty cost if a lower penalty schedule is discovered.

Page 30: IELM 231: IT for Logistics and Manufacturing

When the search space is too large

In the worst case, branch-and-bound will take a very long time tosearch of the best solution

For example, in our scheduling problem the search space increases as n!,which is gets too large very quickly.

How to search for solutions when the space is too large to explore?

Heuristics:

Find some solution, and look for better ones in its “neighborhood”

This general idea is used in methods like Genetic Algorithms, Simulated annealing, etc.

Page 31: IELM 231: IT for Logistics and Manufacturing

Summary

What you have learnt:

- Some examples where sort and search are useful in IT apps

- How to write a simple sort function

- How to implement different types of graph searching functionsDepth first, Breadth first, and Best first

- Decide under what situation you will use which search method

Page 32: IELM 231: IT for Logistics and Manufacturing

References and Further Reading

Books:[For search methods]:Judea Pearl, Heuristics: Intelligent Search Strategies for Computer Problem Solving,Addison Wesley

Web sources:[for sorting methods]1. Wikipedia, Comb sort (wikipedia has very good article on search algorithms also)

Next: Communicating applications: The Client-Server Architecture